/*
WARNING: this script file is duplicate of servicesSearch.js.
TODO: if any functionality is needed to be changed, then do it in the serviceSearch.js
		Then copy the codings from there and overwrite here.
		Then replace ucSearch word by ucCentralPane_ucSearch
NOTE: at the last, ablock for handling callback scripts from home page is written.
		That is not there in serviceSearch.js. so retain that part here.
*/

var __nonMSDOMBrowser = (window.navigator.appName.toLowerCase().indexOf('explorer') == -1);
var _strpathSightSeeing="UcSearchSightSeeing1_";

function setPagePathSIGHTSEEING(paraPath)
{
	_strpathSightSeeing=Trim(paraPath);
}

function getCountryParamsSightSeeing()
{	//--------------to on of start time for TRANFER-----------------
	//alert(document.all(_strpathSightSeeing+'ddlServices').value);
	if(document.all(_strpathSightSeeing+'ddlServices').value=="11")
	{
		//document.all('tdStartTime1').style.visibility='visible';
		//document.all('tdStartTime2').style.visibility='visible';
	}
	else
	{
		//document.all('tdStartTime1').style.visibility='hidden';
		//document.all('tdStartTime2').style.visibility='hidden';
	}
	//-------------------------------------------
	document.all('hidSeacrhFor').value='country';
	var strVal=document.all('hidSeacrhFor').value + ":SIGHTSEEING:" + document.getElementById(_strpathSightSeeing+'ddlServices').value;
	return strVal;
}

function fillCityAsAnySightSeeing()
{
	var oOption1 = document.createElement("OPTION"); 
	oOption1.text="Any"; 
	oOption1.value="-1";
	if(__nonMSDOMBrowser)
		document.getElementById(_strpathSightSeeing+'ddlCities').add(oOption1,null); 				
	else
		document.getElementById(_strpathSightSeeing+'ddlCities').add(oOption1); 				
}

function fillCountriesSightSeeing(paraCountryDet)
{ 
	var arrDiv=paraCountryDet.split('*');
	//-----------set corresponding cities-----------------
	document.getElementById(_strpathSightSeeing+'ddlCities').innerHTML="";
	if(arrDiv.length>1)
	{
		if(arrDiv[1].length==0)
		{//in case of empty
			fillCityAsAnySightSeeing();
		}
		else
		{
			getCitiesNewSightSeeing(arrDiv[1],null); //all cities
		}
	}
	else
	{ //means, there is no city
		fillCityAsAnySightSeeing();
	}
	//----------------------------------------------------
	
	var arrCityItems = arrDiv[0].split('|');
	document.getElementById(_strpathSightSeeing+'ddlCountries').innerHTML="";
	//var prevCyXid=document.all(_strpathSightSeeing+'hidPrevCity').value;
	var index=-1;
	for (cntr = 0;cntr < arrCityItems.length; cntr++)
	{
		index=index+1;
		var arrCityIndvItem=arrCityItems[cntr].split(':');
		if(arrCityIndvItem[0].length>0)
		{
			var oOption = document.createElement("OPTION"); 
			oOption.text=arrCityIndvItem[1]; 
			oOption.value=arrCityIndvItem[0];
			if(__nonMSDOMBrowser)
				document.getElementById(_strpathSightSeeing+'ddlCountries').add(oOption,null); 				
			else
				document.getElementById(_strpathSightSeeing+'ddlCountries').add(oOption); 				
		}
		else
		{//no countries found
			var oOption = document.createElement("OPTION"); 
			oOption.text="Any"; 
			oOption.value="-1";
			if(__nonMSDOMBrowser)
				document.getElementById(_strpathSightSeeing+'ddlCountries').add(oOption,null); 				
			else
				document.getElementById(_strpathSightSeeing+'ddlCountries').add(oOption);
		}
	}
	if(index>-1)
		document.getElementById(_strpathSightSeeing+'ddlCountries').selectedIndex=0;
	else
		{//no countries found
			var oOption = document.createElement("OPTION"); 
			oOption.text="Any"; 
			oOption.value="-1";
			if(__nonMSDOMBrowser)
				document.getElementById(_strpathSightSeeing+'ddlCountries').add(oOption,null); 				
			else
				document.getElementById(_strpathSightSeeing+'ddlCountries').add(oOption);
			document.getElementById(_strpathSightSeeing+'ddlCountries').selectedIndex=0;
		}
	
}	


