/*///  _IMAGEN  ////*/	

var cual_IMAGEN=1;	
var lapso_IMAGEN=2000;
var ancho_IMAGEN=0;
function muestro_IMAGEN_Check(){	
			
		clearInterval(timer_IMAGEN);			
		cual_IMAGEN++
		
		if(cual_IMAGEN>(total_IMAGEN)){
			cual_IMAGEN=1;	
		}
		
		cambio_IMAGEN(cual_IMAGEN,((cual_IMAGEN*ancho_IMAGEN)-ancho_IMAGEN)*-1);
		lapso_IMAGEN=7*ancho_IMAGEN;
		creoInterval_IMAGEN();	
		
}		

function creoInterval_IMAGEN(){
	timer_IMAGEN = setInterval("muestro_IMAGEN_Check()", lapso_IMAGEN);
}

function inicializo_IMAGEN(){
	
	total_IMAGEN=$j('#slide-imagen .imagen').length;
	ultimo_IMAGEN=1;
	ancho_IMAGEN=$j('#galeria').width();
	
	if(total_IMAGEN>1){
		
		play_IMAGEN = $j("#play-imagenes");
		
		for(var i=1;i<=(total_IMAGEN);i++){
								
			var bot_IMAGEN = $j("#imagen-b-"+i);
			
			bot_IMAGEN.data('id',i);
			bot_IMAGEN.data('pos',((i*ancho_IMAGEN)-ancho_IMAGEN)*-1);						
			
			bot_IMAGEN.bind("mouseenter", function(event){	
				cual_IMAGEN=$j(this).data('id');
				cambio_IMAGEN($j(this).data('id'),$j(this).data('pos')); 				
				
				if(play_IMAGEN.hasClass("pausa")){
					
					clearInterval(timer_IMAGEN);			
					play_IMAGEN.removeClass("pausa");
					play_IMAGEN.addClass("play");
					play_IMAGEN.attr("title","play");	
					
				}
				
				return false;			
			});
			
			bot_IMAGEN.click(function(){
				cual_IMAGEN=$j(this).data('id');
				cambio_IMAGEN($j(this).data('id'),$j(this).data('pos')); 				
				
				if(play_IMAGEN.hasClass("pausa")){
					
					clearInterval(timer_IMAGEN);			
					play_IMAGEN.removeClass("pausa");
					play_IMAGEN.addClass("play");
					play_IMAGEN.attr("title","play");
										
				}
				
				return false;			
			});
			
				
		}	
		
		play_IMAGEN.click(function(){
				
				if($j(this).hasClass("play")){
					lapso_IMAGEN=100;
					creoInterval_IMAGEN();
					$j(this).removeClass("play");
					$j(this).addClass("pausa");	
					$j(this).attr("title","pausa");				
				}else{
					clearInterval(timer_IMAGEN);
					$j(this).removeClass("pausa");
					$j(this).addClass("play");
					$j(this).attr("title","play");		
				}
				
				return false;
				
		});
		
		creoInterval_IMAGEN();
	}
	
}

function cambio_IMAGEN(cual,donde){
	
	if(ultimo_IMAGEN!=cual){		
		
		var slide_IMAGEN = $j("#slide-imagen");		
		
		if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {			
			slide_IMAGEN.css({'-webkit-transform':'translateX('+donde+'px)','-webkit-transition':'-webkit-transform .6s ease-in-out'});		
		}else{				
			//slide_IMAGEN.css({'-moz-transform':'translateX('+donde+'px)', '-moz-transition':'-moz-transform 1s ease-in-out'});
			slide_IMAGEN.stop(true,false).animate({left: donde}, 600,'easeInOutExpo');		
		}
		
		$j("#imagen-b-"+cual).addClass("seleccionado");		
		$j("#imagen-b-"+ultimo_IMAGEN).removeClass("seleccionado");
		
		ultimo_IMAGEN=cual;					
						
	}

}

