//set todays date
Now = new Date();
NowDay = Now.getDate();
NowMonth = eval(Now.getMonth());
NowYear = Now.getYear();

//Business rule for making reservation
var makeReservationBefore=NowDay;
var numberOfDaysAllowed2Stay =30;
var startDateValidity = 460;

//combine more than one city
var arrayCities = new Array();
var arrayCitiesTogether=new Array();
var orderby=new Array();

arrayCities[0] = 'COCHIN';
arrayCities[1] = 'ERNAKULAM';
arrayCities[2] = 'OOTY';
arrayCities[3] = 'COONOOR';

arrayCitiesTogether[0] = 'COCHIN~ERNAKULAM';
arrayCitiesTogether[1] = 'ERNAKULAM~COCHIN';
arrayCitiesTogether[2] = 'OOTY~COONOOR';
arrayCitiesTogether[3] = 'COONOOR~OOTY';

orderby[0] = '0'  //ascending
orderby[1] = '1'  //descending

//var strurllink="https://www.yourreservation.net/ibe/02_taj/main.html?language=EN&quick=page1&";
var strurllink="https://www.yourreservation.net/ibe/02_taj/main.html?language=EN&quick=quick&";
//Delimiter
var amenityDL = "|"

//General Form object for all the functions
var currform;
var MonthArray = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
if (NowYear < 2000) NowYear += 1900; //for Netscape

/*-----------------------------------------------------------------
	function for returning how many days there are in a month 
	including leap years
-----------------------------------------------------------------*/
//READ XML//

          var LoadXml;
		  var coucity;
		  function ReadXml(Id) 
{ 

	if( window.ActiveXObject && /Win/.test(navigator.userAgent) )
	{ 
		LoadXml = new ActiveXObject("Msxml.DOMDocument"); 
		LoadXml.async = false; 
		LoadXml.onreadystatechange = function () 
		{ 
		    if (LoadXml.readyState == 4) ManipulateXML(Id); 
		} 
		LoadXml.load("../Common_Inc/link.xml"); 
	} 
	else if( document.implementation && document.implementation.createDocument ) 
	{ 
		LoadXml = document.implementation.createDocument("","",null); 
		LoadXml.async=false; 
		var loaded = LoadXml.load("../Common_Inc/link.xml"); 
		moz=1;
		if (loaded) 
		{ 
			ManipulateXML(Id);
		} 
	} 
	else 
	{ 
		alert("Your browser can\'t handle this script"); 
		return; 
	} 
}
function ManipulateXML(resortid)
{
strTitle = LoadXml.getElementsByTagName("HotelLinks")[0]; 
if(strTitle.getElementsByTagName('Hotel').length>0)
{
for(var i=0; i<strTitle.getElementsByTagName('Hotel').length; i++) 
{
if(strTitle.getElementsByTagName('Hotel')[i].getAttribute("HotelId")==resortid)
{
var countId=strTitle.getElementsByTagName('Hotel')[i].getAttribute("countryId");
var cityId=strTitle.getElementsByTagName('Hotel')[i].getAttribute("CityId");
coucity=countId+"|"+cityId;
//alert(coucity);
}
}
}
} 
		  

//////
//Gateway Hotel ReadXML/////
var ldXML;
var hotellink;
function GWReadXML(htlid)
{
if( window.ActiveXObject && /Win/.test(navigator.userAgent) )
	{ 
		ldXML = new ActiveXObject("Msxml.DOMDocument"); 
		ldXML.async = false; 
		ldXML.onreadystatechange = function () 
		{ 
		    if (ldXML.readyState == 4) ManpXML(htlid); 
		} 
		ldXML.load("Common_Inc/GWhotellink.xml"); 
	} 
	else if( document.implementation && document.implementation.createDocument ) 
	{ 
		ldXML = document.implementation.createDocument("","",null); 
		ldXML.async=false; 
		var loaded = ldXML.load("Common_Inc/GWhotellink.xml"); 
		moz=1;
		if (loaded) 
		{ 
			ManpXML(htlid);
		} 
	} 
	else 
	{ 
		alert("Your browser can\'t handle this script"); 
		return; 
	} 
}

function ManpXML(gwhotelid)
{
strTitle = ldXML.getElementsByTagName("HotelLinks")[0]; 
if(strTitle.getElementsByTagName('Hotel').length>0)
{
for(var i=0; i<strTitle.getElementsByTagName('Hotel').length; i++) 
{
if(strTitle.getElementsByTagName('Hotel')[i].getAttribute("HotelId")==gwhotelid)
{
var link=strTitle.getElementsByTagName('Hotel')[i].getAttribute("HTLLink");
//var cityId=strTitle.getElementsByTagName('Hotel')[i].getAttribute("CityId");
hotellink=link;
}
}
}
} 
//////
///Gateway Hotel Id////

var ldGWXML;
var hotelidlink;
function GWHotelReadXML(ctyid)
{
if( window.ActiveXObject && /Win/.test(navigator.userAgent) )
	{ 
		ldGWXML = new ActiveXObject("Msxml.DOMDocument"); 
		ldGWXML.async = false; 
		ldGWXML.onreadystatechange = function () 
		{ 
		    if (ldGWXML.readyState == 4) ManpGWXML(ctyid); 
		} 
		ldGWXML.load("Common_Inc/GatewayHotelId.xml"); 
	} 
	else if( document.implementation && document.implementation.createDocument ) 
	{ 
		ldGWXML = document.implementation.createDocument("","",null); 
		ldGWXML.async=false; 
		var loaded = ldGWXML.load("Common_Inc/GatewayHotelId.xml"); 
		moz=1;
		if (loaded) 
		{ 
			ManpGWXML(ctyid);
		} 
	} 
	else 
	{ 
		alert("Your browser can\'t handle this script"); 
		return; 
	} 
}

function ManpGWXML(gwctyid)
{
strTitle = ldGWXML.getElementsByTagName("HotelId")[0]; 
if(strTitle.getElementsByTagName('HotelNameId').length>0)
{
for(var i=0; i<strTitle.getElementsByTagName('HotelNameId').length; i++) 
{
if(strTitle.getElementsByTagName('HotelNameId')[i].getAttribute("Name")==gwctyid)
{
var link=strTitle.getElementsByTagName('HotelNameId')[i].getAttribute("Id");
hotelidlink=link;
}
}
}
} 
////
function DaysInMonth(WhichMonth, WhichYear)
{
  var DaysInMonth = 31;
  if (WhichMonth == "April" || WhichMonth == "June" || WhichMonth == "September" || WhichMonth == "November") DaysInMonth = 30;
  if (WhichMonth == "February")
  {
  	if ((WhichYear % 4 == 0 && WhichYear % 100 != 0) || WhichYear % 400 == 0 || WhichYear == 0) 
  		DaysInMonth = 29;
  	else
  		DaysInMonth = 28;
  }
  return DaysInMonth;
}

/*-----------------------------------------------------------------
	Function to change the available days for the selected Month
-----------------------------------------------------------------*/
function ChangeOptionDays(DaysObject,MonthObject,YearObject,choice)
{

	//Get Month, Monthname and Year for any given object
	Month = eval(MonthObject[MonthObject.selectedIndex].value-1);
	txtMonth = MonthObject[MonthObject.selectedIndex].text
	Year = YearObject[YearObject.selectedIndex].text;

	//The variable below fix, where the day to start
	//Initially set to 1
	var iDayStart=1;
	
	//Get selected Month available days
	DaysForThisSelection = DaysInMonth(txtMonth, Year);
	
	//If the selected month and year are as same as current month and current year
	//then user could select the start date as current date + 2 and enddate should be 
	// more than 1 day of start date.
	
	if ((Month==NowMonth) && (Year==NowYear))
	{
		if ((Month==NowMonth) && (Year==NowYear))
		{
			iDayStart=makeReservationBefore;
			
		}
		else
			iDayStart=1;
		if (choice == 'D' && iDayStart > 1 && iDayStart < 32)
			{
			iDayStart += 1;
			
			}
		RemoveOptions(DaysObject);
		var j =0;
		for(;iDayStart<=DaysForThisSelection;iDayStart++)
		{
		  DaysObject.options[j] = new Option(iDayStart,iDayStart);
		  j++;
		}
		//document.getElementById('cmbDepartDay').value=29;
	}
	else
	{//alert("1");
		//User has been selected differnt month [NOT the current month]
		if (choice == 'D' && NowMonth != Month && (Year==NowYear))
		{
			var x= eval(currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value)
			if (x == DaysForThisSelection)
				iDayStart = 1;
			else
			{
				if (x==31)
					iDayStart = 1;
				else
					iDayStart = eval(x+1);
			}
		}
		else
		{
			iDayStart = 1;
		}

		RemoveOptions(DaysObject);
		var j =0;
		for(;iDayStart<=DaysForThisSelection;iDayStart++)
		{
		  DaysObject.options[j] = new Option(iDayStart,iDayStart);
		  j++;
		}
	}
	DaysObject[0].selected = true;
	
}
function ChangeOptionDepartDays(DaysObject,MonthObject,YearObject,choice)
{
	//Get Month, Monthname and Year for any given object
	Month = eval(MonthObject[MonthObject.selectedIndex].value-1);
	txtMonth = MonthObject[MonthObject.selectedIndex].text
	Year = YearObject[YearObject.selectedIndex].text;

	//The variable below fix, where the day to start
	//Initially set to 1
	var iDayStart=1;
	
	//Get selected Month available days
	DaysForThisSelection = DaysInMonth(txtMonth, Year);
	
	//If the selected month and year are as same as current month and current year
	//then user could select the start date as current date + 2 and enddate should be 
	// more than 1 day of start date.
	if ((Month==NowMonth) && (Year==NowYear))
	{
		if ((Month==NowMonth) && (Year==NowYear))
			iDayStart=makeReservationBefore;
		else
			iDayStart=1;
			
		if (choice == 'D' && iDayStart > 1)
			iDayStart += 1;
			
		RemoveOptions(DaysObject);
		var j =0;
		for(;iDayStart<=DaysForThisSelection;iDayStart++)
		{
		  DaysObject.options[j] = new Option(iDayStart,iDayStart);
		  j++;
		}
	}
	else
	{
		//User has been selected differnt month [NOT the current month]
		if (choice == 'D' && NowMonth != Month)
		{
			var x= eval(currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value)
			if (x == DaysForThisSelection)
				iDayStart = 1;
			else
			{
				if (x==31)
					iDayStart = 1;
				else
					iDayStart = eval(x+1);
			}
		}
		else
		{
			iDayStart = 1;
		}

		RemoveOptions(DaysObject);
		var j =0;
		for(;iDayStart<=DaysForThisSelection;iDayStart++)
		{
		  DaysObject.options[j] = new Option(iDayStart,iDayStart);
		  j++;
		}
	}
	DaysObject[0].selected = true;
}

//function to change the available months for the year
function ChangeOptionMonths(DayObject,MonthObject,YearObject,choice)
{
  //Arrival / Departure objects month and year to be assigned ffr
  var startMonth = 0;
  var Month = MonthObject[MonthObject.selectedIndex].value;
  var txtMonth = MonthObject[MonthObject.selectedIndex].text;
  var txtYear = YearObject[YearObject.selectedIndex].text;

  if (NowYear == txtYear)
  {
	//If current year and selected year are same, then
	//set the days for the month
	if (txtMonth == "December")
	{
		startMonth = 11;
		//YearObject[1].selected = true;
	}
	else
	{
		var DaysForThisSelection = DaysInMonth(txtMonth, txtYear);
		if ((NowDay+2) < DaysForThisSelection)
			startMonth = NowMonth;
		else
			startMonth = eval(NowMonth);
	}
	//Remove all options from the month combo
	RemoveOptions(MonthObject)
	var j=0;
	for(i=startMonth;i<12;i++)
	{
		MonthObject.options[j]= new Option(MonthArray[i],i+1);
		j++
	}
	Month = 0;
  }
  else
  {
	//Year is changed so add months for the selected year
	// Before clean up the existing months from combo
	RemoveOptions(MonthObject)
	AddMonthOptions(MonthObject,'F')
  }
  
  /*if (Month >1 && Month <12)
	MonthObject[Month-1].selected = true;
  else
    if(Month==1)
	MonthObject[Month].selected = true;
	else if(Month==12)
	MonthObject[Month-12].selected = true;
	else
	MonthObject[Month].selected = true;*/

  //Once after setting the month for the year, 
  //set the days for the selected month
  //alert(DayObject+MonthObject+YearObject+choice)
  ChangeOptionDays(DayObject,MonthObject,YearObject,choice)
}


//function to set options to today
function Set2Today(objfrm)
{
  currform = objfrm;

  //Arrival
  ADaysObject  = currform.cmbArrivalDay
  AMonthObject = currform.cmbArrivalMonth
  AYearObject  = currform.cmbArrivalYear
	
  //Departure
  DDaysObject  = currform.cmbDepartDay;
  DMonthObject = currform.cmbDepartMonth;
  DYearObject  = currform.cmbDepartYear;

  AddYearOptions(AYearObject);
  AddYearOptions(DYearObject);
  AddMonthOptions4Arrival(AMonthObject)
  AddMonthOptions4Depart(DMonthObject)
  ChangeOptionDays(ADaysObject,AMonthObject,AYearObject,'A')
  ChangeOptionDays(DDaysObject,DMonthObject,DYearObject,'D')
  RemoveOptions(currform.cmbCity)
  RemoveOptions(currform.cmbHotels)
  currform.cmbCity.options[0] = new Option("--- Select City / Region ---",0);
  currform.cmbHotels.options[0] = new Option("--- Select a Hotel ---",0);
  currform.cmbCity[0].selected =true;
  currform.cmbHotels[0].selected =true;
 // setAdultsAndKids();
}
/*---------------------------------------------------------------
	When arrival year changed, change the departure year
	and set the month and days
---------------------------------------------------------------*/
function ArrivalYearChanged()
{
	ChangeOptionMonths(ADaysObject,AMonthObject,AYearObject,'A');
	var arrivalyear = currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value;
	//set the departure year
	for(i=0;i<currform.cmbDepartYear.options.length;i++)
	{
		if (currform.cmbDepartYear.options[i].value==arrivalyear)
		{
			currform.cmbDepartYear.options[i].selected = true;
			break;
		}
	}
	AddNights2Depart();
}

function DepartYearChanged()
{
	var dtstart = new Date(currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "/" + currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value + "/" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value)
	var dtdepart = new Date(currform.cmbDepartMonth.options[currform.cmbDepartMonth.selectedIndex].value + "/" + currform.cmbDepartDay.options[currform.cmbDepartDay.selectedIndex].value + "/" + currform.cmbDepartYear.options[currform.cmbDepartYear.selectedIndex].value)
	day2add = currform.cmbNights.options[currform.cmbNights.selectedIndex].value
	var dtend   = DayAdd(dtstart, day2add)	
    if (dtdepart < dtend  )
	{
		//Roll back the year
		for(i=0;i<currform.cmbDepartYear.options.length;i++)
		{
			if (currform.cmbDepartYear.options[i].value == eval(currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value))
			{
					currform.cmbDepartYear.options[i].selected = true;
					break;
			}
			
	    }
		ChangeOptionMonths(DDaysObject,DMonthObject,DYearObject,'D');	
		
	}
	else
	{
		ChangeOptionMonths(DDaysObject,DMonthObject,DYearObject,'D');
	}
	
}

function ArrivalMonthChanged()
{
	//When arrival month changed, set the days for the month
	ChangeOptionDays(ADaysObject,AMonthObject,AYearObject,'A');
	
	//Set departure month as arrival month
	var dd = currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value 
	var mm = currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].text.slice(0,3) 
	var yy = currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value
	for(i=0;i<currform.cmbDepartMonth.options.length;i++)
	{
		if (currform.cmbDepartMonth.options[i].text.slice(0,3) ==mm)
		{
			currform.cmbDepartMonth.options[i].selected = true;
			break;
		}
	}
	
	var dtstart = new Date(currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "/" + currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value + "/" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value)	
	day2add = currform.cmbNights.options[currform.cmbNights.selectedIndex].value
	var dtend   = DayAdd(dtstart, day2add)

	dd = dtend.getDate()
	mm = MonthArray[dtend.getMonth()].slice(0,3)
	yy = dtend.getFullYear();
	if (yy != NowYear)
	{
		currform.cmbDepartYear.options[1].selected = true;
		DepartYearChanged();
	}
	putdate(dd,mm,yy,'CHECK-OUT')
	ChangeOptionDays(DDaysObject,DMonthObject,DYearObject,'A');
	putdate(dd,mm,yy,'CHECK-OUT')
	
	//set the days for departure month
	//ChangeOptionDays(DDaysObject,DMonthObject,DYearObject,'D')
}

function DepartMonthChanged()
{
	//If date difference exceeds 30 days, bring the current month to view
	if (datediff2Nights() > numberOfDaysAllowed2Stay)
	{
		/*alert("Maximum length of stay is restricted to 30 Days")
		var dtstart = new Date(currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "/" + currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value + "/" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value)	
		var dt2add  = eval(currform.cmbNights.options[currform.cmbNights.selectedIndex].value)
		var dtend   = DayAdd(dtstart, dt2add)
		
		dd = dtend.getDate()
		mm = MonthArray[dtend.getMonth()].slice(0,3)
		yy = dtend.getFullYear();
		if (yy != NowYear)
		{
			currform.cmbDepartYear.options[1].selected = true;
			DepartYearChanged();
		}
		putdate(dd,mm,yy,'CHECK-OUT')
		ChangeOptionDays(DDaysObject,DMonthObject,DYearObject,'A');
		putdate(dd,mm,yy,'CHECK-OUT')
		return; */
		currform.cmbNights.options[29].selected = true;
		AddNights2Depart();
		return;
	}
	if ( datediff2Nights() <= 1 )
	{
		/*
		var dtstart = new Date(currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "/" + currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value + "/" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value)	
		var dt2add  = eval(currform.cmbNights.options[currform.cmbNights.selectedIndex].value)
		var dtend   = DayAdd(dtstart, dt2add)
		
		dd = dtend.getDate()
		mm = MonthArray[dtend.getMonth()].slice(0,3)
		yy = dtend.getFullYear();
		if (yy != NowYear)
		{
			currform.cmbDepartYear.options[1].selected = true;
			DepartYearChanged();
		}
		putdate(dd,mm,yy,'CHECK-OUT')
		ChangeOptionDays(DDaysObject,DMonthObject,DYearObject,'A');
		putdate(dd,mm,yy,'CHECK-OUT')
		return;
		*/
		currform.cmbNights.options[0].selected = true;
		AddNights2Depart();
		return;
				
	}
	else
	{
		for(i=0;i<currform.cmbNights.options.length;i++)
		{
			if (currform.cmbNights.options[i].value==datediff2Nights())
			{
				currform.cmbNights.options[i].selected = true;
				break;
			}
		}
		ChangeOptionDays(DDaysObject,DMonthObject,DYearObject,'D');
	}
}

