var MyMenuFrame=null;
var MyMenuFrameDoc=null;

var MyMenuFrame1=null;
var MyMenuFrameDoc1=null;

function ParamsGet(){
	var url = ""
	url += "?S=" + document.getElementById("hdnStat").value
	url += "&C=" + document.getElementById("ddlCity").value
	url += "&A=" + document.getElementById("ddlArea").value
	url += "&B=" + document.getElementById("ddlBsns").value
	url += "&K=" + theKey
	url += "&T=1"			//T = This
	return url;
}

function ReQuery(){
	setCookie("FHCity", document.getElementById("ddlCity").value, "", "/")
	var url = strHostRoot + "/S.aspx" + ParamsGet()
	document.location = url
}

function SearchOptionsGet(){
	var u = strHostRoot + "/Misc/SearchParms.aspx" + ParamsGet()
	sendData("", u, "xml", "SearchOptionsSet");
}

function SearchOptionsSet(s){
	document.getElementById("divSearchOpts").innerHTML = s;
}

function GetHallInfo(){

	var strType =""
	var url = strHostRoot + "/SInfo.aspx?"
	url += "S=" + document.getElementById("hdnStat").value
	url += "&C=" + escape(document.getElementById("ddlCity").value)
	url += "&A=" + escape(document.getElementById("ddlArea").value)
	url += "&B=" + document.getElementById("ddlBsns").value

	if(document.getElementById("txtCapacity")){
		url += "&txtCapacity=" + document.getElementById("txtCapacity").value
		url += "&txtCapacity1=" + document.getElementById("txtCapacity1").value
	}
	else{
		url += "&txtCapacity="
		url += "&txtCapacity1="
	}
	
	url += "&N=" + escape(document.getElementById("txtBsnsName").value)
	url += "&BC=" + escape(document.getElementById("ddlBsns").options[document.getElementById("ddlBsns").selectedIndex].text)
	url += "&K=" + theKey
	
	for(var x in document.frmSearch.elements){

		// for some reason, some ie versions raises error when x = filters. the following try ...catch is to handle that issue
		try{
			if(document.frmSearch.elements[x]) strType = document.frmSearch.elements[x].type
		}
		catch(er){
		}
		
		if(strType == 'checkbox' && document.frmSearch.elements[x].id.indexOf("chk") == 0){
			if(document.frmSearch.elements[x].checked){
				url += "&" + document.frmSearch.elements[x].id + "=" + document.frmSearch.elements[x].value
			}
		}
		if(strType == 'select-one' && document.frmSearch.elements[x].id.indexOf("selSrvc") >= 0){
			url += "&" + document.frmSearch.elements[x].id + "=" + document.frmSearch.elements[x].value
		}
	}

	//PropGrupKey
	if(document.getElementById("hdnPropGrupKey")){
		url += "&PGK=" + document.getElementById("hdnPropGrupKey").value
	}

	//replace SearchOptions1_ with blank
	var exp = new RegExp("SearchOptions1_","g")
	url = url.replace(exp,"")

	var url1 = strHostRoot + "/Bsns/BsnsCountInfo.aspx?"
	url1 += "S=" + document.getElementById("hdnStat").value
	url1 += "&C=" + escape(document.getElementById("ddlCity").value)
	url1 += "&A=" + escape(document.getElementById("ddlArea").value)
	url1 += "&B=" + document.getElementById("ddlBsns").value
	
	MyMenuFrame.src = url;
	MyMenuFrame1.src = url1;

	//ShowMsg()
	ShowRetrieveMsg()
}


function ShowBsnsInfo(BsnsID, BsnsSubGrup, Area){
	var strType =""
	var url = strHostRoot + "/Bsns/BsnsDtls.aspx"
	url += "?S=" + document.getElementById("hdnStat").value
	url += "&C=" + document.getElementById("ddlCity").value
	url += "&A=" + escape(Area)
	url += "&B=" + BsnsSubGrup
	url += "&BI=" + BsnsID
	url += "&K=" + theKey
	//url += "&hdnViewParms=" + document.getElementById("hdnViewParms").value
	document.location = url
}


function ResetQuery(argBsns){
	ClearSearchCriteria()
	document.getElementById("ddlBsns").value = argBsns
	ReQuery()
	//GetHallInfo()
}


function ResetSearchArea(flag){
	var strType = ""
	document.getElementById("hdnViewParms").value=flag;
	
	if(flag==1){
		try{
			document.getElementById("rowProps").style.display="none"
			document.getElementById("rowServices").style.display="none"
		}
		catch (ex){}

		for(var x in document.frmSearch.elements){

			// for some reason, some ie versions raises error when x = filters. the following try ...catch is to handle that issue
			try{
				if(document.frmSearch.elements[x]) strType = document.frmSearch.elements[x].type
			}
			catch(er){
			}

			if(strType == 'checkbox' && document.frmSearch.elements[x].id.indexOf("chk") == 0){
				try{document.frmSearch.elements[x].checked = false}
				catch (ex){}
			}
			if(strType == 'select-one' && document.frmSearch.elements[x].id.indexOf("selSrvc") == 0){
				try{document.frmSearch.elements[x].selectedIndex = 0}
				catch (ex){}
			}
		}
	}
	else if(flag==2){
		try{
			document.getElementById("rowProps").style.display=""
			document.getElementById("rowServices").style.display=""
		}
		catch(ex){}
	}

	GetHallInfo()
}

