var comboAdultos = "<option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option>";
var comboMenores = "<option value='0'>0</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option>";
var current_promotion = 2;
var timer = setTimeout("animatePromotions()",7000);

var curHotel = -1;

$(function(){	
	var h = $("#container").height();
	h = (h * 1) - 15;	
	$("#main_left").attr("style","height: " + h + "px");
	var hr = (h * 1) - 10;
	$("#decorator_right").attr("style","height: " + hr + "px");
	$("#destination_hotel").attr("autocomplete","off");
	
	$('.image_main_product a').lightBox();
	$('.image_secondary_product a').lightBox();
	
	$(".misc_destination_ajax_shower").click(function(){
		var id = $(this).attr("rel");
		$(".destination_container").hide();
		$("#container_des_" + id).show();
		
		$(".misc_destination_ajax_shower").removeClass("currentDestinationSelected");
		$(this).addClass("currentDestinationSelected");		
		return false;	
	});
	
	$(".misc_transportation_link").click(function(){
		$(".misc_hotel_link").removeClass("misc_current_option_selected");
		$(this).addClass("misc_current_option_selected");
		$(".home_booking").hide();
		$("#booking_transportation").show();
		return false;
	});
	$("#cur_btn_1").addClass("optSelected");
	$("#destination_hotel").keydown(function(e){
		var val = $(this).val();
		//alert(e.which);
		//40 - Arriba
		//38 - Abajo
		
		if(val.length){			
			$.get("/requestDestinationTourico.php",{f:$(this).val()},function(xml){
				$("#destination_info_select").empty().remove();
				$("#container").append("<div id='destination_info_select'></div>");
				
				var xml = xml.split("@@@@");
				var xhtml = "";
				for(i=0;i<xml.length;i++){
					var info = xml[i];
					info = info.split("||||");
					xhtml += "<a id='misc_elemn_select_" + i + "' href='#' title='' rel='" + info[1] + "'>" +  info[0] + "</a>";
				}
				
				$("#destination_info_select").html(xhtml);
							
				if(e.which == 40){
					if(curHotel < xml.length){
						curHotel++;
					}else{
						curHotel = xml.length;
					}
					$("#destination_info_select a").removeClass("current");
					$("#misc_elemn_select_" + curHotel).addClass("current");
				}
				
				if(e.which == 38){
					if(curHotel > 0){
						curHotel--;
					}else{
						curHotel = 0;
					}
					$("#destination_info_select a").removeClass("current");
					$("#misc_elemn_select_" + curHotel).addClass("current");				
				}
				
				$("#destination_info_select a").click(function(){
					$("#destination_hotel").val($(this).html());
					$("#destCode").val($(this).attr("rel"));
					$("#destination_info_select").empty().remove();
					return false;	
				});
			});
		}else{
			$("#destination_info_select").empty().remove();
			curHotel = 0;
		}
		
		if(e.which == 13){
			$("#destination_hotel").val($("#destination_info_select a.current").html());
			$("#destCode").val($("#destination_info_select a.current").attr("rel"));
			$("#destination_info_select").empty().remove();
			return false;
		}
	});
	
	$(".misc_hotel_link").click(function(){
		$(".misc_transportation_link").removeClass("misc_current_option_selected");
		$(this).addClass("misc_current_option_selected");
		$(".home_booking").hide();
		$("#booking_hotel").show();
		return false;
	});
		 
	var padre = $("#cur_btn_" + current_promotion);
	var number = current_promotion
	
	$(".misc_hide_button_info_hidden .decorated").addClass("notNull");
	$(".misc_type_transportation").click(function(){
		
		var cur_val = $(".misc_type_transportation:checked").val();
		
		if(cur_val == 3 || cur_val == 4){
			$(".misc_hide_button_info_hidden").show();
			$(".misc_hide_button_info_hidden .decorated").addClass("notNull");
		}else{
			$(".misc_hide_button_info_hidden").hide();
			$(".misc_hide_button_info_hidden .decorated").removeClass("notNull");
		}
	});
	$(".sello_amipci").click(function(){
		vrsn_splash(2);
	});
	$("#destination_transfer").change(function(){
		val = $(this).val();
		if(val != 0){
			$.get("/requestDestinationTransfer.php",{d:val},function(xml){
				xml = xml.split("@@@@@@@");
				$("#transportation_start_zone").removeAttr("disabled").html(xml[0]);
				$("#transportation_end_zone").removeAttr("disabled").html(xml[1]);				
			});
		}else{
			var xml = '<option value="0">[PLEASE CHOOSE DESTINATION]</option>';
			$("#transportation_start_zone").attr("disabled","disabled").html(xml);
			$("#transportation_end_zone").attr("disabled","disabled").html(xml);

		}
	});

	$("#transportation_date").blur(function(){
		var tDate = $(this).val();
		tDate = tDate.replace("-","");
		tDate = tDate.replace("-","");
		datePickerController.setRangeLow("transportation_date2",tDate);
	});
	
	$("#checkin").blur(function(){
		var tDate = $(this).val();
		tDate = tDate.replace("-","");
		tDate = tDate.replace("-","");
		datePickerController.setRangeLow("checkout",tDate);
	});	
	
	$("#hotel_cuartos").change(function(){
		$(".misc_update_ajax_booking_box_removable").remove();	
		var val = $(this).val();
		var html = "";
		val = (val * 1)+ 1;		
		if(val > 1){
			for(i=2;i<val;i++){	
				html += "<tr class='misc_update_ajax_booking_box_removable'>";			
				html += "<td>" + lblRooms + "</td>";
				html += "<td>" + lblAdultos + "</td>";
				html += "<td>" + lblMenores + "</td>";
				html += "</tr><tr class='misc_update_ajax_booking_box_removable'>";
				html += "<td>&nbsp;</td>";
				html += "<td><select class='decorated' name='adultos_cuarto_" + i + "'>" + comboAdultos + "</select></td>";
				html += "<td><select class='decorated' name='menores_cuarto_" + i + "'>" + comboMenores + "</select></td>";
				html += "</tr>";				
			}
		}
		$("#misc_updater_roooms").before(html);
	});
	
	
	$("#main_number_btns a").click(function(){
		$(".misc_image_promotion").fadeOut("slow");
		$(".misc_information_promotion").fadeOut();
		$("#main_number_btns a").removeClass("optSelected");
		$(this).addClass("optSelected");
		var number = $(this).attr("id");
		number = number.replace("cur_btn_","");
		current_promotion = number;	
		$("#promotion_info_" + number).fadeIn();
		$("#promotion_img_" + number).fadeIn();		
		clearTimeout(timer);		
		if(current_promotion < 5){
			current_promotion++;
		}else{
			current_promotion = 1;
		}
		timer = setTimeout("animatePromotions()",5000);
		return false;
	});
	
	$("#main_number_btns a").hover(function(){
		var number = $(this).attr("id");				
	},function(){
		var number = $(this).attr("id");
		number = number.replace("cur_btn_","");					
	});
	
	
	
	$(".misc_booking_box_selector a").click(function(){
		$(".misc_booking_box_selector a").removeClass("selected");
		$(this).addClass("selected");		
		var rel = $(this).attr("rel");
		$(".booking_options").hide();
		$("#booking_option_" + rel).show();
		
		return false;	
	});
	
	$(".btnGreenSbmt").click(function(){
		var padre = $(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode);		
		$("form",padre).submit();
		return false;	
	});
	$("form").submit(function(){
		if (validacampos($(this))){
	 		return true;
	 	}
		else{
			return false;
		}	
	});
	
	
	$(".misc_prod_display_selector_optional a").click(function(){
		var id = $(this).attr("rel");
		$(".misc_prod_banners_ajax_home").attr("style","background-image: url(/ui/tour/hero" + id + ".jpg);");
		$(".misc_prod_show_tour_home_ajax").hide();
		$("#misc_bloque_promo_tour_" + id).show();
		$(".misc_prod_display_selector_optional a").removeClass("selected");
		$(this).addClass("selected");
		return false;	
	});
	
});
var animatePromotions = function(){
	$("#main_number_btns a").each(function(){
		var number = $(this).attr("id");
		number = number.replace("cur_btn_","");					
	});
	$(".misc_image_promotion").fadeOut(1800);
	$(".misc_information_promotion").fadeOut();	
	
	$(".misc_btn_tours").removeClass("optSelected");
	$("#cur_btn_" + current_promotion).addClass("optSelected");
	$("#promotion_info_" + current_promotion).fadeIn();
	$("#promotion_img_" + current_promotion).fadeIn();
		
	
	if(current_promotion < 5){
		current_promotion++;
	}else{
		current_promotion = 1;
	}
	timer = setTimeout("animatePromotions()",7000);
}
function vrsn_splash(w) {
	if(w == null){
		w = 1;
	}
	if (sopener && !sopener.closed){
			sopener.focus();
	} else {
		tbar = "location=yes,status=yes,resizable=yes,scrollbars=yes,width=560,height=500";
		if(w == 2){
			var sw = window.open("https://www.sellosdeconfianza.org.mx/MuestraCertificado.php?NUMERO_SERIE=039f",'AMIPCI',"location=yes,status=yes,resizable=yes,scrollbars=yes,width=515,height=635");
			if(sw) {
				sw.focus();
				sopener=sw;
			}
			return false;
		}else{
			var sw = window.open(u1,'VRSN_Splash',tbar);
			
		}
		
	
		if(sw) {
			sw.focus();
			sopener=sw;
		}
	}
} 
dn="WWW.OLYMPUS-TOURS.COM";
lang = "en";
aff = "VeriSignSwitzerland";
tpt = "transparent";
vrsn_style = "WW";
splash_url = "https://sealinfo.verisign.com";
seal_url = "https://seal.verisign.com";
u1 = splash_url+"/splash?form_file=fdf/splash.fdf&dn="+dn+"&lang="+lang;
u2 = seal_url+"/getseal?at=0&&sealid=2&dn="+dn+"&aff="+aff+"&lang="+lang;
u3 = seal_url+"/getseal?at=1&&sealid=2&dn="+dn+"&aff="+aff+"&lang="+lang;
var sopener; 