		
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function IsEmpty(aTextField) {

	var regexp = /^(\s)*$/

	if(regexp.test(aTextField.value)){
		return "YES";

	}else{
		return "NO";
	}

}//IsEmpty


function isValidEmail(el)
{        
		var str=el;
		var filter=/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;

		var testresults;
		if (filter.test(str))
				testresults=true;
		else 
				testresults=false;
		return (testresults);
}

function SelectAdvanceResult(numAlerts)
{
	/*if(document.getElementById("ShowLoading"))
		document.getElementById("ShowLoading").style.display = "block";		*/	
	if (typeof(iagreey) != 'undefined' && document.getElementById("iagree")) {
			if(!iagreey())
			{
				alert('You must check the License Agreement Box');
				return false;
			}
		}

	var minprice = parseInt(document.frm.min_price.value);
	var maxprice = parseInt(document.frm.max_price.value);
	
	if(numAlerts >= 3 && document.getElementById('email_alerts').checked == true)
	{
		alert("This search can't be saved as already three alerts exist in your alert list. If you want to save please first delete an alert from alert list."); 
	}

	if(maxprice<minprice)
	{
		alert("Price Range maximum value should be greater than minimum value.");
		document.frm.min_price.value="";
		document.frm.max_price.value="";
		return false;
	}
	
	var minarea=parseInt(document.frm.min_sqft.value);
	var maxarea=parseInt(document.frm.max_sqft.value);
	if(maxarea<minarea)
	{
	
		alert("Living Area maximum value should be greater than minimum value");
		document.frm.min_sqft.value="";
		document.frm.max_sqft.value="";
		return false;
		
	}	
	
	var minlot=parseInt(document.frm.min_acreage.value);
	var maxlot=parseInt(document.frm.max_acreage.value);
	
	if(maxlot<minlot)
	{
		alert("Lot Size Range maximum value should be greater than minimum value");
		document.frm.min_acreage.value="";
		document.frm.max_acreage.value="";
		return false;
	}
	var min_yearbuilt=parseInt(document.frm.min_yearbuilt.value);
	var max_yearbuilt=parseInt(document.frm.max_yearbuilt.value);
	
	if(max_yearbuilt<min_yearbuilt)
	{
		alert("Year Built maximum value should be greater than minimum value");
		document.frm.min_yearbuilt.value="";
		document.frm.max_yearbuilt.value="";
		return false;
	}

	if(document.frm.city.options.length>25)
	{
		
		//alert("Please select less then 25 cities.");
		document.frm.city.focus();
		document.getElementById("ShowLoading").style.display = "none";
		return false;
	}
	else
	{	
		if(document.frm.city.options.length>1)
			document.cookie = "content" + "=" + escape("hide");
		else
			document.cookie = "content" + "=" + escape("show");		
			
		selectAllOptions(document.frm.city);
		
		document.frm.submit();
	}	
	if(document.getElementById("ShowLoading"))
		document.getElementById("ShowLoading").style.display = "none";			
	
	return false;
}

function SelectResult(numAlerts)
{
	/*if(document.getElementById("ShowLoading"))
		document.getElementById("ShowLoading").style.display = "block";		*/
	if (typeof(iagreey) != 'undefined' && document.getElementById("iagree")) {
			if(!iagreey())
			{
				alert('You must check the License Agreement Box');
				return false;
			}
		}
	var minprice = parseInt(document.frm.min_price.value);
	var maxprice = parseInt(document.frm.max_price.value);
	
	/*if(numAlerts >= 3 && document.getElementById('email_alerts').checked == true)
	{
		//alert("This search can't be saved as already three alerts exist in your alert list. If you want to save please first delete an alert from alert list."); 

	}*/

	if(maxprice<minprice)
	{
		alert("Price Range maximum value should be greater than minimum value.");
		document.frm.min_price.value="";
		document.frm.max_price.value="";
		return false;
	}
	
	/*var minarea=parseInt(document.frm.min_sqft.value);
	var maxarea=parseInt(document.frm.max_sqft.value);
	if(maxarea<minarea)
	{
	
		alert("Living Area maximum value should be greater than minimum value");
		document.frm.min_sqft.value="";
		document.frm.max_sqft.value="";
		return false;
		
	}	
	
	var minlot=parseInt(document.frm.min_acreage.value);
	var maxlot=parseInt(document.frm.max_acreage.value);
	
	if(maxlot<minlot)
	{
		alert("Lot Size Range maximum value should be greater than minimum value");
		document.frm.min_acreage.value="";
		document.frm.max_acreage.value="";
		return false;
		}*/

	if(document.frm.city.options.length>25)
	{
		//alert("Please select less then 25 cities.");
		document.frm.city.focus();
		return false;
	}
	else
	{	
		if(document.frm.city.options.length>1)
			document.cookie = "content" + "=" + escape("hide");
		else
			document.cookie = "content" + "=" + escape("show");		

		selectAllOptions(document.frm.city);
		document.frm.submit();
	}	
	
	if(document.getElementById("ShowLoading"))
		document.getElementById("ShowLoading").style.display = "none";		
	return false;	
}

