var nav=navigator.appName;
var tmp_dt=new Date();
var isDefaultRoomTypeSet = true;
function newdt(){
	return new Date(tmp_dt.getFullYear(),tmp_dt.getMonth(),tmp_dt.getDate(),0,0,0,0);
}
var m_today = new newdt();
var m_arr= new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
var my_arr= new Array();
var my_val_arr= new Array();
var temp_month=parseInt(m_today.getMonth());
var temp_year=parseInt(m_today.getFullYear());
var tmp_indt= new newdt();
var m_indt=new Date(tmp_indt.setDate(tmp_indt.getDate()+7));
var tmp_outdt= new newdt();
var m_outdt=new Date(tmp_outdt.setDate(tmp_outdt.getDate()+8));

var temp_m_inc=temp_month;
var temp_y_inc=temp_year;

var inmm 	= tmp_indt.getMonth();
var indd 	= tmp_indt.getDate();
var inyy 	= tmp_indt.getFullYear();

var outmm = tmp_outdt.getMonth();
var outdd = tmp_outdt.getDate();
var outyy = tmp_outdt.getFullYear();


/////////////////////////////////////////////////////////////////////////
var in_month_maxdate=temp_month;
var in_year_maxdate=temp_year;
var out_month_maxdate=outmm;
var out_year_maxdate=outyy;
/////////////////////////////////////////////////////////////////////////

var today_date = new Date();
var setdetetodrop = new Date(today_date.getFullYear()+1,11,31);
var user_date = Date.parse(setdetetodrop);
var diff_date =  user_date - today_date;
var num_months = (diff_date % 31536000000)/2628000000;

if(today_date.getDate()==31)
num_months = num_months + 0.10;

var numberminth = Number(num_months)+12;


var one_day=1000*60*60*24;


function set_RoomTypeToFalse()
{
	isDefaultRoomTypeSet = false;
}


function set_CalendarMonths()
{
	if(document.frm1.language != null && document.frm1.language.value != "")
	{
		var languageName = document.frm1.language.value;
	if(languageName.toLowerCase() == "en")
		{
			m_arr= new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
		}
		else if (languageName.toLowerCase() == "es")
		{
			m_arr= new Array("Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic");
		}
		else if (languageName.toLowerCase() == "de")
		{
			m_arr= new Array("Jan.","Feb.","M\u00E4r.","Apr.","Mai","Jun.","Jul.","Aug.","Sep.","Okt.","Nov.","Dez.");
		}
		else if (languageName.toLowerCase() == "fr")
		{
			m_arr= new Array("Janv.","F\u00E9vr.","Mars","Avr.","Mai","Juin","Juil.","Ao\u00FBt","Sept.","Oct.","Nov.","D\u00E9c.");
		}
		else if (languageName.toLowerCase() == "it")
		{
			m_arr= new Array("Gen","Feb","Mar","Apr","Mag","Giu","Lug","Ago","Set","Ott","Nov","Dic");
		}
		else if (languageName.toLowerCase() == "pl")
		{
			m_arr= new Array("Sty","Lut","Mar","Kwi","Maj","Cze","Lip","Sie","Wrz","Paz","Lis","Gru");
		}
		else 
		{
			m_arr= new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
		}
	}
	else
	{
		m_arr= new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	}
	
for (var inc=0; inc<numberminth; inc++){
	if ((temp_m_inc)>=m_arr.length){
		temp_m_inc=0;
		temp_y_inc=temp_y_inc+1;
	}
	my_arr[inc]=""+m_arr[temp_m_inc] + " "+temp_y_inc+"";
	my_val_arr[inc]=""+temp_y_inc+"-"+temp_m_inc+"";
	temp_m_inc=temp_m_inc+1;
}
}