function DepartDayChanged()
{
	//Set the difference to cmbNights combo
	if (datediff2Nights() > numberOfDaysAllowed2Stay)
	{
		alert("Maximum length of stay is restricted to 30 Days")
		currform.cmbDepartMonth.focus();
		return;
	}
	else
	{
	    if (datediff2Nights() >= 1 )
	    {
			for(i=0;i<currform.cmbNights.options.length;i++)
			{
				if (currform.cmbNights.options[i].value==datediff2Nights())
				{
					currform.cmbNights.options[i].selected = true;
					break;
				}
			}
		}
		else
		{
			AddNights2Depart();
		
		}
	}
}

//function to remove options
function RemoveOptions(objCal)
{
   if (objCal.options.length > 0 )
   {
		for(i=0;objCal.options.length;i++)
		{
			objCal.options[0] = null;
		}
   }
}

/*-------------------------------------------------------------------
	If arrival day is changed, reflect in departure date 
	by arrival date + 1. If the selected day is last day, select next
	month in departure date and set departure day as first day
-------------------------------------------------------------------*/
function ArrivalDayChanged()
{
		var dtstart = new Date(currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "/" + currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value + "/" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value)	
		day2add = currform.cmbNights.options[currform.cmbNights.selectedIndex].value
		var dtend   = DayAdd(dtstart, day2add)

		var dtst = new Date(currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "/" + currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value + "/" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value)
		var dtmax = new Date()
		dtmax = DayAdd(dtmax,365)
		
		if (dtst > dtmax)
		{
			alert("Reservation is allowed maximum before a year!!!\nPlease choose different date.")
			return false;
			dd = 1
			mm = MonthArray[dtstart.getMonth()].slice(0,3)
			yy = dtstart.getFullYear();
			if (yy != NowYear)
			{
				currform.cmbDepartYear.options[1].selected = true;
				DepartYearChanged();
			}
			putdate(dd,mm,yy,'CHECK-IN')
			//ChangeOptionDays(DDaysObject,DMonthObject,DYearObject,'A');
			putdate(2,mm,yy,'CHECK-OUT')
			currform.cmbArrivalMonth.focus();
			return;
		}
		
		dd = dtend.getDate()
		mm = MonthArray[dtend.getMonth()].slice(0,3)
		yy = dtend.getFullYear();
		if (yy != NowYear)
		{
			currform.cmbDepartYear.options[1].selected = true;
			DepartYearChanged();
		}
		putdate(dd,mm,yy,'CHECK-OUT')
		ChangeOptionDays(DDaysObject,DMonthObject,DYearObject,'A');
		putdate(dd,mm,yy,'CHECK-OUT')
}

//function to add month options
function AddMonthOptions(objCal,vlimit)
{
	//This month option will add month names in the combo
	//respective to the year
		
	var monthlimit=0;
	if (vlimit == 'P')
	{
		// Check for the startday
		var LastDay4Month = DaysInMonth(MonthArray[NowMonth],NowYear)
		if (NowDay < LastDay4Month)
			monthlimit = NowMonth;
	}	
	else
		monthlimit = 0;

	var j=0;	
	//Netscape explorer expects to set length before adding option
	objCal.options.length=12;
	RemoveOptions(objCal);
	
	for(i=monthlimit;i<12;i++,j++)
	{
		objCal.options[j]= new Option(MonthArray[i],i+1);
	}
	objCal[0].selected = true;
}

function AddMonthOptions4Arrival(objCal)
{
	//This month option will add month names in the Arrival Combo
	//respective to the year
	var monthlimit=0;
	
	//NowMonth = currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value;
	//NowYear  = currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value;
	// Check for the lastday
	var LastDay4Month = DaysInMonth(MonthArray[NowMonth],NowYear)
	if (NowDay < LastDay4Month)
		monthlimit = NowMonth;
	else if(NowDay == LastDay4Month)
		monthlimit = NowMonth+1;
    if (monthlimit == 12)
    {
		monthlimit = 0;
		currform.cmbArrivalYear.options[eval(currform.cmbArrivalYear.selectedIndex+1)].selected = true;
	}
		
	var j=0;	
	//Netscape explorer expects to set length before adding option
	objCal.options.length=12;
	RemoveOptions(objCal);
	
	for(i=monthlimit;i<12;i++,j++)
	{
		objCal.options[j]= new Option(MonthArray[i],i+1);
	}
	objCal[0].selected = true;
}

function AddMonthOptions4Depart(objCal)
{
	//This month option will add month names in the Depart Combo
	//respective to the year

	var monthlimit=0;
	// Check for the lastday
	var LastDay4Month = DaysInMonth(MonthArray[NowMonth],NowYear)
	if ((NowDay+1) < LastDay4Month)
		monthlimit = NowMonth;
	else if((NowDay+1) >= LastDay4Month)
		monthlimit = NowMonth+1;
    if (monthlimit == 12)
    {
		monthlimit = 0;
		currform.cmbDepartYear.options[eval(currform.cmbDepartYear.selectedIndex+1)].selected = true;
	}
	var j=0;	
	//Netscape explorer expects to set length before adding option
	objCal.options.length=12;
	RemoveOptions(objCal);
	
	for(i=monthlimit;i<12;i++,j++)
	{
		objCal.options[j]= new Option(MonthArray[i],i+1);
	}
	objCal[0].selected = true;
}



//function to write option minths
function WriteMonthOptions()
{
	line = "";
	for(i=0;i<12;i++)
	{
		line += "<OPTION value=" + i + ">";
		line += MonthArray[i] + "</option>\n"
	}
	return line;
}

//function to write option years plus x
function AddYearOptions(objCal)
{
  //Displays current year and 3 subsequent years, to add more years
  //Change the yearsToBeAppeared to another values  
  var yearsToBeAppeared = 2;
  objCal.options.length = 2;
  for (i=0; i<yearsToBeAppeared; i++)
  {
    objCal.options[i] = new Option(NowYear+i,NowYear+i);
  }
  objCal[0].selected = true;
}

//childcontrol
var totalguest=5;
function showchild()
{
var strroom;
var strnoofchildren;
document.getElementById('cntchildren').innerHTML="";
document.getElementById("agechild").innerHTML="";
var gusetroom=document.Form1.cmbAdults.options[document.Form1.cmbAdults.selectedIndex].value
//var roomcount=document.Form1.cmbRooms.options[document.Form1.cmbRooms.selectedIndex].value
 if(gusetroom!=5)
  {
     document.getElementById('div_child').style.display='block';
     //var child=totalguest-gusetroom
      var child=null;
     if(gusetroom<4)
     child=2;
     else
     child=totalguest-gusetroom;
     
     for(j=0;j<=child;j++)
     {
     if(strnoofchildren==null)
     strnoofchildren="<option value='"+j+"'>"+j+"</option>";
     else
     strnoofchildren+="<option value='"+j+"'>"+j+"</option>";
     }
     for(i=1;i<=1;i++)
     {
     if(strroom==null)
     //strroom="<table width='100%' cellpadding='1' cellspacing='2' border='1' class='formdata'><tr><td width='70%'>Room "+i+"&nbsp;<select id='cmbchildcnt"+i+"' name='cmbchildcnt'"+i+" onchange=showAge('age"+i+"',cmbchildcnt"+i+");>"+strnoofchildren+"</select></td><td id='age"+i+"' width='30%'></td></tr>";
     strroom="<table width='210px' cellpadding='1' cellspacing='3' border='0' class='formdata'><tr><td width='100px' valign='top'>Children&nbsp;<select id='cmbchildcnt"+i+"' name='cmbchildcnt'"+i+" onchange=showAge('age"+i+"',cmbchildcnt"+i+");>"+strnoofchildren+"</select></td><td id='age"+i+"' width='110px'></td></tr>";
     else
     strroom+="<tr><td width='100px' valign='top'>Room "+i+"&nbsp;<select class='select' id='cmbchildcnt"+i+"' name='cmbchildcnt"+i+"' onchange=showAge('age"+i+"',cmbchildcnt"+i+");>"+strnoofchildren+"</select></td><td id='age"+i+"' width='110px'></td></tr>";
     }
     strroom+="</table>";
     if(document.getElementById('cntchildren')!=null)
      {
        document.getElementById('cntchildren').innerHTML=strroom;//"<select id='cmbchildcnt' name='cmbchildcnt'><option value='0'>0</option><option value='1'>1</option></select>";
      }  
  }
 else
 {
 document.getElementById('div_child').style.display='none';
 document.getElementById('cntchildren').innerHTML="";
 } 
}
		 
function showAge(tdid1,childcnt)
{
//.
//alert(tdid);
//alert(tdid.innerHTML);

//document.getElementById(tdid).innerText="";
var tdid=document.getElementById(tdid1);

tdid.innerHTML="";

var strage='';
var strrooms;
//var =document.getElementById("cmbchildcnt");
//alert(childcnt.value);
if(childcnt.value!=0)
  {
  
    //alert(childcnt.value);
     document.getElementById("agechild").innerHTML="Age of Children";
     for(m=0;m<=16;m++)
     {
     if(strrooms==null)
     strrooms="<option value='<1'><1</option>";
     else
     strrooms+="<option value='"+m+"'>"+m+"</option>";
     }
    var t=0;
    strage+="<table cellpadding='0' cellspacing='0' border='0'>"
    strage+="<tr vAlign='top'>"
     for(k=0;k<childcnt.value;k++)
     {
      strage+="<td align='left' style='padding-bottom:1px;'>";
      if(t!=0)
      if(t%2==0)
      strage+="<tr vAlign='top'><td style='padding-top:1px;' align='left'>"
      if(strage==null)
      strage="<select id='childage"+childcnt.name+k+"' name='childage"+childcnt.name+k+"'>"+strrooms+"</select>";
      else
      strage+="&nbsp<select id='childage"+childcnt.name+k+"' name='childage"+childcnt.name+k+"'>"+strrooms+"</select>";
      strage+="</td>";
      t++;
     }
      strage+="</tr></table>"
    tdid.innerHTML=strage;
    strage=null;
   
    //alert("SD");
  }
else
 {

 if(document.getElementById("childagecmbchildcnt0")==null && document.getElementById("childagecmbchildcnt1")==null && document.getElementById("childagecmbchildcnt10")==null && document.getElementById("childagecmbchildcnt11")==null && document.getElementById("childagecmbchildcnt20")==null && document.getElementById("childagecmbchildcnt21")==null && document.getElementById("childagecmbchildcnt30")==null && document.getElementById("childagecmbchildcnt31")==null && document.getElementById("childagecmbchildcnt40")==null && document.getElementById("childagecmbchildcnt41")==null)
 {
    document.getElementById("agechild").innerHTML="";
 }
     //document.getElementById("tdid").innerHTML="";
     strage=null;
      tdid.innerHTML="";
 }

}

////

//Availability Child Control
var totalguest=5;
function showchildAvail()
{
var strroom;
var strnoofchildren;
document.getElementById('cntchildren').innerHTML="";
document.getElementById("agechild").innerHTML="";
var gusetroom=document.FrmAvail.cmbAdults.options[document.FrmAvail.cmbAdults.selectedIndex].value
//var roomcount=document.FrmAvail.cmbRooms.options[document.FrmAvail.cmbRooms.selectedIndex].value
 if(gusetroom!=5)
  {
     document.getElementById('div_child').style.display='block';
      //var child=totalguest-gusetroom
       var child=null;
     if(gusetroom<4)
     child=2;
     else
     child=totalguest-gusetroom;
     
     for(j=0;j<=child;j++)
     {
     if(strnoofchildren==null)
     strnoofchildren="<option value='"+j+"'>"+j+"</option>";
     else
     strnoofchildren+="<option value='"+j+"'>"+j+"</option>";
     }
     for(i=1;i<=1;i++)
     {
     if(strroom==null)
     //strroom="<table width='100%' cellpadding='1' cellspacing='2' border='0' class='formdata'><tr><td width='70%'>Room "+i+"&nbsp;<select id='cmbchildcnt"+i+"' name='cmbchildcnt'"+i+" onchange=showAgeAvail('age"+i+"',cmbchildcnt"+i+");>"+strnoofchildren+"</select></td><td id='age"+i+"' width='30%'></td></tr>";
     strroom="<table width='210px' cellpadding='1' cellspacing='3' border='0' class='formdata'><tr><td width='100px' valign='top'>Children&nbsp;<select id='cmbchildcnt"+i+"' name='cmbchildcnt'"+i+" onchange=showAgeAvail('age"+i+"',cmbchildcnt"+i+");>"+strnoofchildren+"</select></td><td id='age"+i+"' width='110px'></td></tr>";
     else
     strroom+="<tr><td width='100px' valign='top'>Room "+i+"&nbsp;<select class='select' id='cmbchildcnt"+i+"' name='cmbchildcnt"+i+"' onchange=showAgeAvail('age"+i+"',cmbchildcnt"+i+");>"+strnoofchildren+"</select></td><td id='age"+i+"' width='110px'></td></tr>";
     }
     strroom+="</table>";
     if(document.getElementById('cntchildren')!=null)
      {
        document.getElementById('cntchildren').innerHTML=strroom;//"<select id='cmbchildcnt' name='cmbchildcnt'><option value='0'>0</option><option value='1'>1</option></select>";
      }  
  }
 else
 {
 document.getElementById('div_child').style.display='none';
 document.getElementById('cntchildren').innerHTML="";
 } 
}
		 
function showAgeAvail(tdid1,childcnt)
{
//.
//alert(tdid);
//alert(tdid.innerHTML);
//alert(childcnt);
//document.getElementById(tdid).innerText="";
var tdid=document.getElementById(tdid1);
tdid.innerHTML="";

var strage='';
var strrooms;
//var =document.getElementById("cmbchildcnt");
//alert(childcnt.value);
if(childcnt.value!=0)
  {
  
    //alert(childcnt.value);
     document.getElementById("agechild").innerHTML="Age of Children";
     for(m=0;m<=16;m++)
     {
     if(strrooms==null)
     strrooms="<option value='<1'><1</option>";
     else
     strrooms+="<option value='"+m+"'>"+m+"</option>";
     }
    var t=0;
    strage+="<table cellpadding='0' cellspacing='0' border='0'>"
    strage+="<tr vAlign='top'>"
     for(k=0;k<childcnt.value;k++)
     {
      strage+="<td align='left' style='padding-bottom:1px;'>";
      if(t!=0)
      if(t%2==0)
      strage+="<tr vAlign='top'><td style='padding-top:1px;' align='left'>"
      if(strage==null)
      strage="<select id='childage"+childcnt.name+k+"' name='childage"+childcnt.name+k+"'>"+strrooms+"</select>";
      else
      strage+="&nbsp<select id='childage"+childcnt.name+k+"' name='childage"+childcnt.name+k+"'>"+strrooms+"</select>";
      strage+="</td>";
      t++;
     }
     strage+="</tr></table>"
    tdid.innerHTML=strage;
    strage=null;
   
    //alert("SD");
  }
else
 {

 if(document.getElementById("childagecmbchildcnt0")==null && document.getElementById("childagecmbchildcnt1")==null && document.getElementById("childagecmbchildcnt10")==null && document.getElementById("childagecmbchildcnt11")==null && document.getElementById("childagecmbchildcnt20")==null && document.getElementById("childagecmbchildcnt21")==null && document.getElementById("childagecmbchildcnt30")==null && document.getElementById("childagecmbchildcnt31")==null && document.getElementById("childagecmbchildcnt40")==null && document.getElementById("childagecmbchildcnt41")==null)
 {

    document.getElementById("agechild").innerHTML="";
 }
     //document.getElementById("tdid").innerHTML="";
     strage=null;
      tdid.innerHTML="";
 }

}


////
function getCountryCityName()
{
 var selectedCountry = document.Form1.cmbCountry.options[document.Form1.cmbCountry.selectedIndex].value;
 
  if(selectedCountry==0 || selectedCountry=="0")
  {
  //alert(selectedCountry);
   PoupulateCountryCity();
  }
  else
  {
  //alert(selectedCountry);
   PoupulateCountryCity();
   document.Form1.cmbCity.selectedIndex=0;
  }
}

function setAdultsAndKids()
{
	var nrooms = eval(currform.cmbRooms.options[currform.cmbRooms.selectedIndex].value)
	var nAdults = 3 //nrooms * 2
	
	if (nrooms == 1)
		var nstart=1;
	else
		var nstart=nrooms;
		
	RemoveOptions(currform.cmbAdults)
	RemoveOptions(currform.cmbChildern)
	
	var k=0;
	for(i=nstart;i<=nAdults;i++)
	{
		currform.cmbAdults.options[k] = new Option(i,i);
		k+=1;
	}
	currform.cmbAdults[0].selected=true;
	k=0;
	for(i=0;i<=nAdults;i++)
	{
		currform.cmbChildern.options[k] = new Option(i,i);
		k+=1;
	}
	currform.cmbChildern[0].selected=true;
}

function FillCountryCombo()
{
	var strcountry = document.Form1.hid_country.value;
	var ArrayCountry = strcountry.split("~")
	var k =1;
	
	RemoveOptions(document.Form1.cmbCountry)
	document.Form1.cmbCountry.options[0] = new Option("--- Select Country / Region ---",0);
	for(i=0;i<ArrayCountry.length;i++)
	{
			document.Form1.cmbCountry.options[k] = new Option(ArrayCountry[i],ArrayCountry[i]);
			k+=1;
	}
	document.Form1.cmbCountry[0].selected =true;
}

function FillCountryComboR1()
{
	var strcountry = document.frmResult.hid_country.value;
	var ArrayCountry = strcountry.split("~")
	var k =1;
	RemoveOptions(document.frmResult.cmbCountry)
	document.frmResult.cmbCountry.options[0] = new Option("--- Select Country / Region---",0);
	for(i=0;i<ArrayCountry.length;i++)
	{
			document.frmResult.cmbCountry.options[k] = new Option(ArrayCountry[i],ArrayCountry[i]);
			k+=1;
	}
	document.frmResult.cmbCountry[0].selected =true;

	//Set city combo
}

function FillCountryComboR2()
{
	var strcountry = document.FrmAvail.hid_country.value;
	var ArrayCountry = strcountry.split("~")
	var k =1;
	RemoveOptions(document.FrmAvail.cmbCountry)
	document.FrmAvail.cmbCountry.options[0] = new Option("--- Select Country / Region ---",0);
	for(i=0;i<ArrayCountry.length;i++)
	{
			document.FrmAvail.cmbCountry.options[k] = new Option(ArrayCountry[i],ArrayCountry[i]);
			k+=1;
	}
	document.FrmAvail.cmbCountry[0].selected =true;

	//Set city combo
}

function SetComboValues(vCountry, vCity)
{
	
	//Hotel Group
	/*for(i=0;i<document.frmResult.cmbHtlGroup.options.length;i++)
	{
		if (document.frmResult.cmbHtlGroup.options[i].value == vHotelGroup)
		{
			document.frmResult.cmbHtlGroup.options[i].selected = true;
			break;
		}
	}*/
	// Country
	for(i=0;i<document.frmResult.cmbCountry.options.length;i++)
	{
		if (document.frmResult.cmbCountry.options[i].value == vCountry)
		{
			document.frmResult.cmbCountry.options[i].selected = true;
			break;
		}
	}
	//City

	PoupulateCountryCityR1();
	if (vCountry != "")  // vCountry != "INDIA"
	{
		for(i=0;i<document.frmResult.cmbCity.options.length;i++)
		{
			if (document.frmResult.cmbCity.options[i].value.toUpperCase() == vCity.toUpperCase())
			{
				document.frmResult.cmbCity.options[i].selected = true;
				break;
			}
		}
	}
	PopulateHotelsR1()
	document.frmResult.cmbHotels[0].selected=true;
}