<!--FUNCTIONS FOR FAVOURITE LISTING STARTS HERE-->

	function FilterByRating(val,isIDXListing)
	{	
		var page = "idx_favourite.php";
		if(isIDXListing == 0)
			 page = "local_favourite.php";

		var strCon="";
		if(document.getElementById("chkOneStar").checked==true)
			strCon += "&o=1";
		if(document.getElementById("chkSecondStar").checked==true)
			strCon += "&w=2";
		if(document.getElementById("chkThirdStar").checked==true)
			strCon += "&r=3";
		if(document.getElementById("chkFourStar").checked==true)
			strCon += "&f=4";
		if(document.getElementById("chkFiveStar").checked==true)
			strCon += "&v=5";
				
		if(document.getElementById("Refresh").value=="Refresh")
		{
			
			if(strCon=="")
			{
				window.location.href = page+"?t=all";
				
			}
			else
			{	
				window.location.href = page+"?t=1"+strCon;		
				
			}
			return true;
		}
		return false;
	}
	
	function refreshSelectBoxRating(idSelectBox, selectedValue){
	
		removeAllOptions(document.getElementById(idSelectBox))

		addOption(document.getElementById(idSelectBox), 1, 'Low' );
		addOption(document.getElementById(idSelectBox), 2, 'Medium' );
		addOption(document.getElementById(idSelectBox), 3, 'High' );

		if(selectedValue == 1)
			document.getElementById(idSelectBox).selectedIndex = 0;
		else if(selectedValue == 2)
			document.getElementById(idSelectBox).selectedIndex = 1;
		else if(selectedValue == 3)
			document.getElementById(idSelectBox).selectedIndex = 2;
	
	}//refreshSelectBoxRating

	function removeAllOptions(idSelectBox)
	{
		var i;
		for(i=idSelectBox.options.length-1;i>=0;i--)
		{
			idSelectBox.remove(i);
		}
	}

	function addOption(selectbox, value, text )
	{
		var optn = document.createElement("OPTION");
		optn.text = text;
		optn.value = value;
	
		selectbox.options.add(optn);
	}

	function stopDisplay(idFavRecord){
	
		document.getElementById(idFavRecord).style.display = "none";
	
	}

function schedulepopupform(mlsNum,isIDX)
{

	if(isIDX==1)
	{
        popwin = popupWindow("overlay", WWWROOT + '/idx_editshowing.php?action=CreateSchedule&mlsNum='+mlsNum+'&isIDX='+isIDX+'&&cf=', 540,500,'<b>Schedule Showing </b>');
			             o();
	}
	else
	{
        popwin = popupWindow("overlay", WWWROOT + '/local_editshowing.php?action=CreateSchedule&mlsNum='+mlsNum+'&isIDX='+isIDX+'&&cf=', 540,500,'<b>Schedule Showing </b>');
			             o();
	}
}
function Confirmdelete(id,isLocal)
{

if(confirm("Are you sure you want to remove the listing"))
{
	if(isLocal==1)
		window.location="local_favourite.php?delRecFromFavListing=Y&t=all&mlsNum="+id;
	else
		window.location="idx_favourite.php?delRecFromFavListing=Y&t=all&mlsNum="+id;
}

}
function changeImage1(id,mlsid,cmpaction,isIDX)
{

	if(cmpaction=='add'){
		//if(confirm("The listing has been added to your Matrix."))
		//{
			var str="<a href='javascript:changeImage1(\""+id+"\",\""+mlsid+"\",\"remove\",\""+isIDX+"\");' class='black_text'><img id='compare' src='idx/theme1/images/remove_from_matrix.gif' alt='Remove From Matrix' title='Remove From Matrix' border='0'>	</a>";
			//alert("Listing has been added in your Compare Basket.Please Click the  Listings to Compare Link to View Your Compare Basket");
			sendRequest('idx_ajaxprocess.php?act=getCompareCount&mlsNum='+mlsid+'&isIDX='+isIDX,'idFavRecord'+mlsid);
			document.getElementById(id).innerHTML=str;	
		//}	
	}
	else	
	{
	
		//if(confirm("The listing has been removed from your Matrix."))
		//{
			var str="<a href='javascript:changeImage1(\""+id+"\",\""+mlsid+"\",\"add\",\""+isIDX+"\");' class='black_text'><img id='compare' src='idx/theme1/images/add_to_matrix.gif'	alt='Add to Matrix' title='Add to Matrix' border='0'></a>";	
			sendRequest('idx_ajaxprocess.php?act=delcmprecord&mlsNum='+mlsid+'&isIDX='+isIDX,'idFavRecord'+mlsid);	
			document.getElementById(id).innerHTML=str;			
		//}	
	}
}

function AddEditNote(mlsNum,mode,page)
{
	/* page =1 (favourites), page = 2 (detail page)  */
	myRand=parseInt(Math.random()*99999999);
   // window.open('idx_addeditnote.php?mode='+mode+'&mlsNum='+mlsNum+'&page='+page,'Note','left=200,top=200,width=550,height=350,scrollbars=1');
	popwin = popupWindow("overlay", 'idx_addeditnote.php?mode='+mode+'&mlsNum='+mlsNum+'&rand='+myRand+'&page='+page, 550,420,'<b>Note</b>');
	o();
}
function AddEditNoteonDetail(mlsNum,mode,page,isDetailPage)
{
	myRand=parseInt(Math.random()*99999999);
	/* page =1 (favourites), page = 2 (detail page)  */
	popwin = popupWindow("overlay", 'idx_addeditnote.php?mode='+mode+'&isDetailPage='+isDetailPage+'&mlsNum='+mlsNum+'&rand='+myRand+'&page='+page, 550,420,'<b>Note</b>');
	o();
}