function getCityParamsNewSightSeeing()
{
	document.all('hidSeacrhFor').value='city';	
	var strMenuItemType;
	strMenuItemType="SIGHTSEEING"
	//'CITY':'services':countryxid:propertyxid
	var strVal=document.all('hidSeacrhFor').value + ":" + strMenuItemType + ":" + document.getElementById(_strpathSightSeeing+'ddlCountries').value + ":" + document.getElementById(_strpathSightSeeing+'ddlServices').value;
	return strVal;
}

function getCitiesNewSightSeeing(strCityDet,cont)
{
	var arrCityItems = strCityDet.split('|');
	document.getElementById(_strpathSightSeeing+'ddlCities').innerHTML="";

	//var prevCityXid=document.all(_strpathSightSeeing+'hidPrevCity').value;
	//var oOptionToSelect;
	var index=-1;
	for (cntr = 0;cntr < arrCityItems.length; cntr++)
	{
		index=index+1;
		var arrCityIndvItem=arrCityItems[cntr].split(':');
		if(arrCityIndvItem[0].length>0)
		{
			var oOption = document.createElement("OPTION"); 
			oOption.text=arrCityIndvItem[1]; 
			oOption.value=arrCityIndvItem[0];
			if(__nonMSDOMBrowser)
				document.getElementById(_strpathSightSeeing+'ddlCities').add(oOption,null); 				
			else
				document.getElementById(_strpathSightSeeing+'ddlCities').add(oOption); 				
		}
		else
		{
			fillCityAsAnySightSeeing();
		}
	}
	if(index>-1)
	{
		document.getElementById(_strpathSightSeeing+'ddlCities').selectedIndex=0;
	}
}	

//=========================end new




//=======================================restore previous settings==========================================
function restorePreviousSightSeeing()
{ 
	//--------------to on of start time for TRANFER-----------------
	if(document.all(_strpathSightSeeing+'ddlServices').value=="11")
	{
		document.all('tdStartTime1').style.visibility='visible';
		document.all('tdStartTime2').style.visibility='visible';
	}
	else
	{
		document.all('tdStartTime1').style.visibility='hidden';
		document.all('tdStartTime2').style.visibility='hidden';
	}
	//-------------------------------------------
	
	if(document.all('hidCurProperty').value.length>0)
	{
		document.getElementById(_strpathSightSeeing+'ddlServices').value=document.all('hidCurProperty').value;
		WebForm_DoAsyncCallback('frmDefault',getPreviousCountryParamsSightSeeing(),fillPreviousCountriesSightSeeing,"",errorCitySightSeeing);
	}
}

function getPreviousCountryParamsSightSeeing()
{
	document.all('hidSeacrhFor').value='country';
	var strVal=document.all('hidSeacrhFor').value + ":SIGHTSEEING:" + document.getElementById(_strpathSightSeeing+'ddlServices').value + "|" + document.all('hidCurCountry').value;
	return strVal;
}

function restoreCountrySightSeeing()
{ 
	//=======================restore the country=======================
	if(document.all('hidCurCountry').value.length>0)
	{
		document.getElementById(_strpathSightSeeing+'ddlCountries')=document.all('hidCurCountry').value;
	}
}

