var nav=navigator.appName;
var tmp_dt=new Date();
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 loadDates(){
	document.forms["frm1"].elements["hidCurrYear"].value=m_today.getFullYear();
	document.forms["frm1"].elements["hidCurrMonth"].value=m_today.getMonth();
	/*
 var selElm = document.forms["frm1"].elements["cmbCheckInMY"];
	selElm.removeChild(selElm[0]);
	
	selElm = document.forms["frm1"].elements["cmbCheckInDate"];
	selElm.removeChild(selElm[0]);

	selElm = document.forms["frm1"].elements["cmbNoOfAdults"];
	selElm.removeChild(selElm[0]);

	selElm = document.forms["frm1"].elements["cmbNoOfNights"];
	selElm.removeChild(selElm[0]);
*//*
	for (var kk1=0; kk1<my_arr.length; kk1++){
		document.forms["frm1"].elements["cmbCheckInMY"].options[document.forms["frm1"].elements["cmbCheckInMY"].options.length]=new Option(my_arr[kk1],my_val_arr[kk1]);
	}
	for (var i=0; i<31; i++){
		document.forms["frm1"].elements["cmbCheckInDate"].options[document.forms["frm1"].elements["cmbCheckInDate"].options.length]=new Option(i+1,i+1);
	}
	
	for (var kk1=0; kk1<my_arr.length; kk1++){
		document.forms["frm1"].elements["cmbCheckOutMY"].options[document.forms["frm1"].elements["cmbCheckOutMY"].options.length]=new Option(my_arr[kk1],my_val_arr[kk1]);
	}
	for (var i=0; i<31; i++){
		document.forms["frm1"].elements["cmbCheckOutDate"].options[document.forms["frm1"].elements["cmbCheckOutDate"].options.length]=new Option(i+1,i+1);
	}
	
	for (var i=0; i<10; i++){
		document.forms["frm1"].elements["cmbNoOfAdults"].options[document.forms["frm1"].elements["cmbNoOfAdults"].options.length]=new Option(i+1,i+1);
	}
	for (var i=0; i<30; i++){
		document.forms["frm1"].elements["cmbNoOfNights"].options[document.forms["frm1"].elements["cmbNoOfNights"].options.length]=new Option(i+1,i+1);
	}
	if(m_today.getMonth() < m_indt.getMonth())
		document.forms["frm1"].elements["cmbCheckInMY"].selectedIndex = 1;
	setMonthDays("In");
	document.forms["frm1"].elements["cmbCheckInDate"].selectedIndex=Number(m_indt.getDate())-1;
	setCheckOut();
}*/
/*
function setCheckOut(){
	var tmpInMY=document.forms["frm1"].elements["cmbCheckInMY"].options[document.forms["frm1"].elements["cmbCheckInMY"].options.selectedIndex].value;
	var tmpInMY_vals=tmpInMY.split("-");
	document.forms["frm1"].elements["cmbCheckInMonth"].value	=tmpInMY_vals[1];
	document.forms["frm1"].elements["cmbCheckInYear"].value	=tmpInMY_vals[0];
	var tmpInDate = new Date(tmpInMY_vals[0],tmpInMY_vals[1],document.forms["frm1"].elements["cmbCheckInDate"].options[document.forms["frm1"].elements["cmbCheckInDate"].selectedIndex].value,0,0,0,0);
	noDays = Number(document.forms["frm1"].elements["cmbNoOfNights"].options[document.forms["frm1"].elements["cmbNoOfNights"].selectedIndex].value);
	tmpOutDate = new Date(tmpInDate.setDate(tmpInDate.getDate()+noDays));
	document.forms["frm1"].elements["cmbCheckOutMonth"].value	= tmpOutDate.getMonth();
	document.forms["frm1"].elements["cmbCheckOutYear"].value	= tmpOutDate.getFullYear();
	document.forms["frm1"].elements["cmbCheckOutDate"].value	= tmpOutDate.getDate();
}

*/

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(){
/*
 document.frm1.cmbCheckInYear.options.length=0;
 for (a=0; a<5; a++){
	with (document.frm1){
	yr1=inyy+a;
	yr2=yr1.toString();
	cmbCheckInYear.options[a]= new Option(inyy+a,inyy+a);
	cmbCheckOutYear.options[a]= new Option(inyy+a,inyy+a);
 }
}
*/
set_CalendarMonths();
 var selElm = document.forms["frm1"].elements["cmbCheckInymcombo"];
	selElm.removeChild(selElm[0]);
	var selElm = document.forms["frm1"].elements["cmbCheckOutymcombo"];
	selElm.removeChild(selElm[0]);
	for (var 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/////////////////////////// 
	


with (document.frm1){
	cmbNoOfAdults.selectedIndex=2;
	/*
	cmbCheckInMonth.selectedIndex		=	inmm;
	cmbCheckInYear.selectedIndex			= inyy-inyy;
	cmbCheckOutMonth.selectedIndex		=	outmm;
	cmbCheckOutYear.selectedIndex			= inyy-inyy;
	*/
	}
	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;
/////////////////////////////////////////////////////////////


/*if (Number(outdd)<10){
 document.frm1.cmbCheckOutDate.value		= "0"+outdd+"";
}else{
 document.frm1.cmbCheckOutDate.value		= outdd;
}*/
for (var i=0; i<10; i++){
		document.forms["frm1"].elements["cmbNoOfAdults"].options[document.forms["frm1"].elements["cmbNoOfAdults"].options.length]=new Option(i+1,i+1);
	}
	document.frm1.disvalue.checked = false;
	document.frm1.selDiscount1.value = "N";
	document.frm1.HidRoomType.value = "%";
	document.frm1.cmbNoOfAdults.selectedIndex = 1;
		hoteltypebycity(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 set_default_date1(){
 document.frm1.cmbCheckInYear.options.length=0;
 for (a=0; a<5; a++){
	with (document.frm1){
	yr1=inyy+a;
	yr2=yr1.toString();
	cmbCheckInYear.options[a]= new Option(inyy+a,inyy+a);
	cmbCheckOutYear.options[a]= new Option(inyy+a,inyy+a);
 }
}


with (document.frm1){
	cmbNoOfAdults.selectedIndex=1;
	cmbCheckInMonth.selectedIndex		=	inmm;
	cmbCheckInYear.selectedIndex			= inyy-inyy;
	cmbCheckOutMonth.selectedIndex		=	outmm;
	cmbCheckOutYear.selectedIndex			= inyy-inyy;
	}
document.images["inday"].src="images/RG_dd"+(tmp_indt.getDay())+".gif";
setMonthDays("In");
document.frm1.cmbCheckInDate.selectedIndex			= indd-1;
document.images["outday"].src="images/RG_dd"+(Number(m_outdt.getDay()))+".gif";
setMonthDays("Out");
document.frm1.cmbCheckOutDate.selectedIndex			= outdd-1;


	document.frm1.disvalue.checked = false;
	document.frm1.selDiscount1.value = "N";
	document.frm1.HidRoomType.value = "%";
	hoteltypebycity(document.frm1.cityCd.value);
	//chkBRmTyp(document.frm1.cityCd.value,document.frm1.selCategory.value);
	document.getElementById("imgSearch").style.display = "block";
	document.getElementById("imgPleaseWait").style.display = "none";
	document.forms["frm1"].cmbNoOfNights.value = "1";
}
*/

/*
function setCheckOutnew(){
//	alert('name >>');
	var tmpInDate = new Date(document.forms["frm1"].elements["cmbCheckInYear"].options[document.forms["frm1"].elements["cmbCheckInYear"].selectedIndex].value,
								document.forms["frm1"].elements["cmbCheckInMonth"].options[document.forms["frm1"].elements["cmbCheckInMonth"].selectedIndex].value,
								document.forms["frm1"].elements["cmbCheckInDate"].options[document.forms["frm1"].elements["cmbCheckInDate"].selectedIndex].value,
								0,0,0,0);
	
	var tmpInDateout = new Date(document.forms["frm1"].elements["cmbCheckOutYear"].options[document.forms["frm1"].elements["cmbCheckOutYear"].selectedIndex].value,
								document.forms["frm1"].elements["cmbCheckOutMonth"].options[document.forms["frm1"].elements["cmbCheckOutMonth"].selectedIndex].value,
								document.forms["frm1"].elements["cmbCheckOutDate"].options[document.forms["frm1"].elements["cmbCheckOutDate"].selectedIndex].value,
								0,0,0,0);

	document.images["outday"].src="images/RG_dd"+(tmpInDateout.getDay())+".gif";
	noDays = (tmpInDateout - tmpInDate)/one_day;
	

	document.forms["frm1"].cmbNoOfNights.value = noDays;
	document.getElementById("calWin").style.visibility="hidden";
	document.getElementById("calWin").style.height="1px";
	document.getElementById("inCal").src="images/RG_cal_acexp.gif";
	document.getElementById("outCal").src="images/RG_cal_acexp.gif";
//	window.frames[0].location.href="calendar_achotelrooms.html";
}
*/
/*
function setMonthDays(name){
    alert('t1');
//	var tmpInYY=document.forms["frm1"].elements["cmbCheckInYY"].options[document.forms["frm1"].elements["cmbCheckInYY"].options.selectedIndex].value;
	var tmpInMY=document.forms["frm1"].elements["cmbCheck"+name+"MY"].options[document.forms["frm1"].elements["cmbCheck"+name+"MY"].options.selectedIndex].value;
	var tmpInMY_vals=tmpInMY.split("-");
	tmpmm	= tmpInMY_vals[1];
	tmpyy	= tmpInMY_vals[0];

//	alert('tmpInMY >> '+tmpInMY)
/*
	if (tmpyy != tmpInYY){
		for (var kk1=0; kk1<document.forms["frm1"].elements["cmbCheckInYY"].options.length; kk1++){
			if (document.frm1.elements["cmbCheck"+name+"YY"].options[kk1].value == tmpyy){
				document.frm1.elements["cmbCheck"+name+"YY"].options[kk1].selected = true;
				break;
			}
		}
	}
*//*
	maxdays = maxdate(tmpmm,tmpyy);
	selectedInd=document.frm1.elements["cmbCheck"+name+"Date"].selectedIndex;
	document.frm1.elements["cmbCheck"+name+"Date"].options.length=28;
	toAdd=maxdays-28;
	for (a=0; a<toAdd; a++){
		document.frm1.elements["cmbCheck"+name+"Date"].options[document.frm1.elements["cmbCheck"+name+"Date"].options.length] = new Option(29+a,29+a);
	}
	new_lnth=document.frm1.elements["cmbCheck"+name+"Date"].options.length;
	if (new_lnth<selectedInd+1){
		document.frm1.elements["cmbCheck"+name+"Date"].selectedIndex=document.frm1.elements["cmbCheck"+name+"Date"].options.length-1;
	}else{
		document.frm1.elements["cmbCheck"+name+"Date"].selectedIndex=selectedInd;
	}
}
*/
/*
function setYearsMonth(name){
	var tmpInYY=document.forms["frm1"].elements["cmbCheckInYY"].options[document.forms["frm1"].elements["cmbCheckInYY"].options.selectedIndex].value;
	var tmpInMY=document.forms["frm1"].elements["cmbCheckInMY"].options[document.forms["frm1"].elements["cmbCheckInMY"].options.selectedIndex].value;
	var tmpInMY_vals=tmpInMY.split("-");
	tmpmm	= tmpInMY_vals[1];
	tmpyy	= tmpInMY_vals[0];
	if (tmpyy != tmpInYY){
		var tmpInMM = temp_month;
		if (tmpInYY > tmpyy) tmpInMM=0;
		for (var kk1=0; kk1<document.forms["frm1"].elements["cmbCheckInMY"].options.length; kk1++){
			if (document.frm1.elements["cmbCheck"+name+"MY"].options[kk1].value == tmpInYY+"-"+tmpInMM){
				document.frm1.elements["cmbCheck"+name+"MY"].options[kk1].selected = true;
				break;
			}
		}
	}
	//setMonthDays(name);
}

function maxdate(mm,yy){
	if (mm==1){
		if(yy%4==0){return 29;}else{return 28;}
	}else if (mm==0 || mm==2 || mm==4 || mm==6 || mm==7 || mm==9 || mm==11){
		return 31;
	}else{
		return 30;
	}
}*/

/*function LoadCal(DateType,monthYField,dayField,formName,name){
dayval=Number(document.forms[formName].elements[dayField].options[document.forms[formName].elements[dayField].selectedIndex].value);
monthval=Number(document.forms[formName].elements[monthYField].options[document.forms[formName].elements[monthYField].selectedIndex].value);
//yearval=Number(document.forms[formName].elements[yearField].options[document.forms[formName].elements[yearField].selectedIndex].value);
fromdayz=Number(document.forms[formName].elements["cmbCheckInDate"].options[document.forms[formName].elements["cmbCheckInDate"].selectedIndex].value);
todayz=Number(document.forms[formName].elements["cmbCheckOutDate"].options[document.forms[formName].elements["cmbCheckOutDate"].selectedIndex].value);
frommonthz=Number(document.forms[formName].elements["cmbCheckInMonth"].value);
tomonthz=Number(document.forms[formName].elements["cmbCheckOutMonth"].value);

var tmpInMY=document.forms["frm1"].elements["cmbCheck"+name+"MY"].options[document.forms["frm1"].elements["cmbCheck"+name+"MY"].options.selectedIndex].value;
	var tmpInMY_vals=tmpInMY.split("-");
	monthField	= tmpInMY_vals[1];
	yearField	= tmpInMY_vals[0];
	
window.open("http://192.168.1.212:81/Ts/includefile/loaddates.asp?DateType="+DateType+"&FormName="+formName+"&DayField="+dayField+"&day="+dayval+"&MonthField=cmbCheck"+name+"Month&month="+(Number(monthField)+1)+"&YearField=cmbCheck"+name+"Year&year="+yearField+"&fromdayz="+fromdayz+"&todayz="+todayz+"&frommonthz="+frommonthz+"&tomonthz="+tomonthz+"&afftCode=RA&langCode=en","calwin","width=250,height=205,top=280,left=100,toolbar=0,location=0,directories=0,status=1,menuBar=0,scrollBars=1,resizable=0");
}*/


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 (tmpOutDate<tmpInDate){
  alert("Check Out Date should be greater than Check In Date");
   // document.getElementById("imgSearch").style.display = "block";
 //document.getElementById("imgPleaseWait").style.display = "none";
  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://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://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.cmbAmenity.options[document.frm1.cmbAmenity.selectedIndex].value)+"&slCt="+escape(document.frm1.selCity.value)+"&CtgNm="+escape(document.frm1.cmbAmenity.options[document.frm1.cmbAmenity.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";

	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;
}

////////////////ggggggggg111111/////////////////////////////////
/*
function chkRmTypByHttype(objroomsetter) { // hotel type gggggg
alert('objroomsetter ##>>>'+objroomsetter.value);
	document.frm1.selCategory.value = document.frm1.cmbAmenity.options[document.frm1.cmbAmenity.selectedIndex].value;
	chkBRmTyp(document.frm1.cityCd.value,document.frm1.selCategory.value);	
}
*/
function chkRmTypByHttype(Valz){

str =''; 
str1 = '';
if(Valz != '%'){
document.frm1.cmbRoomType.length=1;
var chk='N'; 
for(a=0;a<arrCtyhtyrty.length;a++){
	//if(arrCtyhtyrty[a].Cty==document.frm1.cmbCity.options[document.frm1.cmbCity.selectedIndex].value){ 
	if(arrCtyhtyrty[a].HtyID==Valz){ 
		chk='Y'; 
		strVal=arrCtyhtyrty[a].RtyID.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;
	}*/
}
//}
}
playRoomTypez();
}else{

chkRmTypByCty(document.frm1.cityCd.value);
str = str1;
playRoomTypez();
}
}
///////////////////////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 = document.frm1.hidDefultTypAll.value;  
oSelect.appendChild(oOption); 
if((city_code!='%')){ 
//alert('tigs3');
var chk='N'; 
var subTitle=''; 

var selectIndex = 0;
var currentIndex = 0;

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'); 

				if(arrHty[strVal[b]].HtyCd == document.frm1.landingHotelType.value)
				{
					selectIndex = currentIndex + 1;
				}
				currentIndex++;

				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'); 
				
				if(arrHty[strVal[b]].HtyCd == document.frm1.landingHotelType.value)
				{
					selectIndex = currentIndex + 1;
				}
				currentIndex++;

				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{ 
			}
			document.frm1.cmbAmenity.selectedIndex = selectIndex;
		}
	}
	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);
}









