

function check()
{
	var Minprice=parseInt(document.frm.min_price.value);
	var Maxprice=parseInt(document.frm.max_price.value);
	if(Maxprice < Minprice)
	{	
		alert("Please select the valid price range");
		return false;
	}
	var MaxSquare=parseInt(document.frm.max_sqft.value);
	var MinSquare=parseInt(document.frm.min_sqft.value);	
	
	if(MaxSquare < MinSquare)
	{
		alert("Please select the valid Square Ft range");
		return false;
	}
	
	//alert("=================");
	var Maxlot=parseFloat(document.frm.max_acreage.value);
	var Minlot=parseFloat(document.frm.min_acreage.value);
	
	if(Minlot > Maxlot)
	{
		alert("Please select the valid Lot Size range");
		return false;
	}
	
	var Maxyear=parseInt(document.frm.max_yearbuilt.value);;
	var Minyear=parseInt(document.frm.min_yearbuilt.value);;
		if(Minyear > Maxyear)
		{
			alert("Please select vaild Build year Range");
			return false;
		}

	//selectAllOptions(document.frm.city);
	//return true();	
	
}
function EditSearchValidation()
{
	var Minprice=parseInt(document.frm.min_price.value);
	var Maxprice=parseInt(document.frm.max_price.value);
	if(Maxprice < Minprice)
	{	
		alert("Please select the valid price range");
		return false;
	}
	var MaxSquare=parseInt(document.frm.max_sqft.value);
	var MinSquare=parseInt(document.frm.min_sqft.value);	
	
	if(MaxSquare < MinSquare)
	{
		alert("Please select the valid Square Ft range");
		return false;
	}
	
	//alert("=================");
	var Maxlot=parseFloat(document.frm.max_acreage.value);
	var Minlot=parseFloat(document.frm.min_acreage.value);
	
	if(Minlot > Maxlot)
	{
		alert("Please select the valid Lot Size range");
		return false;
	}
	
	var Maxyear=parseInt(document.frm.max_yearbuilt.value);;
	var Minyear=parseInt(document.frm.min_yearbuilt.value);;
		if(Minyear > Maxyear)
		{
			alert("Please select vaild Build year Range");
			return false;
		}

	selectAllOptions(document.frm.city);
	return true;
	
}

function ChangeOrderDir()
{
	var sel = document.getElementById("orderby");
	var pos = sel.selectedIndex;
	var optText = sel.options[pos].text;
	if(optText=="Price Low To High")
		document.getElementById("orderdir").value = "ASC";
	else
	if(optText=="Price High To Low")
		document.getElementById("orderdir").value = "DESC";
	else
		document.getElementById("orderdir").value = "ASC";		

	document.frm.submit();
}

function ChangeOrderDir(name)
{
	var sel = document.getElementById("orderby");
	var pos = sel.selectedIndex;
	var optText = sel.options[pos].text;
	if(optText=="Price Low To High")
		document.getElementById("orderdir").value = "ASC";
	else
	if(optText=="Price High To Low")
		document.getElementById("orderdir").value = "DESC";		
	else
		document.getElementById("orderdir").value = "ASC";		
		
	return false;	
}

function ChangeCity3(val)
{
	iepopupSelect_new();
	if(document.getElementById("ShowLoading"))
		document.getElementById("ShowLoading").style.display = "";	
	window.location.href = WWWROOT+"/idx_result.php?all=1&fieldset=0&city[0]="+val+redirectURL;
}

function ChangeCity(val)
{
	iepopupSelect_new();
	if(document.getElementById("ShowLoading"))
		document.getElementById("ShowLoading").style.display = "";	

	//window.location.href = WWWROOT+"/idx_result.php?s=1&city[]="+val+redirectURL;
	window.location.href = WWWROOT+"/idx_result.php?s=1&city%5B%5D="+val+redirectURL;
}

function GetTotalCompare(pContactId)
{
	if(pContactId!=0)
	{
		iepopupSelect_new();
		var strURL = WWWROOT + "/idx_post_IDXTotalCompare.php?cid="+pContactId;

		AjaxPostNew(strURL, 2);
	}
	else
	{
		if(document.getElementById('ShowLoading'))
			document.getElementById('ShowLoading').style.display = 'none';		
			
		iepopupDeSelect_new();						
	}
}

function AfterGettingTotalCompare(pContent)
{
	var arrVal = pContent.split('|');
	if(document.getElementById("ShowTotalComp"))
		document.getElementById("ShowTotalComp").innerHTML = arrVal[0];	
	if(document.getElementById("ShowSecTotalComp"))
		document.getElementById("ShowSecTotalComp").innerHTML = arrVal[0];	

	if(document.getElementById('ShowLoading'))
		document.getElementById('ShowLoading').style.display = 'none';
	iepopupDeSelect_new();						
}

function AddMatrixDetail(pContactId,pMLSNo,isIDX)
{
	if(document.getElementById('ShowLoading'))
		GetLoading();

	if(pContactId!=0)
	{
		//alert("The listing has been added to your Matrix.");
		var strURL = WWWROOT + "/idx_post_IDXTotalCompare.php?t=1&mls="+pMLSNo+"&isIDX="+isIDX+"&cid="+pContactId;
		AjaxPostNew(strURL, 3);
	}
}

