// JavaScript Document
$(window).bind("unload", function() { // ... 
		carga();						  
 });



$(window).load(function(){
						
		
		carga();
			

});



function carga(){

				
function preloadImages(id) {
    var c = new Array();
    $(id+' img').each( function(j) {
        c[j] = new Image();
        c[j].src = this.src;

        if ( $.browser.msie ) {
            this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='image',src='"+ this.src +"')"; 
        }
    });

}

preloadImages('body');
						
function imageresize() {
    posicionReal = $("#presentacioncentro").offset();
    
	if (posicionReal.top<0){
		
		$('#presentacioncentro').css("top",'0%');
		$('#presentacioncentro').css("margin-top",'0px');

	}else{
		$('#presentacioncentro').css("top",'50%');
		$('#presentacioncentro').css("margin-top",'-319px');
	}
	
	
	if ($(document).width()<=955){
		
		$('#presentacioncentro').css("left",'0%');
		$('#presentacioncentro').css("margin-left",'0px');
		$('#extrasdebajo').css("left",'0%');
		$('#extrasdebajo').css("margin-left",'0px');
		$('#extrasarriba').css("left",'0%');
		$('#extrasarriba').css("margin-left",'0px');

	}else{
		$('#presentacioncentro').css("left",'50%');
		$('#presentacioncentro').css("margin-left",'-477px');
		$('#extrasdebajo').css("left",'50%');
		$('#extrasdebajo').css("margin-left",'-477px');
		$('#extrasarriba').css("left",'50%');
		$('#extrasarriba').css("margin-left",'-477px');
		
	}
	
	//$("#info").html("LEFT: "+posicionReal.left+ " TOP: "+posicionReal.top);
}
			
			
$(window).bind("resize", function(){
			imageresize();
		});
  //llamada cuando la ventana cambia de tamaņo
imageresize();



function ufo()
{
		$('#ufo2').animate({ opacity: '1' }, {duration: 700,complete: function() {  $('#ufo2').animate({ opacity: '0' }, {duration: 600});  }});
		$('#ufo1').animate({ opacity: '1', marginTop: '-120px' , left: '670px' }, {duration: 200,specialEasing: {marginTop: 'easeOutCirc'},complete: function() {  $.timeout(function() {$('#ufo1').animate({ marginTop: '-100px' }, {duration: 600,complete: function() {$('#ufo1').animate({ marginTop: '-120px' }, {duration: 600,complete: function() {$('#ufo1').animate({ marginTop: '-90px' }, {duration: 800,complete: function() {$('#ufo1').animate({ marginTop: '-120px' }, {duration: 400,complete: function() {$('#ufo1').animate({ marginTop: '-100px' }, {duration: 300,complete: function() {$('#ufo1').animate({ marginTop: '-120px' }, {duration: 600,complete: function() {$('#ufo1').animate({ marginLeft: '-100px' }, {duration: 600,specialEasing: {marginLeft: 'easeInOutElastic'},complete: function() {$('#ufo1').animate({ marginTop: '-820px',left: '200px' }, {duration: 600,complete: function() {} });} });} });} });} });} });} });} });	 },500);
							 
																																							  
																																							  }});
	
}


function logo(paso){
	
	
	switch (paso) {
		
		case 1: 
        {
			
		$('#logo1').animate({ top: '2000px', left: '3000px' }, {duration: 16000});

		}
       break;
	   case 2: 
        {
			
		$('#logo2').animate({  top: '-200px', left: '2000px' }, {duration: 16000,specialEasing: {left: 'easeInQuad'}});

		}
       break;
	   
	   case 3: 
        {
			
		$('#logo3').animate({  left: '0px' }, {duration: 16000,specialEasing: {left: 'easeInQuad'}});

		}
       break;
	   
	   case 4: 
        {
			
		$('#logo4').animate({ left: '2400px', top: '0px' }, {duration: 16000,specialEasing: {left: 'easeInQuad'}});

		}
       break;
	   
	}
	
}

