// JScript source code
// JScript source code
var liveagentlink;
function checkarrivaldate()
{
hide('deptError');
	var inday; 
	var inmon;	
	var inyear;
	var outday;
	var outmon;
	var outyear;
	outday=document.frmBooking.OutDay.options[document.frmBooking.OutDay.selectedIndex].value;
	outmon=document.frmBooking.OutMonth.options[document.frmBooking.OutMonth.selectedIndex].value;
	outyear=document.frmBooking.OutYear.options[document.frmBooking.OutYear.selectedIndex].value;
	var strdatenew = new Date();
	var presenetmonth= (parseInt(strdatenew.getMonth())+1);
	var presenetyear= strdatenew.getFullYear();
	inday=document.frmBooking.InDay.options[document.frmBooking.InDay.selectedIndex].value;
	inmon=document.frmBooking.InMonth.options[document.frmBooking.InMonth.selectedIndex].value;
	inyear=document.frmBooking.InYear.options[document.frmBooking.InYear.selectedIndex].value;
	inyear=document.frmBooking.InYear.options[document.frmBooking.InYear.selectedIndex].value;
	
	if (Number(inmon)!="2"  && Number(inday)>=30){
		var monthday;
		monthday=GetMonthDays((Number(inmon)-1));
		if(monthday<Number(inday)) 
		{
			inday=monthday;
		}
	}
	
	if (Number(inmon)=="2" && Number(inday)>=29)
	{
		
		if(LeapYear(Number(inyear))==false)
		{
			
			inday="28";
			errMsg = document.frmBooking.Dyn_txtFeb28.value;
			var selectedyear;
			selectedyear=new String(document.frmBooking.InYear.options[document.frmBooking.InYear.selectedIndex].value);
			errMsg= replaceSubstring(errMsg,"[year]",new String(selectedyear));
			show('deptError',errMsg);
			return false;
			
		}
		else{
			inday="29";
		}
	}
	if (Number(inmon)!=presenetmonth ){
		if (presenetmonth=="12"){
			if(Number(inyear)!=presenetyear){
				inyear =(Number(inyear));
			}
		}
	}
	if (Number(outmon)!="2" && Number(outday)>=30){
		var monthday;
		monthday=GetMonthDays((Number(outmon)-1));
		if(monthday<Number(outday)) 
		{
			outday=monthday;
		}
	}
	
	if (Number(outmon)!=presenetmonth ){
		if (presenetmonth=="12"){
			if(Number(outyear)!=presenetyear){
				outyear =(Number(outyear));
			}
		}
		
	}
	document.frmBooking.OutYear.value=outyear;
	if (Number(outmon)=="2" && Number(outday)>=29)
	{
		if(LeapYear(Number(outyear))==false)
		{
			outday="28";
			errMsg = document.frmBooking.Dyn_txtFeb28.value;
			var selectedyear;
			selectedyear=new String(document.frmBooking.InYear.options[document.frmBooking.InYear.selectedIndex].value);
			errMsg= replaceSubstring(errMsg,"[year]",new String(selectedyear));
			show('deptError',errMsg);
			return false;
			
		}
		else{
			outday="29";
		}
	}
	
	document.frmBooking.OutYear.value=outyear;
	var todaydate=new Date();
	var todayday;
	var todayyear;
	var todaymon;
	//alert("todaydate = "+todaydate);
	
	var stodaydate = new Date(GetMonthString(todaydate.getMonth())+" "+ (Number(todaydate.getDate())+2) +", "+todaydate.getFullYear());
	todayday=(Number(todaydate.getDate())+2);
	
	todayyear=(Number(todaydate.getFullYear()));
	todaymon=(Number(todaydate.getMonth())+1);
	var stodayday;
	var stodayyear;
	var stodaymon;
	stodayday=(Number(stodaydate.getDate()));
	
	stodayyear=(Number(stodaydate.getFullYear()));
	stodaymon=(Number(stodaydate.getMonth())+1);
	//alert("todayday = "+stodayday);
	//alert("todaymon = "+stodaymon);
	//alert("todayyear = "+stodayyear);
	//alert("inday ="+inday);
	if (IsDateGreaterThanSysDate1(inday+"-"+inmon+"-"+inyear)==true){

		//alert("second if");
		
		var strdateout = new Date();
		var arrivaledate=new Date(GetMonthString(strdateout.getMonth())+" "+ (parseInt(strdateout.getDate())+2) +", "+strdateout.getFullYear());
		document.frmBooking.InDay.value=arrivaledate.getDate();
		document.frmBooking.InMonth.value=(parseInt(arrivaledate.getMonth())+1);
		document.frmBooking.InYear.value=arrivaledate.getFullYear();
		var departuredate=new Date(GetMonthString(strdateout.getMonth())+" "+ (parseInt(strdateout.getDate())+3) +", "+strdateout.getFullYear());
		document.frmBooking.OutDay.value=departuredate.getDate();
		document.frmBooking.OutMonth.value=(parseInt(departuredate.getMonth())+1);
		document.frmBooking.OutYear.value=departuredate.getFullYear();
		document.frmBooking.NoOfNight.value=1;
		
		errMsg = document.frmBooking.Dyn_txtArrDateGreater.value;
		//alert("errMsg = "+errMsg);
		var ssfinaldate;
		var slang;
		slang=document.all.sLang.value;
//alert("slangmain = "+slang);
		if (slang.toUpperCase()=="EN")
		{
			errMsg = "Arrival date must be greater than [date].";
		}
		//alert("slang = "+slang);
		ssfinaldate=dateconvertorhotel(slang,arrivaledate.getDate(),arrivaledate.getMonth(),arrivaledate.getFullYear());
		errMsg=errMsg.replace("[date]",ssfinaldate);
		//show('deptError',errMsg);
		
		return false;
		
	}
}
function Liveagent()
{
	show_LiveAgent("http://www.hoteltravel.com/liveagent/liveagent.htm","");
}
function changeOccRoom(){
//alert("test");
if (document.getElementById("WDDOC")==undefined)
{
}else{
hidediv("WDDOC");
}
//alert("indise");
var selectednight = document.frmBooking.NoOfRoom.options[document.frmBooking.NoOfRoom.selectedIndex].value;

var selected = document.frmBooking.Room.options[document.frmBooking.Room.selectedIndex].value;
//alert("selected = "+selected);
selected=replaceSubstring(selected,"/","-");
var slen;
slen = selected.length;
var occ1;
var occ2;
var occ3;
var occ4;
var occ5;
var occ6;
occ1=document.frmBooking.DDOC1.value;
occ2=document.frmBooking.DDOC2.value;
occ3=document.frmBooking.DDOC3.value;
occ4=document.frmBooking.DDOC4.value;
occ5=document.frmBooking.DDOC5.value;
occ6=document.frmBooking.DDOC6.value;
var socc;
	if(selectednight ==1){
	var arrOcc;
	arrOcc = eval('arr' + selected);
	document.frmBooking.DDOC1.options.length = 0;
		for(var iNum=0;iNum<=arrOcc.length-1;iNum++){
		var splOcc;
		var sOcc;
		sOcc = arrOcc[iNum];
		splOcc = sOcc.split("~");
		document.frmBooking.DDOC1.options[iNum]= new Option(splOcc[2],splOcc[1]);
			if(splOcc[1]==occ1){
				document.frmBooking.DDOC1.options[iNum].selected = true;
			}
		}
	}
	else{
		for(var i=1;i<=selectednight;i++){
		var arrOcc;
		arrOcc = eval('arr' + selected);
		eval('document.frmBooking.DDOC'+ i +'.options.length = 0');
			var optionObj;
			var objfound;
			optionObj = 0
			objfound=false;
			for(var iNum=0;iNum<=arrOcc.length-1;iNum++){
			var splOcc;
			var sOcc;
			sOcc = arrOcc[iNum];
			splOcc = sOcc.split("~");
			eval('document.frmBooking.DDOC'+ i +'.options[iNum] = new Option(splOcc[2],splOcc[1])');
				if(splOcc[1]==eval('occ' + i)){
					eval('document.frmBooking.DDOC' + i +'.options[iNum].selected = true');
				}
			}	
		}
	}
	DDOC1Select = document.frmBooking.DDOC1.selectedIndex;
	DDOC2Select = document.frmBooking.DDOC2.selectedIndex;
	DDOC3Select = document.frmBooking.DDOC3.selectedIndex;
	DDOC4Select = document.frmBooking.DDOC4.selectedIndex;
	DDOC5Select = document.frmBooking.DDOC5.selectedIndex;
	DDOC6Select = document.frmBooking.DDOC6.selectedIndex;
	//var selectednight = document.frmBooking.NoOfRoom.options[document.frmBooking.NoOfRoom.selectedIndex].value;
	var scheck;
	scheck=0;
	for (var i=1;i<=6;i++)
	{
		
		sval=eval('document.frmBooking.DDOC'+ i +'.value');
		//alert(sval);
		arrval=sval.split("|");
		sval=arrval[2];
		if (Number(sval)>0)
		{
			if (document.getElementById("WDDOC")==undefined)
{
}else{
showdiv("WDDOC");
}
			scheck=1;
			
		}
		else{
			if (scheck==0){
				if (document.getElementById("WDDOC")==undefined)
{
}else{
hidediv("WDDOC");
}
			}
		}
	}
}