function RemoveMatrixDetail(pContactId, pMLSNo, isIDX)
{
	if(document.getElementById('ShowLoading'))
		GetLoading();

	if(pContactId!=0)
	{
		//alert("The listing has been removed from your Matrix.");
		var strURL = WWWROOT + "/idx_post_IDXTotalCompare.php?t=2&mls="+pMLSNo+"&cid="+pContactId+"&isIDX="+isIDX;
		AjaxPostNew(strURL, 4);
	}
}

function AfterAddCompare(pContent)
{
	var arrVal = pContent.split('|');
	if(document.getElementById("ShowTotalComp"))
		document.getElementById("ShowTotalComp").innerHTML = arrVal[0];	
	if(document.getElementById("ShowSecTotalComp"))
		document.getElementById("ShowSecTotalComp").innerHTML = arrVal[0];	
	
	document.getElementById("AddToMatrix"+arrVal[1]).style.display = "none";
	document.getElementById("RemoveToMatrix"+arrVal[1]).style.display = "";	

	if(document.getElementById('ShowLoading'))
		document.getElementById('ShowLoading').style.display = 'none';
		iepopupSelect_new();
	
}

function AfterRemoveCompare(pContent)
{
	var arrVal = pContent.split('|');	
	
	if(document.getElementById("ShowTotalComp"))
		document.getElementById("ShowTotalComp").innerHTML = arrVal[0];	
	if(document.getElementById("ShowSecTotalComp"))
		document.getElementById("ShowSecTotalComp").innerHTML = arrVal[0];	
	
	document.getElementById("AddToMatrix"+arrVal[1]).style.display = "";
	document.getElementById("RemoveToMatrix"+arrVal[1]).style.display = "none";	

	if(document.getElementById('ShowLoading'))
		document.getElementById('ShowLoading').style.display = 'none';
		iepopupSelect_new();

}

function ChangeSorting(redirectURLSort, pstrOrderBy)
{
	var sel = document.getElementById("orderby");
	var pos = sel.selectedIndex;
	var optText = sel.options[pos].text;
	var strOrderDir;
	if(optText=="Price Low To High")
		strOrderDir = "ASC";
	else
	if(optText=="Price High To Low")
		strOrderDir = "DESC";
	else
		strOrderDir = "ASC";			
	
	window.location.href = WWWROOT+"/idx_result.php?fieldset=0"+redirectURLSort+"&orderby="+pstrOrderBy+"&orderdir="+strOrderDir;
}
function ChangeLocalSorting(redirectURLSort, pstrOrderBy)
{
	var sel = document.getElementById("orderby");
	var pos = sel.selectedIndex;
	var optText = sel.options[pos].text;
	var strOrderDir;
	if(optText=="Price Low To High")
		strOrderDir = "ASC";
	else
	if(optText=="Price High To Low")
		strOrderDir = "DESC";
	else
		strOrderDir = "ASC";			
	
	window.location.href = WWWROOT+"/local_listing.php?fieldset=0"+redirectURLSort+"&mode=1&orderby="+pstrOrderBy+"&orderdir="+strOrderDir;
}

function ChangeSortingAgent(redirectURLSort, pstrOrderBy)
{
	var sel = document.getElementById("orderby");
	var pos = sel.selectedIndex;
	var optText = sel.options[pos].text;
	var strOrderDir;
	if(optText=="Price Low To High")
		strOrderDir = "ASC";
	else
	if(optText=="Price High To Low")
		strOrderDir = "DESC";
	else
		strOrderDir = "ASC";			
	
	window.location.href = WWWROOT+"/idx_agentlisting.php?fieldset=0"+redirectURLSort+"&orderby="+pstrOrderBy+"&orderdir="+strOrderDir;
}

function OpenMultipleCity(pstrQueryString)
{
	iepopupSelect_new();
	popwin = popupWindow("overlay", 'idx_multicityselect.php?'+pstrQueryString, 500,380,'<b>Select Multiple Cities</b>');
	o();

}

function frmShortFormSubmit(f)
{
	//frm.action = 'apg_result.php';	
	selectAllOptions(f.city);
	
	//var d = parent.document.getElementById('overlayMain');
	//var olddiv = parent.document.getElementById('overlay');
	
	//d.removeChild(olddiv);
	//d.style.visibility = 'hidden';	
}

function RedirectToAdvanceForm()
{
	writeCookie("searchPanel","advance");
	window.location.href = WWWROOT+"/idx_search.php";
}

function WideMap(pintFlag)
{
	if(pintFlag==1)
	{
		writeCookie("showMap","yes");
		document.getElementById('frameShowMap').src = WWWROOT+'/idx/ShowMap.php?api=' + MAPKEY;				
		document.getElementById("ShowWideMapLink").style.display = 'none';
		document.getElementById("HideWideMapLink").style.display = '';			
		document.getElementById("ShowWideMap").style.display = '';							
	}
	else
	{
		writeCookie("showMap","no");		
		document.getElementById("ShowWideMapLink").style.display = '';		
		document.getElementById("HideWideMapLink").style.display = 'none';				
		document.getElementById("ShowWideMap").style.display = 'none';							
	}
}