/*
alert('objroomsetter >>>'+city_code);
if((city_code!='%')){ 
document.frm1.cmbAmenity.length=1
for(a=0;a<arrCtyhty.length;a++){
	if(arrCtyhty[a].Cty==city_code){
//	arrCtyhtyrty[a].HtyID
	alert('arrCtyhty[a].HtyID >>>'+arrCtyhty[a].HtyID);
	strVal=arrCtyhty[a].HtyID.split(",");

		for(b=0;b<strVal.length-1;b++){ 

			document.frm1.cmbAmenity.options[document.frm1.cmbAmenity.length]= 
			new Option(arrHty[strVal[b]].HtyDesc,arrHty[strVal[b]].HtyCd); 
			 str = str+arrHty[strVal[b]].HtyDesc+','+arrHty[strVal[b]].HtyCd;    
 str = str+'|';    
		}
		if(chk=='Y'){ 
		break;
		}
	
	/*document.frm1.cmbAmenity.options[document.frm1.cmbAmenity.length]= 
			new Option(arrGRT[strVal[b]].GRTDesc,arrGRT[strVal[b]].GRTCd); 
			 str = str+arrGRT[strVal[b]].GRTDesc+','+arrGRT[strVal[b]].GRTCd; 
	*/
	/*}
	}
//.options[document.frm1.cmbAmenity.selectedIndex].value
*/
//}




}