function DeleteNote1(mlsid)
{

if(confirm("Are you sure you want to remove the note?"))
{
	AjaxPostNew('idx_ajaxprocess.php?act=delnote&mlsNum='+mlsid,6);		
//window.location="idx_favourite.php?delRecFromFavListing=Y&mlsNum="+id;
	}

}
function DeleteNote(mlsid,isDetailPage)
{

if(confirm("Are you sure you want to remove the note?"))
{

	AjaxPostNew('idx_ajaxprocess.php?act=delnote&mlsNum='+mlsid+'&isDetailPage='+isDetailPage,6);		
//window.location="idx_favourite.php?delRecFromFavListing=Y&mlsNum="+id;
	}

}

function AfterDeleteNote(pContent,mlsNum)
{
	var id = "note_"+mlsNum;
	document.getElementById(id).innerHTML=pContent;
}
<!--FUNCTIONS FOR FAVOURITE LISTING ENDS HERE-->


<!-- Start:: IDX Search Page -->

function moveToRight(mode)
{	
	//document.getElementById("ShowLoading").style.display = "block";
//setTimeout('showw()', 5000);

	to = document.frm.city.options.length;
	from = document.getElementById('PropertyList');

	var  c = 0;
	for(var i=0;i<from.options.length;i++)
	{
		var o = from.options[i];
		
		if(o.selected)
			c=c+1;
	}
	
	numoptions = to + c;

	if(numoptions > 25)
	{
		unselect = numoptions - 25;
		alert("Please select cities not more than 25. (You have selected " + unselect + " more cities).");
        document.getElementById('ShowLoading').style.display = "none";
		//document.frm.city.focus();
		return false;
	}

	rightCombo = document.getElementById('city');
	leftCombo = document.getElementById('PropertyList');

	if(mode=='selected')
	{	
	
		//setTimeout('moveSelectedOptions(leftCombo,rightCombo)', 1000);
		moveSelectedOptions(leftCombo,rightCombo);
		//rightCombo.options[rightCombo.options.length] = new Option(leftCombo.options[leftCombo.selectedIndex].value, leftCombo.options[leftCombo.selectedIndex].text);
		//leftCombo.remove(options[leftCombo.selectedIndex]);
	}
	else if(mode=='all')
	{				
		moveAllOptions(leftCombo,rightCombo);
	}
	//setTimeout('showw()', 1000);
	//document.getElementById("ShowLoading").style.display = "none";
	
}

function moveToLeft(mode)
{	
	rightCombo = document.getElementById('city');
	leftCombo = document.getElementById('PropertyList');
	if(mode=='selected')
	{	
		//setTimeout('moveSelectedOptions(rightCombo,leftCombo)', 1000);
		moveSelectedOptions(rightCombo,leftCombo);
	}
	else if(mode=='all')
	{		
		moveAllOptions(rightCombo,leftCombo);
	}
	//document.getElementById("ShowLoading").style.display = "none";	
}

/*** swap values b/w select boxes***/
function hasOptions(obj){if(obj!=null && obj.options!=null){return true;}return false;}
//function selectUnselectMatchingOptions(obj,regex,which,only){if(window.RegExp){if(which == "select"){var selected1=true;var selected2=false;}else if(which == "unselect"){var selected1=false;var selected2=true;}else{return;}var re = new RegExp(regex);if(!hasOptions(obj)){return;}for(var i=0;i<obj.options.length;i++){if(re.test(obj.options[i].text)){obj.options[i].selected = selected1;}else{if(only == true){obj.options[i].selected = selected2;}}}}}
//function selectMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,"select",false);}
//function selectOnlyMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,"select",true);}
//function unSelectMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,"unselect",false);}
function sortSelect(obj){var o = new Array();if(!hasOptions(obj)){return;}for(var i=0;i<obj.options.length;i++){o[o.length] = new Option( obj.options[i].text, obj.options[i].value, obj.options[i].defaultSelected, obj.options[i].selected) ;}if(o.length==0){return;}o = o.sort(
function(a,b){if((a.text+"") <(b.text+"")){return -1;}if((a.text+"") >(b.text+"")){return 1;}return 0;});for(var i=0;i<o.length;i++){obj.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);}}
function selectAllOptions(obj){if(!hasOptions(obj)){return;}for(var i=0;i<obj.options.length;i++){obj.options[i].selected = true;}}