function inicializo_NAV(){
	
	var play_IMAGEN = $j("#play-imagenes");
	var bot_galeria = $j("#bot_galeria");
	var bot_video = $j("#bot_video");
	
	var galeria = $j("#galeria");
	var video = $j("#video");
	
	bot_galeria.click(function(){					
	  if($j(this).hasClass("presionado")){		
		  		
	  }else{		 
		  $j(this).addClass("presionado");	
		  bot_video.removeClass("presionado");
		  galeria.slideDown(400,'easeInOutExpo');
	  }
	  
	  return false;
					
	});
	
	bot_video.click(function(){					
	  if($j(this).hasClass("presionado")){			 
		  		
	  }else{	
	  	 
		  $j(this).addClass("presionado");	
		  bot_galeria.removeClass("presionado");		  
		  galeria.slideUp(400,'easeInOutExpo');		  
		  video.css({'visibility':'visible'});
		  
		  if(play_IMAGEN.hasClass("pausa")){
					
			  clearInterval(timer_IMAGEN);			
			  play_IMAGEN.removeClass("pausa");
			  play_IMAGEN.addClass("play");
			  play_IMAGEN.attr("title","play");	
			  
		  }
		  	  
	  }
	  
	  return false;
					
	});

}

function inicializo_COMPLETO(){	
	
	var bot_completo = $j("#bot_completo");
	var completo = $j("#completo");	
	
	bot_completo.click(function(){					
	  if($j(this).hasClass("presionado")){		
		  $j(this).removeClass("presionado");		  
		  completo.slideUp(400,'easeInOutExpo');		  
	  }else{		 
		  $j(this).addClass("presionado");		 	
		  completo.slideDown(400,'easeInOutExpo');
	  }
	  
	  return false;
					
	});

}


function inicializo_CONFIGURACION_DE_COMPRA(){
	
	var total_TIPOS=$j('.configuracion .tipos dd').length;
	
	if(total_TIPOS>0){
		
		for(var i=1;i<=(total_TIPOS);i++){
								
			var bot_TIPOS = $j("#switch-"+i);
			var cont_TIPOS = $j("#conf-"+i);
			var bot_CON_TRASLADO = $j("#con-traslado-"+i);
			var bot_SIN_TRASLADO = $j("#sin-traslado-"+i);
			var bot_INFO_TRASLADO = $j("#mas-info-traslados-"+i);
			var info_TRASLADOS= $j("#info-traslados-"+i);
			
			var total_CONF=$j("#conf-"+i+" ul li").length;
			
			for(var j=1;j<=total_CONF;j++){
				
				var bot_CONF = $j("#switch-"+i+"-"+j);
				var cont_CONF = $j("#conf-"+i+"-"+j);
				
				if(total_CONF>1 && j==1){
					cont_CONF.css({'display':'none'});
				}
				bot_CONF.data('padre',i);
				bot_CONF.data('id',j);
				
				bot_CONF.click(function(){				
					cambio_CONF($j(this).data('id'),$j(this).data('padre'));			
					return false;						
				});	
				
			}
			
			
			cont_TIPOS.css({'display':'none'});			
			info_TRASLADOS.css({'display':'none'});
			
			bot_TIPOS.data('id',i);					
			
			bot_TIPOS.click(function(){				
				cambio_TIPOS($j(this).data('id'));				
				return false;						
			});		
						
								
			bot_CON_TRASLADO.data('id',i);	
			bot_SIN_TRASLADO.data('id',i);	
			
			bot_CON_TRASLADO.click(function(){				
				switch_TRASLADO($j(this).data('id'));				
			});
			bot_SIN_TRASLADO.click(function(){				
				switch_TRASLADO($j(this).data('id'));				
			});
			
			bot_INFO_TRASLADO.data('id',i);
			
			bot_INFO_TRASLADO.click(function(){				
				switch_INFO_TRASLADO($j(this).data('id'));
				return false;				
			});
		}	
		
		
	}
	
}