function SetAvailComboValues(vCountry, vCity)
{
	// **** storing Hidden values COUNTRY and CITY
	document.FrmAvail.orginal_ctry.value =  vCountry;
	document.FrmAvail.orginal_city.value =  vCity;
	//Hotel Group
	/*for(i=0;i<document.frmResult.cmbHtlGroup.options.length;i++)
	{
		if (document.frmResult.cmbHtlGroup.options[i].value == vHotelGroup)
		{
			document.frmResult.cmbHtlGroup.options[i].selected = true;
			break;
		}
	}*/
	// Country
	for(i=0;i<document.FrmAvail.cmbCountry.options.length;i++)
	{
		if (document.FrmAvail.cmbCountry.options[i].value == vCountry)
		{
			document.FrmAvail.cmbCountry.options[i].selected = true;
			break;
		}
	}
	//City

	PoupulateCountryCityR2();
	if (vCountry != "") //vCountry == "INDIA"
	{
		for(i=0;i<document.FrmAvail.cmbCity.options.length;i++)
		{
			if (document.FrmAvail.cmbCity.options[i].value == vCity)
			{
				document.FrmAvail.cmbCity.options[i].selected = true;
				break;
			}
		}
	}
	PopulateHotelsR2();
	document.FrmAvail.cmbHotels[0].selected=true;
}


//-----------------------------------------------------------------------
//Populate Country and City
//-----------------------------------------------------------------------
function PoupulateCountryCity()
{    
	var selectedCountry = document.Form1.cmbCountry.options[document.Form1.cmbCountry.selectedIndex].value;
	if (selectedCountry == "INDIAN OCEAN")
	{
	    //Indian Ocean added in Country Combo as requested by Ashok on 28 Feb 05
		var ArrayCity1 =  new Array()
		ArrayCity1[0] = "BENTOTA"
		ArrayCity1[1] = "CMB005"
		ArrayCity1[2] = "COLOMBO"
		ArrayCity1[3] = "CMB001"
		ArrayCity1[4] = "MALDIVES"
		ArrayCity1[5] = "MLE011"
		//ArrayCity1[6] = "MAURITIUS"
		//ArrayCity1[7] = "MRU007"
		//ArrayCity1[4] = ""
		var k =1;
		RemoveOptions(document.Form1.cmbCity)
		RemoveOptions(document.Form1.cmbHotels)
		document.Form1.cmbCity.options[0] = new Option("--- Select City / Region ---",0);
		document.Form1.cmbHotels.options[0] = new Option("--- Select a Hotel ---",0);
		for(j=0;j<ArrayCity1.length;j+=2)
		{
			document.Form1.cmbCity.options[k] = new Option(GetCityName(ArrayCity1[j]),ArrayCity1[j+1]);
			k+=1;
		}
	}
	else
	{
		var strcity = document.Form1.hid_city.value;
		var ArrayCity = strcity.split("-")
		var strcountrycity = document.Form1.hid_countrycity.value;
		var ArrayCountryCity = strcountrycity.split("~~")
		var k =1;
		RemoveOptions(document.Form1.cmbCity)
		RemoveOptions(document.Form1.cmbHotels)
		document.Form1.cmbCity.options[0] = new Option("--- Select City / Region ---",0);
		document.Form1.cmbHotels.options[0] = new Option("--- Select a Hotel ---",0);
		var dispCityname="";
		
		for(j=0;j<ArrayCity.length;j++)
		{
			var cc = selectedCountry + "~" +ArrayCity[j];
			//if(cc==cc1) continue; //avoid duplicate entry 
			for(i=0;i<ArrayCountryCity.length;i++)
			{
				if (ArrayCountryCity[i]==cc)
				{
					document.Form1.cmbCity.options[k] = new Option(GetCityName(ArrayCity[j]),ArrayCity[j]);
					k+=1;
					//break;
				}
			}
			//var cc1=cc;
		}
	}
	document.Form1.cmbCity[0].selected =true;
	document.Form1.cmbHotels[0].selected =true;
	
	//validateROI(selectedCountry)
}

function GetCityName(valcity)
{
	var ret_cities=valcity;
	for (m=0;m<arrayCities.length;m++)
	{
		if (arrayCities[m] == valcity)
		{
			ret_cities =arrayCitiesTogether[m]
			ret_cities=ret_cities.replace("~","/")
			break;
		}
	}
	return ret_cities;
}

function PoupulateCountryCityR1()
{    
	var selectedCountry = document.frmResult.cmbCountry.options[document.frmResult.cmbCountry.selectedIndex].value;
	if (selectedCountry == "INDIAN OCEAN")
	{
	    //Indian Ocean added in Country Combo as requested by Ashok on 28 Feb 05
		var ArrayCity1 =  new Array()
		ArrayCity1[0] = "BENTOTA"
		ArrayCity1[1] = "COLOMBO"
		ArrayCity1[2] = "MALDIVES"
		//ArrayCity1[3] = "MAURITIUS"
		//ArrayCity1[4] = ""
		var k =1;
		RemoveOptions(document.frmResult.cmbCity)
		RemoveOptions(document.frmResult.cmbHotels)
		document.frmResult.cmbCity.options[0] = new Option("--- Select City / Region ---",0);
		document.frmResult.cmbHotels.options[0] = new Option("--- Select a Hotel ---",0);
		for(j=0;j<ArrayCity1.length;j++)
		{
			document.frmResult.cmbCity.options[k] = new Option(GetCityName(ArrayCity1[j]),ArrayCity1[j]);
			k+=1;
		}
	}
	else
	{
		var strcity = document.frmResult.hid_city.value;
		var ArrayCity = strcity.split("-")
		var strcountrycity = document.frmResult.hid_countrycity.value;
		var ArrayCountryCity = strcountrycity.split("~~")
		var k =1;
		RemoveOptions(document.frmResult.cmbCity)
		RemoveOptions(document.frmResult.cmbHotels)
		document.frmResult.cmbCity.options[0] = new Option("--- Select City / Region ---",0);
		document.frmResult.cmbHotels.options[0] = new Option("--- Select a Hotel ---",0);
		var dispCityname="";
		
		for(j=0;j<ArrayCity.length;j++)
		{
			var cc = selectedCountry + "~" +ArrayCity[j];
			//if(cc==cc1) continue; //avoid duplicate entry 
			for(i=0;i<ArrayCountryCity.length;i++)
			{
				if (ArrayCountryCity[i]==cc)
				{
					document.frmResult.cmbCity.options[k] = new Option(GetCityName(ArrayCity[j]),ArrayCity[j]);
					k+=1;
					//break;
				}
			}
			//var cc1=cc;
		}
	}
	document.frmResult.cmbCity[0].selected =true;
}

function PoupulateCountryCityR2()
{
	var selectedCountry_new = document.FrmAvail.cmbCountry.options[document.FrmAvail.cmbCountry.selectedIndex].value;
	if (selectedCountry_new == "INDIAN OCEAN")
	{
	    //Indian Ocean added in Country Combo as requested by Ashok on 28 Feb 05
		var ArrayCity1 =  new Array()
		ArrayCity1[0] = "BENTOTA"
		ArrayCity1[1] = "COLOMBO"
		ArrayCity1[2] = "MALDIVES"
		ArrayCity1[3] = "MAURITIUS"
		//ArrayCity1[4] = "MAURITIUS"
		var k =1;
		RemoveOptions(document.FrmAvail.cmbCity)
		RemoveOptions(document.FrmAvail.cmbHotels)
		document.FrmAvail.cmbCity.options[0] = new Option("--- Select City / Region ---",0);
		document.FrmAvail.cmbHotels.options[0] = new Option("--- Select a Hotel ---",0);
		for(j=0;j<ArrayCity1.length;j++)
		{
			document.FrmAvail.cmbCity.options[k] = new Option(GetCityName(ArrayCity1[j]),ArrayCity1[j]);
			k+=1;
		}
	}
	else
	{	
		var strcity = document.FrmAvail.hid_city.value;
		var ArrayCity = strcity.split("-")
		var strcountrycity = document.FrmAvail.hid_countrycity.value;
		var ArrayCountryCity = strcountrycity.split("~~")
		var k =1;
		RemoveOptions(document.FrmAvail.cmbCity)
		RemoveOptions(document.FrmAvail.cmbHotels)
		document.FrmAvail.cmbCity.options[0] = new Option("--- Select City / Region ---",0);
		document.FrmAvail.cmbHotels.options[0] = new Option("--- Select a Hotel ---",0);
		var dispCityname="";
		
		for(j=0;j<ArrayCity.length;j++)
		{
			var cc = selectedCountry_new + "~" +ArrayCity[j];
			//if(cc==cc1) continue; //avoid duplicate entry 
			for(i=0;i<ArrayCountryCity.length;i++)
			{
				if (ArrayCountryCity[i]==cc)
				{
					document.FrmAvail.cmbCity.options[k] = new Option(GetCityName(ArrayCity[j]),ArrayCity[j]);
					k+=1;
					//break;
				}
			}
			//var cc1=cc;
		}
	}
	document.FrmAvail.cmbCity[0].selected =true;
}


//-----------------------------------------------------------------------
//Populate City and Hotels
//-----------------------------------------------------------------------
function PoupulateHotels()
{

	//Hotelnames grouped by Region
	var arrayRegion = new Array();
	var arrayRegionCities = new Array();
	arrayRegion[0] = 'KERALA';
	arrayRegion[1] = 'RAJASTHAN';
	arrayRegion[2] = 'MAURITIUS';

	arrayRegionCities[0]='Kumarakom~Thekkady~Varkala~Cochin~Calicut~Ernakulam~Kovalam~Trivandrum'
	arrayRegionCities[1]='Jaipur~Jaisalmer~Udaipur~Sawai Madhopur~Jodhpur'
	arrayRegionCities[2]='wolmar~dummy'

	var selectedCityval = document.Form1.cmbCity.options[document.Form1.cmbCity.selectedIndex].value;
	var selectedCitytxt = document.Form1.cmbCity.options[document.Form1.cmbCity.selectedIndex].text;
	RemoveOptions(document.Form1.cmbHotels)
	if (selectedCitytxt == 'KERALA' || selectedCitytxt == 'RAJASTHAN')
	{
	    var k =0;
	    var strRegionCities;
	    var arrayRegionHotels = new Array();
		RemoveOptions(document.Form1.cmbHotels)
		document.Form1.cmbHotels.options[0] = new Option("--- Select a Hotel ---",0);
		// Add hotels for all cities for KERALA/RAJASTHAN into hotel dropdown
		if (selectedCitytxt == 'KERALA')
			strRegionCities = arrayRegionCities[0];
		else if (selectedCitytxt == 'RAJASTHAN')
			strRegionCities = arrayRegionCities[1];
		else if (selectedCitytxt == 'MAURITIUS')
				strRegionCities = arrayRegionCities[2];
		
		arrayRegionCities = strRegionCities.split("~");
		//alert(arrayRegionCities)
		for(i=0;i<arrayRegionCities.length;i++)
		{
		    var currcityval = arrayRegionCities[i];
		    var strhotels = document.Form1.hid_hotels.value;
			var ArrayHotel = strhotels.split("||")

			for(j=0;j<ArrayHotel.length;j++)
			{
					
				var currhotel = ArrayHotel[j]
				var pos  = currhotel.lastIndexOf(",")
				var postemp = currhotel.indexOf("#")
				var currcity = currhotel.substr(pos+1,postemp-pos-1)
				
				if (currcity.toUpperCase() == currcityval.toUpperCase())
				{
					//Data Format:TAJ VIEW HOTEL,AGRA#H00066##Leisure
					poscomma = currhotel.lastIndexOf(",")	//Hotelname
					pos1 = currhotel.indexOf("#")	//Duplicate hotelcode
					pos2 = currhotel.indexOf("##")	//Group
					var dupcode = currhotel.substr(pos1+1,(pos2-pos1-1))
					//var hotelname = currhotel.substr(0,poscomma)
					var hotelname = currhotel.substr(0,poscomma);
					var cityname = currhotel.substr(poscomma+1,pos1-1-poscomma);
					//document.Form1.cmbHotels.options[k] = new Option(hotelname,dupcode);
					if(hotelname=="The Gateway Hotel Ramgarh Lodge Jaipur" || hotelname=="The Gateway Hotel Rawalkot Jaisalmer" || hotelname=="The Gateway Hotel Beach Road Calicut" || hotelname=="The Gateway Hotel Marine Drive Ernakulam" || hotelname=="The Gateway Hotel Janardhanapuram Varkala" || hotelname=="The Gateway Hotel Jodhpur")
					{
					arrayRegionHotels[k] = hotelname + '~' + dupcode;
					}
					else
					{
					arrayRegionHotels[k] = hotelname + ',' + capitalizer(cityname) + '~' + dupcode;
					}
					k+=1;
				}
			}
		}
		arrayRegionHotels.sort();
		for(l=0;l<arrayRegionHotels.length;l++)
		{
			var strtemp =arrayRegionHotels[l];
			var temprec = strtemp.split('~');
			
			document.Form1.cmbHotels.options[l+1] = new Option(temprec[0],temprec[1]);
		}
		return 0;
	}
	var strhotels = document.Form1.hid_hotels.value;
	var ArrayHotel = strhotels.split("||")
	var k =1;
	RemoveOptions(document.Form1.cmbHotels)
	document.Form1.cmbHotels.options[0] = new Option("--- Select a Hotel ---",0);
	var pos2cities = selectedCitytxt.indexOf("/")

	if (pos2cities>0)
	{
		var ArrayMore = selectedCitytxt.split("/")
		for(kk=0;kk<ArrayMore.length;kk++)
		{
			for(j=0;j<ArrayHotel.length;j++)
			{
					
				var currhotel = ArrayHotel[j]
				var pos  = currhotel.lastIndexOf(",")
				var postemp = currhotel.indexOf("#")
				var currcity = currhotel.substr(pos+1,postemp-pos-1)
				if (currcity == ArrayMore[kk])
				{
					//Data Format:TAJ VIEW HOTEL,AGRA#H00066##Leisure
					poscomma = currhotel.lastIndexOf(",")
					pos1 = currhotel.indexOf("#")	//Duplicate hotelcode
					pos2 = currhotel.indexOf("##")	//Group
					var dupcode = currhotel.substr(pos1+1,(pos2-pos1-1))
					var hotelname = currhotel.substr(0,poscomma)
					document.Form1.cmbHotels.options[k] = new Option(hotelname,dupcode);
					k+=1;
				}
			}
		}
	}
	else
	{
		for(j=0;j<ArrayHotel.length;j++)
		{
				
			var currhotel = ArrayHotel[j]
			var pos  = currhotel.lastIndexOf(",")
			var postemp = currhotel.indexOf("#")
			var currcity = currhotel.substr(pos+1,postemp-pos-1)
			
			if (currcity == selectedCitytxt)
			{
				//Data Format:TAJ VIEW HOTEL,AGRA#H00066##Leisure
				poscomma = currhotel.lastIndexOf(",")	//Hotelname
				pos1 = currhotel.indexOf("#")	//Duplicate hotelcode
				pos2 = currhotel.indexOf("##")	//Group
				var dupcode = currhotel.substr(pos1+1,(pos2-pos1-1))
				var hotelname = currhotel.substr(0,poscomma)
				document.Form1.cmbHotels.options[k] = new Option(hotelname,dupcode);
				k+=1;
			}
		}
	}
	document.Form1.cmbHotels[0].selected =true;
}

function returnDuplicateHotelCode(valhotelname)
{
	var strhotels = document.Form1.hid_hotels.value;
	var ArrayHotel = strhotels.split("||")
	for(kk=0;kk<ArrayHotel.length;kk++)
	{
		var currhotel = ArrayHotel[j]
		pos1 = currhotel.indexOf("#")	//Duplicate hotelcode
		pos2 = currhotel.indexOf("##")	//Group
		var dupcode = currhotel.substr(pos1+1,(pos2-pos1-1))
	}
}