function moveSelectedOptions(from,to)
{
	var content;
	content="";
	
	document.frm.hdnContent.value="";

	if(arguments.length>3)
	{
		var regex = arguments[3];
		if(regex != "")
		{
			unSelectMatchingOptions(from,regex);
		}
	}

	if(!hasOptions(from))
	{
		return;
		if(document.getElementById("ShowLoading"))
			document.getElementById("ShowLoading").style.display = "none";
	}

	var flagReject = 1;
	var countSel = 0;
	for(var i=0;i<from.options.length;i++)
	{
		var o = from.options[i];
		if(o.selected)
		{
			if(o.value=='')		
				flagReject = 0;

			countSel++;				
		}
	}
	
	var falgtoReject = 1;
	var countToSel = 0;	
	for(var k=0;k<to.options.length;k++)
	{
		var j = to.options[k];
		
		if(j.text=='-- All Cities --')
			falgtoReject = 0;
		
		countToSel++;
	}

	if(flagReject==0 && countSel>1)
	{
		alert("You cannot move the -- All Cities -- option with other cities.");
		if(document.getElementById("ShowLoading"))
			document.getElementById("ShowLoading").style.display = "none";
		return false;	
	}

	if(falgtoReject==0 && countToSel==1)
	{
		alert("You cannot move the -- All Cities -- option with other cities.");
		if(document.getElementById("ShowLoading"))
			document.getElementById("ShowLoading").style.display = "none";
		return false;	
	}
	
	if(flagReject==0 && countToSel!=0 && countSel!=from.options.length)
	{
		alert("You cannot move the -- All Cities -- option with other cities.");
		if(document.getElementById("ShowLoading"))
			document.getElementById("ShowLoading").style.display = "none";
		return false;	
	}

	for(var i=0;i<from.options.length;i++)
	{
		var o = from.options[i];
		if(o.selected)
		{
			if(!hasOptions(to))
			{
				var index = 0;
			}
			else
			{
				var index=to.options.length;
			}

			to.options[index] = new Option( o.text, o.value, false, false);
		}			
	}

	for(var i=(from.options.length-1);i>=0;i--)
	{
		var o = from.options[i];
		if(o.selected)
		{
			from.options[i] = null;
		}
	}

	if((arguments.length<3) ||(arguments[2]==true))
	{
		//sortSelect(from);
		sortSelect(to);
	}
			from.selectedIndex = -1;to.selectedIndex = -1;
			
			var len=document.frm.city.length;
		//alert(len);
	
		for(i=0;i<len;i++)
		{
			if(document.frm.city[i].value)
			{
				if(content=="")
				{
					content=document.frm.city[i].value;
				}
				else
				{
					content=content+","+document.frm.city[i].value;
				}
			}
			
			
		}

		document.frm.hdnContent.value=content;
		if(document.getElementById("ShowLoading"))
			document.getElementById("ShowLoading").style.display = "none";
}


//function copySelectedOptions(from,to){var options = new Object();if(hasOptions(to)){for(var i=0;i<to.options.length;i++){options[to.options[i].value] = to.options[i].text;}}if(!hasOptions(from)){return;}for(var i=0;i<from.options.length;i++){var o = from.options[i];if(o.selected){if(options[o.value] == null || options[o.value] == "undefined" || options[o.value]!=o.text){if(!hasOptions(to)){var index = 0;}else{var index=to.options.length;}to.options[index] = new Option( o.text, o.value, false, false);}}}if((arguments.length<3) ||(arguments[2]==true)){sortSelect(to);}from.selectedIndex = -1;to.selectedIndex = -1;}
function moveAllOptions(from,to)
{
	selectAllOptions(from);
	if(arguments.length==2)
	{
		moveSelectedOptions(from,to);
	}
	else if(arguments.length==3)
	{
		moveSelectedOptions(from,to,arguments[2]);
	}
	else if(arguments.length==4)
	{
		moveSelectedOptions(from,to,arguments[2],arguments[3]);
	}
	if(document.getElementById("ShowLoading"))
		document.getElementById("ShowLoading").style.display = "none";
}
//function copyAllOptions(from,to){selectAllOptions(from);if(arguments.length==2){copySelectedOptions(from,to);}else if(arguments.length==3){copySelectedOptions(from,to,arguments[2]);}}
function swapOptions(obj,i,j){var o = obj.options;var i_selected = o[i].selected;var j_selected = o[j].selected;var temp = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);var temp2= new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected);o[i] = temp2;o[j] = temp;o[i].selected = j_selected;o[j].selected = i_selected;}
function moveOptionUp(obj){if(!hasOptions(obj)){return;}for(i=0;i<obj.options.length;i++){if(obj.options[i].selected){if(i != 0 && !obj.options[i-1].selected){swapOptions(obj,i,i-1);obj.options[i-1].selected = true;}}}}
function moveOptionDown(obj){if(!hasOptions(obj)){return;}for(i=obj.options.length-1;i>=0;i--){if(obj.options[i].selected){if(i !=(obj.options.length-1) && ! obj.options[i+1].selected){swapOptions(obj,i,i+1);obj.options[i+1].selected = true;}}}}
function removeSelectedOptions(from){if(!hasOptions(from)){return;}if(from.type=="select-one"){from.options[from.selectedIndex] = null;}else{for(var i=(from.options.length-1);i>=0;i--){var o=from.options[i];if(o.selected){from.options[i] = null;}}}from.selectedIndex = -1;}
function removeAllOptions(from){if(!hasOptions(from)){return;}for(var i=(from.options.length-1);i>=0;i--){from.options[i] = null;}from.selectedIndex = -1;}
function addOption(obj,text,value,selected){if(obj!=null && obj.options!=null){obj.options[obj.options.length] = new Option(text, value, false, selected);}}

function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function clearlistbox(lb)
{
  for (var i=lb.options.length-1; i>=0; i--)
  {
    lb.options[i] = null;
  }
  lb.selectedIndex = -1;
}
<!-- End:: IDX Search Page -->
function RequestMoreInfoPopup(propertyid,isIDX,thisURL,phpSESSID, isIDXListing)
{
	<!-- isIDX =5 (Favourite Page) isIDX =6 (History Page) isIDX =7 (Property Detai; Page)-->
	if(isIDXListing == 1)
	{
		popwin = popupWindow("overlay", WWWROOT+'/custompages_popupform.php?type=1&id='+propertyid+'&isIDX='+isIDX+'&isIDXListing='+isIDXListing+'&cf='+thisURL+''+phpSESSID, 500,450,'<b>Request More Information</b>');
		o();
	}
	else
	{
		popwin = popupWindow("overlay", WWWROOT+'/custompages_popupform.php?type=1&id='+propertyid+'&isLocal='+isIDX+'&isIDXListing='+isIDXListing+'&cf='+thisURL+''+phpSESSID, 500,450,'<b>Request More Information</b>');
		o();
	}

}

