			jQuery(document).ready(function(){
				jQuery(".rbxDateFrom").each(function(){
					jQuery(this).datepick({
						dateFormat: FormatO,
						showOnFocus: true,
						//defaultDate: +7,
						selectDefaultDate: true,
						minDate:0,
						maxDate:"+1y",
						monthsToShow: 1,
						//showTrigger: "#GalFrom",
						onSelect: customRange
					});
				});

				jQuery(".rbxDateTo").each(function(){
					jQuery(this).datepick({
						dateFormat: FormatO,
						showOnFocus: true, 
						//defaultDate: +14,
						selectDefaultDate: true,
						minDate:+3,
						maxDate:"+1y +1d",
						monthsToShow: 1,
						//showTrigger: "#GalTo",
						onSelect: customRange
					});
				});
				
				jQuery(".extra #mnSel :nth-child(1)").click(function(){
					jQuery(".extra").removeClass("imgpack");
					jQuery(".extra #mnSel").addClass("DhoteL");
				});
				jQuery(".Sel2").click(function(){
					jQuery(".extra").addClass("imgpack");
					jQuery(".extra #mnSel").removeClass("DhoteL");
					
				});
				jQuery('.inLn,.spWidth select,.spWidth1 select').customStyle();
			});
			function customRange(dates) { 
				var FormA=jQuery(this).parent(0).parent(1).attr('id');
				var xFchA=jQuery(this).attr('class');
				var xCDTGn='#'+FormA+" .rbxDateTo"; //xCalendarDateToGeneric 
				var xCDFGn='#'+FormA+" .rbxDateFrom"; //xCalendarDateFromGeneric 
				var xOCDTGn=jQuery(xCDTGn);
				var xOCDFGn=jQuery(xCDFGn);
				xCDTGn=xOCDTGn.val();
				xCDFGn=xOCDFGn.val();
			//ESTA SECCIÓN IDENTIFICA A QUE CALENDARIO SE LE DA CLICK
				if (xFchA.indexOf('rbxDateFrom')>=0){
					var DatesFromDateFrm=jQuery(this).val();
					var DatesFromDateTo=xCDTGn;
					var date = new Date(dates[0]); 
					jQuery.datepick.add(date,'+3', 'd'); 
					DatesFromDateTo==""?xOCDTGn.val(jQuery.datepick.formatDate(date)):xOCDTGn.val(xOCDTGn.val());
					var tempDFrm=DatesFromDateFrm.split("/");
					//alert(tempDFrm);
					var tempDTo=DatesFromDateTo.split("/");
					var tempNewDFrm=tempDFrm[2]+"/"+tempDFrm[1]+"/"+tempDFrm[0];
					var tempNewDTo=tempDTo[2]+"/"+tempDTo[1]+"/"+tempDTo[0];
					tempNewDFrm>=tempNewDTo ? xOCDTGn.val(jQuery.datepick.formatDate(date)) : xOCDTGn.val(xOCDTGn.val()) ;
					var DateFrmx=jQuery.datepick.formatDate(dates[0]);
					var DateTox=xOCDTGn.val();
					var ArrayDateFrmx=DateFrmx.split("/");
					var ArrayDateTox=DateTox.split("/");
					//ELEMENTOS CALENDARIO ANTERIOR FROM
						//Dia
						jQuery("#"+FormA+' input[name=dia_desde]').val(ArrayDateFrmx[IndexDD]);
						//Mes
						jQuery("#"+FormA+' input[name=mes_desde]').val(ArrayDateFrmx[IndexMM]);
						//Anio
						jQuery("#"+FormA+' input[name=anio_desde]').val(ArrayDateFrmx[2]);
					//ELEMENTOS CALENDARIO ANTERIOR TO
						//Dia
						jQuery("#"+FormA+' input[name=dia_hasta]').val(ArrayDateTox[IndexDD]);
						//Mes
						jQuery("#"+FormA+' input[name=mes_hasta]').val(ArrayDateTox[IndexMM]);
						//Anio
						jQuery("#"+FormA+' input[name=anio_hasta]').val(ArrayDateTox[2]);
				}
				else
				{
					var DatesFromDateFrm=xCDFGn; 				//Fecha de Salida
					var DatesFromDateTo=jQuery(this).val();		//Fecha de Regreso
					var date = new Date(dates[0]); 
					jQuery.datepick.add(date,'-3', 'd'); 
					xOCDFGn.val()=="" ? xOCDFGn.val(jQuery.datepick.formatDate(date)):xOCDFGn.val(xOCDFGn.val());
					var tempDFrm=DatesFromDateFrm.split("/");
					var tempDTo=DatesFromDateTo.split("/");
					var tempNewDFrm=tempDFrm[2]+"/"+tempDFrm[1]+"/"+tempDFrm[0];
					var tempNewDTo=tempDTo[2]+"/"+tempDTo[1]+"/"+tempDTo[0];
					tempNewDTo<=tempNewDFrm ? xOCDFGn.val(jQuery.datepick.formatDate(date)): xOCDFGn.val(xOCDFGn.val());
					var DateFrmx=xOCDFGn.val();
					var DateTox= jQuery.datepick.formatDate(dates[0]);
					var ArrayDateFrmx=DateFrmx.split("/");
					var ArrayDateTox=DateTox.split("/");
					//ELEMENTOS CALENDARIO ANTERIOR FROM
						//Dia
						jQuery("#"+FormA+' input[name=dia_desde]').val(ArrayDateFrmx[IndexDD]);
						//Mes
						jQuery("#"+FormA+' input[name=mes_desde]').val(ArrayDateFrmx[IndexMM]);
						//Anio
						jQuery("#"+FormA+' input[name=anio_desde]').val(ArrayDateFrmx[2]);
					//ELEMENTOS CALENDARIO ANTERIOR TO
						//Dia
						jQuery("#"+FormA+' input[name=dia_hasta]').val(ArrayDateTox[IndexDD]);
						//Mes
						jQuery("#"+FormA+' input[name=mes_hasta]').val(ArrayDateTox[IndexMM]);
						//Anio
						jQuery("#"+FormA+' input[name=anio_hasta]').val(ArrayDateTox[2]);
				}
			}
			function newControls(obj){
				obj=obj+",.datepick-nav a";
				jQuery(obj).bind('click',function (){
					dtpkmes=jQuery('.datepick-month .datepick-month-header :nth-child(1) option:selected').html();
					dtpkanio=jQuery('.datepick-month .datepick-month-header :nth-child(2) option:selected').html();
					dtpkclose="X";
					jQuery("#datepick-nav,#datepick-month-header").remove();
					jQuery('.datepick div:first').hide();
					jQuery('.datepick-month .datepick-month-header').hide();
					jQuery('.datepick-month-row').before('<div class="datepick-month-header" id="datepick-month-header"><span id="dtpkmes">'+dtpkmes+' </span><span id="dtpkanio"> '+dtpkanio+'</span><a id="dtpkclose" href="javascript:void(0)">'+dtpkclose+'</a></div>');
					jQuery('#dtpkclose').live('click',function(){jQuery('.datepick-cmd.datepick-cmd-close').click();});
					jQuery('.datepick-ctrl').hide();
					jQuery('.datepick-ctrl').before('<div class="datepick-nav" id="datepick-nav"><a class="datepick-cmd datepick-cmd-prev" id="datepick-prev" href="javascript:void(0)">&lt;Ant</a><a class="datepick-cmd datepick-cmd-today" id="datepick-today" href="javascript:void(0)">Hoy</a><a class="datepick-cmd datepick-cmd-next" id="datepick-next" href="javascript:void(0)">Sig&gt;</a></div>');
					jQuery('.datepick-nav a').html('');
				});
			}
			jQuery(document).ready(function(){
				MnOp('formahotel');
				newControls(".cal, .hasDatepick");
//				jQuery('.mySelectBoxClass').customStyle();
			});
			jQuery('#datepick-prev').live('click',function(){
					newControls('#datepick-prev');
					jQuery('.datepick div:first .datepick-cmd.datepick-cmd-prev').click();
			});
			jQuery('#datepick-today').live('click',function(){
				newControls('#datepick-today');
				jQuery('.datepick div:first .datepick-cmd.datepick-cmd-today').click();
			});
			jQuery('#datepick-next').live('click',function(){
				newControls('#datepick-next');
				jQuery('.datepick div:first .datepick-cmd.datepick-cmd-next').click();
			});
			
			
			