function ClearSearchCriteria(){
	var strType = ""
	try{
		document.getElementById("txtCapacity").value = ""
		document.getElementById("txtCapacity1").value = ""
	}
	catch (ex){}
	document.getElementById("txtBsnsName").value = ""

	for(var x in document.frmSearch.elements){
		// for some reason, some ie versions raises error when x = filters. the following try ...catch is to handle that issue
		try{
			if(document.frmSearch.elements[x]) strType = document.frmSearch.elements[x].type
		}
		catch(er){
		}

		//if(document.frmSearch.elements[x]) strType = document.frmSearch.elements[x].type
		if(strType == 'checkbox' && document.frmSearch.elements[x].id.indexOf("chk") == 0){
			document.frmSearch.elements[x].checked = false
		}
		if(strType == 'select-one' && document.frmSearch.elements[x].id.indexOf("selSrvc") == 0){
			document.frmSearch.elements[x].selectedIndex = 0
		}
	}
}

//This function add/deletes businesses to/from the compare queue
function aa(obj, BsnsID, BsnsSubGrupID){
	if(obj.checked){
		ManageCompareList(BsnsSubGrupID,BsnsID,"ADD")
	}
	else{
		ManageCompareList(BsnsSubGrupID,BsnsID,"DEL")
	}
}

function CapacityKeyPress(e){
	var key = ""
	var name = ""
	var srcObj = ""
	
	if (navigator.appName.indexOf("Netscape") != -1){
		key = e.which;
		name = e.target.name;
		srcObj = e.target;
	} 
	else{
		key = window.event.keyCode;
		name = e.srcElement.name;
		srcObj = e.srcElement;
	}

	if(key == 13 && name == "txtBsnsName"){
		GetHallInfo()
	}


	if(key == 13 && name == "txtCapacity"){
		document.getElementById("txtCapacity1").focus();
	}

	if(key == 13 && name == "txtCapacity1"){
		GetHallInfo()
	}
}


function CompareNow(){
	if(document.getElementById("ddlBsns").value == 0){
		alert("Please select appropriate 'Service Type' when you go to Compare page.")
	}

	var url = strHostRoot + "/Bsns/BsnsCmpr.aspx"
	url += "?S=" + document.getElementById("hdnStat").value
	url += "&C=" + document.getElementById("ddlCity").value
	url += "&A=" + document.getElementById("ddlArea").value
	url += "&B=" + document.getElementById("ddlBsns").value
	url += "&BI="

	document.location = url
}

function SetPageSettings1(){
	var host1 = window.parent.document.location.toString()
	if(window.parent.document.forms[0].id.toLowerCase() != 'frmsearch' || host1.toLowerCase().indexOf(strHostRoot.toLowerCase()) != 0){
		document.getElementById("celSrchResults").innerHTML = "<br/><p align='center' class='FailureText'>Could not find parent.</p><br/>"
	}
	window.parent.MyMenuFrameDoc = document;
	window.parent.HideDiv("divMsg")
	
	//Highlight search word
	if(window.parent.document.getElementById("txtBsnsName").value != ""){
		//alert(document.getElementById("tblSearchResult").innerHTML)
		wordhighlight(document.getElementById("divSearchResult"), window.parent.document.getElementById("txtBsnsName").value)
	}
	
	//Check previously selected business checkboxes
	CheckSelectedBusinesses()
}

//For other info page
function SetPageSettings2(){
	window.parent.MyMenuFrameDoc1 = document;
}


function CompareSelected(){
	document.location = strHostRoot + "/Bsns/BsnsCmpr.aspx"
}

function ShowCalendar(BsnsID, Alias){
	MsgWndShow("", Alias + " Calendar", 124, 50, 755, 420, strHostRoot + "/Bsns/BsnsCldrInfo.aspx?BI=" + BsnsID + "&S=" + document.getElementById("hdnStat").value + "&C=" + document.getElementById("ddlCity").value)
}

function ShowBsnsImgs(BsnsID, Alias, BsnsCtgrID){
	//MsgWndShow("", Alias + " Pictures", 124, 50, 755, 530, strHostRoot + "/Misc/BsnsImgView.aspx?BI=" + BsnsID + "&BCI=" + BsnsCtgrID + "&S=" + document.getElementById("hdnStat").value + "&C=" + document.getElementById("ddlCity").value)
	MsgWndShow("", Alias + " Pictures", 180, 5, 780, 555, strHostRoot + "/Misc/BsnsImgView2.aspx?BI=" + BsnsID + "&BCI=" + BsnsCtgrID)
}