function CheckOccSelect(obj,identity){
	if(eval('document.frmBooking.'+ obj +'.value') == 0){
		eval('document.frmBooking.'+ obj +'.selectedIndex = '+ obj +'Select');
	}
	eval(obj +'Select = document.frmBooking.'+ obj +'.selectedIndex');
	var sval;
	var arrval;
	
	var selectednight = document.frmBooking.NoOfRoom.options[document.frmBooking.NoOfRoom.selectedIndex].value;
	var scheck;
	scheck=0;
	for (var i=1;i<=6;i++)
	{
		
		sval=eval('document.frmBooking.DDOC'+ i +'.value');
		//alert(sval);
		arrval=sval.split("|");
		sval=arrval[2];
		if (Number(sval)>0)
		{
			if (document.getElementById("WDDOC")==undefined)
{
}else{
showdiv("WDDOC");
}
			scheck=1;
			
		}
		else{
			if (scheck==0){
				if (document.getElementById("WDDOC")==undefined)
{
}else{
hidediv("WDDOC");
}
			}
		}
	}
}
var browserType;

CurrentDate = new Date();
Currday = CurrentDate.getDate();
Currmonth = CurrentDate.getMonth();
Curryear = CurrentDate.getFullYear();

function hide(control) {
  cTln = eval('document.getElementById("'+ control +'")');
  cTln.style.visibility = "hidden";
  cTln.innerHTML = '';
}
function hidediv(control) {
  cTln = eval('document.getElementById("'+ control +'")');
  cTln.style.visibility = "hidden";
  cTln.style.display = 'none';
}
function show(control,err) {
  cTln = eval('document.getElementById("'+ control +'")');
  cTln.innerHTML = err;
  cTln.style.visibility = "visible";
 }
 function showdiv(control) {
  cTln = eval('document.getElementById("'+ control +'")');
   cTln.style.visibility = "visible";
   cTln.style.display = '';
 }
 function replaceSubstring(inputString, fromString, toString) {
   // Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function

// javascript by deepak on 20 Dec 2005
function checkdepadate()
{
	//alert("checkdepadate");
	hide('deptError');
	var inday; 
	var inmon;	
	var inyear;
	var outday;
	var outmon;
	var outyear;
	outday=document.frmBooking.OutDay.options[document.frmBooking.OutDay.selectedIndex].value;
	outmon=document.frmBooking.OutMonth.options[document.frmBooking.OutMonth.selectedIndex].value;
	outyear=document.frmBooking.OutYear.options[document.frmBooking.OutYear.selectedIndex].value;
	var strdatenew = new Date();
	var presenetmonth= (parseInt(strdatenew.getMonth())+1);
	var presenetyear= strdatenew.getFullYear();
	inday=document.frmBooking.InDay.options[document.frmBooking.InDay.selectedIndex].value;
	inmon=document.frmBooking.InMonth.options[document.frmBooking.InMonth.selectedIndex].value;
	inyear=document.frmBooking.InYear.options[document.frmBooking.InYear.selectedIndex].value;
	inyear=document.frmBooking.InYear.options[document.frmBooking.InYear.selectedIndex].value;
	
	if (Number(inmon)!="2"  && Number(inday)>=30){
		var monthday;
		monthday=GetMonthDays((Number(inmon)-1));
		if(monthday<Number(inday)) 
		{
			inday=monthday;
		}
	}
	
	if (Number(inmon)=="2" && Number(inday)>=29)
	{
		
		if(LeapYear(Number(inyear))==false)
		{
			
			inday="28";
			errMsg = document.frmBooking.Dyn_txtFeb28.value;
			var selectedyear;
			selectedyear=new String(document.frmBooking.InYear.options[document.frmBooking.InYear.selectedIndex].value);
			errMsg= replaceSubstring(errMsg,"[year]",new String(selectedyear));
			show('deptError',errMsg);
			return false;
			
		}
		else{
			inday="29";
		}
	}
	if (Number(inmon)!=presenetmonth ){
		if (presenetmonth=="12"){
			if(Number(inyear)!=presenetyear){
				inyear =(Number(inyear));
			}
		}
	}
	if (Number(outmon)!="2" && Number(outday)>=30){
		var monthday;
		monthday=GetMonthDays((Number(outmon)-1));
		if(monthday<Number(outday)) 
		{
			outday=monthday;
		}
	}
	
	if (Number(outmon)!=presenetmonth ){
		if (presenetmonth=="12"){
			if(Number(outyear)!=presenetyear){
				outyear =(Number(outyear));
			}
		}
		
	}
	document.frmBooking.OutYear.value=outyear;
	if (Number(outmon)=="2" && Number(outday)>=29)
	{
		if(LeapYear(Number(outyear))==false)
		{
			outday="28";
			errMsg = document.frmBooking.Dyn_txtFeb28.value;
			var selectedyear;
			selectedyear=new String(document.frmBooking.InYear.options[document.frmBooking.InYear.selectedIndex].value);
			errMsg= replaceSubstring(errMsg,"[year]",new String(selectedyear));
			show('deptError',errMsg);
			return false;
			
		}
		else{
			outday="29";
		}
	}
	
	document.frmBooking.OutYear.value=outyear;
	var todaydate=new Date();
	var todayday;
	var todayyear;
	var todaymon;
	//alert("todaydate = "+todaydate);
	
	var stodaydate = new Date(GetMonthString(todaydate.getMonth())+" "+ (Number(todaydate.getDate())+2) +", "+todaydate.getFullYear());
	todayday=(Number(todaydate.getDate())+2);
	
	todayyear=(Number(todaydate.getFullYear()));
	todaymon=(Number(todaydate.getMonth())+1);
	var stodayday;
	var stodayyear;
	var stodaymon;
	stodayday=(Number(stodaydate.getDate()));
	
	stodayyear=(Number(stodaydate.getFullYear()));
	stodaymon=(Number(stodaydate.getMonth())+1);
	//alert("todayday = "+stodayday);
	//alert("todaymon = "+stodaymon);
	//alert("todayyear = "+stodayyear);
	if (Number(inday)<stodayday && stodayyear==Number(inyear) && Number(inmon)<stodaymon)
	{
		//alert("first if");
		var strdateout = new Date();
		
		var arrivaledate=new Date(GetMonthString(strdateout.getMonth())+" "+ (parseInt(todayday)+30) +", "+strdateout.getFullYear());
		document.frmBooking.InDay.value=arrivaledate.getDate();
		document.frmBooking.InMonth.value=(parseInt(arrivaledate.getMonth())+1);
		document.frmBooking.InYear.value=arrivaledate.getFullYear();
		var departuredate=new Date(GetMonthString(strdateout.getMonth())+" "+ (parseInt(todayday)+31) +", "+strdateout.getFullYear());
		document.frmBooking.OutDay.value=departuredate.getDate();
		document.frmBooking.OutMonth.value=(parseInt(departuredate.getMonth())+1);
		document.frmBooking.OutYear.value=departuredate.getFullYear();
		return false;
	}
	else if (IsDateGreaterThanSysDate1(inday+"-"+inmon+"-"+inyear)==true){

		//alert("second if");
		
		var strdateout = new Date();
		var arrivaledate=new Date(GetMonthString(strdateout.getMonth())+" "+ (parseInt(strdateout.getDate())+2) +", "+strdateout.getFullYear());
		document.frmBooking.InDay.value=arrivaledate.getDate();
		document.frmBooking.InMonth.value=(parseInt(arrivaledate.getMonth())+1);
		document.frmBooking.InYear.value=arrivaledate.getFullYear();
		var departuredate=new Date(GetMonthString(strdateout.getMonth())+" "+ (parseInt(strdateout.getDate())+3) +", "+strdateout.getFullYear());
		document.frmBooking.OutDay.value=departuredate.getDate();
		document.frmBooking.OutMonth.value=(parseInt(departuredate.getMonth())+1);
		document.frmBooking.OutYear.value=departuredate.getFullYear();
		document.frmBooking.NoOfNight.value=1;
		
		errMsg = document.frmBooking.Dyn_txtArrDateGreater.value;
		//alert("errMsg = "+errMsg);
		var ssfinaldate;
		var slang;
		slang=document.all.sLang.value;
		if (slang.toUpperCase()=="EN")
		{
			errMsg = "Arrival date must be greater than [date].";
		}
		//alert("slang123= "+slang);
		ssfinaldate=dateconvertorhotel(slang,arrivaledate.getDate(),arrivaledate.getMonth(),arrivaledate.getFullYear());
		errMsg=errMsg.replace("[date]",ssfinaldate);
		show('deptError',errMsg);
		
		return false;
		
	}
	else if (isDateGreaterThanEqual1(outday+"-"+outmon+"-"+outyear,inday+"-"+inmon+"-"+inyear)==true){
		//alert("third if");
		var inoofnghts;
		
		inoofnghts=1;
		
		document.frmBooking.NoOfNight.value=inoofnghts;
		
		var strdateout = new Date(inyear,inmon-1,(parseInt(inday)+parseInt(inoofnghts)));
		
		var departuredate=new Date(GetMonthString(strdateout.getMonth())+" "+ (parseInt(strdateout.getDate())) +", "+strdateout.getFullYear());
		document.frmBooking.OutDay.value=departuredate.getDate();
		document.frmBooking.OutMonth.value=(parseInt(departuredate.getMonth())+1);
		document.frmBooking.OutYear.value=departuredate.getFullYear();
		
		errMsg = document.frmBooking.Dyn_txtARRDEPT.value;
		show('deptError',errMsg);
		return false;
	}
	else{
		//alert("last if");
		if (UpdateNights(inday,inmon,inyear,outday,outmon,outyear)==true){
			return true;
		}else
		{
			return false;
		}
	}
	
}
function IsEmpty(s)
	{  
		return ((s == null) || (s.length == 0))
	}
function calculateNights()
{
	hide('deptError');
	var inday; 
	var inmon;	
	var inyear;
	var strdatenew = new Date();
	var presenetmonth= (parseInt(strdatenew.getMonth())+1);
	var presenetyear= strdatenew.getFullYear();
	var outday;
	var outmon;
	var outyear;
	outday=document.frmBooking.OutDay.options[document.frmBooking.OutDay.selectedIndex].value;
	outmon=document.frmBooking.OutMonth.options[document.frmBooking.OutMonth.selectedIndex].value;
	outyear=document.frmBooking.OutYear.options[document.frmBooking.OutYear.selectedIndex].value;
	inday=document.frmBooking.InDay.options[document.frmBooking.InDay.selectedIndex].value;
	inmon=document.frmBooking.InMonth.options[document.frmBooking.InMonth.selectedIndex].value;
	inyear=document.frmBooking.InYear.options[document.frmBooking.InYear.selectedIndex].value;
	inyear=document.frmBooking.InYear.options[document.frmBooking.InYear.selectedIndex].value;
	if (inmon!="2"  && parseInt(inday)>=30){
		var monthday;
		monthday=GetMonthDays((parseInt(inmon)-1));
		if(monthday<inday) 
		{
			inday=monthday;
		}
	}

	if (inmon=="2" && inday>=29)
	{
		
		if(LeapYear(inyear)==false)
		{
			
			inday="28";
			errMsg = document.frmBooking.Dyn_txtFeb28.value;
			var selectedyear;
			selectedyear=new String(document.frmBooking.InYear.options[document.frmBooking.InYear.selectedIndex].value);
			errMsg= replaceSubstring(errMsg,"[year]",new String(selectedyear));
			show('deptError',errMsg);
		}
		else{
			inday="29";
		}
	}
	if (inmon!=presenetmonth ){
		if (presenetmonth=="12"){
			if(inyear!=presenetyear){
				inyear =(parseInt(inyear));
			}
		}
	}
	if (outmon!="2" && parseInt(outday)>=30){
		var monthday;
		monthday=GetMonthDays((parseInt(outmon)-1));
		if(monthday<outday) 
		{
			outday=monthday;
		}
	}

	if (outmon!=presenetmonth ){
		if (presenetmonth=="12"){
			if(outyear!=presenetyear){
				outyear =(parseInt(outyear));
			}
		}
		
	}
	document.frmBooking.OutYear.value=outyear;
	if (outmon=="2" && outday>=29)
	{
		if(LeapYear(outyear)==false)
		{
			outday="28";
			errMsg = document.frmBooking.Dyn_txtFeb28.value;
			var selectedyear;
			selectedyear=new String(document.frmBooking.InYear.options[document.frmBooking.InYear.selectedIndex].value);
			errMsg= replaceSubstring(errMsg,"[year]",new String(selectedyear));
			show('deptError',errMsg);
			return false;
			
		}
		else{
			outday="29";
		}
	}

	document.frmBooking.OutYear.value=outyear;
	var todaydate=new Date();
	var todayday;
	var todayyear;
	var todaymon;
	todayday=(parseInt(todaydate.getDate())+2);
	todayyear=parseInt(todaydate.getFullYear());
	todaymon=(parseInt(todaydate.getMonth())+1);
	CalUpdateNights(inday,inmon,inyear,outday,outmon,outyear)
		
	
		
}
function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}
function noofnghts()
{
	var inoofnghts;
	inoofnghts=document.frmBooking.NoOfNight.options[document.frmBooking.NoOfNight.selectedIndex].value;
	var inday; 
	var inmon;
	var inyear;
	inday=document.frmBooking.InDay.options[document.frmBooking.InDay.selectedIndex].value;
	inmon=document.frmBooking.InMonth.options[document.frmBooking.InMonth.selectedIndex].value;
	inyear=document.frmBooking.InYear.options[document.frmBooking.InYear.selectedIndex].value;
	var strdateout = new Date(inyear,inmon-1,(parseInt(inday)+parseInt(inoofnghts)));
	document.frmBooking.OutDay.value=strdateout.getDate();
	document.frmBooking.OutMonth.value=(parseInt(strdateout.getMonth())+1);
	document.frmBooking.OutYear.value=strdateout.getFullYear();
}

