//set todays date
Now = new Date();
NowDay = Now.getDate();
NowMonth = eval(Now.getMonth());
NowYear = Now.getYear();

//Business rule for making reservation
var makeReservationBefore=NowDay+1;
var numberOfDaysAllowed2Stay =30;
var startDateValidity = 365

//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

//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
-----------------------------------------------------------------*/
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;
}

////ReadXML////
var ldGWXML;
var hotelidlink;
function GWHotelIdReadXML(ctyid)
{
if( window.ActiveXObject && /Win/.test(navigator.userAgent) )
	{ 
		ldGWXML = new ActiveXObject("Msxml.DOMDocument"); 
		ldGWXML.async = false; 
		ldGWXML.onreadystatechange = function () 
		{ 
		    if (ldGWXML.readyState == 4) ManpGWIdXML(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) 
		{ 
			ManpGWIdXML(ctyid);
		} 
	} 
	else 
	{ 
		alert("Your browser can\'t handle this script"); 
		return; 
	} 
}

function ManpGWIdXML(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;
}
}
}
} 

var loadduplXML;
var duplhotelid;
function GWHotelDuplIdReadXML(duplid)
{
if( window.ActiveXObject && /Win/.test(navigator.userAgent) )
	{ 
		loadduplXML = new ActiveXObject("Msxml.DOMDocument"); 
		loadduplXML.async = false; 
		loadduplXML.onreadystatechange = function () 
		{ 
		    if (loadduplXML.readyState == 4) ManpduplIdXML(duplid); 
		} 
		loadduplXML.load("Common_Inc/GatewayHotelId.xml"); 
	} 
	else if( document.implementation && document.implementation.createDocument ) 
	{ 
		loadduplXML = document.implementation.createDocument("","",null); 
		loadduplXML.async=false; 
		var loaded = loadduplXML.load("Common_Inc/GatewayHotelId.xml"); 
		moz=1;
		if (loaded) 
		{ 
			ManpduplIdXML(duplid); 
		} 
	} 
	else 
	{ 
		alert("Your browser can\'t handle this script"); 
		return; 
	} 
}

function ManpduplIdXML(gwdpID)
{
strTitleId = loadduplXML.getElementsByTagName("HotelId")[0]; 
if(strTitleId.getElementsByTagName('HotelNameId').length>0)
{
for(var i=0; i<strTitleId.getElementsByTagName('HotelNameId').length; i++) 
{
if(strTitleId.getElementsByTagName('HotelNameId')[i].getAttribute("DUPLID")==gwdpID)
{
var link=strTitleId.getElementsByTagName('HotelNameId')[i].getAttribute("Id");
duplhotelid=link;
}
}
}
}
////