function set_default_date(){

set_CalendarMonths();
//alert('set_default_date');
 var selElm = document.forms["frm1"].elements["cmbCheckInymcombo"];
	selElm.removeChild(selElm[0]);
	var selElm = document.forms["frm1"].elements["cmbCheckOutymcombo"];
	selElm.removeChild(selElm[0]);
	
	 var kk1;
	 
	for (kk1=0; kk1<my_arr.length; kk1++){
		document.forms["frm1"].elements["cmbCheckInymcombo"].options[document.forms["frm1"].elements["cmbCheckInymcombo"].options.length]=new Option(my_arr[kk1],my_val_arr[kk1]);
	}
	
	for (var kk1=0; kk1<my_arr.length; kk1++){
		document.forms["frm1"].elements["cmbCheckOutymcombo"].options[document.forms["frm1"].elements["cmbCheckOutymcombo"].options.length]=new Option(my_arr[kk1],my_val_arr[kk1]);
	}
	
	
	
	
	////////////////adding 7 days current date/////////////////////////////////////////////////////////////
	var inmmin 	= m_indt.getMonth();
	var inyyin 	= m_indt.getFullYear();
	var inmmout 	= m_outdt.getMonth();
	var inyyout 	= m_outdt.getFullYear();
	
	document.forms["frm1"].elements["cmbCheckInymcombo"].value=inyyin+"-"+inmmin;
	document.forms["frm1"].elements["cmbCheckOutymcombo"].value=inyyout+"-"+inmmout;
	//////////////////////////////////////////////////////////////////////////////////
	
	
	
	
	
	
		
		
	   /////st///2222/////  when u wnt to increase drop dwn length///////////////////////////  
	  maxdays = maxdate(inmmin,inyyin);
//alert('maxdays >>'+maxdays);
	document.frm1.elements["cmbCheckInDate"].options.length=0;
		for (a=1; a<=maxdays; a++){
		document.frm1.elements["cmbCheckInDate"].options[document.frm1.elements["cmbCheckInDate"].options.length] = (a<10)? new Option("0"+a+"","0"+a+"") : new Option(a,a); 
		}
	

	  maxdays2 = maxdate(inmmout,inyyout);
//alert('maxdays2 >>'+maxdays2);
	
	document.frm1.elements["cmbCheckOutDate"].options.length=0;
		for (a=1; a<=maxdays2; a++){
		document.frm1.elements["cmbCheckOutDate"].options[document.frm1.elements["cmbCheckOutDate"].options.length] = (a<10)? new Option("0"+a+"","0"+a+"") : new Option(a,a); 
		}
/////ed///2222/////  when u wnt to increase drop dwn length/////////////////////////// 
	
	
	if(document.frm1.language.value != null && document.frm1.language.value != "")
  	{
		document.images["inday"].src=document.mapFrm.imagePath.value+"/RG_dd"+(tmp_indt.getDay())+"_"+document.frm1.language.value+".gif";
	}
	else
	{
	document.images["inday"].src=document.mapFrm.imagePath.value+"/RG_dd"+(tmp_indt.getDay())+".gif";
	}
//	document.images["inday"].src=document.mapFrm.imagePath.value+"/RG_dd"+(tmp_indt.getDay())+".gif";
	setMonthDays("In");
	document.frm1.cmbCheckInDate.selectedIndex			= indd-1;
	if(document.frm1.language.value != null && document.frm1.language.value != "")
  	{
		document.images["outday"].src=document.mapFrm.imagePath.value+"/RG_dd"+(Number(m_outdt.getDay()))+"_"+document.frm1.language.value+".gif";
	}
	else
	{
	document.images["outday"].src=document.mapFrm.imagePath.value+"/RG_dd"+(Number(m_outdt.getDay()))+".gif";
	}
	//document.images["outday"].src=document.mapFrm.imagePath.value+"/RG_dd"+(Number(m_outdt.getDay()))+".gif";
	setMonthDays("Out");
	document.frm1.cmbCheckOutDate.selectedIndex			= outdd-1;




////////////////////////date issue//////////////////////////////
  	var tmpInMY=document.forms["frm1"].elements["cmbCheckInymcombo"].options[document.forms["frm1"].elements["cmbCheckInymcombo"].options.selectedIndex].value;
	var tmpInMY_vals=tmpInMY.split("-");

	tmpmm	= tmpInMY_vals[1];
	tmpyy	= tmpInMY_vals[0];
	
	document.forms["frm1"].elements["cmbCheckInMonth"].value	=tmpInMY_vals[1];
	document.forms["frm1"].elements["cmbCheckInYear"].value	=tmpInMY_vals[0];
	
	tmpInDate = new Date(tmpyy,tmpmm,document.frm1.cmbCheckInDate.options[document.frm1.cmbCheckInDate.selectedIndex].value,0,0,0,0);
 
	if(document.frm1.language.value != null && document.frm1.language.value != "")
  	{
		document.images["inday"].src=document.mapFrm.imagePath.value+"/RG_dd"+(tmpInDate.getDay())+"_"+document.frm1.language.value+".gif";
	}
	else
	{
	 document.images["inday"].src=document.mapFrm.imagePath.value+"/RG_dd"+(tmpInDate.getDay())+".gif";
	}
//	 document.images["inday"].src=document.mapFrm.imagePath.value+"/RG_dd"+(tmpInDate.getDay())+".gif";

	 tmpOutDate = new Date(tmpInDate.setDate(tmpInDate.getDate()+1));
	document.frm1.cmbCheckOutMonth.value	= tmpOutDate.getMonth();
	document.frm1.cmbCheckOutYear.value		= tmpOutDate.getFullYear();
	
	var cmbCheckOutymcombo_value=document.frm1.cmbCheckOutYear.value+"-"+document.frm1.cmbCheckOutMonth.value;
	 document.frm1.cmbCheckOutymcombo.value	= cmbCheckOutymcombo_value;
/////////////////////////////////////////////////////////////






document.frm1.cmbNoOfAdults.selectedIndex=1;

	for (var i=0; i<20; i++){
		document.forms["frm1"].elements["cmbNoOfAdults"].options[document.forms["frm1"].elements["cmbNoOfAdults"].options.length]=new Option(i+1,i+1);
	}
	document.frm1.cmbNoOfAdults.selectedIndex=1;
	document.frm1.disvalue.checked = false;
	document.frm1.selDiscount1.value = "N";
	document.frm1.HidRoomType.value = "%";
		
		//cityDropDWN(document.frm1.cmbHotel.options[document.frm1.cmbHotel.selectedIndex].value);
		hotelDropDWN(document.frm1.cityCd.value);
		
//		chkBRmTyp(document.frm1.cityCd.value,document.frm1.selCategory.value);
//	chkBRmTyp(document.frm1.selLocation.value);
	//document.getElementById("imgSearch").style.display = "block";
	//document.getElementById("imgPleaseWait").style.display = "none";
	document.forms["frm1"].cmbNoOfNights.value = "1";
}



