/*Draw Svg*/( function ( $ ) {	
	'use strict';
	$.fn.pt_plus_animated_svg = function() {
		return this.each(function() {
			var $self = $(this);
			var data_id=$self.data("id");
			var data_duration=$self.data("duration");
			var data_type=$self.data("type");
			var data_stroke=$self.data("stroke");
			var svg_fill_enable=$self.data("svg_fill_enable");
			var data_fill_color=$self.data("fill_color");
			if($self.find(".info_box_svg").length > 0){
				$self.find(".info_box_svg > svg").attr("id",data_id);
				new Vivus(data_id, {type: data_type, duration: data_duration,forceRender:false,start: 'inViewport'});
			}else{
				var drawSvg = new Vivus(data_id, {type: data_type, duration: data_duration,forceRender:false,start: 'inViewport',onReady: function (myVivus) {
					var c=myVivus.el.childNodes;
					var show_id=document.getElementById(data_id);
					if(svg_fill_enable!='' && svg_fill_enable=='yes'){
						myVivus.el.style.fillOpacity='0';
						myVivus.el.style.transition='fill-opacity 0s';
					}
					show_id.style.opacity = "1";
					if(data_stroke!=''){
						for (var i = 0; i < c.length; i++) {
							$(c[i]).attr("fill", data_fill_color);
							$(c[i]).attr("stroke",data_stroke);
							var child=c[i];
							var pchildern=child.children;
							if(pchildern != undefined){
								for(var j=0; j < pchildern.length; j++){
									$(pchildern[j]).attr("fill", data_fill_color);
									$(pchildern[j]).attr("stroke",data_stroke);
								}
							}
						}
					}
				}
				}, function (myVivus) {
					if(myVivus.getStatus() === 'end' && svg_fill_enable!='' && svg_fill_enable=='yes'){
						myVivus.el.style.fillOpacity='1';
						myVivus.el.style.transition='fill-opacity 1s';
					}
				} );
				/*window.addEventListener("scroll", function(e) {
					var scrollPercentage = (document.documentElement.scrollTop + $("#"+data_id).scrollTop()) / (document.documentElement.scrollHeight - document.documentElement.clientHeight);
					drawSvg.setFrameProgress(scrollPercentage);
				});*/
			}
		});
	};
	
	$(window).load(function() {
		setTimeout(function(){
			$('.pt_plus_row_bg_animated_svg').pt_plus_animated_svg();
			$('.pt_plus_animated_svg,.ts-hover-draw-svg').pt_plus_animated_svg();
			$('body').find('.pt_plus_row_bg_animated_svg').attr('style', 'stroke:black');
		}, 100);
	});
	$(document).ready(function() {
		$('.plus-hover-draw-svg .svg_inner_block').on("mouseenter",function() {
			var $self;
			$self = $(this).parent();
			var data_id=$self.data("id");
			var data_duration=$self.data("duration");
			var data_type=$self.data("type");
			new Vivus(data_id, {type: data_type, duration: data_duration,start: 'inViewport'}).reset().play();
		}).on("mouseleave", function() {
		});
	});
} ( jQuery ) );
