var openDisplay = "inline";
var closedDisplay = "none";
// expandit function

function expandPanelOnLoad(openItemID)
{
	displayOff(Page_Validators);
	expandit(openItemID);
}
function expandit(openItemID)
{
	if (openItemID == "")
	{
		return;
	}
	var userControl = "reSearchControl_";
	var openItem = userControl + openItemID;
	var closePanel1 = userControl + "commonSearchPanel";
	var closePanel2 = userControl + "zipCodeSearchPanel";
	var closePanel3 = userControl + "radiusSearchPanel";
	var closePanel4 = userControl + "hotSheetSearchPanel";
	var closePanel5 = userControl + "countySearchPanel";

	if (document.all) 
	{
		openItem = document.all[openItem];
		closePanel1= document.all [closePanel1];
		closePanel2= document.all[closePanel2];
		closePanel3= document.all[closePanel3];
		closePanel4= document.all[closePanel4];
		closePanel5= document.all[closePanel5];
	}
	
	if (!document.all && document.getElementById) 
	{
		openItem = document.getElementById(openItemID);
		closePanel1 = document.getElementById(closePanel1);
		closePanel2 = document.getElementById(closePanel2);
		closePanel3 = document.getElementById(closePanel3);
		closePanel4 = document.getElementById(closePanel4);
		closePanel5 = document.getElementById(closePanel5);
	}
	closePanel1.style.display = closedDisplay;
	closePanel2.style.display = closedDisplay;
	closePanel3.style.display = closedDisplay;
	closePanel4.style.display = closedDisplay;
	closePanel5.style.display = closedDisplay;
	openItem.style.display = openDisplay;
	document.all["reSearchControl_viewCountyDivDisplayStatusHidden"].value = (document.all["reSearchControl_countySearchPanel"].style.display == "inline")?1:0;	
	//alert(document.all["reSearchControl_viewCountyDivDisplayStatusHidden"].value);
}
//CommonSearch,ZipCodeSearch,RadiusSearch,MLSSearch,AddressSearch

function submitReviseSearch(buttonName)
{

	var goButton;
	displayOff(Page_Validators);
	if (buttonName == "CommonSearch")
	{
		Page_Validators =  new Array(document.all["reSearchControl_commonMinPriceRegularExpressionValidator"], document.all["reSearchControl_commonMaxPriceRegularExpressionValidator"]);
		goButton = 'reSearchControl:commonSearchGoButton'; 
	}
	else if (buttonName == "CountySearch")
	{
		Page_Validators =  new Array(document.all["reSearchControl_countyMinPriceRegularExpressionValidator"], document.all["reSearchControl_countyMaxPriceRegularExpressionValidator"]);
		goButton = 'reSearchControl:countySearchGoButton'; 
	}
	else if (buttonName == "ZipCodeSearch")
	{
		Page_Validators =  new Array(document.all["reSearchControl_zipZipCodeRequiredFieldValidator"], document.all["reSearchControl_zipZipCodeRegularExpressionValidator"], document.all["reSearchControl_zipMinPriceRegularExpressionValidator"], document.all["reSearchControl_zipMaxPriceRegularExpressionValidator"]);
		goButton = 'reSearchControl:zipCodeSearchGoButton'; 
	}
	else if (buttonName == "RadiusSearch")
	{
		Page_Validators =  new Array(document.all["reSearchControl_radiusStreetRequiredFieldValidator"], document.all["reSearchControl_radiusCityRequiredFieldValidator"], document.all["reSearchControl_radiusMinPriceRegularExpressionValidator"], document.all["reSearchControl_radiusMaxPriceRegularExpressionValidator"]);
		goButton = 'reSearchControl:radiusSearchGoButton'; 
	}
	
	Page_ClientValidate();
		
	if (Page_ValidationActive == true)
	{
		if (!Page_IsValid)
		{
			Page_Validators=new Array();
		}
		else
		{
			__doPostBack(goButton, '');
		}
	}
}

function displayOff(arrControl)
{
	for (i = 0; i < arrControl.length; i++)
	{
		if (arrControl[i] != null)
		{
			arrControl[i].style.display = "none";
		}
	}
	Page_Validators=new Array();
}
function toggleSpan()
{
	var listingTypeSelected = document.all["reSearchControl_listingTypesDropDownList"].selectedIndex;
	var listingTypeId = document.all["reSearchControl_listingTypesDropDownList"].options[listingTypeSelected].value;
	var residentialListingTypeId= document.all["residentialListingTypeHidden"].value;
	var residentialLeaseListingTypeId= document.all["residentialLeaseListingTypeHidden"].value;
	var residentialIncomeListingTypeId= document.all["residentialIncomeListingTypeHidden"].value;
	var mobileListingTypeId= document.all["mobileListingTypeHidden"].value;
	var landLotsListingTypeId= document.all["landLotsListingTypeHidden"].value;
	var commercialLeaseListingTypeId= document.all["commercialLeaseListingTypeHidden"].value;
	var commercialListingTypeId= document.all["commercialListingTypeHidden"].value;
	var businessOpportunityListingTypeId= document.all["businessOpportunityListingTypeHidden"].value;
	var industrialListingTypeId= document.all["industrialListingTypeHidden"].value;
	var vacantLandListingTypeId= document.all["vacantLandListingTypeHidden"].value;
	
	document.all["reSearchControl_numberOfUnitsSpan"].style.display="none";
	document.all["bedBathsSpan"].style.display="inline";
	
	if (listingTypeId == residentialIncomeListingTypeId)
	{
		document.all["reSearchControl_numberOfUnitsSpan"].style.display="inline";
	}
	else
	{
		if (listingTypeId == landLotsListingTypeId || listingTypeId == vacantLandListingTypeId)
		{
			document.all["bedBathsSpan"].style.display="none";
		}
	}
}
function resetCitiesCheckBoxList()
{
	var index = 0;
	while (document.all["reSearchControl_citiesCheckBoxList_" + index] != null)
	{
		document.all["reSearchControl_citiesCheckBoxList_" + index].checked = false;
		index++;
	}
}


function validateCityAllCheckBox()
{
	if (document.all["reSearchControl_cityAllCheckBox"].checked)
	{
		resetCitiesCheckBoxList();
	}
	else
	{
		document.all["reSearchControl_cityAllCheckBox"].checked = !this.isCitiesCheckBoxListDirty();		
	}	
}

function validateCityCheckBoxList()
{
	if (document.all["reSearchControl_cityAllCheckBox"].checked)
	{
		document.all["reSearchControl_cityAllCheckBox"].checked = false;
	}
	document.all["reSearchControl_citiesCheckBoxList"].checked = !this.isCitiesCheckBoxListDirty();
	document.all["reSearchControl_cityAllCheckBox"].checked = !this.isCitiesCheckBoxListDirty();
}

function isCitiesCheckBoxListDirty()
{
	var index = 0;

	while (document.all["reSearchControl_citiesCheckBoxList_" + index] != null)
	{
		if (document.all["reSearchControl_citiesCheckBoxList_" + index].checked)
			return true;
		index++;
	}
	return false;		
}