function cambio_TIPOS(este){
	
	var bot_TIPOS = $j("#switch-"+este);
	var cont_TIPOS = $j("#conf-"+este);			
	
	if(bot_TIPOS.hasClass("switch")){					
					
		bot_TIPOS.removeClass("switch");
		bot_TIPOS.addClass("abierto");	
		cont_TIPOS.slideDown(400,'easeInOutExpo');
			  
	}else{
		
		bot_TIPOS.removeClass("abierto");
		bot_TIPOS.addClass("switch");	
		cont_TIPOS.slideUp(400,'easeInOutExpo');
		
	}
		  	 
	
}
function cambio_CONF(este,papa){
	
	var bot_TIPOS = $j("#switch-"+papa+"-"+este);
	var cont_TIPOS = $j("#conf-"+papa+"-"+este);
	
	if(bot_TIPOS.hasClass("switch2")){					
					
		bot_TIPOS.removeClass("switch2");
		bot_TIPOS.addClass("abierto2");	
		cont_TIPOS.slideDown(400,'easeInOutExpo');		
			  
	}else{
		
		bot_TIPOS.removeClass("abierto2");
		bot_TIPOS.addClass("switch2");	
		cont_TIPOS.slideUp(400,'easeInOutExpo');
		
	}
		  	 
	
}

function switch_TRASLADO(este){
	 
	var bot_TRASLADO=$j("#con-traslado-"+este);
	var hoteles_TRASLADO=$j("#hoteles-"+este);
	
	if(bot_TRASLADO.is(':checked')) { 		   
		hoteles_TRASLADO.slideDown(400,'easeInOutExpo');
	} else {		   
		hoteles_TRASLADO.slideUp(400,'easeInOutExpo');
	}		  	 
	
}

function switch_INFO_TRASLADO(este){
	 
	var bot_INFO_TRASLADO = $j("#mas-info-traslados-"+este);
	var info_TRASLADOS= $j("#info-traslados-"+este);
	
	if(info_TRASLADOS.css("display")=="none") { 		   
		info_TRASLADOS.slideDown(400,'easeInOutExpo');
	} else {		   
		info_TRASLADOS.slideUp(400,'easeInOutExpo');
	}		  	 
	
}


function inicializo_RESUMEN_DE_COMPRA(){
	
	var $win = $j(window);
	var $doc = $j(document);
	var resumen = $j("#resumen");
	var donde=43;
	
	$win.scroll(function () {
		
	   if ($win.scrollTop() >= 230){
							  
		  if($win.height() > resumen.height()){					
			 donde=$win.scrollTop()-180
			 
		  }else{
			 donde=43;
		  }		  									
	   }else {			 
		 donde=43;
	   }	   
	   
	   if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {			
			resumen.css({'-webkit-transform':'translateY('+(donde-43)+'px)', '-webkit-transition':'-webkit-transform .4s ease-in-out'});		
		}else{		
			//resumen.css({'-moz-transform':'translateY('+donde+'px)', '-moz-transition':'-moz-transform .4s ease-in-out'});		
			resumen.stop(true,false).delay(300).animate({"margin-top": donde}, 400,'easeInOutExpo');		
		}
	   
	});
}




$j(document).ready(function(){
	
	
	if($j("#slide-imagen").length){
		inicializo_IMAGEN();
	}
	if($j("#nav-multimedia dd").length>0){
		inicializo_NAV();
	}
	if($j("#completo").length){
		inicializo_COMPLETO();
	}
   if($j(".configuracion .tipos").length){
		inicializo_CONFIGURACION_DE_COMPRA();
   }
    if($j("#resumen").length){
		inicializo_RESUMEN_DE_COMPRA()
   }   
   
   $j("a[rel=mapa]").fancybox({
		'titlePosition'	: 'over',
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'				
	}); 
	
	if($j("#togle_enviar_por_email").length){		
		$j("#togle_enviar_por_email").click(function(){ $j("#enviar-por-email").slideToggle(400,'easeInOutExpo'); return false;});     
	}
	
	if($j("#ver-comentarios").length){
		$j("#comentarios").css({"display":"none"});
		$j("#ver-comentarios").click(function(){ $j("#comentarios").slideToggle(400,'easeInOutExpo'); return false;});     
	}
	
	if($j("#formulario-resumen").length){		
		$j("#formulario-resumen").css({"display":"none"});
		$j("#ingrese-form-resumen").click(function(){ $j("#formulario-resumen").slideToggle(400,'easeInOutExpo'); return false;});     
	}
	if($j("#terminos-y-condiciones").length){		
		$j("#terminos-y-condiciones").css({"display":"none"});
		$j("#ver-terminos").click(function(){ $j("#terminos-y-condiciones").slideToggle(400,'easeInOutExpo'); return false;});     
	}
	
 });
			
					