<!-- -->
function OpenSearch(pFlag)
{
	
	if(pFlag==1)
	{	
		writeCookie("searchPanel","basic");
		document.getElementById("ShowBasicSelected").style.display = '';
		document.getElementById("ShowNewSearchBack").style.display = 'none';
		document.getElementById("ShowNewAdvanceSelected").style.display = 'none';
		document.getElementById("ShowNewAdvanceBack").style.display = '';

		document.getElementById("ShowLivingArea").style.display = 'none';
		document.getElementById("ShowLotSize").style.display = 'none';
		document.getElementById("ShowYearBuilt").style.display = 'none';
		document.getElementById("ShowPoolOne").style.display = 'none';
		document.getElementById("ShowPoolTwo").style.display = 'none';
		document.getElementById("ShowSortResult").style.display = 'none';

		document.getElementById("ShowAdvanceSearchButton").style.display = 'none';
		document.getElementById("ShowSearchButton").style.display = '';
		AjaxPostNew('idx_ajaxprocess.php?act=insertBasicSearch',9);	
	}
	else
	if(pFlag==3)
	{
		document.getElementById("ShowBasicSelected").style.display = 'none';
		document.getElementById("ShowNewSearchBack").style.display = '';
		document.getElementById("ShowNewAdvanceSelected").style.display = 'none';
		document.getElementById("ShowNewAdvanceBack").style.display = '';
	}

	else
	{
		
		writeCookie("searchPanel","advance");
		document.getElementById("ShowBasicSelected").style.display = 'none';
		document.getElementById("ShowNewSearchBack").style.display = '';
		document.getElementById("ShowNewAdvanceSelected").style.display = '';
		document.getElementById("ShowNewAdvanceBack").style.display = 'none';

		document.getElementById("ShowLivingArea").style.display = '';
		document.getElementById("ShowLotSize").style.display = '';
		document.getElementById("ShowYearBuilt").style.display = '';
		document.getElementById("ShowPoolOne").style.display = '';
		document.getElementById("ShowPoolTwo").style.display = '';
		document.getElementById("ShowSortResult").style.display = '';

		document.getElementById("ShowAdvanceSearchButton").style.display = '';
		document.getElementById("ShowSearchButton").style.display = 'none';
		AjaxPostNew('idx_ajaxprocess.php?act=insertAdvanceSearch',9);	
	}
}

function OpenSearch2(pFlag)
{	
	if(pFlag==1)
	{	
		writeCookie("searchPanel","basic");
		document.getElementById("ShowBasicSelected").style.display = '';
		document.getElementById("ShowNewSearchBack").style.display = 'none';
		document.getElementById("ShowNewAdvanceSelected").style.display = 'none';
		document.getElementById("ShowNewAdvanceBack").style.display = '';

		document.getElementById("ShowLivingArea").style.display = 'none';
		document.getElementById("ShowLotSize").style.display = 'none';
		document.getElementById("ShowYearBuilt").style.display = 'none';
		
		document.getElementById("ShowStreetName").style.display = 'none';
		document.getElementById("ShowStreetNumber").style.display = 'none';
		document.getElementById("ShowZipCode").style.display = 'none';				
		document.getElementById("ShowSubDiv").style.display = 'none';		
		
		document.getElementById("ShowPoolOne").style.display = 'none';
		document.getElementById("ShowPoolTwo").style.display = 'none';
		document.getElementById("ShowSortResult").style.display = 'none';

		document.getElementById("ShowAdvanceSearchButton").style.display = 'none';
		document.getElementById("ShowSearchButton").style.display = '';
		AjaxPostNew('idx_ajaxprocess.php?act=insertBasicSearch',9);	
	}
	else
	if(pFlag==3)
	{
		document.getElementById("ShowBasicSelected").style.display = 'none';
		document.getElementById("ShowNewSearchBack").style.display = '';
		document.getElementById("ShowNewAdvanceSelected").style.display = 'none';
		document.getElementById("ShowNewAdvanceBack").style.display = '';
	}

	else
	{
		
		writeCookie("searchPanel","advance");
		document.getElementById("ShowBasicSelected").style.display = 'none';
		document.getElementById("ShowNewSearchBack").style.display = '';
		document.getElementById("ShowNewAdvanceSelected").style.display = '';
		document.getElementById("ShowNewAdvanceBack").style.display = 'none';

		document.getElementById("ShowLivingArea").style.display = '';
		document.getElementById("ShowLotSize").style.display = '';
		document.getElementById("ShowYearBuilt").style.display = '';

		document.getElementById("ShowStreetName").style.display = '';
		document.getElementById("ShowStreetNumber").style.display = '';
		document.getElementById("ShowZipCode").style.display = '';				
		document.getElementById("ShowSubDiv").style.display = '';		

		document.getElementById("ShowPoolOne").style.display = '';
		document.getElementById("ShowPoolTwo").style.display = '';
		document.getElementById("ShowSortResult").style.display = '';

		document.getElementById("ShowAdvanceSearchButton").style.display = '';
		document.getElementById("ShowSearchButton").style.display = 'none';
		AjaxPostNew('idx_ajaxprocess.php?act=insertAdvanceSearch',9);	
	}
}