function searchHotel(){
	//document.getElementById("imgSearch").style.display = "none";
	//document.getElementById("imgPleaseWait").style.display = "block";
	var rSource="W";
	var prvScr="http://bookings.travelstay.com/TravelStayBooking.htm";
	if(document.frm1.language.value != "en")
	{
	    prvScr="http://bookings.travelstay.com/TravelStayBooking_"+document.frm1.language.value+".htm";
	}
	
	tmpInDate = new Date(document.frm1.cmbCheckInYear.value,document.frm1.cmbCheckInMonth.value,document.frm1.cmbCheckInDate.options[document.frm1.cmbCheckInDate.selectedIndex].value,0,0,0,0);
	tmpOutDate = new Date(document.frm1.cmbCheckOutYear.value,document.frm1.cmbCheckOutMonth.value,document.frm1.cmbCheckOutDate.value,0,0,0,0);
// dateDifference = get_deference(tmpInDate,tmpOutDate);
dateDifference = (tmpOutDate-tmpInDate)/one_day;
 noNights = document.frm1.cmbNoOfNights.value;
 today = new Date();

  if ((today-tmpInDate)>86400000){
   alert("Check in date can not be less than the system date");
   //set_default_date1();
  return;
 }

 if (dateDifference>100 || dateDifference<1){
  alert("Number of night(s) can not be greater than 99 or less than 1.\r\nPlease select again ...");
  //set_default_date1();
  return;
 }else{
//  document.frm1.cmbNoOfNights.value=1;
 }

 noOfRooms = document.frm1.cmbNoOfRooms.selectedIndex+1;
 noOfAdults = document.frm1.cmbNoOfAdults.selectedIndex+1;

if(noOfRooms>noOfAdults){
 alert("Number of adults is greater then the maximum no of adults for the rooms selected!");
 return;
}
	
	
	
	//sub_url="http://www4.secure-reservation.com/servlet/TravelStay.ResevationSearch?afCd="+document.frm1.afftCode.value+"&afTp="+document.frm1.afftType.value+"&NoAd="+document.frm1.cmbNoOfAdults.options[document.frm1.cmbNoOfAdults.selectedIndex].value+"&NoCh="+document.frm1.cmbNoChi.value+"&NoNgt="+document.frm1.cmbNoOfNights.value+"&stPr=0&edPr=999999&PrRg=All%20Prices&AcNm="+escape(document.frm1.hotelName.value)+"&Grp="+escape(document.frm1.selGroup.value)+"&NoRm="+document.frm1.cmbNoOfRooms.value+"&Ct="+escape(document.frm1.cityCd.value)+"&InDt="+document.frm1.cmbCheckInDate.options[document.frm1.cmbCheckInDate.selectedIndex].value+"&InMn="+document.frm1.cmbCheckInMonth.options[document.frm1.cmbCheckInMonth.selectedIndex].value+"&InYr="+document.frm1.cmbCheckInYear.options[document.frm1.cmbCheckInYear.selectedIndex].value+"&OtDt="+document.frm1.cmbCheckOutDate.value+"&prSc="+escape(prvScr)+"&OtMn="+document.frm1.cmbCheckOutMonth.options[document.frm1.cmbCheckOutMonth.selectedIndex].value+"&OtYr="+document.frm1.cmbCheckOutYear.options[document.frm1.cmbCheckOutYear.selectedIndex].value+"&htCd="+escape(document.frm1.hotelCode.value)+"&amty="+escape(document.frm1.selCategory.value)+"&slCt="+escape(document.frm1.selCity.value)+"&CtgNm="+escape(document.frm1.selCategoryName.value)+"&slCat="+escape(document.frm1.selCategory.value)+"&Dcn1="+document.frm1.selDiscount1.value+"&Dcn2=N&mxP="+document.frm1.maxpPrevalue.value+"&RmTyD="+escape(document.frm1.cmbRoomType.options[document.frm1.cmbRoomType.selectedIndex].text)+"&RmTyp="+escape(document.frm1.HidRoomType.value)+"&slLoc="+document.frm1.selLocation.value+"&sLNm="+escape(document.frm1.selLocationNm.value)+"&Sor="+rSource+"&vInf="+escape(document.frm1.visitorInfo.value)+"&language=en&country=US&browser=IE&flB=T&Utp=HT";
	//sub_url="http://192.168.1.212:7001/servlet/TravelStay.ResevationSearch?afCd="+document.frm1.afftCode.value+"&afTp="+document.frm1.afftType.value+"&NoAd="+document.frm1.cmbNoOfAdults.options[document.frm1.cmbNoOfAdults.selectedIndex].value+"&NoCh="+document.frm1.cmbNoChi.value+"&NoNgt="+document.frm1.cmbNoOfNights.value+"&stPr=0&edPr=999999&PrRg=All%20Prices&AcNm="+escape(document.frm1.hotelName.value)+"&Grp="+escape(document.frm1.selGroup.value)+"&NoRm="+document.frm1.cmbNoOfRooms.value+"&Ct="+escape(document.frm1.cityCd.value)+"&InDt="+document.frm1.cmbCheckInDate.options[document.frm1.cmbCheckInDate.selectedIndex].value+"&InMn="+document.frm1.cmbCheckInMonth.options[document.frm1.cmbCheckInMonth.selectedIndex].value+"&InYr="+document.frm1.cmbCheckInYear.options[document.frm1.cmbCheckInYear.selectedIndex].value+"&OtDt="+document.frm1.cmbCheckOutDate.value+"&prSc="+escape(prvScr)+"&OtMn="+document.frm1.cmbCheckOutMonth.options[document.frm1.cmbCheckOutMonth.selectedIndex].value+"&OtYr="+document.frm1.cmbCheckOutYear.options[document.frm1.cmbCheckOutYear.selectedIndex].value+"&htCd="+escape(document.frm1.hotelCode.value)+"&amty="+escape(document.frm1.selCategory.value)+"&slCt="+escape(document.frm1.selCity.value)+"&CtgNm="+escape(document.frm1.selCategoryName.value)+"&slCat="+escape(document.frm1.selCategory.value)+"&Dcn1="+document.frm1.selDiscount1.value+"&Dcn2=N&mxP="+document.frm1.maxpPrevalue.value+"&RmTyD="+escape(document.frm1.cmbRoomType.options[document.frm1.cmbRoomType.selectedIndex].text)+"&RmTyp="+escape(document.frm1.HidRoomType.value)+"&slLoc="+document.frm1.selLocation.value+"&sLNm="+escape(document.frm1.selLocationNm.value)+"&Sor="+rSource+"&vInf="+escape(document.frm1.visitorInfo.value)+"&language=en&country=US&browser=IE&flB=T&Utp=HT";
		
	sub_url="http://secure.travelstay.com/servlet/TravelStay.ResevationSearch?afCd="+document.frm1.afftCode.value+"&afTp="+document.frm1.afftType.value+"&NoAd="+document.frm1.cmbNoOfAdults.options[document.frm1.cmbNoOfAdults.selectedIndex].value+"&NoCh="+document.frm1.cmbNoChi.value+"&NoNgt="+document.frm1.cmbNoOfNights.value+"&stPr=0&edPr=999999&PrRg=All%20Prices&AcNm="+escape(document.frm1.hotelName.value)+"&Grp="+escape(document.frm1.selGroup.value)+"&NoRm="+document.frm1.cmbNoOfRooms.value+"&Ct="+escape(document.frm1.cityCd.value)+"&InDt="+document.frm1.cmbCheckInDate.options[document.frm1.cmbCheckInDate.selectedIndex].value+"&InMn="+document.frm1.cmbCheckInMonth.value+"&InYr="+document.frm1.cmbCheckInYear.value+"&OtDt="+document.frm1.cmbCheckOutDate.value+"&prSc="+escape(prvScr)+"&OtMn="+document.frm1.cmbCheckOutMonth.value+"&OtYr="+document.frm1.cmbCheckOutYear.value+"&htCd="+escape(document.frm1.hotelCode.value)+"&amty="+escape(document.frm1.selCategory.value)+"&slCt="+escape(document.frm1.selCity.value)+"&CtgNm="+escape(document.frm1.cmbHotel.options[document.frm1.cmbHotel.selectedIndex].text)+"&slCat="+escape(document.frm1.selCategory.value)+"&Dcn1="+document.frm1.selDiscount1.value+"&Dcn2=N&mxP="+document.frm1.maxpPrevalue.value+"&RmTyD="+escape(document.frm1.cmbRoomType.options[document.frm1.cmbRoomType.selectedIndex].text)+"&RmTyp="+escape(document.frm1.HidRoomType.value)+"&slLoc="+document.frm1.selLocation.value+"&sLNm="+escape(document.frm1.selLocationNm.value)+"&Sor="+rSource+"&vInf="+escape(document.frm1.visitorInfo.value)+"&language="+escape(document.frm1.language.value)+"&country="+escape(document.frm1.country.value)+"&browser=IE&flB=T&Utp=HT";
	
	//http://secure.travelstay.com/servlet/
	//sub_url="http://secure.travelstay.com/servlet/TravelStay.ResevationSearch?afCd="+document.frm1.afftCode.value+"&afTp="+document.frm1.afftType.value+"&NoAd="+document.frm1.cmbNoOfAdults.options[document.frm1.cmbNoOfAdults.selectedIndex].value+"&NoCh="+document.frm1.cmbNoChi.value+"&NoNgt="+document.frm1.cmbNoOfNights.value+"&stPr=0&edPr=999999&PrRg=All%20Prices&AcNm="+escape(document.frm1.hotelName.value)+"&Grp="+escape(document.frm1.selGroup.value)+"&NoRm="+document.frm1.cmbNoOfRooms.value+"&Ct="+escape(document.frm1.cmbHotel.value)+"&InDt="+document.frm1.cmbCheckInDate.options[document.frm1.cmbCheckInDate.selectedIndex].value+"&InMn="+document.frm1.cmbCheckInMonth.value+"&InYr="+document.frm1.cmbCheckInYear.value+"&OtDt="+document.frm1.cmbCheckOutDate.value+"&prSc="+escape(prvScr)+"&OtMn="+document.frm1.cmbCheckOutMonth.value+"&OtYr="+document.frm1.cmbCheckOutYear.value+"&htCd="+escape(document.frm1.hotelCode.value)+"&amty="+escape(document.frm1.selAmenity.value)+"&slCt="+escape(document.frm1.cmbHotel.options[document.frm1.cmbHotel.selectedIndex].text)+"&CtgNm="+escape(document.frm1.selCategoryName.value)+"&slCat="+escape(document.frm1.selCategory.value)+"&Dcn1="+document.frm1.selDiscount1.value+"&Dcn2=N&mxP="+document.frm1.maxpPrevalue.value+"&RmTyD="+escape(document.frm1.cmbRoomType.options[document.frm1.cmbRoomType.selectedIndex].text)+"&RmTyp="+escape(document.frm1.HidRoomType.value)+"&slLoc="+document.frm1.selLocation.value+"&sLNm="+escape(document.frm1.selLocationNm.value)+"&flB=C&Sor="+rSource+"&vInf="+escape(document.frm1.visitorInfo.value)+"&language=en&country=US&browser=IE&Utp=C";
	//sub_url="http://192.168.1.212:7001/servlet/TravelStay.ResevationSearch?afCd="+document.frm1.afftCode.value+"&afTp="+document.frm1.afftType.value+"&NoAd="+document.frm1.cmbNoOfAdults.options[document.frm1.cmbNoOfAdults.selectedIndex].value+"&NoCh="+document.frm1.cmbNoChi.value+"&NoNgt="+document.frm1.cmbNoOfNights.value+"&stPr=0&edPr=999999&PrRg=All%20Prices&AcNm="+escape(document.frm1.hotelName.value)+"&Grp="+escape(document.frm1.selGroup.value)+"&NoRm="+document.frm1.cmbNoOfRooms.value+"&Ct="+escape(document.frm1.cityCd.value)+"&InDt="+document.frm1.cmbCheckInDate.options[document.frm1.cmbCheckInDate.selectedIndex].value+"&InMn="+document.frm1.cmbCheckInMonth.options[document.frm1.cmbCheckInMonth.selectedIndex].value+"&InYr="+document.frm1.cmbCheckInYear.options[document.frm1.cmbCheckInYear.selectedIndex].value+"&OtDt="+document.frm1.cmbCheckOutDate.value+"&prSc="+escape(prvScr)+"&OtMn="+document.frm1.cmbCheckOutMonth.options[document.frm1.cmbCheckOutMonth.selectedIndex].value+"&OtYr="+document.frm1.cmbCheckOutYear.options[document.frm1.cmbCheckOutYear.selectedIndex].value+"&htCd="+escape(document.frm1.hotelCode.value)+"&amty="+escape(document.frm1.selCategory.value)+"&slCt="+escape(document.frm1.selCity.value)+"&CtgNm="+escape(document.frm1.selCategoryName.value)+"&slCat="+escape(document.frm1.selCategory.value)+"&Dcn1="+document.frm1.selDiscount1.value+"&Dcn2=N&mxP="+document.frm1.maxpPrevalue.value+"&RmTyD="+escape(document.frm1.cmbRoomType.options[document.frm1.cmbRoomType.selectedIndex].text)+"&RmTyp="+escape(document.frm1.HidRoomType.value)+"&slLoc="+document.frm1.selLocation.value+"&sLNm="+escape(document.frm1.selLocationNm.value)+"&Sor="+rSource+"&vInf="+escape(document.frm1.visitorInfo.value)+"&language=en&country=US&browser=IE&flB=T&Utp=HT";
	document.location=sub_url;
}