function fillPreviousCountriesSightSeeing(paraCountryDet)
{
	var arrDiv=paraCountryDet.split('*');
	//-----------set corresponding cities-----------------
	document.getElementById(_strpathSightSeeing+'ddlCities').innerHTML="";
	if(arrDiv.length>1)
	{
		if(arrDiv[1].length==0)
		{//in case of empty
			fillCityAsAnySightSeeing();
		}
		else
		{
			getPreviousCitiesNewSightSeeing(arrDiv[1],null); //all cities
		}
	}
	else
	{ //means, there is no city
		fillCityAsAnySightSeeing();
	}
	//----------------------------------------------------
	
	var arrCityItems = arrDiv[0].split('|');
	document.getElementById(_strpathSightSeeing+'ddlCountries').innerHTML="";
	var index=-1;
	for (cntr = 0;cntr < arrCityItems.length; cntr++)
	{
		index=index+1;
		var arrCityIndvItem=arrCityItems[cntr].split(':');
		if(arrCityIndvItem[0].length>0)
		{
			var oOption = document.createElement("OPTION"); 
			oOption.text=arrCityIndvItem[1]; 
			oOption.value=arrCityIndvItem[0];
			if(__nonMSDOMBrowser)
				document.getElementById(_strpathSightSeeing+'ddlCountries').add(oOption,null); 				
			else
				document.getElementById(_strpathSightSeeing+'ddlCountries').add(oOption); 				
		}
		else
		{//no countries found
			var oOption = document.createElement("OPTION"); 
			oOption.text="Any"; 
			oOption.value="-1";
			if(__nonMSDOMBrowser)
				document.getElementById(_strpathSightSeeing+'ddlCountries').add(oOption,null); 				
			else
				document.getElementById(_strpathSightSeeing+'ddlCountries').add(oOption);
		}
	}
	if(index>-1)
		document.getElementById(_strpathSightSeeing+'ddlCountries').value=document.all('hidCurCountry').value;
	else
		{//no countries found
			var oOption = document.createElement("OPTION"); 
			oOption.text="Any"; 
			oOption.value="-1";
			if(__nonMSDOMBrowser)
				document.getElementById(_strpathSightSeeing+'ddlCountries').add(oOption,null); 				
			else
				document.getElementById(_strpathSightSeeing+'ddlCountries').add(oOption);
		}
}	

function getPreviousCitiesNewSightSeeing(strCityDet,cont)
{
	var arrCityItems = strCityDet.split('|');
	document.getElementById(_strpathSightSeeing+'ddlCities').innerHTML="";

	var index=-1;
	for (cntr = 0;cntr < arrCityItems.length; cntr++)
	{
		index=index+1;
		var arrCityIndvItem=arrCityItems[cntr].split(':');
		if(arrCityIndvItem[0].length>0)
		{
			var oOption = document.createElement("OPTION"); 
			oOption.text=arrCityIndvItem[1]; 
			oOption.value=arrCityIndvItem[0];
			if(__nonMSDOMBrowser)
				document.getElementById(_strpathSightSeeing+'ddlCities').add(oOption,null); 				
			else
				document.getElementById(_strpathSightSeeing+'ddlCities').add(oOption); 				
		}
		else
		{
			fillCityAsAnySightSeeing();
		}
	}
	if(index>-1)
	{
		document.getElementById(_strpathSightSeeing+'ddlCities').value=document.all('hidCurCity').value;
	}
}	
//=======================================end new addition======================================









function getCityParamsSightSeeing()
{
	//alert("DDDDDDDDDD")

	document.all('hidSeacrhFor').value='city';	
	var strMenuItemType;
	
	if (document.all('hidMenuItemId').value=='')
	{
		strMenuItemType="SIGHTSEEING"
		//strMenuItemType="accom"
	}
	else
	{
		strMenuItemType=document.all('hidMenuItemId').value
	}
	//alert(strMenuItemType)
	var strVal=document.all('hidSeacrhFor').value + ":" + strMenuItemType + ":" + document.getElementById(_strpathSightSeeing+'ddlCountries').value
	//alert(strVal)
	return strVal;
}

function getPropertyParamsSightSeeing()
{
	document.all('hidSeacrhFor').value='property';
	var strVal=document.all('hidSeacrhFor').value + ":" + document.getElementById(_strpathSightSeeing+'ddlCountries').value + ":" + document.getElementById(_strpathSightSeeing+'ddlCities').value
	//alert(strVal);
	return strVal;
}

function getCitiesSightSeeing(strCityDet,cont)
{
//alert("eeeeeeeeeeee");
	//alert(strCityDet);
	var arrDiv=strCityDet.split('*');	
	getPropertiesSightSeeing(arrDiv[1],'null');
	
	var arrCityItems = arrDiv[0].split(',');
	document.getElementById(_strpathSightSeeing+'ddlCities').innerHTML="";
	//alert(prevCityXid);
	//var oOption = document.createElement("OPTION"); 
	//oOption.text="any"; 
	//oOption.value=-1; 
	//document.getElementById(_strpathSightSeeing+'ddlCities').add(oOption); 
	var prevCityXid=document.all(_strpathSightSeeing+'hidPrevCity').value;
	var oOptionToSelect;
	var index=-1;
	for (cntr = 0;cntr < arrCityItems.length; cntr++)
	{
		var arrCityIndvItem=arrCityItems[cntr].split(':');
		if(arrCityIndvItem[0].length>0)
		{
			var oOption = document.createElement("OPTION"); 
			oOption.text=arrCityIndvItem[1]; 
			oOption.value=arrCityIndvItem[0];
			if(prevCityXid==oOption.value)
			{
				//oOptionToSelect=oOption;
				//oOption.selected = true;
				index=cntr;
			}
			if(__nonMSDOMBrowser)
				document.getElementById(_strpathSightSeeing+'ddlCities').add(oOption,null); 				
			else
				document.getElementById(_strpathSightSeeing+'ddlCities').add(oOption); 				
		}
	}
	if(index>-1)
	{
		if(document.getElementById(_strpathSightSeeing+'ddlCities').selectedIndex!=index)
		{
			document.getElementById(_strpathSightSeeing+'ddlCities').selectedIndex=index;
			//document.getElementById(_strpathSightSeeing+'ddlCities').onchangeSightSeeing();
		}
	}
}	