function extras(paso){
	
	velocidad2 =1.6;
	//velocidad2 =0.1;
	switch (paso) {
		
		case 1: 
        {
			
		logo(1);
		$('#semaforo').animate({ opacity: '1' }, {duration: 600});
		$('#semaforo').animate({ marginTop: '-109px' }, {duration: 1000,specialEasing: {marginTop: 'easeInOutBack'},complete: function() {$.timeout(function() {extras(2); }, 500*velocidad2);}});
		}
       break;
	   case 2: 
        {
		
		$('#english').animate({ opacity: '1', marginTop: '0px', marginLeft: '-90px' }, {duration: 600,specialEasing: {marginLeft: 'easeInQuad'},complete: function() {$.timeout(function() {extras(3); }, 500*velocidad2);}});
		
		}
       break;
	   case 3: 
        {
		
		$('#cable').animate({ opacity: '1',  marginLeft: '-109px' }, {duration: 100,specialEasing: {marginLeft: 'easeInOutBack'},complete: function() {$.timeout(function() {extras(4); }, 500*velocidad2);}});
		
		}
       break;
	   case 4: 
        {
		
		$('#estrellaabajo').animate({ opacity: '1',  marginLeft: '160px' }, {duration: 400,specialEasing: {marginLeft: 'easeInOutBack'},complete: function() {$.timeout(function() {extras(5); }, 500*velocidad2);}});
		
		}
       break;
	   case 5: 
        {
		
		$('#palo').animate({ opacity: '1',  marginTop: '-109px' }, {duration: 400,specialEasing: {marginLeft: 'easeInOutBack'},complete: function() {$.timeout(function() {extras(6); }, 500*velocidad2);}});
		
		}
       break;
	   case 6: 
        {
		
		$('#tele').animate({ opacity: '1', marginTop: '-80px' }, {duration: 600,specialEasing: {marginLeft: 'easeInOutElastic'},complete: function() {$.timeout(function() {extras(7); }, 500*velocidad2);}});
		
		}
       break;
	   
	   case 7: 
        {
		logo(2);
		$('#estrella').animate({ opacity: '1', marginTop: '-80px' }, {duration: 600,specialEasing: {marginLeft: 'easeInOutElastic'},complete: function() {$.timeout(function() {extras(8); }, 500*velocidad2);}});
		
		}
       break;
	   
		case 8: 
        {
		$('#senal').animate({ opacity: '1' }, {duration: 600});
		$('#senal').animate({ marginTop: '-109px' }, {duration: 1000,specialEasing: {marginTop: 'easeInOutBack'},complete: function() {$.timeout(function() {extras(9); }, 500*velocidad2);}});
		}
       break;
	   
	   case 9: 
        {
		$('#stop').animate({ opacity: '1' }, {duration: 600});
		$('#stopimg').animate({ height: '157px', width: '157px' }, {duration: 600,specialEasing: {height: 'easeInOutElastic'},complete: function() {$.timeout(function() {extras(10); }, 500*velocidad2);}});
		 $('#palo').animate({ opacity: '0' }, {duration: 300});
		}
       break;
	   
	   case 10: 
        {
		$('#under').animate({ opacity: '1',  marginLeft: '120px' }, {duration: 100,specialEasing: {marginLeft: 'easeInOutBack'},complete: function() {$.timeout(function() {extras(11); }, 500*velocidad2);}});
       $('#globo').animate({ top: '-400px' }, {duration: 20000});
	    $('#tele').animate({ opacity: '0' }, {duration: 300});
		}
       break;
	   
	    case 11: 
        {
			logo(3);
			$('#bigben').animate({ opacity: '1',marginTop: '-180px' }, {duration: 1000,specialEasing: {marginTop: 'easeInOutBack'},complete: function() {$.timeout(function() {extras(12); }, 500*velocidad2);}});
			
		}
       break;
	   
	   
	   case 12: 
        {
		
	    $('#estrellaabajo').animate({ opacity: '0' }, {duration: 300,specialEasing: {marginLeft: 'easeInOutBack'},complete: function() {$.timeout(function() {extras(13); }, 500*velocidad2);}});
		$('#stop').animate({ opacity: '0' }, {duration: 300});
		ufo();
		}
       break;
	   
	    case 13: 
        {
		$('#pintura').animate({ opacity: '1',  marginLeft: '-90px' }, {duration: 100,specialEasing: {marginLeft: 'easeInOutBack'},complete: function() {$.timeout(function() {extras(14); }, 500*velocidad2);}});
	    $('#semaforo').animate({ opacity: '0' }, {duration: 300});
		}
       break;
	   
	   
	   case 14: 
        {
		$('#pintura').animate({ opacity: '1',  marginLeft: '-90px' }, {duration: 100,specialEasing: {marginLeft: 'easeInOutBack'},complete: function() {$.timeout(function() {extras(15); }, 2500*velocidad2);}});
	    $('#estrella').animate({ opacity: '0' }, {duration: 300});
		$('#cable').animate({ opacity: '0' }, {duration: 300});
		}
       break;
	   
	   case 15: 
        {
		$('#foto').animate({ opacity: '1' }, {duration: 600,complete: function() {$.timeout(function() {extras(16); }, 2500*velocidad2);}});
	    $('#english').animate({ opacity: '0' }, {duration: 300});
		
		}
       break;
	   
	   
	    case 16: 
        {
			logo(4);
		$('#cabina').animate({ opacity: '1' }, {duration: 600,complete: function() {$.timeout(function() {extras(17); }, 2500*velocidad2);}});
	    
		
		}
       break;
	   
	   
	    case 17: 
        {
		$('#sello').animate({ opacity: '1' }, {duration: 600,complete: function() {$.timeout(function() {extras(18); }, 2500*velocidad2);}});
	    $('#senal').animate({ opacity: '0' }, {duration: 300});
		
		}
       break;
	   
	   case 18: 
        {
		$('#estmar').animate({ opacity: '1' }, {duration: 600,complete: function() {$.timeout(function() {extras(19); }, 2500*velocidad2);}});
	   
		
		}
       break;
	   
	   case 99: 
        {
		 $('#semaforo').animate({ opacity: '0' }, {duration: 300});
		 $('#english').animate({ opacity: '0' }, {duration: 300});
		 $('#cable').animate({ opacity: '0' }, {duration: 300});
		 $('#estrellaabajo').animate({ opacity: '0' }, {duration: 300});
		 $('#palo').animate({ opacity: '0' }, {duration: 300});
		 $('#tele').animate({ opacity: '0' }, {duration: 300});
		 $('#estrella').animate({ opacity: '0' }, {duration: 300});
		 $('#senal').animate({ opacity: '0' }, {duration: 300});
		 $('#stop').animate({ opacity: '0' }, {duration: 300});
		 $('#under').animate({ opacity: '0' }, {duration: 300});
		  $('#bigben').animate({ opacity: '0' }, {duration: 300});
		  $('#pintura').animate({ opacity: '0' }, {duration: 300});
		  $('#foto').animate({ opacity: '0' }, {duration: 300});
		  $('#cabina').animate({ opacity: '0' }, {duration: 300});
		  $('#sello').animate({ opacity: '0' }, {duration: 300});
		   $('#estmar').animate({ opacity: '0' }, {duration: 300});

		}
       break;
	   
	}
	
}
	

	
						