function setChecksetter(inmdate,inmmonth,inmyear,nameinchk,dayfiled,daymField,dayyfield)
{
	if(nameinchk.indexOf("In")>-1)
	{
		document.forms["frm1"].elements[dayfiled].options[inmdate].selected = true;
		document.forms["frm1"].elements[daymField].value = inmmonth;
		document.forms["frm1"].elements[dayyfield].value = inmyear;
		document.forms["frm1"].elements[nameinchk].value = inmyear+'-'+inmmonth;
	}
}


function showCalendar(id, format, showsTime, showsOtherMonths) {
  var el = document.getElementById(id);
  if (_dynarch_popupCalendar != null) {
    // we already have some calendar created
    _dynarch_popupCalendar.hide();                 // so we hide it first.
  } else {
    // first-time call, create the calendar.
    var cal = new Calendar(1, null, selected, closeHandler);
    // uncomment the following line to hide the week numbers
    // cal.weekNumbers = false;
    if (typeof showsTime == "string") {
      cal.showsTime = true;
      cal.time24 = (showsTime == "24");
    }
    if (showsOtherMonths) {
      cal.showsOtherMonths = true;
    }
    _dynarch_popupCalendar = cal;                  // remember it in the global var
    cal.setRange(1900, 2070);        // min/max year allowed.
    cal.create();
  } 
  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use
  _dynarch_popupCalendar.showAtElement(el.nextSibling, "Br");        // show the calendar
  return false;
}

