var tempor = null;
var contador=2;
var anterio=0;
var navegador = navigator.appName;
var dispositivo = navigator.userAgent.toLowerCase();

	function cambiar_fondo(){
			
			imagen="url("+dirImg+contador+extImg+")";
			document.getElementById('cap2').style.backgroundImage=imagen;
			palabra=/pad/;
			if(palabra.test(dispositivo)){
						document.getElementById('cap2').style.opacity = 0;
						detener_videoIPAD();
			}else{
				if (navegador == "Microsoft Internet Explorer"){
						document.getElementById('cap2').style.filter='alpha(opacity=0)';
						detener_video();
						
					}
				else{
						document.getElementById('cap2').style.opacity = 0;
						detener_videom();
					}
			}
				return false;
		}
		
//IPAD*******************************************************************************************
			function  detener_videoIPAD(){
			$("#jquery_jplayer_1").jPlayer("stop");
			document.getElementById('video').style.opacity = 0;			
			tempor = setTimeout("paso4IPAD(0.01)",(33*1000));
			return false;}
			
			function paso1IPAD(n){
			if(anterio!=1){
			document.getElementById('cap2').style.display="block";
			document.getElementById('cap2').style.opacity = n;
			n=n+0.01;
			if(n<1)
				tempor = setTimeout("paso1IPAD("+n+")",1);
			else{
					imagen=document.getElementById('cap2').style.backgroundImage;
					document.getElementById('cap1').style.backgroundImage=imagen;
					document.getElementById('cap2').style.opacity = 0;
					if(contador<cantImg)
						contador=contador+1;
					else
						contador=1;
					imagen="url("+dirImg+contador+extImg+")";
					document.getElementById('cap2').style.backgroundImage=imagen;
					tempor = setTimeout("paso2IPAD(0.01)",(segTra*1000));
					
				}
			}
			anterio=0;
			return false;
		}
		
		function paso2IPAD(n){
			if(anterio!=1){
			document.getElementById('cap2').style.display="block";
			document.getElementById('cap2').style.opacity = n;
			n=n+0.01;
			if(n<1){
				tempor = setTimeout("paso2IPAD("+n+")",1);}
			else{
			$("#jquery_jplayer_1").jPlayer("play");
				document.getElementById('video').style.opacity = 1;
				tempor = setTimeout("paso3IPAD()",(50*1000));}
			
			}
			anterio=0;
			return false;
		}
		
		function paso3IPAD(){
			$("#jquery_jplayer_1").jPlayer("stop");
			document.getElementById('video').style.opacity = 0;			
			document.getElementById('cap2').style.display="none";
			imagen=document.getElementById('cap2').style.backgroundImage;
			document.getElementById('cap1').style.backgroundImage=imagen;
			document.getElementById('cap2').style.opacity = 0;
			if(contador<cantImg)
				contador=contador+1;
			else
				contador=1;
			imagen="url("+dirImg+contador+extImg+")";
			document.getElementById('cap2').style.backgroundImage=imagen;
			tempor = setTimeout("paso4IPAD(0.01)",(segTra*1000));
			}
			
		function paso4IPAD(n){
			if(anterio!=1){
			document.getElementById('cap2').style.display="block";
			document.getElementById('cap2').style.opacity = n;
			n=n+0.01;
			if(n<1)
				tempor = setTimeout("paso4IPAD("+n+")",1);
			else{
					imagen=document.getElementById('cap2').style.backgroundImage;
					document.getElementById('cap1').style.backgroundImage=imagen;
					document.getElementById('cap2').style.opacity = 0;
					if(contador<cantImg)
						contador=contador+1;
					else
						contador=1;
					imagen="url("+dirImg+contador+extImg+")";
					document.getElementById('cap2').style.backgroundImage=imagen;
					tempor = setTimeout("paso1IPAD(0.01)",(segTra*1000));
					
				}
			}
			anterio=0;
			return false;
		}
		