function PopulateHotelsR1()
{
	var selectedCityval = document.frmResult.cmbCity.options[document.frmResult.cmbCity.selectedIndex].value;
	var selectedCitytxt = document.frmResult.cmbCity.options[document.frmResult.cmbCity.selectedIndex].text;
	
	//Hotelnames grouped by Region
	var arrayRegion = new Array();
	var arrayRegionCities = new Array();
	arrayRegion[0] = 'KERALA';
	arrayRegion[1] = 'RAJASTHAN';
	arrayRegion[2] = 'MAURITIUS';

	arrayRegionCities[0]='Kumarakom~Thekkady~Varkala~Cochin~Calicut~Ernakulam~Kovalam~Trivandrum'
	arrayRegionCities[1]='Jaipur~Jaisalmer~Udaipur~Sawai Madhopur~Jodhpur'
	arrayRegionCities[2]='Wolmar~dummy'

	//Add hotelnames for KERALA,RAJASTHAN 
	if (selectedCitytxt == 'KERALA' || selectedCitytxt == 'RAJASTHAN' )
	{
	    var k =0;
	    var strRegionCities;
	    var arrayRegionHotels = new Array();
		RemoveOptions(document.frmResult.cmbHotels)
		document.frmResult.cmbHotels.options[0] = new Option("--- Select a Hotel ---",0);
		// Add hotels for all cities for KERALA/RAJASTHAN into hotel dropdown
		if (selectedCitytxt == 'KERALA')
			strRegionCities = arrayRegionCities[0];
		else if (selectedCitytxt == 'RAJASTHAN')
			strRegionCities = arrayRegionCities[1];
		else if (selectedCitytxt == 'MAURITIUS')
			strRegionCities = arrayRegionCities[2];
		
		arrayRegionCities = strRegionCities.split("~");
		
		for(i=0;i<arrayRegionCities.length;i++)
		{
		    var currcityval = arrayRegionCities[i];
		    var strhotels = document.frmResult.hid_hotels.value;
			var ArrayHotel = strhotels.split("||")

			for(j=0;j<ArrayHotel.length;j++)
			{
					
				var currhotel = ArrayHotel[j]
				var pos  = currhotel.lastIndexOf(",")
				var postemp = currhotel.indexOf("#")
				var currcity = currhotel.substr(pos+1,postemp-pos-1)
				
				if (currcity.toUpperCase() == currcityval.toUpperCase())
				{
					//Data Format:TAJ VIEW HOTEL,AGRA#H00066##Leisure
					poscomma = currhotel.lastIndexOf(",")	//Hotelname
					pos1 = currhotel.indexOf("#")	//Duplicate hotelcode
					pos2 = currhotel.indexOf("##")	//Group
					var dupcode = currhotel.substr(pos1+1,(pos2-pos1-1))
					var hotelname = currhotel.substr(0,poscomma);
					var cityname = currhotel.substr(poscomma+1,pos1-1-poscomma);
					//var hotelname = currhotel.substr(0,pos1);
					//document.Form1.cmbHotels.options[k] = new Option(hotelname,dupcode);
					arrayRegionHotels[k] = hotelname + ',' + capitalizer(cityname) + '~' + dupcode;
					k+=1;
				}
			}
		}
		arrayRegionHotels.sort();
		for(l=0;l<arrayRegionHotels.length;l++)
		{
			var strtemp =arrayRegionHotels[l];
			var temprec = strtemp.split('~');
            if(temprec[1]=="HLTJAIRL" || temprec[1]=="HLTJSARK" ||temprec[1]=="HLTCCJTR" || temprec[1]=="HLTTRVGR" || temprec[1]=="HLTCOKTR" || temprec[1]=="HLTJDHGH")
            {
            var temphotelname=temprec[0].split(',');
            document.frmResult.cmbHotels.options[l+1] = new Option(temphotelname[0],temprec[1]);
            }
            else
            {
			document.frmResult.cmbHotels.options[l+1] = new Option(temprec[0],temprec[1]);
			}
		}
		return 0;
	}
	
	var strhotels = document.frmResult.hid_hotels.value;
	var ArrayHotel = strhotels.split("||")
	var k =1;
	RemoveOptions(document.frmResult.cmbHotels)
	document.frmResult.cmbHotels.options[0] = new Option("--- Select a Hotel ---",0);
	var pos2cities = selectedCitytxt.indexOf("/")

	if (pos2cities>0)
	{
		var ArrayMore = selectedCitytxt.split("/")
		for(kk=0;kk<ArrayMore.length;kk++)
		{
			for(j=0;j<ArrayHotel.length;j++)
			{
					
				var currhotel = ArrayHotel[j]
				var pos  = currhotel.lastIndexOf(",")
				var postemp = currhotel.indexOf("#")
				var currcity = currhotel.substr(pos+1,postemp-pos-1)
				if (currcity == ArrayMore[kk])
				{
					//Data Format:TAJ VIEW HOTEL,AGRA#H00066##Leisure
					poscomma = currhotel.lastIndexOf(",") //Hotelname
					pos1 = currhotel.indexOf("#")	//Duplicate hotelcode
					pos2 = currhotel.indexOf("##")	//Group
					var dupcode = currhotel.substr(pos1+1,(pos2-pos1-1))
					var hotelname = currhotel.substr(0,poscomma)
					document.frmResult.cmbHotels.options[k] = new Option(hotelname,dupcode);
					k+=1;
				}
			}
		}
	}
	else
	{
		for(j=0;j<ArrayHotel.length;j++)
		{
				
			var currhotel = ArrayHotel[j]
			var pos  = currhotel.lastIndexOf(",")
			var postemp = currhotel.indexOf("#")
			var currcity = currhotel.substr(pos+1,postemp-pos-1)
			if (currcity == selectedCityval)
			{
				//Data Format:TAJ VIEW HOTEL,AGRA#H00066##Leisure
				poscomma = currhotel.lastIndexOf(",") //Hotelname
				pos1 = currhotel.indexOf("#")	//Duplicate hotelcode
				pos2 = currhotel.indexOf("##")	//Group
				var dupcode = currhotel.substr(pos1+1,(pos2-pos1-1))
				var hotelname = currhotel.substr(0,poscomma)
				document.frmResult.cmbHotels.options[k] = new Option(hotelname,dupcode);
				k+=1;
			}
		}
	}
	document.frmResult.cmbHotels[0].selected =true;
}



//Availability page 
function PopulateHotelsR2()
{

	var selectedCityval = document.FrmAvail.cmbCity.options[document.FrmAvail.cmbCity.selectedIndex].value;
	var selectedCitytxt = document.FrmAvail.cmbCity.options[document.FrmAvail.cmbCity.selectedIndex].text;
	
	//Hotelnames grouped by Region
	var arrayRegion = new Array();
	var arrayRegionCities = new Array();
	arrayRegion[0] = 'KERALA';
	arrayRegion[1] = 'RAJASTHAN';
	arrayRegion[2] = 'MAURITIUS';

	arrayRegionCities[0]='Kumarakom~Thekkady~Varkala~Cochin~Calicut~Ernakulam~Kovalam~Trivandrum'
	arrayRegionCities[1]='Jaipur~Jaisalmer~Udaipur~Sawai Madhopur~Jodhpur'
	arrayRegionCities[2]='Wolmar~dummy'

	//Add hotelnames for KERALA,RAJASTHAN 
	if (selectedCitytxt == 'KERALA' || selectedCitytxt == 'RAJASTHAN' )
	{
	    var k =0;
	    var strRegionCities;
	    var arrayRegionHotels = new Array();
		RemoveOptions(document.FrmAvail.cmbHotels)
		document.FrmAvail.cmbHotels.options[0] = new Option("--- Select a Hotel ---",0);
		// Add hotels for all cities for KERALA/RAJASTHAN into hotel dropdown
		if (selectedCitytxt == 'KERALA')
			strRegionCities = arrayRegionCities[0];
		else if (selectedCitytxt == 'RAJASTHAN')
			strRegionCities = arrayRegionCities[1];
		else if (selectedCitytxt == 'MAURITIUS')
			strRegionCities = arrayRegionCities[2];
		
		arrayRegionCities = strRegionCities.split("~");
		
		for(i=0;i<arrayRegionCities.length;i++)
		{
		    var currcityval = arrayRegionCities[i];
		    var strhotels = document.FrmAvail.hid_hotels.value;
			var ArrayHotel = strhotels.split("||")

			for(j=0;j<ArrayHotel.length;j++)
			{
					
				var currhotel = ArrayHotel[j]
				var pos  = currhotel.lastIndexOf(",")
				var postemp = currhotel.indexOf("#")
				var currcity = currhotel.substr(pos+1,postemp-pos-1)
				
				if (currcity.toUpperCase() == currcityval.toUpperCase())
				{
					//Data Format:TAJ VIEW HOTEL,AGRA#H00066##Leisure
					poscomma = currhotel.lastIndexOf(",")	//Hotelname
					pos1 = currhotel.indexOf("#")	//Duplicate hotelcode
					pos2 = currhotel.indexOf("##")	//Group
					var dupcode = currhotel.substr(pos1+1,(pos2-pos1-1))
					var hotelname = currhotel.substr(0,poscomma);
					var cityname = currhotel.substr(poscomma+1,pos1-1-poscomma);
					//var hotelname = currhotel.substr(0,pos1);
					//document.Form1.cmbHotels.options[k] = new Option(hotelname,dupcode);
					arrayRegionHotels[k] = hotelname + ',' + capitalizer(cityname) + '~' + dupcode;
					k+=1;
				}
			}
		}
		arrayRegionHotels.sort();
		for(l=0;l<arrayRegionHotels.length;l++)
		{
			var strtemp =arrayRegionHotels[l];
			var temprec = strtemp.split('~');
			if(temprec[1]=="HLTJAIRL" || temprec[1]=="HLTJSARK" ||temprec[1]=="HLTCCJTR" ||temprec[1]=="HLTTRVGR" ||temprec[1]=="HLTCOKTR" || temprec[1]=="HLTJDHGH")
            {
            var temphotelname=temprec[0].split(',');
            document.FrmAvail.cmbHotels.options[l+1] = new Option(temphotelname[0],temprec[1]);
            }
            else
            {
			document.FrmAvail.cmbHotels.options[l+1] = new Option(temprec[0],temprec[1]);
			}
			//document.FrmAvail.cmbHotels.options[l+1] = new Option(temprec[0],temprec[1]);
		}
		return 0;
	}
	
	var strhotels = document.FrmAvail.hid_hotels.value;
	var ArrayHotel = strhotels.split("||")
	var k =1;
	RemoveOptions(document.FrmAvail.cmbHotels)
	document.FrmAvail.cmbHotels.options[0] = new Option("--- Select a Hotel ---",0);
	var pos2cities = selectedCitytxt.indexOf("/")

	if (pos2cities>0)
	{
		var ArrayMore = selectedCitytxt.split("/")
		for(kk=0;kk<ArrayMore.length;kk++)
		{
			for(j=0;j<ArrayHotel.length;j++)
			{
					
				var currhotel = ArrayHotel[j]
				var pos  = currhotel.lastIndexOf(",")
				var postemp = currhotel.indexOf("#")
				var currcity = currhotel.substr(pos+1,postemp-pos-1)
				if (currcity == ArrayMore[kk])
				{
					//Data Format:TAJ VIEW HOTEL,AGRA#H00066##Leisure
					poscomma = currhotel.lastIndexOf(",") //Hotelname
					pos1 = currhotel.indexOf("#")	//Duplicate hotelcode
					pos2 = currhotel.indexOf("##")	//Group
					var dupcode = currhotel.substr(pos1+1,(pos2-pos1-1))
					var hotelname = currhotel.substr(0,poscomma)
					document.FrmAvail.cmbHotels.options[k] = new Option(hotelname,dupcode);
					k+=1;
				}
			}
		}
	}
	else
	{
		for(j=0;j<ArrayHotel.length;j++)
		{
				
			var currhotel = ArrayHotel[j]
			var pos  = currhotel.lastIndexOf(",")
			var postemp = currhotel.indexOf("#")
			var currcity = currhotel.substr(pos+1,postemp-pos-1)
			if (currcity == selectedCityval)
			{
				//Data Format:TAJ VIEW HOTEL,AGRA#H00066##Leisure
				poscomma = currhotel.lastIndexOf(",") //Hotelname
				pos1 = currhotel.indexOf("#")	//Duplicate hotelcode
				pos2 = currhotel.indexOf("##")	//Group
				var dupcode = currhotel.substr(pos1+1,(pos2-pos1-1))
				var hotelname = currhotel.substr(0,poscomma)
				document.FrmAvail.cmbHotels.options[k] = new Option(hotelname,dupcode);
				k+=1;
			}
		}
	}
	document.FrmAvail.cmbHotels[0].selected =true;
}