function selected(cal, date) {
  cal.sel.value = date; // just update the date in the input field.
  if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3" || cal.sel.id == "sel4" || cal.sel.id == "sel5"))
    // if we add this call we close the calendar on single-click.
    // just to exemplify both cases, we are using this only for the 1st
    // and the 3rd field, while 2nd and 4th will still require double-click.
    cal.callCloseHandler();
}

function closeHandler(cal) {
  cal.hide();                        // hide the calendar
//  cal.destroy();
  _dynarch_popupCalendar = null;
}
function DisSetter(disval) {
	if(disval.checked)
		document.frm1.selDiscount1.value = "Y";
	else
		document.frm1.selDiscount1.value = "N";
}
function roomtypesetter(objroomsetter) {
//alert('objroomsetter @@>>>'+objroomsetter.value);
	document.frm1.HidRoomType.value = objroomsetter.options[document.frm1.cmbRoomType.selectedIndex].value;
}



function hotelDrop(Valz,hotelname){
document.frm1.hotelCode.value = Valz;
document.frm1.hotelName.value = hotelname;
chkBRmTyp(document.frm1.hotelCode.value);
}




function hotelDropDWN(Valz){
str =''; 
str1 = '';


document.frm1.cmbHotel.length=1;
var chk='N'; 
	
	for(xz=0;xz<arrHot.length;xz++)
	{
		if(arrHot[xz].hotCty == Valz)
		{
			document.frm1.cmbHotel.options[document.frm1.cmbHotel.length]= 
		new Option(arrHot[xz].hotDesc,arrHot[xz].hotCd); 
		}
	}

chkBRmTyp(document.frm1.hotelCode.value);
}