function getPropertiesSightSeeing(strPropertyTypes,cont)
{
	//alert(strPropertyTypes);
	//alert(cont);
	
	if (cont=="null")
	{
		var arrCityItems = strPropertyTypes.split(',');
	}	
	else
	{
		var arrDiv=strPropertyTypes.split('*');	
		var arrCityItems = arrDiv[0].split(',');	
	}
	
	document.getElementById(_strpathSightSeeing+'ddlServices').innerHTML="";
	/*alert(arrCityItems[0]);
	if(arrCityItems.length==0)
	{
	var oOption = document.createElement("OPTION"); 
	oOption.text="any"; 
	oOption.value=-1; 
	document.getElementById(_strpathSightSeeing+'ddlServices').add(oOption); 
	}
	*/
	for (cntr = 0;cntr < arrCityItems.length; cntr++)
	{
		var arrCityIndvItem=arrCityItems[cntr].split(':');
		//alert(arrCityIndvItem[0]);
		if(arrCityIndvItem[0].length>0)
		{
		var oOption = document.createElement("OPTION"); 
		oOption.text=arrCityIndvItem[1]; 
		oOption.value=arrCityIndvItem[0]; 
		if(__nonMSDOMBrowser)
				document.getElementById(_strpathSightSeeing+'ddlServices').add(oOption,null);
		else
			document.getElementById(_strpathSightSeeing+'ddlServices').add(oOption);	
		}
	}
}

function errorCitySightSeeing(res,cont)
{
	alert(res);
}

function showpickdropSightSeeing()
{
	//Modified on 17-Sept-2005, ucCentralPane_ucSearch_ddlServices was serviceType
	if (document.frmDefault.ucCentralPane_ucSearch_ddlServices.value==11)
	{
		//alert(document.frmsearch.serviceType.value);	
		document.all.divPick.style.visibility='visible'
	}
	else
	{
	//alert(document.frmsearch.serviceType.value);
		document.all.divPick.style.visibility='hidden'
	}
}

function onValidateBasicSIGHTSEEINGServices()
{
	if (document.all(_strpathSightSeeing+'ddlStartTime').value=='-1')
	{
		alert('Select a Start Time');
		return false;
	}
	if (document.all(_strpathSightSeeing+'ddlEndTime').value=='-1')
	{
		alert('Select a End Time');
		return false;
	}
	return onValidateBasicSightSeeing();
}