var MsjAirport,altMsjAirport,altMsjDate,NFOrigen,NFDestino,PosadaAllIclusive,FalseHotel,FormatO,IndexMM,IndexDD,MsjAllInclusive,MsjHotel;
function DefVar(obj)
{
	if(jQuery(obj+" input[name=idioma]").val().toUpperCase()=="ESP")
	{
		MsjAirport="Ciudad o Clave IATA";
		altMsjAirport="Por favor seleccione un aeropuerto de origen.";
		altMsjDate="Debe Seleccionar una Fecha de Salida";
		NFOrigen="Por favor seleccione un aeropuerto de origen.";
		NFDestino="Por favor seleccione un aeropuerto de destino."
		PosadaAllIclusive="Puede seleccionar como m\u00E1ximo 4 personas por habitaci\u00F3n.";
		FalseHotel="Por favor seleccione un hotel";
		FormatO="dd/mm/yyyy";
		IndexMM=1;
		IndexDD=0;
		MsjAllInclusive="M\u00E1ximo 4 personas por habitaci\u00F3n, incluyendo ni\u00F1os.";
		MsjHotel="Seleccione un hotel por favor.";
	}
	if(jQuery(obj+" input[name=idioma]").val().toUpperCase()=="POR")
	{
		MsjAirport="Cidade ou do aeroporto";
		altMsjAirport="Por favor seleccione um aeroporto de partida.";
		altMsjDate="Você deve selecionar uma data de partida";
		NFOrigen="Digite o aeroporto de partida.";
		NFDestino="Especificar Retorno aeroporto";
		PosadaAllIclusive="Voc\u00EA deve selecionar at\u00E9 quatro pessoas por quarto.";
		FalseHotel="Por favor, seleccione um hotel";
		FormatO="dd/mm/yyyy";
		IndexMM=1;
		IndexDD=0;
		MsjAllInclusive="Maximum 4 persons per room, including children.";
		MsjHotel="Please select a hotel.";
	}
	if(jQuery(obj+" input[name=idioma]").val().toUpperCase()=="ING")
	{
		MsjAirport="City or Airport";
		altMsjAirport="Please select a departure airport.";
		altMsjDate="You must select a Departure Date";
		NFOrigen="Enter the departure airport.";
		NFDestino="Specify airport Return";
		PosadaAllIclusive="You must select up to four people per room.";
		FalseHotel="Please select a hotel";
		FormatO="mm/dd/yyyy";
		IndexMM=0;
		IndexDD=1;
		MsjAllInclusive="M\u00E1ximo de 4 pessoas por quarto, incluindo crian\u00E7as.";
		MsjHotel="Por favor, seleccione um hotel.";
	}
}