function UpdateNights(iDayArrive, iMonthArrive, iYearArrive, iDayDept, iMonthDept, iYearDept) {
	hide('deptError');
	var strdate=new Date(iYearArrive,iMonthArrive-1,iDayArrive);
	var strdate1=new Date(iYearDept,iMonthDept-1,iDayDept);
	var strtime=strdate.getTime();
	var strtime1=strdate1.getTime();
	var strdiff=strtime1-strtime;
	var strfinal=strdiff/(24*60*60*1000);
	//alert("strfinal = "+strfinal);
	if (strfinal>30){
		var strdateout = new Date(iYearArrive,iMonthArrive-1,(parseInt(iDayArrive)+30));
		document.frmBooking.OutDay.value=strdateout.getDate();
		document.frmBooking.OutMonth.value=(parseInt(strdateout.getMonth())+1);
		document.frmBooking.OutYear.value=strdateout.getFullYear();
		document.frmBooking.NoOfNight.value = "30";
		errMsg = document.frmBooking.Dyn_txtLIVEAGENT.value;
		show('deptError',errMsg);
		return false;
	}else{
		document.frmBooking.OutDay.value=iDayDept;
		document.frmBooking.InDay.value=iDayArrive;
		document.frmBooking.NoOfNight.value = strfinal;
		return true;
	}
}
function CalUpdateNights(iDayArrive, iMonthArrive, iYearArrive, iDayDept, iMonthDept, iYearDept) {
	hide('deptError');
	var strdate=new Date(iYearArrive,iMonthArrive-1,iDayArrive);
	var strdate1=new Date(iYearDept,iMonthDept-1,iDayDept);
	//alert(strdate1);
	var strtime=strdate.getTime();
	var strtime1=strdate1.getTime();
	var strdiff=strtime1-strtime;
	//alert("Strdiff = "+strdiff);
	var strfinal;
	if (strdiff <= 0) {
		strfinal=0;
	}
	else
	{
		strfinal=strdiff/(24*60*60*1000);
	}	
	//alert("strfinal = "+strfinal);
	if (strfinal>0 && strfinal<=30){
	
		var strdateout = new Date(iYearArrive,iMonthArrive-1,(parseInt(iDayArrive)+parseInt(strfinal)));
		document.frmBooking.NoOfNight.value = parseInt(strfinal);
		document.frmBooking.OutDay.value=strdateout.getDate();
		document.frmBooking.OutMonth.value=(parseInt(strdateout.getMonth())+1);
		document.frmBooking.OutYear.value=strdateout.getFullYear();
		
		
		//errMsg = document.frmBooking.Dyn_txtLIVEAGENT.value;
		//show('deptError',errMsg);
		//return false;
	}else{
	document.frmBooking.NoOfNight.value = strfinal;
	}
	
}
/*Function to get the name of the month if the number Is given*/
function GetMonthString(num)
		 {
		 var month;
		 switch(num)
					{
					 case 0:
						  month = "Jan";
						  break;
					 case 1:
						  month = "Feb";
						  break;
					 case 2:
						  month = "Mar";
						  break;
					 case 3:
						  month = "Apr";
						  break;
					 case 4:
						  month = "May";
						  break;
					 case 5:
						  month = "Jun";
						  break;
					 case 6:
						  month = "Jul";
						  break;
					 case 7:
						  month = "Aug";
						  break;
					 case 8:
						  month = "Sep";
						  break;
					 case 9:
						  month = "Oct";
						  break;
					 case 10:
						  month = "Nov";
						  break;
					 case 11:
						  month = "Dec";
						  break;
					}
		 return month;
		 }
		 