function OpenBasicSearch()
{
	writeCookie("searchPanel","basic");
	document.getElementById("idxAdvanceSearch").style.display='none';
	document.getElementById("idxBasicSearch").style.display='';
}
function OpenAdvanceSearch()
{
	writeCookie("searchPanel","advance");
	document.getElementById("idxAdvanceSearch").style.display='';
	document.getElementById("idxBasicSearch").style.display='none';
}
function AfterTrackTab(pContent)
{
	
}
function writeCookie(name, value)
{
	 var expire = "";
	 expire = new Date((new Date()).getTime() + 60 * 60 * 24 * 365);
     expire = "; expires=" + expire.toGMTString();
     document.cookie = name + "=" + escape(value) + expire;
}	

function CheckEmailAlert(val,divtag,strflag)
{
	document.getElementById("hdnStatus").value = strflag;
	if(strflag == 1)
	{
		document.getElementById("xspanText").style.display = 'none';
	}
	if(val==true)
	{				

		element = document.getElementById(divtag);
		element.style.display = 'block';
		
		if(document.getElementById("hdnHiddenDsp"))
			GetAlertDaysTime(document.getElementById("hdnHiddenDsp").value,'')
		
		if(strflag == 2)
		{
			document.getElementById("daily_alerts").style.display = '';
			document.getElementById("weekly_alerts").style.display = 'none';
		}
		if(strflag == 3)
		{
			document.getElementById("daily_alerts").style.display = 'none';
			document.getElementById("weekly_alerts").style.display = '';
				document.getElementById("xspanText").style.display = '';
		}
		
	}
	else
	{		
		element = document.getElementById(divtag);
		element.style.display = 'none';
		
		//element = document.getElementById('email_alerts_value').value;
	}
	

}
function submitBasicForm(){
				
	var minprice=parseInt(document.frm.min_price.value);
	var maxprice=parseInt(document.frm.max_price.value);
	
	if(maxprice<minprice)
	{
		alert("Price Range maximum value should be greater than minimum value");
		document.frm.min_price.value="";
		document.frm.max_price.value="";
		return false;
	}
	
	var minarea=parseInt(document.frm.min_sqft.value);
	var maxarea=parseInt(document.frm.max_sqft.value);
	if(maxarea<minarea)
	{
	
		alert("Living Area maximum value should be greater than minimum value");
		document.frm.min_sqft.value="";
		document.frm.max_sqft.value="";
		return false;
		
	}	
	
	var minlot=parseInt(document.frm.min_acreage.value);
	var maxlot=parseInt(document.frm.max_acreage.value);
	
	if(maxlot<minlot)
	{
		alert("Lot Size Range maximum value should be greater than minimum value");
		document.frm.min_acreage.value="";
		document.frm.max_acreage.value="";
		return false;
		}
		if(document.frm.SelectedCities.options.length>25)
				{
					alert("Please select less then 25 cities.");
					document.frm.SelectedCities.focus();
					return false;
				}

			var len=document.frm.SelectedCities.length;
		//alert(len);
		var content="";
		for(i=0;i<len;i++)
		{
			if(document.frm.SelectedCities[i].value)
			{
				if(content=="")
					{
						content=document.frm.SelectedCities[i].value;
					}
					else
					{
						content=content+","+document.frm.SelectedCities[i].value;
					}
			}
			
			
		}
		document.frm.cities.value=content;
		selectAllOptions(document.frm.SelectedCities);		
		return true;
		/*return false;
		document.frm.action="custompages_save_search.php";
		document.frm.submit();*/
	
	}//reset