//IE*******************************************************************************************
		function  detener_video(){
			$("#jquery_jplayer_1").jPlayer("stop");
			document.getElementById('video').style.opacity = 0;			
			tempor = setTimeout("paso4(0.01)",(33*1000));
			return false;}


		function paso1(n){	
			document.getElementById('cap2').style.display="block";
			document.getElementById('cap2').style.filter='alpha(opacity='+n+')';
			n=n+1;
			if(n<100){
				tempor = setTimeout("paso1("+n+")",1);}
			else{
					imagen=document.getElementById('cap2').style.backgroundImage;
					document.getElementById('cap1').style.backgroundImage=imagen;
					document.getElementById('cap2').style.filter='alpha(opacity=0)';
					if(contador<cantImg)
						contador=contador+1;
					else
						contador=1;
					imagen="url("+dirImg+contador+extImg+")";
					document.getElementById('cap2').style.backgroundImage=imagen;
					tempor = setTimeout("paso2(1)",(segTra*1000));
				}
			return false;
		}
		function paso2(n){	
			document.getElementById('cap2').style.display="block";
			document.getElementById('cap2').style.filter='alpha(opacity='+n+')';
			n=n+1;
			if(n<100){
				tempor = setTimeout("paso2("+n+")",1);}
			else{
					document.getElementById('video').style.display="block";
					$("#jquery_jplayer_1").jPlayer("play");
					tempor = setTimeout("paso3m()",(33*1000));
				}
			return false;}
		
		function paso3(){
			$("#jquery_jplayer_1").jPlayer("stop");
			document.getElementById('video').style.display="none";
			document.getElementById('cap2').style.display="none";
			imagen=document.getElementById('cap2').style.backgroundImage;
			document.getElementById('cap1').style.backgroundImage=imagen;
			document.getElementById('cap2').style.filter='alpha(opacity=0)';
			if(contador<cantImg)
				contador=contador+1;
			else
				contador=1;
			imagen="url("+dirImg+contador+extImg+")";
			document.getElementById('cap2').style.backgroundImage=imagen;
			tempor = setTimeout("paso3(1)",(segTra*1000));}
		
		function paso4(n){	
			document.getElementById('cap2').style.display="block";
			document.getElementById('cap2').style.filter='alpha(opacity='+n+')';
			n=n+1;
			if(n<100){
				tempor = setTimeout("paso4("+n+")",1);}
			else{
					imagen=document.getElementById('cap2').style.backgroundImage;
					document.getElementById('cap1').style.backgroundImage=imagen;
					document.getElementById('cap2').style.filter='alpha(opacity=0)';
					if(contador<cantImg)
						contador=contador+1;
					else
						contador=1;
					imagen="url("+dirImg+contador+extImg+")";
					document.getElementById('cap2').style.backgroundImage=imagen;
					tempor = setTimeout("paso1(1)",(segTra*1000));
				}
			return false;
		}
		
//nestcape******************************************************************************************************************
function  detener_videom(){
			$("#jquery_jplayer_1").jPlayer("stop");
			document.getElementById('video').style.opacity = 0;			
			tempor = setTimeout("paso4m(0.01)",(33*1000));
			return false;}

		function paso1m(n){
			if(anterio!=1){
			document.getElementById('cap2').style.display="block";
			document.getElementById('cap2').style.opacity = n;
			n=n+0.01;
			if(n<1)
				tempor = setTimeout("paso1m("+n+")",1);
			else{
					imagen=document.getElementById('cap2').style.backgroundImage;
					document.getElementById('cap1').style.backgroundImage=imagen;
					document.getElementById('cap2').style.opacity = 0;
					if(contador<cantImg)
						contador=contador+1;
					else
						contador=1;
					imagen="url("+dirImg+contador+extImg+")";
					document.getElementById('cap2').style.backgroundImage=imagen;
					tempor = setTimeout("paso2m(0.01)",(segTra*1000));
					
				}
			}
			anterio=0;
			return false;
		}
		
		function paso2m(n){
			if(anterio!=1){
			document.getElementById('cap2').style.display="block";
			document.getElementById('cap2').style.opacity = n;
			n=n+0.01;
			if(n<1){
				tempor = setTimeout("paso2m("+n+")",1);}
			else{
				document.getElementById('video').style.display="block";
				$("#jquery_jplayer_1").jPlayer("play");
				tempor = setTimeout("paso3m()",(33*1000));}
			
			}
			anterio=0;
			return false;
		}
		
		function paso3m(){
			$("#jquery_jplayer_1").jPlayer("stop");
			document.getElementById('video').style.display="none";	
			document.getElementById('cap2').style.display="none";
			imagen=document.getElementById('cap2').style.backgroundImage;
			document.getElementById('cap1').style.backgroundImage=imagen;
			document.getElementById('cap2').style.opacity = 0;
			if(contador<cantImg)
				contador=contador+1;
			else
				contador=1;
			imagen="url("+dirImg+contador+extImg+")";
			document.getElementById('cap2').style.backgroundImage=imagen;
			tempor = setTimeout("paso4m(0.01)",(segTra*1000));
			}
			
		function paso4m(n){
			if(anterio!=1){
			document.getElementById('cap2').style.display="block";
			document.getElementById('cap2').style.opacity = n;
			n=n+0.01;
			if(n<1)
				tempor = setTimeout("paso4m("+n+")",1);
			else{
					imagen=document.getElementById('cap2').style.backgroundImage;
					document.getElementById('cap1').style.backgroundImage=imagen;
					document.getElementById('cap2').style.opacity = 0;
					if(contador<cantImg)
						contador=contador+1;
					else
						contador=1;
					imagen="url("+dirImg+contador+extImg+")";
					document.getElementById('cap2').style.backgroundImage=imagen;
					tempor = setTimeout("paso1m(0.01)",(segTra*1000));
					
				}
			}
			anterio=0;
			return false;
		}
		