function GetMonthDays(num)
		 {
		 var month;
		 switch(num)
					{
					 case 0:
						  month = "31";
						  break;
					 case 1:
						  month = "";
						  break;
					 case 2:
						  month = "31";
						  break;
					 case 3:
						  month = "30";
						  break;
					 case 4:
						  month = "31";
						  break;
					 case 5:
						  month = "30";
						  break;
					 case 6:
						  month = "31";
						  break;
					 case 7:
						  month = "31";
						  break;
					 case 8:
						  month = "30";
						  break;
					 case 9:
						  month = "31";
						  break;
					 case 10:
						  month = "30";
						  break;
					 case 11:
						  month = "31";
						  break;
					}
		 return month;
		 }
function IsDateGreaterThanSysDate1(date1)
{
	 var bufArray1 = date1.split("-");	
	 var effDateDay1 = bufArray1[0];
	 var effDateMonth1 = bufArray1[1];
	 var effDateYear1 = bufArray1[2];
	 
	 var effDateDate1 = new Date(GetMonthString(effDateMonth1-1)+" "+ (parseInt(effDateDay1)) +", "+effDateYear1);
	// alert(effDateDate1);
	 var date2 = new Date();
	 var effDateDate2 = new Date(GetMonthString(date2.getMonth())+" "+(parseInt(date2.getDate())+2) +", "+date2.getFullYear());
	//  alert(effDateDate2);
	if (effDateDate2 > effDateDate1) {
		
		return true;
	     }
	 else {
	
	     return false;
	     }


}