function emailCheck (emailStr)
{

	/* The following variable tells the rest of the function whether or not
	to verify that the address ends in a two-letter country or well-known
	TLD.  1 means check it, 0 means don't. */
	
	var checkTLD=1;
	
	/* The following is the list of known TLDs that an e-mail address must end with. */
	
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	
	/* The following pattern is used to check if the entered e-mail address
	fits the user@domain format.  It also is used to separate the username
	from the domain. */
	
	var emailPat=/^(.+)@(.+)$/;
	
	/* The following string represents the pattern for matching all special
	characters.  We don't want to allow special characters in the address.
	These characters include ( ) < > @ , ; : \ " . [ ] */
	
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	
	/* The following string represents the range of characters allowed in a
	username or domainname.  It really states which chars aren't allowed.*/
	
	var validChars="\[^\\s" + specialChars + "\]";
	
	/* The following pattern applies if the "user" is a quoted string (in
	which case, there are no rules about which characters are allowed
	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	is a legal e-mail address. */
	
	var quotedUser="(\"[^\"]*\")";
	
	/* The following pattern applies for domains that are IP addresses,
	rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	e-mail address. NOTE: The square brackets are required. */
	
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	
	/* The following string represents an atom (basically a series of non-special characters.) */
	
	var atom=validChars + '+';
	
	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */
	
	var word="(" + atom + "|" + quotedUser + ")";
	
	// The following pattern describes the structure of the user
	
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	
	/* The following pattern describes the structure of a normal symbolic
	domain, as opposed to ipDomainPat, shown above. */
	
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	
	/* Finally, let's start trying to figure out if the supplied address is valid. */
	
	/* Begin with the coarse pattern to simply break up user@domain into
	different pieces that are easy to analyze. */
	
	var matchArray=emailStr.match(emailPat);
	
	if (matchArray==null) {
	
	/* Too many/few @'s or something; basically, this address doesn't
	even fit the general mould of a valid e-mail address. */
	
	//alert("Email address seems incorrect (check @ and .'s)");
	alert("Please Enter A Valid Email Address");
	return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	
	// Start by checking that only basic ASCII characters are in the strings (0-127).
	
	for (i=0; i<user.length; i++) {
	if (user.charCodeAt(i)>127) {
	//alert("Ths username contains invalid characters.");
	alert("Please Enter A Valid Email Address");
	return false;
	   }
	}
	for (i=0; i<domain.length; i++) {
	if (domain.charCodeAt(i)>127) {
	//alert("Ths domain name contains invalid characters.");
	alert("Please Enter A Valid Email Address");
	return false;
	   }
	}
	
	// See if "user" is valid
	
	if (user.match(userPat)==null) {
	
	// user is not valid
	
	//alert("The username doesn't seem to be valid.");
	alert("Please Enter A Valid Email Address");
	return false;
	}
	
	/* if the e-mail address is at an IP address (as opposed to a symbolic
	host name) make sure the IP address is valid. */
	
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
	
	// this is an IP address
	
	for (var i=1;i<=4;i++) {
	if (IPArray[i]>255) {
	//alert("Destination IP address is invalid!");
	alert("Please Enter A Valid Email Address");
	return false;
	   }
	}
	return true;
	}
	
	// Domain is symbolic name.  Check if it's valid.
	
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
	if (domArr[i].search(atomPat)==-1) {
	//alert("The domain name does not seem to be valid.");
	alert("Please Enter A Valid Email Address");
	return false;
	   }
	}
	
	/* domain name seems valid, but now make sure that it ends in a
	known top-level domain (like com, edu, gov) or a two-letter word,
	representing country (uk, nl), and that there's a hostname preceding
	the domain or country. */
	
	if (checkTLD && domArr[domArr.length-1].length!=2 &&
	domArr[domArr.length-1].search(knownDomsPat)==-1) {
	//alert("The address must end in a well-known domain or two letter " + "country.");
	alert("Please Enter A Valid Email Address");
	return false;
	}
	
	// Make sure there's a host name preceding the domain.
	
	if (len<2) {
	//alert("This address is missing a hostname!");
	alert("Please Enter A Valid Email Address");
	return false;
	}
	
	// If we've gotten this far, everything's valid!
	return true;
}
function removeElement() 
{
	if(parent.document.getElementById('txtFirstName'))
		parent.document.getElementById('txtFirstName').focus();

	var b_version=navigator.appVersion;
	if(b_version.match('MSIE 6.0')!=null) //MSIE 6.0  Done by bhawdeep
	{
		if(parent.window.document.forms.length>0)
		{
			for(var j=0; j<parent.window.document.forms.length ;j++)
			{
				if(parent.window.document.forms[j])
				{
					 var arrSelect=parent.window.document.forms[j].getElementsByTagName("SELECT");
					  for (var i=0; i<arrSelect.length; i++)
					  {
							if (arrSelect[i].type == 'select-one' || arrSelect[i].type == 'select-multiple')
							{
								arrSelect[i].style.display='';
							}
					   }
				  }
			  }
		 }
   }
	var d = parent.document.getElementById('overlayMain');
	var olddiv = parent.document.getElementById('overlay');
	
	d.removeChild(olddiv);
	d.style.visibility = "hidden";
	
}	
function ConfirmAddSearch()
{
	if(confirm('Are you sure to save this search.This will delete previous alert'))
	  return true; 
   else 
	 return false;
}
//******************For png images***********************//

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function fixPNG(myImage) 
{
  
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML	  
    }
}
function resizeMapIframe(flag){

		
	  var ifr = document.getElementById("submain");
	  var ifrBody = ifr.contentWindow.document[getDocBody(ifr.contentWindow)];
	  ifr.style.height=ifrBody.scrollHeight+"px";
	  ifr.style.width=ifrBody.scrollWidth+"px";

	}
function resizeMapIframe1(){

		
	  var ifr = document.getElementById("submain");
	   var ifrBody = ifr.contentWindow.document[getDocBody(ifr.contentWindow)];
		  ifr.style.height="100px";	
	}
	

function GetAlertDaysTime(pdate,pdays)
{
	if(document.getElementById("hdnStatus"))	
	{
		if(document.getElementById("hdnStatus").value=="3")	
		{
			if(pdays=='')
				pdays=7;
		
			var d = new Date(pdate);
			d.setDate(d.getDate()+parseInt(7));
			var newdate=(d.getMonth()+1)+"/"+d.getDate()+"/"+d.getFullYear();
			var fulldate=d.toLocaleString(newdate);
			arrdate=fulldate.split(',');
			document.getElementById("xspanText").innerHTML="<br><b>Alerts are sent every week on <font color='#FF3300'>"+ arrdate[0] + "</font>.</b>";
	   }
		else
	   {
			document.getElementById("xspanText").innerHTML="";
		}

	}

}
function PrintWindow()
{
	var b_version=navigator.appVersion;
	if(b_version.match('MSIE 6.0')==null) //MSIE 6.0  Done by bhawdeep
	{
		window.print()
	}		
		
}
function LoadCityCombo()
{
	iepopupSelect_new();
	if(document.getElementById("ShowLoading"))
		document.getElementById("ShowLoading").style.display = "";		
 
	var strURL = WWWROOT+"/idx_post_citydata.php";
	
	AjaxPostNew(strURL, 12);
}