////////////////ggggggggg111111/////////////////////////////////
function ldRelData(Value,Value1){
	 str = '';
if((Value!='%')){ 
document.frm1.cmbAccomSelection.length=0;
document.frm1.cmbAccomSelection.options[document.frm1.cmbAccomSelection.length]= 
new Option('All Accommodations','%') 
for(a=0;a<arrHot.length;a++){
	if(arrHot[a].arlcEle==Value){ 
		document.frm1.cmbAccomSelection.options[document.frm1.cmbAccomSelection.length]= 
		new Option(arrHot[a].hotDesc,arrHot[a].hotCd); 
chkRmTypByCty(arrHot[a].hotCd); 
	}
}
playRoomTypez(); 
sortHotels('cmbAccomSelection');	
}else{
document.frm1.cmbAccomSelection.length=0;
document.frm1.cmbAccomSelection.options[document.frm1.cmbAccomSelection.length]= 
new Option('All Accommodations','%') 
	for(a=0;a<arrHot.length;a++){
		document.frm1.cmbAccomSelection.options[document.frm1.cmbAccomSelection.length]= 
		new Option(arrHot[a].hotDesc,arrHot[a].hotCd); 
	}
sortHotels('cmbAccomSelection');	
}
}
	var str = '';
	var str1 = '';