function isDateGreaterThanEqual1(date1,date2)
{
	
	 var bufArray1 = date1.split("-");
	 var effDateMonth1 = bufArray1[1].toUpperCase();
	 var effDateDay1 = bufArray1[0];
	 var effDateYear1 = bufArray1[2];
	 var effDateDate1 = new Date(GetMonthString(effDateMonth1-1)+" "+ effDateDay1 +
			   ", "+effDateYear1);

	 var bufArray2 = date2.split("-");
	 var effDateMonth2 = bufArray2[1].toUpperCase();
	 var effDateDay2 = bufArray2[0];
	 var effDateYear2 = bufArray2[2];
	 var effDateDate2 = new Date(GetMonthString(effDateMonth2-1)+" "+ effDateDay2 +
			   ", "+effDateYear2);
	 if (effDateDate1 <= effDateDate2)
	 return true;


}
//end javascript by deepak
function IsNumber(Expression)
{
	Expression = Expression.toLowerCase();
	RefString = "0123456789";

	if (Expression.length < 1) 
		return (false);

	for (var i = 0; i < Expression.length; i++) 
	{
		var ch = Expression.substr(i, 1);
		var a = RefString.indexOf(ch, 0);
		if (a == -1)
			return (false);
	}
	return(true);
}

function DisplayOcc() { 
checkarrivaldate();
		var cbo;
		var iNoOf;
		cbo = eval('document.frmBooking.NoOfRoom');
		iNoOf = cbo.value;
		for (var iNum=1; iNum<=6; iNum++)
			{
				if (iNum <= iNoOf) {
					Display('Occ'+iNum, 'Show');			
				}

				else {
					Display('Occ'+iNum, 'Hide');
				}
			}
			changeOccRoom();
			var selectednight = document.frmBooking.NoOfRoom.options[document.frmBooking.NoOfRoom.selectedIndex].value;
	var scheck;
	scheck=0;
	for (var i=1;i<=6;i++)
	{
		
		sval=eval('document.frmBooking.DDOC'+ i +'.value');
		//alert(sval);
		arrval=sval.split("|");
		sval=arrval[2];
		if (Number(sval)>0)
		{
			if (document.getElementById("WDDOC")==undefined)
{
}else{
showdiv("WDDOC");
}
			scheck=1;
			
		}
		else{
			if (scheck==0){
				if (document.getElementById("WDDOC")==undefined)
{
}else{
hidediv("WDDOC");
}
			}
		}
	}
	}

	function Display( control, visible) { 
		
		var browsername=navigator.appName;
		if(document.layers){
            browsername="NN4";
        }
        if(document.all){
            browsername="ie";
        }
        if(!document.all && document.getElementById){
            browsername="NN6";
        }
		if (browsername=="NN6"){
			var ctril;
			ctril= "document.getElementById(\""+control+"\")";
			
			var ctlName;
			ctlName = eval(ctril);
			
			switch (visible) {
				case "Hide":
					ctlName.style.visibility='hidden';
					ctlName.style.display = 'none';
					break;
				case "Show":
					ctlName.style.visibility='visible';
					ctlName.style.display = '';
					break;
				}
		}
		else if (browsername=="NN4"){
			var ctlName;
			ctlName = eval('document.'+ control);
			switch (visible) {
				case "Hide":
					ctlName.style.visibility='hidden';
					ctlName.style.display = 'none';
					break;
				case "Show":
					ctlName.style.visibility='visible';
					ctlName.style.display = '';
					break;
				}
		}
		else{
		
			var ctlName;
			ctlName = eval('document.all.'+ control);
			switch (visible) {
				case "Hide":
					ctlName.style.visibility='hidden';
					ctlName.style.display = 'none';
					break;
				case "Show":
					ctlName.style.visibility='visible';
					ctlName.style.display = '';
					break;
				}
		}
	}