function onValidateBasicSightSeeing()
	{
		if (document.all(_strpathSightSeeing+'txtCheckInDt').value=='')
		{
			alert('Enter check in date');
			//document.all(_strpathSightSeeing+'txtCheckInDt').focus();
			return false;
		}
		if (document.all(_strpathSightSeeing+'ddlCities').value=='')
		{
			alert('Select a City');
			//document.all(_strpathSightSeeing+'txtCheckInDt').focus();
			return false;
		}
		if (document.all(_strpathSightSeeing+'ddlServices').value=='')
		{
			alert('Select a service type');
			//document.all(_strpathSightSeeing+'txtCheckInDt').focus();
			return false;
		}
		if(document.getElementById(_strpathSightSeeing+'ddlServices').value=="11") //transfer
		{
			if(document.getElementById(_strpathSightSeeing+'ddlStartTime').value=="-1")
			{
				alert("Select a start time");
				return false;
			}
		}
		
		startDate=document.all(_strpathSightSeeing+'txtCheckInDt').value.split("/")
		startDateDay = startDate[0];
		startDateMon = startDate[1];
		startDateYear = startDate[2];
		startDateFinal=new Date(startDateMon + "/" + startDateDay  + "/" + startDateYear)
		
		//---------checkindate should be 3 days greater than today's date
		//hidCurDate is curdate+3 days
		varstrCurDate=document.all(_strpathSightSeeing+'hidCurDate').value;
		var curDate=new Date(varstrCurDate);
		if(startDateFinal<=curDate)
		{
			alert('Arrival Date must be at least 3 days from the current date!');
			return false;
		}
		//=============================================================
		//alert(startDateFinal)
		document.getElementById(_strpathSightSeeing+'hidCountry').value=document.getElementById(_strpathSightSeeing+'ddlCountries').value
		document.getElementById(_strpathSightSeeing+'hidCityXid').value=document.getElementById(_strpathSightSeeing+'ddlCities').value
		document.getElementById(_strpathSightSeeing+'hidPropertyXid').value=document.getElementById(_strpathSightSeeing+'ddlServices').value
		document.all(_strpathSightSeeing+'hidPrevCity').value=document.getElementById(_strpathSightSeeing+'ddlCities').value;
		//alert(document.getElementById(_strpathSightSeeing+'ddlCities').value);
		//=======================for restore values =================================================
		document.all('hidCurProperty').value=document.getElementById(_strpathSightSeeing+'ddlServices').value;
		document.all('hidCurCountry').value=document.getElementById(_strpathSightSeeing+'ddlCountries').value;
		document.all('hidCurCity').value=document.getElementById(_strpathSightSeeing+'ddlCities').value;
		//========================end new addition on 6-dec-2005======================================
		//================
		//document.all(_strpathSightSeeing+'Panel1').style.display='none';
		VisibleAnimation();
		//================
		return true;
	}

//*************************************************SEARCH SCRIPT HANDLING FROM HOME PAGE*************************
//*********************************************ADDED BY IRABANTA ON 15-DEC-2005*********************************
//=======================new additions on 13-dec-2005 for home search result
function validateServiceSearchSightSeeing()
{
	if(onValidateBasicSightSeeing()==false)
		return false;
	else
		return ExtractServiceSearchParamsSightSeeing();
}

function ExtractServiceSearchParamsSightSeeing()
{
			 /*1. arrival date
			 * 2. dept date
			 * 3. countryxid
			 * 4. cityxid
			 * 5. propertyxid
			 * 6. top
			 * 7. Expensive
			 * 8. ServiceName
			 * 9. StartTime
			 * 10. EndTime
			 * 11. WhatType
			 * 11. active curr xid. (not to use here)
			 */
	var strArrivalDate=document.all(_strpathSightSeeing+'txtCheckInDt').value;
	var strDeptDate=document.all(_strpathSightSeeing+'txtCheckInDt').value;
	var strCountryXid=document.getElementById(_strpathSightSeeing+'hidCountry').value;
	var strCityXid=document.getElementById(_strpathSightSeeing+'hidCityXid').value;
	var strPropertyXid=document.getElementById(_strpathSightSeeing+'hidPropertyXid').value;
	var strTOP=document.all(_strpathSightSeeing+'cmbShowTopBasic').value;
	var strExp=document.all(_strpathSightSeeing+'cmbShowByExpBasic').value;
	var strServiceName=document.all(_strpathSightSeeing+'txtServiceName').value;
	var strStartTime=document.all(_strpathSightSeeing+'ddlStartTime').value;
	var strEndTime=document.all(_strpathSightSeeing+'ddlEndTime').value;
	var strWhatType="SERVICE";
	var curxid=document.all('hidActiveCurrency').value;
	//--------------------------------------------------------
	var strResult=strArrivalDate+"|"+strDeptDate+"|"+strCountryXid+"|"+strCityXid+"|"+strPropertyXid+"|"+strTOP+"|"+strExp+"|"+strServiceName+"|"+strStartTime+"|"+strEndTime+"|"+strWhatType+"|"+curxid;
	//alert(strResult);
	return strResult;	
}

function displayServiceSearchResultSightSeeing(paraResult, cont)
{
	document.all('divSearchResult').style.display='block';
	document.all('divSearchResult').innerHTML=paraResult;
	document.all('divProcessing').style.display='none';
}
function gotoBackSightSeeing()
{
	document.all('divSearchResult').style.display='none';
	document.all(_strpathSightSeeing+'divSearch').style.display='block';
}