/*-----------------------------------------------------------------
	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 += 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
  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 = 0;
		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)
	MonthObject[Month-1].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;}
			}		
	}
	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;
	}
	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;
	}
	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.")
			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;
}

function setAdultsAndKids()
{
	var nrooms = eval(currform.cmbRooms.options[currform.cmbRooms.selectedIndex].value)
	var nAdults = 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] = "COLOMBO"
		ArrayCity1[2] = "MALDIVES"
		ArrayCity1[3] = "MAURITIUS"
		//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++)
		{
			document.Form1.cmbCity.options[k] = new Option(GetCityName(ArrayCity1[j]),ArrayCity1[j]);
			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];
			for(i=0;i<ArrayCountryCity.length;i++)
			{
				if (ArrayCountryCity[i]==cc)
				{
					document.Form1.cmbCity.options[k] = new Option(GetCityName(ArrayCity[i]),ArrayCity[i]);
					k+=1;
				}
			}
		}
	}
	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];
			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;
				}
			}
		}
	}
	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];
			for(i=0;i<ArrayCountryCity.length;i++)
			{
				if (ArrayCountryCity[i]==cc)
				{
					document.FrmAvail.cmbCity.options[k] = new Option(GetCityName(ArrayCity[i]),ArrayCity[i]);
					k+=1;
				}
			}
		}
	}
	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'
	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);
					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 == 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.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]='MAURITIUS'

	//Add hotelnames for KERALA,RAJASTHAN vvv
	if (selectedCitytxt == 'KERALA' || selectedCitytxt == 'RAJASTHAN' || selectedCitytxt == 'MAURITIUS')
	{
	    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]=="H00018" || temprec[1]=="H00019" ||temprec[1]=="H00056" ||temprec[1]=="H00057" ||temprec[1]=="H00038" ||temprec[1]=="H00032" || temprec[1]=="H00101")
            {
            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]);
			}
			//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
	{
	ArrayHotel.sort();
		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'
	arrayRegionCities[1]='Jaipur~Jaisalmer~Udaipur~Sawai Madhopur~Jodhpur'
	arrayRegionCities[2]='Wolmar~dummy'

	//Add hotelnames for KERALA,RAJASTHAN vvv
	if (selectedCitytxt == 'KERALA' || selectedCitytxt == 'RAJASTHAN' ||  selectedCitytxt == 'MAURITIUS')
	{
	    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 hotelname = currhotel.substr(0,pos1);
					var cityname = currhotel.substr(poscomma+1,pos1-1-poscomma);
					//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('~');
			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)
{
alert(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;
	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
			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
			{
				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")
			{
				//Get the hotel group name
				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)+","+escape(cityname)+"/default.htm"
			}
			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
			if (selectedCity==null || selectedCity=="" || selectedCity==0 || selectedCity=="0")
				navURL = "Result1.aspx?Country="+escape(selectedCountry)+"&Location="+getLocation()+"&Facilities="+getFacilities()+"&SortValue="+sortBy;
			else
			{
			    if (selectedHotel==null || selectedHotel=="" || selectedHotel==0 || selectedHotel=="0")
					navURL = "Result1.aspx?Country="+escape(selectedCountry)+"&City="+escape(selectedCity)+"&Location="+getLocation()+"&Facilities="+getFacilities()+"&SortValue="+sortBy;
				else
				{
					/*******************/
					//Get the hotel group name
					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;
						}
					}
					navURL = "../"+escape(groupname)+"/"+escape(hotelname)+","+escape(cityname)+"/default.htm"
					
					/****************/
				}
			}
			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 if (selectedCountry == "INDIA" || selectedCountry == "INDIAN OCEAN")
		{
			var selectedCity = document.Form1.cmbCity.options[document.Form1.cmbCity.selectedIndex].value
			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";
			}
		}
		else 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"			
			}
		}
		
		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 == "INDIA")
				resOption= "Y"
				else
				resOption="N";
			
		document.Form1.hid_location.value = getLocation()
		document.Form1.hid_facilities.value = getFacilities()
		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
		var selectedHotelName = document.Form1.cmbHotels.options[document.Form1.cmbHotels.selectedIndex].text
		if (selectedHotel==null || selectedHotel=="" || selectedHotel==0 || selectedHotel=="0")
			var	strvalues = "select" + "|" + selectedCountry + "|" + selectedCity  + "|" + dtcheckin + "|" + dtcheckout + "|" + rooms + "|" + adults + "|" + children + "|" + resOption
		else
			var	strvalues = selectedHotel + "|" + selectedCountry + "|" + selectedCity  + "|" + dtcheckin + "|" + dtcheckout + "|" + rooms + "|" + adults + "|" + children + "|" + resOption

        /*if (selectedHotel == "H00033")  //Maldives, Taj Exotica Resort & Spa is disabled from reservation
        {
			openMaldivesWindow()
        }
        else
        {*/
        //importXML(strvalues);
        
	if(currform.hid_hotel.value == 'H00028')
			{
				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 December 15, 2008. 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 = "../resevation/default.aspx?reserve=" + strvalues
			location.href = reDirectUrl 
	 
	}
}


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)
{
debugger;
var strflag;
	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")
			  {
			  strflag=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
			var selectedHotelName=document.frmResult.cmbHotels.options[document.frmResult.cmbHotels.selectedIndex].text;
			if (selectedHotel != "" && selectedHotel != 0 && selectedHotel != "0")
			{
			    debugger;
			    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
				//Get the hotel group name
				if(selectedHotel=="H00066" || selectedHotel=="H00007" || selectedHotel=="H00056" || selectedHotel=="H00035" || selectedHotel=="H00039" || selectedHotel=="H00034" || selectedHotel=="H00019" || selectedHotel=="H00040" || selectedHotel=="H00015" || selectedHotel=="H00052" || selectedHotel=="H00085" || selectedHotel=="H00053" || selectedHotel=="H00090" || selectedHotel=="H00054" || selectedHotel=="H00057" || selectedHotel=="H00038" || selectedHotel=="H00018" || selectedHotel=="H00063" || selectedHotel=="H00101")
			    {
			     strflag=2;
			    }
			    else if(selectedHotelName.indexOf("Vivanta")!=-1)
			     {
			     strflag=3;
			     
			     }
			    //else if(selectedHotel=="H00098")
			    //{
			    //window.open('Common_Inc/Taj Cape Town.pdf');
			    //return false;
			    //}
			    //else if(selectedHotel=="H00099")
			    //{
			    //window.open("Common_Inc/Taj Exotica Resort and Spa Dubai.pdf");
			    //return false;
			    //}
			    //else if(selectedHotel=="H00095")
			    //{
			    //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(strflag==1)
			{
			GWHotelIdReadXML(selectedCity);
			//window.open("http://www.thegatewayhotels.com/"+hotelidlink+"_overview.htm");
			window.open("http://www.thegatewayhotels.com/index.htm?hotelId="+hotelidlink+"&page=Overview");
			}
			else if(strflag==2)
			{
			GWHotelDuplIdReadXML(selectedHotel);
			//window.open("http://www.thegatewayhotels.com/"+duplhotelid+"_overview.htm");
			window.open("http://www.thegatewayhotels.com/index.htm?hotelId="+duplhotelid+"&page=Overview");
			}
			else if(strflag==3 && selectedHotel!=0)
			{
			  var urllink=getVivantalink(selectedHotel);
			  if(urllink!=null)
			  window.open(urllink);
			   else
			  location.href = navURL
			}
			else if(selectedHotel==0)
			{
			var urllink=getVivantalink(0,selectedCity);
			 if(urllink!=null)
			 window.open(urllink);
			  else
			  location.href = navURL
			}
			else
			{
			location.href = navURL
			}
		}
		else //Other than INDIA is selected
		{
		selectedCountry=document.frmResult.cmbCountry.options[document.frmResult.cmbCountry.selectedIndex].value
			selectedCity = document.frmResult.cmbCity.options[document.frmResult.cmbCity.selectedIndex].value
			selectedHotel = document.frmResult.cmbHotels.options[document.frmResult.cmbHotels.selectedIndex].value
			if(selectedCountry=="MAURITIUS")
			     {
			       fn_mauritius();
			       return false;
			     }
			     else if(selectedCity=="MAURITIUS")
			     {
			       fn_mauritius();
			       return false;
			     }
			
			if (selectedCity==null || selectedCity=="" || selectedCity==0 || selectedCity=="0")
				navURL = "Result1.aspx?Country="+escape(selectedCountry)+"&Location="+getLocationResult()+"&Facilities="+getFacilitiesResult()+"&SortValue="+sortBy;
			else
			{
			    if (selectedHotel==null || selectedHotel=="" || selectedHotel==0 || selectedHotel=="0")
					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;
						}
					}
					navURL = "../"+escape(groupname)+"/"+escape(hotelname)+","+escape(cityname)+"/default.htm"
					//navURL = "../"+escape(groupname)+"/"+escape(hotelname)+"/default.htm"
					/****************/
				}
			}
			if(selectedHotel=="H00032")
			     {
			       fn_mauritius();
			     }
			 
			    else if(selectedHotel=="H00099")
			    {
			    window.open("Common_Inc/Taj Exotica Resort and Spa Dubai.pdf");
			    return false;
			    }
			    else if(selectedHotel=="H00028")
			{
			  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();
	*/
	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 == '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_ctry.value == 'INDIA')
		resOption = "Y"
		else
		resOption = "N";
	var hotelid  = currform.hid_hotel.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 
	var strvalues = hotelid + "|" + escape(country) +  "|" + escape(city) + "|" + dtcheckin + "|" + dtcheckout + "|" + rooms+  "|" + +adults +  "|" +  children +  "|" + resOption;
	//importXML(strvalues);
	
	if(currform.hid_hotel.value == 'H00028')
			{
				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 December 15, 2008. 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)
	{
		location.href = "../Resevation/default.aspx?reserve=" + 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 = "../Resevation/default.aspx?reserve=" + 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)
{
	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
			{
				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")
			{
				//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*/
						break;
						
						break;
					}
				}
				navURL = "../"+escape(groupname)+"/"+escape(hotelname)+","+escape(cityname)+"/default.htm"
				//navURL = "../"+escape(groupname)+"/"+escape(hotelname)+"/default.htm"
			}
			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
			if (selectedCity==null || selectedCity=="" || selectedCity==0 || selectedCity=="0")
				navURL = "Result1.aspx?Country="+escape(selectedCountry)+"&Location="+getLocationAvail()+"&Facilities="+getFacilitiesAvail()+"&SortValue="+sortBy;
			else
			{
			    if (selectedHotel==null || selectedHotel=="" || selectedHotel==0 || selectedHotel=="0")
					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;
						}
					}
					
					navURL = "../"+escape(groupname)+"/"+escape(hotelname)+","+escape(cityname)+"/default.htm"
					//navURL = "../"+escape(groupname)+"/"+escape(hotelname)+"/default.htm"
					/****************/
				}
			}
			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;}
		}
		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');
		//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();
	}
	
	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();
		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)
{
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_mauritius()
{
window.open("mauritiuspopup.html","Theme","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=680,height=260,top=230,left=170");
}


function getVivantalink()
{

if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","Common_Inc/Vivantalink.xml",false);
xmlhttp.send();
xmlDoclink=xmlhttp.responseXML;


parentN = xmlDoclink.getElementsByTagName("Vivanta")[0]; 
if(arguments.length==1){
if(parentN.getElementsByTagName('Hotel').length>0){
for(var i=0; i<parentN.getElementsByTagName('Hotel').length; i++){
if(parentN.getElementsByTagName('Hotel')[i].getAttribute("HotelId")==arguments[0]){
var link=parentN.getElementsByTagName('Hotel')[i].getAttribute("link");
//var cityId=strTitle.getElementsByTagName('Hotel')[i].getAttribute("CityId");

return link;
   }
  }
 }
}
else
{
var c=0;
var link=null;
   if(parentN.getElementsByTagName('Hotel').length>0){
for(var i=0; i<parentN.getElementsByTagName('Hotel').length; i++){
if(parentN.getElementsByTagName('Hotel')[i].getAttribute("City").toLowerCase()==arguments[1].toLowerCase()){
c++;
link=parentN.getElementsByTagName('Hotel')[i].getAttribute("link");
//var cityId=strTitle.getElementsByTagName('Hotel')[i].getAttribute("CityId");


   }
  }
  if(c<=1)
  return link;
  else
  return null;
 }
}



}