function presentacion(paso){


velocidad =0.8;

switch (paso) {
	
	
	
	
    case 1: //sacamos el logo
        {
		$('#logomini').animate({ marginTop: '-75px' }, {duration: 1300,specialEasing: {marginTop: 'easeInOutBack'},complete: function() {$.timeout(function() {presentacion(2); }, 1500*velocidad);}});
		}
       break;
		
	
	 case 2: //ocultamos el logo
	{
      
	  $('#logomini').animate({ opacity: '0' }, {duration: 300,complete: function() {$.timeout(function() {presentacion(3); }, 100*velocidad);}});
	   
	}
	 break;
	 
	 
	 
    case 3: //sacamos la caja
	{
      
	  $('#caja').animate({ width: '955px',height: '639px' }, {duration: 100,specialEasing: {marginTop: 'easeInOutBack'},complete: function() {$.timeout(function() {presentacion(4); }, 1000*velocidad);}});
	  $('#sombra').animate({ opacity: '1' }, {duration: 200});
	}
    break;
	
	
	
	
    case 4://mostramos la primera diapositiva
	{
	 
     $('#dia1').animate({ opacity: '1' }, {duration: 200,complete: function() {$.timeout(function() {presentacion(5); }, 1000*velocidad);}});
	 $('#saltar').animate({ opacity: '1' }, {duration: 600});
	 extras(1);
	}
	 break;
	 
	 case 5:
	{
		
     $('#fondofrase1').animate({ left: '-140px' }, {duration: 200,complete: function() {$.timeout(function() {presentacion(6); }, 3000*velocidad);}});
	  $('#frase1').animate({ left: '60px' }, {duration: 600});
	}
	 break;
	 
	 
	 case 6:
	{
		
     $('#fondofrase1').animate({ opacity: '0' }, {duration: 600,complete: function() {$.timeout(function() {presentacion(7); }, 500*velocidad);}});
	  $('#frase1').animate({ opacity: '0' }, {duration: 300});
	}
	 break;
	 
	case 7:
	{
		
		
     $('#dia1').animate({ opacity: '0' }, {duration: 600,complete: function() {$.timeout(function() {presentacion(8); }, 1000*velocidad);}});
	 $('#dia2').animate({ opacity: '1' }, {duration: 600});
	}
	 break;
	 
	 case 8:
	{
		
     $('#fondofrase2').animate({ left: '-140px' }, {duration: 200,complete: function() {$.timeout(function() {presentacion(9); }, 3000*velocidad);}});
	  $('#frase2').animate({ left: '60px' }, {duration: 600});
	}
	 break;
	 
	 
	 case 9:
	{
		
     $('#fondofrase2').animate({ opacity: '0' }, {duration: 600,complete: function() {$.timeout(function() {presentacion(10); }, 500*velocidad);}});
	  $('#frase2').animate({ opacity: '0' }, {duration: 300});
	}
	 break;
	 
	case 10:
	{
		
		
     $('#dia2').animate({ opacity: '0' }, {duration: 600,complete: function() {$.timeout(function() {presentacion(11); }, 1000*velocidad);}});
	 $('#dia3').animate({ opacity: '1' }, {duration: 600});
	}
	 break;
	 
	 case 11:
	{
		
     $('#fondofrase3').animate({ right: '-110px' }, {duration: 200,complete: function() {$.timeout(function() {presentacion(12); }, 3000*velocidad);}});
	  $('#frase3').animate({ right: '60px' }, {duration: 600});
	}
	 break;
	 
	 
	 case 12:
	{
		
     $('#fondofrase3').animate({ opacity: '0' }, {duration: 600,complete: function() {$.timeout(function() {presentacion(13); }, 500*velocidad);}});
	  $('#frase3').animate({ opacity: '0' }, {duration: 300});
	}
	 break;
	 
	case 13:
	{
		
		
     $('#dia3').animate({ opacity: '0' }, {duration: 600,complete: function() {$.timeout(function() {presentacion(14); }, 1000*velocidad);}});
	 $('#dia4').animate({ opacity: '1' }, {duration: 600});
	}
	 break;
	 
	 case 14:
	{
		
     $('#fondofrase4').animate({ left: '-140px' }, {duration: 200,complete: function() {$.timeout(function() {presentacion(15); }, 3000*velocidad);}});
	  $('#frase4').animate({ left: '80px' }, {duration: 600});
	}
	 break;
	 
	 
	 
	 case 15:
	{
		
     $('#fondofrase4').animate({ opacity: '0' }, {duration: 600,complete: function() {$.timeout(function() {presentacion(16); }, 500*velocidad);}});
	  $('#frase4').animate({ opacity: '0' }, {duration: 300});
	}
	 break;
	 
	case 16:
	{
		
		
     $('#dia4').animate({ opacity: '0' }, {duration: 600,complete: function() {$.timeout(function() {presentacion(17); }, 1000*velocidad);}});
	 $('#dia5').animate({ opacity: '1' }, {duration: 600});
	}
	 break;
	 
	 case 17:
	{
		
     $('#fondofrase5').animate({ right: '-110px' }, {duration: 200,complete: function() {$.timeout(function() {presentacion(18); }, 3000*velocidad);}});
	  $('#frase5').animate({ right: '60px' }, {duration: 600});
	}
	 break;
	 
	 case 18:
	{
		
     $('#fondofrase5').animate({ opacity: '0' }, {duration: 600,complete: function() {$.timeout(function() {presentacion(19); }, 500*velocidad);}});
	  $('#frase5').animate({ opacity: '0' }, {duration: 300});
	}
	 break;
	 
	 case 19:
	{
		
		
     $('#dia5').animate({ opacity: '0' }, {duration: 600,complete: function() {$.timeout(function() {presentacion(20); }, 1000*velocidad);}});
	 $('#dia6').animate({ opacity: '1' }, {duration: 600});
	}
	 break;
	 
	 case 20:
	{
		
     $('#fondofrase6').animate({ left: '-140px' }, {duration: 200,complete: function() {$.timeout(function() {presentacion(21); }, 3000*velocidad);}});
	  $('#frase6').animate({ left: '60px' }, {duration: 600});
	}
	 break;
	 
	  case 21:
	{
		
     $('#fondofrase6').animate({ opacity: '0' }, {duration: 600,complete: function() {$.timeout(function() {presentacion(22); }, 500*velocidad);}});
	  $('#frase6').animate({ opacity: '0' }, {duration: 300});
	}
	 break;
	 
	 case 22:
	{
		
		
     $('#dia6').animate({ opacity: '0' }, {duration: 600,complete: function() {$.timeout(function() {presentacion(23); }, 1000*velocidad);}});
	 $('#dia7').animate({ opacity: '1' }, {duration: 600});
	}
	 break;
	 
	 case 23:
	{
		
     $('#fondofrase7').animate({ right: '-110px' }, {duration: 200,complete: function() {$.timeout(function() {presentacion(24); }, 3000*velocidad);}});
	  $('#frase7').animate({ right: '60px' }, {duration: 600});
	}
	 break;
	 
	 case 24:
	{
		
     $('#fondofrase7').animate({ opacity: '0' }, {duration: 600,complete: function() {$.timeout(function() {presentacion(25); }, 500*velocidad);}});
	  $('#frase7').animate({ opacity: '0' }, {duration: 300});
	}
	 break;
	 
	 case 25:
	{
		
		
     $('#dia7').animate({ opacity: '0' }, {duration: 600,complete: function() {$.timeout(function() {presentacion(26); }, 1000*velocidad);}});
	 $('#dia8').animate({ opacity: '1' }, {duration: 600});
	}
	 break;
	 
	 case 26:
	{
		
     $('#fondofrase8').animate({ left: '-140px' }, {duration: 200,complete: function() {$.timeout(function() {presentacion(27); }, 3000*velocidad);}});
	  $('#frase8').animate({ left: '60px' }, {duration: 600});
	}
	 break;
	 
	 
	 case 27:
	{
		
     $('#fondofrase8').animate({ opacity: '0' }, {duration: 600,complete: function() {$.timeout(function() {presentacion(28); }, 500*velocidad);}});
	  $('#frase8').animate({ opacity: '0' }, {duration: 300});
	}
	 break;
	 
	 case 28:
	{
		
	extras(99);
     $('#dia8').animate({ opacity: '0' }, {duration: 600,complete: function() {$.timeout(function() {presentacion(29); }, 1000*velocidad);}});
	 $('#saltar').animate({ opacity: '0' }, {duration: 600});
	 
	}
	 break;
	
	  case 29:
	{
		
		
      $('#caja').animate({ width: '0px',height: '0px' }, {duration: 300,specialEasing: {marginTop: 'easeInElastic'},complete: function() {$.timeout(function() {presentacion(30); }, 1000*velocidad);}});
	 $('#sombra').animate({ opacity: '0' }, {duration: 200});
	}
	 break;
	 
	 case 30:
	{
		
		window.location.href = 'index2.php';
	}
	 break;
    
       
} // fin de switch


}// fin de funcion presentacion





presentacion(pres);

}