jQuery(document).ready(function(){
	DefVar("#formahotel");
	jQuery("#formahotel").submit(function(){
		if (jQuery(".inLn").val()=="")
		{
			alert("Seleccione un Hotel");
			return(false);
		}
		if(ValidaFechaS("#formahotel")==false)
		{
			return(false);
		}
		return(AllInclusive("#formahotel"));
	});
	jQuery("#formapackage").submit(function(){
		return(ValidaPackageAvion());
	});
});

function ValidaPackageAvion()
{
	//jQuery("#formapackage")
	if(jQuery("#formapackage input[name=Leavingfrom]").val()=="" || jQuery("#formapackage input[name=Leavingfrom]").val()==MsjAirport)
	{
		alert(altMsjAirport);
		return (false);
	}
	if(jQuery('#formapackage select[name=ID] option:selected').val()=="")
	{
		alert(FalseHotel);
		return(false);
	}
	if (ValidaFechaS("#formapackage")==false){return(false);}
	return(AllInclusive("#formapackage"));
}
function ValidaFechaS(obj)
{
	if(jQuery(obj+" .rbxDateFrom").val()=="" || jQuery(obj+" .rbxDateTo").val()=="")
	{
		alert(altMsjDate);
		return (false);
	}
}
function AllInclusive(FormA)
{	
	if(parseInt(jQuery(FormA+" select[name=num_adultos]").val())+parseInt(jQuery(FormA+" select[name=num_ninos]").val())>4)
		{
			alert(MsjAllInclusive);
			return(false);
		}
}
	jQuery(document).ready(function(){
	var cachePQ = {};
		$("#formapackage #Leavingfrom").autocomplete({
			minLength: 2,
			delay: 1000,
			source: function(request, response) {
				if (request.term in cachePQ) {
					response(cachePQ[request.term]);
					return;
				}
				$.ajax({
					// Callback - JSONP
					//	                url: "http://partners.clickhotels.com/AJAX/DestinationsJSONP?idioma=<%= Resources.General.LanguageRegionalId %>",
					url: "http://partners.clickhotels.com/AJAX/AirportsJSONP?idioma=es",
					dataType: "jsonp",
					data: request,
					success: function(data) {
						cachePQ[request.term] = data;
						response(data);
					}
				});
			},
			select: function(event, ui) {
				//alert("selection: " + ui.item.id + " : " + ui.item.desc_name + " : " + ui.item.desc);
				$("#formapackage #Leavingfrom").val(ui.item.desc);
				$("#formapackage #CodeAirport").val(ui.item.id);
				return false;
			}
		}).data("autocomplete")._renderItem = function(ul, item) {
			return $("<li></li>")
			.data("item.autocomplete", item)
			.append($("<a></a>, ").text(item.desc))
			.appendTo(ul);
		};
    jQuery("#formapackage select[name=ID]").change(function(){
      var tempdestino=jQuery("#formapackage input[name=Destino]");
      tempdestino.val("9");  
      if(jQuery(this).val()=="824")
        {
          tempdestino.val("13");
        }
      if(jQuery(this).val()=="226")
        {
          tempdestino.val("4");
        }
    });
	});