var str = '';
var str1 = '';



function chkBRmTyp(Value1,value2){
//alert('Value1>>'+Value1);

	str = '';
if((value2!='%')){ 
document.frm1.cmbRoomType.length=1;
var chk='N'; 
for(a=0;a<arrCtyhtyrty.length;a++){
//	if(arrHot[a].hotCd==Value1){ 
	if(arrCtyhtyrty[a].Cty==Value1){ 

	if(arrCtyhtyrty[a].HtyID==value2){
//alert('arrCtyhtyrty[a].HtyID>>'+arrCtyhtyrty[a].HtyID);
			chk='Y'; 
		strVal=arrCtyhtyrty[a].RtyID.split(",")
		
		for(b=0;b<strVal.length-1;b++){ 

			document.frm1.cmbRoomType.options[document.frm1.cmbRoomType.length]= 
			new Option(arrGRT[strVal[b]].GRTDesc,arrGRT[strVal[b]].GRTCd); 
			 str = str+arrGRT[strVal[b]].GRTDesc+','+arrGRT[strVal[b]].GRTCd;    
 str = str+'|';    
		}
		if(chk=='Y'){ 
		break;
		}	
	}
/*		chk='Y'; 
		strVal=arrHot[a].arGRTEle.split(",")
		for(b=0;b<strVal.length-1;b++){ 
			document.frm1.cmbRoomType.options[document.frm1.cmbRoomType.length]= 
			new Option(arrGRT[strVal[b]].GRTDesc,arrGRT[strVal[b]].GRTCd); 
		}
	}*/
	//chkRmTypByCty(arrHot[a].hotCd); 
/*	if(chk=='Y'){ 
		break;
	}*/

}
}
playRoomTypez(); 
document.forms["frm1"].cmbRoomType.selectedIndex=0;
}else{
chkRmTypByCty(Value1);

str = str1;    
playRoomTypez(); 
/*document.forms["frm1"].cmbRoomType.selectedIndex=0;*/
}
}


					
					
			






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;
}
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")
			{
				selectIndex = currentIndex + 1;
			}
			currentIndex++;
		}
		}
		document.frm1.cmbRoomType.selectedIndex = selectIndex;
		roomtypesetter(document.frm1.cmbRoomType);
}
//long SilkRoad