function chkRmTypByCty(Valz){
document.frm1.cmbRoomType.length=1;
var chk='N'; 
for(a=0;a<arrHot.length;a++){
	if(arrHot[a].hotCd==Valz){ 
		chk='Y'; 
		strVal=arrHot[a].arGRTEle.split(",")
		for(b=0;b<strVal.length-1;b++){ 
if(str.indexOf(arrGRT[strVal[b]].GRTDesc,arrGRT[strVal[b]].GRTCd)== -1) {  
 str = str+arrGRT[strVal[b]].GRTDesc+','+arrGRT[strVal[b]].GRTCd;    
 str = str+'|';    
		}
	}
	if(chk=='Y'){ 
		break;
	}
}
}
str1 = str;
}
function playRoomTypez(){
document.frm1.cmbRoomType.length=1;
		var strArry=str.split("|")
 var sortArray=new Array();
   sortArray= arrGRT.slice(0,arrGRT.length+1)       
 for(x=0;x<sortArray.length;x++){
   var IsIn = true;      
   for(y=0;y<strArry.length;y++){       
  if( sortArray[x].GRTCd         ==  strArry[y].substr( strArry[y].indexOf(',')+1,(strArry[y].length)+1  )       ){IsIn = false;} 
        }  
  if(IsIn) {       
    sortArray[x]='null';      
}
}
    var selectIndex = 0;
    var currentIndex = 0;
		for(z=0;z<sortArray.length;z++){ 
  if(sortArray[z]!='null') {       
			document.frm1.cmbRoomType.options[document.frm1.cmbRoomType.length]= 
			new Option(sortArray[z].GRTDesc,sortArray[z].GRTCd); 
			if((sortArray[z].GRTCd == "GRT10") && isDefaultRoomTypeSet == true)
			{
				selectIndex = currentIndex + 1;
				isDefaultRoomTypeSet = false;
			}
			currentIndex++;
		}
		}
		document.frm1.cmbRoomType.selectedIndex = selectIndex;
		roomtypesetter(document.frm1.cmbRoomType);
}
///////////////////////ggggggg//////////////////////////////////////////////////