function AfterCityLoad(pList)
{
	
	var myIndex;
	document.frm.PropertyList.disabled = false;	
	document.frm.PropertyList.options.length=0;
	document.frm.PropertyList.options[0]= new Option("-- All Cities --","",true,false);	
	if(document.getElementById("rdSearchType"))
	{
		if(document.frm.elements['rdSearchType'][1].checked == true) 
			document.frm.PropertyList.options[0]= new Option("-- All Counties --","",true,false);	
		else
			document.frm.PropertyList.options[0]= new Option("-- All Cities --","",true,false);	
	}
	
	
	arrCityData = pList.split('|');
	for(i=0;i<arrCityData.length;i++)
	{
	  arrCityTemp = arrCityData[i].split(',,,');
	  document.frm.PropertyList.options[i+1]= new Option(arrCityTemp[1],arrCityTemp[0]);	  
 	}

	if(document.getElementById("ShowLoading"))
		document.getElementById("ShowLoading").style.display = 'none';

	iepopupDeSelect_new();
}
function LoadCountyCombo()
{
	iepopupSelect_new();

	if(document.getElementById("ShowLoading"))
		document.getElementById("ShowLoading").style.display = "";		

	var strURL = WWWROOT+"/idx_post_countydata.php";
	AjaxPostNew(strURL, 12);
}

function SendEmailtoAgent(filename)
{
	
	if(document.getElementById('txtMsgContents').value=='')
		{
			alert('Please enter message.');
			document.getElementById('txtMsgContents').focus();
			return false;
		}
	  getstr = "";
	  getstr += "txtMsgContents="+document.getElementById('txtMsgContents').value;
	  var strURL = WWWROOT+"/"+filename+".php?hdnSendMessage=yes&"+getstr;
	  AjaxPostNew(strURL, 13);
	
}
function AfterMessageSenttoAgent(pContent)
{
	if(document.getElementById('divAgentMessage'))
		document.getElementById('divAgentMessage').style.display = ""; 
}						 
function open_win(url_add)
{
   window.open(url_add,'welcome','width=600,height=700,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=yes');
}
function iepopupSelect_new()
{ 
		var b_version=navigator.appVersion;
		if(b_version.match('MSIE 6.0')!=null) //MSIE 6.0  
		{
			if(document.forms.length>0)
			{
				for(var j=0; j<document.forms.length ;j++)
				{
					if(document.forms[j])
					{
						var arrSelect=document.forms[j].getElementsByTagName("SELECT");
						for (var i=0; i<arrSelect.length; i++)
						{
							if (arrSelect[i].type == 'select-one' || arrSelect[i].type == 'select-multiple')
							{
								arrSelect[i].style.display='none';
							}
						}
					}
				}
			 }
	   }
}

/**********************************/
function moveCountySelectedOptions(from,to)
{
	var content;
	content="";
	
	document.frm.hdnContent.value="";

	if(arguments.length>3)
	{
		var regex = arguments[3];
		if(regex != "")
		{
			unSelectMatchingOptions(from,regex);
		}
	}

	if(!hasOptions(from))
	{
		return;
		if(document.getElementById("ShowLoading"))
			document.getElementById("ShowLoading").style.display = "none";
	}

	var flagReject = 1;
	var countSel = 0;
	for(var i=0;i<from.options.length;i++)
	{
		var o = from.options[i];
		if(o.selected)
		{
			if(o.value=='')		
				flagReject = 0;

			countSel++;				
		}
	}
	
	var falgtoReject = 1;
	var countToSel = 0;	
	for(var k=0;k<to.options.length;k++)
	{
		var j = to.options[k];
		
		if(j.text=='-- All Cities --')
			falgtoReject = 0;
		
		countToSel++;
	}

	if(flagReject==0 && countSel>1)
	{
		alert("You cannot move the -- All Cities -- option with other cities.");
		if(document.getElementById("ShowLoading"))
			document.getElementById("ShowLoading").style.display = "none";
		return false;	
	}

	if(falgtoReject==0 && countToSel==1)
	{
		alert("You cannot move the -- All Counties -- option with other counties.");
		if(document.getElementById("ShowLoading"))
			document.getElementById("ShowLoading").style.display = "none";
		return false;	
	}
	
	if(flagReject==0 && countToSel!=0 && countSel!=from.options.length)
	{
		alert("You cannot move the -- All Counties -- option with other counties.");
		if(document.getElementById("ShowLoading"))
			document.getElementById("ShowLoading").style.display = "none";
		return false;	
	}

	for(var i=0;i<from.options.length;i++)
	{
		var o = from.options[i];
		if(o.selected)
		{
			if(!hasOptions(to))
			{
				var index = 0;
			}
			else
			{
				var index=to.options.length;
			}

			to.options[index] = new Option( o.text, o.value, false, false);
		}			
	}

	for(var i=(from.options.length-1);i>=0;i--)
	{
		var o = from.options[i];
		if(o.selected)
		{
			from.options[i] = null;
		}
	}

	if((arguments.length<3) ||(arguments[2]==true))
	{
		//sortSelect(from);
		sortSelect(to);
	}
			from.selectedIndex = -1;to.selectedIndex = -1;
			
			var len=document.frm.county.length;
		//alert(len);
	
		for(i=0;i<len;i++)
		{
			if(document.frm.county[i].value)
			{
				if(content=="")
				{
					content=document.frm.county[i].value;
				}
				else
				{
					content=content+","+document.frm.county[i].value;
				}
			}
			
			
		}

		document.frm.hdnContent.value=content;
		if(document.getElementById("ShowLoading"))
			document.getElementById("ShowLoading").style.display = "none";
}

function ChangeFeedURL(val,page)
{
	window.location.href = page+"?MLSFeedID="+val;
}

		