function callBack()
{
	
	hide('deptError');
	var outday;
	var outmon;
	var outyear;
	var inday; 
	var inmon;
	var inyear;
	
	
	inday=document.frmBooking.InDay.options[document.frmBooking.InDay.selectedIndex].value;
	
	inmon=document.frmBooking.InMonth.options[document.frmBooking.InMonth.selectedIndex].value;
	inyear=document.frmBooking.InYear.options[document.frmBooking.InYear.selectedIndex].value;

	outday=document.frmBooking.OutDay.options[document.frmBooking.OutDay.selectedIndex].value;
	outmon=document.frmBooking.OutMonth.options[document.frmBooking.OutMonth.selectedIndex].value;
	outyear=document.frmBooking.OutYear.options[document.frmBooking.OutYear.selectedIndex].value;
	if (outmon!="2"){
		outday=GetMonthDays((parseInt(outmon)-1));
	}
	if (outmon=="2" && outday=="29")
	{
		if(LeapYear(outyear)==false)
		{
			outday=(parseInt(outday)-1);
			
			errMsg = document.frmBooking.Dyn_txtFeb28.value;
			var selectedyear;
			selectedyear=new String(document.frmBooking.InYear.options[document.frmBooking.InYear.selectedIndex].value);
			errMsg= replaceSubstring(errMsg,"[year]",new String(selectedyear));
			show('deptError',errMsg);
			
		}
	}
	var checklist;
	
	if (checkdepadate()==true){
		checklist=true;
	}
	else{
		checklist=false;
		return false;
		
		
	}
	
	if (isDateGreaterThanEqual1(outday+"-"+outmon+"-"+outyear,inday+"-"+inmon+"-"+inyear)==true){
	
		errMsg = document.frmBooking.Dyn_txtARRDEPT.value;
		
		show('deptError',errMsg);
		return false;
	}
	else if (checklist==true) {
	
	document.frmBooking.Dyn_txtLIVEAGENT.value=null;
			//start adding by deepak
				var sArrdt;
				var sNoofroom;
				var sNoofnts;
				var sroomtype;
				var socc;
				var sday;
				var smonth;
				sday = document.frmBooking.InDay.options[document.frmBooking.InDay.selectedIndex].value;
				smonth = document.frmBooking.InMonth.options[document.frmBooking.InMonth.selectedIndex].value;
				var sadylen;
				var smonthlen;
				smonthlen=smonth.length;
				sdaylen=sday.length
				if (parseInt(sdaylen)==1){
					sday = "0" + sday;
				}
				if (parseInt(smonthlen)==1) {
					smonth = "0" + smonth;
				 }
				 var syear;
				 syear = document.frmBooking.InYear.options[document.frmBooking.InYear.selectedIndex].value;
				 sArrdt="";
				 
				sArrdt = sday + smonth + syear;
			    sNoofroom = document.frmBooking.NoOfRoom.options[document.frmBooking.NoOfRoom.selectedIndex].value;
				sNoofnts = document.frmBooking.NoOfNight.options[document.frmBooking.NoOfNight.selectedIndex].value;
				sroomtype = document.frmBooking.Room.options[document.frmBooking.Room.selectedIndex].value;
				socc = "";
				var i;
				
				if (parseInt(sNoofroom)==1) {
					var soccroom;
					soccroom = document.frmBooking.DDOC1.options[document.frmBooking.DDOC1.selectedIndex].value;
					if (parseInt(soccroom)==5) {
						soccroom = "2";
					}
					socc = soccroom;
					
				}else{
					for (var i = 1;i<=parseInt(sNoofroom);i++){
						var sOccp;
						sOccp=""
						sOccp = "DDOC" + i;
						
						var soccroom;
						var soccobj
						soccroom = eval("document.frmBooking."+sOccp+".options[document.frmBooking."+sOccp+".selectedIndex].value");
						
						if (parseInt(soccroom)==5){
							soccroom = "2";
						}
						if (socc.length>0){
						socc = socc +'~'+ soccroom;
						}
						else
						{
						socc = socc + soccroom;
						}
						
					}
		      }
		     
			//end of add by depak
			var surl;
			var shotelcode;
			shotelcode=document.frmBooking.sHotelCode.value;
			var slang;
			slang=document.frmBooking.sLang.value;
			
			surl="http://www.hoteltravel.com/planner/travelplan.aspx?htc="+shotelcode+"&rc="+sroomtype+"&afc=AFH1000&wid=10012&lng="+slang+"&ArrDt="+sArrdt+"&NoNts="+sNoofnts+"&NoRm="+sNoofroom;//+"&Occ="+socc;
//alert(surl);
//document.frmBooking.action=surl;
//			document.frmBooking.submit();
window.location=surl;
return true;

	}
	
	return false;
	
}
function dateconvertorhotel(lang,inday,inmon,inyear)
{
	var sdate;
	if (lang.toUpperCase()=="CN")
	{
		sdate=inyear+"年"+(Number(inmon)+1)+"月"+inday+"日";
	}
	else if (lang.toUpperCase()=="JP")
	{
		sdate=inyear+"年"+(Number(inmon)+1)+"月"+inday+"日";
	}
	else if (lang.toUpperCase()=="KR")
	{
		sdate=inyear+"년 "+(Number(inmon)+1)+"월 "+inday+"일";
	}
	else if (lang.toUpperCase()=="DE")
	{
		var monthname;
		monthname=monthsShortDE[(Number(inmon))];
		sdate=inday+" "+monthname+" "+inyear;
	}
	else if (lang.toUpperCase()=="FR")
	{
		var monthname;
		monthname=monthsShortFR[(Number(inmon))];
		sdate=inday+" "+monthname+" "+inyear;
	}
	else if (lang.toUpperCase()=="IT")
	{
		var monthname;
		monthname=monthsShortIT[(Number(inmon))];
		sdate=inday+" "+monthname+" "+inyear;
	}
	else if (lang.toUpperCase()=="ES")
	{
		var monthname;
		monthname=monthsShortES[(Number(inmon))];
		sdate=inday+" "+monthname+" "+inyear;
	}
	else
	{
		var monthname;
		//alert(Number(inmon));
		monthname=monthsShortEN[(Number(inmon))];
		sdate=inday+" "+monthname+" "+inyear;
	}
	return sdate;
}


function showFAQpopup(filename) {
var sfilename;
sfilename="http://www.hoteltravel.com/planner/"+filename;
var width = 470;
var height = 300;
var w = 0, h = 0;
                                    if (document.all || document.layers) {
                                                w = screen.availWidth;
                                                h = screen.availHeight;
                                    }
                                    var leftPos = (w-width)/2, topPos = (h-height)/2;
                                    windowHandle = window.open(sfilename,'windowName','width=' + width + ',scrollbars=yes,height=' + height + ',left=' + leftPos + ',top=' + topPos);
}
function offlinerates(url,htc,city,afc,wid,lng)
{
var splanner;
splanner=url + "/planner/travelplan.aspx?htc=" + htc +"&rc=&city=" + city + "&afc=" + afc + "&wid=" + wid + "&lng="+lng;
//alert("splanner = "+splanner);
document.frmofflinerate.action=splanner;
			document.frmofflinerate.submit();
return true;
}