function hoteltypebycity(city_code)
{

//alert('tigs1 >>'+city_code);
var isHostel = false; 	 
var oGroup = document.createElement('optgroup'); 	 
var oSelect = document.frm1.elements["cmbAmenity"]; 
var x=0;
(oSelect.hasChildNodes())
{ 
	oSelect.removeChild(oSelect.firstChild);
	oSelect.innerHTML = '';
} 
//alert('tigs2');
oSelect.length=0; 
 oSelect = document.frm1.elements["cmbAmenity"]; 
var oOption = document.createElement('option'); 
oOption.value = '%';  
oOption.innerHTML = 'All';  
oSelect.appendChild(oOption); 
if((city_code!='%')){ 
//alert('tigs3');
var chk='N'; 
var subTitle=''; 
for(a=0;a<arrCtyhty.length;a++){
//alert('tigs4');
	if(arrCtyhty[a].Cty==city_code){ 
		chk='Y'; 
		//alert('arrCtyhty[a].HtyID >>>'+arrCtyhty[a].HtyID);
		strVal=arrCtyhty[a].HtyID.split(",")
		for(b=0;b<strVal.length-1;b++){ 
			if(arrHty[strVal[b]].HtyTle!='-'){
			if(arrHty[strVal[b]].HtyDesc=='Hostel'){isHostel = true;}
				if(subTitle!=arrHty[strVal[b]].HtyTle){ 
					var oGroup = document.createElement('optgroup'); 
					oGroup.label = arrHty[strVal[b]].HtyTle; 	
				}
				var oOption = document.createElement('option'); 
				oOption.value = arrHty[strVal[b]].HtyCd;  
				oOption.innerHTML = arrHty[strVal[b]].HtyDesc;  
				oGroup.appendChild(oOption); 	
				if(subTitle!=arrHty[strVal[b]].HtyTle){ 
					oSelect.appendChild(oGroup); 	
					subTitle=arrHty[strVal[b]].HtyTle;	
				}
			}else if((arrHty[strVal[b]].HtyTle=='-')&&(arrHty[strVal[b]].HtyDesc=='Hostel')&&(!isHostel)){
				if(subTitle!='Type of Hotel'){ 
					var oGroup = document.createElement('optgroup'); 
					oGroup.label = 'Type of Hotel'; 	
				}
				var oOption = document.createElement('option'); 
				oOption.value = arrHty[strVal[b]].HtyCd;  
				oOption.innerHTML = arrHty[strVal[b]].HtyDesc;  
				oGroup.appendChild(oOption); 	
				if(subTitle!='Type of Hotel'){ 
					oSelect.appendChild(oGroup); 	
					subTitle='Type of Hotel';	
				}
			}else{ 
			}
		}
	}
	if(chk=='Y'){ 
		break;
	}
}

chkBRmTyp(document.frm1.cityCd.value,document.frm1.selCategory.value);
}else{
  var subTitle=''; 
  //alert('helz');
	for(a=0;a<arrHty.length;a++){
			if(arrHty[a].HtyTle=='-'){ 
				var oOption = document.createElement('option'); 
				oOption.value = arrHty[a].HtyCd;  
				oOption.innerHTML = arrHty[a].HtyDesc;  
				oSelect.appendChild(oOption); 
			}else{
				if(subTitle!=arrHty[a].HtyTle){ 
					var oGroup = document.createElement('optgroup'); 
					oGroup.label = arrHty[a].HtyTle; 	
				}
				var oOption = document.createElement('option'); 
				oOption.value = arrHty[a].HtyCd;  
				oOption.innerHTML = arrHty[a].HtyDesc;  
				oGroup.appendChild(oOption); 	
				if(subTitle!=arrHty[a].HtyTle){ 
					oSelect.appendChild(oGroup); 	
					subTitle=arrHty[a].HtyTle;	
				}
			}
	}
	
	chkRmTypByCty(city_code);
}
}











var str = '';
var str1 = '';


function chkBRmTyp(Value1){

if(Value1 != "%")
{

for(xz=0;xz<arrHot.length;xz++)

if(arrHot[xz].hotCd == Value1)
{
	//alert('arrHot[xz].hotCd '+arrHot[xz].hotCd);
	//chkRmTypByCty(arrHot[xz].hotCd); 
	str ="";
	strVal=arrHot[xz].arGRTEle.split(",")
		for(b=0;b<strVal.length-1;b++){ 
if(str.indexOf(arrGRT[strVal[b]].GRTDesc,arrGRT[strVal[b]].GRTCd)== -1) {  
 str = str+arrGRT[strVal[b]].GRTDesc+','+arrGRT[strVal[b]].GRTCd;    
 str = str+'|';    
		}
	}
}
}else
{
chkRmTypByCty(document.frm1.cityCd.value);
}

playRoomTypez();
}


function chkRmTypByCty(Valz){
document.frm1.cmbRoomType.length=1;
var chk='N'; 
for(a1=0;a1<arrHot.length;a1++){
	if(arrHot[a1].hotCty==Valz){ 
	
		chk='Y'; 
		strVal=arrHot[a1].arGRTEle.split(",")
		for(b=0;b<strVal.length-1;b++){ 
if(str.indexOf(arrGRT[strVal[b]].GRTDesc,arrGRT[strVal[b]].GRTCd)== -1) {  
 str = str+arrGRT[strVal[b]].GRTDesc+','+arrGRT[strVal[b]].GRTCd;    
 str = str+'|';    
		}
	}
	//if(chk=='Y'){ 
	//	break;
	//}
}
}
str1 = str;
}

//long SilkRoad