function checkPageData(valOption)
{
	//Quick Search -  has been selected.
	//1.If hotelname is selected, omit options selected in Facilities & Locations. Take the user to homepage of the hotel
	//2.If hotelname is not selected the process is as usual.
	var selectedCity;
	var htlflg;
	if (valOption == 1)
	{
		var sortBy = document.Form1.cmbSort.options[document.Form1.cmbSort.selectedIndex].value
		var selectedCountry =  document.Form1.cmbCountry.options[document.Form1.cmbCountry.selectedIndex].value
		
			
		if (selectedCountry == 0 || selectedCountry == "0")
		{
			alert("Select Country / Region from the above list")
			document.Form1.cmbCountry.focus();
			return;
		}
		else if (selectedCountry == "INDIA")
		{

			var navURL;
			var loc=getLocation();
			var fac=getFacilities()
			
			selectedCity = document.Form1.cmbCity.options[document.Form1.cmbCity.selectedIndex].value
			//var selectedHotel = document.getElementById("cmbHotels").options[document.Form1.cmbCity.selectedIndex].value;
			if ((selectedCity==null || selectedCity=="" || selectedCity==0 || selectedCity=="0") && loc =="" && fac=="")
			{	
				alert("Please select either one of City/Region/Location/Facilities")
				document.Form1.cmbCity.focus();
				return;
}
		/*if (selectedCity == 'BANDHAVGARH NATIONAL PARK')
		{
		//var NationalWindow = window.open ('../Common_PDF/Mahua_Kothi_Fact_Sheet_Rates.pdf', 'NationalWindow1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1');
			var NationalWindow = window.open ('../Common_PDF/Mahua_Kothi_Fact_Sheet_Rates.pdf');
			NationalWindow.focus();
			return ;
			
		}
		if (selectedCity == 'PENCH NATIONAL PARK')
		{
		//var NationalWindow = window.open ('../Common_PDF/Mahua_Kothi_Fact_Sheet_Rates.pdf', 'NationalWindow1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1');
			var BaghvanWindow = window.open ('../Common_PDF/Baghvan_Fact_Sheet_Rates.pdf');
			BaghvanWindow.focus();
			return ;
			
		}*/
			if (selectedCity==null || selectedCity=="" || selectedCity==0 || selectedCity=="0")
				navURL = "Result1.aspx?Country="+escape(selectedCountry)+"&Location="+getLocation()+"&Facilities="+getFacilities()+"&SortValue="+sortBy;
			else
			{
			selectedCity = document.Form1.cmbCity.options[document.Form1.cmbCity.selectedIndex].text
			  if(selectedCity=="AGRA" || selectedCity=="CALICUT" || selectedCity=="CHIKMAGALUR" ||selectedCity=="COONOOR" || selectedCity=="JAISALMER" || selectedCity=="MADURAI" || selectedCity=="MANGALORE" || selectedCity=="NASHIK" || selectedCity=="SURAT" || selectedCity=="VADODARA" || selectedCity=="VIJAYAWADA" || selectedCity=="VISAKHAPATNAM" || selectedCity=="VARKALA" || selectedCity=="ERNAKULAM" || selectedCity=="AHMEDABAD")
			  {
			   //GWHotelReadXML(selectedCity);
			   //window.open("http://www.thegatewayhotels.com/"+hotelidlink+"_overview.htm");
			   htlflg=1;
			  }
			 
			  //else if(selectedCity=="PANNA")
			  //{
			  //window.open("Common_Inc/pashan garh.pdf");
			  //return false;
			  //}
			  else
			  {
				for (i=0;i<arrayCities.length;i++)
				{
					if (arrayCities[i] == selectedCity)
					{
						selectedCity = arrayCitiesTogether[i]
						sortBy = orderby[i];
						break;
					}
				}
				navURL = "Result1.aspx?Country="+escape(selectedCountry)+"&City="+escape(selectedCity)+"&Location="+getLocation()+"&Facilities="+getFacilities()+"&SortValue="+sortBy;
			  }
				
			}
			//Point 1 is implemented
			var selectedHotel = document.Form1.cmbHotels.options[document.Form1.cmbHotels.selectedIndex].value			
			
			if (selectedHotel != "" && selectedHotel != 0 && selectedHotel != "0")
			{
			    if (selectedCity == "HYDERABAD")
			    {
			        if (selectedHotel == "HLTHFLKU"/*Taj Falaknuma*/)
			        {
			            var falaknuma = window.open('../Common_PDF/Taj-Falaknuma-Factsheet.pdf', 'FalaknumaWindow1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1');
			            return;
			        }
			    }
				//Get the hotel group name
			     if(selectedHotel=="HLTJSARK" || selectedHotel=="HLTAGRTV" || selectedHotel=="HLTCJBTG" || selectedHotel=="HLTIXMTG" || selectedHotel=="HLTBLRGH" || selectedHotel=="HLTJAIRL" || selectedHotel=="HLTCCJTR" || selectedHotel=="HLTISKTR" || selectedHotel=="HLTVTZTR" || selectedHotel=="HLTIXEMH" || selectedHotel=="HLTBDQTR" || selectedHotel=="HLTSTVGH" || selectedHotel=="HLTVGAGH" || selectedHotel=="HLTBLRTG" || selectedHotel=="HLTVNSTG" || selectedHotel=="HLTTRVGR" || selectedHotel=="HLTCOKTR" || selectedHotel=="HLTAMDTR" || selectedHotel=="HLTJDHGH")
			     {
			     //var strhotel=selectedHotel.substring(2);
			     //navURL="http://www.thegatewayhotels.com/"+strhotel+"_overview.htm";
			     htlflg=2;
			     }	
			   
			     //else if(selectedHotel=="HLTHJRPG")
			     //{
			     //window.open("Common_Inc/pashan garh.pdf");
			     //return false;
			     //}
			     //else if(selectedHotel=="HLNDPVNS")
			     //{
			     //window.open("../Palace/Nadesar Palace,Varanasi/NadesarPalaceBro.pdf");
			     //return false;
			     //}
			     else
			     {			        
				var strhotels = document.Form1.hid_hotels.value;
				var ArrayHotel = strhotels.split("||")
				var k =1;
				for(j=0;j<ArrayHotel.length;j++)
				{
					var currhotel = ArrayHotel[j]
					var pos=currhotel.indexOf(selectedHotel)
					if (pos>0)
					{
						pos1 = currhotel.indexOf("##")
						var poscity1 = eval(currhotel.lastIndexOf(",")+1)
						var poscity2 = eval(currhotel.indexOf("#"))
						var cityname = currhotel.substr(poscity1,eval(poscity2-poscity1))
						var groupname = currhotel.substr(pos1+2,currhotel.length-pos1)
						var hotelname = currhotel.substr(0,poscity1-1)
						/*var xtemp = document.Form1.cmbHotels.options[document.Form1.cmbHotels.selectedIndex].text
						if (xtemp.indexOf(",") > 0)
							var hotelname = document.Form1.cmbHotels.options[document.Form1.cmbHotels.selectedIndex].text
						else
							var hotelname = document.Form1.cmbHotels.options[document.Form1.cmbHotels.selectedIndex].text + ',' + cityname*/
						break;
					}
				}
				//navURL = "../"+escape(groupname)+"/"+escape(hotelname)+"/default.htm"
				navURL = "../"+escape(groupname)+"/"+escape(hotelname)+","+cityname+"/default.htm"
				}
			}
			
			if(htlflg==1)
			{
			GWHotelReadXML(selectedCity);
			window.open("http://www.thegatewayhotels.com/index.htm?hotelId="+hotelidlink+"&page=Overview");
			}
			else if(htlflg==2)
			{
			 var strhotel=selectedHotel.substring(2);
			 window.open("http://www.thegatewayhotels.com/index.htm?hotelId="+strhotel+"&page=Overview");
			}
			else
			{
			location.href = navURL
			}
		}
		else //Other than INDIA is selected
		{
		
			selectedCity = document.Form1.cmbCity.options[document.Form1.cmbCity.selectedIndex].value
			selectedHotel = document.Form1.cmbHotels.options[document.Form1.cmbHotels.selectedIndex].value
			selectedCountry = document.Form1.cmbCountry.options[document.Form1.cmbCountry.selectedIndex].value
			//if(selectedCity=="NYC000" && selectedHotel=="HLTNYCTP")
			//{
			//alert("1");
			//window.open("../luxury/The Pierre,New York/popup.htm","Theme","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=760,height=590,top=10,left=70");
		     //window.open("../Luxury/The Pierre,New York/popup.htm","Theme","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=860,height=540,top=80,left=70");
			//window.location.href="../luxury/The Pierre,New York/popup.htm"
			//return;
			//}
			if(selectedCountry=="MAURITIUS")
			{
			fn_mauritius();
			return false;
			}
			else if(selectedCity=="MAURITIUS")
			{
			fn_mauritius();
			return false;
			}
												
			if (selectedCity==null || selectedCity=="" || selectedCity==0 || selectedCity=="0")
			{
			
			//if(selectedCountry=="BHUTAN")
			//{
			//navURL="../Common_pdf/Taj-Tashi-Bhutan.pdf";
			//}
			//else
			//{
				navURL = "Result1.aspx?Country="+escape(selectedCountry)+"&Location="+getLocation()+"&Facilities="+getFacilities()+"&SortValue="+sortBy;
			//}
			}
			else
			{
			selectedCity = document.Form1.cmbCity.options[document.Form1.cmbCity.selectedIndex].text
			    
			    if (selectedHotel==null || selectedHotel=="" || selectedHotel==0 || selectedHotel=="0")
			    {
			   if(selectedCity=="MAURITIUS" && selectedCountry=="INDIAN OCEAN")
			      {
			      fn_mauritius();
			return false;
			      }
			    else
			     {
					navURL = "Result1.aspx?Country="+escape(selectedCountry)+"&City="+escape(selectedCity)+"&Location="+getLocation()+"&Facilities="+getFacilities()+"&SortValue="+sortBy;
				 }
				}
				else
				{
					/*******************/
					//Get the hotel group name
					selectedCity = document.Form1.cmbCity.options[document.Form1.cmbCity.selectedIndex].text
					var strhotels = document.Form1.hid_hotels.value;
					var ArrayHotel = strhotels.split("||")
					var k =1;
					for(j=0;j<ArrayHotel.length;j++)
					{
						var currhotel = ArrayHotel[j]
						var pos=currhotel.indexOf(selectedHotel)
						if (pos>0)
						{
							pos1 = currhotel.indexOf("##")
							var poscity1 = eval(currhotel.lastIndexOf(",")+1)
							var poscity2 = eval(currhotel.indexOf("#"))
							var cityname = currhotel.substr(poscity1,eval(poscity2-poscity1))
							var groupname = currhotel.substr(pos1+2,currhotel.length-pos1)
							var hotelname = currhotel.substr(0,poscity1-1)
							/*var xtemp = document.Form1.cmbHotels.options[document.Form1.cmbHotels.selectedIndex].text
							if (xtemp.lastIndexOf(",") > 0)
								var hotelname = document.Form1.cmbHotels.options[document.Form1.cmbHotels.selectedIndex].text
							else
								var hotelname = document.Form1.cmbHotels.options[document.Form1.cmbHotels.selectedIndex].text + ',' + cityname

							//var hotelname = document.Form1.cmbHotels.options[document.Form1.cmbHotels.selectedIndex].text + ',' + cityname*/
							break;
						}
					}
					
					if(selectedCity=="MAURITIUS" && selectedHotel=="HLTMRUTE" && selectedCountry=="INDIAN OCEAN")
			          {
			          
		            	fn_mauritius();
			return false;
			          }
			else
			{
					navURL = "../"+escape(groupname)+"/"+escape(hotelname)+","+cityname+"/default.htm"
			}		
					/****************/
				}
			}
			 if(selectedHotel=="HLTMRUTE")
			     {
			       fn_mauritius();
			     }
			      else if(selectedHotel=="HLTDUBTE")
			     {
			     window.open("Common_Inc/Taj Exotica Resort and Spa Dubai.pdf");
			     return false;
			     }
			     else if(selectedHotel=="HLTMLETC")
			     {
			      document.location.href="../TajGroup/Vivanta-taj-maldives-coral-reef/";
			      return false;
			     }
			     else if(selectedHotel=="HLTHFLKU")
			     {
			      document.location.href="../TajGroup/Vivanta-taj-maldives-coral-reef/";
			      return false;
			     }
			     
			 else
			 {
			location.href = navURL
			 }
		}
	}
	
	//Check-Rates and availablity 
	if (valOption == 2)
	{
		var selectedCountry =  document.Form1.cmbCountry.options[document.Form1.cmbCountry.selectedIndex].value
		if (selectedCountry == 0 || selectedCountry =="0")
		{
			alert("Select Country / Region from the above list")
			document.Form1.cmbCountry.focus();
			return;
		}
		else
		{
		
			var selectedCity = document.Form1.cmbCity.options[document.Form1.cmbCity.selectedIndex].value
			if(selectedCity=='0001' || selectedCity=='SAN000')
			{
			if(selectedCity=='0001' )
			  var name="Taj Gir Lodge ";
			  else
			  var name="Taj Sheba Hotel";
				
				var mesg="Please contact <a href='mailto:reservations@tajhotels.com'>reservations@tajhotels.com</a> to make bookings for this hotel.";
				var length="750";
				var breadth="400";
							
			   var url='popup1.html?name='+name +'&mesg='+mesg+'&len='+length+'&hgt='+breadth ;
			  window.open(url,'welcome','width='+length+',height='+breadth+', menubar=0,status=yes,location=0,toolbar=0,scrollbars=0,left='+(screen.width/2-350)+',top='+(screen.height/2 - 250));
			  return;
		   }
			
			if (selectedCity==null || selectedCity=="" || selectedCity==0 || selectedCity=="0")
			{
				alert("Select City / Region from the above list")
				document.Form1.cmbCity.focus();
				return;
			}
			if (selectedCity=="KERALA" || selectedCity=="RAJASTHAN")
			{
				alert("You have selected region.\nPlease Select City from the above list to check Rates & Availability.")
				document.Form1.cmbCity.focus();
				return;
			}
			if (selectedCity=="MAURITIUS")
			{
				selectedCity = "WOLMAR";
			}
		}
	 if (selectedCountry == "NEPAL")
		{
			NepalWindow = window.open ('../resevation/Res_Currency.asp?Nepal=True', 'NepalWindow1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=220,width=575');
			NepalWindow.focus();
			return ;
		}
		else
		{
			var selectedCity = document.Form1.cmbCity.options[document.Form1.cmbCity.selectedIndex].value
			if (selectedCity==null || selectedCity=="" || selectedCity==0 || selectedCity=="0")
			{
				selectedCity ="select"			
			}
		}
		
		if(selectedCity=="NYC000")
		{
		window.open("../Luxury/The Pierre,New York/popup1.htm","Theme","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=570,height=380,top=100,left=220");
		return;
		}
		
		var dtArrival,dtDepart,dtToday;
		var dtccheckin, dtcheckout
		var resOption;
		dtArrival = new Date(currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "/" + currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value + "/" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value)
		dtDepart  = new Date(currform.cmbDepartMonth.options[currform.cmbDepartMonth.selectedIndex].value + "/" + currform.cmbDepartDay.options[currform.cmbDepartDay.selectedIndex].value + "/" + currform.cmbDepartYear.options[currform.cmbDepartYear.selectedIndex].value)
		dtcheckin = currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "/" + currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value + "/" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value
		dtcheckout = currform.cmbDepartMonth.options[currform.cmbDepartMonth.selectedIndex].value + "/" + currform.cmbDepartDay.options[currform.cmbDepartDay.selectedIndex].value + "/" + currform.cmbDepartYear.options[currform.cmbDepartYear.selectedIndex].value
        /*if (selectedCity == 'BANDHAVGARH NATIONAL PARK')
		{
		var NationalWindow = window.open ('../resevation/Res_Currency.asp?Mahua=true', 'NationalWindow1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=440,width=845');
			NationalWindow.focus();
			return ;
			
		}
		if (selectedCity == 'PENCH NATIONAL PARK')
		{
		var BaghvanWindow = window.open ('../resevation/Res_Currency.asp?Baghvan=true', 'Baghvan', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=440,width=845');
			BaghvanWindow.focus();
			return ;
			
		}*/
	
		if (selectedCountry == "SEYCHELLES" && dtcheckin >= '10/1/2006'&& dtcheckin <= '12/15/2006')
		{
			NepalWindow = window.open ('../resevation/Res_Currency.asp?Seychelles=true', 'DenisWindow1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=440,width=845');
			NepalWindow.focus();
			return ;
		}
		
		if (selectedCountry == "INDIAN OCEAN" && selectedCity == "SEYCHELLES" && dtcheckin >= '10/1/2006'&& dtcheckin <= '12/15/2006')
		{
			NepalWindow = window.open ('../resevation/Res_Currency.asp?Seychelles=true', 'DenisWindow1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=440,width=845');
			NepalWindow.focus();
			return ;
		}
		if (selectedCity == "SASAN GIR")
		{
			NepalWindow = window.open ('../resevation/Res_Currency.asp?SasanGir=true', 'SasanGir', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=400,width=842,top=100,left=100');
			NepalWindow.focus();
			return ;
		}

	
		if (eval(dtArrival.getDate()) <  eval(makeReservationBefore) && eval(dtArrival.getMonth) == eval(NowMonth))
		{
			alert("Arrival Date colud be start from " + makeReservationBefore)
			currform.cmbArrivalDay.focus();
			return;
		}
		if (dtArrival > dtDepart)
		{
			alert("Change your arrival Date!!!\nArrival date is higher than Departure Date.")
			currform.cmbArrivalMonth.focus();
			return;
		}
		if (datediff2Nights() > numberOfDaysAllowed2Stay)
		{
			alert("Change your dates!!!\nMaximum length of stay is restricted to 30 Days.")
			currform.cmbDepartMonth.focus();
			return;
		}
		
		//startDateValidity*/
		
		var dtst = new Date(currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "/" + currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value + "/" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value)
		var dtend = new Date()
		dtend = DayAdd(dtend,365)

		if (dtst > dtend)
		{
			alert("Reservation is allowed maximum before a year!!!\nPlease choose different date.")
			currform.cmbArrivalMonth.focus();
			return;
		}

		if (selectedCity == 'CHIPLUN')
		{
			var dtNov1 = "12/25/2004"
			var dtNov = "12/28/2004"
			
			if (dtcheckin>dtNov1)
			{
				ChiplunWindow = window.open ('../Resevation/Res_Currency.asp?Chiplun=True', 'ChiplunWindow1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=220,width=575');
				ChiplunWindow.focus();
				return;
			}
			if (dtcheckout>dtNov)
			{
				ChiplunWindow = window.open ('../Resevation/Res_Currency.asp?Chiplun=True', 'ChiplunWindow1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=220,width=575');
				ChiplunWindow.focus();
				return;
			}
		}

		/* **** with resident option ***
		if (currform.rYes[0].checked==true)
			resOption = "Y"
		else if (currform.rYes[1].checked==true)
			resOption = "N"
		else
		{
			alert("Please select residential status")
			return;
		}*/
		 //if (selectedCountry == "BHUTAN")
		//{
		//	 window.open('../common_pdf/Taj-Tashi-Bhutan.pdf');
		//	 return;
			
		//	}
		if (selectedCountry == "INDIA")
				resOption= "Y"
				else
				resOption="N";
		var city = currform.cmbCity.options[currform.cmbCity.selectedIndex].value
			var city1 = currform.cmbCity.options[currform.cmbCity.selectedIndex].text
		document.Form1.hid_location.value = getLocation()
		document.Form1.hid_facilities.value = getFacilities()
		var inday=currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value
		var inmonth= currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "-" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value
		var outday= currform.cmbDepartDay.options[currform.cmbDepartDay.selectedIndex].value
		var outmonth=currform.cmbDepartMonth.options[currform.cmbDepartMonth.selectedIndex].value + "-" + currform.cmbDepartYear.options[currform.cmbDepartYear.selectedIndex].value
		//var rooms = currform.cmbRooms.options[currform.cmbRooms.selectedIndex].value
        var adults = currform.cmbAdults.options[currform.cmbAdults.selectedIndex].value;
        
       // var children = currform.cmbChildern.options[currform.cmbChildern.selectedIndex].value
		var selectedHotel = document.Form1.cmbHotels.options[document.Form1.cmbHotels.selectedIndex].value
		if (selectedHotel==null || selectedHotel=="" || selectedHotel==0 || selectedHotel=="0")
		{
		        alert("Select Hotel from the above list")
				document.Form1.cmbHotels.focus();
				return;
		}
		if (selectedCity == "HYDERABAD")
		{
		    if (selectedHotel == "HLTHFLKU"/*Taj Falaknuma*/)
		    {
		        var falaknuma = window.open('../Common_PDF/Taj-Falaknuma-Factsheet.pdf', 'FalaknumaWindow1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1');
		        return;
		    }
		}
		if(selectedHotel=="HLTDUBTE")
		{
		 window.open("Common_Inc/Taj Exotica Resort and Spa Dubai.pdf");
			     return false;
		}
		
		
		if (selectedHotel==null || selectedHotel=="" || selectedHotel==0 || selectedHotel=="0")
		{
	
		if(city=='TajV3KE' || city =='TajV3Rj')
		{
		var	strvalues = city + "&in_day=" + inday + "&in_month=" + inmonth  + "&out_day=" + outday + "&out_month=" + outmonth + "&guests=" + adults
		var reDirectUrl = "https://www.trustinternational.com/mBooker/taj?LANGUAGE=en&i=" + strvalues
			location.href = reDirectUrl 
			return;
		}
		
				strvalues = "city_code=" +city+ "&in_day=" + inday + "&in_month=" + inmonth  + "&out_day=" + outday + "&out_month=" + outmonth + "&guests=" + adults
				}
		else
				
			//var	strvalues = "property_selection=TXL-TJ-"+ selectedHotel   + "&in_day=" + inday + "&in_month=" + inmonth  + "&out_day=" + outday + "&out_month=" + outmonth + "&guests=" +  adults 
           
            ReadXml(selectedHotel);
         
            var ccount=coucity.split('|');
            //alert(ccount[0]);
            var arrmon=inmonth.split('-');
           
           if(inday.length==1)
           inday="0"+inday;
            //var chkinarr=getMonth(arrmon[0])+"%20" +inday+ "%2C" +arrmon[1];
            //Code for reservation changed
            var arr_month;
            if(arrmon[0].length <= 1)
            {
            arr_month="0"+arrmon[0];
            }
            else
            {
            arr_month=arrmon[0];
            }
            var chkinarr=arrmon[1]+"-"+arr_month+"-"+inday;
            var arroutmon=outmonth.split('-');
            if(outday.length==1)
            outday="0"+outday;
            var dep_month;
            if(arroutmon[0].length <= 1)
            {
            dep_month="0"+arroutmon[0];
            }
            else
            {
            dep_month=arroutmon[0];
            }
            var chkoutarr=arroutmon[1]+"-"+dep_month+"-"+outday;
            var	strvalues = "ccpSelectCity="+ccount[1]+"&ccpSelectCountry="+ccount[0]+"&ccpSelectHotel=TJ%2D"+ selectedHotel   + "&calArrivalDateField="+chkinarr+"&calDepartureDateField="+chkoutarr;//+"&prsRoomCount="+rooms//+"&occupancy="+adults
            
            var j;
            var i;
            //var rms=document.Form1.cmbRooms.options[document.Form1.cmbRooms.selectedIndex].value;
            var prs=document.Form1.cmbAdults.options[document.Form1.cmbAdults.selectedIndex].value;
          
          if(document.Form1.cmbAdults.options[document.Form1.cmbAdults.selectedIndex].value<totalguest)
          {
          
            for(i=1;i<=1;i++)
              {
                var chid="cmbchildcnt"+i;
                //alert(document.getElementById(chid));&occupancy=
                if(i==1)
                var adults=parseInt(document.getElementById(chid).value)+parseInt(currform.cmbAdults.options[currform.cmbAdults.selectedIndex].value);
                if(document.getElementById(chid).value>0)
                {
                 
                if(strvalues==null)
                   strvalues="&prsNumChildren="+document.getElementById(chid).value;
                else
                strvalues+="&prsNumChildren="+document.getElementById(chid).value;
                    //alert(room);
                    for(j=1;j<=document.getElementById(chid).value;j++)
                     {
                   
                           if(i==1)
                              {
                                  var ageId="childagecmbchildcnt"+(parseInt(j)-1);
                                   //alert(ageId);
                               }
                            else
                            {
                                    var ageId="childagecmbchildcnt"+i+(j-1);
                                   // alert(document.getElementById(ageId).value);
                            }
                  if(document.getElementById(ageId).value=="<1")
                  {
                  strvalues+="&prsRoomAge=0";
                  }
                  else
                  {          
                 strvalues+="&prsRoomAge="+document.getElementById(ageId).value;
                  }
                       }
                 }
               }
               //alert(url);
          }
          //alert(parseInt(document.getElementById(chid).value)+parseInt(currform.cmbAdults.options[currform.cmbAdults.selectedIndex].value));
                   	
           	//var	strvalues = "ccpSelectCity="+ccount[1]+"&ccpSelectCountry="+ccount[0]+"&ccpSelectHotel=TJ%2D"+ selectedHotel   + "&calArrivalDateField="+chkinarr+"&calDepartureDateField="+chkoutarr+"&prsRoomCount="+rooms+"&occupancy="+adults

        /*if (selectedHotel == "H00033")  //Maldives, Taj Exotica Resort & Spa is disabled from reservation
        {
			openMaldivesWindow()
			currform.cmbDepartMonth.options[currform.cmbDepartMonth.selectedIndex].value + "/" + currform.cmbDepartDay.options[currform.cmbDepartDay.selectedIndex].value + "/" + currform.cmbDepartYear.options[currform.cmbDepartYear.selectedIndex].value)
        }
        else
        {*/
        //importXML(strvalues);
      
	if(selectedHotel == 'HLTMLETC')
			{
				var name="Taj Coral Reef Resort ";
				var date1="4/1/2008";
				var date2="12/15/2008";
				var mesg="Taj Coral Reef Resort, Maldives is closed for renovations from April 1 to February 15, 2009. For stays in Maldives during this period, please check availability at our other luxury resort Taj Exotica Resort  Spa, Maldives.";
				var length="750";
				var breadth="400";
				
				if (date2 == '~')
			{
			if( Date.parse(dtcheckin) >= Date.parse (date1) || Date.parse(dtcheckout) >= Date.parse (date1))
			{
			   var url='popup.aspx?name='+name +'&mesg='+mesg+'&len='+length+'&hgt='+breadth ;
			  window.open(url,'welcome','width='+length+',height='+breadth+', menubar=0,status=yes,location=0,toolbar=0,scrollbars=0,left='+(screen.width/2-350)+',top='+(screen.height/2 - 250));
			  return;
		   }
		   
		   }
			else
			if((Date.parse (dtcheckin) >= Date.parse (date1) && Date.parse (dtcheckin) <= Date.parse (date2)) ||(Date.parse (dtcheckout) >= Date.parse (date1) && Date.parse (dtcheckout) <= Date.parse (date2)) )
			{
				
			  var url='popup.aspx?name='+name +'&mesg='+mesg+'&len='+length+'&hgt='+breadth ;
			  window.open(url,'welcome','width='+length+',height='+breadth+', menubar=0,status=yes,location=0,toolbar=0,scrollbars=0,left='+(screen.width/2-350)+',top='+(screen.height/2 - 250));
			  return;
			}
				
			}
	//End of part 
	var reDirectUrl;
	if(selectedHotel=="HLTJSARK" || selectedHotel=="HLTAGRTV" || selectedHotel=="HLTCJBTG" || selectedHotel=="HLTIXMTG" || selectedHotel=="HLTBLRGH" || selectedHotel=="HLTJAIRL" || selectedHotel=="HLTCCJTR" || selectedHotel=="HLTISKTR" || selectedHotel=="HLTVTZTR" || selectedHotel=="HLTIXEMH" || selectedHotel=="HLTBDQTR" || selectedHotel=="HLTSTVGH" || selectedHotel=="HLTVGAGH" || selectedHotel=="HLTBLRTG" || selectedHotel=="HLTVNSTG" || selectedHotel=="HLTTRVGR" || selectedHotel=="HLTCOKTR" || selectedHotel=="HLTAMDTR" || selectedHotel=="HLTJDHGH")
     {
     reDirectUrl="https://www.yourreservation.net/ibe/02_gateway/main.htm?language=EN&quick=quick&"+"occupancy="+adults +"&"+strvalues;
    // alert(reDirectUrl);
     }
     else if(selectedHotel=="HLTMRUTE")
     {
      fn_mauritius();
      return false;
     }
     else
     {
	  reDirectUrl =strurllink+"occupancy="+adults +"&"+ strvalues;
	 }
			//location.href = reDirectUrl 
			window.open(reDirectUrl);
	  
	}
}


function getMonth(mm)
		  {
		  switch(mm)
		  {
		 case '1':
		  return 'January';
		  break;
		  case '2':
		  return 'February';
		  break;
		  case '3':
		  return 'March';
		  break;
		  case '4':
		  return 'April';
		  break;
		  case '5':
		  return 'May';
		  break;
		  case '6':
		  return 'June';
		  break;
		  case '7':
		  return 'July';
		  break;
		  case '8':
		  return 'August';
		  break;
		  case '9':
		  return 'September';
		  break;
		  case '10':
		  return 'October';
		  break;
		  case '11':
		  return 'November';
		  break;
		  case '12':
		  return 'December';
		  break;
		  }
		  
		  }


function getLocation()
{
	var disp="";
	for(i=0;i<currform.LOC.length;i++)
	{
		if (currform.LOC[i].checked == true)
		{
		   if (disp == "")
			   disp = "'" + currform.LOC[i].value + "'"
		   else
			   disp = disp + amenityDL + "'"+ currform.LOC[i].value + "'";
		}
	}
	return disp;
}

function getFacilities()
{
	var disp="";
	for(i=0;i<document.Form1.FAC.length;i++)
	{
		if (document.Form1.FAC[i].checked == true)
		{
		   if (disp == "")
			   disp = "'" + document.Form1.FAC[i].value + "'";
		   else
			   disp = disp + amenityDL + "'" + document.Form1.FAC[i].value+"'";
		}
	}
	return disp;
}

//Result page - Find a hotel function
function checkPageDataR1(valOption)
{

var chkflag;
	if (valOption == 1)
	{
		var sortBy = 0;
		var selectedCountry =  document.frmResult.cmbCountry.options[document.frmResult.cmbCountry.selectedIndex].value
		
	if (selectedCountry == 0 || selectedCountry =="0")
		{
			alert("Select Country / Region from the above list")
			document.frmResult.cmbCountry.focus();
			return;
		}
		else if (selectedCountry=="INDIA")
		{
			var navURL;
			var loc=getLocationResult();
			var fac=getFacilitiesResult();

			var selectedCity = document.frmResult.cmbCity.options[document.frmResult.cmbCity.selectedIndex].value
			if ((selectedCity==null || selectedCity=="" || selectedCity==0 || selectedCity=="0") && loc =="" && fac=="")
			{	
				alert("Please select either one of City/Region/Location/Facilities")
				document.frmResult.cmbCity.focus();
				return;
			}
			if (selectedCity==null || selectedCity=="" || selectedCity==0 || selectedCity=="0")
			{
				navURL = "Result1.aspx?Country="+escape(selectedCountry)+"&Location="+getLocationResult()+"&Facilities="+getFacilitiesResult();
			}
			else
			{
			selectedCity = document.frmResult.cmbCity.options[document.frmResult.cmbCity.selectedIndex].text;
			if(selectedCity=="AGRA" || selectedCity=="CALICUT" || selectedCity=="CHIKMAGALUR" ||selectedCity=="COONOOR" || selectedCity=="JAISALMER" || selectedCity=="MADURAI" || selectedCity=="MANGALORE" || selectedCity=="NASHIK" || selectedCity=="SURAT" || selectedCity=="VADODARA" || selectedCity=="VIJAYAWADA" || selectedCity=="VISAKHAPATNAM" || selectedCity=="VARKALA" || selectedCity=="ERNAKULAM" || selectedCity=="AHMEDABAD")
			  {
			   //GWHotelReadXML(selectedCity);
			   //window.open("http://www.thegatewayhotels.com/"+hotelidlink+"_overview.htm");
			   chkflag=1;
			  }
			
			//else if(selectedCity=="PANNA")
			 //{
			 //window.open('Common_Inc/pashan garh.pdf');
			 //return false;
			 //}
			else
			 {
				for (i=0;i<arrayCities.length;i++)
				{
					if (arrayCities[i] == selectedCity)
					{
						selectedCity = arrayCitiesTogether[i]
						sortBy = orderby[i];
						break;
					}
				}
				navURL = "Result1.aspx?Country="+escape(selectedCountry)+"&City="+escape(selectedCity)+"&Location="+getLocationResult()+"&Facilities="+getFacilitiesResult()+"&SortValue="+sortBy;
			 }
			}
			
			//Result page add hotel combo
			//Point 1 is implemented
			var selectedHotel = document.frmResult.cmbHotels.options[document.frmResult.cmbHotels.selectedIndex].value			
			if (selectedHotel != "" && selectedHotel != 0 && selectedHotel != "0")
			{
			    if (selectedCity == "HYDERABAD")
			    {
			        if (selectedHotel == "HLTHFLKU" || selectedHotel == "H00102"/*Taj Falaknuma*/)
			        {
			            var falaknuma = window.open('../Common_PDF/Taj-Falaknuma-Factsheet.pdf', 'FalaknumaWindow1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1');
			            return;
			        }
			    }
				//Get the hotel group name
				 if(selectedHotel=="HLTJSARK" || selectedHotel=="HLTAGRTV" || selectedHotel=="HLTCJBTG" || selectedHotel=="HLTIXMTG" || selectedHotel=="HLTBLRGH" || selectedHotel=="HLTJAIRL" || selectedHotel=="HLTCCJTR" || selectedHotel=="HLTISKTR" || selectedHotel=="HLTVTZTR" || selectedHotel=="HLTIXEMH" || selectedHotel=="HLTBDQTR" || selectedHotel=="HLTSTVGH" || selectedHotel=="HLTVGAGH" || selectedHotel=="HLTBLRTG" || selectedHotel=="HLTVNSTG" || selectedHotel=="HLTCOKTR" || selectedHotel=="HLTTRVGR" || selectedHotel=="HLTAMDTR" || selectedHotel=="HLTJDHGH")
			     {
			     //var strhotel=selectedHotel.substring(2);
			     //navURL="http://www.thegatewayhotels.com/"+strhotel+"_overview.htm";
			     chkflag=2;
			     }	
				
				//else if(selectedHotel=="HLTHJRPG")
				//{
				//window.open('Common_Inc/pashan garh.pdf');
				//return false;
				//}
				//else if(selectedHotel=="HLNDPVNS")
				//{
				//window.open("../Palace/Nadesar Palace,Varanasi/NadesarPalaceBro.pdf");
				//return false;
				//}
				else
				{
				var strhotels = document.frmResult.hid_hotels.value;
				var ArrayHotel = strhotels.split("||")
				var k =1;
				for(j=0;j<ArrayHotel.length;j++)
				{
					var currhotel = ArrayHotel[j]
					var pos=currhotel.indexOf(selectedHotel)
					if (pos>0)
					{
						pos1 = currhotel.indexOf("##")
						var poscity1 = eval(currhotel.lastIndexOf(",")+1)
						var poscity2 = eval(currhotel.indexOf("#"))
						var cityname = currhotel.substr(poscity1,eval(poscity2-poscity1))
						var groupname = currhotel.substr(pos1+2,currhotel.length-pos1)
						var hotelname = currhotel.substr(0,poscity1-1)
						/*var xtemp = document.frmResult.cmbHotels.options[document.frmResult.cmbHotels.selectedIndex].text
						if (xtemp.indexOf(",") > 0)
							var hotelname = document.frmResult.cmbHotels.options[document.frmResult.cmbHotels.selectedIndex].text;
						else
							var hotelname = document.frmResult.cmbHotels.options[document.frmResult.cmbHotels.selectedIndex].text + ',' + cityname*/
						break;
					}
				}
				//navURL = "../"+escape(groupname)+"/"+escape(hotelname)+"/default.htm"
				navURL = "../"+escape(groupname)+"/"+escape(hotelname)+","+escape(cityname)+"/default.htm"
			   }
			}
			if(chkflag==1)
			{
			GWHotelReadXML(selectedCity);
			window.open("http://www.thegatewayhotels.com/index.htm?hotelId="+hotelidlink+"&page=Overview");
			}
			else if(chkflag==2)
			{
			var strhotel1=selectedHotel.substring(2);
			window.open("http://www.thegatewayhotels.com/index.htm?hotelId="+strhotel1+"&page=Overview");
			}
			else
			{
			location.href = navURL
			}
		}
		else //Other than INDIA is selected
		{
			selectedCity = document.frmResult.cmbCity.options[document.frmResult.cmbCity.selectedIndex].value
			selectedHotel = document.frmResult.cmbHotels.options[document.frmResult.cmbHotels.selectedIndex].value
			selectedCountry = document.frmResult.cmbCountry.options[document.frmResult.cmbCountry.selectedIndex].value
			//if(selectedCity=="NEW YORK" && selectedHotel=="HLTNYCTP")
			//{
			//window.open("../luxury/The Pierre,New York/popup.htm","Theme","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=760,height=590,top=10,left=70");
			//window.open("../Luxury/The Pierre,New York/popup.htm","Theme","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=860,height=540,top=80,left=70");
			//window.location.href="../luxury/The Pierre,New York/popup.htm"
			//return;
			//} 
			
			if(selectedCountry=="MAURITIUS")
			     {
			       fn_mauritius();
			       return false;
			     }
			     else if(selectedCity=="MAURITIUS")
			     {
			       fn_mauritius();
			       return false;
			     }
			if (selectedCity==null || selectedCity=="" || selectedCity==0 || selectedCity=="0")
			{
			//alert(selectedCountry);
			//if(selectedCountry=="BHUTAN")
			//{
			//navURL="../Common_pdf/Taj-Tashi-Bhutan.pdf";
			//}
			//else
			//{
				navURL = "Result1.aspx?Country="+escape(selectedCountry)+"&Location="+getLocationResult()+"&Facilities="+getFacilitiesResult()+"&SortValue="+sortBy;
			//}
				//navURL = "Result1.aspx?Country="+escape(selectedCountry)+"&Location="+getLocationResult()+"&Facilities="+getFacilitiesResult()+"&SortValue="+sortBy;
			}
			else
			{
			    if (selectedHotel==null || selectedHotel=="" || selectedHotel==0 || selectedHotel=="0")
			    {
			    //if(selectedCountry=="BHUTAN" && selectedCity=="THIMPHU")
			     //{
			     //navURL="../Common_pdf/Taj-Tashi-Bhutan.pdf";
			     //}
			    //else
			     //{ 
					navURL = "Result1.aspx?Country="+escape(selectedCountry)+"&City="+escape(selectedCity)+"&Location="+getLocationResult()+"&Facilities="+getFacilitiesResult()+"&SortValue="+sortBy;
				 //}
				}
				else
				{
					/*******************/
					//Get the hotel group name
					var strhotels = document.frmResult.hid_hotels.value;
					var ArrayHotel = strhotels.split("||")
					var k =1;
					for(j=0;j<ArrayHotel.length;j++)
					{
						var currhotel = ArrayHotel[j]
						var pos=currhotel.indexOf(selectedHotel)
						if (pos>0)
						{
							pos1 = currhotel.indexOf("##")
							var poscity1 = eval(currhotel.lastIndexOf(",")+1)
							var poscity2 = eval(currhotel.indexOf("#"))
							var cityname = currhotel.substr(poscity1,eval(poscity2-poscity1))
							var groupname = currhotel.substr(pos1+2,currhotel.length-pos1)
							var hotelname = currhotel.substr(0,poscity1-1)
							/*var xtemp = document.frmResult.cmbHotels.options[document.frmResult.cmbHotels.selectedIndex].text
							if (xtemp.indexOf(",") > 0)
								var hotelname = document.frmResult.cmbHotels.options[document.frmResult.cmbHotels.selectedIndex].text
							else
								var hotelname = document.frmResult.cmbHotels.options[document.frmResult.cmbHotels.selectedIndex].text + ',' + cityname*/

							//var hotelname = document.Form1.cmbHotels.options[document.Form1.cmbHotels.selectedIndex].text + ',' + cityname
							break;
						}
					}
					//alert(selectedCountry);
					//alert(selectedCity);
					//alert(selectedHotel);
					//if(selectedCity=="THIMPHU" && selectedHotel=="HLTPBHTT")
			          //{
		            	//navURL="../Common_pdf/Taj-Tashi-Bhutan.pdf";
			          //}
			          //else
			          //{
					navURL = "../"+escape(groupname)+"/"+escape(hotelname)+","+escape(cityname)+"/default.htm"
					  //}
					//navURL = "../"+escape(groupname)+"/"+escape(hotelname)+"/default.htm"
					/****************/
				}
			}
			if(selectedHotel=="HLTMRUTE")
			     {
			       fn_mauritius();
			     }
			     else if(selectedHotel=="HLTDUBTE")
			{
			  window.open('Common_Inc/Taj Exotica Resort and Spa Dubai.pdf');
			return;
			}
			else if(selectedHotel=="HLTMLETC")
			{
			  document.location.href="../TajGroup/Vivanta-taj-maldives-coral-reef";
			  return false;
			}
			     else
			     {
			location.href = navURL
			}
		}
	}
}


//checkrates Functions callable in Result1.page
function checkrates(mid)
{
	/*
	document.frmResult.hid_submit.value="2";
	document.frmResult.hid_Hotel.value=mid;
	document.frmResult.submit();
	*/
    if (mid == 'H00102')
    {
        var FalaknumaWindow = window.open('../Common_pdf/Taj-Falaknuma-Factsheet.pdf', 'TajFalaknuma', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=400,width=842,top=100,left=100');
        FalaknumaWindow.focus();
        return;
    }
    document.location.href = "Availability.aspx?HotelId=" + mid;
	
}

//AvailSubmit Functions callable in Availability Page
function AvailSubmit(vl)
{

	var dtArrival,dtDepart,dtToday;
	var dtccheckin, dtcheckout
	var resOption;
	dtArrival = new Date(currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "/" + currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value + "/" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value)
	dtDepart  = new Date(currform.cmbDepartMonth.options[currform.cmbDepartMonth.selectedIndex].value + "/" + currform.cmbDepartDay.options[currform.cmbDepartDay.selectedIndex].value + "/" + currform.cmbDepartYear.options[currform.cmbDepartYear.selectedIndex].value)
	dtcheckin = currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "/" + currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value + "/" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value
	dtcheckout = currform.cmbDepartMonth.options[currform.cmbDepartMonth.selectedIndex].value + "/" + currform.cmbDepartDay.options[currform.cmbDepartDay.selectedIndex].value + "/" + currform.cmbDepartYear.options[currform.cmbDepartYear.selectedIndex].value

	if (eval(dtArrival.getDate()) <  eval(makeReservationBefore) && eval(dtArrival.getMonth) == eval(NowMonth))
	{
		alert("Arrival Date colud be start from " + makeReservationBefore)
		currform.cmbArrivalDay.focus();
		return;
	}
	if (dtArrival > dtDepart)
	{
		alert("Arrival date is higher than Departure Date!!!.\nChange your arrival Date")
		currform.cmbArrivalMonth.focus();
		return;
	}
	if (datediff2Nights() > numberOfDaysAllowed2Stay)
	{
		alert("Maximum length of stay is restricted to 30 Days!!!\nChange your dates.")
		currform.cmbDepartMonth.focus();
		return;
	}
	
	//startDateValidity*/
		
	var dtst = new Date(currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "/" + currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value + "/" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value)
	var dtend = new Date()
	dtend = DayAdd(dtend,365)
	
	if (dtst > dtend)
	{
		alert("Reservation is allowed maximum before a year!!!\nPlease choose different date.")
		//currform.cmbArrivalMonth.focus();
		return;
}
if (currform.hid_hotel.value == 'H00102')
{
    var FalaknumaWindow = window.open('../Common_pdf/Taj-Falaknuma-Factsheet.pdf', 'TajFalaknuma', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=400,width=842,top=100,left=100');
    FalaknumaWindow.focus();
    return;

}	

	if (currform.hid_hotel.value == 'H00009')
	{
			var dtNov1 = "12/25/2004"
			var dtNov = "12/28/2004"
			
			if (dtcheckin>dtNov1)
			{
				ChiplunWindow = window.open ('../Resevation/Res_Currency.asp?Chiplun=True', 'ChiplunWindow1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=220,width=575');
				ChiplunWindow.focus();
				return;
			}
			if (dtcheckout>dtNov)
			{
				ChiplunWindow = window.open ('../Resevation/Res_Currency.asp?Chiplun=True', 'ChiplunWindow1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=220,width=575');
				ChiplunWindow.focus();
				return;
			}
	}
	if (currform.hid_hotel.value == 'H00079')
	{
	if (dtcheckin >= '10/1/2006'&& dtcheckin <= '12/15/2006')
		{
			NepalWindow = window.open ('../resevation/Res_Currency.asp?Seychelles=true', 'DenisWindow1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=440,width=845');
			NepalWindow.focus();
			return ;
		}
	}
    if (currform.hid_hotel.value == 'H00070')
	{
			NepalWindow = window.open ('../resevation/Res_Currency.asp?SasanGir=true', 'SasanGir', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=400,width=842,top=100,left=100');
			NepalWindow.focus();
			return ;

}
	/*
	if (currform.rYes[0].checked==true)
		resOption = "Y"
	else if (currform.rYes[1].checked==true)
		resOption = "N"
	else
	{
		alert("Please select residential status")
		return;
	}*/
	//***** Check with xml file for temporary close of reservation ****
	
//if(document.FrmAvail.orginal_city.value=='NEW YORK')
//	{
	
//	window.open("../Luxury/The Pierre,New York/popup1.htm","Theme","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=570,height=380,top=100,left=220");
//	return;
//	}
	
	 if(document.FrmAvail.orginal_ctry.value == 'INDIA')
		resOption = "Y"
		else
		resOption = "N";
		var inday=currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value
		var inmonth= currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "-" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value
		var outday= currform.cmbDepartDay.options[currform.cmbDepartDay.selectedIndex].value
		var outmonth=currform.cmbDepartMonth.options[currform.cmbDepartMonth.selectedIndex].value + "-" + currform.cmbDepartYear.options[currform.cmbDepartYear.selectedIndex].value
	var selectedHotel = document.FrmAvail.hid.value;
	var country  = document.FrmAvail.orginal_ctry.value;
	var city     = document.FrmAvail.orginal_city.value;
	//var rooms    = currform.cmbRooms.options[currform.cmbRooms.selectedIndex].value ;
	var adults   = currform.cmbAdults.options[currform.cmbAdults.selectedIndex].value ;
	//var children = currform.cmbChildern.options[currform.cmbChildern.selectedIndex].value
	
	//if(selectedHotel=="HLTJLRBT" || selectedHotel=="HLTHJRPG")
     // {
       //fn_khajurahowindow(selectedHotel);
       //return false;
	//}
	if (selectedHotel == "HLTHFLKU")
	{
	    window.open("../Common_pdf/Taj-Falaknuma-Factsheet.pdf");
	    return false;
	}
    if(selectedHotel=="HLTDUBTE")
    {
    window.open("Common_Inc/Taj Exotica Resort and Spa Dubai.pdf");
    return false;
    }
  
    
ReadXml(selectedHotel);
var ccont=coucity.split('|');
var arrmn=inmonth.split('-');
if(inday.length==1)
           inday="0"+inday;
     //Code Changed
     //var chkinarr1=getMonth(arrmn[0])+"%20" +inday+ "%2C" +arrmn[1];
     var availarr_month;
    if(arrmn[0].length <=1)
    {
    availarr_month="0"+arrmn[0];
    }
    else
    {
    availarr_month=arrmn[0];
    }     
     var chkinarr1=arrmn[1]+"-" +availarr_month+ "-" +inday;     
var arroutmn=outmonth.split('-');
            if(outday.length==1)
            outday="0"+outday;
             // var chkoutarr1=getMonth(arroutmn[0])+"%20" +outday+ "%2C" +arroutmn[1];
           var availdep_month;
           if(arroutmn[0].length <=1)
           {
           availdep_month="0"+arroutmn[0];
           }
           else
           {
           availdep_month=arroutmn[0];
           }
           var chkoutarr1=arroutmn[1]+"-" +availdep_month+ "-" +outday;
  var	strvalues = "ccpSelectCity="+ccont[1]+"&ccpSelectCountry="+ccont[0]+"&ccpSelectHotel=TJ%2D"+ selectedHotel   + "&calArrivalDateField="+chkinarr1+"&calDepartureDateField="+chkoutarr1;//+"&prsRoomCount="+rooms//+"&occupancy="+adults          
         
            var j;
            var i;
            //var rms=document.FrmAvail.cmbRooms.options[document.FrmAvail.cmbRooms.selectedIndex].value;
            var prs=document.FrmAvail.cmbAdults.options[document.FrmAvail.cmbAdults.selectedIndex].value;
          
         if(document.FrmAvail.cmbAdults.options[document.FrmAvail.cmbAdults.selectedIndex].value<totalguest)
          {
          
            for(i=1;i<=1;i++)
              {
                var chid="cmbchildcnt"+i;
                //alert(document.getElementById(chid));
                if(i==1)
                var adults=parseInt(document.getElementById(chid).value)+parseInt(currform.cmbAdults.options[currform.cmbAdults.selectedIndex].value);
                if(document.getElementById(chid).value>=0)
                {
                 
                if(strvalues==null)
                   strvalues="&prsNumChildren="+document.getElementById(chid).value;
                else
                strvalues+="&prsNumChildren="+document.getElementById(chid).value;
                    //alert(room);
                    for(j=1;j<=document.getElementById(chid).value;j++)
                     {
                   
                           if(i==1)
                              {
                                  var ageId="childagecmbchildcnt"+(parseInt(j)-1);
                                   //alert(ageId);
                               }
                            else
                            {
                                    var ageId="childagecmbchildcnt"+i+(j-1);
                                   // alert(document.getElementById(ageId).value);
                            }
                  if(document.getElementById(ageId).value=="<1")
                  {
                  strvalues+="&prsRoomAge=0";
                  }
                  else
                  {          
                 strvalues+="&prsRoomAge="+document.getElementById(ageId).value;
                  }
                       }
                 }
               }
               //alert(url);
          }
          
            
//var	strvalues = "property_selection=TXL-TJ-"+ selectedHotel   + "&in_day=" + inday + "&in_month=" + inmonth  + "&out_day=" + outday + "&out_month=" + outmonth + "&guests=" +  adults 
		//var	strvalues = "property_selection=TXL-TJ-"+ selectedHotel   + "&in_day=" + inday + "&in_month=" + inmonth  + "&out_day=" + outday + "&out_month=" + outmonth + "&guests=" +  adults 
		
	//importXML(strvalues);
	if(selectedHotel == 'HLTGL' || selectedHotel =='HLT2')
			{
			if(selectedHotel=='HLTGL' )
			  var name="Taj Gir Lodge ";
			  else
			  var name="Taj Sheba Hotel";
				
				var mesg="Please contact <A href 'mailto:reservations@tajhotels.com' >reservations@tajhotels.com </a>to make bookings for this hotel.";
				var length="750";
				var breadth="400";
							
			   var url='popup1.html?name='+name +'&mesg='+mesg+'&len='+length+'&hgt='+breadth ;
			  window.open(url,'welcome','width='+length+',height='+breadth+', menubar=0,status=yes,location=0,toolbar=0,scrollbars=0,left='+(screen.width/2-350)+',top='+(screen.height/2 - 250));
			  return;
		   }
	if(currform.hid.value == 'HLTMLETC')
			{
				var name="Taj Coral Reef Resort ";
				var date1="4/1/2008";
				var date2="12/15/2008";
				var mesg="Taj Coral Reef Resort, Maldives is closed for renovations from April 1 to February 15, 2009. For stays in Maldives during this period, please check availability at our other luxury resort Taj Exotica Resort  Spa, Maldives.";
				var length="750";
				var breadth="400";
				
				if (date2 == '~')
			{
			if( Date.parse(dtcheckin) >= Date.parse (date1) || Date.parse(dtcheckout) >= Date.parse (date1))
			{
			   var url='popup.aspx?name='+name +'&mesg='+mesg+'&len='+length+'&hgt='+breadth ;
			  window.open(url,'welcome','width='+length+',height='+breadth+', menubar=0,status=yes,location=0,toolbar=0,scrollbars=0,left='+(screen.width/2-350)+',top='+(screen.height/2 - 250));
			  return;
		   }
		   
		   }
			else
			if((Date.parse (dtcheckin) >= Date.parse (date1) && Date.parse (dtcheckin) <= Date.parse (date2)) ||(Date.parse (dtcheckout) >= Date.parse (date1) && Date.parse (dtcheckout) <= Date.parse (date2)) )
			{
				
			  var url='popup.aspx?name='+name +'&mesg='+mesg+'&len='+length+'&hgt='+breadth ;
			  window.open(url,'welcome','width='+length+',height='+breadth+', menubar=0,status=yes,location=0,toolbar=0,scrollbars=0,left='+(screen.width/2-350)+',top='+(screen.height/2 - 250));
			  return;
			}
				
			}
	//End of part 	
	if (vl == 1)
	{
	if(selectedHotel=="HLTJSARK" || selectedHotel=="HLTAGRTV" || selectedHotel=="HLTCJBTG" || selectedHotel=="HLTIXMTG" || selectedHotel=="HLTBLRGH" || selectedHotel=="HLTJAIRL" || selectedHotel=="HLTCCJTR" || selectedHotel=="HLTISKTR" || selectedHotel=="HLTVTZTR" || selectedHotel=="HLTIXEMH" || selectedHotel=="HLTBDQTR" || selectedHotel=="HLTSTVGH" || selectedHotel=="HLTVGAGH" || selectedHotel=="HLTBLRTG" || selectedHotel=="HLTVNSTG" || selectedHotel=="HLTTRVGR" || selectedHotel=="HLTCOKTR" || selectedHotel=="HLTAMDTR" || selectedHotel=="HLTJDHGH")
      {
        var offerurl="https://www.yourreservation.net/ibe/02_gateway/main.htm?language=EN&quick=quick&" +"occupancy="+adults +"&"+ strvalues;
        window.open(offerurl);
        //location.href = "https://www.yourreservation.net/ibe/02_gateway/main.htm?language=EN&quick=quick&" +"occupancy="+adults +"&"+ strvalues;
      }
      else
      {
      window.open(strurllink +"occupancy="+adults +"&"+ strvalues);
			//location.href = strurllink +"occupancy="+adults +"&"+ strvalues;
			//location.href="https://www.yourreservation.net/ibe/02_taj/main.html?language=EN&quick=page1&" + strvalues
	   }
	}
	
}

function importXML(val)
{
	if (document.implementation && document.implementation.createDocument)
	{
		xmlDoc = document.implementation.createDocument("", "", null);
		currform.strvalues.value=val;
		xmlDoc.onload = createTable;
		
	}
	else if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.onreadystatechange = function () {
			if (xmlDoc.readyState == 4) createTable(val)
		};
 	}
	else
	{
		alert('Your browser can\'t handle this script');
		return;
	}
	xmlDoc.load("tajpopup.xml");
	
}

function createTable(val)
{
	var x = xmlDoc.getElementsByTagName('event');
	var dtcheckin = currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "/" + currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value + "/" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value
	var dtcheckout = currform.cmbDepartMonth.options[currform.cmbDepartMonth.selectedIndex].value + "/" + currform.cmbDepartDay.options[currform.cmbDepartDay.selectedIndex].value + "/" + currform.cmbDepartYear.options[currform.cmbDepartYear.selectedIndex].value
	var HotelId = document.getElementById('hid_hotel').value;
	var dataarray = new Array();
	var k=0;
    for (i=0;i<x.length;i++)
	{
		for (j=0;j<x[i].childNodes.length;j++)
				{	
					if (x[i].childNodes[j].nodeType != 1) continue;	
					var data  = x[i].childNodes[j].firstChild.nodeValue;	
					dataarray[k]=data;
					k++;
				}
	}
	for(i=0;i<dataarray.length;i++)
	{
		if(dataarray[i]==HotelId)
			{
				var name=dataarray[i+1];
				var date1=dataarray[i+2];
				var date2=dataarray[i+3];
				var mesg=dataarray[i+4];
				var length=dataarray[i+5];
				var breadth=dataarray[i+6];
				
				if (date2 == '~')
			{
			if( Date.parse(dtcheckin) >= Date.parse (date1) || Date.parse(dtcheckout) >= Date.parse (date1))
			{
			   var url='popup.aspx?name='+name +'&mesg='+mesg+'&len='+length+'&hgt='+breadth ;
			  window.open(url,'welcome','width='+length+',height='+breadth+', menubar=0,status=yes,location=0,toolbar=0,scrollbars=0,left='+(screen.width/2-350)+',top='+(screen.height/2 - 250));
			  return;
		   }
		   
		   }
			else
			if((Date.parse (dtcheckin) >= Date.parse (date1) && Date.parse (dtcheckin) <= Date.parse (date2)) ||(Date.parse (dtcheckout) >= Date.parse (date1) && Date.parse (dtcheckout) <= Date.parse (date2)) )
			{
				
			  var url='popup.aspx?name='+name +'&mesg='+mesg+'&len='+length+'&hgt='+breadth ;
			  window.open(url,'welcome','width='+length+',height='+breadth+', menubar=0,status=yes,location=0,toolbar=0,scrollbars=0,left='+(screen.width/2-350)+',top='+(screen.height/2 - 250));
			  return;
			}
				break;
			}
			
	}

	if(val=='[object Event]') 	val=currform.strvalues.value;
	
	location.href =  "https://www.trustinternational.com/mBooker/taj/4Z?LANGUAGE=en_US&" + val;
	
	
}
	

function createMessage()
{

	var x = xmlDoc.getElementsByTagName('event');
	var dtcheckin = currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "/" + currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value + "/" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value
	var dtcheckout = currform.cmbDepartMonth.options[currform.cmbDepartMonth.selectedIndex].value + "/" + currform.cmbDepartDay.options[currform.cmbDepartDay.selectedIndex].value + "/" + currform.cmbDepartYear.options[currform.cmbDepartYear.selectedIndex].value
	var HotelId = document.getElementById('hid_hotel').value;
	for (i=0;i<x.length;i++)
	{
		
		
			if (x[i].childNodes[0].nodeType != 1) continue;
			alert(x[i].childNodes[0].firstChild.nodeValue);
			var theData = x[i].childNodes[0].firstChild.nodeValue;
			if(theData == HotelId )
			{
			var date1=x[i].childNodes[2].firstChild.nodeValue;
			var date2=x[i].childNodes[3].firstChild.nodeValue;
			alert(date1+'-'+date2);
			if (date2 == '~')
			{
			if( Date.parse(dtcheckin) >= Date.parse (date1) || Date.parse(dtcheckout) >= Date.parse (date1))
			{
			 var url='popup.aspx?name='+x[i].childNodes[1].firstChild.nodeValue +'&mesg='+x[i].childNodes[4].firstChild.nodeValue ;
			   window.open(url,'welcome','width=700,height=500, menubar=0,status=yes,location=0,toolbar=0,scrollbars=0,left='+(screen.width/2-350)+',top='+(screen.height/2 - 250));
			 return;
		   }
		   
		   }
			else
			if((Date.parse (dtcheckin) >= Date.parse (date1) && Date.parse (dtcheckin) <= Date.parse (date2)) ||(Date.parse (dtcheckout) >= Date.parse (date1) && Date.parse (dtcheckout) <= Date.parse (date2)) )
			{
				
			  var url='popup.aspx?name='+x[i].childNodes[1].firstChild.nodeValue +'&mesg='+x[i].childNodes[4].firstChild.nodeValue ;
			  window.open(url,'welcome','width=700,height=500, menubar=0,status=yes,location=0,toolbar=0,scrollbars=0,left='+(screen.width/2-350)+',top='+(screen.height/2 - 250));
			  return;
			}
			
			
			}
			
			
		
		
	}
	alert(date1);
	if (1)
	{
		location.href = "../Resevation/default.aspx?reserve=" + date1
		
		return;
	}
	
}

function GetHotelId()
{
			
			//document.Form1.hid_hotel.value = document.Form1.cmbHotels.options[document.Form1.cmbHotels.selectedIndex].value
			
}
// New hotel is selected from HotelCombo
function BindNewHotel()
{
	if(document.frmResult.cmbOtherHotels.options[document.frmResult.cmbOtherHotels.selectedIndex].value != "---- Select Hotel ----")
	{
		document.frmResult.hid_submit.value="3";
		document.frmResult.submit();
	}
}

//Availability Form showing Location and Facilities
//Finally the output can be collected from client
function getLocationResult()
{
	var disp="";
	for(i=0;i<document.frmResult.LOC.length;i++)
	{
		if (document.frmResult.LOC[i].checked == true)
		{
		   if (disp == "")
			   disp = "'" + document.frmResult.LOC[i].value + "'"
		   else
			   disp = disp + amenityDL +"'"+ document.frmResult.LOC[i].value + "'";
		}
	}
	return disp;
}

function getFacilitiesResult()
{
	var disp="";
	for(i=0;i<document.frmResult.FAC.length;i++)
	{
		if (document.frmResult.FAC[i].checked == true)
		{
		   if (disp == "")
			   disp = "'" + document.frmResult.FAC[i].value + "'";
		   else
			   disp = disp + amenityDL +"'"+ document.frmResult.FAC[i].value+"'";
		}
	}
	return disp;
}



//Availability Form showing Location and Facilities
//Finally the output can be collected from client
function getLocationAvail()
{
	var disp="";
	for(i=0;i<document.FrmAvail.LOC.length;i++)
	{
		if (document.FrmAvail.LOC[i].checked == true)
		{
		   if (disp == "")
			   disp = "'" + document.FrmAvail.LOC[i].value + "'"
		   else
			   disp = disp + amenityDL +"'"+ document.FrmAvail.LOC[i].value + "'";
		}
	}
	return disp;
}

function getFacilitiesAvail()
{
	var disp="";
	for(i=0;i<document.FrmAvail.FAC.length;i++)
	{
		if (document.FrmAvail.FAC[i].checked == true)
		{
		   if (disp == "")
			   disp = "'" + document.FrmAvail.FAC[i].value + "'";
		   else
			   disp = disp + amenityDL + "'"+ document.FrmAvail.FAC[i].value+"'";
		}
	}
	return disp;
}

// Function for collecting input and send a new request to server for displaying the hotels result
function Htlresult(numx)
{
var availcheckflag;
	if (numx==2)
	{
		var sortBy = 0;
		var selectedCountry =  document.FrmAvail.cmbCountry.options[document.FrmAvail.cmbCountry.selectedIndex].value
		if (selectedCountry == 0 || selectedCountry =="0")
		{
			alert("Select Country / Region from the above list")
			document.FrmAvail.cmbCountry.focus();
			return;
		}
		else if (selectedCountry == "INDIA")
		{
			var navURL;
			var loc=getLocationAvail();
			var fac=getFacilitiesAvail();

			var selectedCity = document.FrmAvail.cmbCity.options[document.FrmAvail.cmbCity.selectedIndex].value
			if ((selectedCity==null || selectedCity=="" || selectedCity==0 || selectedCity=="0") && loc =="" && fac=="")
			{	
				alert("Please select either one of City/Region/Location/Facilities")
				document.FrmAvail.cmbCity.focus();
				return;
			}
			if (selectedCity==null || selectedCity=="" || selectedCity==0 || selectedCity=="0")
			{
				navURL = "Result1.aspx?Country="+escape(selectedCountry)+"&Location="+getLocationAvail()+"&Facilities="+getFacilitiesAvail();
			}
			else
			{
			 selectedCity = document.FrmAvail.cmbCity.options[document.FrmAvail.cmbCity.selectedIndex].text;
			 if(selectedCity=="AGRA" || selectedCity=="CALICUT" || selectedCity=="CHIKMAGALUR" ||selectedCity=="COONOOR" || selectedCity=="JAISALMER" || selectedCity=="MADURAI" || selectedCity=="MANGALORE" || selectedCity=="NASHIK" || selectedCity=="SURAT" || selectedCity=="VADODARA" || selectedCity=="VIJAYAWADA" || selectedCity=="VISAKHAPATNAM" || selectedCity=="VARKALA" || selectedCity=="ERNAKULAM" || selectedCity=="AHMEDABAD")
			  {
			   availcheckflag=1;
			  }
			
			 //else if(selectedCity=="PANNA")
			// {
			 //window.open("Common_Inc/pashan garh.pdf");
			 //return false;
			 //}
			  else
			  {
				for (i=0;i<arrayCities.length;i++)
				{
					if (arrayCities[i] == selectedCity)
					{
						selectedCity = arrayCitiesTogether[i]
						sortBy = orderby[i];
						break;
					}
				}
				navURL = "Result1.aspx?Country="+escape(selectedCountry)+"&City="+escape(selectedCity)+"&Location="+getLocationAvail()+"&Facilities="+getFacilitiesAvail()+"&SortValue="+sortBy;
			  }
			}
			
			//Result page add hotel combo
			//Point 1 is implemented
			var selectedHotel = document.FrmAvail.cmbHotels.options[document.FrmAvail.cmbHotels.selectedIndex].value
			if (selectedHotel != "" && selectedHotel != 0 && selectedHotel != "0")
			{
			    if (selectedCity == "HYDERABAD")
			    {
			        if (selectedHotel == "HLTHFLKU"/*Taj Falaknuma*/)
			        {
			            var falaknuma = window.open('../Common_PDF/Taj-Falaknuma-Factsheet.pdf', 'FalaknumaWindow1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1');
			            return;
			        }
			    }
				//Get the hotel group name
				if(selectedHotel=="HLTJSARK" || selectedHotel=="HLTAGRTV" || selectedHotel=="HLTCJBTG" || selectedHotel=="HLTIXMTG" || selectedHotel=="HLTBLRGH" || selectedHotel=="HLTJAIRL" || selectedHotel=="HLTCCJTR" || selectedHotel=="HLTISKTR" || selectedHotel=="HLTVTZTR" || selectedHotel=="HLTIXEMH" || selectedHotel=="HLTBDQTR" || selectedHotel=="HLTSTVGH" || selectedHotel=="HLTVGAGH" || selectedHotel=="HLTBLRTG" || selectedHotel=="HLTVNSTG" || selectedHotel=="HLTTRVGR" || selectedHotel=="HLTCOKTR" || selectedHotel=="HLTAMDTR" || selectedHotel=="HLTJDHGH")
			     {
			     //var strhotel=selectedHotel.substring(2);
			     //navURL="http://www.thegatewayhotels.com/"+strhotel+"_overview.htm";
			     availcheckflag=2;
			     }	
//			     else if(selectedHotel=="HLTJLRBT" || selectedHotel=="HLTHJRPG")
//			     {
//			     fn_khajurahowindow(selectedHotel);
//			     return false;
//			     }
			     
			     else
			     {
				var strhotels = document.FrmAvail.hid_hotels.value;
				var ArrayHotel = strhotels.split("||")
				var k =1;
				for(j=0;j<ArrayHotel.length;j++)
				{
					var currhotel = ArrayHotel[j]
					var pos=currhotel.indexOf(selectedHotel)
					if (pos>0)
					{
						pos1 = currhotel.indexOf("##")
						var poscity1 = eval(currhotel.lastIndexOf(",")+1)
						var poscity2 = eval(currhotel.indexOf("#"))
						var cityname = currhotel.substr(poscity1,eval(poscity2-poscity1))						
						var groupname = currhotel.substr(pos1+2,currhotel.length-pos1)
						var hotelname = currhotel.substr(0,poscity1-1)
						/*var xtemp = document.FrmAvail.cmbHotels.options[document.FrmAvail.cmbHotels.selectedIndex].text
						if (xtemp.indexOf(",") > 0)
							var hotelname = document.FrmAvail.cmbHotels.options[document.FrmAvail.cmbHotels.selectedIndex].text
						else
							var hotelname = document.FrmAvail.cmbHotels.options[document.FrmAvail.cmbHotels.selectedIndex].text + ',' + cityname*/
						break;
						
						break;
					}
				}
				navURL = "../"+escape(groupname)+"/"+escape(hotelname)+","+escape(cityname)+"/default.htm"
				//navURL = "../"+escape(groupname)+"/"+escape(hotelname)+"/default.htm"
				}
			}
			if(availcheckflag==1)
			{
			GWHotelReadXML(selectedCity);
			window.open("http://www.thegatewayhotels.com/index.htm?hotelId="+hotelidlink+"&page=Overview");
			}
			else if(availcheckflag==2)
			{
			var strhotel=selectedHotel.substring(2);
			window.open("http://www.thegatewayhotels.com/index.htm?hotelId="+strhotel+"&page=Overview");
			}
			else
			{
			location.href = navURL
			}
		}
		else //Other than INDIA is selected
		{
			selectedCity = document.FrmAvail.cmbCity.options[document.FrmAvail.cmbCity.selectedIndex].value
			selectedHotel = document.FrmAvail.cmbHotels.options[document.FrmAvail.cmbHotels.selectedIndex].value
			selectedCountry = document.FrmAvail.cmbCountry.options[document.FrmAvail.cmbCountry.selectedIndex].value
			//if(selectedCity=="NEW YORK" && selectedHotel=="HLTNYCTP")
			//{
			//window.open("../luxury/The Pierre,New York/popup.htm","Theme","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=760,height=590,top=10,left=70");
			//window.open("../Luxury/The Pierre,New York/popup.htm","Theme","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=860,height=540,top=80,left=70");
			//window.location.href="../luxury/The Pierre,New York/popup.htm"
			//return;
			//}
			if(selectedCountry=="MAURITIUS")
			{
			fn_mauritius();
			return false;
			}
			else if(selectedCity=="MAURITIUS")
			{
			fn_mauritius();
			return false;
			}
			
			if (selectedCity==null || selectedCity=="" || selectedCity==0 || selectedCity=="0")
	    	{
	    	//if(selectedCountry=="BHUTAN")
			 //{
			//navURL="../Common_pdf/Taj-Tashi-Bhutan.pdf";
			 //}
			//else
			 //{
				navURL = "Result1.aspx?Country="+escape(selectedCountry)+"&Location="+getLocationAvail()+"&Facilities="+getFacilitiesAvail()+"&SortValue="+sortBy;
			 //}
			}
			else
			{
			    if (selectedHotel==null || selectedHotel=="" || selectedHotel==0 || selectedHotel=="0")
				{
				 //if(selectedCountry=="BHUTAN" && selectedCity=="THIMPHU")
			     //{
			     //navURL="../Common_pdf/Taj-Tashi-Bhutan.pdf";
			     //}
			     //else
			     //{
					navURL = "Result1.aspx?Country="+escape(selectedCountry)+"&City="+escape(selectedCity)+"&Location="+getLocationAvail()+"&Facilities="+getFacilitiesAvail()+"&SortValue="+sortBy;
				 //}
				}
				else
				{
					/*******************/
					//Get the hotel group name
					var strhotels = document.FrmAvail.hid_hotels.value;
					var ArrayHotel = strhotels.split("||")
					var k =1;
					for(j=0;j<ArrayHotel.length;j++)
					{
						var currhotel = ArrayHotel[j]
						var pos=currhotel.indexOf(selectedHotel)
						if (pos>0)
						{
							pos1 = currhotel.indexOf("##")
							var poscity1 = eval(currhotel.lastIndexOf(",")+1)
							var poscity2 = eval(currhotel.indexOf("#"))
							var cityname = currhotel.substr(poscity1,eval(poscity2-poscity1))
							var groupname = currhotel.substr(pos1+2,currhotel.length-pos1)
							var hotelname = currhotel.substr(0,poscity1-1)
							/*var xtemp = document.FrmAvail.cmbHotels.options[document.FrmAvail.cmbHotels.selectedIndex].text
							if (xtemp.indexOf(",") > 0)
								var hotelname = document.FrmAvail.cmbHotels.options[document.FrmAvail.cmbHotels.selectedIndex].text
							else
								var hotelname = document.FrmAvail.cmbHotels.options[document.FrmAvail.cmbHotels.selectedIndex].text + ',' + cityname*/

							//var hotelname = document.Form1.cmbHotels.options[document.Form1.cmbHotels.selectedIndex].text + ',' + cityname
							break;
						}
					}
					//if(selectedCity=="THIMPHU" && selectedHotel=="HLTPBHTT")
			          //{
		            //	navURL="../Common_pdf/Taj-Tashi-Bhutan.pdf";
			         // }
			          //else
			          //{
					navURL = "../"+escape(groupname)+"/"+escape(hotelname)+","+escape(cityname)+"/default.htm"
					//}
					//navURL = "../"+escape(groupname)+"/"+escape(hotelname)+"/default.htm"
					/****************/
				}
			}
			if(selectedHotel=="HLTMRUTE")
			{
			fn_mauritius();
			}
			else if(selectedHotel=="HLTDUBTE")
			{
			 window.open('Common_Inc/Taj Exotica Resort and Spa Dubai.pdf');
			     return;
			}
			else if(selectedHotel=="HLTMLETC")
			{
			  document.location.href="../TajGroup/Vivanta-taj-maldives-coral-reef";
			  return false;
			}
			else
			{
			location.href = navURL
			}
		}
	}
}

//Calendar functions
function invokeCal(vtype)
{
    var dtArrival;
	frmname = currform.name
	if (vtype=='ci')
	{
	 var dd=currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value
	 var mm=currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value
	 var yy=currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value
	 GoToCalendar('Cal','CHECK-IN',frmname,dd,mm,yy,dtArrival)
	}
	else if (vtype=='co')
	{
	 /*var dd=currform.cmbDepartDay.options[currform.cmbDepartDay.selectedIndex].value
	 var mm=currform.cmbDepartMonth.options[currform.cmbDepartMonth.selectedIndex].value
	 var yy=currform.cmbDepartYear.options[currform.cmbDepartYear.selectedIndex].value*/
	 var dd=currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value
	 var mm=currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value
	 var yy=currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value
	 dtArrival = mm+"-"+yy+"-"+dd
	 GoToCalendar('Cal','CHECK-OUT',frmname,dd,mm,yy,dtArrival)
	}
}
function putdate(dd,mm,yy,ctrlname)
{
	if (ctrlname == 'CHECK-IN')
	{
		//set year
				
		for(i=0;i<currform.cmbArrivalYear.options.length;i++)
		{
			if (currform.cmbArrivalYear.options[i].value ==yy){
				currform.cmbArrivalYear.options[i].selected = true;
				break;
				}
		}
		ChangeOptionMonths(ADaysObject,AMonthObject,AYearObject,'A');
		//ArrivalYearChanged();

		//set month
		for(i=0;i<currform.cmbArrivalMonth.options.length;i++)
		{
			if (currform.cmbArrivalMonth.options[i].text.slice(0,3) ==mm){
				currform.cmbArrivalMonth.options[i].selected = true;
				break;}
		}

		ChangeOptionDays(ADaysObject,AMonthObject,AYearObject,'A');
		//ArrivalMonthChanged()
		//var count=DaysinMonth(
		//set day
		for(i=0;i<currform.cmbArrivalDay.options.length;i++)
		{
			if (currform.cmbArrivalDay.options[i].value ==dd){
				currform.cmbArrivalDay.options[i].selected = true;
				break;}
		}
		AddNights2Depart();
		ArrivalDayChanged();
		
	}
	
	if (ctrlname == 'CHECK-OUT')
	{

	//set day
	for(i=0;i<currform.cmbDepartDay.options.length;i++)
	{
		if (currform.cmbDepartDay.options[i].value ==dd){
			currform.cmbDepartDay.options[i].selected = true;
			break;}
	}
	
	//set month
	for(i=0;i<currform.cmbDepartMonth.options.length;i++)
	{
		if (currform.cmbDepartMonth.options[i].text.slice(0,3) ==mm){
			currform.cmbDepartMonth.options[i].selected = true;
			break;}
	}

	//set year
	for(i=0;i<currform.cmbDepartYear.options.length;i++)
	{
		if (currform.cmbDepartYear.options[i].value ==yy){
			currform.cmbDepartYear.options[i].selected = true;
			break;}
	}
	}

	
}

/*------------------------------------------------------------
	Function will change the departure date
------------------------------------------------------------*/
function AddNights2Depart()
{
	var arrivalday = eval(currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value);
	var departlastday = eval(currform.cmbDepartDay.options[currform.cmbDepartDay.options.length-1].value);
	var nightselected = eval(currform.cmbNights.options[currform.cmbNights.selectedIndex].value);
	var departsetday = eval(arrivalday + nightselected)

	//if Departure date doesn't exceed,
	/*if (arrivalday + nightselected <= departlastday)
	{
		for(i=0;i<currform.cmbDepartDay.options.length;i++)
		{
			if ( currform.cmbDepartDay.options[i].text == departsetday)
			{
				currform.cmbDepartDay.options[i].selected = true;
				break;
			}
		}
	}
	else
	{*/
		//if exceeds
		var dtstart = new Date(currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "/" + currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value + "/" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value)	
		var dtend   = DayAdd(dtstart, nightselected)

		dd = dtend.getDate()
		mm = MonthArray[dtend.getMonth()].slice(0,3)
		yy = dtend.getFullYear();
		//alert("yy"+yy+"N"+NowYear);
		//if (yy != NowYear)
		//{
		//	currform.cmbDepartYear.options[1].selected = true;
			DepartYearChanged();
		//}
		putdate(dd,mm,yy,'CHECK-OUT')
		ChangeOptionDays(DDaysObject,DMonthObject,DYearObject,'A');
		putdate(dd,mm,yy,'CHECK-OUT')
	//}
}

function datediff2Nights()
{
	var date2 = new Date(currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "/" + currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value + "/" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value)
	var date1 = new Date(currform.cmbDepartMonth.options[currform.cmbDepartMonth.selectedIndex].value + "/" + currform.cmbDepartDay.options[currform.cmbDepartDay.selectedIndex].value + "/" + currform.cmbDepartYear.options[currform.cmbDepartYear.selectedIndex].value)
	var difference = Date.UTC(y2k(date1.getYear()),date1.getMonth(),date1.getDate(),0,0,0) - Date.UTC(y2k(date2.getYear()),date2.getMonth(),date2.getDate(),0,0,0);
	return difference/1000/60/60/24;
}

function y2k(number) {  //called in daysElapsed function if the year is NOT passed as getFullYear then Y2k will take care
	return (number < 1000) ? number + 1900 : number; 
}

function DateAdd(startDate, numDays, numMonths, numYears) {
	var returnDate = new Date(startDate.getTime());
	var yearsToAdd = numYears;
						
	var month = returnDate.getMonth() + numMonths;
	if (month > 11) {
		yearsToAdd = Math.floor((month+1)/12);
		month -= 12*yearsToAdd;
		yearsToAdd += numYears;
	}
	returnDate.setMonth(month);
	returnDate.setFullYear(returnDate.getFullYear()	+ yearsToAdd);
						
	returnDate.setTime(returnDate.getTime()+60000*60*24*numDays);
						
	return returnDate;
}
function DayAdd(startDate, numDays) {
	return DateAdd(startDate,numDays,0,0);
}

function openmywind()
{
	var x;
	x=window.open('wellington.htm')
	return;
}

function setCustom(dtstart1,nights,objform)
{
	Set2Today(objform)

	//var dtstart = new Date(currform.cmbArrivalMonth.options[currform.cmbArrivalMonth.selectedIndex].value + "/" + currform.cmbArrivalDay.options[currform.cmbArrivalDay.selectedIndex].value + "/" + currform.cmbArrivalYear.options[currform.cmbArrivalYear.selectedIndex].value)	
	//day2add = currform.cmbNights.options[currform.cmbNights.selectedIndex].value
	var dtstart = new Date(dtstart1);

	dd1 = dtstart.getDate();
	mm1 = MonthArray[dtstart.getMonth()].slice(0,3)
	yy1 = dtstart.getFullYear();
	if (yy1 != NowYear)
	{
		currform.cmbDepartYear.options[1].selected = true;
		DepartYearChanged();
	}
	putdate(dd1,mm1,yy1,'CHECK-IN')
	var dtend   = DayAdd(dtstart, nights)
	dd = dtend.getDate()
	mm = MonthArray[dtend.getMonth()].slice(0,3)
	yy = dtend.getFullYear();
	if (yy != NowYear)
	{
		currform.cmbDepartYear.options[1].selected = true;
		DepartYearChanged();
	}
	putdate(dd,mm,yy,'CHECK-OUT')
	ChangeOptionDays(DDaysObject,DMonthObject,DYearObject,'A');
	putdate(dd,mm,yy,'CHECK-OUT')
	
	for(i=0;i<currform.cmbNights.options.length;i++)
	{
		if (currform.cmbNights.options[i].value==nights)
		{
			currform.cmbNights.options[i].selected = true;
			break;
		}
	}
}

function sortresults(valstr)
{
	/******** 0 - Hotelname , 1 - City **********/
	var straction = location.href;
	var posSortby = straction.indexOf("SortValue=");
	var strnewaction = straction.substring(0,posSortby+10) + valstr
	location.href = strnewaction;
}

function sortRegionResults(valregion,valsort)
{
	location.href = laddress + '/TajHotelFinder/Result1.aspx?Country=INDIA&City=' + valregion + '&SortValue=' + valsort;
}

function capitalizer(e)
{
      if (e.indexOf(" ")>0)
      {
			var cap_holder,temp1,temp2;
			temp2="";
			cap_holder=e.split(" ")

	  for(var i=0;i<cap_holder.length;i++)
	  {
		temp1=cap_holder[i].charAt(0).toUpperCase()+cap_holder[i].substring(1).toLowerCase();
		if (temp2 == "")
			temp2=temp2 + temp1;
		else
			temp2=temp2 + " " + temp1;
	  }
  	  return temp2;
        }
        else
        {
           temp1=e.charAt(0).toUpperCase()+e.substring(1,e.length).toLowerCase();
           return temp1;
        }

}
function openNepalWindow()
{
	NepalWindow = window.open ('../resevation/Res_Currency.asp?Nepal=True', 'NepalWindow1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=400,width=842');
	NepalWindow.focus();
	return ;
}

function openMaldivesWindow()
{
	MaldivesWindow = window.open ('../resevation/Res_Currency.asp?Maldives1=true', 'MaldivesWindow1', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=400,width=842');
	MaldivesWindow.focus();
	return ;
}

//News Flash
function showNewsFlash(vfile)
{
	var mapWin = window.open(vfile,"alerter","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=760,height=400,top=200,left=125");
}

function openDelhiFlash()
{
	DelhiWindow = window.open ('../PressRoom/PressReleases/co-oct31-2005-NewsUpdate.htm');
	return ;
}

function validateROI(ea_country)
{	var tc_ROI=document.getElementById("resdiv");
	resdiv.style.visibility="hidden";
	/*
	if(ea_country.toString().toLowerCase()!="india"){
		resdiv.style.visibility="hidden";
		document.forms[0].rYes.checked=false;
		document.forms[0].rNo.checked=true;
	}
	else{
		resdiv.style.visibility="visible";
		document.forms[0].rYes.checked=false;
		document.forms[0].rNo.checked=false;
	}*/
	
}

function fn_citywindow(strid)
{
//alert(strid.substr(0,6));
//alert(parseInt(strid.length));
//alert(parseInt(strid.length)-3)
var page=(strid.substr((strid.indexOf('_')+1),(parseInt(strid.length)-(4+strid.indexOf('_')+1))));
 var wincity=window.open('http://www.thegatewayhotels.com/index.htm?hotelId='+strid.substr(0,6)+'&page='+page);
 wincity.focus();
}

function fn_cityfactswindow(strhtlid)
{
 var citywindow=window.open('http://www.thegatewayhotels.com/'+strhtlid);
 citywindow.focus();
}

function fn_khajurahowindow(htlid)
{
 if(htlid=="BNTHGR" || htlid=="HLTJLRBT")
 {
 var newwin=window.open('Common_Inc/Banjaar.pdf');
 newwin.focus();
 }
 else
 {
 var newwindow=window.open('Common_Inc/pashan garh.pdf');
 newwindow.focus();
 }
}

function fn_mauritius()
{
window.open("mauritiuspopup.html","Theme","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=680,height=230,top=230,left=170");
}

function maldivespopup()
{
var name="Taj Coral Reef Resort";
				
				
				var length="750";
				var breadth="400";
							
			  var url='https://www.yourreservation.net/ibe/02_taj/main.html?calArrivalDateField=2009-08-15&calDepartureDateField=2009-08-16&ccpSelectHotel=TJ-HLTMLETC&quick=page1';
			  window.open(url,'name');
}


function newlinkoffer(link)
{
 window.open(link);
}

function specialoffers(linkurl)
{
document.location.href=linkurl;
}
