

/*propertySearch.js*/

var drawNbrHoodMap = false;
var recLimitArr = new Array('sevengables');
var roloUse = false;
var fromMarketReport="";
var emlSaveSearchDlg;
var oldMapData;
var map2 = undefined;
var localBitArr = new Array();
var chkAlertStatus='';
var selFavGrps = "";
var currView = "s";
var imgArr;
var ctr0=0;
var ctr1=0;
var ctr2=0;
var ctr3=0;
var ctr4=0;
var ctr5=0;
var isIE = document.all?1:0;
var isIE6 = (window.XMLHttpRequest)?0:1;
var usrAgt = navigator.userAgent.toLowerCase();
var isFF2 = (usrAgt.indexOf('firefox/2')!=-1)?1:0;
var isFF3 = (usrAgt.indexOf('firefox/3')!=-1)?1:0;
var isSafari = (usrAgt.indexOf('safari')!=-1)?1:0;
var imgThmPath = "/wt/"+bkTheme+"/images/";
var qryStrHash = new $H();
var totalRecords;
var lastView = "";
var chkPSAr = new Array();
var alertMlsNo	= ""; 
var alertPrice	= "";
var alertStatus = "";
var alertTid	= "";
var alertAddress = "";
var alertCity	= "";
var	alertState	= "";
var	alertZip	= "";
var latLong = "";

function num2moneyWrapper(num)
{
	if(num=="0" || num=="0.0" || num=="0.00" || num == "00000") 
		return "0";
	else 
		return num2money(num);
}
function exploreEnter(e)
{
	if(e.keyCode == 13)
	{
		disablePower = true;
		doPropSearch();	
	}
}
function clearSelVal(event)
{
	if(event && event.keyCode != 13 && event.type == 'keypress')
	{
		$('selVal').value='';			
	}
}
function loadView(actView)
{
	switch(actView)
	{
		case 'G':				 
				 if(lastView == "galleryView" && $('fromPage').value != "listView")
				 {
					qryStrHash['fromPage'] = "galleryView";
					extendMap('s');
				 }
				 else
				 {
					 $('fromPage').value = "galleryView";
					 clearAllFav();
					 doPropSearch();
				 }
				 break;
		case 'M':
				$('fromPage').value = "mapView"; 
				if (typeof(map2) == "undefined")
				{
					hideMapList();
				}			 
				extendMap('l');
				break;
		case 'L':				
				 if(lastView == "listView"  && $('fromPage').value != "galleryView")
				 {
					qryStrHash['fromPage'] = "listView";
					extendMap('s');
				 }
				 else
				 {
					 $('fromPage').value = "listView";
					 doPropSearch();
				 }
				 break;
	}	
}

function checkForOpenHome()
{
		if(trim(getSearchCookie('area')) != "")
			qryStrHash['area'] = trim(getSearchCookie('area'));
		if(trim(getSearchCookie('polygon')) != "")
			qryStrHash['polygon'] = trim(getSearchCookie('polygon'));
		//-------------------------CHECKING FOR SUB - NEIGHBORHOOD---------------------//		
		qryStrHash.each(function(pair)
		{	
			//alert(pair.key + " == "+pair.value);
			setSearchCookie(pair.key,pair.value);		
		});
		url = '/openHomes/navigator.php?';
		
		var nhood = getSearchCookie('neighborhood');
		if(nhood)
			url += 'nhood=' + nhood.replace(/\s/g, '_');

		var qs = new Querystring();
		if(qs.get("frm") != null && trim(qs.get("frm")) == 'agt' && qs.get("aid") != null)
		{
			url += "&frm="+trim(qs.get("frm"))+"&aid="+trim(qs.get("aid"));
		}
		if(qs.get("ps") != null )
		{
			url += "&ps="+trim(qs.get("ps"));
		}
		location.href=url;
}

function checkForForeclosure()
{
		url = '/app/listing/foreclosureListing.php?';
		
		var qs = new Querystring();
		if(qs.get("frm") != null && trim(qs.get("frm")) == 'agt' && qs.get("aid") != null)
		{
			url += "&frm="+trim(qs.get("frm"))+"&aid="+trim(qs.get("aid"));
		}
		if(qs.get("ps") != null )
		{
			url += "&ps="+trim(qs.get("ps"));
		}
		$('frmPropSearch').action = url;
		$('frmPropSearch').submit();
		//location.href=url;
}

function doPropSearch()
{		
	if(typeof(setMapZoomOutLimit) != "undefined")
		setMapZoomOutLimit = 0;
	if($('frmPropSearch')) { $('frmPropSearch').action = "";}
	nbrPolyline = "";
	if($('propHeroDiv')) $('propHeroDiv').hide();
	if($('mapHeader')) $('mapHeader').hide();	
	if( qryStrHash['fromPage'] != 'undefined' && qryStrHash['fromPage'] != null && qryStrHash['fromPage'] != "mapView")
		lastView = qryStrHash['fromPage'];	
	
	//----GETTING OLD VAL FOR LISTING TYPE. IF "FAVORITES" THEN NO NEED TO LOAD FAV-GRP-POPUP (B4  validateRSCriteriaNew())---//
	var lastListing = trim(getSearchCookie("searchCriteria"));
	if(lastListing == "favorites" && $F('bit_select_box') == 'favorites')
	{
		$('pagiVal').value = 0;
		$('sortProp').value = "ph";
		selFavGrps = qryStrHash['grp'] ;		
	}
	if(validateRSCriteriaNew())
	{
		if(chkSignInReqd == "1" && uid == "")
		{
			var drMpUrl = '/Search/';
			if(trim(getSearchCookie('city')) != "")
				drMpUrl += trim(getSearchCookie('state'))+'/'+trim(getSearchCookie('city'));
			var qstr = new Querystring();		
			if(qstr.get("frm") != null && qstr.get("aid") != null)
				drMpUrl += '&frm=agt&aid='+ trim(qstr.get("aid"));
			
			if(trim($F("txtPolygon")) != "")
			{
				var polyEncodeStr = encodePolygonToStr(trim($F("txtPolygon")));
				setSearchCookie("polygon",polyEncodeStr);
			}
			if($F("txtArea") != "")
				setSearchCookie("area",$F("txtArea"));

			opensignInRegDlg(drMpUrl,'C');
			return;
		}

		if($('mainResTbl')) { $('mainResTbl').style.height="630px"; $('mainResTbl').show();}
		if($('resContainer')) { $('resContainer').style.height="1080px"; $('resContainer').show(); }
		if($('recOperationTbl')) { $('recOperationTbl').show(); }	

		//------------ CODE FOR CLEAR LOCAL SEARCH AND REMOVE MAP OVERLAY ------------ 
		localBitArr = [];
		if(typeof(map2) == "object") map2.clearOverlays();		

		//------------  IF OPEN HOME THEN REDIRCT ON OPEN HOME NAVIGATE PAGE------------//
		if(bkTheme == 'atproperties' && $('chkOpnHome')  && $('chkOpnHome').checked)
		{
			setSearchCookie("searchCriteria","brokeropenHome");
			checkForOpenHome();
			return;
		}

		if(bkTheme == 'johngreene' && $('Foreclosure')  && $('Foreclosure').checked)
		{
			checkForForeclosure();
			return;
		}
		
		//alert("lastView: == " + lastView + " === CurrView: "+qryStrHash['fromPage']);

		hideSavedSearch($('bit_select_box'));

		/**************** Reload Page For Power Search (clear cookie and load consumer view) -- sandip **************/
			
		if(initPower && typeof(initPower) != "undefined" && disablePower && typeof(disablePower) != "undefined")
		{
			initPower = false;
			disablePower = false;

			var powerUrl = '/Search/';
			if(trim(getSearchCookie('city')) != "")
				powerUrl += trim(getSearchCookie('state'))+'/'+trim(getSearchCookie('city'));
			
			var qstr = new Querystring();		
			if(qstr.get("frm") != null && qstr.get("aid") != null)
				powerUrl += '?frm=agt&aid='+ trim(qstr.get("aid"));
			
			ClrQckSrchCookies();
			var host = "http://"+window.location.hostname+powerUrl;
			window.location.href = host;			
		}

		/************************************************************************************************************/

		//****************************IF FAVORITE LISTING COMES*******************************//
		if($F('bit_select_box') == 'favorites')
		{	
			if(typeof(uid) == "undefined" || uid == "" || uid == null)
			{
				/*
				if(typeof(SignInDlg) == "string" || typeof(SignInDlg) == "undefined" || SignInDlg == null)
				{
					if($('divSignInFrm')) 
					{ 
						$('divSignInFrm').style.display = '';			
						if(typeof(createDialog) == "function")
							SignInDlg = createDialog('divSignInFrm');
					}
				}
				SignInDlg.beforeHideEvent.subscribe(beforeHideSignInFrm, this);
				SignInDlg.beforeShowEvent.subscribe(beforeShowSignInFrm, this);
				$('divSignInFrm').style.dispaly = 'block';			
				$('userName').value = "";
				$('userPwd').value = "";
				$('userName').className="textboxSotheby";
				$('userPwd').className="textboxSotheby";
				$('errSysLogin').innerHTML="&nbsp;";
				if($("fromWhere")) $("fromWhere").value = "listing";
				if($("signInRoloLnk")) $("signInRoloLnk").href  = '/app/auth/login.php';
				var qs = new Querystring();
				if(qs.get("frm") != null && qs.get("aid") != null)
					$("signInRoloLnk").href += "?agd="+trim(qs.get("aid"));	
				SignInDlg.show();			
				$('userName').focus();
				*/						
				var mrUrl = window.location.href;
				opensignInRegDlg(mrUrl,'R','','');
			}
			else
			{	
				if(lastListing != $F('bit_select_box') || typeof(selFavGrps) == 'undefined' || selFavGrps == "")	
					showFavPopupDualPane("listing");	
				else
				{	
					removePolyRelated();
					qryStrHash['uid'] = uid;
					qryStrHash['grp'] = selFavGrps;
					setUpDown();
				}
			}		
			return;		
		}
		setUpDown();
	}	
}

function setUpDown()
{
	if(!renderRecLimit())
	{
		$('pagiVal').value = parseInt(qryStrHash['page']) - 1;
		return false;
	}
	$('lrgSmlMapDiv').show();
	$('viewTabTbl').hide();
	if($('msgTable'))	$('msgTable').hide(); // for message - santafe and sandia 	
	$('mainContainerTbl').className='mainContainerTbl1';
	$('noRecTbl').hide();
	var pageNo = $F('pagiVal');
	pageNo = parseInt(pageNo)+1;
	qryStrHash['page'] =  pageNo;
	
	if(qryStrHash['fromPage'] == "mapView")
	{
		if(lastView == "galleryView")
			recordPerPage = galleryRecPerPage;
		else 
			recordPerPage = propRecPerPage;
	}
	qryStrHash["limit"] = recordPerPage;
	if(typeof(nbrStoreArr) == "object" && nbrStoreArr.length > 0)
	{		
		var nbrString = cmImplodeArr(nbrStoreArr,",");
		qryStrHash['mul_nbrhood'] = nbrString;	
		setSearchCookie("mul_nbrhood",nbrString);
	}

	/*
	sortType = $F('highLowVal');
	if(sortType == "1")
	{
		strHtml = "<img src='"+imgThmPath+"listing/up_d.gif' id='lblAscC' title='Up'>&nbsp;<img src='"+imgThmPath+"listing/down_a.gif' id='lblDescC' class='upDownLink crsr' onclick='$(\"pagiVal\").value=0;$(\"highLowVal\").value=\"0\";sortProperty($(\"sortProp\"));' title='Down'/>";			
	}                        
	else
	{
		strHtml = "<img title='Up' src='"+imgThmPath+"listing/up_a.gif' id='lblAscC' class='upDownLink crsr' onclick='$(\"pagiVal\").value=0;$(\"highLowVal\").value=\"1\"; sortProperty($(\"sortProp\"));'/>&nbsp;<img title='Down' src='"+imgThmPath+"listing/down_d.gif' id='lblDescC' class='upDownLabel'/>";			
	}
	$("spnUpDown").innerHTML = strHtml;
	*/

	var queryStr = new Querystring();

	makeTabActive(qryStrHash['fromPage']);
	var qs = "";	
	var url = "";
	var area = "";
	var polygon = "";

	if(initPower && typeof(initPower) != "undefined")
	{
		var url = '/app/dashboard/powerSearchListing.php';
		area = getSearchCookie("area");
		if(trim(getSearchCookie("polygon")) != "")
		{
			var decodedPolyStr = decodeStrToPolygon(trim(getSearchCookie("polygon")));
			polygon = decodedPolyStr;
		}
		qs = getPowerSearchCookie();
		qs = qs.substr(1,qs.length);

		if(qryStrHash['fromPage'] == "mapView")
			qs += '&fromPage=' + lastView;
		else
			qs += '&fromPage=' + qryStrHash['fromPage'];

		qs += "&page="+qryStrHash['page']+"&limit="+qryStrHash['limit'];

		qs += "&MultiCity="+trim(getSearchCookie("multicity"));
		qs += "&MultiZip="+trim(getSearchCookie("multizip"));

		if(trim(aid) != "") qs += "&agtid="+aid;
	}
	else
	{
		url = '/app/dashboard/mlsPropertyListings.php';
		qryStrHash.each(function(pair)
		{	if(pair.key == "fromPage" &&  pair.value == "mapView")
			{			
				qs += '&' + pair.key + '=' + lastView;	
			}
			else
				qs += '&' + pair.key + '=' + pair.value;		
		});

		area = trim($("txtArea").value);
		polygon = trim($F("txtPolygon"));

		if(trim(strAgtMlsSrc) != "") 
		{ 
			var mlsSrc = strAgtMlsSrc.replace(/\+/g,' ');
			qs += '&mlsSource='+mlsSrc;
			setSearchCookie("mlsSource",mlsSrc);
		}

		if(trim(aid) != "") qs += "&aid="+aid;
	}

	/**********************************************************************************/
	
	if(area != "" && !area.include("|"))
	{
		area = area.replace(/\ /g,"");
		area = area.replace("((","");
		area = area.replace("))","");
		area = area.replace("),(",",");
		area = area.split(",");				
		qs += "&minlat="+area[0];
		qs += "&minlong="+area[1];
		qs += "&maxlat="+area[2];
		qs += "&maxlong="+area[3];
	}
	else if(area != "")
	{
		mapArr = area.split("|");
		var minLat = "";
		var minLong = "";
		
		var maxLat = "";
		var maxLong = "";

		for(var i=0;i<mapArr.length;i++)
		{
			mapArr[i] = mapArr[i].replace(/\ /g,"");
			var areaArr = mapArr[i].split(",");
			minLat += areaArr[0].replace("((","")+",";
			minLong += areaArr[1].replace(")","")+",";
			
			maxLat += areaArr[2].replace("(","")+",";
			maxLong += areaArr[3].replace("))","")+",";
		}
		minLat = minLat.substr(0,minLat.length-1);
		minLong = minLong.substr(0,minLong.length-1);
		maxLat = maxLat.substr(0,maxLat.length-1);
		maxLong = maxLong.substr(0,maxLong.length-1);						

		qs += "&minlat="+minLat;
		qs += "&minlong="+minLong;
		qs += "&maxlat="+maxLat;
		qs += "&maxlong="+maxLong;
	}
	if(trim(polygon) != "")
	{		
		var polyEncodeStr = encodePolygonToStr(polygon);

		qs +=  "&polygon="+trim(polygon);
		setSearchCookie("polygon",polyEncodeStr);
	
		if($("drawSerArea")) $("drawSerArea").hide();
		if($("clrSerArea")) $("clrSerArea").show();
	}

	if(area != "")
		setSearchCookie("area",area);
	/**********************************************************************************/
	
	
	//alert(url +" --- "+ qs);	
	$('loaderLogin').show();
	$('recOperationDiv').hide();
	$('botPagiRow').hide();
	ajaxRequest(url,qs,function(r)
	{	
		rsText = r.responseText; 		
		posAlert = rsText.indexOf('Alert:',0);
		if(posAlert == -1)
		{	
			if($('schoolratingsdiv')) $('schoolratingsdiv').show();
			if($('areaphotosdiv')) $('areaphotosdiv').show();
			$('viewTabTbl').show();				
			resArr=rsText.split('=^^=');
			response =  eval('(' + trim(resArr[2]) + ')');
			totalRecords = resArr[0];
			mapData = response;							
			showPaging(totalRecords);
			if($('msgTable'))	customMsg();	// for message - santafe and sandia 
			var htmlPart = resArr[1];			
			$("mapDiv").hide();			
			$('recOperationDiv').show();
			var totRecHtml = totalRecords + " Properties Found";
			if(parseInt(totalRecords) == 1)
				totRecHtml = totalRecords + " Property Found";
			$('resCntDiv').innerHTML = totRecHtml;
			$('sortingDiv').show();
			$('proListingDiv').show();			
			$('proListingDiv').innerHTML = htmlPart;
			if(qryStrHash['fromPage'] == "galleryView")
			{				
				imgArr = new Array();
				for(var i=0;i<mapData.length;i++)
				{					
					imgArr[i] = mapData[i].pictures.split(","); 				
				}
				//Hide Previoue/Next for GalaryView when no image available
				for(var i=0;i<imgArr.length;i++)
				{
					if(imgArr[i][0].indexOf('noImageThmbBig.jpg') != -1 || imgArr[i].length == 1)
					{
						if($('prePhoto'+i)) $('prePhoto'+i).hide();
						if($('nextPhoto'+i)) $('nextPhoto'+i).hide();
					}
				}
			}
			
			$('loaderLogin').hide();
			$("mapDiv").show();			
			if(qryStrHash['fromPage'] == "mapView")
			{	
				currView = "l";
				/*$("mapMainDiv").style.top = "2px";
				$("mapMainDiv").style.left = "10px";
				$("mapMainDiv").style.height = "350px";
				$("mapDiv").style.height = "320px";
				$("mapMainDiv").style.width =  $("mapDivHeader").style.width = $("mapDiv").style.width = "974px";
				$("mapMainDiv").style.position = "relative";*/
				$("mapMainDiv").className = "mapMainDivBig";
				$("mapDiv").className = "mapDivBig";
				$("mapDivHeader").className = "mapDivHeaderBig mapDivHeader";
			}
			else
			{
				currView = "s";
				/*$("mapMainDiv").style.position = "absolute";
				$("mapMainDiv").style.top = "101px";
				$("mapMainDiv").style.left = "663px";
				$("mapDiv").style.height = "320px";
				$("mapDiv").style.width = "323px";
				$("mapMainDiv").style.width = $("mapDivHeader").style.width = "323px";	*/	
				$("mapMainDiv").className = "mapMainDivSmall";
				$("mapDiv").className = "mapDivSmall";
				$("mapDivHeader").className = "mapDivHeaderSmall mapDivHeader";
			}
			if(typeof(map2) != "undefined" && drawNbrHoodMap)
			{
				map2.clearOverlays();
			}
			/*	Added By Krunal	for Flicker Api*/
				latLong = resArr[5];
			/*	Added By Krunal	for Flicker Api*/

			loadOnMap(mapData);			
			if(typeof(resArr[3]) != "undefined" && resArr[3] != "" && nbrPolyline=="")
			{				
				try
				{
					var ptArr = decodeLine(decodeURIComponent(resArr[3]));
					var ptStr = convPolyPointStr(ptArr);
					setMapPolygonNhood(map2,ptStr);				
					drawNbrHoodMap = true;
				}
				catch (Exception)
				{
					// Do Nothing
				}
			}

			if(typeof(map2) != "undefined") map2.checkResize();
			oldMapData = mapData;
			if($('helpBox')) $('helpBox').hide();
			$('mapDivHeader').show();
			if(currView == "l")
			{	
				$('lrgMap').style.display="none";
				$('smlMap').style.display="";				
				$('spacerRow').style.height="10px";
				$('mainContainerTbl').style.width="62%";
				$('polygonDiv').show();
				$("rightBorderTopIcons").className="";
				if($("msgTable"))$("msgTable").className="";
				//$('apiDiv').style.top="-5px";
			}
			if(currView == "s")
			{	
				$('smlMap').style.display="none";
				$('lrgMap').style.display="";				
				$('spacerRow').style.height="370px";
				$('mainContainerTbl').style.width="65%";
				$("rightBorderTopIcons").className="mainsrchBoxLeft";
				if($("msgTable"))$("msgTable").className="mainsrchBoxLeft";
				if(getSearchCookie("polygon") != "")
					$('polygonDiv').show();
				else
					$('polygonDiv').hide();
				//$('apiDiv').style.top="45px";
			}			
			
			//function for powersearch to change favorite icon and load favorite-function in rolo.js(added by saloni)			
			loadFav();
			$('favRoloDiv').show();
			if($('photoId0'))
			{
				$('mainContainerTbl').className='mainContainerTbl1';
				if($('favRoloRow')) $('favRoloRow').hide();
			}
			else
			{
				$('mainContainerTbl').className='mainContainerTbl';
				if($('favRoloRow')) $('favRoloRow').show();
			}			
			$('mapMainDiv').show();
		}
		else
		{			
			noRecRelated(rsText.substr(6));			
			if($('mapMainDiv')) $('mapMainDiv').hide();
		}
	});
}

function noRecRelated(msg)
{
	totalRecords = 0;
	if($('schoolratingsdiv')) $('schoolratingsdiv').hide();
	if($('areaphotosdiv')) $('areaphotosdiv').hide();
	$('loaderLogin').hide();
	$('botPagiRow').hide();
	$('mapDiv').hide();
	$("helpBox").hide();
	$('proListingDiv').hide();
	$('favRoloDiv').hide();
	$('recOperationDiv').hide();
	$('viewTabTbl').hide();
	if($('msgTable'))	$('msgTable').hide(); // for message - santafe and sandia 
	$('apiLoading').hide();
	if($('noRecTbl'))
	{
		$('noRecTbl').show();
		$('noRecTblMsg').innerHTML = msg;
	}	
}

function validateRSCriteriaNew()
{
	qryStrHash = new $H();	
	
	qryStrHash['city'] = '';
	qryStrHash['state'] = '';
	qryStrHash['zip'] = '';
	qryStrHash['lat'] = '';
	qryStrHash['lng'] = '';

	if(trim(getSearchCookie("searchSortType")) == "")
	{
		if(bkTheme == 'atproperties')
			qryStrHash['searchSortType'] = "atp";
		else
			qryStrHash['searchSortType'] = $F("sortProp");
	}
	else
		qryStrHash['searchSortType'] = getSearchCookie("searchSortType");

	setSearchCookie('searchSortType',qryStrHash['searchSortType']);

	var searchCSZ = trim($F('RSsearchCSZ'));
	if(!isNaN(searchCSZ) && $('selVal') && trim(getSearchCookie('neighborhood')) == "" && trim(getSearchCookie('subNhood')) == "")
	{
		$('selVal').value = 'CS';
	}
	$('mlsno').className		= 'TextBoxBig';
	$('RSsearchCSZ').className  = '';
		
	var mlsno = trim($F('mlsno'));	
	//**************************** MLS NUMBER VALIDATION *******************/
	$('mlsno').className  = 'TextBoxBig';
	var mlsurl = "/app/dashboard/mlsSearch.php";
	var mlsstr = "mlsno="+mlsno+ "&forAlert=1&ignorestatus=1&theme="+bkTheme;		    
	if(mlsno != "")
	{
		var mlsTrue = true;
		ajaxRequest(mlsurl,mlsstr,function(r)
		{	         
			if(trim(r.responseText)=='0')	           
			{
				alert('MLS NO. not found.');
				$('mlsno').className  = 'textboxRed';
				$('mlsno').value = "";
				$('mlsno').focus();	
				mlsTrue = false;
			}			
		},false);		
		if(mlsTrue)
		{
			qryStrHash['mlsno'] = mlsno;
			setSearchCookie("mlsno",mlsno);
		}
		if(!mlsTrue)
		{
			qryStrHash['mlsno'] = "";
			setSearchCookie("mlsno","");
			return false;
		}
	}
	else
	{
		qryStrHash['mlsno'] = "";
		setSearchCookie("mlsno","");
	}
	//**************************** CSZ VALIDATION *******************/
	if(searchCSZ == "" && mlsno == "")
	{
		alert("Please Enter Neighborhood, City or ZIP code");
		return false;
	}	
	if(searchCSZ != "")
	{		
		if($F('selVal') == "NBR")
		{			
			$('neighborhood').value = searchCSZ;
			qryStrHash['neighborhood'] = escape(encodeURI(searchCSZ));
			setSearchCookie("neighborhood",searchCSZ);			

			removeSearchCookie("city");
			removeSearchCookie("state");
			removeSearchCookie("zip");
			removeSearchCookie('subNhoodId');
			removeSearchCookie('subNhood');
			removeSearchCookie('multicity');
			removeSearchCookie('multizip');
			if(getSearchCookie('polygon') != "")
			{
				removePolyRelated();
			}
		}
		else if($F('selVal').indexOf("SNBR") != -1)
		{
			qryStrHash['subNhood'] = searchCSZ;
			var selValArr = $F('selVal').split("_");
			getPolygonFrmSNbr(selValArr[1]);
			setSearchCookie('subNhoodId',selValArr[1]);
			setSearchCookie("subNhood",searchCSZ);
			qryStrHash['subNhoodId'] = selValArr[1];			
			removeSearchCookie("city");
			removeSearchCookie("state");
			removeSearchCookie("zip");
			removeSearchCookie("neighborhood");
			removeSearchCookie('multicity');
			removeSearchCookie('multizip');
		}
		else if($F('selVal').indexOf("CS") != -1)
		{				
			var retArray = doGeoCode(searchCSZ,"");
			//alert(retArray);
			//alert($F('city') + "=="+retArray['city']);
			if($F('city') != retArray['city'] && getSearchCookie('polygon') != "")
			{					
				removePolyRelated();
			}
			if(!retArray) { $('RSsearchCSZ').className  = 'textboxRed'; $('RSsearchCSZ').focus(); return false; }
			qryStrHash['city'] = $('city').value = retArray['city'];
			qryStrHash['state'] = $('state').value = retArray['state'];
			qryStrHash['zip'] = $('zip').value = retArray['zip'];
			qryStrHash['propLatitude'] = $('lat').value = retArray['lat'];
			qryStrHash['propLongitude'] = $('lng').value = retArray['lng'];	
			
			setSearchCookie("city",retArray['city']);
			setSearchCookie("state",retArray['state']);
			setSearchCookie("zip",retArray['zip']);
			setSearchCookie("lat",retArray['lat']);
			setSearchCookie("lng",retArray['lng']);
			
			$('RSsearchCSZ').value = trim(retArray['city']+', '+retArray['state']);
			if(trim(retArray['zip']) != "") { $('RSsearchCSZ').value = retArray['zip']; }

			var latLongStr = "[{'lat':'"+retArray['lat']+"','lng':'"+retArray['lng']+"'}]";
			var now = new Date();
			now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
			setCookie("latLongCk",latLongStr,now);
			if(getSearchCookie('subNhood') != "")
			{
				removePolyRelated();
			}
			removeSearchCookie("neighborhood");
			removeSearchCookie('subNhoodId');
			removeSearchCookie('subNhood');
			removeSearchCookie('multicity');
			removeSearchCookie('multizip');
		}
		else
		{			
			if(trim(getSearchCookie("multicity")) != "" || trim(getSearchCookie("multizip")) != "")
			{
				removeSearchCookie("address");
				removeSearchCookie("city");
				removeSearchCookie("state");
				removeSearchCookie("zip");
				removeSearchCookie("lat");
				removeSearchCookie("lng");
				removeSearchCookie("neighborhood");
				removeSearchCookie('subNhoodId');
				removeSearchCookie('subNhood');
				removeSearchCookie('polygon');
				removeSearchCookie('area');				
			}
			else
			{
				setSearchCookie("city",defCity);
				setSearchCookie("state",defState);
				setSearchCookie("lat",defLat);
				setSearchCookie("lng",defLng);
				
				qryStrHash['city'] = defCity;
				qryStrHash['state'] = defState;			
				qryStrHash['propLatitude'] = defLat;
				qryStrHash['propLongitude'] = defLng;

				var latLongStr = "[{'lat':'"+defLat+"','lng':'"+defLng+"'}]";
				var now = new Date();
				now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
				setCookie("latLongCk",latLongStr,now);
				$('RSsearchCSZ').value =defCity+', '+defState;
				removeSearchCookie('polygon');
				removeSearchCookie('area');			
				removeSearchCookie('subNhoodId');
				removeSearchCookie('subNhood');
				removeSearchCookie('neighborhood');
				if(getSearchCookie('subNhood') != "")
				{
					removePolyRelated();
				}
				removeSearchCookie('multicity');
				removeSearchCookie('multizip');
			}
		}
	}
	//----------------Address Search Validation 
	qryStrHash['address'] = "";
	if(trim($F('address')) != "")
	{
		qryStrHash['address']	= escape(trim($F('address')));
	}
	setSearchCookie("address",qryStrHash['address']);
	//----------------price param validation
	var minP = Number(money2num($('minprice').value));	
	var maxP = Number(money2num($('maxprice').value));

	if(minP<0 || maxP<0)
	{		
		alert("Please enter valid price range");
		$('minprice').value = '';
		$('maxprice').value = '';
		$('minprice').focus();
		return false;
	}

	if((minP>maxP) && (minP != "" && maxP != ""))
	{		
		alert("Please enter valid price range");
		$('minprice').value = '';
		$('maxprice').value = '';
		$('minprice').focus();
		return false;
	}	
	
	if (maxP == "0")
	{
		$('maxprice').value = '';
		maxP = "";
	}
	if (minP == "0")
	{
		$('minprice').value = '';
		minP = "";
	}
	
	if( maxP != "" && minP != "" && parseInt(maxP) <= parseInt(minP) )
	{			
			$('minprice').focus();
			alert("Maximum price should be greater than minimum price.");
			$("maxprice").value = "";
			$('minprice').value = "";			
			return false;
	}
	if($("keywordSrch"))
	{
		var cntrComma = ($("keywordSrch").value).split(/,/g).length - 1;
		if(cntrComma >= 5)
		{
			alert("Maximum 5 keywords are allowed to search");
			return false;
		}

	}

	//----------------sqft param validation
	if($("minPSize"))
	{
		var sqftMin = Number($("minPSize").value);
		var sqftMax = Number($("maxPSize").value);
		if(sqftMin>sqftMax && sqftMax != 0)
		{			
			$('minPSize').focus();
			alert("Please select valid range for square feet");
			return false;
		}
	}	
    //----------------Lot Size  param validation       
	/*
	if($("minLotSize") && $("maxLotSize"))
	{
			var lotMin = Number($("minLotSize").value);
			var lotMax = Number($("maxLotSize").value);
			if(lotMin>lotMax && lotMin != '0' && lotMax != '0' )
			{					
					$('minLotSize').focus();
					alert("Please select valid range for Lot size");
					return false;
			}
	}
	*/
	//----------------listdate param validation
	if($("RStxtLFDate") && $("RStxtLTDate"))
	{
		if(trim($("RStxtLFDate").value) != "" && trim($("RStxtLTDate").value) != "")
		{
			var valLFDate = $("RStxtLFDate").value;
			var arrLFDate = valLFDate.split("-");		
			var objLFDate = new Date();
			objLFDate.setYear(arrLFDate[2]);
			objLFDate.setMonth(arrLFDate[0]);
			objLFDate.setDate(arrLFDate[1]);
			var tsLFDate = objLFDate.getTime()
			var valLTDate = $("RStxtLTDate").value;
			var arrLTDate = valLTDate.split("-");		
			var objLTDate = new Date();
			objLTDate.setYear(arrLTDate[2]);
			objLTDate.setMonth(arrLTDate[0]);
			objLTDate.setDate(arrLTDate[1]);
			var tsLTDate = objLTDate.getTime()
			if(tsLFDate > tsLTDate)
			{
				alert("To date should not be less than From date.");
				$('RStxtLFDate').value = '';
				$('RStxtLTDate').value = '';
				return false;
			}
		}
	}
	//----------------
	qryStrHash['minprice']		= minP;
	qryStrHash['maxprice']		= maxP;
	setSearchCookie("minPrice",minP);
	setSearchCookie("maxPrice",maxP);
	
	qryStrHash['beds']	= $F('searchBeds');
	setSearchCookie("searchBeds",$F('searchBeds'));	
	
	qryStrHash['baths']	= $F('searchBaths');
	setSearchCookie("searchBaths",$F('searchBaths'));
	
	//qryStrHash['searchType']	= $F('searchType');		
	qryStrHash['searchType'] = getAllCheckedPropType("value").replace(/:-:/g, ",");	
	
	/* for power search multiple property type handling */
	/*var selIndex = $('searchType').selectedIndex;
	if(selIndex == -1)
	{
		$('searchType').selectedIndex = 0;
	}*/

	//qryStrHash['searchTypeText']	= $('searchType').options[$('searchType').selectedIndex].text;
	qryStrHash['searchTypeText'] = getAllCheckedPropType("key").replace(/_/g, " ");
	
	setSearchCookie("searchType", getAllCheckedPropType("value"));
	setSearchCookie("searchTypeText",qryStrHash['searchTypeText']);
	
	displayPropType();
	
	qryStrHash['searchCriteria'] = $F('bit_select_box');
	setSearchCookie("searchCriteria",$F('bit_select_box'));
	setSearchCookie("keywordSrch",($("keywordSrch"))?$F("keywordSrch")==""?"":$F("keywordSrch"):"");
	setSearchCookie("minPSize",($("minPSize"))?$F("minPSize")==0?"":$F("minPSize"):"");	
	setSearchCookie("maxPSize",($("maxPSize"))?$F("maxPSize")==0?"":$F("maxPSize"):"");
	qryStrHash['minsqft'] = $F("minPSize");
	qryStrHash['maxsqft'] = $F("maxPSize");	
	if($("keywordSrch"))
		qryStrHash['keywordSrch'] = $F("keywordSrch");	
	
	/*
	if($("minLotSize") && $("maxLotSize"))
	{
		setSearchCookie("minLotSize",($("minLotSize"))?$F("minLotSize")==""?"":$F("minLotSize"):"");
		setSearchCookie("maxLotSize",($("maxLotSize"))?$F("maxLotSize")==""?"":$F("maxLotSize"):"");
		qryStrHash['minLotSize'] = $F("minLotSize");
		qryStrHash['maxLotSize'] = $F("maxLotSize");
	}
	*/
	//-------------------- TPL PARAMS ------------START--------//
	var addtionalThemeParam = getSearchTemplateParam ();
	if (addtionalThemeParam != null)
	{
		var setAdditionalParamCookie = addtionalThemeParam['setcookie'];
		addtionalThemeParam.remove ('setcookie');
		addtionalThemeParam.each(function(pair)
		{				
			qryStrHash[pair.key]=pair.value;
			setSearchCookie(pair.key,pair.value);
		});
	}	
	//-------------------- TPL PARAMS ------------END--------//	
	var lfDate = ''; var ltDate = '';	
	if($F('bit_select_box') == 'newListing') 
	{
		$("RStxtLFDate").value = listDate1;
		$("RStxtLTDate").value = listDate2;
	}
	else
	{
		lfDate = ''; ltDate = '';
		$("RStxtLFDate").value = '';
		$("RStxtLTDate").value = '';		
	}
	setSearchCookie("ckLFDate",($("RStxtLFDate"))?($F("RStxtLFDate")):"");
	setSearchCookie("ckLTDate",($("RStxtLTDate"))?($F("RStxtLTDate")):"");	

	var tempDate = escape(trim(getSearchCookie("ckLFDate")));	
	if (tempDate != "")
	{
		var arrTempDate = tempDate.split ("-");
		lfDate = arrTempDate[2] + "-" + arrTempDate[0] + "-" + arrTempDate[1];
		qryStrHash['lfDate'] = lfDate;
	}
	tempDate = escape(trim(getSearchCookie("ckLTDate")));	
	if (tempDate != "")
	{
		var arrTempDate = tempDate.split ("-");
		ltDate = arrTempDate[2] + "-" + arrTempDate[0] + "-" + arrTempDate[1];
		qryStrHash['ltDate'] = ltDate;
	}
	
	if($F('fromPage') == "galleryView")
		recordPerPage = galleryRecPerPage;
	else
		recordPerPage = propRecPerPage;

	qryStrHash['fromPage'] = $F('fromPage');
	if($('chkOpnHome')  && $('chkOpnHome').checked)
	{
			setSearchCookie("searchCriteria","brokeropenHome");
	}
	$('pagiVal').value = "0";
	$('highLowVal').value = "0";
	return true;
}

function loadFirstTime()
{	
	loadInCtrlFrmCookie();
	if(drawSearch)
	{
		window.setTimeout(function()
		{
			searchMap(); 
			if($('rightBorderTopIcons')) $('rightBorderTopIcons').className = "";
			if($("msgTable"))$("msgTable").className="";
			if($('helpBox')) { $('helpBox').show();}
		}, 1000);
		
	}
	else
	{
		doPropSearch();
	}
}

function sortProperty(sortBy)
{
	$('pagiVal').value=0;
	var sortStr = "";
	/*
	if($F('highLowVal') == "0" )
		sortStr = sortBy.value+"l";
	else
		sortStr = sortBy.value+"h";
	*/
	sortStr = sortBy.value;
	qryStrHash['searchSortType'] = sortStr;	
	setSearchCookie('searchSortType',sortStr);
	setUpDown();
}

function photoPaging(action,cntr,imgArrID)
{
	//alert("action:"+action+"Arr Len: "+imgArr[imgArrID].length+",id="+imgArrID);
	if((bkTheme == 'santafe' || bkTheme == 'sandia') && action == "prev" && cntr < 1 )// Continue slideshow
	{
		cntr = imgArr[imgArrID].length;
		x=eval('ctr'+imgArrID+'='+imgArr[imgArrID].length+';');
		//alert(x);
		eval('$(photoId'+imgArrID+').src="'+imgArr[imgArrID][x]+'";');
	}
	if(action == "prev" && cntr >= 1 )	
	{		
		x=eval('--ctr'+imgArrID+';');
		//alert(x);
		eval('$(photoId'+imgArrID+').src="'+imgArr[imgArrID][x]+'";');
	}
	else if(action == "next" && cntr < (imgArr[imgArrID].length-1) )	
	{	
		x=eval('++ctr'+imgArrID+';');
		//alert(x);
		eval('$(photoId'+imgArrID+').src="'+imgArr[imgArrID][x]+'";');
	}
	else
	{
		if(bkTheme == 'santafe' || bkTheme == 'sandia') // Continue slideshow, without any message
		{
			x=eval('ctr'+imgArrID+'=0;');
			//alert(x);
			eval('$(photoId'+imgArrID+').src="'+imgArr[imgArrID][x]+'";');
		}
		else
			alert("No more photos available");	
	}
}

function showPaging(totalRecords)
{	
	var pctr;
	var pagiText = " ";
	var pno = $F('pagiVal');
	pno = parseInt(pno);
	if(pno == '-1') pno = '0';		
	prev=pno-1;
	next=pno+1;	

	totalPage = totalRecords / recordPerPage;
	totalPage = Math.ceil(totalPage);
		
	sLimit = recordPerPage*pno + 1;
	sLimit = parseInt(sLimit);
	
	recordPerPage = parseInt(recordPerPage);
	eLimit = sLimit + recordPerPage-1;
	if(eLimit > totalRecords)
		eLimit = totalRecords;

	if(prev < 0) 
		prevImg = '<img src="'+imgThmPath+'common/arrow_left_deactive1.gif" />';		
	else
		prevImg = '<img class="crsr" src="'+imgThmPath+'common/arrow_left_active1.gif" onclick="javascript:goToPage(\'prev\');" title="Previous"/>';
	
	if(next >= totalPage) 
		nextImg = '<img src="'+imgThmPath+'common/arrow_right_deactive1.gif" />';
	else
		nextImg = '<img class="crsr" src="'+imgThmPath+'common/arrow_right_active1.gif" onclick="javascript:goToPage(\'next\');" title="Next"/>';
	
	//alert(sLimit + " === "+eLimit);
	//$("paginationDiv").innerHTML = '<table align="center" style="padding-left:10px;"><tr><td>'+prevImg+'</td><td class="pagiText" id="txtLimit"> &nbsp;&nbsp; '+ sLimit +' - '+ eLimit +' of '+totalRecords+' Results  &nbsp;&nbsp;</td><td>'+nextImg+'</td></tr></table>';
	//alert( sLimit +' - '+ eLimit +' of '+totalRecords);
	var pno1 = pno;
	if(totalPage - pno <= 4)
		pno1 =  parseInt(totalPage - 5);
		
	if(totalPage > 1)
	{
		var totPageStr = "'"+totalPage+"'";
		var totPageStrCnt = totPageStr.length-2;
		var pagiEnd  = 3;		
		if(totPageStrCnt > 3)
			pagiEnd  = 2;		
		for(pctr = pno1; pctr <= (pno1+pagiEnd); pctr++)
		{		pctr=parseInt(pctr);
				if(pctr >= 0 && pctr < totalPage)
				{
					var stlTag = 'class=""';
					if(pctr == pno)
						stlTag = 'class="pageSelected"';

					pagiText += '<a href="javascript:void(0)" onclick="javascript:$(\'pagiVal\').value='+pctr+';setUpDown();"'+stlTag+' >'+(pctr+1)+'</a>';
				}
				pagiText += " ";
		}
		var stlTag = 'class=""';
		if((totalPage-1) == pno)
			stlTag = 'class="pageSelected"';
		pagiText += "... "+'<a href="javascript:void(0)" onclick="javascript:$(\'pagiVal\').value='+(totalPage-1)+';setUpDown();" '+stlTag+'>'+totalPage+'</a> ';
	}
	$("paginationDiv").innerHTML = '<table align="center" style="padding-left:10px;"><tr><td>'+prevImg+'</td><td class="listPrice" id="txtLimit"> &nbsp;'+ pagiText +'&nbsp;</td><td>'+nextImg+'</td></tr></table>';
	$('paginationDiv').style.display="inline";
	
	$('botPagiRow').innerHTML = $('paginationDiv').innerHTML;
	if(totalPage > 1 && $('paginationDiv'))
	{
		$('paginationDiv').show();
		$('botPagiRow').show();
	}
	else
	{
		$('paginationDiv').hide();
		$('botPagiRow').hide();
	}
}

function goToPage(action)
{	
	var pno = $F('pagiVal');
	if(action == "goToPage")
	{
		pno = trim($("txtGoToPage").value);

		if(pno == "")
		{
			alert("Please enter page no.");			
			return;
		}
		else if(isNaN(pno) || pno.include("."))
		{
			alert("Please enter valid page no.");
			$("txtGoToPage").value = "";
			return;
		}
		else if(pno == "0")
		{
			alert("Please enter valid page no.");
			$("txtGoToPage").value = "";
			return;
		}

		pno = parseInt(pno.replace(/^[0]+/g,""));
		$("txtGoToPage").value = pno;
		if(typeof(totalPage) == "undefined" || totalPage == 0)
		{
			alert("Please perform search again.");
			$("txtGoToPage").value = "";
			return;
		}
		else if(pno <=0 || pno > totalPage)
		{
			alert("Please enter page no. between 1 to "+totalPage+".");
			$("txtGoToPage").value = "";
			return;
		}
		pno--;	
	}
	pno = parseInt(pno);	
	if(action == 'prev' && pno > 0)	
		pno--; 	
	else if(action == 'next' && pno < totalPage)	
		pno++; 			
    $('pagiVal').value = pno;
	
	setUpDown();	
}

function showDiv(id)
{	
	switch(id)
	{
		case 'divEmailSaveSearch': 
			{
				if($(id).style.display != 'none')
					$(id).style.display = 'none';
				else
					$(id).style.display = '';
			}
			break;		
	}
}

//For Price/Status Alert
function savePrStAlert()
{
	var agentId		= "";
	var alertFreq	= "";

	if(chkAlertStatus == "priceAlert")
	{
		if($('nfySrchElrChkBox') && $('nfySrchElrChkBox').checked)
			alertFreq += "Active=1";
		else 
			alertFreq += "Active=0&refineSearch=1";

		alertFreq	+= "&fromAlert=price";
	}
	else if(chkAlertStatus == "statusAlert")
	{
		if($('nfySrchElrChkBox') && $('nfySrchElrChkBox').checked)
			alertFreq += "Active=2";
		else 
			alertFreq += "Active=0&refineSearch=1";

		alertFreq	+= "&fromAlert=status";
	}
	else
	{
		alertFreq = "Active=0";	
	}
	
	if(trim($("txtSrchNm").value) == "")
	{
		alert("Please give name to your search.");
		if($("txtSrchNm")) $("txtSrchNm").focus();
		return;
	}

	var qs = new Querystring();		
	if(qs.get("frm") != null && qs.get("aid") != null)
		agentId = '&aid='+ trim(qs.get("aid"));

	var cUrl 	 = "/app/mlsPropertyAlert/propertyFinder.php";
	var queryStr = alertFreq + "&MlsNo=" + alertMlsNo + "&terabitzId=" + alertTid + "&priceAlert=" + alertPrice + "&statusAlert=" + alertStatus + agentId + "&SrchNm="+ escape($('txtSrchNm').value);
	queryStr += '&Address=' + escape(alertAddress) + '&City=' + alertCity + '&State=' + alertState + '&Zip='+ alertZip;
	ajaxRequest(cUrl,queryStr,prStCallBack,false);
}

function prStCallBack(reqObj)
{
	var response1 = trim(reqObj.responseText);
	if(response1.indexOf("=^^=") != -1)
	{
		var allResponse  = response1.split("=^^=");
		if(allResponse[3] != "" && typeof(allResponse[3]) != 'undefined')
		{
			alert("Your search has been saved successfully.");
			$("txtSrchNm").value="";
			showHideDiv('divEmailSaveSearch');
			return;
		}
	}
	else
	{
		alert("Your search has been saved successfully.");
		return;
	}
}

function saveMarketReportSearch()
{
	var cUrl 	 = "/app/mlsPropertyAlert/marketReportFinder.php";
	var queryStr = "marketReport=1&SrchNm="+trim($F('txtSrchNm1'));
	var qs = new Querystring();
	var nhood = "";
	var agentId = "";
	if(qs.get('nhood') != "" )
	nhood = qs.get('nhood');	
	queryStr += "&Neighbourhood="+nhood;

	var qs = new Querystring();		
	if(qs.get("frm") != null && qs.get("aid") != null)
		agentId = '&aid='+ trim(qs.get("aid"));

	queryStr += agentId;
	
	if($('dailyChkBox') && $('dailyChkBox').checked && $('divEmailSaveSearch1').visible())
		queryStr += "&Active=1";
	else if($('WeeklyChkBox') && $('WeeklyChkBox').checked && $('divEmailSaveSearch1').visible())
		queryStr += "&Active=2";
	else
		queryStr += "&Active=0";

	ajaxRequest(cUrl,queryStr,function(r)
	{
		var rsText = r.responseText;
		if(rsText != "FAIL")
		{
			alert('Market report alert created successfully');
		}
	},false);
}

function saveEmailAlert()
{
	var srchNmId = "txtSrchNm1";
	var agentId="";
	var qs = new Querystring();
	
	if(qs.get("frm") != null && qs.get("aid") != null)
		agentId = '&aid='+ trim(qs.get("aid"));

	var cUrl 	 = "/app/mlsPropertyAlert/propertyFinder.php";
	var queryStr = "MlsNo=" + propMlsNo;	

	if($('dailyChkBox') && $('dailyChkBox').checked)
		queryStr += "&Active=1";
	else if($('WeeklyChkBox') && $('WeeklyChkBox').checked)
		queryStr += "&Active=2";
	
	queryStr += agentId + "&SrchNm="+ escape($(srchNmId).value);
	queryStr += '&Address='+ escape(propMlsAddr);
	ajaxRequest(cUrl,queryStr,alertCallBackfn,false); 
}

//For Mls Propery Alert
function saveRefineSearch(share)
{
	var forShare = "0";
	if (typeof(share) != "undefined" && share == "1")
		forShare = "1";
	
	var srchNmId = "txtSrchNm";
	if(chkAlertStatus == "all" || chkAlertStatus == "homeEmailAlert" || fromMarketReport)
		srchNmId = "txtSrchNm1";

	var agentId="";
	if(trim($(srchNmId).value) == "" && forShare != "1")
	{
		alert("Please give name to your search.");		
		if($(srchNmId) && $(srchNmId).style.display != "none") $(srchNmId).focus();
		return;
	}

	// Call Open Home Function
	if(typeof(fromOpenHome) != "undefined" && fromOpenHome == "1")
	{
		saveRefineSearchOH();
		return;
	}

	// Call Development Function
	/*if(typeof(fromDevelopment) != "undefined" && fromDevelopment == "1")
	{
		saveDevelopmentSearch();
		return;
	}*/	
	
	// Call Market Report Alert
	if(typeof(fromMarketReport) != "undefined" && fromMarketReport == "1")
	{
		saveMarketReportSearch();
		emlSaveSearchDlg.hide();
		return;
	}

	//Call For Price/Status Alert
	if(chkAlertStatus == "priceAlert" || chkAlertStatus == "statusAlert")
	{
		savePrStAlert();
		emlSaveSearchDlg.hide();
		return;
	}

	//Call For Homesite Email Alert
	if(chkAlertStatus == "homeEmailAlert")
	{
		saveEmailAlert();
		emlSaveSearchDlg.hide();
		return;
	}	
	
	if(validateRSCriteriaNew())
	{
		var qs = new Querystring();		
		if(qs.get("frm") != null && qs.get("aid") != null)
			agentId = '&aid='+ trim(qs.get("aid"));

		var cUrl 	 = "/app/mlsPropertyAlert/propertyFinder.php";
		var queryStr = "MlsNo=" + $("mlsno").value + '&area=' + $('txtArea').value + '&polygon=' + $("txtPolygon").value;

		//Selection On Search
		if($F('selVal') == 'NBR')
			queryStr += '&Neighbourhood=' + qryStrHash['neighborhood'];
		else if($F("selVal").indexOf("SNBR") != -1)
			queryStr += '&SubNHoodName=' + qryStrHash['subNhood'].replace(/\&/g,'_') + '&SubNHoodId=' + qryStrHash['subNhoodId'];	
		else
			queryStr += '&Address='+ escape(qryStrHash['address']) + '&City=' + qryStrHash['city'] + '&State=' + qryStrHash['state'] + '&Zip='+ qryStrHash['zip'] + '&Latitude=' + qryStrHash['propLatitude'] + '&Longitude=' + qryStrHash['propLongitude'];
				
		/*if($('searchType').options[$('searchType').selectedIndex].text == "Any")
			queryStr += "&PropertyType=";
        else
            queryStr += "&PropertyType=" + $('searchType').options[$('searchType').selectedIndex].text;*/
		
		queryStr += "&PropertyType="+getAllCheckedPropType("key").replace(/_/g, " ");
		
		if(getSearchCookie("searchBeds") != "")
			queryStr += "&minBeds=" + getSearchCookie("searchBeds");

		if(getSearchCookie("searchBaths") != "")
			queryStr += "&minBaths=" + getSearchCookie("searchBaths");		

		if(getSearchCookie("minPrice") != "")
			queryStr += "&minPrice=" + getSearchCookie("minPrice");

		if(getSearchCookie("maxPrice") != "")
			queryStr += "&maxPrice=" + getSearchCookie("maxPrice");

		if(getSearchCookie("minPSize") != 0)
			queryStr += "&minSqFt=" + getSearchCookie("minPSize");

		if(getSearchCookie("maxPSize") != 0)
			queryStr += "&maxSqFt=" + getSearchCookie("maxPSize");

		if(typeof(nbrStoreArr) == "object" && nbrStoreArr.length > 0)
		{		
			var nbrString = cmImplodeArr(nbrStoreArr,",");
			queryStr += "&mul_nbrhood=" + nbrString;
			qryStrHash['mul_nbrhood'] = nbrString;				
			setSearchCookie("mul_nbrhood",nbrString);			
		}
		
		// Template Specific Code
		var addtionalThemeParam = getListingSearchTemplateParam ();
		if (addtionalThemeParam != null)
		{
			var setAdditionalParamCookie = addtionalThemeParam['setcookie'];
			addtionalThemeParam.remove ('setcookie');

			addtionalThemeParam.each(function(pair)
			{				
				queryStr += '&' + pair.key + '=' + pair.value;
			});
		}
		// Template Specific Code
		
		// Template Specific Code
		var addtionalThemeParam = getSearchTemplateParam ();
		if (addtionalThemeParam != null)
		{
			addtionalThemeParam.each(function(pair)
			{				
				queryStr += '&' + pair.key + '=' + pair.value;
			});		
		}
		// Template Specific Code

		//For Keyword Search
		if($("keywordSrch") && $F("keywordSrch") != "")
		{
			queryStr += "&KeyWordSrch=" + $F("keywordSrch");
		}

		//For Sorting
		if(qryStrHash['searchSortType'] == "ph")
			queryStr += "&sort=CURR_LISTPRICE&sortType=DESC";
		else if(qryStrHash['searchSortType'] == "pl")
			queryStr += "&sort=CURR_LISTPRICE&sortType=ASC";
		else if(qryStrHash['searchSortType'] == "brh")
			queryStr += "&sort=BEDS&sortType=DESC";
		else if(qryStrHash['searchSortType'] == "brl")
			queryStr += "&sort=BEDS&sortType=ASC";
		else if(qryStrHash['searchSortType'] == "bah")
			queryStr += "&sort=BATHS&sortType=DESC";
		else if(qryStrHash['searchSortType'] == "bal")
			queryStr += "&sort=BATHS&sortType=ASC";
		else if(qryStrHash['searchSortType'] == "sqfth")
			queryStr += "&sort=AREASQFT&sortType=DESC";
		else if(qryStrHash['searchSortType'] == "sqftl")
			queryStr += "&sort=AREASQFT&sortType=ASC";	

		if($('divEmailSaveSearch').visible())
		{
			if($('nfySrchElrChkBox') && $('nfySrchElrChkBox').checked)
				queryStr += "&Active=1";
			else
				queryStr += "&refineSearch=1&Active=0";
		}
		else if($('dailyChkBox') && $('dailyChkBox').checked && $('divEmailSaveSearch1').visible())
			queryStr += "&Active=1";
		else if($('WeeklyChkBox') && $('WeeklyChkBox').checked && $('divEmailSaveSearch1').visible())
			queryStr += "&Active=2";
		else
			queryStr += "&refineSearch=1&Active=0";

		 queryStr += "&forShare="+forShare;

		 if(forShare == 1 && typeof(qryStrHash['fromPage']) != "undefined" && qryStrHash['fromPage'] != "")
		{
			 queryStr += "&defView="+qryStrHash['fromPage'];
			 queryStr += "&listingType="+getSearchCookie("searchCriteria")
		}		

		queryStr += agentId + "&SrchNm="+ escape($(srchNmId).value);
		ajaxRequest(cUrl,queryStr,alertCallBackfn,false); 
	}
}

function alertCallBackfn(reqObj)
{
	var response1 = trim(reqObj.responseText);	
	var shareIdx = response1.indexOf ("=");
	var shareStr = "";
	if (shareIdx >= 0)
		shareStr = response1.substring (0, shareIdx);

	if (shareStr == "share")
	{
		$('shareEmailEnable').style.display = 'block';
		$('shareEmailDisable').style.display = 'none';

		$('txtGeneratedUrl').style.display = "block";
		$('urlGenerate').style.display = "none";
		$('txtGeneratedUrl').style.width="390px";
		$('txtGeneratedUrl').value = response1.substring (shareIdx+1, response1.length);
		return;
	}
	
	if(response1.indexOf("=^^=") != -1)
	{
		var allResponse  = response1.split("=^^=");
		response1	= allResponse[0];		
	}

	if(trim(response1) == "SUC")
	{
    	alert("Email Alert Saved Successfully.");
		if(typeof(fbApiKey) != "undefined" && fbApiKey != "" && typeof(userCCno) != "undefined" && userCCno != "")
		{
			var url = '/app/user/userProcess.php';
			var qs = "action=getFBUser";
			
			ajaxRequest(url,qs,function(req){
				var resp = trim(req.responseText);
				var respArr = eval('('+resp+')');				
				if(respArr['fbEnable'] == "1")
				{
					var resp = trim(reqObj.responseText);	
					var alertId = "";
					if(resp.indexOf("=^^=") != -1)
					{
						var allResp  = resp.split("=^^=");
						if(allResp[4] != "" && typeof(allResp[4]) != 'undefined')
							alertId = allResp[4];	
					}					

					var respHash = $H();
					respHash["action"] = "emailalert";
					respHash["orgName"] = respArr['orgName'];
					respHash["domain"] = respArr['domain'];
					respHash["theme"] = respArr['theme'];
					respHash["logo"] = respArr['logo'];
					respHash["href"] = "http://"+location.host+"/app/mlsPropertyAlert/propertySearchMapit.php?sid="+alertId+"&frmbk=1";

					showFeedDialog(respHash);
				}
			});			
		}
   	}
	else if(trim(response1) != "")
	{
		alert(response1);
		if(typeof(fbApiKey) != "undefined" && fbApiKey != "" && typeof(userCCno) != "" && userCCno != "")
		{
			var url = '/app/user/userProcess.php';
			var qs = "action=getFBUser";
			
			ajaxRequest(url,qs,function(req){
				var resp = trim(req.responseText);
				var respArr = eval('('+resp+')');				
				if(respArr['fbEnable'] == "1")
				{
					var resp = trim(reqObj.responseText);	
					var alertId = "";
					if(resp.indexOf("=^^=") != -1)
					{
						var allResp  = resp.split("=^^=");
						if(allResp[1] != "" && typeof(allResp[1]) != 'undefined')
							alertId = allResp[1];	
					}					

					var respHash = $H();
					respHash["action"] = "savedSearch";
					respHash["orgName"] = respArr['orgName'];
					respHash["domain"] = respArr['domain'];
					respHash["theme"] = respArr['theme'];
					respHash["logo"] = respArr['logo'];
					respHash["href"] = "http://"+location.host+"/app/mlsPropertyAlert/propertySearchMapit.php?sid="+alertId+"&frmbk=1";

					showFeedDialog(respHash);
				}
			});			
		}
	}
	else
   	{
   		alert("Email Alert can not be saved.\nCheck user or agent/broker email address");
   	}
	
	$("txtSrchNm").value="";
	$("txtSrchNm1").value="";
	//showHideDiv('divEmailSaveSearch');
	emlSaveSearchDlg.hide();
}

function showHideDiv(divID)
{
	if($(divID))
	{
		if($(divID).style.display != 'none')
			$(divID).style.display = 'none';
		else
			$(divID).style.display = 'inline';
	}
}

function extendMap(view)
{	
	currView = view;
	if(view == "l")
	{
		$('polygonDiv').show();
		qryStrHash['fromPage'] = "mapView";
		if($('photoId0'))
			lastView = 'galleryView';
		else
			lastView = 'listView';

		$('fromPage').value = "mapView";
		/*
		$("mapMainDiv").style.top = "6px";
		$("mapMainDiv").style.left = "12px";
		$("mapMainDiv").style.height = "350px";
		$("mapDiv").style.height = "320px";
		$("mapMainDiv").style.width =  $("mapDivHeader").style.width = $("mapDiv").style.width = "974px";
		$("mapMainDiv").style.position = "relative";
		*/
		$("mapMainDiv").className = "mapMainDivBig";
		$("mapDiv").className = "mapDivBig";
		$("mapDivHeader").className = "mapDivHeaderBig mapDivHeader";
		
		$("rightBorderTopIcons").className="";
		if($("msgTable"))$("msgTable").className="";
		$('lrgMap').style.display="none";
		$('smlMap').style.display="";		
		$('spacerRow').style.height="10px";
		$('mainContainerTbl').style.width="62%";		
		//$('apiDiv').style.top="-5px";
	}
	if(view == "s")
	{	
		if(getSearchCookie("polygon") != "")
			$('polygonDiv').show();
		else
			$('polygonDiv').hide();
		qryStrHash['fromPage'] = lastView;
		$('fromPage').value = lastView;		
		
		/*$("mapMainDiv").style.position = "absolute";
		$("mapMainDiv").style.top = "101px";
		$("mapMainDiv").style.left = "663px";
		$("mapDiv").style.height = "320px";
		$("mapDiv").style.width = "323px";
		$("mapMainDiv").style.width = $("mapDivHeader").style.width = "323px";*/
		$("mapMainDiv").className = "mapMainDivSmall";
		$("mapDiv").className = "mapDivSmall";
		$("mapDivHeader").className = "mapDivHeaderSmall mapDivHeader";
		
		$('smlMap').style.display="none";
		$('lrgMap').style.display="";		
		$('spacerRow').style.height="370px";
		$('mainContainerTbl').style.width="65%";
		$("rightBorderTopIcons").className="mainsrchBoxLeft";
		if($("msgTable"))$("msgTable").className="mainsrchBoxLeft";
		//$('apiDiv').style.top="45px";
	}
	makeTabActive(qryStrHash['fromPage']);
	if(typeof(map2) != "undefined") map2.checkResize();
	if(typeof(map2) != "undefined") map2.setCenter(mapCenter, map2.getZoom());
	//map2 = undefined;
	//loadOnMap(mapData);									
	$("mapDiv").show();
	$('menumtctl_main').style.visibility = "visible";
	//loadLocalBitArr();
}

function findElementPos(obj) 
{
	var curleft = obj.offsetLeft || 0;
	var curtop = obj.offsetTop || 0;
	while (obj = obj.offsetParent) 
	{
		curleft += obj.offsetLeft
		curtop += obj.offsetTop
	}
		return {x:curleft,y:curtop};
}

function loadInCtrlFrmCookie()
{		
	setCookieTemplateParam();	
	if(trim(getSearchCookie("searchCriteria")) != "")
	{
		$('bit_select_box').value = trim(getSearchCookie("searchCriteria"));		
	}	
	if(trim(getSearchCookie("subNhoodId")) != "")
	{		
		$('selVal').value = "SNBR_"+trim(getSearchCookie("subNhoodId"));		
		$('RSsearchCSZ').value = trim(getSearchCookie("subNhood")).replace(/\\/g, '');
		$('txtArea').value = trim(getSearchCookie("area"));		
		var decodedPolyStr = decodeStrToPolygon(trim(getSearchCookie("polygon")));
		$('txtPolygon').value = decodedPolyStr;
	}
	else if(trim(getSearchCookie("neighborhood")) != "" && trim(getSearchCookie("multiNbr")) != "1")
	{		
		$('selVal').value = "NBR";
		$('neighborhood').value = $('RSsearchCSZ').value = trim(getSearchCookie("neighborhood"));
	}
	else if(trim(getSearchCookie("city")) != "")
	{
		var ckCSZ = trim(getSearchCookie("city"));
		if(trim(getSearchCookie("state")) != "")
			ckCSZ += ", "+trim(getSearchCookie("state"));

		if(trim(getSearchCookie("zip")) != "")
			ckCSZ = trim(getSearchCookie("zip"));

		$('RSsearchCSZ').value = ckCSZ;
		$('city').value = trim(getSearchCookie("city"));
		$('state').value = trim(getSearchCookie("state"));
		$('zip').value = trim(getSearchCookie("zip"));
		$('lat').value = trim(getSearchCookie("lat"));
		$('lng').value = trim(getSearchCookie("lng"));
		$('selVal').value = "CS";
	}	 
	else if(trim(paramCSZ) != "" && trim(paramCSZ) != ",")
	{
		$('RSsearchCSZ').value = trim(paramCSZ);
	}
	else if(trim(getSearchCookie("multicity")) != "" || trim(getSearchCookie("multizip")) != "")
	{
		if(trim(getSearchCookie("multicity")) != "")
			$('RSsearchCSZ').value = trim(getSearchCookie("multicity"));
		else
			$('RSsearchCSZ').value = trim(getSearchCookie("multizip"));
	}
	else
	{		
		$('RSsearchCSZ').value = defCSZ;
	}

	if(trim(getSearchCookie("searchSortType")) != "")
	{
		$('sortProp').value = trim(getSearchCookie("searchSortType"));
	}

	if(trim(getSearchCookie("address")) != "")
	{
		var addrStr = unescape(trim(getSearchCookie("address")));
		addrStr = addrStr.replace(/%20/g, " ");
		$('address').value = addrStr;
	}
	if(trim(getSearchCookie("polygon")) != "")
	{
		$("chkPolySearch").checked = true;
		$("drawSerArea").style.display = "none";		
		$("clrSerArea").style.display = "";	
		var decodedPolyStr = decodeStrToPolygon(trim(getSearchCookie("polygon")));		
		$('txtPolygon').value = decodedPolyStr;
	}
	if(trim(getSearchCookie("area")) != "")
	{
		$("chkPolySearch").checked = true;
		$("drawSerArea").style.display = "none";		
		$("clrSerArea").style.display = "";	
		$('txtArea').value = trim(getSearchCookie("area"));
	}
	if(trim(getSearchCookie("searchBeds")) != "")
	{
		$('searchBeds').value = trim(getSearchCookie("searchBeds"));
	}
	if(trim(getSearchCookie("searchBaths")) != "")
	{
		$('searchBaths').value = trim(getSearchCookie("searchBaths"));
	}
	if(trim(getSearchCookie("minPrice")) != "")
	{
		$('minprice').value = trim(getSearchCookie("minPrice"));
	}
	if(trim(getSearchCookie("maxPrice")) != "")
	{
		$('maxprice').value = trim(getSearchCookie("maxPrice"));
	}
	if(trim(getSearchCookie("searchType")) != "")
	{
		checkAllPropType();
	}
	if(trim(getSearchCookie("mlsno")) != "" && $('mlsno'))
	{
		$('mlsno').value = trim(getSearchCookie("mlsno"));
	}
	if(trim(getSearchCookie("minPSize")) != "" && $('minPSize'))
	{
		$('minPSize').value =  trim(getSearchCookie("minPSize"));
	}
	if(trim(getSearchCookie("maxPSize")) != "" && $('maxPSize'))
	{
		$('maxPSize').value =  trim(getSearchCookie("maxPSize"));
	}
	if(trim(getSearchCookie("keywordSrch")) != "" && $('keywordSrch'))
	{
		$('keywordSrch').value =  trim(getSearchCookie("keywordSrch"));
	}

	/*
	if(trim(getSearchCookie("minLotSize")) != "" && $('minLotSize') )
	{
		$('minLotSize').value =  trim(getSearchCookie("minLotSize"));
	}
	if(trim(getSearchCookie("maxLotSize")) != "" && $('maxLotSize'))
	{
		$('maxLotSize').value =  trim(getSearchCookie("maxLotSize"));
	}	
	*/
}

function makeTabActive(actView)
{
	$('galleryTab').src = "/wt/"+bkTheme+"/images/common/galleryView.gif";
	$('mapTab').src = "/wt/"+bkTheme+"/images/common/mapView.gif";
	$('listTab').src = "/wt/"+bkTheme+"/images/common/listView.gif";
	switch(actView)
	{
		case 'listView':
						$('listTab').src = "/wt/"+bkTheme+"/images/common/listview_sel.gif";						
						break;
		case 'galleryView':
						$('galleryTab').src = "/wt/"+bkTheme+"/images/common/galleryview_sel.gif";		
						break;
		case 'mapView':
						$('mapTab').src = "/wt/"+bkTheme+"/images/common/mapview_sel.gif";		
						break;				
	}
}


function viewDetails(link)
{
	window.open(link,"_blank");
}
//********START***************** LIST SEARCH MORE OPTION BUTTON SLIDING ANIMATION DIV ******************//
var hgtMoreOpt=0;
function openMoreOption()
{	
	var moreOptDivObj = $('moreOptTbl');
	var hgt = moreOptDivObj.style.height;
	hgt = parseInt(hgt);	
	if(hgt == 0)
		expandMoreOpt(hgt,maxMoreOpt);
	else
		collapseMoreOpt();
}
function expandMoreOpt()
{  
   var divObj = $('moreOptTbl');  
   if(hgtMoreOpt != maxMoreOpt)
   {
     hgtMoreOpt+=25;
     divObj.style.height = hgtMoreOpt+'px';	
     window.setTimeout("expandMoreOpt();", 1);
   }
   divObj.style.display="";
   if(hgtMoreOpt == maxMoreOpt)
   {
	 //$("imgMoreSearchOpt").src = "/wt/"+bkTheme+"/images/common/closeSearchOpt.gif";
	 $('moreOptDiv').innerHTML = "Close Expanded Search";
   }
}

function collapseMoreOpt()
{
   var divObj = $('moreOptTbl');
   hgtMoreOpt = divObj.style.height;
   hgtMoreOpt = parseInt(hgtMoreOpt);
   if(hgtMoreOpt != 0)
   {
     hgtMoreOpt-=25;
     divObj.style.height = parseInt(hgtMoreOpt)+'px';	
     window.setTimeout("collapseMoreOpt();", 1);
   }
   divObj.style.display="";
   if(hgtMoreOpt == 0) 
   {
	   divObj.style.display="none";
	  //$("imgMoreSearchOpt").src = "/wt/"+bkTheme+"/images/common/moreSearchOpt.gif";
	  $('moreOptDiv').innerHTML = "Expanded Search";
   }
}
//********END***************** LIST SEARCH MORE OPTION BUTTON SLIDING ANIMATION DIV ******************//

function searchMap(event)
{
	if(typeof(setMapZoomOutLimit) != "undefined")
		setMapZoomOutLimit = 1;
	/*var searchCSZ = trim($F('RSsearchCSZ'));
	if(searchCSZ == "" || $F('selVal') == "NBR")
	{
		alert('Please enter city,state'); return false;
	}
	else
	{
		var retArray = doGeoCode(searchCSZ,'');
		if(!retArray) { $('RSsearchCSZ').className  = 'textboxRed'; $('RSsearchCSZ').focus(); return false; }
	}*/
	var lat = map2.getCenter().lat();
	var lng = map2.getCenter().lng();
	var latLongStr = "[{'lat':'"+lat+"','lng':'"+lng+"'}]";	
	var now = new Date();
	now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
	setCookie("latLongCk",latLongStr,now);	
	map2 = undefined;
	$("mapDivHeader").hide();
	/*$("mapMainDiv").style.top = "0px";
	$("mapMainDiv").style.left = "10px";
	$("mapMainDiv").style.height = "322px";
	$("mapDiv").style.height = "320px";
	$("mapMainDiv").style.width =  $("mapDivHeader").style.width = $("mapDiv").style.width = "978px";
	$("mapMainDiv").style.position = "relative";*/
	
	$("mapMainDiv").className = "mapMainDivDSBig";
	$("mapDiv").className = "mapDivDSBig";
	$("mapDivHeader").className = "mapDivHeaderDSBig mapDivHeader";
				
	$("mapDiv").show();
	if(typeof(polyRouteArr) != "undefined") 	polyRouteArr.clear();
	loadPolyMap();
	if($F('selVal') == "NBR")
	{
		getLatLngFrmNbr($F('RSsearchCSZ'))
		minimap.setCenter(new GLatLng(getSearchCookie("lat"), getSearchCookie("lng")));
	}
}
function getLatLngFrmNbr(name)
{	
		var url = '/info/subNbrHandler.php';
		var qs = 'case=getNbrFrmProp&nbrName='+name;	
		ajaxRequest(url,qs,function(r)
		{
			var rsText = r.responseText;
			if(rsText != "")
			{
				var latLngArr = rsText.split('~!@');
						var latLongStr = "[{'lat':'"+latLngArr[0]+"','lng':'"+latLngArr[1]+"'}]";
				var now = new Date();
				now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
				setCookie("latLongCk",latLongStr,now);
				setSearchCookie("lat",latLngArr[0]);
				setSearchCookie("lng",latLngArr[1]); 						
			}
		},false);
}
function clearMapList()
{
	pointswitch = false;
	if($('dist')) $("dist").style.display = "none";	
	$('txtArea').value='';
	$('txtPolygon').value='';
	removeSearchCookie('area');
	removeSearchCookie("polygon");
	polyRouteArr.clear();
	routePoints.clear();
	if(minimap) minimap.clearOverlays();
	
	$('clrSerArea').style.display='none';
	$('drawSerArea').style.display='';		
}

function checkMapSearch()
{
	if($("chkPolySearch").checked == false) clearMapList();
	$("drawSerArea").style.display = "";
	$("clrSerArea").style.display = "none";
}

function clearMapSearch()
{	
	if(typeof(setMapZoomOutLimit) != "undefined")
		setMapZoomOutLimit = 0;
	if($('mapMainDiv') && parseInt($('mapMainDiv').style.width) < 900)
	{
		extendMap('l');
	}
	$("chkPolySearch").checked = false;
	clearMapList();	
	$("drawSerArea").style.display = "";
	$("clrSerArea").style.display = "none";
	if($('mapDiv').className == "mapDivSmall")
	{
		$('polygonDiv').hide();
	}
}

function hideHelpBox()
{	
	$("helpBox").hide();
}

function cityResponseList(resp)
{	
	var cityResp = trim((resp.responseText)).split(",");
	geoCity = cityResp[0];
	geoState = cityResp[1];
	latitude = cityResp[2];
	longitude = cityResp[3];
	if(geoCity=="")
	{
		alert("Sorry, There are no listings for the selected region.");
		while(routePoints.length > 1)
		{
			routePoints.pop();
			plotRoute();
		}
		routePoints.clear();
		minimap.removeOverlay(startMarker);
	}
	else
	{
		if(trim($("txtArea").value) == "")
		{
			$("txtArea").value = tmpBound.toString();
			$("txtPolygon").value = routePoints.toString();
		}
		else 
		{
			if($("txtPolygon").value == "")
			{
				$("txtPolygon").value = rectToPoly($("txtArea").value);
			}
			$("txtArea").value += "|" +tmpBound.toString();
			$("txtPolygon").value += "|"+routePoints.toString();
		}
		lat = latitude;
   		lng = longitude;       
		var latLongStr = "[{'lat':'"+lat+"','lng':'"+lng+"'}]";
		var now = new Date();
		now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
		setCookie("latLongCk",latLongStr,now);
		removeSearchCookie('neighborhood');
		$('RSsearchCSZ').value = geoCity+', '+geoState;
		$('selVal').value='CS';
	}
	if($("chkPolySearch")) $("chkPolySearch").checked = true;
}

function hideMapList()
{	
	if(typeof(setMapZoomOutLimit) != "undefined")
		setMapZoomOutLimit = 0;
	if($("chkPolySearch") && $("chkPolySearch").checked)
	{		
		if($("drawSerArea").style.display != 'none') { var flgalert = true; }
		$("drawSerArea").style.display = "none";
		if(singlePoly) 
		{ 			
			removeSearchCookie("neighborhood");
			var polyEncodeStr = encodePolygonToStr(trim($F("txtPolygon")));
			setSearchCookie("polygon",polyEncodeStr);
			setSearchCookie("area",$F("txtArea"));						
		}
		$("clrSerArea").style.display = "";
	}		
	
	if($("chkPolySearch") && ($F("txtPolygon")!="" || $F("txtArea")!="")) $("chkPolySearch").checked = true;
	else if($("chkPolySearch"))	$("chkPolySearch").checked = false;		
	if(trim(getSearchCookie("polygon")) == "" || $F("txtPolygon") == "")
	{
		clearMapList();
	}
	if( getSearchCookie("polygon") == "" )
	{
		$('clrSerArea').style.display='none';
		$('drawSerArea').style.display='';	
	}	
	if($("helpBox")) $("helpBox").hide();	
	if($("mapHeader")) $("mapHeader").hide();		
	//if($("mapDiv")) $("mapDiv").hide();		
	if($('RSsearchCSZ') && trim($F('RSsearchCSZ')) == "" )
	{
		$('RSsearchCSZ').value = defCSZ;
		$('selVal').value = 'CS';
	}
	doPropSearch();
}

function setPosForEmailSaveSearch(fromPage,alertType,divId,cnt)
{
	if(typeof(cnt) == 'undefined') cnt = '';
	if(fromPage == "listing")
	{
		alertAddress = response[cnt].address;
		alertCity	= response[cnt].city;		
		alertState	= response[cnt].state;		
		alertZip	= response[cnt].zip;
		alertMlsNo	= response[cnt].mlsno;
		alertPrice	= response[cnt].price;
		alertStatus = response[cnt].status;
		alertTid	= response[cnt].terabitzid;
		chkAlertStatus = alertType;
	}
	else if(fromPage == "listingView")
	{
		alertAddress = response[cnt].address;
		alertCity	= response[cnt].city;		
		alertState	= response[cnt].state;		
		alertZip	= response[cnt].zip;
		alertMlsNo	= response[cnt].mlsno;
		alertPrice	= response[cnt].price;
		alertStatus = response[cnt].status;
		alertTid	= response[cnt].terabitzid;
		chkAlertStatus = alertType;			
	}
	else if(fromPage == "homeSite")
	{
		alertAddress = propMlsAddr;
		alertMlsNo	= propMlsNo;
		alertPrice	= propPrice;
		alertStatus = propStatus;
		alertTid	= propTid;
		chkAlertStatus = alertType;		
	}
	else
	{
		chkAlertStatus = "";
	}
	if(alertType == "all") chkAlertStatus = "all";
}
var myPriceParmObj = new Object();
function savePriceStatusAlert(fromPage,alertType,divId,cnt)
{	
	myPriceParmObj.fromPage = fromPage;
	myPriceParmObj.alertType = alertType;
	myPriceParmObj.divId = divId;
	myPriceParmObj.cnt = cnt;
	if(typeof(response) == 'undefined') response = [];	
	myPriceParmObj.response = response;
	$('txtSrchNm').value = $('txtSrchNm1').value = '';
	setPosForEmailSaveSearch(fromPage,alertType,divId,cnt);
	if($('divEmailSaveSearch')) $('divEmailSaveSearch').hide();	
	if(typeof(uid) == "undefined" || uid == "" || uid == null)
	{	
		if(alertType == 'marketReport')
		{	
			var qsObj = new Querystring();			
			var mrUrl = window.location.href;
			if(qsObj.get("updateFlg") == null) mrUrl += '&updateFlg=1';
			opensignInRegDlg(mrUrl,'R','','');
		}
		else
		{				
			var mrUrl = window.location.href;
			opensignInRegDlg(mrUrl,'R','','');
			/*
			if(typeof(SignInDlg) == "string" || typeof(SignInDlg) == "undefined" || SignInDlg == null)
			{
				if($('divSignInFrm')) 
				{ 				
					$('divSignInFrm').style.display = '';			
					if(typeof(createDialog) == "function")
						SignInDlg = createDialog('divSignInFrm');
				}
			}
			$('divSignInFrm').style.dispaly = 'block';
			$('userName').value = "";
			$('userPwd').value = "";
			$('userName').className="textbox";
			$('userPwd').className="textbox";
			$('errSysLogin').innerHTML="&nbsp;";
			if($("fromWhere")) $("fromWhere").value = "pricestatusAlert";			
			if($("signInRoloLnk")) $("signInRoloLnk").href  = '/app/auth/login.php';
			var qs = new Querystring();
			if(qs.get("frm") != null && qs.get("aid") != null && $("signInRoloLnk"))
				$("signInRoloLnk").href += "?agd="+trim(qs.get("aid"));
			roloUse = true;
			SignInDlg.show();
			*/
		}
	}
	else
	{	
		if($('divEmlSerHeader1')) $('divEmlSerHeader1').innerHTML = "Get email alerts";
		if($('divEmlSerHeader')) $('divEmlSerHeader').innerHTML = "Save This Search";

		if($('saveSerLabel')) $('saveSerLabel').innerHTML = "Name this search";
		if($('saveSerLabel1')) $('saveSerLabel1').innerHTML = "Name this search";
		if($('dailyWeeklySpan')) $('dailyWeeklySpan').innerHTML = "Send me email alerts for properties matching this search<br/><br/>";
		if($('dailyWeeklyRow')) $('dailyWeeklyRow').show();

		//showDiv('divEmailSaveSearch');
		//----FOLLOWING LINE IS FOR STORING LATEST SEARCH CRITERIA IN COOKIE----//
		if(cnt == "" && $('bit_select_box') && validateRSCriteriaNew() && ($('chkOpnHome')  && !$('chkOpnHome').checked)) 
		{		
			qryStrHash['grp']='';doPropSearch();
		}
		else if(cnt == "" &&$('bit_select_box') && ($('chkOpnHome')  && !$('chkOpnHome').checked))
		{			
			return; 			
		}
		else if(cnt == "" &&typeof(fromOpenHome) != "undefined" && fromOpenHome == "1" && chkOPCriteria()) 
		{
			chkOpenHousesArr = new Array();
			openHousesAddArr = new Array();
			getOpenHomes();
			getOpenHomes('1');
		}
		else if(cnt == "" && typeof(fromOpenHome) != "undefined" && fromOpenHome == "1" && cnt == "")
		{
			return; 
		}		
		var searchCrtStr = '';
		if(alertType == 'statusAlert' && fromPage != "homeSite")
		{	
			if($('divEmlSerHeader')) $('divEmlSerHeader').innerHTML = "Status alert";
			var addrStr = "";
			addrStr = response[cnt].address;
			if(response[0].unitno != "") addrStr += "#"+response[cnt].unitno;
			addrStr += ", "+response[cnt].city;
			addrStr += " "+response[cnt].state;
			addrStr += ", "+response[cnt].zip;
			searchCrtStr = "Having address:"+addrStr;
			
			if(response[cnt].mlsno.indexOf("PKT") != -1)
			{
				var tid = response[cnt].mlsno;
				tid = tid.substr(3,tid.length);
				searchCrtStr += " and terabitz id:"+tid;
				alertTid = tid;
				alertMlsNo = "";
			}
			else
			{
				searchCrtStr += " and mls no:"+response[cnt].mlsno;
			}
			searchCrtStr += "<br/><br/>You will receive an email alert if the status of this property changes.";
			if($('saveSerLabel')) $('saveSerLabel').innerHTML = "Name this alert";
		}
		else if(alertType == 'statusAlert' && fromPage == "homeSite")
		{				
			if($('divEmlSerHeader')) $('divEmlSerHeader').innerHTML = "Status alert";
			searchCrtStr = "Having address:"+propMlsAddr;
			
			if(propMlsNo != "" && source != "ENHANCEDLISTING" && source != "POCKETLISTING")
			{
				searchCrtStr += " and mls no:"+propMlsNo;
			}
			else
			{
				if(source == "POCKETLISTING")
				{
					searchCrtStr += " and terabitz id:"+propTid;
					alertTid = propTid;
					alertMlsNo = "";
				}
				else
				{
					if(propMlsNo != "" && source == "ENHANCEDLISTING")
					{
						searchCrtStr += " and mls no:"+propMlsNo;
						alertMlsNo = propMlsNo;
					}
					else
					{
						searchCrtStr += " and terabitz id:"+propTid;
						alertTid = propTid;
						alertMlsNo = "";
					}					
				}				
			}
			
			searchCrtStr += "<br/><br/>You will receive an email alert if the status of this property changes.";
			if($('saveSerLabel')) $('saveSerLabel').innerHTML = "Name this alert";
		}
		else if(alertType == 'all' && fromPage == "homeSite")
		{
			chkAlertStatus = "homeEmailAlert";
			searchCrtStr = "Having address:"+propMlsAddr;

			if(propMlsNo != "" && source != "ENHANCEDLISTING" && source != "POCKETLISTING")
			{
				searchCrtStr += " and mls no:"+propMlsNo;
			}
			else
			{
				if(source == "POCKETLISTING")
				{
					searchCrtStr += " and terabitz id:"+propTid;
					alertTid = propTid;					
				}
				else
				{
					searchCrtStr += " and terabitz id:"+propMlsNo;
					alertTid = propMlsNo;
				}
				alertMlsNo = "";
			}

			searchCrtStr += "<br/><br/>You will receive an email alert if the status of this property changes.";
		}
		else if(alertType == 'marketReport' && fromMarketReport)
		{			
			var qs = new Querystring();
			if($('divEmlSerHeader1')) $('divEmlSerHeader1').innerHTML = "Market reports";
			searchCrtStr = "Having neighborhood:"+trim(qs.get("nhood").replace('_',' '));
			searchCrtStr += "<br/><br/>You will receive an email with market information on this area every month.";
			if($('saveSerLabel1')) $('saveSerLabel1').innerHTML = "Name this alert";
			if($('dailyWeeklySpan')) $('dailyWeeklySpan').innerHTML = "";
			if($('dailyWeeklyRow')) $('dailyWeeklyRow').hide();
		}
		else
			searchCrtStr = getSearchCriteriaString();
				
		if(alertType != 'all' && fromMarketReport == "")
		{			
			$('srchCrtDiv').innerHTML = searchCrtStr;
			$('divEmailSaveSearch').style.display = '';		
			if(typeof(createDialog) == "function")
				emlSaveSearchDlg = createDialog('divEmailSaveSearch');
		}
		else
		{
			if($('saveSerLabel1')) $('saveSerLabel1').innerHTML = "Name this alert";
			$('srchCrtDiv1').innerHTML = searchCrtStr;
			$('divEmailSaveSearch1').style.display = '';		
			if(typeof(createDialog) == "function")
				emlSaveSearchDlg = createDialog('divEmailSaveSearch1');
		}		
		emlSaveSearchDlg.show();
	}
}

function removePolyRelated()
{
	removeSearchCookie("polygon");
	removeSearchCookie("area");
	if($("txtArea")) $("txtArea").value = "";
	if($("txtPolygon")) $("txtPolygon").value = "";
	if($("chkPolySearch")) $("chkPolySearch").checked = false;
	if($("drawSerArea")) $("drawSerArea").show();
	if($("clrSerArea")) $("clrSerArea").hide();
	if($("miniMapContainer")) $("miniMapContainer").hide();
	if($('mapDiv') && $('mapDiv').className == "mapDivSmall" && $('polygonDiv'))
	{
		$('polygonDiv').hide();
	}
	if(typeof(map2) == 'object' )
	{
		map2.clearOverlays();
	}
}

function hideSavedSearch(id)
{	
	if($("aSavSearch"))
	{
		if((id).value != "officeListing" && (id).value != "brokeropenHome" && (id).value != "openHome" && (id).value != "")
		{
			$("aSavSearch").hide();
			$("btnEmailAlerts").hide();			
		}
		else
		{
			$("aSavSearch").show();
			$("btnEmailAlerts").show();
		}

		//Hide For Power Search
		if(initPower && typeof(initPower) != "undefined")
		{
			$("aSavSearch").hide();
			$("btnEmailAlerts").hide();
		}
	}
}

function loadLocalBit(bitName)
{	
	var obj = $('chkBx'+bitName);
    var crawlerName = '';
	var objName = (obj.id).replace('chkBx','');
	for(var i=0;i<bitArr.length;i++)
	{
	  if(bitArr[i]['bitname']==bitName)
	  {			
			crawlerName = bitArr[i]['wDrag'];
	  }
	}

	if (obj && obj.checked)
	{	
		if(!checkInArray(obj.id,localBitArr))
			localBitArr.push(obj.id);

		if (trim(objName) == 'wikipedia')
		{
			wikiLayer = new GLayer("org.wikipedia.en");
			window.map2.addOverlay(wikiLayer);
		}
		else
		{
			var gcenter = map2.getCenter();
			var latVar = gcenter.lat();
			var lngVar = gcenter.lng();
			if(crawlerName)
			{
				var url = 'http://'+location.hostname+'/app/dashboard/'+crawlerName;
				var queryStr = 'mapit=1&city='+getSearchCookie("city")+'&state='+getSearchCookie("state")+'&zip='+getSearchCookie("zip")+'&propLatitude='+latVar+'&propLongitude='+lngVar;
				getLocalBitz(url, queryStr);
			}
		}
	}
	else if(obj)
	{	
		localBitArr.pop(obj.id);		
		if ( trim(objName) == 'wikipedia' )
		{
			if (typeof(wikiLayer)=='object')
				window.map2.removeOverlay(wikiLayer);
		}
		else
			removeCommPushpins(objName, 20);
	}
}

function loadLocalBitArr()
{	
	if(localBitArr && localBitArr.length > 0)
	{
		for(cntL=0;cntL<localBitArr.length;cntL++)
		{
			obj = $(localBitArr[cntL]);	
			if(obj)
			{
				obj.checked = true;
				loadLocalBit(obj);				
			}
		}
	}
}

function addRemoveLocal(bitName)
{
	loadLocalBit(bitName);	
}

function getPolygonFrmSNbr(id)
{
	var url = '/info/subNbrHandler.php';
	var qs = 'id='+id;	
	ajaxRequest(url,qs,function(r)
	{
		var rsText = r.responseText;
		if(rsText != "")
		{
			var sNbrPolyAreaArr = rsText.split('~!@');
			$('txtArea').value = sNbrPolyAreaArr[0];
			$('txtPolygon').value = sNbrPolyAreaArr[1];
			if($("chkPolySearch")) $("chkPolySearch").checked = true;
			//setSearchCookie('area',sNbrPolyAreaArr[0]);
			//setSearchCookie('polygon',sNbrPolyAreaArr[1]);
		}
	},false);
}

function redirectToFavUrl(url)
{
	saveFavUrl = url;
	if(typeof(uid) == "undefined" || uid == "" || uid == null)
	{		
		/*
		if(typeof(SignInDlg) == "string" || typeof(SignInDlg) == "undefined" || SignInDlg == null)
		{
			if($('divSignInFrm')) 
			{ 				
				$('divSignInFrm').style.display = '';			
				if(typeof(createDialog) == "function")
					SignInDlg = createDialog('divSignInFrm');
			}
		}
		$('divSignInFrm').style.dispaly = 'block';
		$('userName').value = "";
		$('userPwd').value = "";
		$('userName').className="textbox";
		$('userPwd').className="textbox";
		$('errSysLogin').innerHTML="&nbsp;";
		if($("fromWhere")) $("fromWhere").value = "saveFavUrl";
		if($("signInRoloLnk")) $("signInRoloLnk").href  = '/app/auth/login.php';
		var qs = new Querystring();
		if(qs.get("frm") != null && qs.get("aid") != null && $("signInRoloLnk"))
			$("signInRoloLnk").href += "?agd="+trim(qs.get("aid"));
		SignInDlg.show();
		*/				
		var mrUrl = window.location.href;
		opensignInRegDlg(mrUrl,'R','','');
	}
	else
	{
		window.open(saveFavUrl);
	}
}

function showOpenHomeDir(id)
{
	var myQs = new Querystring();
	var frm = myQs.get("frm");
	var aid = myQs.get("aid");
	var aidParam = "";
	if(frm != null && trim(frm) == 'agt' && aid != null && trim(aid) != "")
		aidParam = "&frm=" + frm + "&aid=" + aid;

	var host = "http://"+window.location.hostname+"/app/dashboard/getDirectionDetails.php?id=" + id + aidParam;
	window.open(host,"_blank");
}

// ---- record limit while next - prev & goto page ----//
function renderRecLimit()
{	
	if(!checkInArray(bkTheme,recLimitArr)) return true;

	var myNxtPage = parseInt($F('pagiVal')) + 1;
	var rpp = parseInt(recordPerPage);
	var gpp = parseInt(galleryRecPerPage);
	var ppp = 0;
	var totRec = 0;
	if($('photoId0') != null) 
	{
		ppp = gpp;
		totRec = parseInt(gpp*myNxtPage);
	}
	else
	{
		ppp = rpp;
		totRec = parseInt(rpp*myNxtPage);
	}
	//alert('totRec: '+totRec+"===totalRecords: "+parseInt(totalRecords)+"===mlsMaxResult: "+mlsMaxResult);
	if(totRec > mlsMaxResult)
	{
			alert('Your search has returned more than '+mlsMaxResult+' results. Please refine your search criteria.');
			return false;		
	}	
	return true;
}


function decodeLine (encoded) 
{
  var len = encoded.length;
  var index = 0;
  var array = [];
  var lat = 0;
  var lng = 0;

  while (index < len) {
    var b;
    var shift = 0;
    var result = 0;
    do {
      b = encoded.charCodeAt(index++) - 63;
      result |= (b & 0x1f) << shift;
      shift += 5;
    } while (b >= 0x20);
    var dlat = ((result & 1) ? ~(result >> 1) : (result >> 1));
    lat += dlat;

    shift = 0;
    result = 0;
    do {
      b = encoded.charCodeAt(index++) - 63;
      result |= (b & 0x1f) << shift;
      shift += 5;
    } while (b >= 0x20);
    var dlng = ((result & 1) ? ~(result >> 1) : (result >> 1));
    lng += dlng;

    array.push([lat * 1e-5, lng * 1e-5]);
  }
  return array;
}

function convPolyPointStr(array)
{
	polyPointStr = "";
	cnt=0;
	for(i=0;i<array.length;i++)
	{
		cnt++;
		polyPointStr += "("+array[i][0]+", "+array[i][1]+")";
		if(cnt != array.length)
			polyPointStr +=",";
	}
	return polyPointStr;
}

function setMapPolygonNhood (map, area)
{
	bound = area;
	var polyRouteArr = new Array();
	var points = new Array; 	
	var mapArr = area.split("|");
	var boundset = new GLatLngBounds();

	for(var i=0;i<mapArr.length;i++)
	{
		polyRouteArr.push(mapArr[i]);
		mapArr[i] = mapArr[i].replace(/\ /g,"");
		var tmpStr = mapArr[i].replace(/\),\(/g,")::(");
		var tmpArr = tmpStr.split("::");
		for(var j=0;j<tmpArr.length;j++)
		{	
			tmpArr[j] = tmpArr[j].replace(")","");
			tmpArr[j] = tmpArr[j].replace("(","");
			points.push(new GLatLng(tmpArr[j].split(",")[0],tmpArr[j].split(",")[1]));
			boundset.extend(new GLatLng(tmpArr[j].split(",")[0],tmpArr[j].split(",")[1]));	
		} 
		var polyArea = new GPolygon(points,"#ff0000",2,0.5,"#00FF00", 0.5);
		map.addOverlay(polyArea);
		points = [];		
	}	
}

function getPowerSearchCookie()
{	
	var strSearchCookie = getCookie("strSearchCookie");
	var arrSearchCookie = new Array();
	if(strSearchCookie != null && strSearchCookie != "")
	{
		arrSearchCookie = strSearchCookie.split(':::');
	}

	if(arrSearchCookie.length > 0)
	{		
		var postParam = "";
		for(var i=0;i<arrSearchCookie.length;i++)
		{
			var arrKeyVal = arrSearchCookie[i].split('=');			
			arrKeyVal[1] = arrKeyVal[1].replace(/\+/g,' ');			
			if((arrKeyVal[0]=="ltDate" || arrKeyVal[0] == "lfDate") && arrKeyVal[1] != "")
			{				
					var dateTmp = arrKeyVal[1].split('-');
					arrKeyVal[1] = dateTmp[2]+"-"+dateTmp[0]+"-"+dateTmp[1];
					//alert(arrKeyVal[1] +"=="+arrKeyVal[0]);			
			}
			if(arrKeyVal[1] != "")
			{
				if(arrKeyVal[1].indexOf(":") > 0)
				{				
					arrKeyVal[1] = arrKeyVal[1].replace(/\:/g, ",");					
				}
				else if(arrKeyVal[1].indexOf("|^|") >= 0)
				{				
					arrKeyVal[1] = arrKeyVal[1].replace(/\|\^\|/g, ":-:");					
					checkAllPropType(arrKeyVal[1]);
				}
				postParam +=  "&"+arrKeyVal[0]+"="+arrKeyVal[1];
			}			
		}	
	}
	
	return postParam;	
}

/* function related to multiple property type selection */
function getAllCheckedPropType(attr)
{
	var srchTyp = "";		
	if($("chk_All").checked == true)
	{
		// IF ALL CHECKED NOTHING TO SAVE IN COOKIE
	}
	else
	{
		var arrChkBox = $("dvPropType").getElementsByTagName("input");
		var lenArrChkBox = arrChkBox.length;			

		for(k=0; k<lenArrChkBox; k++)
		{
			if(arrChkBox[k].id == "chk_All")
				continue;

			if(arrChkBox[k].checked == true)
			{
				if(attr == "value")
					srchTyp += arrChkBox[k].value+":-:";					
				else if(attr == "key")
				{
					var tmp = arrChkBox[k].id;
					tmp = tmp.substr(4, tmp.length);
					srchTyp += tmp+",";
				}
			}
		}
		
		if(srchTyp != "")
		{
			if(attr == "value")
				srchTyp = srchTyp.substr(0, srchTyp.length-3);
			else if(attr == "key")
				srchTyp = srchTyp.substr(0, srchTyp.length-1);
		}
	}
	return srchTyp;
}

function showHidePropTypeDiv()
{
	if($('dvPropTypeMain').style.display == 'block')
		$('dvPropTypeMain').style.display = 'none';
	else
		$('dvPropTypeMain').style.display = 'block';
}

function checkUnCheckPropType(obj)
{
	if(trim(obj.id) == "chk_All") // All - type checked / unchecked
	{
		var arrChkBox = $("dvPropType").getElementsByTagName("input");
		var lenArrChkBox = arrChkBox.length;
		
		if(obj.checked == true)
		{
			for(k=0; k<lenArrChkBox; k++)
			{
				arrChkBox[k].checked = true;
			}
		}
		else
		{
			for(k=0; k<lenArrChkBox; k++)
			{
				arrChkBox[k].checked = false;
			}
		}
	}
	else
	{
		var arrChkBox = $("dvPropType").getElementsByTagName("input");
		var lenArrChkBox = arrChkBox.length;
		var flag = false;

		for(k=0; k<lenArrChkBox; k++)
		{
			if(arrChkBox[k].id == "chk_All")
				continue;

			if(arrChkBox[k].checked == true)
			{
				flag = true;
				break;
			}
		}

		if(flag)
		{
		}
		else
		{
			$("chk_All").checked = false;
			return;
		}
		
		if(obj.checked == true)
		{
			var flag = false;

			for(k=0; k<lenArrChkBox; k++)
			{
				if(arrChkBox[k].id == "chk_All")
					continue;

				if(arrChkBox[k].checked == false)
				{
					flag = true;
					break;
				}
			}				

			if(flag)
				$("chk_All").checked = false;
			else
				$("chk_All").checked = true;
		}
		else
		{
			var flag = false;

			for(k=0; k<lenArrChkBox; k++)
			{
				if(arrChkBox[k].id == "chk_All")
					continue;

				if(arrChkBox[k].checked == true)
				{
					flag = true;
					break;
				}
			}				

			if(flag)
				$("chk_All").checked = false;
			else
				$("chk_All").checked = true;
		}
	}
}

function savePropType()
{
	var srchTyp = "";		
	if($("chk_All").checked == true)
	{
		// IF ALL CHECKED NOTHING TO SAVE IN COOKIE
	}
	else
	{
		var arrChkBox = $("dvPropType").getElementsByTagName("input");
		var lenArrChkBox = arrChkBox.length;			

		for(k=0; k<lenArrChkBox; k++)
		{
			if(arrChkBox[k].id == "chk_All")
				continue;

			if(arrChkBox[k].checked == true)
			{
				srchTyp += arrChkBox[k].value+":-:";					
			}
		}
		if(srchTyp != "")
			srchTyp = srchTyp.substr(0, srchTyp.length-3);
	}

	setSearchCookie("searchType", trim(srchTyp));
	displayPropType();
	showHidePropTypeDiv();
}

function displayPropType(str)
{
	var titleText = "";

	if(typeof(str) != "undefined" && str != "")
		titleText = str;
	else
		titleText = getAllCheckedPropType("key").replace(/_/g, " ");;

	if(titleText == "")
		titleText = "All";		

	if(titleText.length > 22)
		titleText = titleText.substr(0,22)+"...";

	$("dvPropTypeTitle").innerHTML = titleText;
}

function checkAllPropType(str)
{
	var stringToUse = "";
	if(typeof(str) != "undefined" && str != "")
		stringToUse = str.replace(/%20/g, " ");
	else
		stringToUse = trim(getSearchCookie("searchType"));

	var checkedArr = new Array();
	if(stringToUse.indexOf(":-:")>=0)
		checkedArr = stringToUse.split(":-:");
	else
		checkedArr[0] = stringToUse;
	
	var checkedArrLen = checkedArr.length;		

	var arrChkBox = $("dvPropType").getElementsByTagName("input");
	var lenArrChkBox = arrChkBox.length;
	var flag = false;
	
	var arrChkBoxInner = new Array();
	var arrChkBoxInnerTitle = new Array();
	for(var k=0; k<lenArrChkBox; k++)
	{
		arrChkBoxInner[k] = arrChkBox[k].value;
		arrChkBoxInnerTitle[k] = ((arrChkBox[k].id).substr(4,(arrChkBox[k].id).length)).replace(/_/, " ");
	}

	stringToUse = "";	

	for(var k=0; k<checkedArrLen; k++)
	{
		var ind = arrChkBoxInner.in_array(checkedArr[k]);
		if(ind !== false)
		{
			arrChkBox[ind].checked = true;
			stringToUse += arrChkBoxInnerTitle[ind]+",";
		}
	}

	if(stringToUse != "")
		stringToUse = stringToUse.substr(0,stringToUse.length-1);

	displayPropType(stringToUse);
}
/* function related to multiple property type selection */

/* function for sandia-santafe to display custom message */

function customMsg()
{
	var msg = "";
	if(getSearchCookie('searchCriteria')=='newListing')
	{
		msg =  " for the past 7 days";
	}
	var selInd = $('bit_select_box').selectedIndex;
	var selText = $('bit_select_box')[selInd].text; 
	if($('dvPropTypeTitle').innerHTML== "Commercial" || $('dvPropTypeTitle').innerHTML== "Lots and Land")
		selText = "All "+$('dvPropTypeTitle').innerHTML + " listings";
	var msgHtml = "You are viewing "+selText+" available in the "+ $('RSsearchCSZ').value + msg+".";
	$('msgTable').innerHTML = msgHtml;
	$('msgTable').show(); // for message - santafe and sandia 
	if($('mlsno') && $F('mlsno') != "") $('msgTable').hide();	
}

function setNeighborhoodMsg(divId)
{
	if($F(divId) == '') {
		$(divId).value = 'Choose Neighborhood';
	}
	else if($F(divId) == 'Choose Neighborhood') {
		$(divId).value = '';
	}
}

function getKeyCode(event, type)
{
	if(event && event.keyCode == 13)
	{
		qryStrHash['grp']='';
		disablePower=true;
		setTimeout(function() { doPropSearch(); },1000);
	}
}

/*common.js*/

/** 
 * @fileoverview This javascript file contains the common functions. 
 * @author Hardik Shah
 * @author Pankit Bhanushali
 * @version 0.1 
 */
var goToMap = false;
var imgThmPath = "../../wt/"+bkTheme+"/images/";
var isIE = document.all?1:0;
var isIE6 = (window.XMLHttpRequest)?0:1;
var usrAgt = navigator.userAgent.toLowerCase();
var isFF = (usrAgt.indexOf('firefox')!=-1)?1:0;
var isOpera = (usrAgt.indexOf('opera')!=-1)?1:0;
var isSafari = ((usrAgt.indexOf('safari')!=-1)&&(usrAgt.indexOf('mac')!=-1))?1:0;
//enables background image cache for internet explorer 6
if (isIE6) try {document.execCommand("BackgroundImageCache", false, true);} catch(e){};
// Global Variables
//var leadEmailDlg1;
var maindivid	= 'middle';
var url			= '';
var queryString	= '';
var lastToggled	;
var sessid	= '';
var YAHOO;
var jsPath = '../../';
var totalImgs;
var latLong = '';
var isCountySearchEnabled = "0";
//lmsre specific
var lmsreDshbrdBitz= '{"mortgagerates" : "50","mcalc":"24","equity":"57","weather":"19","climate":"19","demographics" : "28","localnews" : "20","marketsnapshot":"46","crimestats":"49","valuehome":"58","afford":"51","localSearch":"39","crimestats":"49"}';
//var leadEmailDlg1;
/*metrospecific*/
var agtOffDlgBox = "";
var clientTime = new Date();
var ClientTimezoneOffset = (clientTime.getTimezoneOffset() / 60);
var month = clientTime.getMonth() + 1;
var day = clientTime.getDate();
var year = clientTime.getFullYear();
var hours = clientTime.getHours();
var min = clientTime.getMinutes();
var sec = clientTime.getSeconds();
var localTime = year + "-" + month + "-" + day+" "+hours+ ":" + min+ ":" + sec;

/**
 * set new session id
 *
 */
function setSessid()
{
	var queryString  = "PHPSESSID="+sessid;
	var url = jsPath+"../classes/sessionSwitch.php";
	ajaxRequest(url,queryString,setID);
};

function setID(originalRequest)
{
	sessid = originalRequest.responseText;
};
function pageReload(originalRequest)
{
	if(originalRequest==null)originalRequest="";
	window.location.href = window.location.pathname+window.location.search;
};
/**
 * This is the Ajax function that requests the url and loads the HT response to particular Div/container
 * @param {String} url The url called by the Ajax request
 * @param {String} queryString The parameter String passed to the url 
 * @param {String} inDiv The Div/Container in which the response to be set
 * @param {String} callbackfn The callback function name
 */
 
function loadToDiv(url,queryString,inDiv,callbackfn,classNm)
{

	if(classNm==null)
		classNm = false;
		
	inDiv = typeof(inDiv) != 'undefined' ? inDiv : maindivid; 
	if(queryString=='')
	{
		queryString = "PHPSESSID="+sessid;
	}
	else
	{
		queryString = "PHPSESSID="+sessid+"&"+queryString;
	}
	/*
	var callbackfn = function(myAjaxObjext)
	{
		alert(inDiv+" :: "+$(inDiv)+" :: "+$(inDiv).innerHTML);
		alert(myAjaxObjext.responseText);
	}
	*/ 
	if(callbackfn==null)
	{
		var objAjax = new Ajax.Updater({success: inDiv},url, {method: 'post', parameters: queryString, onFailure: showError,onlyLatestOfClass:classNm,evalScripts: true});
	}
	else
	{
		var objAjax = new Ajax.Updater({success: inDiv},url, {method: 'post', parameters: queryString, onFailure: showError,onlyLatestOfClass:classNm,onSuccess: callbackfn, evalScripts: true});
	}
};

/**
 * This is the Ajax function that request the particular url 
 * @param {String} url The url called by the Ajax request
 * @param {String} queryString The parameter String passed to the url 
 * @param {String} callbackfn The callback function name
 * @param {boolean} requestType The type of the request to be made should synchronous or asynchronous(default)
 */
 
function ajaxRequest(url,queryString,callbackfn,requestType,classNm)
{

	if(classNm==null)
		classNm = false;
		
	if(requestType==null)
	{
		requestType=true;
	}

	if(queryString=='')
	{
		queryString = "PHPSESSID="+sessid;
	}
	else
	{
		queryString = "PHPSESSID="+sessid+"&"+queryString;
	}
	if(typeof(callbackfn) == 'undefined')
	{
		var objAjaxReq = new Ajax.Request(url, {method: 'post',asynchronous:requestType, parameters: queryString, onlyLatestOfClass:classNm, onFailure: showError, evalScripts: true});
	}
	else
	{
		var objAjaxReq = new Ajax.Request(url, {method: 'post',asynchronous:requestType, parameters: queryString, onlyLatestOfClass:classNm, onFailure: showError, onSuccess: callbackfn, evalScripts: true});
	}
};

/**
 * Display the Error message when the Ajax request fails 
 * @param {String} originalRequest the request object
 */
function showError(originalRequest)
{
	if (originalRequest.status == 999)
	{
		window.location.href = "../auth/sessionExpire.php";
	}
	else
	{
		var response = originalRequest.responseText;
		$(maindivid).innerHTML = response;
		alert(response);
	}
};


/***********************General Section********************/

/**
 * Includes the single javaScript file dynamically
 * @param {String} jsFile the javscript filename
 */

function includeJS(jsFile, callBack)
{
	var fileName = jsFile.substr(eval(jsFile.lastIndexOf('/')+1),eval(jsFile.lastIndexOf('\.')-eval(jsFile.lastIndexOf('/')+1)));
	var myScript = $(fileName+"Script");
	if(fileName+"Script" == "mlsSrc.searchPs.template.jsScript")
	{
		myScript = null;
	}	
	if(myScript==null)
	{
		var myScr = document.createElement('script');
		myScr.id= fileName+"Script";
		myScr.src = jsFile;
		myScr.type = "text/javascript";
								
		if(typeof(callBack) != "undefined" && typeof(callBack) == "function")
		{
			myScr.onload = myScr.onreadystatechange = function(){
				if(this.readyState)
				{
					if(this.readyState == "loaded")
						callBack();
				}
				else
					callBack();
			}
		}
		document.getElementsByTagName('head')[0].appendChild(myScr);						
	}
};
/**
 * Includes the single css file dynamically
 * @param {String} cssFile the css filename
 */

function includeCSS(cssFile)
{
	var fileName = cssFile.substr(eval(cssFile.lastIndexOf('/')+1),eval(cssFile.lastIndexOf('\.')-eval(cssFile.lastIndexOf('/')+1)));
	var myStyle = $(fileName+"Css");
	
	if(myStyle==null)
	{
		var myCss = document.createElement('link');
		myCss.id= fileName+"Css";
		myCss.href = cssFile;
		myCss.rel = "stylesheet";
		myCss.type = "text/css";
		document.getElementsByTagName('head')[0].appendChild(myCss);
	}
};
/**
 * Includes the multiple css files dynamically
 * @param {Array} cssFileArr the array of css filenames
 */
function includeMultiCSS(cssFileArr)
{
	var insrtCssFileArr = $A(cssFileArr);
	insrtCssFileArr.each(function(node) {
		includeCSS(node);
	});
};

/**
 * Function for flipping images on mouse over
 * (Normal images should be with suffix '_n' and hoverimages should be with suffix '_h')
 * @requires changeImgOnHover The changeImgOnHover function
 */

function revealThumbnail()
{
	imgsrc = this.src;
	newimgsrc=(imgsrc.replace("_n","_h"));
	this.src=newimgsrc;
};

/**
 * Function for flipping images on mouse out
 * (Normal images should be with suffix '_n' and hoverimages should be with suffix '_h')
 * @requires changeImgOnHover The changeImgOnHover function
 */	
function hideThumbnail()
{
	imgsrc = this.src;
	newimgsrc=(imgsrc.replace("_h","_n"));
	this.src=newimgsrc;
};
/**
 * Function for Toggle Divs using Effect for showing details
 * @param {id} id current Div id to be opened
 */
var sameFlag = false;
function menuToggle(id)
{
    if (lastToggled == null || $(lastToggled) == null) 
	{
		//Effect.toggle(id,'blind',{duration:0.2});
		lastToggled = id;
		//Element.Toggle(id);
		$(id).style.display = "block";
    }
    else if (lastToggled == id) 
	{     		       
		//Effect.toggle(id,'blind',{duration:0.2});	
		//Element.Toggle(id);
		if(sameFlag==false)
		{
			$(id).style.display = "none";
			sameFlag = true;
		}
		else
		{
			$(id).style.display = "block";
			sameFlag = false;
		}
    }  
    else
	{
	   $(lastToggled).style.display = "none";
       lastToggled = id;
       $(id).style.display = "block";
    }
    
};


/**
 * InPlace Editor function for Textbox
 * @param {TextBox Id} elementId The current element ID
 * @param {Button Id}  edtBtn The button id
 * @param {fileToCommunicate} The file that is call on click of edit button
 */
function createInplaceEditorText(elementId,fileToCommunicate,fieldName,tableName,condition,edtBtn,validation,size)
{
	
	if(elementId==null || fileToCommunicate == null || fieldName==null || tableName == null || condition == null)
	{
		alert("Parameters missing: elementId, fileToCommunicate, fieldName, tableName, and condition are mandatory");	
	}
	else
	{
		
		if(validation==null){validation="";}
		
		if(edtBtn==null){edtBtn="";}
		
		if(size==null)
			var inplaceEditorTxt =new Ajax.InPlaceEditor(elementId, fileToCommunicate,{ clickToEditText : "You can Edit this by clicking on it.", callback: function(form, value) { return 'value=' + escape(value)+'&fieldName='+escape(fieldName)+'&tableName='+escape(tableName)+'&condition='+escape(condition) },validate:validation,externalControl:edtBtn,highlightcolor:'#74AACF'});
		else
			var inplaceEditorTxt =new Ajax.InPlaceEditor(elementId, fileToCommunicate,{ clickToEditText : "You can Edit this by clicking on it.", size:size, callback: function(form, value) { return 'value=' + escape(value)+'&fieldName='+escape(fieldName)+'&tableName='+escape(tableName)+'&condition='+escape(condition) },validate:validation,externalControl:edtBtn,highlightcolor:'#74AACF'});
	
		return inplaceEditorTxt;
	}
};

/**
 * InPlace Editor function for TextArea
 * @param {TextArea Id} elementId The current element ID
 * @param {Button Id}  edtBtn The button id
 * @param {fileToCommunicate} The file that is call on click of edit button
 */
function createInplaceEditorTextArea(elementId,fileToCommunicate,fieldName,tableName,condition,edtBtn)
{
	if(elementId==null || fileToCommunicate == null || fieldName==null || tableName == null || condition == null)
	{
		alert("Parameters missing: elementId, fileToCommunicate, fieldName, tableName, and condition are mandatory");	
	}
	else
	{
		if(Ajax.InPlaceEditor == null)
		{
			alert("Please include Scriptaculous.js from vendor folder for using inplace Editor");
		}
		else
		{
			if(edtBtn==null){edtBtn="";}
			var inplaceEditorTA = new Ajax.InPlaceEditor(elementId, fileToCommunicate, { clickToEditText : "You can Edit this by clicking on it.", callback: function(form, value) { return 'value=' + escape(value)+'&fieldName='+escape(fieldName)+'&tableName='+escape(tableName)+'&condition='+escape(condition) },externalControl:edtBtn,rows:4,cols:60,highlightcolor:'#74AACF'});
			return inplaceEditorTA;
		}
	}
};

/**
 * InPlace Editor function for ComboBox
 * @param {ComboBox Id} elementId The current element ID
 * @param {Button Id}  edtBtn The button id
 * @param {fileToCommunicate} The file that is call on click of edit button
 */
function createInplaceEditorCombo(elementId,fileToCommunicate,optionArray,fieldName,tableName,condition,edtBtn)
{
	if(elementId==null || fileToCommunicate == null || fieldName==null || tableName == null || condition == null)
	{
		alert("Parameters missing: elementId, fileToCommunicate, fieldName, tableName, and condition are mendatory");	
	}
	else
	{
		if(Ajax.InPlaceEditor == null)
		{
			alert("Please include Scriptaculous.js from vendor folder for using inplace Editor");
		}
		else
		{
			var queryString = '&combo=1&fieldName='+escape(fieldName)+'&tableName='+escape(tableName)+'&condition='+escape(condition);
			if(edtBtn==null){edtBtn=""}
			var inplaceEditorTA = new Ajax.InPlaceCollectionEditor (elementId,fileToCommunicate,{collection:optionArray, ajaxOptions: {parameters: queryString },externalControl:edtBtn,highlightcolor:'#74AACF'} );
			return inplaceEditorTA;
		}
	}
};

function StringBuffer() { this.buffer = []; }
StringBuffer.prototype.append = function(string)
{
	this.buffer.push(string);
	return this;
}

StringBuffer.prototype.toString = function()
{
	return this.buffer.join("");
}

// YUI Related Functions 
/**
 * Create the YAHOO Panel dynamically
 * @param {id} elid The div id of the Yahoo Panel
 * @return Panel object
 */
 function setDlgPos(elid)
{
	
	if(elid=="initWithMe")
		return;
	if($(elid))
	{
		var f_cw = f_clientWidth();
		var f_ch = f_clientHeight();
		var el_H = $(elid).getHeight();
		var el_W = $(elid).getWidth();
		$(elid).style.position = "static";
		$(elid).style.top = eval(Math.abs(f_ch/2) - Math.abs(el_H/2))+"px";
		$(elid).style.left = eval(Math.abs(f_cw/2) - Math.abs(el_W/2))+"px";
		var myObj = document.getElementsByClassName('underlay');
		if(myObj != null)
		{
			var myLen = myObj.length;
			for(var i=0;i<myLen;i++)
			{
				myObj[i].removeClassName('underlay');
			}
		}			
	}	
}
function createDialog(elid)
{
	var useShim;
	var ua = navigator.userAgent.toLowerCase();
	if (isIE){
		useShim = true;
	}else{
		useShim = false;
		setDlgPos(elid);
	}
	if(YAHOO==null)
	{
		alert("Please include yahoo.js");
	}
	else
	{			
		dlgBox = new YAHOO.widget.Panel(elid, {modal:true, visible:false, fixedcenter:true, constraintoviewport:true, shim:useShim, draggable:false} );
		dlgBox.render();
		if (!isIE6)
			dlgBox.beforeShowEvent.subscribe(function(){setDlgPos(elid);}, this);					
		return dlgBox;
	}
};

/**
 * Create the YAHOO TabView dynamically
 * @param {id} parentDiv The div id that will contain the Tabs
 * @param {Array} keyValArr the Key:Value paired array of Labels:Urls
 * @param {String} orientation the Tab Orientation ie. left,right,top or bottom
 * @return TabView object
 */
function loadTabs(parentDiv,keyValArr,orientation,noOfTabs)
{
	if(noOfTabs!=null)
	{
		loadTabsDynamically(parentDiv,keyValArr,orientation,noOfTabs);
		return;
	}
	orientation = typeof(orientation) != 'undefined' ? orientation : 'top';

	var hashArrLabels = $A($H(keyValArr).keys());
	var hashArrURLs   = $A($H(keyValArr).values());

    var tabView = new YAHOO.widget.TabView({id: parentDiv , orientation: orientation});
    var activate = false;
	for(i=0;i<hashArrLabels.length;i++)
	{
		if(i==0)
			activate = true;
		else
			activate = false;

		if(hashArrURLs[i]==null || hashArrURLs[i]=="")
		{
			dataSource = hashArrURLs[i];
		}
		else
		{
			if(hashArrURLs[i].search(/\?/)<0)
			{
				dataSource = hashArrURLs[i]+"?PHPSESSID="+sessid;
			}
			else
			{
				dataSource = hashArrURLs[i]+"&PHPSESSID="+sessid;
			}
		}
		tabView.addTab(new YAHOO.widget.Tab({
			label: hashArrLabels[i],
			dataSrc: dataSource,
			active: activate,
			cacheData: false /******************To be kept true in production *************/
	 	 }));
	}
    
    YAHOO.util.Event.onContentReady(parentDiv, function() {
        tabView.appendTo(parentDiv);
    });
    
  	for(i=0;i<$A($H(keyValArr)).length;i++)
	{
		tabView.getTab(i).addListener('contentChange',function (){
				this.get('content').evalScripts();
			});
	}
	return tabView;
};

var start = 1;
function addTabs(tabElem,keyValArr,enableArr)
{
	var hashArrLabels = $A($H(keyValArr).keys());
	var hashArrURLs   = $A($H(keyValArr).values());

	for(i=0;i<hashArrLabels.length;i++)
	{

		tabElem.addTab(new YAHOO.widget.Tab({
			label: hashArrLabels[i],
			dataSrc: hashArrURLs[i],
			active: true,
			disabled : enableArr[i],
			cacheData: false /******************To be kept true in production *************/
	    }));
	}
	var noOfTabs = 0;
	while(tabElem.getTab(noOfTabs))
	{
		noOfTabs = noOfTabs + 1;
	}
	for(i=1;i<noOfTabs;i++)
	{
		tabElem.getTab(i).addListener('contentChange',function (){
					this.get('content').evalScripts();
			});

	}
	return tabElem;
};
/************************************************************************/
/**
* Create Custom Confirm Dialog Box
*/
		var popupMessageBoxForm;
    function popupMessageBox (title, message, icon, buttons,wth,hgt) 
    {
    		if(!wth || wth == null)
    			wth = "300px";
    		if(!hgt || hgt == null)
    			hgt = "100px";
        // our container must exist for this to work				
        if (!YAHOO.util.Dom.inDocument('popupMessageBoxContainer'))
					return;
				
        // create the confirm dialog
        var ybuttons = [];
        for (var i=0; i<buttons.length; i++) 
        {
            ybuttons[i] = { text:buttons[i].label, handler:buttons[i].func, isDefault:(i==0?true:false) };
        }

	    	popupMessageBoxForm = new YAHOO.widget.SimpleDialog("popupMessageBoxContainer1", 
				{
	            modal: true,
	     			  width: wth+"px",
	     			  height:hgt+"px",
	            fixedcenter: true,
	            visible: false,
	            draggable: false,
	            close: true,
	            text: message,
	            icon: icon,
	            constraintoviewport: true,
	            buttons: ybuttons
	           
	      });
		    popupMessageBoxForm.setHeader(title);
		    popupMessageBoxForm.render("popupMessageBoxContainer");     
		    popupMessageBoxForm.show();

    }

    function popupMessageBoxHide() 
    {
        popupMessageBoxForm.hide();
    }

    function YAlert (title, msg, icon,button,wth,hgt) 
    {
        if (icon === undefined) icon = YAHOO.widget.SimpleDialog.ICON_ALARM;
        popupMessageBox (title, msg, icon,[{label:button,func:popupMessageBoxHide}],wth,hgt);        
    }

    function YConfirm (msg, yeshandler,nohandler,button1,button2,wth,hgt) 
    {
        popupMessageBox('Please Confirm...', msg,YAHOO.widget.SimpleDialog.ICON_HELP, [{label:button1,func:function(){popupMessageBoxHide();yeshandler();}},{label:button2,func:function(){popupMessageBoxHide();nohandler();}}],wth,hgt);
    } 
/************************************************************************/    
/** 
 * Function that returns the string in particular Language
 * @param {String} str The string to be converted in the selected language
 * @return String of the language currently set. 
 */

function getText(str) /* Returns Related Language from Language Array String */
{
	//below line, which uses Localisation variable, is commented by pratik as hardik removed line for loading of individual Language.JS file in code clean up
	//if (Localisation[str]) str = Localisation[str];
	return str;
};

/**************************Added Without Comments *******************/
function _alert(str) 
{
	alert(getText(str));
};
function _confirm(str)
{
	return confirm(getText(str));
};

/*************************Added Functions ************************/
/**
 * @author Shah Pratik
 * @date 31/01/2007
 * @param {String | Int} search string or integer
 * @return {boolean} return index of needle if needle is found in array else return false
 */
Array.prototype.in_array = function ( needle ) 
{
	var len = this.length;
	for ( var x = 0 ; x <= len ; x++ ) 
	{
		if ( this[x] == needle ) 
		{
			return x;
		}
	}
	return false;
};

/**
 * Function that sets the cookie.
 * @author Sanjev Dutta
 * @date 31/01/2007
 * @param {String} name of the cookie
 * @param {String} value of the cookie
 * @param {String} expires expiry time for the cookie
 * @param {String} path path
 * @param {String} domain domain
 * @param {String} secure Secure cookie (SSL)
 */
function setCookie(name, value, expires, path, domain, secure)
{
	//alert(name+" "+value);
	if (name == "msgboxCK" || name == "msgboxCKSignin" || name == "msgboxtutorialcook" || name == "rememberIdPassword" || name == "Cpanel_rememberIdPassword" || name == "pv" || name == "strWidgetCookie")
	{
		if (expires)
		{
			expires = expires.toGMTString();
		}
	}
	else
		expires = null;

  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires : "") +
      ((path) ? "; path=" + path : "; path=/") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
};

/**
 * Function that gets the cookie value for given name.
 * @author Sanjev Dutta
 * @date 31/01/2007
 * @param {String} name of the cookie
 * @return (String) returns the value for the given cookie name.
 */
function getCookie(name)
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1)
	{
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} 
	else
		begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
		end = dc.length;
	var returnCookie = unescape(dc.substring(begin + prefix.length, end));
	if((returnCookie == null) || (returnCookie == 'null'))
	{
		returnCookie = "";
	}

	return returnCookie;
	
};

/**
 * Function that deletes the cookie.
 * @author Sanjev Dutta
 * @date 31/01/2007
 * @param {String} name of the cookie
 * @param {String} path path
 * @param {String} domain domain
 * @return (void)
 */
function deleteCookie(name, path, domain)
{
	if (getCookie(name))
	{
		document.cookie = name + "=" + ((path) ? "; path=" + path : "path=/") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
};
/********in place editor code******/


/******************************** Thanks To Scriptaculaus****************************/
// script.aculo.us effects.js v1.7.0_beta2, Mon Dec 18 23:38:56 CET 2006

// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// Contributors:
//  Justin Palmer (http://encytemedia.com/)
//  Mark Pilgrim (http://diveintomark.org/)
//  Martin Bialasinki
// 
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/ 

/************************** Ajax Inplace Editor ********************************/	
Ajax.InPlaceEditor = Class.create();
Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99";
Ajax.InPlaceEditor.prototype = {
  initialize: function(element, url, options) {
    this.url = url;
    this.element = $(element);

    this.options = Object.extend({
      paramName: "value",
      okButton: true,
      okText: "Save",
      cancelLink: true,
      cancelText: "Cancel",
      savingText: "Saving...",
      clickToEditText: "Click to edit",
      rows: 1,
      onComplete: function(transport, element) {
        new Effect.Highlight(element, {startcolor: this.options.highlightcolor});
      },
      onFailure: function(transport) {
        alert("Error communicating with the server: " + transport.responseText.stripTags());
      },
      callback: function(form) {
        return Form.serialize(form);
      },
      handleLineBreaks: true,
      loadingText: 'Loading...',
      savingClassName: 'inplaceeditor-saving',
      loadingClassName: 'inplaceeditor-loading',
      formClassName: 'inplaceeditor-form',
      highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor,
      highlightendcolor: "#E2E2DF",
      externalControl: null,
      submitOnBlur: false,
      ajaxOptions: {},
      evalScripts: false
    }, options || {});

    if(!this.options.formId && this.element.id) {
      this.options.formId = this.element.id + "-inplaceeditor";
      if ($(this.options.formId)) {
        // there's already a form with that name, don't specify an id
        this.options.formId = null;
      }
    }
    
    if (this.options.externalControl) {
      this.options.externalControl = $(this.options.externalControl);
    }
    
    this.originalBackground = Element.getStyle(this.element, 'background-color');
    if (!this.originalBackground) {
      this.originalBackground = "transparent";
    }
    
    this.element.title = this.options.clickToEditText;
    
    this.onclickListener = this.enterEditMode.bindAsEventListener(this);
    this.mouseoverListener = this.enterHover.bindAsEventListener(this);
    this.mouseoutListener = this.leaveHover.bindAsEventListener(this);
    Event.observe(this.element, 'click', this.onclickListener);
    Event.observe(this.element, 'mouseover', this.mouseoverListener);
    Event.observe(this.element, 'mouseout', this.mouseoutListener);
    if (this.options.externalControl) {
      Event.observe(this.options.externalControl, 'click', this.onclickListener);
      Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener);
      Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener);
    }
  },
  enterEditMode: function(evt) {
    if (this.saving) return;
    if (this.editing) return;
    this.editing = true;
    this.onEnterEditMode();
    if (this.options.externalControl) {
      Element.hide(this.options.externalControl);
    }
    Element.hide(this.element);
    this.createForm();
    this.element.parentNode.insertBefore(this.form, this.element);
    // stop the event to avoid a page refresh in Safari
    
    if (evt) {
      Event.stop(evt);
    }
    return false;
  },
  createForm: function() {
    this.form = document.createElement("form");
    this.form.id = this.options.formId;
    var uid = this.options.formId;
	var arrid = uid.split('-');    
    var txtid = arrid[0];
    Element.addClassName(this.form, this.options.formClassName)
    this.form.onsubmit = this.onSubmit.bind(this,txtid);

    this.createEditField();

    if (this.options.textarea) {
      var br = document.createElement("br");
      this.form.appendChild(br);
    }

    if (this.options.okButton) {
      okButton = document.createElement("a");
      //okButton.type = "#";
	  okButton.href = "#";
	  okButton.appendChild(document.createTextNode(this.options.okText));
	  okButton.onclick = this.onSubmit.bind(this);	  
      okButton.value = this.options.okText;
      okButton.className = 'editor_ok_button';
	  okButton.style.fontSize  = '13px';
	  //okButton.style.height ='17px';
	  //okButton.style.paddingTop = '0px' ;
	  this.form.appendChild(okButton);
    }
    if (this.options.cancelLink) {
      cancelLink = document.createElement("a");
      cancelLink.href = "#";
      cancelLink.appendChild(document.createTextNode(this.options.cancelText));
      cancelLink.onclick = this.onclickCancel.bind(this);
      cancelLink.style.fontSize  = '13px';
	  cancelLink.style.fontWeight  = 'normal';
	  cancelLink.className = 'editor_cancel';      
	  this.form.appendChild(cancelLink);
    }
  },
  hasHTMLLineBreaks: function(string) {
    if (!this.options.handleLineBreaks) return false;
    return string.match(/<br/i) || string.match(/<p>/i);
  },
  convertHTMLLineBreaks: function(string) {
    return string.replace(/<br>/gi, "\n").replace(/<br\/>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<p>/gi, "");
  },
  createEditField: function() {
    var text;
    if(this.options.loadTextURL) {
      text = this.options.loadingText;
    } else {
    	if(this.getText()=="none")
    	 	text="";
    	else
      		text = this.getText();
    }

    var obj = this;
    
    if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) {
      this.options.textarea = false;
      var textField = document.createElement("input");
      textField.obj = this;
      textField.type = "text";
      textField.name = this.options.paramName;
      textField.value = text;
      textField.style.backgroundColor = this.options.highlightcolor;
      textField.className = 'editor_field';
      textField.style.backgroundColor = 'white';
      var size = this.options.size || this.options.cols || 0;
      if (size != 0) textField.size = size;
      if (this.options.submitOnBlur)
        textField.onblur = this.onSubmit.bind(this);
      this.editField = textField;
    } else {
      this.options.textarea = true;
      var textArea = document.createElement("textarea");
      textArea.obj = this;
      textArea.name = this.options.paramName;
      textArea.value = this.convertHTMLLineBreaks(text);
      textArea.rows = this.options.rows;
      textArea.cols = this.options.cols || 40;
      textArea.className = 'editor_field_ta';   
      textArea.style.backgroundColor = 'white';   
      if (this.options.submitOnBlur)
        textArea.onblur = this.onSubmit.bind(this);
      this.editField = textArea;
    }
    
    if(this.options.loadTextURL) {
      this.loadExternalText();
    }
    this.form.appendChild(this.editField);
  },
  getText: function() {
    return this.element.innerHTML;
  },
  loadExternalText: function() {
    Element.addClassName(this.form, this.options.loadingClassName);
    this.editField.disabled = true;
    new Ajax.Request(
      this.options.loadTextURL,
      Object.extend({
        asynchronous: true,
        onComplete: this.onLoadedExternalText.bind(this)
      }, this.options.ajaxOptions)
    );
  },
  onLoadedExternalText: function(transport) {
    Element.removeClassName(this.form, this.options.loadingClassName);
    this.editField.disabled = false;
    this.editField.value = transport.responseText.stripTags();
    Field.scrollFreeActivate(this.editField);
  },
  onclickCancel: function() {
  	var erArr = document.getElementsByClassName("errMsg")
	$A(erArr).each(function(node){
			node.innerHTML="&nbsp;";
	});
  	if(this.editField.value=="")
  	{
  		this.editField.value=="none"
  	}
  	if ($('selTag'))
  	{
	  	if($('selTag').options[$('selTag').selectedIndex].value=="A" && $('divOH')!=null)
	  		$('divOH').style.display = "none";
  	}  	
    this.onComplete();
    this.leaveEditMode();
    return false;
  },
  onFailure: function(transport) {
    this.options.onFailure(transport);
    if (this.oldInnerHTML) {
      this.element.innerHTML = this.oldInnerHTML;
      this.oldInnerHTML = null;
    }
    return false;
  },
  onSubmit: function(id,id2) {
	var erArr;
  	if(!this.validate(id))
  	{
  		if(navigator.appName=="Microsoft Internet Explorer")
		  	this.editField.className = "textboxRedIn";
		 else
		 	this.editField.style.border = "1px solid red";
  		
  		erArr = document.getElementsByClassName("errMsg")
  		$A(erArr).each(function(node){
				node.innerHTML=alertErrorMsg;
  		});
  		
  		return false;
  	}
  	else
  	{
  		erArr = document.getElementsByClassName("errMsg")
  		$A(erArr).each(function(node){
				node.innerHTML="&nbsp;";
  		});
	    // onLoading resets these so we need to save them away for the Ajax call
	    var form = this.form;
	    var value = this.editField.value;
	    // do this first, sometimes the ajax call returns before we get a chance to switch on Saving...
	    // which means this will actually switch on Saving... *after* we've left edit mode causing Saving...
	    // to be displayed indefinitely
	    this.onLoading();
	    if (this.options.evalScripts) {
	    	this.options.ajaxOptions.parameters = this.options.callback(form, value);
	      new Ajax.Request(
	        this.url, Object.extend({
	          parameters: this.options.callback(form, value),
	          onComplete: this.onComplete.bind(this),
	          onFailure: this.onFailure.bind(this),
	          asynchronous:true, 
	          evalScripts:true
	        }, this.options.ajaxOptions));
	    } else  {
    	 this.options.ajaxOptions.parameters = this.options.callback(form, value);
	      new Ajax.Updater(
	        { success: this.element,
	          // don't update on failure (this could be an option)
	          failure: null }, 
	        this.url, Object.extend({
	          parameters: this.options.callback(form, value),
	          onComplete: this.onComplete.bind(this),
	          onFailure: this.onFailure.bind(this)
	        }, this.options.ajaxOptions));
	    }
	    // stop the event to avoid a page refresh in Safari
	    if (arguments.length > 1) {
	      Event.stop(arguments[0]);
	    }
	    return false;
  	}
  },
  onLoading: function() {
    this.saving = true;
    this.removeForm();
    this.leaveHover();
    this.showSaving();
  },
  showSaving: function() {
    this.oldInnerHTML = this.element.innerHTML;
    this.element.innerHTML = this.options.savingText;
    Element.addClassName(this.element, this.options.savingClassName);
    this.element.style.backgroundColor = this.originalBackground;
    Element.show(this.element);
  },
  removeForm: function() {
    if(this.form) {
      if (this.form.parentNode) Element.remove(this.form);
      this.form = null;
    }
  },
  enterHover: function() {
    if (this.saving) return;
    this.element.style.backgroundColor = this.options.highlightcolor;
    if (this.effect) {
      this.effect.cancel();
    }
    Element.addClassName(this.element, this.options.hoverClassName)
  },
  leaveHover: function() {
    if (this.options.backgroundColor) {
      this.element.style.backgroundColor = this.oldBackground;
    }
    Element.removeClassName(this.element, this.options.hoverClassName)
    if (this.saving) return;
    this.effect = new Effect.Highlight(this.element, {
      startcolor: this.options.highlightcolor,
      endcolor: this.options.highlightendcolor,
      restorecolor: this.originalBackground
    });
  },
  leaveEditMode: function() {
    Element.removeClassName(this.element, this.options.savingClassName);
    this.removeForm();
    this.leaveHover();
    this.element.style.backgroundColor = this.originalBackground;
    Element.show(this.element);
    if (this.options.externalControl) {
      Element.show(this.options.externalControl);
    }
    this.editing = false;
    this.saving = false;
    this.oldInnerHTML = null;
    this.onLeaveEditMode();
  },
  onComplete: function(transport) {
    this.leaveEditMode();
    this.options.onComplete.bind(this)(transport, this.element);
  },
  onEnterEditMode: function() {},
  onLeaveEditMode: function() {
  		onLeaveEditMd = window.onLeaveEditMd || false;
  	    if(onLeaveEditMd==false)
  	    	return;
  	    else
	    	onLeaveEditMd();
  },
  
  validate:function(id)
  {
	    validArg=this.options.validate;
		if(validArg!="" && typeof(validArg)!="undefined" && validArg!=null)
			id=validArg;
		
		switch(id)
		{
			case "ufname" : 
				return this.editField;
				break; 

			case "umname" : 
				return this.editField;
				break; 

			case "ulname" : 
				return this.editField;
				break; 

			case "name" : 
				return (isBlank(this.editField,"value"))
				break; 
				
			case "uemail":
			case "email":
				return emailIsValid(this.editField);
				break;

			case "ualtemail":
				return chkOnlyEmailIsValid(this.editField);
				break;

			case "uMobile":
			case "cell":
				return (mobileIsValid(this.editField,"Number"));
				break;

			case "uPhone":
			case "phone":
				return (phoneIsValid(this.editField,"Number"));
				break;

			case "uFax":
			case "fax":
				return (faxIsValid(this.editField,"Number"));
				break;
			case "site":
				return isValidURL(this.editField);
				break;
				
			case "uZip":
			case "zip":
				return zipIsValid(this.editField,"msg");
				break;
			
			case "uCity":
				//return isOfLength(this.editField,2);
				return albhabetIsValid(this.editField,"Only alphabets allowed.","City ");
				break;

			case "uState":
			case "state":
				//return isOfLength(this.editField,2);
				return albhabetIsValid(this.editField,"Only alphabets allowed.","State ",2,2);
				break;
			case "year":
				return isYear(this.editField);
				break;
			case "room":
				return (isOfLength(this.editField,3,"max") && numberIsValid(this.editField,"Enter valid Number",""));
				break;
			case "sqft":
				return isSqft(this.editField);
				break;
			default:
				return true;
		}
  	},  
 
  dispose: function() {
    if (this.oldInnerHTML) {
      this.element.innerHTML = this.oldInnerHTML;
    }
    this.leaveEditMode();
    Event.stopObserving(this.element, 'click', this.onclickListener);
    Event.stopObserving(this.element, 'mouseover', this.mouseoverListener);
    Event.stopObserving(this.element, 'mouseout', this.mouseoutListener);
    if (this.options.externalControl) {
      Event.stopObserving(this.options.externalControl, 'click', this.onclickListener);
      Event.stopObserving(this.options.externalControl, 'mouseover', this.mouseoverListener);
      Event.stopObserving(this.options.externalControl, 'mouseout', this.mouseoutListener);
    }
  }
};


/************************** Ajax Inplace Editor Ends ********************************/	
/***************************Ajax Inplace collectin Editor*******************************/

Ajax.InPlaceCollectionEditor = Class.create();
Object.extend(Ajax.InPlaceCollectionEditor.prototype, Ajax.InPlaceEditor.prototype);
Object.extend(Ajax.InPlaceCollectionEditor.prototype, {
createEditField: function() {
if (!this.cached_selectTag) {
var selectTag = document.createElement("select");
selectTag.id = "selTag";
var collection = this.options.collection || [];
var optionTag;
collection.each(function(e,i) {
optionTag = document.createElement("option");
optionTag.value = (e instanceof Array) ? e[0] : e;
if((typeof this.options.value == 'undefined') &&
((e instanceof Array) ? this.element.innerHTML == e[1] : e == optionTag.value)) optionTag.selected = true;
if(this.options.value==optionTag.value) optionTag.selected = true;
optionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e));
selectTag.appendChild(optionTag);
}.bind(this));
this.cached_selectTag = selectTag;
}
this.editField = this.cached_selectTag;
if(this.options.loadTextURL) this.loadExternalText();
this.form.appendChild(this.editField);

value2 = this.options.ajaxOptions.parameters;
//alert(value2);
this.options.callback = function(form, value) {
	if(value2.indexOf('value=')>=0)
	{
		value2 = value2.substr(value2.indexOf('&'),eval(value2.length-value2.indexOf('&')))
	}
	newVal = "value=" + encodeURIComponent(value)+value2;
//alert(newVal);	
	//this.options.ajaxOptions.parameters = "value=" + encodeURIComponent(value)+value2;
return newVal;
}
}
});


/*******************************Ajax Inplace collectin Editor Ends********************************/
/************************** Basic Effect For Inplace Editor *********************************/
String.prototype.parseColor = function() {  
  var color = '#';
  if(this.slice(0,4) == 'rgb(') {  
    var cols = this.slice(4,this.length-1).split(',');  
    var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);  
  } else {  
    if(this.slice(0,1) == '#') {  
      if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();  
      if(this.length==7) color = this.toLowerCase();  
    }  
  }  
  return(color.length==7 ? color : (arguments[0] || this));  
};

/*--------------------------------------------------------------------------*/

Element.collectTextNodes = function(element) {  
  return $A($(element).childNodes).collect( function(node) {
    return (node.nodeType==3 ? node.nodeValue : 
      (node.hasChildNodes() ? Element.collectTextNodes(node) : ''));
  }).flatten().join('');
};

Element.collectTextNodesIgnoreClass = function(element, className) {  
  return $A($(element).childNodes).collect( function(node) {
    return (node.nodeType==3 ? node.nodeValue : 
      ((node.hasChildNodes() && !Element.hasClassName(node,className)) ? 
        Element.collectTextNodesIgnoreClass(node, className) : ''));
  }).flatten().join('');
};

Element.setContentZoom = function(element, percent) {
  element = $(element);  
  element.setStyle({fontSize: (percent/100) + 'em'});   
  if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
  return element;
};

Element.getOpacity = function(element){
  return $(element).getStyle('opacity');
};

Element.setOpacity = function(element, value){
  return $(element).setStyle({opacity:value});
} ; 
 
Element.getInlineOpacity = function(element){  
  return $(element).style.opacity || '';
};

Element.forceRerendering = function(element) {
  try {
    element = $(element);
    var n = document.createTextNode(' ');
    element.appendChild(n);
    element.removeChild(n);
  } catch(e) { }
};

/*--------------------------------------------------------------------------*/

Array.prototype.call = function() {
  var args = arguments;
  this.each(function(f){ f.apply(this, args) });
};

/*--------------------------------------------------------------------------*/

var Effect = {
  _elementDoesNotExistError: {
    name: 'ElementDoesNotExistError',
    message: 'The specified DOM element does not exist, but is required for this effect to operate'
  },
  tagifyText: function(element) {
    if(typeof Builder == 'undefined')
      throw("Effect.tagifyText requires including script.aculo.us' builder.js library");
      
    var tagifyStyle = 'position:relative';
    if(/MSIE/.test(navigator.userAgent) && !window.opera) tagifyStyle += ';zoom:1';
    
    element = $(element);
    $A(element.childNodes).each( function(child) {
      if(child.nodeType==3) {
        child.nodeValue.toArray().each( function(character) {
          element.insertBefore(
            Builder.node('span',{style: tagifyStyle},
              character == ' ' ? String.fromCharCode(160) : character), 
              child);
        });
        Element.remove(child);
      }
    });
  },
  multiple: function(element, effect) {
    var elements;
    if(((typeof element == 'object') || 
        (typeof element == 'function')) && 
       (element.length))
      elements = element;
    else
      elements = $(element).childNodes;
      
    var options = Object.extend({
      speed: 0.1,
      delay: 0.0
    }, arguments[2] || {});
    var masterDelay = options.delay;

    $A(elements).each( function(element, index) {
      new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay }));
    });
  },
  PAIRS: {
    'slide':  ['SlideDown','SlideUp'],
    'blind':  ['BlindDown','BlindUp'],
    'appear': ['Appear','Fade']
  },
  toggle: function(element, effect) {
    element = $(element);
    effect = (effect || 'appear').toLowerCase();
    var options = Object.extend({
      queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
    }, arguments[2] || {});
    Effect[element.visible() ? 
      Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options);
  }
};

/* ------------- core effects ------------- */

Effect.ScopedQueue = Class.create();
Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
  initialize: function() {
    this.effects  = [];
    this.interval = null;
  },
  _each: function(iterator) {
    this.effects._each(iterator);
  },
  add: function(effect) {
    var timestamp = new Date().getTime();
    
    var position = (typeof effect.options.queue == 'string') ? 
      effect.options.queue : effect.options.queue.position;

    switch(position) {
      case 'front':
        // move unstarted effects after this effect  
        this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) {
            e.startOn  += effect.finishOn;
            e.finishOn += effect.finishOn;
          });
        break;
      case 'with-last':
        timestamp = this.effects.pluck('startOn').max() || timestamp;
        break;
      case 'end':
        // start effect after last queued effect has finished
        timestamp = this.effects.pluck('finishOn').max() || timestamp;
        break;
    }
    
    effect.startOn  += timestamp;
    effect.finishOn += timestamp;

    if(!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit))
      this.effects.push(effect);
    if(!this.interval) 
      this.interval = setInterval(this.loop.bind(this), 15);
  },
  remove: function(effect) {
    this.effects = this.effects.reject(function(e) { return e==effect });
    if(this.effects.length == 0) {
      clearInterval(this.interval);
      this.interval = null;
    }
  },
  loop: function() {
    var timePos = new Date().getTime();
    this.effects.invoke('loop', timePos);
  }
});

Effect.Queues = {
  instances: $H(),
  get: function(queueName) {
    if(typeof queueName != 'string') return queueName;
    
    if(!this.instances[queueName])
      this.instances[queueName] = new Effect.ScopedQueue();
      
    return this.instances[queueName];
  }
};
Effect.Queue = Effect.Queues.get('global');

Effect.DefaultOptions = {
  duration:   1.0,   // seconds
  fps:        60.0,  // max. 60fps due to Effect.Queue implementation
  sync:       false, // true for combining
  from:       0.0,
  to:         1.0,
  delay:      0.0,
  queue:      'parallel'
};



Effect.Base = function() {};
Effect.Base.prototype = {
  position: null,
  start: function(options) {
    this.options      = Object.extend(Object.extend({},Effect.DefaultOptions), options || {});
    this.currentFrame = 0;
    this.state        = 'idle';
    this.startOn      = this.options.delay*1000;
    this.finishOn     = this.startOn + (this.options.duration*1000);
    this.event('beforeStart');
    if(!this.options.sync)
      Effect.Queues.get(typeof this.options.queue == 'string' ? 
        'global' : this.options.queue.scope).add(this);
  },
  loop: function(timePos) {
  	  	
    if(timePos >= this.startOn) {
      if(timePos >= this.finishOn) {
        this.render(1.0);
        this.cancel();
        this.event('beforeFinish');
        if(this.finish) this.finish(); 
        this.event('afterFinish');
        return;  
      }
      var pos   = (timePos - this.startOn) / (this.finishOn - this.startOn);
      var frame = Math.round(pos * this.options.fps * this.options.duration);
      if(frame > this.currentFrame) {
        this.render(pos);
        this.currentFrame = frame;
      }
    }
  },
  render: function(pos) {
    if(this.state == 'idle') {
      this.state = 'running';
      this.event('beforeSetup');
      if(this.setup) this.setup();
      this.event('afterSetup');
    }
    if(this.state == 'running') {
      if(this.options.transition) pos = this.options.transition(pos);
      pos *= (this.options.to-this.options.from);
      pos += this.options.from;
      this.position = pos;
      this.event('beforeUpdate');
      if(this.update) this.update(pos);
      this.event('afterUpdate');
    }
  },
  cancel: function() {
    if(!this.options.sync)
      Effect.Queues.get(typeof this.options.queue == 'string' ? 
        'global' : this.options.queue.scope).remove(this);
    this.state = 'finished';
  },
  event: function(eventName) {
    if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);
    if(this.options[eventName]) this.options[eventName](this);
  },
  inspect: function() {
    return '#<Effect:' + $H(this).inspect() + ',options:' + $H(this.options).inspect() + '>';
  }
};

/************************** Basic Effect For Inplace Editor Ends *********************************/

Effect.Scale = Class.create();
Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
  initialize: function(element, percent) {
    this.element = $(element);
    if(!this.element) throw(Effect._elementDoesNotExistError);
    var options = Object.extend({
      scaleX: true,
      scaleY: true,
      scaleContent: true,
      scaleFromCenter: false,
      scaleMode: 'box',        // 'box' or 'contents' or {} with provided values
      scaleFrom: 100.0,
      scaleTo:   percent
    }, arguments[2] || {});
    this.start(options);
  },
  setup: function() {
    this.restoreAfterFinish = this.options.restoreAfterFinish || false;
    this.elementPositioning = this.element.getStyle('position');
    
    this.originalStyle = {};
    ['top','left','width','height','fontSize'].each( function(k) {
      this.originalStyle[k] = this.element.style[k];
    }.bind(this));
      
    this.originalTop  = this.element.offsetTop;
    this.originalLeft = this.element.offsetLeft;
    
    var fontSize = this.element.getStyle('font-size') || '100%';
    ['em','px','%','pt'].each( function(fontSizeType) {
      if(fontSize.indexOf(fontSizeType)>0) {
        this.fontSize     = parseFloat(fontSize);
        this.fontSizeType = fontSizeType;
      }
    }.bind(this));
    
    this.factor = (this.options.scaleTo - this.options.scaleFrom)/100;
    
    this.dims = null;
    if(this.options.scaleMode=='box')
      this.dims = [this.element.offsetHeight, this.element.offsetWidth];
    if(/^content/.test(this.options.scaleMode))
      this.dims = [this.element.scrollHeight, this.element.scrollWidth];
    if(!this.dims)
      this.dims = [this.options.scaleMode.originalHeight,
                   this.options.scaleMode.originalWidth];
  },
  update: function(position) {
    var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
    if(this.options.scaleContent && this.fontSize)
      this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType });
    this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
  },
  finish: function(position) {
  	if(this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
  },
  setDimensions: function(height, width) {
    var d = {};
    if(this.options.scaleX) d.width = Math.round(width) + 'px';
    if(this.options.scaleY) d.height = Math.round(height) + 'px';
    if(this.options.scaleFromCenter) {
      var topd  = (height - this.dims[0])/2;
      var leftd = (width  - this.dims[1])/2;
      if(this.elementPositioning == 'absolute') {
        if(this.options.scaleY) d.top = this.originalTop-topd + 'px';
        if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px';
      } else {
        if(this.options.scaleY) d.top = -topd + 'px';
        if(this.options.scaleX) d.left = -leftd + 'px';
      }
    }
    this.element.setStyle(d);
  }
});


Effect.Highlight = Class.create();
Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    if(!this.element) throw(Effect._elementDoesNotExistError);
    var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {});
    this.start(options);
  },
  setup: function() {
    // Prevent executing on elements not in the layout flow
    if(this.element.getStyle('display')=='none') { this.cancel(); return; }
    // Disable background image during the effect
    this.oldStyle = {
      backgroundImage: this.element.getStyle('background-image') };
    this.element.setStyle({backgroundImage: 'none'});
    if(!this.options.endcolor)
      this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff');
    if(!this.options.restorecolor)
      this.options.restorecolor = this.element.getStyle('background-color');
    // init color calculations
    this._base  = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
    this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this));
  },
  update: function(position) {
    this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){
      return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) });
  },
  finish: function() {
    this.element.setStyle(Object.extend(this.oldStyle, {
      backgroundColor: this.options.restorecolor
    }));
  }
});



Effect.BlindUp = function(element) {
	
  element = $(element);
  element.makeClipping();
  return new Effect.Scale(element, 0,
    Object.extend({ scaleContent: false, 
      scaleX: false, 
      restoreAfterFinish: true,
      afterFinishInternal: function(effect) {
        effect.element.hide().undoClipping();
      } 
    }, arguments[1] || {})
  );
};

Effect.BlindDown = function(element) {
  element = $(element);
  var elementDimensions = element.getDimensions();
  return new Effect.Scale(element, 100, Object.extend({ 
    scaleContent: false, 
    scaleX: false,
    scaleFrom: 0,
    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
    restoreAfterFinish: false,
    afterSetup: function(effect) {
      effect.element.makeClipping().setStyle({height: '0px'}).show(); 
      if(effect.element.id=="toggleDiv" && isIE)
      	setTimeout(function(){effect.element.style.display="block";},200);
    },  
    afterFinishInternal: function(effect) {
      effect.element.undoClipping();
    }
  }, arguments[1] || {}));
};


Effect.SlideDown = function(element) {
  element = $(element).cleanWhitespace();
  // SlideDown need to have the content of the element wrapped in a container element with fixed height!
  var oldInnerBottom = element.down().getStyle('bottom');
  var elementDimensions = element.getDimensions();
  return new Effect.Scale(element, 100, Object.extend({ 
    scaleContent: false, 
    scaleX: false, 
    scaleFrom: window.opera ? 0 : 1,
    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
    restoreAfterFinish: true,
    afterSetup: function(effect) {
      effect.element.makePositioned();
      effect.element.down().makePositioned();
      if(window.opera) effect.element.setStyle({top: ''});
      effect.element.makeClipping().setStyle({height: '0px'}).show(); 
    },
    afterUpdateInternal: function(effect) {
      effect.element.down().setStyle({bottom:
        (effect.dims[0] - effect.element.clientHeight) + 'px' }); 
    },
    afterFinishInternal: function(effect) {
      effect.element.undoClipping().undoPositioned();
      effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); }
    }, arguments[1] || {})
  );
};

Effect.SlideUp = function(element) {
  element = $(element).cleanWhitespace();
  var oldInnerBottom = element.down().getStyle('bottom');
  return new Effect.Scale(element, window.opera ? 0 : 1,
   Object.extend({ scaleContent: false, 
    scaleX: false, 
    scaleMode: 'box',
    scaleFrom: 100,
    restoreAfterFinish: true,
    beforeStartInternal: function(effect) {
      effect.element.makePositioned();
      effect.element.down().makePositioned();
      if(window.opera) effect.element.setStyle({top: ''});
      effect.element.makeClipping().show();
    },  
    afterUpdateInternal: function(effect) {
      effect.element.down().setStyle({bottom:
        (effect.dims[0] - effect.element.clientHeight) + 'px' });
    },
    afterFinishInternal: function(effect) {
      effect.element.hide().undoClipping().undoPositioned().setStyle({bottom: oldInnerBottom});
      effect.element.down().undoPositioned();
    }
   }, arguments[1] || {})
  );
};



/************************************Slide Show Related *****************************************/



	var displayWaitMessage=true;	// Display a please wait message while images are loading?
	var activeImage = false;
	var imageGalleryLeftPos = false;
	var imageGalleryWidth = false;
	var imageGalleryObj = false;
	var maxGalleryXPos = false;
	var slideSpeed = 0;
	var imageGalleryCaptions = new Array();
	function startSlide(e)
	{
		//alert('start slide');
		slideSpeed = 0;
		if(document.all)e = event;
		var id = this.id;
		if(this.getElementsByTagName('IMG')[0].src.indexOf('Over')<0)
			this.getElementsByTagName('IMG')[0].src = this.getElementsByTagName('IMG')[0].src.replace('.gif','Over.gif');
		if(this.id=='arrowRight'){
			slideSpeed = -4;
		}else{
			slideSpeed = 6;
		}
	};
	
	function releaseSlide()
	{
		var id = this.id;
		
		this.getElementsByTagName('IMG')[0].src = this.getElementsByTagName('IMG')[0].src.replace('Over','')			
		slideSpeed=0;
	};
	function fastSlide(event)
	{

		var arrow = Event.element(event).parentNode.id;
		imageGalleryWidth = $('galleryContainer').offsetWidth - 80;
		if(arrow.search('Left') != -1)
		{
			var leftPos = imageGalleryObj.offsetLeft;
				leftPos = leftPos + imageGalleryWidth;
			if(leftPos>maxGalleryXPos)
			{				
				leftPos = maxGalleryXPos;
			}
			if(leftPos<minGalleryXPos)
			{
				leftPos = minGalleryXPos;
			}
			
			imageGalleryObj.style.left = leftPos + 'px';
		}
		else
		{
			
			var leftPos = imageGalleryObj.offsetLeft;
				leftPos = leftPos - imageGalleryWidth;
			if(leftPos>maxGalleryXPos)
			{
				leftPos = maxGalleryXPos;
			}
			if(leftPos<minGalleryXPos)
			{
				leftPos = minGalleryXPos;
			}
			imageGalleryObj.style.left = leftPos + 'px';
		}
	}
	function gallerySlide()
	{
		
		if(slideSpeed!=0){
			var leftPos = imageGalleryObj.offsetLeft;
				
			leftPos = eval(leftPos + slideSpeed);
			
			if(leftPos>maxGalleryXPos){
				
				leftPos = maxGalleryXPos;
				slideSpeed = 0;
			}
			if(leftPos<minGalleryXPos){
				leftPos = minGalleryXPos;
				slideSpeed=0;
				//alert("here else");
			}
			
			imageGalleryObj.style.left = leftPos + 'px';
		}
		setTimeout('gallerySlide()',20);
		
	};
	
	function initSlideShow()
	{
		if($('arrowLeft')&& $('arrowRight'))
		{
			
			$('arrowLeft').onmousemove = startSlide;
			$('arrowLeft').onmouseout = releaseSlide;
			$('arrowRight').onmousemove = startSlide;
			$('arrowRight').onmouseout = releaseSlide;
			
			Event.observe($('arrowLeft'), 'click', function(event) {
				fastSlide(event);
			});
			Event.observe($('arrowRight'), 'click', function(event) {
				fastSlide(event);
			});
		}
		totalImgs = $A(document.getElementsByClassName('dashIconsDrag')).length;
		imageGalleryObj = $('theImages');
		imageGalleryLeftPos = imageGalleryObj.offsetLeft;
		imageGalleryWidth = $('galleryContainer').offsetWidth - 80;
		
		maxGalleryXPos = imageGalleryObj.offsetLeft; 
		minGalleryXPos = imageGalleryWidth - $('slideEnd').offsetLeft;		
		
		if(isIE)
		{
		
			var arrAllIcons = $('divIconCollect').getElementsByTagName('img');
			var lenAllIcons = arrAllIcons.length;
			//alert(lenAllIcons);
			var widthImages = 0;
			for(var i =0;i<lenAllIcons;i++)
			{
				var divWidth = $(arrAllIcons[i].id.replace('img','divImg')).style.width.replace('px','');
				divWidth = (isNaN(parseInt(divWidth)))?0:parseInt(divWidth); 
				widthImages = widthImages + divWidth;
			}
					//alert("widthImages : " + widthImages);	
			minGalleryXPos = imageGalleryWidth - widthImages;
			maxGalleryXPos = imageGalleryObj.offsetLeft;
			//minGalleryXPos += 1550;
		}
		
		var slideshowImages = imageGalleryObj.getElementsByTagName('IMG');
		for(var no=0;no<slideshowImages.length;no++){
			slideshowImages[no].onmouseover = revealThumbnail;
			slideshowImages[no].onmouseout = hideThumbnail;
		}
		gallerySlide();
	};
	
/***********************************************End Slide Show*********************************/







function selectAll(parentdiv,all,myObj)
{
	if(all==null)
		all = true;

	if(myObj!=null && myObj.checked)
		all = true;
	else
		all = false;
		
	chkbxArr = $A($(parentdiv).getElementsByTagName("input"));
	chkbxArr.each(
		function(node)
		{
			if(node.type=="checkbox")
				node.checked=all;
		});
};

/******************Number To Money Format******************/
function num2money(n_value,prefix,elementId,dec,retval)
{
	
	dec = (dec)?dec:false;
	retval = (retval)?true:false;
	oNval = n_value.toString();
	if(typeof(n_value) == "string")
	{
		n_value = money2num(n_value);
	}
	if(n_value=="")
	{
		if(elementId!=null)
		{
			if($(elementId).type == "text")
			{
				if(retval)
				{
					$(elementId).value = "";
				}
				else
				{
					$(elementId).value = prefix+"0";
				}
			}
		else
			$(elementId).innerHTML = prefix+"0";
		}
		return;
	}
	var pre = (!prefix)?"$":prefix;
	
	if (isNaN(Number(n_value)))
	return 'ERROR';

	var b_negative = Boolean(n_value < 0);
	n_value = Math.abs(n_value);
	
	// round to 1/100 precision, add ending zeroes if needed
	if(dec && dec>2)
	{
		dec = parseInt(oNval.substr(oNval.indexOf('.')).length-1);
		divd = parseInt(eval('1e'+dec));
		var roundPt = (Math.round(n_value*divd)%divd>9)?(Math.round(n_value*divd)%divd):('0'+Math.round(n_value*divd)%divd);
	}
	else
		var roundPt = (Math.round(n_value*1e2)%1e2>9)?(Math.round(n_value*1e2)%1e2):('0'+Math.round(n_value*1e2)%1e2);
	var s_result = String(roundPt + '00').substring(0,dec);
	// separate all orders
	var b_first = true;
	var s_subresult;
	while (n_value >= 1) 
	{
		s_subresult = (n_value >= 1e3 ? '00' : '') + Math.floor(n_value%1e3);
		s_result = s_subresult.slice(-3) + (b_first ? '.' : ',') + s_result;
		b_first = false;
		n_value = n_value/1e3;
	}
	
	// add at least one integer digit
	if (b_first)
	s_result = '0.' + s_result;

	// apply formatting and return
	if(!dec)
	{
		s_result = s_result.substring(0,s_result.indexOf("."));
	}
	if(elementId!=null)
	{
		if($(elementId).type == "text")
			$(elementId).value = b_negative ? '-'+pre + s_result + '' : pre + s_result;
		else
			$(elementId).innerHTML = b_negative ? '-'+pre + s_result + '' : pre + s_result;
	}
	
	return b_negative
	? '-'+pre + s_result + ''
	: pre + s_result;
};
/******************* String To number************/

function money2num(strMoney) 
{
	var strArr = strMoney.toArray();
	var newnum = "";
	strArr.each(function(i) {
		if(i=="-"||i=="1"||i=="2"||i=="3"||i=="4"||i=="5"||i=="6"||i=="7"||i=="8"||i=="9"||i=="0"||i==".")
		{
			newnum += i;
		}
	});
	newnum = parseFloat(newnum);
	if(!isNaN(newnum))
		return(newnum);
	else
		return "";
};
function numTotal(strMoney)
{
	var strArr = strMoney.toArray();
	var newnum = "";
	strArr.each(function(i) {
		if(i=="1"||i=="2"||i=="3"||i=="4"||i=="5"||i=="6"||i=="7"||i=="8"||i=="9"||i=="0")
		{
			newnum += i;
		}
	});
	newnum = parseFloat(newnum);
	if(!isNaN(newnum))
		return(newnum);
	else
		return "";
}
/**
 * Function For Changing inplace Edit Link
 */
function trim(str)
{ 
	if((str == null) || ( str != null && str.length == 0))
		return "";
	else if (typeof(str) != "string")
		return "";

	return(str.replace(/^\s+|\s+$/g, ''));
};



Array.prototype.find = function(searchStr, from, strict) 
{
	 if(from == undefined || from >= this.length) from = 0;
	   strict = strict == undefined ? false : strict;

	  var returnArray = false;
	  for (i=from; i<this.length; i++) 
	{
		if (typeof(searchStr) == 'function') 
		{
		  if (searchStr.test(this[i]))
			{
				if (!returnArray)
					{ returnArray = [] }
				returnArray.push(i);
			}
		} 
		else
		{
			if(strict)
			{
					if (this[i]===searchStr) 
					{
							if (!returnArray) 
								{ returnArray = [] }
							returnArray.push(i);
					}
			}
			else
			{
				if (this[i]==searchStr) 
				{
					if (!returnArray) 
						{ returnArray = [] }
					returnArray.push(i);
				}
			 }
		}
		
	  }
	  return returnArray;
};
/*
a = ["0",1,2,3,4,5,'',7,"0",1,"1",1,"1",1]
	result1 = a.find ("1"); // return 1,9,10,11,12,13
	result2 = a.find ("1",3);//return 9,10,11,12,13
	result3 = a.find ("1",3,true);//return 10,12
	*/
	
function toggleSlider()
{
	var now = new Date();
	now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
	Element.toggle('toggleDiv');
	if($('after')&&$('before'))
    {
		Element.toggle('after');
		Element.toggle('before');	
    }
    var menuDivArr = document.getElementsByClassName("widgetMenuDiv");
	$A(menuDivArr).each(function(node){
		$(node).style.display = "none";
		oldidMenu = null;
	});
	if($("tabArrow") && $("tabArrow").className.include("_up"))
	{
		$("tabArrow").className ="dashboard_tab_arrow_down";
		document.getElementsByClassName("tabCss").each(function(node){
			node.className = "tabCssCl";
		});
		if($("divSuperParent"))
			$("divSuperParent").addClassName("divSuperParentCl");
	}
	else if($("tabArrow") && $("tabArrow").className.include("_down"))
	{
		$("tabArrow").className ="dashboard_tab_arrow_up";
		document.getElementsByClassName("tabCssCl").each(function(node){
			node.className = "tabCss";
		});
		if($("divSuperParent"))
			$("divSuperParent").removeClassName("divSuperParentCl");
	}
};


function chooseChecked(parentDiv,chkd)
{
	var selectedArr = new Array();
	var selectArr = new Array();
	if($(parentDiv)==null)
	{
		return false;
	}
	parentDiv = $(parentDiv);
	chkbxArr = $A(parentDiv.getElementsByTagName("input"));
	var i=0;
	var j = 0;
	chkbxArr.each(
		function(node)
		{
			if(node.type=="checkbox" && node.id!="sel")
			{
				selectedArr[i]=node.value;
				if(chkd!=null && node.checked)
				{
					selectArr[j] = node.value;
					j++;
				}
				i++;
			}
		});
		if(chkd!=null)
			return selectArr;
		else
			return selectedArr;	
};
function getPositionLeft(element)
{
     var el = $(element);
	 var pL = 0;
     while(el)
     {
           pL += el.offsetLeft;
           el = el.offsetParent;
     }
     return pL;
};
// To find the top position, add this snippet to your code:
function getPositionTop(element)
{
     var el = $(element);var pT = 0;
     while(el)
     {
        pT += el.offsetTop;
        el = el.offsetParent;
     }
     return pT;
};
function showTooltip(tipStr,evnt,xpos)
{
	var e = evnt;
	var xpos = (xpos==null || xpos == "undefined")?50:xpos;
	var element = Event.element(e);
	var leftpos = e.clientX-xpos;
	var toppos = getPositionTop(element)+20;
	if(tipStr!=null || tipStr!="")
	{
		toppos = getPositionTop(element)+5;
		if($("titleInner"))
			$("titleInner").innerHTML = tipStr;
	}
	else
	{
		if($("titleInner"))
			$("titleInner").innerHTML = $("titleInner").title;
	}
	if($("titleDiv"))
	{
		$("titleDiv").style.width = "50px";
		$("titleDiv").style.left = leftpos+"px";
		$("titleDiv").style.top = eval(toppos+50)+"px";
		$("titleDiv").style.display = "inline";
	}
};
function hideTooltip()
{
	if($("titleDiv"))
	{
		$("titleDiv").style.display = "none";
		$("titleDiv").style.left = "0px";
		$("titleDiv").style.top = "0px";
	}
};


function getGeoAdd(lat,lng,city,state,zip,page,action,otherArgs)
{
	//alert(page);
		//alert("4"+zip);
		var myState = '';
		if(state.indexOf('|')>-1)
		{
			var arrState = state.split('|');
			myState = arrState[0];	
		}
		
		if(city.indexOf('|')>-1)
		{
			var arrCity = city.split('|');
			city = arrCity[0];	
		}
		
		var geoCodeResp = function(geoResponse)//response function for ajax call from getGeoAdd
		{
			var geoArr = eval('('+geoResponse.responseText+')');
			var geoStatus = geoArr[0].status;
			if(geoStatus!=0)
			{
				var geoCity = "";
				var geoState = "";
				var geoZip = "";
				//alert(lat+","+lng+","+city+","+state+","+zip+","+page+","+action);
				//alert('Sorry, We couldn\'t find a location for "' + geoArr[0].originaladdress + '"');
				switch(action)
				{
					case 'start':
						//alert('startNo');
						getGeoAdd(lat,lng,city,state,zip,page,'zip');
					break;
					case 'zip':
						//alert('zipNo');
						getGeoAdd(lat,lng,city,state,zip,page,'end');
					break;
				}
				return;
			}
			else
			{
				//alert('bye');
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoZip = geoArr[0].zip;
				var geoAddress = geoArr[0].address;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				if(geoCity=="" && geoZip=="")
				{
					alert('Please specify City or Zip');
					return;
				}
				else if((geoLat == "0" && geoLong == "0") || (geoLat == 0 && geoLong == 0))
				{
					//alert('else if');
					switch(action)
					{
						case 'start':
							//alert('startNo');
							getGeoAdd(lat,lng,city,state,zip,page,'zip');
						break;
						case 'zip':
							//alert('zipNo');
							getGeoAdd(lat,lng,city,state,zip,page,'end');
						break;
					}
					return;	
				}
				
				if(geoState == "")
					geoState = state;
				setSearchCookie("searchAddress",geoAddress);
				/*setSearchCookie("city",geoCity);
				setSearchCookie("state",geoState);
				setSearchCookie("zip",geoZip);*/
				//var cszFromCookie = setCSZValue (getSearchCookie("city"), state, getSearchCookie("zip"));
				/*if($("searchCSZ") && page != "ListMyHome")
					$("searchCSZ").value = cszFromCookie;*/
				
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				var latLongStr = "[{'lat':'"+geoLat+"','lng':'"+geoLong+"'}]";
				var now = new Date();
				now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
				setCookie("latLongCk",latLongStr,now);
				latLong = eval(getCookie("latLongCk"))[0];
			}
			
			setSearchCookie("city",listAllCity);
			setSearchCookie("state",state);
			
			if(page.include("METRO"))
			{
				var strFromWhere = page.split("|");
				var mapit=strFromWhere[1];
				var widgetName =strFromWhere[2]; 
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoZip = geoArr[0].zip;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				var url;
				if(isZip)
				{	
					if(geoZip == "")
						geoZip = zip;
				}
				else
					geoZip = '';
				//alert(state);
				//return;
				if(mapit=="mapitAddr")
				{
					var geoAddress = geoArr[0].address;
					if(listAllCity != false)
					{
						var tempArr = listAllCity.split('|');
						//alert(tempArr.length);
						if(tempArr.length != 1) 
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+listAllCity+","+state+",,,,,"+geoLat+","+geoLong;
						else
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+listAllCity+","+state+","+geoZip+",,,,"+geoLat+","+geoLong;
					}
					else
					 	url = "app/listing/singlePropertyLanding.php?PHPSESSID=&status=EXP&address="+geoAddress+","+geoCity+","+state+","+geoZip+",,,,"+geoLat+","+geoLong;
					 //url = "app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName;
				}
				else if(mapit=="mapit")
				{						
					 if(listAllCity != false)
					 {
						var tempArr = listAllCity.split('|');
						//alert(tempArr.length);
						if(tempArr.length != 1)
						 {
							url = "Search/"+state+"/"+geoCity;
							 if(zip != "")
								url += "/"+geoZip;
							//url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+",,,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName;
						 }
						else
						 {
							url = "Search/"+state+"/"+geoCity;
							 if(zip != "")
								url += "/"+geoZip;
							//url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName;
						 }
					 }
					 else
					{
						 url = "Search/"+state+"/"+geoCity;
						 if(zip != "")
							url += "/"+geoZip;
					 	//url = "app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+state+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName;//+",jbfeaturedlistings";
					}
				}
				else if(mapit=="multicity")
				{
					setSearchCookie("city",listAllCity);
					setSearchCookie("state",state);
					//cszFromCookie = setCSZValue (getSearchCookie("city"), myState);
					
					 if(listAllCity != false)
					 {
						var tempArr = listAllCity.split('|');
						//alert(tempArr.length);
						if(tempArr.length != 1) 
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+",,,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName;
						else
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName;
					 }
					 else
					 	url = "app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+state+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName;//+",jbfeaturedlistings";
				}
				//alert(url);
				if(otherArgs!= null)
					url = url + otherArgs;
				location.href = url;
				return;
			}
			else if(page.include("LMSRE"))
			{
				var address="";
				//alert(geoArr);
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				if(geoState == "")
					geoState = state;
				
				var geoZip = geoArr[0].zip;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				var url;
				if(Exclusiveflag==1)
					url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+address+","+listAllCity+","+state+",,,,,"+geoLat+","+geoLong+"&widgetnames=exclusivelisting";
				else
					url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+address+","+listAllCity+","+state+",,,,,"+geoLat+","+geoLong+"&widgetnames=mlsCountySearch";

				if(otherArgs!= null)
					url = url + otherArgs;
				location.href = url;
				return;			
			}	
		}
		
		if(lat != "0" || lng != "0")
		{
			//alert(lat+","+lng)
			if(page.include("METRO"))
			{
				var strFromWhere = page.split("|");
				var mapit=strFromWhere[1];
				var widgetName =strFromWhere[2];
				var url;

				var latLongStr = "[{'lat':'"+lat+"','lng':'"+lng+"'}]";
				var now = new Date();
				now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
				setCookie("latLongCk",latLongStr,now);
				if(!isZip)
					zip = '';
				
				setSearchCookie("city",listAllCity);
				setSearchCookie("state",state);
				//var	cszFromCookie = setCSZValue (getSearchCookie("city"), state);
				if(mapit=="mapitAddr")
				{
					var geoAddress;
					
					
					if($("txtAddress"))
						geoAddress = $("txtAddress").value;
					else
						geoAddress="";
						
					if(listAllCity != false)
					{
						var tempArr = listAllCity.split('|');
						//alert(tempArr.length);
						if(tempArr.length != 1) 
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+listAllCity+","+state+",,,,,"+lat+","+lng;
						else
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+listAllCity+","+state+","+zip+",,,,"+lat+","+lng;
					}
					else
						url = "app/listing/singlePropertyLanding.php?PHPSESSID=&status=EXP&address="+geoAddress+","+city+","+state+","+zip+",,,,"+lat+","+lng;
				
				}
				else if(mapit=="mapit")
				{					
					removeSearchCookie("city");
					removeSearchCookie("state");
					 //alert("2"+ zip+" , "+isZip);					
					 url = "Search/"+state+"/"+city;
	    			 if(zip != "")
						url += "/"+zip;
					 /*if(listAllCity != false)
					 {
						var tempArr = listAllCity.split('|');
						//alert(tempArr.length);
						if(tempArr.length != 1) 
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+",,,,,"+lat+","+lng+"&widgetnames="+widgetName;
						else
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+","+zip+",,,,"+lat+","+lng+"&widgetnames="+widgetName;
					 }
					 else
					 	//url = "app/listing/singlePropertyLanding.php?status=EXP&address=,"+city+","+state+","+zip+",,,,"+lat+","+lng+"&widgetnames="+widgetName;//+",jbfeaturedlistings";*/
				}
				else if(mapit=="multicity")
				{
					 if(listAllCity != false)
					 {
						var tempArr = listAllCity.split('|');
						//alert(tempArr.length);
						if(tempArr.length != 1) 
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+",,,,,"+lat+","+lng+"&widgetnames="+widgetName;
						else
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+","+zip+",,,,"+lat+","+lng+"&widgetnames="+widgetName;
					 }
					 else
					 	url = "app/listing/singlePropertyLanding.php?status=EXP&address=,"+city+","+state+","+zip+",,,,"+lat+","+lng+"&widgetnames="+widgetName;//+",jbfeaturedlistings";
				}
				//if(otherArgs!= null)
				//	url = url + otherArgs;
				location.href = url;
			}
			else if(page.include("LMSRE"))
			{
				var address="";
				var url;
//				alert("LMSRE : "+lat+","+lng);
				if(Exclusiveflag==1)
					url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+address+","+listAllCity+","+state+",,,,,"+lat+","+lng+"&widgetnames=exclusivelisting";
				else
					url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+address+","+listAllCity+","+state+",,,,,"+lat+","+lng+"&widgetnames=mlsCountySearch";
				
				setSearchCookie("city",listAllCity);
				setSearchCookie("state",state);
				var latLongStr = "[{'lat':'"+lat+"','lng':'"+lng+"'}]";
				var now = new Date();
				now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
				setCookie("latLongCk",latLongStr,now);
				if(otherArgs!= null)
					url = url + otherArgs;
				location.href = url;
				//return;			
			}	
		}
		else
		{
			//alert('else');
			var geoAddress;
			var geoUrl = "/classes/getCSZ.php";
			
			if($("txtAddress"))
				geoAddress = $("txtAddress").value;
			else
				geoAddress="";
			
			var geoQueryString;
			switch(action)
			{
				case 'start':
					geoQueryString = "csz="+city+","+myState+"&address="+geoAddress;	
					//alert('start');
					ajaxRequest(geoUrl,geoQueryString,geoCodeResp);
				break;
				case 'zip':
					geoQueryString = "csz="+city+","+myState+","+zip+"&address="+geoAddress;	
					//alert('zip');
					ajaxRequest(geoUrl,geoQueryString,geoCodeResp);
				break;
				case 'end':
					//alert('Ends');
					if(page.include("METRO"))
					{
						var strFromWhere = page.split("|");
						var mapit=strFromWhere[1];
						var widgetName =strFromWhere[2];
						var url;
						if(!isZip)
							zip = '';
						if(mapit=="mapitAddr")
						{
							var geoAddress;
							if($("txtAddress"))
								geoAddress = $("txtAddress").value;
							else
								geoAddress="";
								
							 if(listAllCity != false)
							 {
								var tempArr = listAllCity.split('|');
								//alert(tempArr.length);
								if(tempArr.length != 1) 
									url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+listAllCity+","+state+",,,,,"+lat+","+lng;
								else
									url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+listAllCity+","+state+","+zip+",,,,"+lat+","+lng;
							 }
							 else
								 url = "app/listing/singlePropertyLanding.php?PHPSESSID=&status=EXP&address="+geoAddress+","+city+","+state+","+zip+",,,,"+lat+","+lng;
						}
						else if(mapit=="mapit")
						{
							 //alert("3"+ zip+" , "+isZip);
							 if(listAllCity != false)
							 {
								var tempArr = listAllCity.split('|');
								//alert(tempArr.length);
								if(tempArr.length != 1)
								{
									//alert('e');
									url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+",,,,,"+lat+","+lng+"&widgetnames="+widgetName;
								}
								else
								{
									//alert('d');
									url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+","+zip+",,,,"+lat+","+lng+"&widgetnames="+widgetName;
								}
							 }
							 else
							 url = "app/listing/singlePropertyLanding.php?status=EXP&address=,"+city+","+state+","+zip+",,,,"+lat+","+lng+"&widgetnames="+widgetName;//+",jbfeaturedlistings";
						}
						if(otherArgs!= null)
							url = url + otherArgs;
						location.href = url;
					}
					else if(page.include("LMSRE"))
					{
						var address="";
						if(Exclusiveflag==1)
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+address+","+listAllCity+","+state+",,,,,"+lat+","+lng+"&widgetnames=exclusivelisting";
						else
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+address+","+listAllCity+","+state+",,,,,"+lat+","+lng+"&widgetnames=mlsCountySearch";
						//alert(url);
						if(otherArgs!= null)
							url = url + otherArgs;
						location.href = url;
					}
				break;
			}
			//var geoQueryString = "csz="+city+","+state+","+zip+"&address="+geoAddress;
		}
}


function getGeocodeAddress(csz,page)
{
		var geoCbFn = function(geoResponse)
		{
			var geoArr = eval('('+geoResponse.responseText+')');
			var geoStatus = geoArr[0].status;
			if(geoStatus!=0)
			{
				var geoCity = "";
				var geoState = "";
				var geoZip = "";
				alert('Sorry, We couldn\'t find a location for "' + geoArr[0].originaladdress + '"');
				if (page=="ValueMyHome")
				{
					$('btnSearchEstimateAddress').style.display = "";
					$('statusMsg').style.display = "none";
				}
				
				return;
			}
			else
			{

				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoZip = geoArr[0].zip;
				var geoAddress = geoArr[0].address;
				if(geoCity=="" && geoZip=="")
				{
					alert('Please specify City or Zip');
					return;
				}
				if($("searchCity"))
					$("searchCity").value = geoCity;
				if($("searchState"))
					$("searchState").value = geoState;
				if($("searchZip"))
					$("searchZip").value = geoZip;
				if($("searchAddress")  && page != "ListMyHome")
					$("searchAddress").value = geoAddress;
					
				
				setSearchCookie("searchAddress",geoAddress);
				setSearchCookie("city",geoCity);
				setSearchCookie("state",geoState);
				setSearchCookie("zip",geoZip);
				setSearchCookie("county","");
				
				var cszFromCookie = setCSZValue (getSearchCookie("city"), getSearchCookie("state"), getSearchCookie("zip"));
				if($("searchCSZ") && page != "ListMyHome")
					$("searchCSZ").value = cszFromCookie;
				
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				var latLongStr = "[{'lat':'"+geoLat+"','lng':'"+geoLong+"'}]";
				var now = new Date();
				now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
				setCookie("latLongCk",latLongStr,now);
				latLong = eval(getCookie("latLongCk"))[0];
				
				
			}
			//alert(page);
			if(page != "campaign" && page != "landing" && page != "ListMyHome" && page != "snapShot" && page != "VOH" && page != "BST" && page != "FAH" && page != "FAO" && page != "VH" && !(page.include("LMSRE")) && page != "LMSRE_SmartWin" && page != "METRO_AssOff" &&!(page.include("METRO")))
			{
				if(trim($('searchAddress').value) == "")$('searchAddress').value = "optional";	

				if(document.cookie=="")
					pageReload();
			}
			if(page=="dashboard")
			{
				funQckUpdateWidgets();		
			}
			else if(page=="singleProp")
			{
				funExploreOnMapit();//alert("Please add your function call for MapIt in common.js");
			}
			else if(page=="landing")
			{
				window.location.href = './app/dashboard/dashboardIndex.php';
			}
			else if(page == "dashboardbitz")
			{
				window.location.href = '../../app/dashboard/dashboardIndex.php?setDsh=1';
			}
			else if(page=="campaign")
			{

				lat = latLong.lat;
				lng = latLong.lng;

				if (geoArr[0].city !="")
					var geoCityStr = geoArr[0].city;
				if (geoArr[0].state !="")
					geoCityStr += ", "+geoArr[0].state;
				if (geoArr[0].zip !="")
					geoCityStr += ", "+geoArr[0].zip;
				//return geoCityStr;
				if(trim(geoCityStr)=="") 
					alert("Please refine your search criteria");
				else
					sendDashboard(geoCity,geoState,geoZip,lat,lng);
			}
			else if(page=="ValueMyHome")
			{
				var url = "../feed/homeEstimate.php?pid=&address="+geoAddress+","+geoCity+","+geoState+","+geoZip;
				window.open(url,"_blank");
				$('btnSearchEstimateAddress').style.display = "";
				$('statusMsg').style.display = "none";
			}
			
			else if(page=="ExploreNeighborhood")
			{
				
				var url = './dshbrdExplore.php';
				var qryStr = 'geoAddress=1&exploreAddress='+geoAddress+'&exploreCity='+geoCity+'&exploreState='+geoState+'&exploreZip='+geoZip;
				ajaxRequest(url,qryStr,function(respObj)
				{
					if (respObj.responseText=="0")
					{
						alert("Sorry, Not Able To Resolve Address");
						$('btnSearchExplore').style.display = "";
						$('expStatusMsg').style.display = "none";
					}
					else
					{
						var url = respObj.responseText;
						window.open(url,"_blank");
						$('btnSearchExplore').style.display = "";
						$('expStatusMsg').style.display = "none";
					}
				});
			}
			
			else if(page=="ListMyHome")
			{
				$('btnGetBids').style.display = "none";
				$('statusMsgListHome').style.display = "";

				var url = './dshbrdLMH.php';
				var qryStr = 'validateAddress=1&address='+geoAddress+'&city='+geoCity+'&state='+geoState+'&zip='+geoZip+'&expt='+exptdSales+'&name='+names+'&email='+email+'&timel='+timeLine;
				var divid = $('listHome').id;
				loadToDiv(url,qryStr,divid);			
			}
			else if(page=="snapShot")
			{
				getListingSnapshots();
			}
			else if(page=="FAH")
			{
				var url = "app/dashboard/dashboardIndex.php";
				location.href = url;
			}
			else if(page=="BST")
			{
				var url = "app/dashboard/dashboardIndex.php";
				location.href = url;
			}
			else if(page=="VOH")
			{
				var url = "app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong;
				location.href = url;
			}
			else if (page=="VH")
			{
				var csz = geoCity+","+geoState+","+geoZip;
				var url = "app/feed/homeEstimate.php?pid=&address="+escape(geoAddress)+","+escape(csz);
				location.href = url; 				
			}
			else if(page=="FAO")
			{
				var url = "app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong;
				location.href = url;
			}
			else if(page=="METRO_AssOff")
			{
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoZip = geoArr[0].zip;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				
				var url = "app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames=brokeragents,brokeroffices";
				location.href = url;
			}
			else if(page=="METRO_AssAgtOff")
			{
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoZip = geoArr[0].zip;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				var qs = "";
				var wdNm = "brokeragents";
				var isOthSet = false;
				if(isBlank('txtFname','First Name'))
				{
					qs += "&fname="+$F('txtFname');
					isOthSet= true;
				}
				
				if(isBlank('txtLname','Last Name'))
				{
					qs += "&lname="+$F('txtLname');
					isOthSet= true;
				}
				
				if(isBlank('txtCityName','City'))
				{
					qs += "&cityName="+escape($F('txtCityName'));
					wdNm = wdNm + ",officeLocation";
					isOthSet= true;
				}
				
				if($F('txtOffice') != "")
				{
					//qs += "&office="+escape($F('txtOffice'));
					qs += "&office="+escape($("txtOffice").options[$("txtOffice").selectedIndex].value);
					wdNm = wdNm + ",brokeroffices";
					isOthSet= true;
				}
				
				if($F('txtOfficeLoc') != "")
				{
					//qs += "&office="+escape($F('txtOffice'));
					qs += "&officeLoc="+escape($("txtOfficeLoc").options[$("txtOfficeLoc").selectedIndex].value);
					//alert($F('txtOfficeLoc'));return;
					/*if(isOthSet)
						wdNm = wdNm + ",officeLocation";
					else
						wdNm = "officeLocation";*//*old*/
					
					if(!wdNm.include("officeLocation"))
						wdNm = wdNm + ",officeLocation";/*new*/	
				}				
				var showDialog="";
				if(wdNm != "officeLocation")
					showDialog = "&showAgentDialog=some";
				else
					showDialog = "&showAgentDialog=";
				var url = "app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+wdNm+showDialog+qs;
				
				//var url = "./app/listing/singlePropertyLanding.php?status=EXP&address=,denver,CO,,,,,39.755092,-104.988123&widgetnames=brokeragents,brokeroffices&showAgentDialog=1";
				//alert(url);
				location.href = url;
			}
			else if(page=="LMSRE_SmartWin")
			{
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				sendAddressFldsToLMSRE(geoCity,geoState,geoLat,geoLong);
			}
			else if(page.include("LMSRE"))
			{
				var strFromWhere = page.split("|");
				var mapit=strFromWhere[1];
				var widgetName =strFromWhere[2]; 
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoZip = geoArr[0].zip;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				var url;
				var moreWidgets="";
				moreWidgets = getCookie("strMapitCK");
				if(widgetName=="terabitzMap")
				{
					url = "/app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames=";
				}
				else if(mapit=="mapit")
				{
					var ps = "";
					if(typeof(powerSearch) != 'undefined' && powerSearch == '1' && (uRole == 'EA' || uRole == 'A'))
						var ps = "&ps=1";

					if(moreWidgets == "" || moreWidgets == null)
					{
						url = "/app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName+ps;
					}
					else
					{
						url = "/app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName+","+moreWidgets+ps;
					}
					if(uid != "")
						setCookie("strMapitCK","");
				}
				else if(mapit=="fromMapIt")
				{
					if(moreWidgets == "" || moreWidgets == null)
					{
						url = "/app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName;
					}
					else
					{
						url = "/app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName+","+moreWidgets;
					}
				}
				else if(mapit=="dashboard")
				{
					//url = "/app/dashboard/dashboardIndex.php?loadnow=1&code=searchAddress=:::city="+geoCity+":::state="+geoState+":::county=:::neighborhood=:::minPrice=:::maxPrice=:::searchBeds=:::minSize=:::maxSize=:::searchBaths=:::searchType=:::searchSortType=ph:::ckLFDate=:::ckLTDate=:::zip=&fe=&f=1&propLatitude="+geoLat+"&propLongitude="+geoLong;
					url = "/app/dashboard/dashboardIndex.php";
				}
				else if(mapit=="dashboardindex")
				{
					eval("var hashDshbrdBitz="+lmsreDshbrdBitz); 
					if(eval("hashDshbrdBitz['"+widgetName+"']")!=null)
	 				{	
	 					hashVal = eval("hashDshbrdBitz['"+widgetName+"']");
	 					url = "/app/dashboard/dashboardIndex.php?loadnow=1&code=searchAddress=:::city="+geoCity+":::state="+geoState+":::county=:::neighborhood=:::minPrice=:::maxPrice=:::searchBeds=:::minSize=:::maxSize=:::searchBaths=:::searchType=:::searchSortType=ph:::ckLFDate=:::ckLTDate=:::zip=&id=:::"+hashVal+",1,2&fe=&f=1&propLatitude="+geoLat+"&propLongitude="+geoLong;
 					}
	 			}
				location.href = url;
			}
			else if(page.include("METRO"))
			{
				var strFromWhere = page.split("|");
				var mapit=strFromWhere[1];
				var widgetName =strFromWhere[2]; 
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoZip = geoArr[0].zip;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				if(geoState!="CO")
				{
					alert("Sorry, we do not support any other state then CO.");
					return;
				}
				var url;
				var extra = "";
				if(widgetName == "exclusivecol")
				{
					extra = "&mapZoomLevel=9";
					var now = new Date();
					now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
					setCookie("mapSearchSelect","1",now);
				}

				if(mapit=="mapitAddr")
				{
					var geoAddress = geoArr[0].address;
					 widgetName = 'mlsaddrsearch';
					 url = "app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName+extra;
				}
				else if(mapit=="mapit")
				{
					//alert(3);
					var dist = "";
					var distStr = "";
					if($("distanceChk").checked)
					{
						dist = $F("distance");
						distStr = "&mapZoomLevel=" + dist;//"&distance="+dist;
					}

					if(widgetName == "exclusivecol")
					{
						distStr = "&mapZoomLevel=9";
					}

					//url = "app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName+distStr;//+",jbfeaturedlistings";
					url = "Search/"+geoState+"/"+geoCity;
					if(geoZip != "")
						url += "/"+geoZip;
					
					removeSearchCookie("city");
					removeSearchCookie("state");
				}
				else if(mapit=="fromMapIt")
				{
					url = "/app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName+extra;
				}
				else if(mapit=="dashboard")
				{
					url = "/app/dashboard/dashboardIndex.php?loadnow=1&code=searchAddress=:::city="+geoCity+":::state="+geoState+":::county=:::neighborhood=:::minPrice=:::maxPrice=:::searchBeds=:::minSize=:::maxSize=:::searchBaths=:::searchType=:::searchSortType=ph:::ckLFDate=:::ckLTDate=:::zip=&fe=&f=1&propLatitude="+geoLat+"&propLongitude="+geoLong;
				}
				else if(mapit=="dashboardindex")
				{
					if(widgetName=="demographics")
						url = "app/dashboard/dashboardIndex.php?loadnow=1&code=searchAddress=:::city="+geoCity+":::state="+geoState+":::county=:::neighborhood=:::minPrice=:::maxPrice=:::searchBeds=:::minSize=:::maxSize=:::searchBaths=:::searchType=:::searchSortType=ph:::ckLFDate=:::ckLTDate=:::zip=&id=28,1,1:::&fe=&f=1&propLatitude="+geoLat+"&propLongitude="+geoLong;
					if(widgetName=="climate")
						url = "app/dashboard/dashboardIndex.php?loadnow=1&code=searchAddress=:::city="+geoCity+":::state="+geoState+":::county=:::neighborhood=:::minPrice=:::maxPrice=:::searchBeds=:::minSize=:::maxSize=:::searchBaths=:::searchType=:::searchSortType=ph:::ckLFDate=:::ckLTDate=:::zip=&id=19,1,1:::&fe=&f=1&propLatitude="+geoLat+"&propLongitude="+geoLong;
					if(widgetName=="mortgage rates")
						url = "app/dashboard/dashboardIndex.php?loadnow=1&code=city="+geoCity+":::state="+geoState+":::county=:::minsqft=:::maxsqft=:::minSize=:::maxSize=:::searchType=:::searchAddress=:::searchSortType=ph:::ckLFDate=:::ckLTDate=:::minPrice=:::maxPrice=:::searchBeds=:::searchBaths=:::zip=&id=50,1,1:::&fe=&f=1&propLatitude="+geoLat+"&propLongitude="+geoLong;;
					if(widgetName=="mcalc")
						url = "app/dashboard/dashboardIndex.php?loadnow=1&code=city="+geoCity+":::state="+geoState+":::county=:::minsqft=:::maxsqft=:::minSize=:::maxSize=:::searchType=:::searchAddress=:::searchSortType=ph:::ckLFDate=:::ckLTDate=:::minPrice=:::maxPrice=:::searchBeds=:::searchBaths=:::zip=&id=24,1,1:::&fe=&f=1&propLatitude="+geoLat+"&propLongitude="+geoLong;
				}
				location.href = url;
			}
			else if(page == "METRO_GOTLL")
			{
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoZip = geoArr[0].zip;
				sendAddressForLatLong(geoCity,geoState,geoZip);
			}
			else if(page=="METRO_SmartWin")
			{
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				sendAddressFldsToMETRO(geoCity,geoState,geoLat,geoLong);
			}
			else
			{
				submitSearchForm();
			}
		}
		
		if (page == 'ValueMyHome')
		{
			var geoAddress = $("valueHomeAddress").value;
		}
		else if (page == 'ExploreNeighborhood')
		{
			var geoAddress = $("exploreAddress").value;
		}
		else if (page == 'ListMyHome')
		{
			var geoAddress = $("listHomeAddress").value;
			var exptdSales = $("expectedSale").value;
			var names = $("listHomeName").value;
			var email = $("listHomeEmail").value;						
			var timeLine = $("timeLine").value;									
		}
		else if (page == 'landing')
		{
			if ($('searchAddress').value == "optional")
			{
				var geoAddress = "";
			}
			else
			{
				var geoAddress = $("searchAddress").value;
			}

			if  ($('searchCSZ').value == "required")
			{
				alert ('Please enter a location.');
				return;
			}
		}
		else if(page == 'campaign')
		{
			var geoAddress ="";
		}
		else if(page == "FAH" || page == "BST" || page == "VOH" || page == "VH" || page == "FAO")
		{
			if ($('searchAddress').value == "optional")
			{
				var geoAddress = "";
			}
			else
			{
				var geoAddress = $("searchAddress").value;
			}
		}
		else if(page.include("LMSRE") || page=="LMSRE_SmartWin" || page.include("METRO") || page=="METRO_SmartWin" || page == 'Metro')
		{
			var geoAddress; 
			if($("txtAddress"))
				geoAddress = $("txtAddress").value;
			else
				geoAddress="";
		}
		else
		{
			var geoAddress = $("searchAddress").value;
		}
		
	
		var geoUrl = "/classes/getCSZ.php";
		var geoQueryString = "csz="+csz+"&address="+geoAddress;
		if (page == 'METRO')
		{
			ajaxRequest(geoUrl,geoQueryString,geoCbFn,false);
		}
		else
		{
			ajaxRequest(geoUrl,geoQueryString,geoCbFn);
		}

}

//--------------------------- Search Funtions -----------------------------//
function isNumeric(strValue)
{
	var objRegExp  = /(^-?\d\d*$)/;
	return objRegExp.test(strValue);
};

function submitSearchForm()
{
	if (($F('searchCity') == "") && ($F('searchZip') == ""))
	{
		alert ("Atleast one of 'City' or 'Zip' is requied");
		return false;
	}

	if(!zipValid('searchZip'))
	{
		alert("Zip is invalid");
		return false;
	}
	if(!numberIsValid('yearFrom',"Please enter valid year value","Year From",null,null))
	{
		alert ("Please enter valid year value");
		return false;
	}
	else
	{
		 if($('yearFrom').value!="" && $('yearFrom').value!=" ")
		 {
			 if($('yearFrom').value.length < 4)
			 {
				alert ("Year From should be 4 charcters long.");
				return false;
			 }
		}
	}
	
	if(!numberIsValid('yearTo',"Please enter valid year value","Year To",null,null))
	{
		alert ("Please enter valid year value");
		return false;
	}
	else
	{
		if($('yearTo').value!="" && $('yearTo').value!=" ")
		{
			 if($('yearTo').value.length < 4)
			 {
				alert ("Year To should be 4 charcters long.");
				return false;
			 }
		}
	}
	var contextArray = new Array("onSale","openHouse","newHomes","allHomes");
	var searchAddress = $F('searchAddress');
	if($('srchPopInDiv'))
		Element.toggle('srchPopInDiv');

	var saleable = "3";
	var userContext = "allHomes";
	var queryString = "address=" + escape(searchAddress);
		queryString = queryString + "&city=" + escape(trim($F("searchCity")));
		queryString = queryString + "&state=" + escape(trim($F("searchState")));
		queryString = queryString + "&zip=" + escape(trim($F("searchZip")));
		queryString = queryString + "&minprice=" + escape(money2num($F("minPrice")));
		queryString = queryString + "&maxprice=" + escape(money2num($F("maxPrice")));
		queryString = queryString + "&minsqft=" + escape($F("minSize"));
		queryString = queryString + "&maxsqft=" + escape($F("maxSize"));
		queryString = queryString + "&beds=" + escape($F("searchBeds"));
		queryString = queryString + "&baths=" + escape($F("searchBaths"));
		queryString = queryString + "&searchType=" + escape($F("searchType"));
		queryString = queryString + "&saleable=" + escape(saleable);
		queryString = queryString + "&usercontext=" + escape(userContext);
		setCookie("checkedType",saleable,now);
		
	//-------------------setting client side cookies--------------------//
	var now = new Date();
	now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
	setAllToCookie();
	url = "../listing/checkRecords.php";
	if ($('signInDiv')) Element.toggle('signInDiv');
	if ($('srchDiv')) Element.toggle('srchDiv');
	ajaxRequest(url,queryString,evalResponce);	
};

function evalResponce(originalRequest)
{
	var recCount = parseInt(originalRequest.responseText);
	if (recCount < 0)
	{
		if ($('srchDiv')) Element.toggle('srchDiv');
		if ($('signInDiv')) Element.toggle('signInDiv');
		alert("Sorry cannot connect to server");
	}	
	else if (recCount == 0)
	{
		if ($('srchDiv')) Element.toggle('srchDiv');
		if ($('signInDiv')) Element.toggle('signInDiv');
		alert("Sorry no records found");
		if($('srchPopInDiv'))
			Element.toggle('srchPopInDiv');
	}	
	else
	{
		window.location.href = "../listing/searchResult.php?PHPSESSID="+sessid;
	}
};

//--------------------------- Search Funtions -----------------------------//
function contactUs(type)
{
	alert ("For technical issues, please contact us at support@terabitz.com"+'\n'+"Broker-Agents contact us at brokeragentsupport@terabitz.com"+'\n'+"For all other inquiries, please contact us at info@terabitz.com");
}
/*********************************************************************************
 * Getting window size and scroll bars position in JavaScript/DHTML
 * http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html
 * author : Hi Pratik!
 * Date	: 15th May 2007
 * 
 ********************************************************************************** 
 */

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function Querystring(qs) { 
	this.qs = qs;
	this.params = new Object();
	this.get=Querystring_get;
	this.set = Querystring_set;
	if (this.qs == null)
		this.qs=location.search.substring(1,location.search.length)

	if (this.qs.length == 0) return

	this.qs = this.qs.replace(/\+/g, ' ')
	var args = this.qs.split('&') // parse out name/value pairs separated via &
	
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0]);
        if(i==0)
		{
			name = name.substr(eval(name.indexOf('?')+1),name.length);
		}
		if (pair.length == 2)
			value = unescape(pair[1]);
		else
			value = name;
		this.params[name] = value;
	}
}

function Querystring_get(key, default_) 
{
	if (default_ == null) default_ = null;
	
	var value=this.params[key];
	if (value==null) value=default_;
	return value;
}
function Querystring_set(key,value)
{
	if(key == null)
		return;
	if(value == null)
		value = "";	
	this.params[key] = unescape(value);
	var paramKeys = Object.keys(this.params);
	var myQS = "";
	for(var i=0;i<paramKeys.length;i++)
	{
		myQS = myQS + "&" + paramKeys[i] + "=" + escape(this.params[paramKeys[i]]);
	}
	myQS = myQS.substr(1,myQS.length);
	this.qs = myQS;
}
Element.addMethods({
  hasAttributeValue: function(element, attrName, attrVal, separator) {
    element = $(element);
    attrName = trim(attrName);
    separator = (separator)?(separator):" ";
    var attr = element.readAttribute(attrName);
    if(attr==null || attr =="")
    	return false;
    attrVal = trim(attrVal);
    if(attr!="" || trim(attr)!="")
    {
    	attr = attr.replace (/^\s+/g, "").replace (/\s+$/g, "").replace (/\s+/g, " ");
    	var attrArr = attr.split(separator);
    	var retVal = attrArr.find(attrVal);
    	if(retVal===false)
    		return false;
    	else
    		return true;
    }
    return false;
  }
});
  
document.getElementsByAttributeVal = function(attrName,attrVal, parentElement) {
  if (Prototype.BrowserFeatures.XPath) {
    var q = ".//*[contains(concat(' ', @"+ attrName +", ' '), ' " + attrVal + " ')]";
    return document._getElementsByXPath(q, parentElement);
  } else {
    var children = ($(parentElement) || document.body).getElementsByTagName('*');
    var elements = [], child;
    for (var i = 0, length = children.length; i < length; i++) {
      child = children[i];
      if ($(child).hasAttributeValue(attrName, attrVal))
      {
        elements.push(Element.extend(child));
      }
    }
    return elements;
  }
};
//("groupid","3","galleryContainer")
var lastArrow = false;
function searchAddressFormat(event,defaultText)
{
	if(typeof(event)!="string")
	{
		var element = Event.element(event);
			if(event.type=="blur")
	{
		var srchVal = element.value.replace (/^\s+/g, '').replace (/\s+$/g, '').replace (/\s+/g, ' ');
		if(srchVal == '')
		{
			element.value=defaultText;
			element.className = element.className.gsub("N","");
		}
		else
		{
			element.value=srchVal;
			if(element.className.indexOf("N")==-1)
				element.className = String(element.className+"N");
		}
	}
	if(event.type=="focus")
	{
		if(element.value==defaultText)
		{
			element.value='';
			if(element.className.indexOf("N")==-1)
				element.className = String(element.className+"N");
		}
	}
		
	}
	else
	{
		var element = $(event);
		var srchVal = element.value.replace (/^\s+/g, '').replace (/\s+$/g, '').replace (/\s+/g, ' ');
		if(srchVal == '')
		{
			element.value=defaultText;
			element.className = element.className.gsub("N","");
		}
		else
		{
			element.value=srchVal;
			if(element.className.indexOf("N")==-1)
				element.className = String(element.className+"N");
		}
	}	
}
function findBitFormat()
{
	if(trim($("findBitTxt").value) == "")
	{
		$("findBitTxt").value = "Find Bit";
		$("findBitTxt").className = "textboxstyle";
	}
	else if(trim($("findBitTxt").value) == "Find Bit")
	{
		$("findBitTxt").value = "";
		$("findBitTxt").className = "textboxstyleN";
	}
	else
	{
		$("findBitTxt").className = "textboxstyleN";
		findBit();
	}
}
var arrLoadedTabs = new Array();
function showWidgetGrp(gid)
{
	if(gid==null || typeof(gid)=='undefined')
		return;
	if($("toggleDiv").style.display=="none")
	{
		toggleSlider();
	}
	
	$A(document.getElementsByClassName("dashIconsDrag","galleryContainer")).each(Element.hide);
	if(gid=="All")
	{
		var gidArr = document.getElementsByClassName("dashIconsDrag","galleryContainer");
		gidArr.each(function(nd)
		{
			$(nd).style.display = "inline";
		});
		$('theImages').style.left = 25 + 'px';
		if($("arrowLeft"))
		{
			$("arrowLeft").show();
			$("arrowRight").show();
			$("arrowLeftDis").hide();
			$("arrowRightDis").hide();
		}
		initSlideShow();
		return;
	}
	gid = gid.toString();
	var gidArr = document.getElementsByAttributeVal("groupid",gid,"galleryContainer");
	var len = gidArr.length;
	for(var i=0;i<len;i++)
	{
		if((arrLoadedTabs.in_array(gid) === false) && ($(gidArr[i]) != null))
		{
			var divImgId = $(gidArr[i]).id;
			var widgetName = divImgId.gsub('divImg_','');
			var imgId =  'img_'+widgetName;
			$(imgId).src = $(imgId).src.gsub('spacer.gif',eval('widgetsData.'+widgetName+'.img_n'));
		}	
		if($(gidArr[i]))
			$(gidArr[i]).style.display = "inline";
	}
	if(arrLoadedTabs.in_array(gid) === false)
		arrLoadedTabs[arrLoadedTabs.length] = parseInt(gid);
	
	if(len>=9)
	{
		lastArrow = true;
		if($("arrowLeft"))
		{
			$("arrowLeft").show();
			$("arrowRight").show();
			$("arrowLeftDis").hide();
			$("arrowRightDis").hide();
		}
	}
	else
	{
		lastArrow = false;
		if($("arrowLeft"))
		{
			$("arrowLeft").hide();
			$("arrowRight").hide();
			$("arrowLeftDis").style.display = "inline";
			$("arrowRightDis").style.display = "inline";
		}
	}
	$('theImages').style.left = 25 + 'px';
	if(!isIE)
		initSlideShow();
}

function findHash(myObjFind,key)
{
	var h  = $H(myObjFind);
	var arrKeys = h.keys().sort();
	
	key = trim(key).toLowerCase();
	var keyLen = key.length;
	
	var arrRes = Array();
	for(var i=0;i<arrKeys.length;i++)
	{
		//if(key==((arrKeys[i].toLowerCase().substring(0,keyLen)).toLowerCase()))
		if((arrKeys[i].toLowerCase()).include(key))
			arrRes.push(h[arrKeys[i]]);
	}
	return arrRes;
}
function findBit()
{
	var gidArr = document.getElementsByClassName("dashIconsDrag","galleryContainer");
	var key=$("findBitTxt").value;
	if(trim(key)!="")
	{
		gidArr.each(function(nd)
		{
			$(nd).style.display = "none";
		});
		var findArr = findHash(myObjFind[0],key);
		$A(findArr).each(
			function(node)
			{
				if($("divImg_"+node) && node!="mapit")
					$("divImg_"+node).show();
			}
		);
	}
	else
	{
		gidArr.each(function(nd)
		{
			if(nd!="divImg_mapit")
				$(nd).style.display = "inline";
		});
	}
}

function changeTabCls(type,event)
{
	var gidArr = document.getElementsByClassName("tabTdCls",event);
	if(type=="over")
	{
		gidArr.each(function(nd)
		{
			if(!(nd.className.include("_blue_h")))
				nd.className = nd.className.gsub("_blue_n","_blue_h");
		});
	}
	else if(type=="out")
	{
		gidArr.each(function(nd)
		{
			if((nd.className.include("_blue_h")))
				nd.className = nd.className.gsub("_blue_h","_blue_n");
		});
	}
	else
	{
		var gidArrAll = document.getElementsByClassName("tabTdCls","grpDiv");
		gidArrAll.each(function(nd)
		{
			if((nd.className.include("_blue_cl")))
			{
				nd.className = nd.className.gsub("_blue_cl","_blue_n");
			}
		});
		gidArr.each(function(nd)
		{
			if(!(nd.className.include("_blue_cl")))
			{
				nd.className = nd.className.gsub("_blue_h","_blue_cl");
				nd.className = nd.className.gsub("_blue_n","_blue_cl");
			}
		});
	}
	
}

function trimToRect(w, h, str, strApp, strClass, bTrimToWords, bAlwaysAppend,id)
{
	h=parseInt(h);
	str=str.replace(/<=>/g,"'");
	str=str.replace(/<==>/g,'"');
// element with id "ruler" must exist in the document, e.g.:
// <div id=ruler style="position:absolute; left:-5000px;"><!-- --></div>
	elR = document.getElementById(id);
	elR.className = strClass;
	elR.style.width = w;
	
	if(bAlwaysAppend)
		strResult = str + strApp;
	else
		strResult = str;

	// fits already? opt out early
	elR.innerHTML = strResult;
	if(elR.clientHeight <= h)
		return strResult;

	with(Math) position = nextOffset = pow(2,floor(log(str.length) / LN2));

	do
	{
		nextOffset = nextOffset / 2;
		elR.innerHTML = str.substr(0, position) + strApp;
		position = position + (elR.clientHeight > h? -nextOffset:nextOffset);
	} while(nextOffset!= 1);

	elR.innerHTML = str.substr(0, position) + strApp;
	if(elR.clientHeight > h)
		position--;

	if(bTrimToWords)
		while(str.substr(--position, 1)!= " ");

	return str.substr(0, position) + strApp;
}

function highlightMapTypeBtn(maparg)
{
	if (maparg)
		mapType = maparg.getCurrentMapType().getName(true);
	if(mapType=="Map")
	{
		document.getElementById("btnMap").className="mapTypeButtonSelect";
		document.getElementById("btnSat").className="mapTypeButton";
//		document.getElementById("btnHyb").className="mapTypeButton";
		document.getElementById("btnTer").className="mapTypeButton";
	}
	else if(mapType=="Sat")
	{
		document.getElementById("btnMap").className="mapTypeButton";
		document.getElementById("btnSat").className="mapTypeButtonSelect";
//		document.getElementById("btnHyb").className="mapTypeButton";
		document.getElementById("btnTer").className="mapTypeButton";
	}
/*	else if(mapType=="Hyb")
	{
		document.getElementById("btnMap").className="mapTypeButton";
		document.getElementById("btnSat").className="mapTypeButton";
		document.getElementById("btnHyb").className="mapTypeButtonSelect";
		document.getElementById("btnTer").className="mapTypeButton";
	}
*/
	else if(mapType=="Ter")
	{
		document.getElementById("btnMap").className="mapTypeButton";
		document.getElementById("btnSat").className="mapTypeButton";
//		document.getElementById("btnHyb").className="mapTypeButton";
		document.getElementById("btnTer").className="mapTypeButtonSelect";
	};
}
//Funtions for getting the all the MapIT bits that are currently loaded on the dashboard

function getMapItBitsLoadedOnDashboard(expURL,uid)
{
	if (typeof(uid) != "undefined")
	{
		var url = "/app/dashboard/dshbrdProcess.php";
		var qryStr = "fetchdata=1";
		ajaxRequest(url,qryStr,function(objRequest){

			var response = trim(objRequest.responseText);
			if(response == '{}')
			{
				return;
			}
			else
			{
				var responseArr = eval(response);
				widgetNames = '';
				for(var i=0;i<responseArr.length;i++)
				{
					var rowNo = responseArr[i].rowNo;
					var colNo = responseArr[i].colNo;
					var widgetName = responseArr[i].widgetName;
					var divChildId = "divChild"+rowNo+"X"+colNo; 
					widgetNames = widgetNames + widgetName + ',';	
				}
				widgetNames = widgetNames.substr(0, widgetNames.length - 1);
				window.open(expURL+"&widgetnames=" + widgetNames,"_self");
			}
		});
	}
	else
	{
		widgetNames = '';
		for (var i=1 ; i<=3 ; i++)
		{
			for (var j=1 ; j<=3 ; j++)
			{
				if(getCookie("widget"+i+"X"+j))
				{
					var widgetName;
					widgetName = getCookie("widget"+i+"X"+j).split(':::')[0];
					if (widgetName != "undefined")
					{
						widgetNames = widgetNames + widgetName + ',';
					}
				}
				
			}
		}		
		widgetNames = widgetNames.substr(0, widgetNames.length - 1);
		window.open(expURL+"&widgetnames=" + widgetNames,"_self");
	}
}

function getMapItBits(objRequest,expURL)
{
	var MapitBitzName = trim(objRequest.responseText);
	MapitBitzName = MapitBitzName.substr(0, MapitBitzName.length - 1);
	window.open(expURL+"&widgetnames=" + MapitBitzName,"_self");
}

var timeDiff  =  {
    setStartTime:function (){
        d = new Date();
        time  = d.getTime();
    },

    getDiff:function (){
        d = new Date();
        return (d.getTime()-time);
    }
}
var bitzTabPrev="";
var bitzTabNew="";
function changeTabImg(newTabVal)
{
	if(bitzTabNew!="")
	{
		bitzTabPrev = bitzTabNew;
		bitzTabNew = newTabVal;
	}
	else
	{
		var dgidArrAll = document.getElementsByClassName("tabSelected","tabDiv");
		dgidArrAll.each(function(nd)
		{
		   bitzTabPrev = nd.id;
		});
		bitzTabNew = newTabVal;
	}
	if($(bitzTabPrev)) 
	{
		$(bitzTabPrev).className = "tabs";	
		$(bitzTabNew).className = "tabSelected";
	}
	/*
		var dgidArrAll = document.getElementsByClassName("tabSelected");
		dgidArrAll.each(function(nd)
		{
				$(nd.id).className = "tabs";
			
		});
		var gidArrAll = document.getElementsByClassName("tabs");
		gidArrAll.each(function(nd)
		{
			if((nd.id==event))
			{
				$(nd.id).className = "tabSelected";
			}
		});
	*/ 
}
function funMakeChatWindow(userType,toChatType)
{
	if(typeof(flagB)!=='undefined' && flagB)
		document.getElementById('tooltipMainB').style.display = 'none';
	if(typeof(flag)!=='undefined' && flag)
		document.getElementById('tooltipMain').style.display = 'none';
	initResizePanel("widgetPanel");
	$('widgetPanel_h').style.display='none';
	if(typeof(initResizePanel)!='undefined')
	{
		/*if(userType=="C")
		{
			$('msgerDiv').style.display="none";
			$('loginDiv').style.display="none";
			$('registerDiv').style.display="block";
		}
		else*/ if(userType=="SP")
		{
			location.href = "../../app/ajaxim/support.php";
		}
		else
		{
			pingTimer = setInterval(ping, pingFrequency);
			$('msgerDiv').style.display="block";
			/*$('loginDiv').style.display="none";
			$('registerDiv').style.display="none";*/
		}
	}
	else
	{
		alert("include Chat Window");
	}
		
}


//function for searching by mlsno from index page header//
function funReloadAdvertise()
{
	//if(window.frames['iframeAdvertise'])
	//{
	//	window.frames['iframeAdvertise'].location.href = "/getAdvertise.php";
	//}
}

function setSearchCookie(ckName,ckValue)
{
	var strSearchCookie = getCookie("strSearchCookie");
	var arrSearchCookie = new Array();
	if(strSearchCookie != null && strSearchCookie != "")
	{
		arrSearchCookie = strSearchCookie.split(':::');
	}
	var arrNameSearchCookie = new Array();
	var arrValueSearchCookie = new Array();
	
	if(arrSearchCookie.length > 0)
	{
		for(var i=0;i<arrSearchCookie.length;i++)
		{
			var arrKeyVal = arrSearchCookie[i].split('=');
			arrNameSearchCookie[arrNameSearchCookie.length] = trim(arrKeyVal[0]);
			arrValueSearchCookie[arrValueSearchCookie.length] = trim(arrKeyVal[1]);
		}	
	}
	if(arrNameSearchCookie.find(ckName) !== false )
	{
		var ckIndex = arrNameSearchCookie.find(trim(ckName));
		arrValueSearchCookie[ckIndex] = escape(ckValue);
	}	
	else
	{
		arrNameSearchCookie[arrNameSearchCookie.length] = trim(ckName);
		arrValueSearchCookie[arrValueSearchCookie.length] = trim(escape(ckValue));
	}
	
	var strSearchCookie = "";
	for(var j=0;j<arrNameSearchCookie.length;j++)
	{
		if(j==0)
			strSearchCookie = strSearchCookie + trim(arrNameSearchCookie[j]) + '=' + trim(arrValueSearchCookie[j]); 
		else
			strSearchCookie = strSearchCookie + ':::' + trim(arrNameSearchCookie[j]) + '=' + trim(arrValueSearchCookie[j]);
	}
	
	var now = new Date();
	now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
	
	setCookie("strSearchCookie",strSearchCookie,now);
}

function getSearchCookie(ckName)
{
	var strSearchCookie = getCookie("strSearchCookie");
	var arrSearchCookie = new Array();
	if(strSearchCookie != null && strSearchCookie != "")
	{
		arrSearchCookie = strSearchCookie.split(':::');
	}
	var arrNameSearchCookie = new Array();
	var arrValueSearchCookie = new Array();
	
	if(arrSearchCookie.length > 0)
	{
		for(var i=0;i<arrSearchCookie.length;i++)
		{
			var arrKeyVal = arrSearchCookie[i].split('=');
			arrNameSearchCookie[arrNameSearchCookie.length] = trim(arrKeyVal[0]);
			arrValueSearchCookie[arrValueSearchCookie.length] = trim(arrKeyVal[1]);
		}	
	}
	
	var returnCKValue = "";
	if(arrNameSearchCookie.find(trim(ckName)) !== false)
	{
		var ckIndex = arrNameSearchCookie.find(ckName);
		returnCKValue = trim(unescape(arrValueSearchCookie[ckIndex]));
	}
	return returnCKValue;
	
}

function removeSearchCookie(ckName)
{
	var strSearchCookie = getCookie("strSearchCookie");
	var arrSearchCookie = new Array();
	if(strSearchCookie != null && strSearchCookie != "")
	{
		arrSearchCookie = strSearchCookie.split(':::');
	}
	
	var arrNameSearchCookie = new Array();
	var arrValueSearchCookie = new Array();
	
	if(arrSearchCookie.length > 0)
	{
		for(var i=0;i<arrSearchCookie.length;i++)
		{
			var arrKeyVal = arrSearchCookie[i].split('=');
			if(arrKeyVal[0] != ckName)
			{
				arrNameSearchCookie[arrNameSearchCookie.length] = trim(arrKeyVal[0]);
				arrValueSearchCookie[arrValueSearchCookie.length] = trim(arrKeyVal[1]);
			}	
		}
		var strSearchCookie = "";
		for(var j=0;j<arrNameSearchCookie.length;j++)
		{
			if(j==0)
				strSearchCookie = strSearchCookie + trim(arrNameSearchCookie[j]) + '=' + trim(arrValueSearchCookie[j]); 
			else
				strSearchCookie = strSearchCookie + ':::' + trim(arrNameSearchCookie[j]) + '=' + trim(arrValueSearchCookie[j]);
		}
	
		var now = new Date();
		now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
		setCookie("strSearchCookie",strSearchCookie,now);
	}
}
function funClrQckLocSrchCookies()
{
	removeSearchCookie("searchAddress");
	removeSearchCookie("city");
	removeSearchCookie("state");
	removeSearchCookie("zip");
	removeSearchCookie("county");
	removeSearchCookie("neighborhood");
}
function funClrQckSrchCookies()
{
	// CLEAR COOKIE RELATED TO MLSSource 
	if(typeof(clr_MLSSRC_Cookie) == 'function')	
		clr_MLSSRC_Cookie();
	if(typeof(clr_MLSSRC_Html) == 'function')	
		clr_MLSSRC_Html();	
	//UI Template Related Code
	if(typeof(clearSearchTemplateParam) == 'function' )
		clearSearchTemplateParam();
	
	removeSearchCookie('Garage');
	removeSearchCookie('Stories');
	removeSearchCookie('YearBuilt');
	removeSearchCookie('Pool');
	removeSearchCookie('Photo');
	removeSearchCookie('FirePlace');
	removeSearchCookie('searchCriteria');
	removeSearchCookie("listType");

	removeSearchCookie("spanHTML");
	removeSearchCookie("spanStyleHTML");
	removeSearchCookie("searchAddress");
	removeSearchCookie("city");
 	removeSearchCookie("state");
	removeSearchCookie("zip");
	removeSearchCookie("county");
	removeSearchCookie("neighborhood");
	removeSearchCookie("minPrice");
	removeSearchCookie("maxPrice");
	removeSearchCookie("searchBeds");
	removeSearchCookie("minSize");
	removeSearchCookie("maxSize");
	removeSearchCookie("searchBaths");
	removeSearchCookie("searchType");
	removeSearchCookie("searchSortType");
	removeSearchCookie("ckLFDate");
	removeSearchCookie("ckLTDate");
	removeSearchCookie("propStyle");
	removeSearchCookie("neighborhood");
	//removeSearchCookie("parkingType");
	
	// for power search
	removeSearchCookie("mlsSource");
	removeSearchCookie("propType");
	removeSearchCookie("propStatus");
	removeSearchCookie("area");
	removeSearchCookie("polygon");
	removeSearchCookie("salePriceFrom");
	removeSearchCookie("salePriceTo");
	removeSearchCookie("minPSize");
	removeSearchCookie("maxPSize");
	removeSearchCookie("ckPLFDate");
	removeSearchCookie("ckPLTDate");
	removeSearchCookie("listAgentFnm");
	removeSearchCookie("listAgentLnm");
	removeSearchCookie("minLotSize");
	removeSearchCookie("maxLotSize");
	removeSearchCookie("fromAge");
	removeSearchCookie("toAge");
	removeSearchCookie("fromYear");
	removeSearchCookie("toYear");
	removeSearchCookie("marketDaysFrom");
	removeSearchCookie("marketDaysTo");
	removeSearchCookie("garage");
	removeSearchCookie("stories");
	removeSearchCookie("eleSchool");
	removeSearchCookie("midSchool");
	removeSearchCookie("highSchool");
	removeSearchCookie("saleDateFrom");
	removeSearchCookie("saleDateTo");
	removeSearchCookie("saleAgentFnm");
	removeSearchCookie("saleAgentLnm");
	removeSearchCookie("salePriceFrom");
	removeSearchCookie("salePriceTo");
	removeSearchCookie("powerradial");
	removeSearchCookie("listagtid");
	removeSearchCookie("saleagtid");
	removeSearchCookie("listoff");
	removeSearchCookie("saleoff");
	removeSearchCookie("fire");
	removeSearchCookie("pool");
	removeSearchCookie("roof");
	
	setAllCookieValue("mlssource");
	setAllCookieValue("proptype");
	setAllCookieValue("propstatus");
	setAllCookieValue("sqftp");
	setAllCookieValue("listdatep");
	setAllCookieValue("listagent");
	setAllCookieValue("lotsize");
	setAllCookieValue("age");
	setAllCookieValue("yearbuilt");
	setAllCookieValue("daysonmarket");
	setAllCookieValue("garage");
	setAllCookieValue("stories");
	setAllCookieValue("eleschool");
	setAllCookieValue("midschool");
	setAllCookieValue("highschool");
	setAllCookieValue("saledate");
	setAllCookieValue("saleprice");
	setAllCookieValue("saleagent");
	setAllCookieValue("area");
	setAllCookieValue("polygon");
	setAllCookieValue("listagtid");
	setAllCookieValue("listoff");
	setAllCookieValue("saleagtid");
	setAllCookieValue("saleoff");
	setAllCookieValue("roof");
	setAllCookieValue("fire");
	setAllCookieValue("pool");
	//---------------------------------

	setAllCookieValue(null);
	headerContent(null);
	funCloseAdvanceSearch();
	
	removeSearchCookie("spanStyleHTML");
	removeSearchCookie("propStyle")
	if($('prpStyleText')) $('prpStyleText').innerHTML = "";

	if(typeof(srTabs) != "undefined" && srTabs.getTab(0).get("active"))
	{
		srTabs.set('activeTab',srTabs.getTab(0),true);
		srTabs.getTab(0).refresh();
	}
}

/**
 * add and remove the MapIt cookie
 * @param bitzNm = BitName
 * @param oprn = 'add' to add cookie 'del' to remove cookie 
 */
function setMapItCookie(bitzNm,oprn)
{
	var now = new Date();
	now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
	var strMapitCK = getCookie("strMapitCK");
	var ckAr = new Array();
	if(strMapitCK == null || trim(strMapitCK) == "")
	{
		strMapitCK = "";
		ckAr.length = 0;
	}
	else
	{
		ckAr = strMapitCK.split(',').compact();
	}
	if(oprn == "add")
	{
		var isBitz = ckAr.in_array(bitzNm);
		if(isBitz === false)
		{
			ckAr[ckAr.length] = bitzNm;
			strMapitCK = "";
			for(var i=0;i<ckAr.length;i++)
			{
				if(strMapitCK != "")
				{
					strMapitCK = strMapitCK + ',';
				}
				strMapitCK = strMapitCK + ckAr[i]; 
			}		
			setCookie("strMapitCK",strMapitCK,now);
		}
	}
	else if (oprn == "del")
	{
		var isBitz = ckAr.in_array(bitzNm);
		if(isBitz === false)
		{
			return;
		}
		else
		{
			ckAr.splice(isBitz,1);
		}
		strMapitCK = "";
		for(var i=0;i<ckAr.length;i++)
		{
			if(strMapitCK != "")
			{
				strMapitCK = strMapitCK + ',';
			}
			strMapitCK = strMapitCK + ckAr[i]; 
		}
		setCookie("strMapitCK",strMapitCK,now);
	}
}

/**
 * returns all the mapable bits in form of an array
 */
function getAllMapItCookie()
{
	var now = new Date();
	now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
	var strMapitCK = getCookie("strMapitCK");
	var ckAr = new Array();
	if(strMapitCK == null || trim(strMapitCK) == "")
	{
		strMapitCK = "";
		ckAr.length = 0;
	}
	else
	{
		ckAr = strMapitCK.split(',').compact();
	}
	return ckAr;
}

/**
 * set the mapit cookie to the list of mapable bits passed as an array
 */
function setAllMapItCookie(mapitBitsArray)
{
	for(i=0;i<mapitBitsArray.length;i++)
		setMapItCookie(mapitBitsArray[i],"add");
}

/**
 * set the mapit cookie to the list of mapable bits passed as an array
 */
function removeAllMapItCookie()
{
	var now = new Date();
	now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
	var strMapitCK = "";
	setCookie("strMapitCK",strMapitCK,now);
}


function setCSZValue(city, state, zip)
{
	var geoCSZStr = "";
	var multiCity = false;
	if ((city  == null) || (city =="") || (city  =="undefined"))
	{
		// Do nothing
	}
	else
	{
		if (city.indexOf('|') != -1)
			multiCity = true;
	}

	if (!multiCity && (zip  == null) || (zip =="") || (zip  =="undefined"))
	{
		// Do nothing
	}
	else
	{
		if (zip.indexOf('|') != -1)
			multiCity = true;
	}
	
	if (multiCity)
	{
		var cityArr = new Array();
		var stateArr = new Array();
		var zipArr = new Array();
		if ((city  == null) || (city =="") || (city  =="undefined"))
		{}
		else
		{
			cityArr = city.split('|');
		}
		if (state  =="" || state  =="undefined" || state  == null)
		{}
		else
		{
			stateArr = state.split('|');
		}
		if (zip =="" || zip  =="undefined" || zip  == null)
		{}
		else
		{
			zipArr = zip.split('|');
		}
		
		for (var i=0; i<cityArr.length; i++)
		{
			var currentCsz = "";
			if (cityArr[i]  == null || cityArr[i] == "")
			{}
			else
			{
				currentCsz += cityArr[i] + ", ";
			}
			if (stateArr[i]  == null || stateArr[i] == "")
			{}
			else
			{
				currentCsz += stateArr[i] + " ";
			}
			if (zipArr[i]  == null || zipArr[i] == "")
			{}
			else
			{
				currentCsz += zipArr[i];
			}
			
			if (currentCsz != "")
				geoCSZStr += trim(currentCsz) + ";";
				
			var geoCity 	= cityArr[i];
			var geoState 	= stateArr[i];
			var geoZip 		= zipArr[i];
			var geoCSZ 		= setCSZValue(geoCity, geoState,geoZip);
			var idTxtObj = 'searchCSZ'+ eval(i+1);
			if($(idTxtObj) != null)
				$(idTxtObj).value = trim(geoCSZ).replace (/^\s+/g, "").replace (/\s+$/g, "").replace (/\s+/g, " ");
		}
		if (geoCSZStr != "")
			geoCSZStr = geoCSZStr.substr(0, geoCSZStr.length-1);
	}
	else
	{
	 	if(city!=null)
	 	{
			if ((city  == null) || (city =="") || (city  =="undefined"))
			{
				
			}
			else
			{
				geoCSZStr = city + ", ";
			}
	 	}
	 	if(state!=null)
	 	{
			if (state  =="" || state  =="undefined" || state  == null)
			{
				
			}
			else
			{
				geoCSZStr += state +" ";
			}
	 	}
	 	if(zip!=null)
	 	{
			if (zip =="" || zip  =="undefined" || zip  == null)
			{
				
			}
			else
			{
				geoCSZStr += zip;
			}
	 	}
	}
	
 	if(trim(geoCSZStr) == "" )
 	{
 		geoCSZStr = "Enter Neighborhood, City or ZIP code";
 	}
 	return trim(geoCSZStr);
}
function funWrapText(str,len)
{
	if(str.length > len)
	{
		str = str.substr(0,len)+' ...';
	}
	return str;
}

function explore(page)
{	

	/* */
	// IF NEW LISTING THEN LAST 15 DAYS DATE DURATION WOULD BE SET
	if($('bit_select_box') && $F('bit_select_box') == 'newListing')
	{
		$("RStxtLFDate").value = listDate1;
		$("RStxtLTDate").value = listDate2;
		setSearchCookie("listType",$F('bit_select_box'));
	}
	else if($('bit_select_box') && $F('bit_select_box') != 'newListing')
	{
		lfDate = ''; ltDate = '';
		$("RStxtLFDate").value = '';
		$("RStxtLTDate").value = '';
		setSearchCookie("listType",$F('bit_select_box'));
	}
	setSearchCookie("ckLFDate",($("RStxtLFDate"))?($F("RStxtLFDate")):"");
	setSearchCookie("ckLTDate",($("RStxtLTDate"))?($F("RStxtLTDate")):"");



	if (countySearchEnabled == "0" && checkMultiCity() == false && trim(getSearchCookie("neighborhood")) != "")
	{
		setSearchCookie("county", "");
	}
	if ( bkTheme != "terabitz" && trim($("searchMLS").value) != "")
	{
		var allBitz = getAllMapItCookie().toString();
		allBitz = allBitz.split(",");

		if(allBitz.length >= 10)
		{	
			alert("Please close atleast one bit, then enter MLS Number.");
			return;
		}

		if (page=="agentSiteListing")
			searchByMlsNoAgentSite();
		else if(page == "singlePropPower")
		{
			if(typeof(powerSearch) != 'undefined' && powerSearch == "1" && (uRole == "EA" || uRole == "A"))
			{
				var mlsurl = "../../app/dashboard/mlsSearch.php";
			    var mlsstr = "mlsno="+trim($("searchMLS").value)+ "&forAlert=1&mlsSource="+getSearchCookie('mlsSource')+"&ignorestatus=1&theme="+bkTheme+"&aid="+uid;
				
				ajaxRequest(mlsurl,mlsstr,function(r){
					response = trim(r.responseText);
					if(response == '0')	           
					{
						alert('MLS NO. not found.');
						return;
					}
					else
					{
						dataArr = response.split("&")[1].split("=")[1].split(",");
						var city = dataArr[1];
						var state = dataArr[2];
						var zip = dataArr[3];
						var lat = dataArr[7];
						var lng = dataArr[8];

						setSearchCookie("city",city);
						setSearchCookie("state",state);
						setSearchCookie("zip",zip);

						var latLongStr = "[{'lat':'"+lat+"','lng':'"+lng+"'}]";
						var now = new Date();
						now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
						setCookie("latLongCk",latLongStr,now);

						setSearchCookie("mlsno",trim($("searchMLS").value));
						setSearchCookie("area","");
						setSearchCookie("polygon","");
						funExplorePowerSearch();
					}
				});
			}
		}
		else
			searchByMlsNo();
		return;
	}
	else if($("searchMLS").value != "" && ($("searchCSZ").value == "" || $F("searchCSZ").toLowerCase() == "required"))
	{
		alert("Please enter City or Zip along with MLS Number.");
		return;
	}
	else if($("searchMLS").value != "")
	{
		var myStatus = funCheckContradict();
		if(myStatus != null && myStatus != 0)
		{
			if (page=="agentSiteListing")
				searchByMlsNoAgentSite();
			else
				searchByMlsNo();
		}
		return;
	}
	var csz = $("searchCSZ").value.replace (/^\s+/g, '').replace (/\s+$/g, '').replace (/\s+/g, ' ');
	var addr= $("searchAddress").value.replace (/^\s+/g, '').replace (/\s+$/g, '').replace (/\s+/g, ' ');
	/*if (trim(csz) == "")
	{
		alert ("Please specify either City or Zip");
		return false;
	}
	else */
	if (trim(csz) == "" || trim(csz).toLowerCase() == "required")
	{
		if(page == "singlePropPower")
		{
			if($("txtArea") && $("txtArea").value == "")
			{
				alert ("Please specify either City or Zip");
				return false;
			}
			else
			{				
				var status = funSaveAdvanceSearch("power","singlePropPower");
				
				if(status == true)
				{
					if(getSearchCookie("mlsno") && getSearchCookie("mlsno") != "")
						setSearchCookie("mlsno","");
					funExplorePowerSearch();
				}
			}
		}
		else
		{
			alert ("Please specify either City or Zip");
			return false;
		}
	}
	else if ( addr!="optional" && addr!="")
	{
		var contradict = funCheckContradict();
		if(contradict != null && contradict != 0)
		{
			var contradict = funReloadAdvertise();

			if(typeof(powerSearch) != 'undefined' && powerSearch == "1" && (uRole == "EA" || uRole == "A"))
			{		
				/*
				[{"status":"0","originaladdress":"4214 E Arch Rd, Stockton, CA ","statuscode":"200","country":"US","accuracy":"8","address":"4214 E Arch Rd","state":"CA","city":"Stockton","zip":"95215","latitude":"37.905234","longitude":"-121.214809"}]
				*/
				var url = "../../classes/getCSZ.php";
			    var qs = "csz="+trim($("searchCSZ").value)+"&address="+addr;
				
				ajaxRequest(url,qs,function(r){
					response = eval('(' + trim(r.responseText) + ')');

					if(response[0].status == "0")
					{
						var addr = response[0].address;
						var city = response[0].city;
						var state = response[0].state;
						var zip = response[0].zip;
						var lat = response[0].latitude;
						var lng = response[0].longitude;

						setSearchCookie("searchAddress",addr);
						setSearchCookie("city",city);
						setSearchCookie("state",state);
						setSearchCookie("zip",zip);

						var latLongStr = "[{'lat':'"+lat+"','lng':'"+lng+"'}]";
						var now = new Date();
						now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
						setCookie("latLongCk",latLongStr,now);
							
						funExplorePowerSearch();
					}
				});
			}
			else
			{
				var allBitz = getAllMapItCookie().toString();
				allBitz = allBitz.split(",");

				if(allBitz.length >= 10)
				{	
					alert("Please close atleast one bit, then enter Address.");
					return;
				}
				funExploreMlsAddrMap();
			}
			
			return;
		}
	}
	else
	{
		var cszFromCk = setCSZValue(getSearchCookie("city"), getSearchCookie("state"), getSearchCookie("zip"));
		var contradict = funCheckContradict();
		if(contradict != null && contradict != 0)
		{
			var contradict = funReloadAdvertise();
			if(page == "index")
			{
				gotoDashBrd();
			}	
			else if(page=="dashboard")
			{
				funQckUpdateWidgets();		
			}
			else if(page=="singleProp")
			{
				funExploreOnMapit();
			}
			else if(page=="singlePropPower")
			{
				var status = funSaveAdvanceSearch("power","singlePropPower");
				
				if(status == true)
				{
					if(getSearchCookie("mlsno") && getSearchCookie("mlsno") != "" && $("searchCSZ").value != "")
					{
						setSearchCookie("mlsno","");
					}
					else
					{
						if($('searchCSZ') != null)
						{
							$('searchCSZ').value = $('searchCSZ').value.replace (/^\s+/g, "").replace (/\s+$/g, "").replace (/\s+/g, " ");
							if (trim(cszFromCk).toUpperCase() != trim($('searchCSZ').value).toUpperCase())
							{
								if(getSearchCookie("area") && getSearchCookie("area") == $("txtArea").value)
								{
									setSearchCookie("area","");
									setSearchCookie("polygon","");
								}
							}
						}	
					}
					funExplorePowerSearch();
				} 
			}
			else if(page=="agentSiteListing")
			{
				funAgentSiteSearch();
			}
		}	
	}	
}
function funAgentSiteSearch(page,valOrderBy,typeOrderBy,searchByMlsNo)
{
	var cbfnAgentSite = function(reqObj)
	{
		var response = trim(reqObj.responseText);
		var arrResponseCount = response.split('|==|');
		var responseCount = arrResponseCount[0];
		var responseHTML = arrResponseCount[1];
		$('listDiv').innerHTML = responseHTML;
		if(parseInt(responseCount) > 0)
		{
			$('propSortBar').style.display = 'block';
		}
	}
	var url = "./getListing.php";
	var qs = funGetSearchQueryString();

	var objQS = new Querystring();
	var aid = objQS.get('aid');
	
	qs = qs + "&aid="+aid;

	if(page != null)
	{
		qs = qs + "&page="+page;
	}
	else
	{
		qs = qs + "&page=1";
	}
	if(valOrderBy != null)
	{
		qs = qs + "&valOrderBy="+valOrderBy;
	}
	else
	{
		qs = qs + "&valOrderBy=price";
	}
	if(typeOrderBy != null)
	{
		qs = qs + "&typeOrderBy="+typeOrderBy;
	}
	else
	{
		qs = qs + "&typeOrderBy=asc";
	}
	if(searchByMlsNo != null)
	{
		qs = qs + "&MlsSearch="+searchByMlsNo;
	}
	else
	{
		qs = qs + "&MlsSearch=0";
	}
	$('listDiv').innerHTML = '';
	ajaxRequest(url,qs,cbfnAgentSite);
}

function searchByMlsNoAgentSite()
{
	var cbfnAgentSite = function(reqObj)
	{
		var response = trim(reqObj.responseText);
		var arrResponseCount = response.split('|==|');
		var responseCount = arrResponseCount[0];
		var responseHTML = arrResponseCount[1];
		$('listDiv').innerHTML = responseHTML;
		if(parseInt(responseCount) > 0)
		{
			$('propSortBar').style.display = 'block';
		}
	}
	var url = "./getListing.php";
	var qs = "";
        var objQS = new Querystring();
        var aid = objQS.get('aid');
        qs = qs + "&aid="+aid;


	var mlsNo = objQS.get('mlsno');
	if(mlsNo!=null && mlsNo!='')
	{
		qs = qs + "&MlsSearch="+mlsNo;
	}
	else
	{
		qs = qs + "&MlsSearch="+trim($("searchMLS").value);
	}

	//qs = qs + "&MlsSearch=1";
    qs = qs + "&valOrderBy=price";
    qs = qs + "&typeOrderBy=asc";

	$('listDiv').innerHTML = '';
	ajaxRequest(url,qs,cbfnAgentSite);
}

var	recordDialogBox = "";
var	agtOffDlgBox = "";
function searchByMlsNo()
{
	if ($("searchMLS").value == "")
	{
		alert("Please input MLS number to search.");
		$("searchMLS").value = "";
		$("searchMLS").focus();
		return;
	}
	var mlsno = trim($("searchMLS").value);
	var qStr = "mlsno="+escape(mlsno);
	qStr += "&city="	+ trim(getSearchCookie("city"));
	qStr += "&state="	+ trim(getSearchCookie("state"));
	qStr += "&zip="		+ trim(getSearchCookie("zip"));
	var myQs = new Querystring();
	var frm = myQs.get("frm");
	var aid = myQs.get("aid");
	
	if(frm != null && trim(frm) == 'agt' && aid != null && trim(aid) != "")
	{
		if(typeof(strAgtMlsSrc) != 'undefined' && strAgtMlsSrc != null && strAgtMlsSrc.length > 0)
			qStr = qStr + "&mlsSource="	+ 	escape((trim(strAgtMlsSrc)));
		else
			qStr = qStr + "&mlsSource=";
		qStr = qStr + "&aid="+	escape((trim(aid)));

		//agentsite statistics
		var city = getSearchCookie("city");
		var ad = getSearchCookie("searchAddress");
		var beds = getSearchCookie("searchBeds");
		var baths = getSearchCookie("searchBaths");
		var type = getSearchCookie("searchType");
		var minprice = getSearchCookie("minPrice");
		var maxprice = getSearchCookie("maxPrice");

		var url = "../../classes/emailStats.php";
		var qs = "from=search&aid="+aid+"&city="+city+"&type="+type+"&beds="+beds+"&baths="+baths+"&price="+minprice+"-"+maxprice+"&addr="+ad+"&mlsno="+mlsno;

		ajaxRequest(url,qs);
		//statistics done
	}	
	var url  = "/app/dashboard/mlsSearch.php";
	ajaxRequest(url,qStr,cbfnSearchByMlsNo);
}

function funRedirectToMLS(urlMLS)
{
	funClrQckLocSrchCookies();
	removeAllMapItCookie();	
	var myQs = new Querystring();
	var frm = myQs.get("frm");
	var aid = myQs.get("aid");
	
	if(frm != null && trim(frm) == 'agt' && aid != null && trim(aid) != "")
	{
		urlMLS = urlMLS + '&frm=agt&aid='+aid;
	}	
	window.location.href = unescape(urlMLS);
}

function cbfnSearchByMlsNo(originalRequest)
{
	var response = originalRequest.responseText;
	if (response == 0)
	{
		alert("MLS Number Not found.");
		$("searchMLS").value = "";
		$("searchMLS").focus();
		return;
	}
	else
	{
		if(response.include("|^|"))
		{
			var arrResponse = response.split("|^|");
			var strIH = new StringBuffer();
			strIH.append(' <div id="divMLSConfirmBox" style="background-color:#B0B0B0;display: none;border: 0px solid rgb(0, 0, 0); padding: 20px; height: 150px; width: 530px; position: fixed; top: 225px; left: 255px; visibility: inherit;" >');
			strIH.append(' 	<table cellspacing="0" cellpadding="0" bordercolor="red" border="0" style="width: 100%; height: 100%;">');
			strIH.append(' 		<tr style="height: 8px;">');
			strIH.append(' 			<td valign="bottom" class="crvTopLeft"></td>');
			strIH.append(' 			<td valign="bottom" class="crvTopMid" style="width: 500px;"></td>');
			strIH.append(' 			<td valign="bottom" class="crvTopRight"></td>');
			strIH.append(' 		</tr>');
			strIH.append(' 		<tr style="height: 90%;width:520px;">');
			strIH.append(' 			<td style="background-color: rgb(255, 255, 255);" class="crvLeftMid"></td>');
			strIH.append(' 			<td style="background-color: rgb(255, 255, 255);">');

			strIH.append('<table style="width:100%;height:100%">');
			strIH.append('<tr>');
			strIH.append('<td>');
			strIH.append('<img src="../../wt/'+bkTheme+'/images/common/imgConfirm.gif" alt="conform" />');
			strIH.append('</td>');
			strIH.append('<td  class="moduleDescText">');
			strIH.append('<div style="position: relative;font-size:11px;width: 79%;float: left;display: inline;padding-left: 5px;height:100%;vertical-align: middle;" align="left" id="divMLSConfirmMessageText">');
			strIH.append('&nbsp;');
			strIH.append('</div>');
			strIH.append('</td>');
			strIH.append('<tr>');
			strIH.append('<td colspan="2" align="center" valign="top">');
			strIH.append('<button style="width:50px;" onclick="javascript:myPopup();" class="lang" type="button" name="btnOK" id="btnOK">Yes</button>');
			strIH.append('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button class="lang" type="button" name="btnCancel" id="btnCancel" onclick="dlgMLSConfirmBox.hide();" style="width:50px;">No</button>');
			strIH.append('</td>');
			strIH.append('</tr>');
			strIH.append('</table>');

			strIH.append(' 			</td>');
			strIH.append(' 			<td style="background-color: rgb(255, 255, 255);" class="crvRightMid"></td>');
			strIH.append(' 		</tr>');
			strIH.append(' 		<tr style="height: 8px;">');
			strIH.append(' 			<td class="crvBotLeft"></td>');
			strIH.append(' 			<td class="crvBotMid"></td>');
			strIH.append(' 			<td class="crvBotRight"></td>');
			strIH.append(' 		</tr>');
			strIH.append(' 	</table>');
			strIH.append(' </div><style type="text/css">.closeMy{background-image:url(../../wt/'+bkTheme+'/images/common/close_dlgLog.gif);}</style>');
			
			myPopup = function()
			{
				response = arrResponse[1];
				dlgMLSConfirmBox.hide();
				loadMlsNumberProp(response);
				
			}

			function funRedirectToOther()
			{
				response = arrResponse[1];
				loadMlsNumberProp(response);
			}

			function funCnfrmRedirectToOther()
			{
				var closeBox = document.getElementsByClassName("close","divMLSConfirmBox")[0];
				if(closeBox)
				{
					closeBox.removeClassName("nonsecure");
					closeBox.addClassName("closeMy");
				}
				$('divMLSConfirmMessageText').innerHTML = "Redirecting to our Partners Site: <b>"+arrResponse[0]+"</b>";
				$("divMLSConfirmBox").style.display="block";	
				dlgMLSConfirmBox.show();
			}
			if($("divMLSConfirmBox") == null)
			{
				var myIH = strIH.toString();var myDiv = document.createElement("div");myDiv.innerHTML = myIH;document.body.appendChild(myDiv);							
				dlgMLSConfirmBox = createDialog('divMLSConfirmBox');
				
			}
			//funCnfrmRedirectToOther();				
			funRedirectToOther();
			//alert("Redirecting to our Partner's site '" + arrResponse[0] +"'");
			
		}
		else
		{
			loadMlsNumberProp(response);
		}
	}
}

function loadMlsNumberProp(response)
{
	var arrMlsRecords = new Array();	
	var arrRecords = new Array();	
	arrMlsRecords = response.split('\n');

	if(arrMlsRecords.length == 1)
	{
		arrRecords = arrMlsRecords[0].split('|');
		funRedirectToMLS(arrRecords[8]);
	}
	else
	{
		var mlsNumber;
		var detailRecords="";
		var startRecords;
		var recLen = arrMlsRecords.length;
		// Build table for div
		
		for(var i=0;i<recLen;i++)
		{
			arrRecords = arrMlsRecords[i].split('|');
			mlsNumber  = arrRecords[0];
			detailRecords += "<tr style=\"height:25px\"><td width=\"60%\" class=\"mlsLightBoxDescText\" align=\"left\" valign=\"top\">&nbsp;<a class=\"mlsHeadDis\" href=\"javascript:void(0);\" onclick=\"javascript:funRedirectToMLS(\'"+arrRecords[8]+"\');\"><b><span class=\"crsr\">"+arrRecords[1]+", "+arrRecords[2]+", "+arrRecords[3]+", "+arrRecords[4]+"</span></b></a></td><td width=\"15%\" class=\"mlsLightBoxDescText\" valign=\"top\">&nbsp;<a class=\"mlsHeadDis\" href=\"javascript:void(0);\" onclick=\"javascript:funRedirectToMLS(\'"+arrRecords[8]+"\');\"><b><span class=\"crsr\">"+num2money(arrRecords[5])+"</span></b></a></td><td width=\"15%\" class=\"mlsLightBoxDescText\" valign=\"top\">&nbsp;<a class=\"mlsHeadDis\" href=\"javascript:void(0);\" onclick=\"javascript:funRedirectToMLS(\'"+arrRecords[8]+"\');\"><b><span class=\"crsr\">"+arrRecords[6]+"-Br/"+arrRecords[7]+"-Ba</span></b></a></td></tr>";
		}			
		
		startRecords = "<table width=\"100%\" height=\"98%\" class=\"mlsLightBoxLableText\">";
		startRecords += "<tr style=\"height:25px\"><td class=\"mlsLightBoxTopLableText\" colspan=\"3\" align=\"left\" style=\"height:20px\">Total "+recLen+" listings were found. For more details, click on below link.</td></tr>";
		startRecords += "<tr><td height=\"5px\" colspan=\"3\"></td></tr>";
		startRecords = startRecords+detailRecords;
		startRecords += "</table>";
		
		if(typeof(recordDialogBox) == "string")
		{
			recordDialogBox = createDialog("recordsDialog");	
		}
		
		var ht = (recLen+1)*25;
		if(recLen>3)
			ht = "100%";
		else
		{
			if(isIE)
				ht = "85%";//ht+"px";
			else
				ht = "80%";//ht+"px";
		}
		$("recordsDialog").getElementsByClassName("bd")[0].style.height = ht;
		$("recordsDialog").getElementsByClassName("bd")[0].innerHTML = startRecords;
		$("recordsDialog").getElementsByClassName("hd")[0].innerHTML = "Listing Of MLS Number : "+mlsNumber;			
		$("recordsDialog").style.display="block";
		recordDialogBox.show();			
	}
}
function setAllToCookie(srchcrt,from)
{
	if(srchcrt == null)
	{
		if ($F("searchAddress").toLowerCase() == "optional" || $F("searchAddress") == "undefined" || $F("searchAddress") == null)
		{
			setSearchCookie("searchAddress","");
		}
		else
		{
			setSearchCookie("searchAddress",($("searchAddress"))?$F("searchAddress"):"");
		}
	}
	if(srchcrt == "neighborhood")
	{			
		if(typeof(from)!="undefined")
		{
			divId = "divNHood";
			chkAllId = "chbRSNHAll";
		}
		else
		{
			divId = "divSHDataNeighborHood";
			chkAllId = "chbSHNHAll";
		}
		if($(divId))
		{
			var arrChkBox = $(divId).getElementsByTagName("input");
			var lenArrChkBox = arrChkBox.length;
			var strCKNH = "";
			for(var i=0;i<lenArrChkBox;i++)
			{
				if(arrChkBox[i].id == chkAllId && arrChkBox[i].checked == true)
				{
					strCKNH = 'all';
					break;
				}
				if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
				{
					var valChkBox = arrChkBox[i].value;
					strCKNH = strCKNH + valChkBox + ",";  	
				}
			}
			if(strCKNH.charAt(strCKNH.length-1) == ',')
			{
				strCKNH = strCKNH.substr(0,eval(strCKNH.length-1));
			}
			setSearchCookie("neighborhood",strCKNH);
			if(srchcrt != null)
			{
				return;
			}
		}
	}
	if(srchcrt == "county")
	{		
		var dv = "";
		if(typeof(from) != "undefined")
			dv = "divRSCounty";
		else
			dv = "divSHDataCounty";

		if($(dv))
		{
			var arrChkBox = $(dv).getElementsByTagName("input");
			var lenArrChkBox = arrChkBox.length;
			var strCKCounty = "";
			for(var i=0;i<lenArrChkBox;i++)
			{
				if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
				{
					var valChkBox = arrChkBox[i].value;
					strCKCounty = strCKCounty + valChkBox + ",";  	
				}
			}
			
			if(strCKCounty.charAt(strCKCounty.length-1) == ',')
			{
				strCKCounty = strCKCounty.substr(0,eval(strCKCounty.length-1));
			}

			if(trim(strCKCounty) != "")
			{
				setSearchCookie("county",strCKCounty);
				removeSearchCookie("neighborhood");
				headerContent("neighborhood");
			}
			else
			{
				// If no County selected then just remove county from cookie
				removeSearchCookie("county");
			}
		}
		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt == null || srchcrt == "price")
	{			
		setSearchCookie("minPrice",($("minPrice"))?(money2num($F("minPrice"))):"");
		setSearchCookie("maxPrice",($("maxPrice"))?(money2num($F("maxPrice"))):"");
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "beds")
	{			
		var srchBds = "";
		var minBeds = trim($("searchBedsMin").value);
		if(minBeds == "0") minBeds = "";
		if(minBeds != "" && minBeds.indexOf(".") == (minBeds.length-1)) minBeds = minBeds+"0";
		if(minBeds != "" && minBeds.indexOf(".") == 0) minBeds = "0"+minBeds;

		var maxBeds = trim($("searchBedsMax").value)
		if(maxBeds == "0") maxBeds = "";
		if(maxBeds != "" && maxBeds.indexOf(".") == (maxBeds.length-1)) maxBeds = maxBeds+"0";
		if(maxBeds != "" && maxBeds.indexOf(".") == 0) maxBeds = "0"+maxBeds;

		srchBds = minBeds+"-"+maxBeds;
		if(trim(srchBds) == "-")
			srchBds = "";
		setSearchCookie("searchBeds",srchBds);

		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "sqft")
	{			
		setSearchCookie("minSize",($("minSize"))?$F("minSize")==0?"":$F("minSize"):"");
		setSearchCookie("maxSize",($("maxSize"))?$F("maxSize")==0?"":$F("maxSize"):"");
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "baths")
	{			
		var srchBths = "";
		var minBath = trim($("searchBathsMin").value);
		if(minBath == "0") minBath = "";
		if(minBath != "" && minBath.indexOf(".") == (minBath.length-1)) minBath = minBath+"0";
		if(minBath != "" && minBath.indexOf(".") == 0) minBath = "0"+minBath;

		var maxBath = trim($("searchBathsMax").value);
		if(maxBath == "0") maxBath = "";
		if(maxBath != "" && maxBath.indexOf(".") == (maxBath.length-1)) maxBath = maxBath+"0";
		if(maxBath != "" && maxBath.indexOf(".") == 0) maxBath = "0"+maxBath;

		srchBths = minBath+"-"+maxBath;
		if(trim(srchBths) == "-")
			srchBths = "";
		setSearchCookie("searchBaths",srchBths);

		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "type")
	{
		if(typeof(from)!="undefined")
		{
			divId = "divRSType";
			chkAllId = "RSchbSHTypeAll";
		}
		else
		{
			divId = "divPopUpSHType";
			chkAllId = "chbSHTypeAll";
		}
		var arrChkBox = $(divId).getElementsByTagName("input");
		var lenChkBox = arrChkBox.length;		
		var strChkBox = "";
		var allChked = true;		
		for(var i=0;i<lenChkBox;i++)
		{			
	    	if(arrChkBox[i].id == chkAllId)
	    	{
	    		continue;
	    	}
	    	if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
	    	{
	    	    var valChkBox = arrChkBox[i].value;
	    	    strChkBox = strChkBox + valChkBox + ':';				
	    	}
	    	else if(arrChkBox[i].type == "checkbox")
	    	{
	    	    allChked = false;    
	    	}
		}
		if(allChked == true)
		{
	    	strChkBox = "";
		}
		else if(strChkBox.charAt(strChkBox.length-1) == ':')
		{
			strChkBox = strChkBox.substr(0,eval(strChkBox.length-1));
		}		
		setSearchCookie("searchType",strChkBox);		
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "sortby")
	{			
		setSearchCookie("searchSortType",($("searchSortType"))?$F("searchSortType"):"");
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "listdate")
	{			
		setSearchCookie("ckLFDate",($("txtLFDate"))?($F("txtLFDate")):"");
		setSearchCookie("ckLTDate",($("txtLTDate"))?($F("txtLTDate")):"");
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "mlssource")
	{
		setSearchCookie("mlsSource",($("mlsSource"))?($F("mlsSource")):"");
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "proptype" && $("divPType"))
	{			
		//setSearchCookie("propType",($("propTypes"))?($F("propTypes")):"");			
		var arrChkBox = $("divPType").getElementsByTagName("input");
		var strChkd = "";

		for(i=0;i<arrChkBox.length;i++)
		{
			if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
	    	{
				strChkd += arrChkBox[i].value + ':';
			}
		}
		
		if(strChkd.charAt(strChkd.length-1) == ':')
			strChkd = strChkd.substr(0,eval(strChkd.length-1));

		setSearchCookie("propType",strChkd);

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "propstatus" && $("divPStatus"))
	{
		/*setSearchCookie("propStatus",($("propStatus"))?($F("propStatus")):"");
		if(srchcrt != null)
		{
			return;
		}*/

		var arrChkBox = $("divPStatus").getElementsByTagName("input");
		var strChkd = "";

		for(i=0;i<arrChkBox.length;i++)
		{
			if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
	    	{
				strChkd += arrChkBox[i].value + ':';
			}
		}
		
		if(strChkd.charAt(strChkd.length-1) == ':')
			strChkd = strChkd.substr(0,eval(strChkd.length-1));

		setSearchCookie("propStatus",strChkd);

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "sqftp")
	{
		setSearchCookie("minPSize",($("minPSize"))?$F("minPSize")==0?"":$F("minPSize"):"");
		setSearchCookie("maxPSize",($("maxPSize"))?$F("maxPSize")==0?"":$F("maxPSize"):"");
		if(srchcrt != null)
		{
			return;
		}		
	}
	if(srchcrt != null && srchcrt == "listagent")
	{
		if($('txtAgtFName').value != 'First Name')
			setSearchCookie("listAgentFnm",($("txtAgtFName"))?($F("txtAgtFName")):"");
		else
			setSearchCookie("listAgentFnm","");

		if($('txtAgtLName').value != 'Last Name')				
			setSearchCookie("listAgentLnm",($("txtAgtLName"))?($F("txtAgtLName")):"");
		else
			setSearchCookie("listAgentLnm","");

		if(srchcrt != null)
		{
			return;
		}		
	}
	if(srchcrt != null && srchcrt == "listdatep")
	{			
		setSearchCookie("ckPLFDate",($("txtPLFDate"))?($F("txtPLFDate")):"");
		setSearchCookie("ckPLTDate",($("txtPLTDate"))?($F("txtPLTDate")):"");
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "lotsize")
	{
		setSearchCookie("minLotSize",($("minLotSize"))?$F("minLotSize")==0?"":$F("minLotSize"):"");
		setSearchCookie("maxLotSize",($("maxLotSize"))?$F("maxLotSize")==0?"":$F("maxLotSize"):"");
		if(srchcrt != null)
		{
			return;
		}		
	}
	if(srchcrt != null && srchcrt == "age")
	{			
		setSearchCookie("fromAge",($("txtAgeFrom"))?(money2num($F("txtAgeFrom"))):"");
		setSearchCookie("toAge",($("txtAgeTo"))?(money2num($F("txtAgeTo"))):"");
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt != null && srchcrt == "yearbuilt")
	{			
		setSearchCookie("fromYear",($("txtYearBuiltFrom"))?(money2num($F("txtYearBuiltFrom"))):"");
		setSearchCookie("toYear",($("txtYearBuiltTo"))?(money2num($F("txtYearBuiltTo"))):"");
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt != null && srchcrt == "daysonmarket")
	{			
		setSearchCookie("marketDaysFrom",($("txtDaysMarketFrom"))?(money2num($F("txtDaysMarketFrom"))):"");
		setSearchCookie("marketDaysTo",($("txtDaysMarketTo"))?(money2num($F("txtDaysMarketTo"))):"");
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt != null && srchcrt == "garage")
	{			
		if(typeof(from)!="undefined")
			var cmbId = "RScmbGarage";
		else
			var cmbId = "cmbGarage";

		setSearchCookie("garage",($(cmbId))?$F(cmbId)==0?"":$F(cmbId):"");

		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt != null && srchcrt == "stories")
	{			
		setSearchCookie("stories",($("txtStories"))?($F("txtStories")):"");		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "bankowned")
	{			
		setSearchCookie("bankowned",$("chkBankOwned").checked);
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "shortsales")
	{			
		setSearchCookie("shortsales",$("chkShortSales").checked);
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "schooldist")
	{			
		setSearchCookie("schooldist",($("txtSchoolDist"))?($F("txtSchoolDist")):"");		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "eleschool")
	{			
		setSearchCookie("eleSchool",($("txtEleSchool"))?($F("txtEleSchool")):"");		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "midschool")
	{			
		setSearchCookie("midSchool",($("txtMidSchool"))?($F("txtMidSchool")):"");		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "highschool")
	{			
		setSearchCookie("highSchool",($("txtHighSchool"))?($F("txtHighSchool")):"");		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "saledate")
	{			
		setSearchCookie("saleDateFrom",($("txtSFDate"))?($F("txtSFDate")):"");
		setSearchCookie("saleDateTo",($("txtSTDate"))?($F("txtSTDate")):"");
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "saleprice")
	{			
		setSearchCookie("salePriceFrom",($("txtSalePriceFrom"))?(money2num($F("txtSalePriceFrom"))):"");
		setSearchCookie("salePriceTo",($("txtSalePriceTo"))?(money2num($F("txtSalePriceTo"))):"");
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt != null && srchcrt == "saleagent")
	{
		if($('txtSaleAgentFname').value != 'First Name')
			setSearchCookie("saleAgentFnm",($("txtSaleAgentFname"))?($F("txtSaleAgentFname")):"");
		else
			setSearchCookie("saleAgentFnm","");

		if($('txtSaleAgentLname').value != 'Last Name')				
			setSearchCookie("saleAgentLnm",($("txtSaleAgentLname"))?($F("txtSaleAgentLname")):"");
		else
			setSearchCookie("saleAgentLnm","");

		if(srchcrt != null)
		{
			return;
		}		
	}
	if(srchcrt != null && srchcrt == "area")
	{			
		setSearchCookie("area",($("txtArea"))?($F("txtArea")):"");		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "polygon")
	{			
		setSearchCookie("polygon",($("txtPolygon"))?($F("txtPolygon")):"");		
		//alert(getSearchCookie("polygon"))
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "powerradial")
	{			
		setSearchCookie("powerradial",$F("cmbradial"));

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "listagtid")
	{			
		setSearchCookie("listagtid",trim($F("txtListAgtId")));

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "listoff")
	{			
		setSearchCookie("listoff",trim($F("txtListOff")));

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "saleagtid")
	{			
		setSearchCookie("saleagtid",trim($F("txtSaleAgtId")));

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "saleoff")
	{			
		setSearchCookie("saleoff",trim($F("txtSaleOff")));

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "roof")
	{			
		setSearchCookie("roof",trim($F("txtRoof")));

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "fire")
	{			
		setSearchCookie("fire",trim($F("cmbFire")));

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "pool")
	{			
		setSearchCookie("pool",trim($F("cmbPool")));

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt == null || srchcrt == "propstyle")
	{		
		if(typeof(from)!="undefined")
		{
			divId = "RSpropStyleDv";
			chkAllId = "RSchkStyleAll";
		}
		else
		{
			divId = "propStyleDv";
			chkAllId = "chkStyleAll";
		}

		if($(divId))
		{
			var arrChkBox = $(divId).getElementsByTagName("input");
			var lenChkBox = arrChkBox.length;
			var strChkBox = "";
			var allChked = true;
			for(var i=0;i<lenChkBox;i++)
			{
				if(arrChkBox[i].id == chkAllId)
				{
					continue;
				}
				if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
				{
					var valChkBox = arrChkBox[i].value;
					strChkBox = strChkBox + valChkBox + ':';
				}
				else if(arrChkBox[i].type == "checkbox")
				{
					allChked = false;    
				}
			}
			if(allChked == true)
			{
				strChkBox = "";
			}
			else if(strChkBox.charAt(strChkBox.length-1) == ':')
			{
				strChkBox = strChkBox.substr(0,eval(strChkBox.length-1));
			}
			setSearchCookie("propStyle",strChkBox);
		}
		else
			setSearchCookie("propStyle","");

		if(srchcrt != null)
		{
			return;
		}
	}
	/*if(srchcrt == null || srchcrt == "parkingtype")
	{
		if($("parkingStyleDv"))
		{
			var arrChkBox = $("parkingStyleDv").getElementsByTagName("input");
			var lenChkBox = arrChkBox.length;
			var strChkBox = "";
			var allChked = true;
			for(var i=0;i<lenChkBox;i++)
			{
				if(arrChkBox[i].id == "chkParkingStyleAll")
				{
					continue;
				}
				if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
				{
					var valChkBox = arrChkBox[i].value;
					strChkBox = strChkBox + valChkBox + ':';
				}
				else if(arrChkBox[i].type == "checkbox")
				{
					allChked = false;    
				}
			}
			if(allChked == true)
			{
				strChkBox = "";
			}
			else if(strChkBox.charAt(strChkBox.length-1) == ':')
			{
				strChkBox = strChkBox.substr(0,eval(strChkBox.length-1));
			}
			setSearchCookie("parkingType",strChkBox);
		}
		else
			setSearchCookie("parkingType","");

		if(srchcrt != null)
		{
			return;
		}
	}*/
}
function setAllCookieValue(srchcrt)
{
	
	if(srchcrt == null)
	{
		if($("searchAddress"))
		{
			
			$("searchAddress").value = (trim(getSearchCookie("searchAddress")) == "")?"optional":trim(getSearchCookie("searchAddress"));
			$("searchAddress").className = "textboxDashHdN";
		}
		if($('searchCSZ'))
		{
			var cszFromCookie = setCSZValue(getSearchCookie("city"), getSearchCookie("state"), getSearchCookie("zip"));
			$('searchCSZ').value = trim(cszFromCookie).replace (/^\s+/g, "").replace (/\s+$/g, "").replace (/\s+/g, " ");
			if(trim(getSearchCookie('city')) == "" && trim(getSearchCookie('zip')) == "")
			{
				for(var i=0;i<20;i++)
				{
					var idTxtObj = 'searchCSZ'+ eval(i+1);
					if($(idTxtObj) != null)
						$(idTxtObj).value = "";
				}
			}	
		}
		if($('searchMLS'))
		{
			$('searchMLS').value = "";
		}
	}	
	if(srchcrt == null || srchcrt == "price")
	{
		if($("minPrice"))
		{
			if(getSearchCookie("minPrice") != 0)
				$("minPrice").value = addCommas(getSearchCookie("minPrice"));
			else 
				$("minPrice").value = '';
		}
		if($("maxPrice"))
		{
			if(getSearchCookie("maxPrice") != 0)
				$("maxPrice").value = addCommas(getSearchCookie("maxPrice"));
			else 
				$("maxPrice").value = '';
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt == null || srchcrt == "beds")
	{
		if(getSearchCookie("searchBeds") && $("searchBedsMin") && $("searchBedsMax"))
		{
			var beds = getSearchCookie("searchBeds");
			if(trim(beds) == "")
			{
				$("searchBedsMin").value = "";
				$("searchBedsMax").value = "";
			}
			else
			{
				var bdArr = beds.split("-");
				$("searchBedsMin").value = bdArr[0];
				$("searchBedsMax").value = bdArr[1];
			}
		}
		else
		{
			if($("searchBedsMin") && $("searchBedsMax"))
			{
				$("searchBedsMin").value = "";
				$("searchBedsMax").value = "";
			}
		}		
		
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "sqft")
	{
		if(getSearchCookie("minSize") && $("minSize"))
		{
			$("minSize").value = getSearchCookie("minSize");
		}
		else if($("minSize"))
		{
			$("minSize").selectedIndex = 0;
		}
		if(getSearchCookie("maxSize") && $("maxSize"))
		{
			$("maxSize").value = getSearchCookie("maxSize");
		}
		else if($("maxSize"))
		{
			$("maxSize").selectedIndex = 0;
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "baths")
	{
		if(getSearchCookie("searchBaths") && $("searchBathsMin") && $("searchBathsMax"))
		{
			var baths = getSearchCookie("searchBaths");
			if(trim(baths) == "")
			{
				$("searchBathsMin").value = "";
				$("searchBathsMax").value = "";
			}
			else
			{
				var bthArr = baths.split("-");
				$("searchBathsMin").value = bthArr[0];
				$("searchBathsMax").value = bthArr[1];
			}
		}
		else
		{
			if($("searchBathsMin") && $("searchBathsMax"))
			{
				$("searchBathsMin").value = "";
				$("searchBathsMax").value = "";
			}
		}

		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "type")
	{
		if(getSearchCookie("searchType") || trim(getSearchCookie("searchType")) == "")
		{
			if($("divPopUpSHType"))
			{
				var arrChkBox = $("divPopUpSHType").getElementsByTagName("input");
				var lenChkBox = arrChkBox.length;
				var strChkBox = getSearchCookie("searchType");
				if(trim(strChkBox) == "")
				{
					
					for(var i=0;i<lenChkBox;i++)
					{
				    	if(arrChkBox[i].id == "chbSHTypeAll")
				    	{
				    		continue;
				    	}
		    			if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == false)
		    			{
		    				arrChkBox[i].checked = true;
		    			}
					}	
				}
				else
				{
					var arrStrChkBox = strChkBox.split(":");
					for(var i=0;i<lenChkBox;i++)
					{
				    	if(arrChkBox[i].id == "chbSHTypeAll")
				    	{
				    		continue;
				    	}
		    			if(arrChkBox[i].type == "checkbox")
		    			{
		    				var valChkBox = arrChkBox[i].value;
		    				if(arrStrChkBox.in_array(valChkBox) !== false)
		    				{
		    					arrChkBox[i].checked = true;
		    				}
							else
							{
								arrChkBox[i].checked = false;
							}
		    			}
					}	
				}
			}
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "sortby")
	{
		if(getSearchCookie("searchSortType") && $("searchSortType"))
		{
			$("searchSortType").value = getSearchCookie("searchSortType");
		}
		else if($("searchSortType"))
		{
			$("searchSortType").selectedIndex = 0;
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "listdate")
	{
		if(getSearchCookie("ckLFDate") && $("txtLFDate"))
		{
			$("txtLFDate").value = getSearchCookie("ckLFDate");
		}
		else if($("txtLFDate"))
		{
			$("txtLFDate").value = '';
		}
		if(getSearchCookie("ckLTDate") && $("txtLTDate"))
		{
			$("txtLTDate").value = getSearchCookie("ckLTDate");
		}
		else if($("txtLTDate"))
		{
			$("txtLTDate").value = '';
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt == null || srchcrt == "propstyle")
	{
		if(getSearchCookie("propStyle") || trim(getSearchCookie("propStyle")) == "")
		{
			if($("propStyleDv"))
			{
				var arrChkBox = $("propStyleDv").getElementsByTagName("input");
				var lenChkBox = arrChkBox.length;
				var strChkBox = getSearchCookie("propStyle");
				if(trim(strChkBox) == "")
				{					
					for(var i=0;i<lenChkBox;i++)
					{
				    	if(arrChkBox[i].id == "chkStyleAll")
				    	{
				    		continue;
				    	}
		    			if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == false)
		    			{
		    				arrChkBox[i].checked = true;
		    			}
					}	
				}
				else
				{
					var arrStrChkBox = strChkBox.split(":");
					for(var i=0;i<lenChkBox;i++)
					{
				    	if(arrChkBox[i].id == "chkStyleAll")
				    	{
				    		continue;
				    	}
		    			if(arrChkBox[i].type == "checkbox")
		    			{
		    				var valChkBox = arrChkBox[i].value;
		    				if((arrStrChkBox.in_array(valChkBox) !== false) && (arrChkBox[i].checked == false))
		    				{
		    					arrChkBox[i].checked = true;
		    				}
		    			}
					}	
				}
			}
		}

		if(srchcrt != null)
		{
			return;
		}
	}
	/*if(srchcrt == null || srchcrt == "parkingtype")
	{
		if(getSearchCookie("parkingType") || trim(getSearchCookie("parkingType")) == "")
		{
			if($("parkingStyleDv"))
			{
				var arrChkBox = $("parkingStyleDv").getElementsByTagName("input");
				var lenChkBox = arrChkBox.length;
				var strChkBox = getSearchCookie("parkingType");
				if(trim(strChkBox) == "")
				{					
					for(var i=0;i<lenChkBox;i++)
					{
				    	if(arrChkBox[i].id == "chkParkingStyleAll")
				    	{
				    		continue;
				    	}
		    			if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == false)
		    			{
		    				arrChkBox[i].checked = true;
		    			}
					}	
				}
				else
				{
					var arrStrChkBox = strChkBox.split(":");
					for(var i=0;i<lenChkBox;i++)
					{
				    	if(arrChkBox[i].id == "chkParkingStyleAll")
				    	{
				    		continue;
				    	}
		    			if(arrChkBox[i].type == "checkbox")
		    			{
		    				var valChkBox = arrChkBox[i].value;
		    				if((arrStrChkBox.in_array(valChkBox) !== false) && (arrChkBox[i].checked == false))
		    				{
		    					arrChkBox[i].checked = true;
		    				}
		    			}
					}	
				}
			}
		}

		if(srchcrt != null)
		{
			return;
		}
	}*/
	
	if(srchcrt != null && srchcrt == "mlssource")
	{
		if(getSearchCookie("mlsSource") && $("mlsSource"))
		{
			$("mlsSource").value = getSearchCookie("mlsSource").replace(/[+]/g, ' ');
		}
		else if($("mlsSource"))
		{
			$("mlsSource").selectedIndex = 0;
		}
		if(srchcrt != null)
		{
			return;
		}
	}

	if(srchcrt != null && srchcrt == "propstatus")
	{
		/*if(getSearchCookie("propStatus") && $("propStatus"))
		{
			$("propStatus").value = getSearchCookie("propStatus");
		}
		else if($("propStatus"))
		{
			//$("propStatus").selectedIndex = 0;
			len = $("propStatus").options.length;
			var j;
			var status = 0;
			var defaultStatus = "";
			if(len>0)
			{
				for(j=0;j<len;j++)
				{
					if($("propStatus").options[j].value == 'Active')
					{
						defaultStatus = $("propStatus").options[j].value;
						status = 1;
					}
					else if(status==0)
					{
						defaultStatus = $("propStatus").options[0].value;
					}
				}
			}
			$("propStatus").value = defaultStatus;
		}
		if(srchcrt != null)
		{
			return;
		}*/

		var status = getSearchCookie("propStatus");

		if(status != '')
		{
			if($('divPStatus'))
			{				
				var dataArr = status.split(":");
				chkbxArr = $A($('divPStatus').getElementsByTagName("input"));
				chkbxArr.each(
					function(node)
					{				
						if(node.type == "checkbox" && node.checked == true)
							node.checked = false;

						if(node.type == "checkbox" && dataArr.indexOf(node.value) != -1)
							node.checked = true;
					});			
			}
		}
		else
		{
			if($('divPStatus'))
			{
				var stat = 0;
				chkbxArr = $A($('divPStatus').getElementsByTagName("input"));
				chkbxArr.each(
					function(node)
					{
						if(node.type=="checkbox" && (node.id == 'Active'))
						{
							node.checked = true;
							stat = 1;
						}
						else
							node.checked = false;
					});
					
				if(stat == 0)
				{
					var unstat = 0;
					$A($('divPStatus').getElementsByTagName("input")).each(function(node)
					{
						if(node.type=="checkbox" && unstat == 0)
						{
							node.checked = true;
							unstat = 1;
						}
					});
				}
			}
		}

		if(srchcrt != null)
		{
			return;
		}
	}
	
	if(srchcrt != null && srchcrt == "proptype")
	{		
		var types = getSearchCookie("propType");	

		if(types != '')
		{
			if($('divPType'))
			{
				var dataArr = types.split(":");
				chkbxArr = $A($('divPType').getElementsByTagName("input"));
				chkbxArr.each(
					function(node)
					{				
						if(node.type == "checkbox" && node.checked == true)
							node.checked = false;

						if(node.type == "checkbox" && dataArr.indexOf(node.value) != -1)
							node.checked = true;
					});			
			}
		}
		else
		{
			if($('divPType'))
			{
				chkbxArr = $A($('divPType').getElementsByTagName("input"));
				chkbxArr.each(
					function(node)
					{
						if(node.type=="checkbox" && (node.id == 'Single Family Residential' || node.id == 'Residential' || node.id == 'Single Family' || node.id == 'Single Family Homes'))
							node.checked = true;
						else
							node.checked = false;
					});			
			}
		}

		if(srchcrt != null)
		{
			return;
		}
	}
	
	if(srchcrt != null && srchcrt == "sqftp")
	{
		if(getSearchCookie("minPSize") && $("minPSize"))
		{
			$("minPSize").value = getSearchCookie("minPSize");
		}
		else if($("minPSize"))
		{
			$("minPSize").value = "";
		}
		if(getSearchCookie("maxPSize") && $("maxPSize"))
		{
			$("maxPSize").value = getSearchCookie("maxPSize");
		}
		else if($("maxPSize"))
		{
			$("maxPSize").value = "";
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	
	if(srchcrt != null && srchcrt == "listdatep")
	{
		if(getSearchCookie("ckPLFDate") && $("txtPLFDate"))
		{
			$("txtPLFDate").value = getSearchCookie("ckPLFDate");
		}
		else if($("txtPLFDate"))
		{
			$("txtPLFDate").value = '';
		}
		if(getSearchCookie("ckPLTDate") && $("txtPLTDate"))
		{
			$("txtPLTDate").value = getSearchCookie("ckPLTDate");
		}
		else if($("txtPLTDate"))
		{
			$("txtPLTDate").value = '';
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	
	if(srchcrt != null && srchcrt == "listagent")
	{
		if(getSearchCookie("listAgentFnm") && $("txtAgtFName"))
		{
			$("txtAgtFName").value = getSearchCookie("listAgentFnm");
		}
		else if($("txtAgtFName"))
		{
			$("txtAgtFName").value = 'First Name';
		}
		
		if(getSearchCookie("listAgentLnm") && $("txtAgtLName"))
		{
			$("txtAgtLName").value = getSearchCookie("listAgentLnm");
		}
		else if($("txtAgtLName"))
		{
			$("txtAgtLName").value = 'Last Name';
		}
		if(srchcrt != null)
		{
			return;
		}		
	}	
	
	if(srchcrt != null && srchcrt == "lotsize")
	{
		if(getSearchCookie("minLotSize") && $("minLotSize"))
		{
			$("minLotSize").value = getSearchCookie("minLotSize");
		}
		else if($("minLotSize"))
		{
			$("minLotSize").value = "";
		}
		
		if(getSearchCookie("maxLotSize") && $("maxLotSize"))
		{
			$("maxLotSize").value = getSearchCookie("maxLotSize");
		}
		else if($("maxLotSize"))
		{
			$("maxLotSize").value = "";
		}
		
		if(srchcrt != null)
		{
			return;
		}		
	}
	
	if(srchcrt != null && srchcrt == "age")
	{			
		if(getSearchCookie("fromAge") && $("txtAgeFrom"))
		{
			$("txtAgeFrom").value = getSearchCookie("fromAge");
		}
		else if($("txtAgeFrom"))
		{
			$("txtAgeFrom").value = '';
		}
		
		if(getSearchCookie("toAge") && $("txtAgeTo"))
		{
			$("txtAgeTo").value = getSearchCookie("toAge");
		}
		else if($("txtAgeTo"))
		{
			$("txtAgeTo").value = '';
		}
		
		if(srchcrt != null)
		{
			return;
		}
	}
	
	if(srchcrt != null && srchcrt == "yearbuilt")
	{			
		if(getSearchCookie("fromYear") && $("txtYearBuiltFrom"))
		{
			$("txtYearBuiltFrom").value = getSearchCookie("fromYear");
		}
		else if($("txtYearBuiltFrom"))
		{
			$("txtYearBuiltFrom").value = '';
		}
		
		if(getSearchCookie("toYear") && $("txtYearBuiltTo"))
		{
			$("txtYearBuiltTo").value = getSearchCookie("toYear");
		}
		else if($("txtYearBuiltTo"))
		{
			$("txtYearBuiltTo").value = '';
		}
		
		if(srchcrt != null)
		{
			return;
		}
	}	
	
	if(srchcrt != null && srchcrt == "daysonmarket")
	{			
		if(getSearchCookie("marketDaysFrom") && $("txtDaysMarketFrom"))
		{
			$("txtDaysMarketFrom").value = getSearchCookie("marketDaysFrom");
		}
		else if($("txtDaysMarketFrom"))
		{
			$("txtDaysMarketFrom").value = '';
		}
		if(getSearchCookie("marketDaysTo") && $("txtDaysMarketTo"))
		{
			$("txtDaysMarketTo").value = getSearchCookie("marketDaysTo");
		}
		else if($("txtDaysMarketTo"))
		{
			$("txtDaysMarketTo").value = '';
		}
		
		if(srchcrt != null)
		{
			return;
		}
	}
			
	if(srchcrt != null && srchcrt == "garage")
	{	
		if(getSearchCookie("garage") && $("cmbGarage"))
		{
			$("cmbGarage").value = getSearchCookie("garage").replace(/[+]/g, ' ');
		}
		else if($("cmbGarage"))
		{
			$("cmbGarage").selectedIndex = 0;
		}
		
		if(srchcrt != null)
		{
			return;
		}		
	}	

	if(srchcrt != null && srchcrt == "stories")
	{			
		if(getSearchCookie("stories") && $("txtStories"))
		{
			$("txtStories").value = getSearchCookie("stories");
		}
		else if($("txtStories"))
		{
			$("txtStories").value = '';
		}	
		if(srchcrt != null)
		{
			return;
		}
	}
	
	if(srchcrt != null && srchcrt == "schooldist")
	{			
		if(getSearchCookie("schooldist") && $("txtSchoolDist"))
		{
			$("txtSchoolDist").value = getSearchCookie("schooldist").replace(/[+]/g, ' ');
		}
		else if($("txtSchoolDist"))
		{
			$("txtSchoolDist").value = '';	
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "eleschool")
	{			
		if(getSearchCookie("eleSchool") && $("txtEleSchool"))
		{
			$("txtEleSchool").value = getSearchCookie("eleSchool").replace(/[+]/g, ' ');
		}
		else if($("txtEleSchool"))
		{
			$("txtEleSchool").value = '';	
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "midschool")
	{			
		if(getSearchCookie("midSchool") && $("txtMidSchool"))
		{
			$("txtMidSchool").value = getSearchCookie("midSchool").replace(/[+]/g, ' ');
		}
		else if($("txtMidSchool"))
		{
			$("txtMidSchool").value = '';	
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "highschool")
	{			
		if(getSearchCookie("highSchool") && $("txtHighSchool"))
		{
			$("txtHighSchool").value = getSearchCookie("highSchool").replace(/[+]/g, ' ');
		}
		else if($("txtHighSchool"))
		{
			$("txtHighSchool").value = '';	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}

	if(srchcrt != null && srchcrt == "bankowned")
	{			
		if(getSearchCookie("bankowned") && $("chkBankOwned"))
		{
			if(getSearchCookie("bankowned") == "true")
				$("chkBankOwned").checked = true;
			else
				$("chkBankOwned").checked = false;
		}
		else if($("chkBankOwned"))
		{
			$("chkBankOwned").checked = false;	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}

	if(srchcrt != null && srchcrt == "shortsales")
	{			
		if(getSearchCookie("shortsales") && $("chkShortSales"))
		{
			if(getSearchCookie("shortsales") == "true")
				$("chkShortSales").checked = true;
			else
				$("chkShortSales").checked = false;
		}
		else if($("chkShortSales"))
		{
			$("chkShortSales").checked = false;	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}

	if(srchcrt != null && srchcrt == "listagtid")
	{			
		if(getSearchCookie("listagtid") && $("txtListAgtId"))
		{
			$("txtListAgtId").value = getSearchCookie("listagtid");
		}
		else if($("txtListAgtId"))
		{
			$("txtListAgtId").value = '';	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "listoff")
	{			
		if(getSearchCookie("listoff") && $("txtListOff"))
		{
			$("txtListOff").value = getSearchCookie("listoff").replace(/[+]/g, ' ').replace("__",'#');
		}
		else if($("txtListOff"))
		{
			$("txtListOff").value = '';	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "saleagtid")
	{			
		if(getSearchCookie("saleagtid") && $("txtSaleAgtId"))
		{
			$("txtSaleAgtId").value = getSearchCookie("saleagtid");
		}
		else if($("txtSaleAgtId"))
		{
			$("txtSaleAgtId").value = '';	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "saleoff")
	{			
		if(getSearchCookie("saleoff") && $("txtSaleOff"))
		{
			$("txtSaleOff").value = getSearchCookie("saleoff").replace(/[+]/g, ' ');
		}
		else if($("txtSaleOff"))
		{
			$("txtSaleOff").value = '';	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "roof")
	{			
		if(getSearchCookie("roof") && $("txtRoof"))
		{
			$("txtRoof").value = getSearchCookie("roof").replace(/[+]/g, ' ');
		}
		else if($("txtRoof"))
		{
			$("txtRoof").value = '';	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "fire")
	{	
		if(getSearchCookie("fire") && $("cmbFire"))
		{
			$("cmbFire").value = getSearchCookie("fire");
		}
		else if($("cmbFire"))
		{
			$("cmbFire").selectedIndex = 0;
		}
		
		if(srchcrt != null)
		{
			return;
		}		
	}
	if(srchcrt != null && srchcrt == "pool")
	{	
		if(getSearchCookie("pool") && $("cmbPool"))
		{
			$("cmbPool").value = getSearchCookie("pool");
		}
		else if($("cmbPool"))
		{
			$("cmbPool").selectedIndex = 0;
		}
		
		if(srchcrt != null)
		{
			return;
		}		
	}
	
	if(srchcrt != null && srchcrt == "saledate")
	{			
		if(getSearchCookie("saleDateFrom") && $("txtSFDate"))
		{
			$("txtSFDate").value = getSearchCookie("saleDateFrom");
		}
		else if($("txtSFDate"))
		{
			$("txtSFDate").value = '';
		}
		if(getSearchCookie("saleDateTo") && $("txtSTDate"))
		{
			$("txtSTDate").value = getSearchCookie("saleDateTo");
		}
		else if($("txtSTDate"))
		{
			$("txtSTDate").value = '';
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "saleprice")
	{			
		if(getSearchCookie("salePriceFrom") && $("txtSalePriceFrom"))
		{
			$("txtSalePriceFrom").value = getSearchCookie("salePriceFrom");
		}
		else if($("txtSalePriceFrom"))
		{
			$("txtSalePriceFrom").value = '';
		}
		if(getSearchCookie("salePriceTo") && $("txtSalePriceTo"))
		{
			$("txtSalePriceTo").value = getSearchCookie("salePriceTo");
		}
		else if($("txtSalePriceTo"))
		{
			$("txtSalePriceTo").value = '';
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt != null && srchcrt == "saleagent")
	{
		if(getSearchCookie("saleAgentFnm") && $("txtSaleAgentFname"))
		{
			$("txtSaleAgentFname").value = getSearchCookie("saleAgentFnm");
		}
		else if($("txtSaleAgentFname"))
		{
			$("txtSaleAgentFname").value = 'First Name';
		}
		if(getSearchCookie("saleAgentLnm") && $("txtSaleAgentLname"))
		{
			$("txtSaleAgentLname").value = getSearchCookie("saleAgentLnm");
		}
		else if($("txtSaleAgentLname"))
		{
			$("txtSaleAgentLname").value = 'Last Name';
		}
		if(srchcrt != null)
		{
			return;
		}		
	}
	if(srchcrt != null && srchcrt == "area")
	{			
		if(getSearchCookie("area") && $("txtArea"))
		{
			$("txtArea").value = getSearchCookie("area");
		}
		else if($("txtArea"))
		{
			$("txtArea").value = '';	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "polygon")
	{			
		if(getSearchCookie("polygon") && $("txtPolygon"))
		{
			$("txtPolygon").value = getSearchCookie("polygon").replace(/\+/g, " ");
		}
		else if($("txtPolygon"))
		{
			$("txtPolygon").value = '';	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}

	if(srchcrt != null && srchcrt == "powerradial")
	{	
		if(getSearchCookie("powerradial") && $("cmbradial"))
		{
			$("cmbradial").value = getSearchCookie("powerradial");
		}
		else if($("cmbradial"))
		{
			$("cmbradial").selectedIndex = 0;
		}
		
		if(srchcrt != null)
		{
			return;
		}		
	}
}

function funGetSearchQueryString()
{
	var lfDate = "";
	var ltDate = "";

	var tempDate = escape(trim(getSearchCookie("ckLFDate")));
	if (tempDate != "")
	{
		var arrTempDate = tempDate.split ("-");
		lfDate = arrTempDate[2] + "-" + arrTempDate[0] + "-" + arrTempDate[1];
	}

	var tempDate = escape(trim(getSearchCookie("ckLTDate")));
	if (tempDate != "")
	{
		var arrTempDate = tempDate.split ("-");
		ltDate = arrTempDate[2] + "-" + arrTempDate[0] + "-" + arrTempDate[1];
	}

	searchQueryString = "";
	searchQueryString = searchQueryString + "qckWidgetUpdate=1";
	searchQueryString = searchQueryString + "&address=" 		+ 	escape(getSearchCookie("searchAddress"));
	if(getSearchCookie("city") && getSearchCookie("city") != "")
	{
		searchQueryString = searchQueryString + "&city=" 			+ 	escape(getSearchCookie("city"));
	}
	if(getSearchCookie("state") && getSearchCookie("state") != "")
	{
		searchQueryString = searchQueryString + "&state=" 			+ 	escape(getSearchCookie("state"));
	}
	if(getSearchCookie("zip") && getSearchCookie("zip") != "")
	{
		searchQueryString = searchQueryString + "&zip=" 			+ 	escape(getSearchCookie("zip"));
	}
	searchQueryString = searchQueryString + "&minprice=" 		+ 	escape(money2num(getSearchCookie("minPrice")));
	searchQueryString = searchQueryString + "&maxprice=" 		+ 	escape(money2num(getSearchCookie("maxPrice")));
	searchQueryString = searchQueryString + "&beds=" 			+ 	escape(getSearchCookie("searchBeds"));
	searchQueryString = searchQueryString + "&minsqft=" 		+ 	escape(getSearchCookie("minSize"));
	searchQueryString = searchQueryString + "&maxsqft=" 		+ 	escape(getSearchCookie("maxSize"));
	searchQueryString = searchQueryString + "&baths=" 			+ 	escape(getSearchCookie("searchBaths"));
	searchQueryString = searchQueryString + "&searchType=" 		+ 	escape(getSearchCookie("searchType"));
	searchQueryString = searchQueryString + "&searchSortType=" 	+ 	escape(trim(getSearchCookie("searchSortType"))==""?"ph":trim(getSearchCookie("searchSortType")));
	searchQueryString = searchQueryString + "&lfDate="			+ 	escape(lfDate);
	searchQueryString = searchQueryString + "&ltDate="			+ 	escape(ltDate);
	searchQueryString = searchQueryString + "&county="			+ 	escape(trim(getSearchCookie("county")));
	
	var setPropStyle  = getSearchCookie("propStyle");
	setPropStyle 	  = setPropStyle.replace(":",",");
	searchQueryString = searchQueryString + "&propStyle="		+ 	escape(trim(setPropStyle));
	
	if(trim(getSearchCookie("garage")) == 'All')
		searchQueryString = searchQueryString + "&garage=";
	else
		searchQueryString = searchQueryString + "&garage="		+ 	escape(trim(getSearchCookie("garage")));
		
	if(trim(getSearchCookie("neighborhood")) == 'all')
		searchQueryString = searchQueryString + "&neighborhood=";
	else
		searchQueryString = searchQueryString + "&neighborhood="	+ 	escape((trim(getSearchCookie("neighborhood"))));
	
	var myQs = new Querystring();
	var frm = myQs.get("frm");
	var aid = myQs.get("aid");

	if(frm != null && trim(frm) == 'agt' && aid != null && trim(aid) != "")
	{
		if(typeof(strAgtMlsSrc) != 'undefined' && strAgtMlsSrc != null && strAgtMlsSrc.length > 0)
			searchQueryString = searchQueryString + "&mlsSource="	+ 	escape((trim(strAgtMlsSrc)));
		else
			searchQueryString = searchQueryString + "&mlsSource=";
		searchQueryString = searchQueryString + "&aid="			+ 	escape((trim(aid)));
	}	
	if(latLong)
		searchQueryString = searchQueryString+"&propLatitude="+latLong.lat+"&propLongitude="+latLong.lng;
	return searchQueryString;
}

function funGetAdvSearchQueryString()
{
	var lfDate = "";
	var ltDate = "";

	var tempDate = escape(trim(getSearchCookie("ckLFDate")));
	if (tempDate != "")
	{
		var arrTempDate = tempDate.split ("-");
		lfDate = arrTempDate[2] + "-" + arrTempDate[0] + "-" + arrTempDate[1];
	}

	var tempDate = escape(trim(getSearchCookie("ckLTDate")));
	if (tempDate != "")
	{
		var arrTempDate = tempDate.split ("-");
		ltDate = arrTempDate[2] + "-" + arrTempDate[0] + "-" + arrTempDate[1];
	}

	searchQueryString = new StringBuffer();
	searchQueryString.append("qckWidgetUpdate=1");
	searchQueryString.append("&minprice=" 		+ 	escape(money2num(getSearchCookie("minPrice"))));
	searchQueryString.append("&maxprice=" 		+ 	escape(money2num(getSearchCookie("maxPrice"))));
	searchQueryString.append("&beds=" 			+ 	escape(getSearchCookie("searchBeds")));
	searchQueryString.append("&minsqft=" 		+ 	escape(getSearchCookie("minSize")));
	searchQueryString.append("&maxsqft=" 		+ 	escape(getSearchCookie("maxSize")));
	searchQueryString.append("&baths=" 			+ 	escape(getSearchCookie("searchBaths")));
	searchQueryString.append("&searchType=" 		+ 	escape(getSearchCookie("searchType")));
	searchQueryString.append("&searchSortType=" 	+ 	escape(trim(getSearchCookie("searchSortType"))==""?"ph":trim(getSearchCookie("searchSortType"))));
	searchQueryString.append("&lfDate="			+ 	escape(lfDate));
	searchQueryString.append("&ltDate="			+ 	escape(ltDate));
	searchQueryString.append("&county="			+ 	escape(trim(getSearchCookie("county"))));
		
	if(trim(getSearchCookie("neighborhood")) == 'all')
		searchQueryString.append("&neighborhood=");
	else
		searchQueryString.append("&neighborhood="	+ 	escape((trim(getSearchCookie("neighborhood")))));

	var myQs = new Querystring();
	var frm = myQs.get("frm");
	var aid = myQs.get("aid");	
	if(frm != null && trim(frm) == 'agt' && aid != null && trim(aid) != "")
	{
		if(typeof(strAgtMlsSrc) != 'undefined' && strAgtMlsSrc != null && strAgtMlsSrc.length > 0)
			searchQueryString.append("&mlsSource="	+ 	escape((trim(strAgtMlsSrc))));
		else
			searchQueryString.append("&mlsSource=");
		searchQueryString.append("&aid="			+ 	escape((trim(aid))));
	}	
	return searchQueryString.toString();
}

function funCompareSearchCookie()
{
	if($('searchCSZ') != null)
	{
		var cszFromCookie = setCSZValue(getSearchCookie("city"), getSearchCookie("state"), getSearchCookie("zip"));
		$('searchCSZ').value = $('searchCSZ').value.replace (/^\s+/g, "").replace (/\s+$/g, "").replace (/\s+/g, " ");
		if (trim(cszFromCookie).toUpperCase() != trim($('searchCSZ').value).toUpperCase())
		{
			return 1;		
		}
	}		
	if(($("searchAddress") != null) && (getSearchCookie("searchAddress") != $F("searchAddress").replace('optional','')))
	{
		return 1;
	}
	if($("minPrice") && (getSearchCookie("minPrice") != money2num($F("minPrice"))))
	{
		return true;
	}
	if($("maxPrice") && (getSearchCookie("maxPrice") != money2num($F("maxPrice"))))
	{
		return true;
	}
	if($("searchBedsMin") && $("searchBedsMax") && trim(getSearchCookie("searchBeds")) != "" && (trim(getSearchCookie("searchBeds")) != trim($F("searchBedsMin"))+"-"+trim($F("searchBedsMax"))))
	{
		return true;
	}
	if($("minSize") && ((trim(getSearchCookie("minSize")) == "" && $F("minSize") != 0) || ((trim(getSearchCookie("minSize")) != "") && (trim(getSearchCookie("minSize")) != $F("minSize")))))
	{
		return true;
	}
	if($("maxSize") && ((trim(getSearchCookie("maxSize")) == "" && $F("maxSize") != 0) || ((trim(getSearchCookie("maxSize")) != "") && (trim(getSearchCookie("maxSize")) != $F("maxSize")))))
	{
		return true;
	}
	if($("searchBathsMin") && $("searchBathsMax") && trim(getSearchCookie("searchBaths")) != "" && (trim(getSearchCookie("searchBaths")) != trim($F("searchBathsMin"))+"-"+trim($F("searchBathsMax"))))
	{
		return true;
	}
	if($("divPopUpSHType") != null)
	{
		var arrChkBox = $("divPopUpSHType").getElementsByTagName("input");
		var lenChkBox = arrChkBox.length;
		var strChkBox = getSearchCookie("searchType");
		if(trim(strChkBox) == "")
		{
			for(var i=0;i<lenChkBox;i++)
			{
		    	if(arrChkBox[i].id == "chbSHTypeAll")
		    	{
		    		continue;
		    	}
		    	if((arrChkBox[i].type == "checkbox") && (arrChkBox[i].checked === false))
		    	{
		    		return true;
		    	}
			}	
		}
		else
		{
			var arrStrChkBox = strChkBox.split(":");
			for(var i=0;i<lenChkBox;i++)
			{
		    	if(arrChkBox[i].type == "checkbox")
		    	{
		    		var valChkBox = arrChkBox[i].value;
		    		if(arrStrChkBox.in_array(valChkBox) != false && arrChkBox[i].checked == false)
		    		{
		    			return true;
		    		}
		    	}
			}	
		}
	}
	if($("searchSortType") && (((trim(getSearchCookie("searchSortType"))!= "") && (getSearchCookie("searchSortType") !== $F("searchSortType"))) || (((trim(getSearchCookie("searchSortType")) == "") && ($F("searchSortType") != "ph")))))
	{
		return true;
	}
	return false;
}

function funCheckContradict()
{
	var retValue;
	var geoCbFn = function(reqObj)
	{
		for(var i=0;i<20;i++)
		{
			var idTxtObj = 'searchCSZ'+ eval(i+1);
			if($(idTxtObj) != null)
				$(idTxtObj).value = "";
		}
		var geoResponse = reqObj.responseText;
		var allCity = "";
		var allState = "";
		var allZip = "";
		var geoArrResponse = eval(geoResponse);
		var boolGetSingleCity = false;
		for(var i=0;i<geoArrResponse.length;i++)
		{
			if(geoArrResponse[i].status == 0)
			{	
				boolGetSingleCity = true;
				var geoCity = geoArrResponse[i].city;
				allCity += geoCity + '|';
				var geoState = geoArrResponse[i].state;
				allState += geoState + '|';
				var geoZip = geoArrResponse[i].zip;
				allZip += geoZip + '|';
				var geoAddress = geoArrResponse[i].address;
				setSearchCookie("searchAddress",geoAddress);
				$("searchAddress").value = geoAddress;
				
				
				setSearchCookie("county","");
				setSearchCookie("neighborhood","");
				arrDataCounty.length = 0;
				arrDataNeighborHood.length = 0;
				headerContent("county");
				headerContent("neighborhood");
				
				var now = new Date();
				now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
				var latLongStr = "[{'lat':'"+geoArrResponse[i].latitude+"','lng':'"+geoArrResponse[i].longitude+"'}]";
				setCookie("latLongCk",latLongStr,now);
				latLong = eval(getCookie("latLongCk"))[0];
				if(trim(getCookie("lpid")) != "" && isContradict === 1)
				{
					setCookie("lpid","");
					if(window.location.pathname.indexOf("dashboard") > 0)
					{
						funCloseWidget("divChild1X2");
						funCloseWidget("divChild1X3");
						funCloseWidget("divChild2X1");
						funCloseWidget("divChild2X2");
						funCloseWidget("divChild2X3");
						funCloseWidget("divChild3X1");
						funCloseWidget("divChild3X2");
						funCloseWidget("divChild3X3");
					}	
				}
			}
		}
		if(boolGetSingleCity == false)
		{			
			if(geoArrResponse.length > 1)
			{
				alert('Sorry, We couldn\'t find any location from "' + $('searchCSZ').value + '"');
			}
			else
			{				
				alert('Sorry, We couldn\'t find a location for "' + geoArrResponse[0].originaladdress + '"');
				setSearchCookie("searchAddress","");
				if($("searchAddress")) $("searchAddress").value = "optional";
				if(typeof(srTabs) != "undefined" && srTabs.getTab(0).get("active"))
				{
					srTabs.set('activeTab',srTabs.getTab(0),true);
					srTabs.getTab(0).refresh();
				}
			}
			retValue = "0";
			return;
		}
		else
		{
			if (allCity != "")
			{
				setSearchCookie ("city", allCity.substr(0, allCity.length-1));			
			}
			if (allState != "")
			{
				setSearchCookie ("state", allState.substr(0, allState.length-1));			
			}
			if (allZip != "")
			{
				setSearchCookie ("zip", allZip.substr(0, allZip.length-1));			
			}
			$('searchCSZ').value = setCSZValue(getSearchCookie('city'),getSearchCookie('state'),getSearchCookie('zip'));
			retValue = "2";
			return;
		}	
	}
	var isContradict = funCompareSearchCookie();
	if(isContradict === 1)
	{
		var geoUrl = "/classes/getCSZ.php";
		var geoAddress = "";
		if((trim($("searchAddress").value).toLowerCase() != "optional") && (trim($('searchCSZ').value).search(';') === -1))
		{
			geoAddress = $("searchAddress").value;
		}
		var geoQueryString = "csz="+escape($('searchCSZ').value)+"&address="+escape(geoAddress);
		ajaxRequest(geoUrl,geoQueryString,geoCbFn,false);
		return retValue;
	}
	else
	{
		return "1";
	}	
}

function CompareMinMax(srchcrt)
{
	if(srchcrt == null || srchcrt == "price")
	{
		var minP = Number(money2num($('minPrice').value));	
		var maxP = Number(money2num($('maxPrice').value));	
	
		if(minP<0 || maxP<0)
		{
			alert("Please enter valid price range");
			$('minPrice').value = '';
			$('maxPrice').value = '';
			return false;
		}
		if((minP>maxP) && (minP != "" && maxP != ""))
		{
			alert("Please enter valid price range");
			$('minPrice').value = '';
			$('maxPrice').value = '';
			return false;
		}
		if(srchcrt != null)
		{
			return;
		}
	}

	if(srchcrt == null || srchcrt == "beds")
	{
		var minbd = trim($('searchBedsMin').value);
		var maxbd = trim($('searchBedsMax').value);

		if(isNaN(minbd))
		{
			alert("Please enter numeric value for min beds");
			$('searchBedsMin').value = '';
			return false;
		}

		if(isNaN(maxbd))
		{
			alert("Please enter numeric value for max beds");
			$('searchBedsMax').value = '';
			return false;
		}

		if(minbd.include("."))
		{
			var ptLen = minbd.substr(minbd.indexOf(".")+1,minbd.length).length;
			if(ptLen>2)
			{
				alert("Only 2 digits allowed after decimal point for min beds");
				$('searchBedsMin').value = '';
				return false;
			}
		}

		if(maxbd.include("."))
		{
			var ptLen = maxbd.substr(maxbd.indexOf(".")+1,maxbd.length).length;
			if(ptLen>2)
			{
				alert("Only 2 digits allowed after decimal point for max beds");
				$('searchBedsMax').value = '';
				return false;
			}
		}

		minbd = Number(minbd);
		maxbd = Number(maxbd);

		if(minbd<0 || maxbd<0)
		{
			alert("Please enter valid beds range");
			$('searchBedsMin').value = '';
			$('searchBedsMax').value = '';
			return false;
		}
		if((minbd>maxbd) && (minbd != "" && maxbd != ""))
		{
			alert("Please enter valid beds range");
			$('searchBedsMin').value = '';
			$('searchBedsMax').value = '';
			return false;
		}
	}

	if(srchcrt == null || srchcrt == "baths")
	{
		var minbth = trim($('searchBathsMin').value);
		var maxbth = trim($('searchBathsMax').value);

		if(isNaN(minbth))
		{
			alert("Please enter numeric value for min baths");
			$('searchBathsMin').value = '';
			return false;
		}

		if(isNaN(maxbth))
		{
			alert("Please enter numeric value for max baths");
			$('searchBathsMax').value = '';
			return false;
		}

		if(minbth.include("."))
		{
			var ptLen = minbth.substr(minbth.indexOf(".")+1,minbth.length).length;
			if(ptLen>2)
			{
				alert("Only 2 digits allowed after decimal point for min baths");
				$('searchBathsMin').value = '';
				return false;
			}
		}

		if(maxbth.include("."))
		{
			var ptLen = maxbth.substr(maxbth.indexOf(".")+1,maxbth.length).length;
			if(ptLen>2)
			{
				alert("Only 2 digits allowed after decimal point for max baths");
				$('searchBathsMax').value = '';
				return false;
			}
		}

		minbth = Number(minbth);
		maxbth = Number(maxbth);

		if(minbth<0 || maxbth<0)
		{
			alert("Please enter valid baths range");
			$('searchBathsMin').value = '';
			$('searchBathsMax').value = '';
			return false;
		}
		if((minbth>maxbth) && (minbth != "" && maxbth != ""))
		{
			alert("Please enter valid baths range");
			$('searchBathsMin').value = '';
			$('searchBathsMax').value = '';
			return false;
		}
	}

	if(srchcrt == null || srchcrt == "sqft")	
	{
		var sqftMin = Number($("minSize").value);
		var sqftMax = Number($("maxSize").value);
		if(sqftMin>sqftMax && sqftMax != 0)
		{
			alert("Please select valid range for square feet");
			return false;
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt == null || srchcrt == "listdate")
	{
		if(trim($("txtLFDate").value) != "" && trim($("txtLTDate").value) != "")
		{
			var valLFDate = $("txtLFDate").value;
			var arrLFDate = valLFDate.split("-");		
			var objLFDate = new Date();
			objLFDate.setYear(arrLFDate[2]);
			objLFDate.setMonth(arrLFDate[0]);
			objLFDate.setDate(arrLFDate[1]);
			var tsLFDate = objLFDate.getTime()
			var valLTDate = $("txtLTDate").value;
			var arrLTDate = valLTDate.split("-");		
			var objLTDate = new Date();
			objLTDate.setYear(arrLTDate[2]);
			objLTDate.setMonth(arrLTDate[0]);
			objLTDate.setDate(arrLTDate[1]);
			var tsLTDate = objLTDate.getTime()
			if(tsLFDate > tsLTDate)
			{
				alert("To date should not be less than From date.");
				$('txtLFDate').value = '';
				$('txtLTDate').value = '';
				return false;
			}
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	return true;
}

function headerContent(srchcrt)
{
	if(srchcrt != null && srchcrt == "mls")
	{
		var ihMLSLabel = "MLS # ";
		var ihMLSValue = "";
		if(trim(getSearchCookie('mlsno')) != "")
		{
			var ihMLSValue = getSearchCookie('mlsno'); 
		}
		if($("divSHMLS") != null)
		{
			if($("divSHMLS").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHMLS").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihMLSLabel;
				}
				var objSpanValue = $("divSHMLS").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihMLSValue) != ""))
				{
					objSpanValue.innerHTML = ihMLSValue;
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt == null || srchcrt == "county")
	{
		var ihCountyLabel = "County: ";
		var ihCountyValue = "";
		if((getSearchCookie("county") != null) && (trim(getSearchCookie("county")) != ""))
		{
			ihCountyValue = getSearchCookie("county"); 
		}
		else
		{
			ihCountyValue = 'any';
		}
		if($("divSHCounty") != null)
		{
			if($("divSHCounty").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHCounty").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihCountyLabel;
				}
				var objSpanValue = $("divSHCounty").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihCountyValue) != ""))
				{
					objSpanValue.innerHTML = funWrapText(ihCountyValue,20);
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt == null || srchcrt == "neighborhood")
	{
		var ihNeighborhoodLabel = "Neighborhood: ";
		var ihNeighborhoodValue = new StringBuffer();
		if((getSearchCookie("neighborhood") != null) && (trim(getSearchCookie("neighborhood")) != ""))
		{
			var strCKNH = getSearchCookie("neighborhood");
			var arrCKNH = strCKNH.split(',');
			var lenArrCKNH = arrCKNH.length;
			for(var i=0;i<lenArrCKNH;i++)
			{
				ihNeighborhoodValue.append(arrCKNH[i] + ',');
			}
			ihNeighborhoodValue = ihNeighborhoodValue.toString();
			if(ihNeighborhoodValue.charAt(ihNeighborhoodValue.length-1) == ',')
			{
				ihNeighborhoodValue = ihNeighborhoodValue.substr(0,eval(ihNeighborhoodValue.length-1));
			}
		}
		else
		{
			ihNeighborhoodValue =  ihNeighborhoodValue + 'any';
		}
		if($("divSHNeighborHood") != null)
		{
			if($("divSHNeighborHood").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHNeighborHood").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihNeighborhoodLabel;
				}
				var objSpanValue = $("divSHNeighborHood").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihNeighborhoodValue) != ""))
				{
					objSpanValue.innerHTML = funWrapText(ihNeighborhoodValue,15);
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if((srchcrt == null || srchcrt == "price") && $('minPrice') && $('maxPrice'))
	{	
		var ihPriceLabel = "Price: ";
		var ihPriceValue = "";
		var minP = Number(money2num(getSearchCookie("minPrice")));
		var maxP = Number(money2num(getSearchCookie("maxPrice")));	
		if(minP != 0 || maxP != 0)
		{
			if(minP != 0)
			{
				minP = num2money($('minPrice').value,'$','minPrice',false);
				ihPriceValue = ihPriceValue + minP+" to ";
			}
			else
			{
				ihPriceValue = ihPriceValue + "No Min to ";
			}
			if(maxP != 0)
			{
				maxP = num2money($('maxPrice').value,'$','maxPrice',false);
				ihPriceValue = ihPriceValue + maxP;
			}
			else
			{
				ihPriceValue = ihPriceValue + "No Max";
			}
		}
		else
		{
			ihPriceValue = ihPriceValue + "any";
		}
		if($("divSHPrice") != null)
		{
			if($("divSHPrice").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHPrice").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihPriceLabel;
				}
				var objSpanValue = $("divSHPrice").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihPriceValue) != ""))
				{
					objSpanValue.innerHTML = ihPriceValue;
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt == null || srchcrt == "beds")
	{
		var ihBedsLabel = "Beds: ";
		var ihBedsValue = "";
		var searchBeds = getSearchCookie("searchBeds");
		if(trim(searchBeds) == "")
			ihBedsValue = ihBedsValue + "any";
		else
		{
			var bdArr = searchBeds.split("-");

			if(bdArr[0] != "" && bdArr[1] != "")
				ihBedsValue = bdArr[0] + " to " + bdArr[1];
			else if(bdArr[0] != "")
				ihBedsValue = bdArr[0] + " to No Max";
			else
				ihBedsValue = "No Min to " + bdArr[1];
		}
		if($("divSHBeds") != null)
		{
			if($("divSHBeds").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHBeds").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihBedsLabel;
				}
				var objSpanValue = $("divSHBeds").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihBedsValue) != ""))
				{
					objSpanValue.innerHTML = ihBedsValue;
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}		
	if(srchcrt == null || srchcrt == "baths")
	{
		var ihBathsLabel = "Baths: ";
		var ihBathsValue = "";
		var searchBaths = getSearchCookie("searchBaths");
		if(trim(searchBaths) == "")
			ihBathsValue = ihBathsValue + "any";
		else
		{
			var bthArr = searchBaths.split("-");

			if(bthArr[0] != "" && bthArr[1] != "")
				ihBathsValue = bthArr[0] + " to " + bthArr[1];
			else if(bthArr[0] != "")
				ihBathsValue = bthArr[0] + " to No Max";
			else
				ihBathsValue = "No Min to " + bthArr[1];
		}

		if($("divSHBaths") != null)
		{
			if($("divSHBaths").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHBaths").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihBathsLabel;
				}
				var objSpanValue = $("divSHBaths").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihBathsValue) != ""))
				{
					objSpanValue.innerHTML = ihBathsValue;
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "sqft")
	{
		var ihSqftLabel = "Sqft: ";
		var ihSqftValue = "";
		var sqftMin = Number(getSearchCookie("minSize"));
		var sqftMax = Number(getSearchCookie("maxSize"));
		if((sqftMax != "0") || (sqftMin > 0 && sqftMax == 0))
		{
			if (sqftMin > 0 || (sqftMax > 0 && sqftMin == 0))
				ihSqftValue = ihSqftValue + sqftMin + ' - ';
			if (sqftMax > 0)
				ihSqftValue = ihSqftValue + sqftMax;
			if (sqftMax == 0)
				ihSqftValue = ihSqftValue + 'No Max';
		}
		else
		{
			ihSqftValue = ihSqftValue +  "any";
		}
		if($("divSHSqft") != null)
		{
			if($("divSHSqft").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHSqft").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihSqftLabel;
				}
				var objSpanValue = $("divSHSqft").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihSqftValue) != ""))
				{
					objSpanValue.innerHTML = ihSqftValue;
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "listdate")
	{
		var ihListDateLabel = "List Date: ";
		var ihListDateValue = "";
		var valLFDate = getSearchCookie("ckLFDate");
		var valLTDate = getSearchCookie("ckLTDate");
		if(trim(valLFDate) != "" || trim(valLTDate) != "")
		{
			if(trim(valLFDate) != "")
			{
				ihListDateValue = ihListDateValue + "From "+valLFDate;
			}
			if(trim(valLFDate) != "" && trim(valLTDate) != "")
			{
				ihListDateValue = ihListDateValue + " To "+valLTDate;
			}
			else if(trim(valLTDate) != "")
			{
				ihListDateValue = ihListDateValue + " : UpTo "+valLTDate;
			}
		}
		else
		{
			ihListDateValue = ihListDateValue + "any";
		}
		if($("divSHListDate") != null)
		{
			if($("divSHListDate").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHListDate").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihListDateLabel;
				}
				var objSpanValue = $("divSHListDate").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihListDateValue) != ""))
				{
					objSpanValue.innerHTML = ihListDateValue;
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "type")
	{
		var ihTypeLabel = "Type: ";
		var ihTypeValue = "";
		var valSearchType = getSearchCookie("searchType");
		if(trim(valSearchType) != "")
		{
			var arrValSearchType = valSearchType.split(':');
			var lenValSearchType = arrValSearchType.length;
			for(var i=0;i<lenValSearchType;i++)
			{
				var keySearchTypeVal = arrValSearchType[i];
				if(trim(keySearchTypeVal) != "")
				{
					ihTypeValue = ihTypeValue + arrValSearchType[keySearchTypeVal]+',';
				}	
			}
			if(ihTypeValue.charAt(ihTypeValue.length-1) == ',')
			{
				ihTypeValue = ihTypeValue.substr(0,eval(ihTypeValue.length-1));
			}
		}
		else
		{
			ihTypeValue = ihTypeValue + "all";
		}
		if($("divSHType") != null)
		{
			if($("divSHType").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHType").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihTypeLabel;
				}
				var objSpanValue = $("divSHType").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihTypeValue) != ""))
				{
					objSpanValue.innerHTML = funWrapText(ihTypeValue,15);
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "sortby")
	{
		var ihSortTypeLabel = "Sort By: ";
		var ihSortTypeValue = "";
		var sortType = getSearchCookie("searchSortType");
		if(trim(sortType) == "" || sortType == "ph")
		{ 
			ihSortTypeValue = ihSortTypeValue + "Price High to Low";
		}		
		else if(sortType == "pl")
		{ 
			ihSortTypeValue = ihSortTypeValue + "Price Low to High";
		}	
		else if(sortType == "brh")
		{ 
			ihSortTypeValue = ihSortTypeValue + "Beds High to Low";
		}		
		if(sortType == "brl")
		{ 
			ihSortTypeValue = ihSortTypeValue + "Beds Low to High";
		}	
		else if(sortType == "bah")
		{ 
			ihSortTypeValue = ihSortTypeValue + "Baths High to Low";
		}		
		else if(sortType == "bal")
		{ 
			ihSortTypeValue = ihSortTypeValue + "Baths Low to High";
		}
		if($("divSHSortBy") != null)
		{
			if($("divSHSortBy").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHSortBy").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihSortTypeLabel;
				}
				var objSpanValue = $("divSHSortBy").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihSortTypeValue) != ""))
				{
					objSpanValue.innerHTML = ihSortTypeValue;
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}		
}
function funUnchkAllChkBox(objChkBox) 
{
	if(($('chbSHNHAll').checked == true) && (objChkBox.checked == false))
	{
		$('chbSHNHAll').checked = false;
	}
}
function funSetSHNHAll(from)
{
	if(typeof(from)!="undefined")
	{
		divId = "divNHood";
		chkAllId = "chbRSNHAll";
	}
	else
	{
		divId = "divSHDataNeighborHood";
		chkAllId = "chbSHNHAll";
	}
	var arrChkBox = $(divId).getElementsByTagName("input");
	var lenChkBox = arrChkBox.length;
	for(var i=0;i<lenChkBox;i++)
	{
		if(arrChkBox[i].id == chkAllId)
		{
		 	continue;
		}
	    if(($(chkAllId).checked == true) && (arrChkBox[i].type == "checkbox"))
	    {
	    	arrChkBox[i].checked = true;
	    }
	    else if(arrChkBox[i].type == "checkbox")
	    {
    		arrChkBox[i].checked = false;
	    }
	}
}
function funSetSHTypeAll(type)
{
	if(typeof(type)!="undefined")
	{
		divId = "divRSType";
		chkAllId = "RSchbSHTypeAll";
	}
	else
	{
		divId = "divPopUpSHType";
		chkAllId = "chbSHTypeAll";
	}
	if($(divId))
	{
		var	arrChkBox  = $(divId).getElementsByTagName("input");
		var lenChkBox = arrChkBox.length;
		for(var i=0;i<lenChkBox;i++)
		{
			if(arrChkBox[i].id == chkAllId)
			{
				continue;
			}
			if(($(chkAllId).checked == true) && (arrChkBox[i].type == "checkbox"))
			{
				arrChkBox[i].checked = true;
			}
			else if(($(chkAllId).checked == false) && (arrChkBox[i].type == "checkbox"))
			{
				arrChkBox[i].checked = false;
			}
		}
	}
}

function funCloseAdvanceSearch(srchcrt,page)
{	
	if($("divSHCounty")==null)
	{
		return;
	}
	
	Element.removeClassName($("divSHCounty").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
	Element.addClassName($("divSHCounty").getElementsByTagName('a')[0],'linkAdvanceSearch');
	$("divPopUpSHCounty").style.display = "none";

	Element.removeClassName($("divSHNeighborHood").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
	Element.addClassName($("divSHNeighborHood").getElementsByTagName('a')[0],'linkAdvanceSearch');
	$("divPopUpSHNeighborHood").style.display 	= "none";
	
	if($("divPopUpSHPrice"))
	{
		Element.removeClassName($("divSHPrice").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
		Element.addClassName($("divSHPrice").getElementsByTagName('a')[0],'linkAdvanceSearch');
		$("divPopUpSHPrice").style.display = "none";
	}

	if($("divSHMultiCity") != null)
	{
		Element.removeClassName($("divSHMultiCity").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
		Element.addClassName($("divSHMultiCity").getElementsByTagName('a')[0],'linkAdvanceSearch');
		$("divPopUpSHMultiCity").style.display = "none";
	}
	
	if($("divPopUpSHBeds"))
	{
		Element.removeClassName($("divSHBeds").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
		Element.addClassName($("divSHBeds").getElementsByTagName('a')[0],'linkAdvanceSearch');
		$("divPopUpSHBeds").style.display = "none";
	}
	
	if($("divPopUpSHBaths"))
	{
		Element.removeClassName($("divSHBaths").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
		Element.addClassName($("divSHBaths").getElementsByTagName('a')[0],'linkAdvanceSearch');
		$("divPopUpSHBaths").style.display = "none";
	}
	
	if($("divPopUpSHSqft"))
	{
		Element.removeClassName($("divSHSqft").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
		Element.addClassName($("divSHSqft").getElementsByTagName('a')[0],'linkAdvanceSearch');
		$("divPopUpSHSqft").style.display = "none";
	}
	
	Element.removeClassName($("divSHListDate").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
	Element.addClassName($("divSHListDate").getElementsByTagName('a')[0],'linkAdvanceSearch');
	$("divPopUpSHListDate").style.display = "none";
	
	Element.removeClassName($("divSHType").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
	Element.addClassName($("divSHType").getElementsByTagName('a')[0],'linkAdvanceSearch');
	$("divPopUpSHType").style.display = "none";
	
	Element.removeClassName($("divSHMLS").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
	Element.addClassName($("divSHMLS").getElementsByTagName('a')[0],'linkAdvanceSearch');
	$("divPopUpSHMLS").style.display = "none";
	
	Element.removeClassName($("divSHSortBy").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
	Element.addClassName($("divSHSortBy").getElementsByTagName('a')[0],'linkAdvanceSearch');
	$("divPopUpSHSortBy").style.display = "none";

	if($("divSaveSearch"))
	{
		Element.removeClassName($("divSaveSearch").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
		Element.addClassName($("divSaveSearch").getElementsByTagName('a')[0],'linkAdvanceSearch');
		$("divSaveSearch").style.display = "none";
	}

	if($("divSHPowerSortBy"))
	{
		Element.removeClassName($("divSHPowerSortBy").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
		Element.addClassName($("divSHPowerSortBy").getElementsByTagName('a')[0],'linkAdvanceSearch');
	}
	
	if($("divPopUpSHPower"))
		$("divPopUpSHPower").style.display = "none";
	
	if($("divPopUpSHPropStyle")) $("divPopUpSHPropStyle").style.display = "none";
	if($("divPopUpSHGarage")) $("divPopUpSHGarage").style.display = "none";
	
	$("divPopUpSHMLSInfo").style.visibility = "hidden";
	$("divPopUpSHControls").style.display = "none";
	
	$("divContainerAdvanceSearch").style.display = "none";
	$("divContainerAdvanceSearch").style.left = "-100px";
	$("divContainerAdvanceSearch").style.top = "-100px";
	
	if(srchcrt != null)
	{
		setAllCookieValue(srchcrt);
	}
}
function funSaveAdvanceSearch(srchcrt,page)
{
	if(srchcrt == "multicity")
	{
		var boolAllCityBlank = true;
		for(var i=0;i<20;i++)
		{
			var idTxtObj = 'searchCSZ'+ eval(i+1);
			if(trim($(idTxtObj).value) != "")
			{
				boolAllCityBlank = false;
				break;
			}
		}
		if (boolAllCityBlank == true)
		{
			alert("Please specify either City & State or Zip for atleast one.");
			return false;
		}
		var allCSZ = "";
		for(var i=0;i<20;i++)
		{
			var idTxtObj = 'searchCSZ'+ eval(i+1);
			if(trim($(idTxtObj).value) == "")
			{
				continue;
			}
			else
			{
				allCSZ += trim($(idTxtObj).value.replace(/;/g,'')) + ';';
			}
		}
		$('searchCSZ').value = allCSZ.substr(0, allCSZ.length-1);
		funCloseAdvanceSearch();
		return true;
	}
	if(srchcrt == "mls")
	{
		if(trim($("searchMLS").value) == "")
		{
			alert("Please input MLS number to search.");
			return false;
		}
		searchByMlsNo();
		return true;
	}
	if(srchcrt == "more")
	{
		if(CompareMinMax(null) === false)
		{
			return false;
		}
		setAllToCookie("sqft");
		setAllToCookie("listdate");
		setAllToCookie("county");
		funCloseAdvanceSearch();		
		return true;
	}	
	
	if((srchcrt == 'price') && (CompareMinMax(srchcrt) === false))
	{
		return false;
	}
	if((srchcrt == 'beds') && (CompareMinMax(srchcrt) === false))
	{
		return false;
	}
	if((srchcrt == 'baths') && (CompareMinMax(srchcrt) === false))
	{
		return false;
	}
	if(srchcrt == 'power')
	{		
		var validate = validatePower();
		if(validate === false)
			return false;

		if($("txtArea") && $("txtArea").value != "")
		{
			setSearchCookie("neighborhood","");
			headerContent("neighborhood");
		}
		setAllToCookie("mlssource");
		setAllToCookie("proptype");
		setAllToCookie("propstatus");
		setAllToCookie("sqftp");
		setAllToCookie("listdatep");
		setAllToCookie("listagent");
		setAllToCookie("lotsize");
		setAllToCookie("age");
		setAllToCookie("yearbuilt");
		setAllToCookie("daysonmarket");
		setAllToCookie("garage");
		setAllToCookie("stories");
		setAllToCookie("eleschool");
		setAllToCookie("midschool");
		setAllToCookie("highschool");
		setAllToCookie("saledate");
		setAllToCookie("saleprice");
		setAllToCookie("saleagent");
		setAllToCookie("area");
		setAllToCookie("polygon");
		setAllToCookie("powerradial");
		setAllToCookie("listagtid");
		setAllToCookie("listoff");
		setAllToCookie("saleagtid");
		setAllToCookie("saleoff");
		setAllToCookie("fire");
		setAllToCookie("pool");
		setAllToCookie("roof");
		funCloseAdvanceSearch();
		return true;
	}

	setAllToCookie(srchcrt);
	headerContent(srchcrt);
	funCloseAdvanceSearch();	
	return true;
}

function validatePower()
{
	/* Prop Type */
	if(chooseChecked('divPType',true) == '')
	{
		alert("Please select atleast one property type");
		return false;
	}

	/* Prop Status */
	if(chooseChecked('divPStatus',true) == '')
	{
		alert("Please select atleast one property status");
		return false;
	}

	/* Sales Price */
	var minSalesP = Number(money2num($('txtSalePriceFrom').value));	
	var maxSalesP = Number(money2num($('txtSalePriceTo').value));	
	if(minSalesP<0 || maxSalesP<0)
	{
		alert("Please enter valid price range");
		$('txtSalePriceFrom').value = '';
		$('txtSalePriceTo').value = '';
		return false;
	}
	if((minSalesP>maxSalesP) && (minSalesP != "" && maxSalesP != ""))
	{
		alert("Please enter valid price range");
		$('txtSalePriceFrom').value = '';
		$('txtSalePriceTo').value = '';
		return false;
	}
	 
	/* Sqft */
	/*var sqftMin = Number($("minPSize").value);
	var sqftMax = Number($("maxPSize").value);
	if(sqftMin>sqftMax && sqftMax != 0)
	{
		alert("Please enter valid range for square feet");
		$("minPSize").selectedIndex=0;
		$("maxPSize").selectedIndex=0;
		return false;
	}*/

	var sqftMin = Number($F('minPSize'));
	var sqftMax = Number($F('maxPSize'));
	if(isNaN(sqftMin))
	{
		alert("Please enter numerical values only for min sqft.");
		$('minPSize').value = '';
		$('minPSize').focus();
		return false;
	}

	if(isNaN(sqftMax))
	{
		alert("Please enter numerical values only for max sqft.");
		$('maxPSize').value = '';
		$('maxPSize').focus();
		return false;
	}

	if(sqftMin<0 || sqftMax<0)
	{
		alert("Please enter valid square feet range.");
		$('minPSize').value = '';
		$('maxPSize').value = '';
		$('minPSize').focus();
		return false;
	}

	if(sqftMin>sqftMax && (sqftMin != "" && sqftMax != ""))
	{
		alert("Please enter valid square feet range.");
		//$("minPSize").value='';
		//$("maxPSize").value='';
		return false;
	}
	
	/* Lot Sqft */
	/*var sqftLotMin = Number($("minLotSize").value);
	var sqftLotMax = Number($("maxLotSize").value);
	if(sqftLotMin>sqftLotMax && sqftLotMax != 0)
	{
		alert("Please enter valid range for lot size");
		$("minLotSize").selectedIndex=0;
		$("maxLotSize").selectedIndex=0;
		return false;
	}*/
	var sqftLotMin = Number($F('minLotSize'));
	var sqftLotMax = Number($F('maxLotSize'));
	if(isNaN(sqftLotMin))
	{
		alert("Please enter numerical values only for min lot size.");
		$('minLotSize').value = '';
		$('minLotSize').focus();
		return false;
	}

	if(isNaN(sqftLotMax))
	{
		alert("Please enter numerical values only for max lot size.");		
		$('maxLotSize').value = '';
		$('maxLotSize').focus();
		return false;
	}

	if(sqftLotMin<0 || sqftLotMax<0)
	{
		alert("Please enter valid lot size range.");
		$('minLotSize').value = '';
		$('maxLotSize').value = '';
		$('minLotSize').focus();
		return false;
	}

	if(sqftLotMin>sqftLotMax && (sqftLotMin != "" && sqftLotMax != ""))
	{
		alert("Please enter valid lot size range.");
		//$("minLotSize").value='';
		//$("maxLotSize").value='';
		return false;
	}

	/* List Date */
	if($("txtPLFDate").value != "")
	{
		if(!validDate("txtPLFDate","Please select from list date less than current date"))
			return false;
	}

	if($("txtPLTDate").value != "")
	{
		if(!validDate("txtPLTDate","Please select to list date less than current date"))
			return false;
	}

	if(trim($("txtPLFDate").value) != "" && trim($("txtPLTDate").value) != "")
	{
		var valLFDate = $("txtPLFDate").value;
		var arrLFDate = valLFDate.split("-");		
		var objLFDate = new Date();
		objLFDate.setYear(arrLFDate[2]);
		objLFDate.setMonth(arrLFDate[0]);
		objLFDate.setDate(arrLFDate[1]);
		var tsLFDate = objLFDate.getTime()
		var valLTDate = $("txtPLTDate").value;
		var arrLTDate = valLTDate.split("-");		
		var objLTDate = new Date();
		objLTDate.setYear(arrLTDate[2]);
		objLTDate.setMonth(arrLTDate[0]);
		objLTDate.setDate(arrLTDate[1]);
		var tsLTDate = objLTDate.getTime()
		if(tsLFDate > tsLTDate)
		{
			alert("To date should not be less than From date.");
			$('txtPLFDate').value = '';
			$('txtPLTDate').value = '';
			return false;
		}
	}
	
	/* Sale Date */
	if($("txtSFDate").value != "")
	{
		if(!validDate("txtSFDate","Please select from sale date less than current date"))
			return false;
	}

	if($("txtSTDate").value != "")
	{
		if(!validDate("txtSTDate","Please select to sale date less than current date"))
			return false;
	}
	if(trim($("txtSFDate").value) != "" && trim($("txtSTDate").value) != "")
	{
		var valLFDate = $("txtSFDate").value;
		var arrLFDate = valLFDate.split("-");		
		var objLFDate = new Date();
		objLFDate.setYear(arrLFDate[2]);
		objLFDate.setMonth(arrLFDate[0]);
		objLFDate.setDate(arrLFDate[1]);
		var tsLFDate = objLFDate.getTime()
		var valLTDate = $("txtSTDate").value;
		var arrLTDate = valLTDate.split("-");		
		var objLTDate = new Date();
		objLTDate.setYear(arrLTDate[2]);
		objLTDate.setMonth(arrLTDate[0]);
		objLTDate.setDate(arrLTDate[1]);
		var tsLTDate = objLTDate.getTime()
		if(tsLFDate > tsLTDate)
		{
			alert("To date should not be less than From date.");
			$('txtSFDate').value = '';
			$('txtSTDate').value = '';
			return false;
		}
	}
	
	/* Age */
	var minAge = Number($('txtAgeFrom').value);
	var maxAge = Number($('txtAgeTo').value);
	if(isNaN(minAge))
	{
		alert("Please enter numerical values only.");
		$('txtAgeFrom').value = '';
		$('txtAgeTo').value = '';
		return false;
	}
	else if(isNaN(maxAge))
	{
		alert("Please enter numerical values only.");
		$('txtAgeFrom').value = '';
		$('txtAgeTo').value = '';
		return false;
	}
	else if(minAge>maxAge && (minAge != "" && maxAge != ""))
	{
		alert("Please enter valid range for age.");
		//$('txtAgeFrom').value = '';
		//$('txtAgeTo').value = '';
		return false;
	}
	
	/* Year Build */
	var minYr = Number($F('txtYearBuiltFrom'));
	var maxYr = Number($F('txtYearBuiltTo'));
	if(isNaN(minYr))
	{
		alert("Please enter numerical values only.");
		$('txtYearBuiltFrom').value = '';
		$('txtYearBuiltTo').value = '';
		return false;
	}
	else if(isNaN(maxYr))
	{
		alert("Please enter numerical values only.");
		$('txtYearBuiltFrom').value = '';
		$('txtYearBuiltTo').value = '';
		return false;
	}
	else if($F('txtYearBuiltFrom') != '' && $F('txtYearBuiltFrom').length != 4 )
	{
		alert("Please enter 4 digit year value.");
		$('txtYearBuiltFrom').value = '';
		$('txtYearBuiltTo').value = '';
		return false;
	}
	else if($F('txtYearBuiltTo') != '' && $F('txtYearBuiltTo').length != 4)
	{
		alert("Please enter 4 digit year value.");
		$('txtYearBuiltFrom').value = '';
		$('txtYearBuiltTo').value = '';
		return false;
	}
	else if(minYr>maxYr && (minYr != "" && maxYr != ""))
	{
		alert("Please enter valid range for year build.");
		//$('txtYearBuiltFrom').value = '';
		//$('txtYearBuiltTo').value = '';
		return false;
	}
	
	/* Days on Market */
	var minMkt = Number($F('txtDaysMarketFrom'));
	var maxMkt = Number($F('txtDaysMarketTo'));
	if(isNaN(minMkt))
	{
		alert("Please enter numerical values only.");
		$('txtDaysMarketFrom').value = '';
		$('txtDaysMarketTo').value = '';
		return false;
	}
	else if(isNaN(maxMkt))
	{
		alert("Please enter numerical values only.");
		$('txtDaysMarketFrom').value = '';
		$('txtDaysMarketTo').value = '';
		return false;
	}
	else if(minMkt>maxMkt && (minMkt != "" && maxMkt != ""))
	{
		alert("Please enter valid range for days on market.");
		//$('txtDaysMarketFrom').value = '';
		//$('txtDaysMarketTo').value = '';
		return false;
	}
	
	/* Stories */
	var stories = Number($F('txtStories'));
	if(isNaN(stories))
	{
		alert("Please enter numerical values only.");
		$('txtStories').value = '';
		return false;
	}
	
	/* Listing Agt Id*/
	if($("txtListAgtId").value != "")
	{
		var listAgtId = trim($("txtListAgtId").value);
		var tstRegex = /^([a-zA-Z0-9_-]+)$/;
		if(!tstRegex.test(listAgtId))
		{
			alert("Listing Agent Id should not contain special characters.");
		    $('txtListAgtId').value = '';
		    return false;
		}
	}

	/* Selling Agt Id*/
	if($("txtSaleAgtId").value != "")
	{
		var saleAgtId = trim($("txtSaleAgtId").value);
		var tstRegex = /^([a-zA-Z0-9_-]+)$/;
		if(!tstRegex.test(saleAgtId))
		{
			alert("Selling Agent Id should not contain special characters.");		    
		    $('txtSaleAgtId').value = '';
		    return false;
		}
	}
	
	return true;
}

function funGoAdvanceSearch(srchcrt,page)
{
	if(srchcrt == "multicity")
	{
		var boolAllCityBlank = true;
		for(var i=0;i<20;i++)
		{
			var idTxtObj = 'searchCSZ'+ eval(i+1);
			if(trim($(idTxtObj).value) != "")
			{
				boolAllCityBlank = false;
				break;
			}
		}
		if (boolAllCityBlank == true)
		{
			alert("Please specify either City & State or Zip for atleast one.");
			return;
		}
	}	
	var boolSaveAdvanceSearch = funSaveAdvanceSearch(srchcrt,page);
	if(boolSaveAdvanceSearch == true)
	{
		if($('chkmapSearchSelect') != null && $('chkmapSearchSelect').checked == true && typeof(reloadDragZoomAll) != 'undefined') 
		{
			reloadDragZoomAll();
		}
		else
		{
			explore(page);
		}	
	}	
}
function funGetNeighborHood(srchcrt,page)
{
	var cbfnGetNeighborHood = function(reqObj)
	{
		var response = reqObj.responseText;
		if(response.toString() != 'null')
		{
			arrDataNeighborHood = eval(response);
			if(arrDataNeighborHood.length > 0)
			{
				$('divPopUpSHNeighborHood').style.height = "150px";
				var strCKNH = getSearchCookie("neighborhood");
				var arrCKNH = strCKNH.split(',');
				var ihNeighborHood = new StringBuffer();
				var lenArrDataNeighborHood = arrDataNeighborHood.length;
				ihNeighborHood.append('<table cellpadding="0" cellspacing="0" style="width:250px; height:100%;" border="0">');
					ihNeighborHood.append('<tr>'); 
						ihNeighborHood.append('<td style="width:10%;">'); 
							ihNeighborHood.append('<input type="checkbox" value=""  id="chbSHNHAll" name="chbSHNHAll" onclick="javscript:funSetSHNHAll();"/>');
						ihNeighborHood.append('</td>'); 
						ihNeighborHood.append('<td style="width:80%;">'); 
							ihNeighborHood.append('<span class="contentSHPopup lang">all</span>');
						ihNeighborHood.append('</td>'); 
					ihNeighborHood.append('</tr>'); 
				for(var i=0;i<lenArrDataNeighborHood;i++)
				{
					if(typeof(arrDataNeighborHood[i]['neighborhood']) != "undefined" && trim(arrDataNeighborHood[i]['neighborhood'])!="")
					{
						ihNeighborHood.append('<tr>'); 
							ihNeighborHood.append('<td style="width:10%;">'); 
								if((arrCKNH.in_array(arrDataNeighborHood[i]['neighborhood']) !== false) || (trim(strCKNH) == 'all'))
								{
									ihNeighborHood.append('<input type="checkbox" value="'+arrDataNeighborHood[i]['neighborhood']+'" onclick="javascript:funUnchkAllChkBox(this);" checked="checked" />');
								}
								else
								{
									ihNeighborHood.append('<input type="checkbox" value="'+arrDataNeighborHood[i]['neighborhood']+'" onclick="javascript:funUnchkAllChkBox(this);" />');
								}	
							ihNeighborHood.append('</td>'); 
							ihNeighborHood.append('<td style="width:80%;">'); 
								ihNeighborHood.append('<span class="contentSHPopup lang">'+arrDataNeighborHood[i]['neighborhood']+'</span>');
							ihNeighborHood.append('</td>'); 
						ihNeighborHood.append('</tr>'); 
					}
					else if(typeof(arrDataNeighborHood[i]['area']) != "undefined" && trim(arrDataNeighborHood[i]['area'])!="")
					{
						ihNeighborHood.append('<tr>'); 
							ihNeighborHood.append('<td style="width:10%;">'); 
								if((arrCKNH.in_array(arrDataNeighborHood[i]['area']) !== false) || (trim(strCKNH) == 'all'))
								{
									ihNeighborHood.append('<input type="checkbox" value="'+arrDataNeighborHood[i]['area']+'" onclick="javascript:funUnchkAllChkBox(this);" checked="checked" />');
								}
								else
								{
									ihNeighborHood.append('<input type="checkbox" value="'+arrDataNeighborHood[i]['area']+'" onclick="javascript:funUnchkAllChkBox(this);" />');
								}	
							ihNeighborHood.append('</td>'); 
							ihNeighborHood.append('<td style="width:80%;">'); 
								ihNeighborHood.append('<span class="contentSHPopup lang">'+arrDataNeighborHood[i]['code']+" - "+arrDataNeighborHood[i]['area']+'</span>');
							ihNeighborHood.append('</td>'); 
						ihNeighborHood.append('</tr>'); 
					}
				}	
				ihNeighborHood.append('</table>');
				$("divSHDataNeighborHood").innerHTML = ihNeighborHood.toString();
				var arrChkBox = $('divSHDataNeighborHood').getElementsByTagName("input");
				var lenArrChkBox = arrChkBox.length;
				var allChked = true;
				for(var i=0;i<lenArrChkBox;i++)
				{
			    	if((arrChkBox[i].id == "chbSHNHAll") || (arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true))
			    	{
			    		continue;
			    	}
					else
					{
						allChked = false;
						break;
					}
				}
				if(allChked == true)
				{
					$("chbSHNHAll").checked = true;
				}
				Element.removeClassName($("divSHNeighborHood").getElementsByTagName('a')[0],'linkAdvanceSearch');
				Element.addClassName($("divSHNeighborHood").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
				$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
				$("divPopUpSHMLSInfo").style.visibility = "visible";
				$("divPopUpSHControls").style.display = "inline";
				$("divPopUpSHNeighborHood").style.display = "inline";
			}
			else
			{
				$('divPopUpSHNeighborHood').style.height = "55px";
				$("divPopUpSHControls").innerHTML = '&nbsp<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';
				$("divSHDataNeighborHood").innerHTML = '<span class="contentSHPopup">Neighborhood information not available for &nbsp;\"' + getSearchCookie("city") + ', ' + getSearchCookie("state") + '\".</span>';
				$("divPopUpSHMLSInfo").style.visibility = "hidden";
				$("divPopUpSHControls").style.display = "inline";
				$("divPopUpSHNeighborHood").style.display = "inline";
				headerContent("county");
			}
		}
		else
		{
			$('divPopUpSHNeighborHood').style.height = "50px";
			$("divPopUpSHControls").innerHTML = '&nbsp<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';
			$("divSHDataNeighborHood").innerHTML = '<span class="contentSHPopup">Neighborhood information for \"' + getSearchCookie("city") + '", ' + getSearchCookie("state") + '\" is coming soon.</span>';
			$("divPopUpSHMLSInfo").style.visibility = "hidden";
			$("divPopUpSHControls").style.display = "inline";
			$("divPopUpSHNeighborHood").style.display = "inline";
			headerContent("county");
		}		
	}
	var url = "../../getCountyNeighborHood.php";
	var qs = "getDataNeighborHood=1&city="+getSearchCookie('city')+"&state="+getSearchCookie("state")+"&zip="+getSearchCookie("zip");

	if($("mlsSource"))
		qs +="&ds="+$F("mlsSource");
	else if(getSearchCookie('mlsSource'))
		qs +="&ds="+escape(getSearchCookie('mlsSource'));

	$("divSHDataNeighborHood").innerHTML = "";
	ajaxRequest(url,qs,cbfnGetNeighborHood);
}
function funGetCounty(srchcrt,page)
{
	var cbfnGetCounty = function(reqObj)
	{
		var response = reqObj.responseText;
		if(response.toString() != 'null')
		{
			arrDataCounty = eval(trim(response));
			if(arrDataCounty.length > 0)
			{
				var strCKCounty = getSearchCookie("county");
				var arrCKCounty = strCKCounty.split(',');
				var ihCounty = new StringBuffer();
				var lenArrDataCounty = arrDataCounty.length;
				ihCounty.append('<table cellpadding="0" cellspacing="0" style="width:320px;*width:100%;height:100%;">');
				for(var i=0;i<lenArrDataCounty;i++)
				{
					var countyName = arrDataCounty[i]['county'];
					ihCounty.append('<tr>'); 
						ihCounty.append('<td style="width:6%;">'); 
							if(arrCKCounty.in_array(countyName) !== false)
							{
								ihCounty.append('<input type="checkbox" value="'+countyName+'" checked="checked" />');
							}
							else
							{
								ihCounty.append('<input type="checkbox" value="'+countyName+'"  />');
							}	
						ihCounty.append('</td>'); 
						ihCounty.append('<td style="width:94%;">'); 
							ihCounty.append('<span class="contentSHPopup lang">'+countyName+'</span>');
						ihCounty.append('</td>'); 
					ihCounty.append('</tr>'); 
				}	
				ihCounty.append('</table>');
				
				$("divSHDataCounty").innerHTML = ihCounty.toString();
				$("divPopUpSHCounty").style.display = "inline";
			}
			else
			{
				$("divSHDataCounty").innerHTML = '<span class="contentSHPopup">County information for \"' + getSearchCookie("city") + ', ' + getSearchCookie("state") + '\" is coming soon.</span>';
				if(bkTheme == 'realestateone' || bkTheme == 'maxbroock' || bkTheme == 'jensenwhite')
				{
					$("divPopUpSHCounty").style.display = "none";
				}
				else
				{
					$("divPopUpSHCounty").style.display = "inline";
				}
			}
		}
		else
		{
			
			$("divSHDataCounty").innerHTML = '<span class="contentSHPopup">County information for \"' + getSearchCookie("city") + ', ' + getSearchCookie("state") + '\" is coming soon.</span>';
			if(bkTheme == 'realestateone' || bkTheme == 'maxbroock' || bkTheme == 'jensenwhite')
			{
			$("divPopUpSHCounty").style.display = "none";
			}
			else
			{
				$("divPopUpSHCounty").style.display = "inline";
			}
		}
	}
	if ($('searchCSZ').value.search(/;/) > -1)
	{
		$("divSHDataCounty").innerHTML = '<span class="contentSHPopup">Please select single city to enable county search.</span>';
		$("divPopUpSHCounty").style.display = "inline";
		return;
	}
	var isContradict = funCheckContradict();
	if((isContradict != null) && (isContradict != 0))
	{
		var url = "../../getCountyNeighborHood.php";
		var qs = "getDataCounty=1&city="+getSearchCookie('city')+"&state="+getSearchCookie("state")+"&zip="+getSearchCookie("zip");
		$("divSHDataCounty").innerHTML = "";
		ajaxRequest(url,qs,cbfnGetCounty);
	}
	else
	{
		return;
	}	
}

function funShowMultiCity()
{
	if($('divPopUpMultiCity') == null)
	{
		var ihMultiCity = new StringBuffer();
		ihMultiCity.append('<table align="center" style="border:3px double #192046;display:block;position:relative;border-collapse: separate;border-spacing: 3px;width:100%;*width:93%;" >');
		ihMultiCity.append('<tr>');
		ihMultiCity.append('<td valign="middle" >');
		ihMultiCity.append('<div id="divDataMultiCity" name="divDataMultiCity" style="width:290px;height:270px;position:relative;float:left;display:inline;vertical-align:middle;overflow:auto" align="left">');
			ihMultiCity.append('<table  id="multiCTFirst" align="center" border="0" width="100%" style="display:block;position:relative;border-collapse: separate;border-spacing: 3px;" >');
				ihMultiCity.append('<tr>');
					ihMultiCity.append('<td align="left" colspan="2">');
						ihMultiCity.append('<span id="multiErr"></span>');
					ihMultiCity.append('</td>');													
				ihMultiCity.append('</tr>');
				ihMultiCity.append('<tr>');
					ihMultiCity.append('<td align="left" colspan="2">');
						ihMultiCity.append('<span class="contentSHPopupNew lang" align="left">City, State</span>');
					ihMultiCity.append('</td>');													
				ihMultiCity.append('</tr>');
			ihMultiCity.append('</table>');									
		ihMultiCity.append('</div>');
		ihMultiCity.append('</td>');													
		ihMultiCity.append('</tr>');
		
		ihMultiCity.append('<tr>');
					ihMultiCity.append('<td align="right" colspan="2" width="100%" class="borderTop">');
						ihMultiCity.append('<a href="javascript:gotoSingPropMulti();" class="linkOkCancleSH">Go</a>&nbsp;&nbsp;');
						ihMultiCity.append('<a href="javascript:clearMulti();" class="linkOkCancleSH">Clear All</a>&nbsp;&nbsp;');
						ihMultiCity.append('<a href="javascript:closePopUpMultiCity();" class="linkOkCancleSH">Close</a>&nbsp;');
					ihMultiCity.append('</td>');													
				ihMultiCity.append('</tr>');
		ihMultiCity.append('</table><input type="hidden" id="lat"><input type="hidden" id="longi">');									
		
		var myDiv = document.createElement('div');
		myDiv.id = "divPopUpMultiCity";
		myDiv.name = "divPopUpMultiCity";
		myDiv.style.display = "none";
		myDiv.style.position = "absolute";
		myDiv.className = "divContainerAdvannceSearchMulti";
		if(isIE)
		{
			myDiv.style.width = "290px";
			myDiv.style.styleFloat = "left";
		}
		else
		{
			myDiv.style.width = "290px";
			myDiv.style.cssFloat = "left";
		}
		myDiv.style.height = "300px";
		myDiv.innerHTML = ihMultiCity.toString();
		document.body.appendChild(myDiv);
	}
	return $('divPopUpMultiCity');
}

function clearMulti()
{
	if(isIE)
	{
		var tbl = document.getElementById('multiCTFirst');
		var lastRow = tbl.rows.length;
		while(lastRow != 2)
		{
			tbl.deleteRow(lastRow-1);
			lastRow--;
		}
	}
	else
	{
		ihMultiCity = "";
		ihMultiCity += '<tr>';
			ihMultiCity += '<td align="left" colspan="2">';
				ihMultiCity += '<span id="multiErr"></span>';
			ihMultiCity += '</td>';													
		ihMultiCity += '</tr>';
		ihMultiCity += '<tr>';
			ihMultiCity += '<td align="left" colspan="2">';
				ihMultiCity += '<span class="contentSHPopupNew lang" align="left">City, State</span>';
			ihMultiCity += '</td>';													
		ihMultiCity += '</tr>';
		if($("multiCTFirst"))
			$("multiCTFirst").innerHTML = ihMultiCity;
	}
	
	cityList = new Hash();
}

function closePopUpMultiCity()
{
	$('divPopUpMultiCity').style.display = "none";
}

function gotoSingPropMulti()
{
	var lat = "";
	var lng = "";
	lat = $("lat").value;
	lng = $("longi").value;
	//alert(2 +" "+lat+","+lng);
	var state="";
	var city="";
	if(bkTheme=="lmsre")
	{
		var typeIncookie = "";
		typeInCookie = getSearchCookie("searchType");
		if(typeInCookie=="'non mls'")
			setSearchCookie("searchType","");
	}
	var cityLst = $('multiCTFirst').getElementsByTagName("input");
	for(i=0;i<=cityLst.length;i++)
	{
		if($(cityLst[i]) && $(cityLst[i]).value!="")
		{
			var arrCityState = (trim($(cityLst[i]).value)).split(",");
			city += trim(arrCityState[0]) + "|";
			state += trim(arrCityState[1]) + "|";
		}	
	}
	if(city.length==0)
	{
		alert("Please select atleast one city");
		return;
	}
	city = city.substring(0,city.length-1);
	state = state.substring(0,state.length-1);
	listAllCity = city;
	var zip="";	var page=""; var action="start";var otherArgs="";

	
	page=bkTheme.toUpperCase();
		
	getGeoAdd(lat,lng,city,state,zip,page,action,otherArgs)
}

var arrDataCounty = new Array();
var arrDataNeighborHood = new Array();
function funShowAdvanceSearch(srchcrt,page,e)
{	
	funCloseAdvanceSearch();
	if($("divContainerAdvannceSearch"))
		$("divContainerAdvannceSearch").style.display="";
	if($("divPopUpSHPower"))
		$("divPopUpSHPower").style.display="";	

	$("divContainerAdvanceSearch").style.width = "290px";
	switch(srchcrt)
	{
		case "multicity":
			$("divContainerAdvanceSearch").style.width = "250px";
			Element.removeClassName($("divSHMultiCity").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHMultiCity").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divPopUpSHMultiCity").style.display = "inline";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
			break;
		case "more":
			setAllCookieValue('sqft');
     		setAllCookieValue('listdate');
			$("divContainerAdvanceSearch").style.width = "400px";
			$("divPopUpSHSqft").style.display = "inline";
			$("divPopUpSHListDate").style.display = "inline";
			
			//for property styles
			if($("divPopUpSHPropStyle"))
			{
				var arrChkBox = $('propStyleDv').getElementsByTagName("input");
				var lenArrChkBox = arrChkBox.length;
				var allChked = true;
				var strChkBox = getSearchCookie("propStyle");

				if(strChkBox == "" || strChkBox == null)
				{
					for(var i=0;i<lenArrChkBox;i++)
					{
				    	if(arrChkBox[i].id == "chkStyleAll")
				    	{
				    		continue;
				    	}
		    			if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == false)
		    			{
		    				arrChkBox[i].checked = true;
		    			}
					}
				}
				else
				{
					var arrStrChkBox = strChkBox.split(":");
					for(var i=0;i<lenArrChkBox;i++)
					{
						if (arrChkBox[i].id == "chkStyleAll")
						{
							continue;
						}
						if(arrChkBox[i].type == "checkbox")
						{
							var valChkBox = arrChkBox[i].value;
		    				if(arrStrChkBox.in_array(valChkBox) !== false)
		    				{
		    					arrChkBox[i].checked = true;
		    				}
							else
							{
								allChked = false;
								arrChkBox[i].checked = false;
							}
						}						
					}
				}

				if(allChked == true)
				{
					$("chkStyleAll").checked = true;
				}
				else
				{
					var confAllChked = true;
					for(var i=0;i<lenArrChkBox;i++)
					{
						if (arrChkBox[i].id == "chkStyleAll")
						{
							continue;
						}
						if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
						{
							confAllChked = false;
							break;
						}
					}
					
					if(confAllChked == true)
					{
						for(var i=0;i<lenArrChkBox;i++)
						{
							if(arrChkBox[i].type == "checkbox")
								arrChkBox[i].checked = true;
						}
					}
					else
						$("chkStyleAll").checked = false;
				}
				$("divPopUpSHPropStyle").style.display = "inline";
			}

			//for parking styles
			if($("divPopUpSHGarage"))
			{
				setAllCookieValue("garage");
				/*var arrChkBox = $('parkingStyleDv').getElementsByTagName("input");
				var lenArrChkBox = arrChkBox.length;
				var allChked = true;
				for(var i=0;i<lenArrChkBox;i++)
				{
					if (arrChkBox[i].id == "chkParkingStyleAll")
					{
						continue;
					}
					if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
					{
						continue;
					}
					else
					{
						allChked = false;
						break;
					}
				}
				if(allChked == true)
				{
					$("chkParkingStyleAll").checked = true;
				}
				else
				{
					$("chkParkingStyleAll").checked = false;
				}*/
				$("divPopUpSHGarage").style.display = "inline";
			}

			$("divPopUpSHMLSInfo").style.visibility = "hidden";
			$('searchCSZ').value = $('searchCSZ').value.replace (/^\s+/g, '').replace (/\s+$/g, '').replace (/\s+/g, ' ');
			if(countySearchEnabled == 1)
			{
				if((trim($('searchCSZ').value) == "")||(trim($('searchCSZ').value).toLowerCase () == "required"))
				{
					var ihCounty = "";
					ihCounty = ihCounty + '<a href="javascript:void(0);" onclick="javascript:funGetCounty(\'county\',\''+page+'\');" class="linkOkCancleSH lang">Get County Information</a>'; 
					$("divSHDataCounty").innerHTML = ihCounty;
					$("divPopUpSHCounty").style.display = "inline";
				}
				else
				{
					var isCompare = funCompareSearchCookie();
					if(isCompare === 1)
					{
						var ihCounty = "";
						ihCounty = ihCounty + '<a href="javascript:void(0);" onclick="javascript:funGetCounty(\'county\',\''+page+'\');" class="linkOkCancleSH lang">Get County Information</a>'; 
						$("divSHDataCounty").innerHTML = ihCounty;
						$("divPopUpSHCounty").style.display = "inline";
					}
					else
					{
						if(arrDataCounty.length == 0)
						{
							funGetCounty(srchcrt,page);
						}
						else
						{
							var strCKCounty = getSearchCookie("county");
							var arrCKCounty = strCKCounty.split(',');
							var ihCounty = "";
							var lenArrDataCounty = arrDataCounty.length;
							ihCounty = ihCounty + '<table cellpadding="0" cellspacing="0" style="width:100%;height:100%;">';
							for(var i=0;i<lenArrDataCounty;i++)
							{
								var countyName = arrDataCounty[i]['county'];
								ihCounty = ihCounty + '<tr>'; 
									ihCounty = ihCounty + '<td style="width:20%;">'; 
										if(arrCKCounty.in_array(countyName) !== false)
										{
											ihCounty = ihCounty + '<input type="checkbox" value="'+countyName+'" checked="checked" />';
										}
										else
										{
											ihCounty = ihCounty + '<input type="checkbox" value="'+countyName+'"  />';
										}	
									ihCounty = ihCounty + '</td>'; 
									ihCounty = ihCounty + '<td style="width:80%;">'; 
										ihCounty = ihCounty + '<span class="contentSHPopup lang">'+countyName+'</span>';
									ihCounty = ihCounty + '</td>'; 
								ihCounty = ihCounty + '</tr>'; 
							}	
							ihCounty = ihCounty + '</table>';
							
							$("divSHDataCounty").innerHTML = ihCounty;
							$("divPopUpSHCounty").style.display = "inline";
						}
					}
				}
			}
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "county":
			var isContradict = funCheckContradict();
			if(isContradict == null || isContradict == 0)
			{
				return;
			}
			if(arrDataCounty.length == 0)
			{
				funGetCounty(srchcrt,page);
			}
			else
			{
				var strCKCounty = getSearchCookie("county");
				var arrCKCounty = strCKCounty.split(',');
				var ihCounty = "";
				var lenArrDataCounty = arrDataCounty.length;
				ihCounty = ihCounty + '<table cellpadding="0" cellspacing="0" style="width:100%;height:100%;">';
				for(var i=0;i<lenArrDataCounty;i++)
				{
					var countyName = arrDataCounty[i]['county'];
					ihCounty = ihCounty + '<tr>'; 
						ihCounty = ihCounty + '<td style="width:20%;">'; 
							if(arrCKCounty.in_array(countyName) !== false)
							{
								ihCounty = ihCounty + '<input type="checkbox" value="'+countyName+'" checked="checked" />';
							}
							else
							{
								ihCounty = ihCounty + '<input type="checkbox" value="'+countyName+'"  />';
							}	
						ihCounty = ihCounty + '</td>'; 
						ihCounty = ihCounty + '<td style="width:80%;">'; 
							ihCounty = ihCounty + '<span class="contentSHPopup lang">'+countyName+'</span>';
						ihCounty = ihCounty + '</td>'; 
					ihCounty = ihCounty + '</tr>'; 
				}	
				ihCounty = ihCounty + '</table>';
				
				$("divSHDataCounty").innerHTML = ihCounty;
				Element.removeClassName($("divSHCounty").getElementsByTagName('a')[0],'linkAdvanceSearch');
				Element.addClassName($("divSHCounty").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
				$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
				$("divPopUpSHControls").style.display = "inline";
				$("divPopUpSHMLSInfo").style.visibility = "visible";
				$("divPopUpSHCounty").style.display = "inline";
			}
			break;
		case "neighborhood":
			if ($('searchCSZ').value.search(/;/) > -1)
			{
				$('divPopUpSHNeighborHood').style.height = "50px";
				$("divPopUpSHControls").innerHTML = '&nbsp<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';
				$("divSHDataNeighborHood").innerHTML = '<span class="contentSHPopup">Please select single city to enable neighborhood search.</span>';
				$("divPopUpSHMLSInfo").style.visibility = "hidden";
				$("divPopUpSHControls").style.display = "inline";
				$("divPopUpSHNeighborHood").style.display = "inline";
				headerContent("neighborhood");
				break;
			}
			if($('chkmapSearchSelect') != null && $('chkmapSearchSelect').checked == true) 			
			{
				$('divPopUpSHNeighborHood').style.height = "50px";
				$("divPopUpSHControls").innerHTML = '&nbsp<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';
				$("divSHDataNeighborHood").innerHTML = '<span class="contentSHPopup">Please disable Map Search to enable neighborhood search.</span>';
				$("divPopUpSHMLSInfo").style.visibility = "hidden";
				$("divPopUpSHControls").style.display = "inline";
				$("divPopUpSHNeighborHood").style.display = "inline";
				headerContent("neighborhood");
				break;
			}
			if(trim(getSearchCookie("county")) != "" && countySearchEnabled == "1")	
			{
				$('divPopUpSHNeighborHood').style.height = "50px";
				$("divPopUpSHControls").innerHTML = '&nbsp<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';
				$("divSHDataNeighborHood").innerHTML = '<span class="contentSHPopup">Please deselect county to enable neighborhood search.</span>';
				$("divPopUpSHMLSInfo").style.visibility = "hidden";
				$("divPopUpSHControls").style.display = "inline";
				$("divPopUpSHNeighborHood").style.display = "inline";
				headerContent("neighborhood");
				break;
			}
			if($("txtArea") && $("txtArea").value != "")
			{
				$('divPopUpSHNeighborHood').style.height = "50px";
				$("divPopUpSHControls").innerHTML = '&nbsp<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';
				$("divSHDataNeighborHood").innerHTML = '<span class="contentSHPopup">Please disable Area Search to enable neighborhood search.</span>';
				$("divPopUpSHMLSInfo").style.visibility = "hidden";
				$("divPopUpSHControls").style.display = "inline";
				$("divPopUpSHNeighborHood").style.display = "inline";
				headerContent("neighborhood");
				break;
			}
			
			var isContradict = funCheckContradict();
			if(isContradict == null || isContradict == 0)  
			{
				return;
			}
			if(arrDataNeighborHood.length == 0)
			{
				funGetNeighborHood(srchcrt,page);
			}
			else
			{
				$('divPopUpSHNeighborHood').style.height = "150px";
				var strCKNH = getSearchCookie("neighborhood");
				var arrCKNH = strCKNH.split(',');
				var ihNeighborHood = new StringBuffer();
				var lenArrDataNeighborHood= arrDataNeighborHood.length;
				ihNeighborHood.append('<table cellpadding="0" cellspacing="0" style="width:250px; height:100%;" border="0">');
					ihNeighborHood.append('<tr>'); 
						ihNeighborHood.append('<td style="width:30px;">'); 
							ihNeighborHood.append('<input type="checkbox" value=""  id="chbSHNHAll" name="chbSHNHAll" onclick="javscript:funSetSHNHAll();"/>');
						ihNeighborHood.append('</td>'); 
						ihNeighborHood.append('<td style="width:220px;">'); 
							ihNeighborHood.append('<span class="contentSHPopup lang">all</span>');
						ihNeighborHood.append('</td>'); 
					ihNeighborHood.append('</tr>'); 
				for(var i=0;i<lenArrDataNeighborHood;i++)
				{
					ihNeighborHood.append('<tr>'); 
						ihNeighborHood.append('<td style="width:30px;">'); 
							if(typeof(arrDataNeighborHood[i]['neighborhood']) != "undefined")
							{
								if((arrCKNH.in_array(arrDataNeighborHood[i]['neighborhood']) !== false) || (trim(strCKNH) == 'all'))
								{
									ihNeighborHood.append('<input type="checkbox" value="'+arrDataNeighborHood[i]['neighborhood']+'" onclick="javascript:funUnchkAllChkBox(this);" checked="checked" />');
								}
								else
								{
									ihNeighborHood.append('<input type="checkbox" value="'+arrDataNeighborHood[i]['neighborhood']+'" onclick="javascript:funUnchkAllChkBox(this);" />');
								}	
							}
							else if(typeof(arrDataNeighborHood[i]['area']) != "undefined")
							{
								if((arrCKNH.in_array(arrDataNeighborHood[i]['area']) !== false) || (trim(strCKNH) == 'all'))
								{
									ihNeighborHood.append('<input type="checkbox" value="'+arrDataNeighborHood[i]['area']+'" onclick="javascript:funUnchkAllChkBox(this);" checked="checked" />');
								}
								else
								{
									ihNeighborHood.append('<input type="checkbox" value="'+arrDataNeighborHood[i]['area']+'" onclick="javascript:funUnchkAllChkBox(this);" />');
								}
							}
						ihNeighborHood.append('</td>');
						ihNeighborHood.append('<td style="width:220px;">');
							if(typeof(arrDataNeighborHood[i]['neighborhood']) != "undefined")
								ihNeighborHood.append('<span class="contentSHPopup lang">'+arrDataNeighborHood[i]['neighborhood']+'</span>');
							else if(typeof(arrDataNeighborHood[i]['area']) != "undefined")
								ihNeighborHood.append('<span class="contentSHPopup lang">'+arrDataNeighborHood[i]['code']+" - "+arrDataNeighborHood[i]['area']+'</span>');
						ihNeighborHood.append('</td>'); 
					ihNeighborHood.append('</tr>'); 
				}	
				ihNeighborHood.append('</table>');
				$("divSHDataNeighborHood").innerHTML = ihNeighborHood.toString();
				var arrChkBox = $('divSHDataNeighborHood').getElementsByTagName("input");
				var lenArrChkBox = arrChkBox.length;
				var allChked = true;
				for(var i=0;i<lenArrChkBox;i++)
				{
			    	if((arrChkBox[i].id == "chbSHNHAll") || (arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true))
			    	{
			    		continue;
			    	}
					else
					{
						allChked = false;
						break;
					}
				}
				if(allChked == true)
				{
					$("chbSHNHAll").checked = true;
				}
				Element.removeClassName($("divSHNeighborHood").getElementsByTagName('a')[0],'linkAdvanceSearch');
				Element.addClassName($("divSHNeighborHood").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
				$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
				$("divPopUpSHMLSInfo").style.visibility = "visible";
				$("divPopUpSHControls").style.display = "inline";
				$("divPopUpSHNeighborHood").style.display = "inline";
			}
			break;
		case "price":
			Element.removeClassName($("divSHPrice").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHPrice").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divPopUpSHPrice").style.display = "inline";
			if($("minPrice") && getSearchCookie("minPrice")!='0' && getSearchCookie("minPrice")!='') $("minPrice").value = addCommas(getSearchCookie("minPrice"));
			if($("maxPrice") && getSearchCookie("maxPrice")!='0' && getSearchCookie("maxPrice")!='') $("maxPrice").value = addCommas(getSearchCookie("maxPrice"));
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "beds":
			setAllCookieValue('beds');
			Element.removeClassName($("divSHBeds").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHBeds").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divPopUpSHBeds").style.display = "inline";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "baths":
			setAllCookieValue('baths');
			Element.removeClassName($("divSHBaths").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHBaths").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divPopUpSHBaths").style.display = "inline";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "sqft":
			Element.removeClassName($("divSHSqft").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHSqft").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divPopUpSHSqft").style.display = "inline";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "listdate":
			Element.removeClassName($("divSHListDate").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHListDate").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divPopUpSHListDate").style.display = "inline";
			$("divPopUpSHMLSInfo").style.visibility = "visible";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "type":
			var arrChkBox = $('divPopUpSHType').getElementsByTagName("input");
			var lenArrChkBox = arrChkBox.length;
			var allChked = true;
			for(var i=0;i<lenArrChkBox;i++)
			{
				if (arrChkBox[i].id == "chbSHTypeAll")
				{
					continue;
				}
				if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
				{
					continue;
				}
				else
				{
					allChked = false;
					break;
				}
			}
			if(allChked == true)
			{
				$("chbSHTypeAll").checked = true;
			}
			else
			{
				$("chbSHTypeAll").checked = false;
			}

			Element.removeClassName($("divSHType").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHType").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divPopUpSHType").style.display = "inline";
			$("divPopUpSHMLSInfo").style.visibility = "visible";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "mls":
			Element.removeClassName($("divSHMLS").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHMLS").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			if(trim(getSearchCookie('mlsno')) != "")
			{
				$("searchMLS").value = trim(getSearchCookie('mlsno'));
			}
			else
			{
				$("searchMLS").value = "";
			}
			$("divPopUpSHMLS").style.display = "inline";
			$("divPopUpSHMLSInfo").style.visibility = "visible";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "sortby":
			Element.removeClassName($("divSHSortBy").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHSortBy").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divPopUpSHSortBy").style.display = "inline";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;		
		case "power":
			$("divContainerAdvanceSearch").style.width = "456px";
			if($("divSHPowerSortBy"))
			{
				Element.removeClassName($("divSHPowerSortBy").getElementsByTagName('a')[0],'linkAdvanceSearch');
				Element.addClassName($("divSHPowerSortBy").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			}
			$("divPopUpSHPower").style.display = "inline";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "saveSearch":
			Element.removeClassName($("divSaveSearch").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSaveSearch").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divSaveSearch").style.display = "inline";
			if($("errDivP")) $("errDivP").innerHTML = "";
			if($("txtSrchNm"))
			{
				$("txtSrchNm").value = "";
				$("txtSrchNm").className = 'lang';
			}
			if($("txtClient")) $("txtClient").value = "";
			if($("txtEmails"))
			{
				$("txtEmails").value = "";
				$("txtEmails").className = 'lang';
			}
			break;
		default: 
			return;
	}
	
	var element = Event.element(e);
	var objDiv = element.parentNode;
	var posLeft = getPositionLeft(objDiv);
	if(srchcrt=="power")
		posLeft -=7; 
	var posTop = getPositionTop(objDiv);
	$("divContainerAdvanceSearch").style.left = posLeft + "px";
	$("divContainerAdvanceSearch").style.top = eval(posTop + 15) + "px";
	if(!isIE && srchcrt=="more")	
			$("divContainerAdvanceSearch").style.top = eval(posTop + 9) + "px";
	$("divContainerAdvanceSearch").style.display = "block";
	
}

//====================================================
//LMSRE specific:
//it will check on two pan map..if multicity then give
//alert else allow to go and perform other action
//====================================================
function checkMultiCity()
{
		var cityPipeList = getSearchCookie("city");
		var stateMy = getSearchCookie("state");
		if($("searchCSZ"))
			var csz = $("searchCSZ").value;
		var flag = false;
		if(cityPipeList.indexOf("|") > -1)
		{
			flag=true;
		}
		else
		{
			flag=false;
		}
		return flag;
}
//====================================================
//LMSRE specific:
//called while dragging any bit,and onclik of 
//dashboard tab.
//====================================================
function callMultiCityCheck_Dashboard(fromWhere,bitzName)
{

	var cityPipeList = getSearchCookie("city");
	var csz = $("searchCSZ").value;	
	if(cityPipeList.indexOf("|") > -1  || csz=="required" || csz=="")
	{
		if(fromWhere == 'dashboard')
		{	
			bitzName = "dashboard";
			showPopupDivforMenu(bitzName,'mapit');
		}
		if(fromWhere == 'mapit')
		{
			bitzName = "mapit";
			showPopupDivforMenu(bitzName,'dashboard');
		}
		return false;
	}
	else if(fromWhere == "dashboard")
	{
		var qs = new Querystring();
		var isNoSearch = qs.get('noSearch');
		if(isNoSearch != null && trim(isNoSearch) == 1)
		{
			location.href="../dashboard/dashboardIndex.php?noSearch=1";
		}
		else if (bkTheme == 'reotexashomes') //to load reo bit as default on dashboard of reotexashomes
		{
			var now = new Date();
			now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
			var myObject = new Object();
			myObject.widget1X1="bankowned";
			setCookie("strWidgetCookie",$H(myObject).toJSON(),now);

			location.href="../dashboard/dashboardIndex.php";
		}
		else
		{
			location.href="../dashboard/dashboardIndex.php";
		}
	}
	else if(fromWhere == "mapit")
	{
		callExploreNeighbourhood(); 
	}
}
function callMultiCityCheck_Dashboard_Metro(fromWhere,bitzName)
{
	var cityPipeList = getSearchCookie("city");
	
	if(cityPipeList.indexOf("|") > -1)
	{
		if(fromWhere == "dragbit")
		{
			//DO NOTHING
		}
		else
		{
			if(fromWhere == 'dashboard')
				bitzName = "dashboard";
			showPopupDivforMenu(bitzName,'mapit');
			return false;
		}
	}
	if(fromWhere == "dashboard")
	{
		location.href="../dashboard/dashboardIndex.php";
	}
}
/**
 * Extra useful functions to the standard javascript prototypes.
 * Added By: Pankit Bhanushali
 */
Array.prototype.intersection = function( value ) {

	var result = new Array();
	
	if( typeof value != "object" ) {
		value = new Array(value);
	}
	
    for( var tc = 0; tc<this.length; tc++) {
		for( var vc = 0; vc < value.length; vc++ ) {
	        if( this[tc] == value[vc] ) {
				result.push_back(value[vc]);
			}
		}
    }
    return result;
}
Array.prototype.push_back = function( value ) {
	if( typeof value == "object" && value.length ) {
		for( var count = 0; count < value.length; count++ ) {
			this[this.length] = value[count];
		}
	} else {
		this[this.length] = value;
	}
}

/** code for brokeragent light box to get all office list **/
function getOffice(type)
{
	var queryString="type=off";
	if(type != null)
		queryString="type=offLoc";
	var url="/app/listing/getOffice.php";
	ajaxRequest(url,queryString,officeCallBack);	
}

//Callback for Assign Lead
function officeCallBack(originalResponse)
{
	var responce = originalResponse.responseText;
	
	
	/*****************sanju, this code can u used if company name depends on office location****************************/
	
	/*
	var respArr = responce.split('<!sep!>');
	if(respArr[0] == 'offLoc')
	{
		$('allOfficeLoc').innerHTML = respArr[1];
		if($('radioOffice').checked)
			$('txtOfficeLoc').disabled= false;
		else
			$('txtOfficeLoc').disabled= true;
	}
	else if(respArr[0] == 'offM')
	{
		$('allOffice').innerHTML = respArr[1];
		if($('radioOffice').checked)
			$('txtOffice').disabled= false;
		else
			$('txtOffice').disabled= true;
	}
	else if(respArr[0] == 'off')
	{
		$('allOffice').innerHTML = respArr[1];
		if($('radioOffice').checked)
			$('txtOffice').disabled= false;
		else
			$('txtOffice').disabled= true;
	}
	* 
	********************************************/
	
	/********************sanju, code that will load both company name and office loc simultanously*************************************/
	
	
	$('allOffice').innerHTML = responce;
	if($('radioOffice').checked)
		$('txtOffice').disabled= false;
	else
		$('txtOffice').disabled= true;
	
	
	/***************************************************************/
}

function offLocChanged()
{
	var offLocId = escape($("txtOfficeLoc").options[$("txtOfficeLoc").selectedIndex].value);
	var queryString="olid="+offLocId;
	var url="/app/listing/getOffice.php";
	ajaxRequest(url,queryString,officeCallBack);	
}

function funExploreMlsAddrMap()
{
	showDetail=1;
	latp = latLong.lat;
	lngp = latLong.lng;

	var city = getSearchCookie("city");
	var zip = getSearchCookie("zip");
	var state = getSearchCookie("state");
	var ad = getSearchCookie("searchAddress");	
	/*var mapLoadedBits = getCookie("strMapitCK");
	
	if (mapLoadedBits != "")
	{
		mapLoadedBits = mapLoadedBits + ",mlsaddrsearch";
	}
	else
	{
		mapLoadedBits = "mlsaddrsearch";
	}*/

	if(mapToShow == "")
	{
		setMapItCookie("mlsaddrsearch","add");
		newUrl = "/app/listing/singlePropertyLanding.php?PHPSESSID=&status=EXP&address=" + ad + "," + city + "," + state + "," + zip + ",,,," + latp + "," + lngp;
	}
	else
	{
		setMapItCookie("mlsNHoodMode","add");
		newUrl = "/app/listing/singlePropertyLanding.php?status=N&code=propView=1:::searchAddress="+ad+":::city="+city+":::state="+state+":::zip="+zip+":::neighborhood=:::county=:::minPrice="+getSearchCookie("minPrice")+":::maxPrice="+getSearchCookie("maxPrice")+":::searchBeds="+getSearchCookie("searchBeds")+":::searchBaths="+getSearchCookie("searchBaths")+":::id=355&mapCenter=("+latp+","+lngp+")&valChkMapSearchSelect=1&fe=&f=1&propLatitude="+latp+"&propLongitude="+lngp+"&mapZoom=13";
	}
	var myQs = new Querystring();
	var frm = myQs.get("frm");
	var aid = myQs.get("aid");
	if(frm != null && trim(frm) == 'agt' && aid != null && trim(aid) != "")
	{
		newUrl = newUrl + "&frm=agt&aid="+aid;

		//agentsite statistics
		var beds = getSearchCookie("searchBeds");
		var baths = getSearchCookie("searchBaths");
		var type = getSearchCookie("searchType");
		var minprice = getSearchCookie("minPrice");
		var maxprice = getSearchCookie("maxPrice");

		var url = "../../classes/emailStats.php";
		var qs = "from=search&aid="+aid+"&city="+city+"&type="+type+"&beds="+beds+"&baths="+baths+"&price="+minprice+"-"+maxprice+"&addr="+ad+"&mlsno=";

		ajaxRequest(url,qs);
		//statistics done
	}
	window.location.href = newUrl;
	return;
}

function gotoSellDshbrd(uid)
{
	if (uid != 1)
	{
		var myObject = new Object();
		myObject.widget1X1="recentsales";
		myObject.widget1X2="marketsnapshot";
		myObject.widget1X3="equity";
		myObject.widget2X1="valuehome";
		myObject.widget2X2="";
		myObject.widget2X3="";
		myObject.widget3X1="";
		myObject.widget3X2="";
		myObject.widget3X3="";

		var now = new Date();
		now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
		setCookie("strWidgetCookie",$H(myObject).toJSON(),now);

		location.href = "http://" + location.hostname + "/app/dashboard/dashboardIndex.php";
	}
	else
	{
		var queryStr="widgetsConf=1,1,25|1,2,46|1,3,57|2,1,58|2,2,|2,3,|3,1,|3,2,|3,3,&setUserPref=1";
		var url ="/app/dashboard/dshbrdProcess.php";
		ajaxRequest(url,queryStr,loadDecDash);
	}
}
function loadDecDash(response)
{
	location.href = "http://" + location.hostname + "/app/dashboard/dashboard.php";
}

function gotoDashBrdFoot(call)
{
	if(call == '1' || call == '0' )
		location.href = "http://" + location.hostname + "/terabitzApi/finance/index.php";
	else if(call == 'openhouse')
	{
		setSearchCookie("listType","openHome");		
		setSearchCookie("ohflag","1");		
		url = 	'/Search/'+getSearchCookie("state")+'/'+getSearchCookie("city");
		location.href = url;
	}
	else
	{
		ClrQckSrchCookies();
		location.href = "http://" + location.hostname + "/app/listing/singlePropertyLandingNew.php";
	}
}

function gotoDashBrdFoot_org(call)
{
	var city = getSearchCookie("city");
	var state= getSearchCookie("state");

	if(trim(city) == '' && city != null)
	{
		var now = new Date();
		now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
		city = "San Jose";
		state = "CA";
		latLongStr = "[{'lat':'37.316466','lng':'-121.873881'}]";
		setCookie("latLongCk",latLongStr, now);
		latLong = eval(getCookie("latLongCk"))[0];
		setSearchCookie("city", city);			
		setSearchCookie ("state", state);
	}

	if (call == 'openhouse')
		callMapIt(call);
	else if (call == 1 || call == 0)
		gotoSellDshbrd(call);
	else
		callMapIt();
}

startStack=function() { };  // A stack of functions to run onload/domready

registerOnLoad = function(func) 
{
   var orgOnLoad = startStack;
   startStack = function () {
      orgOnLoad();
      func();
      return;
   }
}

var ranOnload=false; // Flag to determine if we've ran the starting stack already.

if (document.addEventListener) 
{
  // Mozilla actually has a DOM READY event.
   document.addEventListener("DOMContentLoaded", function(){if (!ranOnload) {ranOnload=true; startStack();}}, false);
}
else if (document.all && !window.opera)
{
  // This is the IE style which exploits a property of the (standards defined) defer attribute
  document.write("<scr" + "ipt id='DOMReady' defer=true " + "src=//:><\/scr" + "ipt>");  
  document.getElementById("DOMReady").onreadystatechange=function(){
    if (this.readyState=="complete"&&(!ranOnload)){
      ranOnload=true;
      startStack();
    }
  }
}

// Commented by ravi. Do not put onload funtion in Common files.

/*var orgOnLoad=window.onload;
window.onload=function() 
{
	if (typeof(orgOnLoad)=='function') 
	{
		orgOnLoad();
	}
	if (!ranOnload) 
	{
		ranOnload=true;
		startStack();
	}
}*/

var funRplcImgBitzBar = function()
{
	if($('divIconCollect'))
	{
		var dashIcons = $('divIconCollect').getElementsByClassName('dashIconsDrag');
		for(var i=0;i<dashIcons.length;i++)
		{
			var divImgId = dashIcons[i].id;
			var widgetName = divImgId.gsub('divImg_','');
			var imgId =  'img_'+widgetName;
			$(imgId).src = $(imgId).src.gsub('blankImg.gif',eval('widgetsData.'+widgetName+'.img_n'));
		}
	}
	
}
/*
registerOnLoad(funRplcImgBitzBar);

var startup1 = function() {
   alert("I'm the first function!")
}

registerOnLoad(startup1);
registerOnLoad(function () {
   alert("I'm the second function!")
});
*/

function funMakeBitClickable(bitName,page,from)
{
	var ihBitz = new StringBuffer();
		ihBitz.append('<table border="0" style="font-size:0.7em;width:100%;height:100%;border-spacing:0px;">');
			ihBitz.append('<tr>');
				if(page != null && trim(page) == 'dashboard')
				{
					var innerTitleText = "Click to load on dashboard";
				}
				else
				{
					var innerTitleText = "Click to load on map";
				}	
				if(from=="API")
				{
					var innerTitleText = "Click on the bit to load.";
				}
				ihBitz.append('<td align="center" valign="top"  onmouseover="try{showTooltip(\''+innerTitleText.stripTags()+'\',event);}catch(e){}" onmouseout="try{hideTooltip();}catch(e){}">');
					try
					{
						var bitImg = eval('widgetsData.'+bitName+'.img_n');
						var bitTitle = eval('widgetsData.'+bitName+'.title');
					}
					catch(e)
					{
						var bitImg = "";
						var bitTitle = "";
						
					}
				if(page != null && trim(page) == 'dashboard')
					{
						ihBitz.append('<img id="img_'+bitName+'" style="cursor:pointer;" class="crsr" src="../../wt/'+bkTheme+'/images/dashboard/toolbarIcons/'+bitImg+'"  title="" alt="'+bitTitle+'" onclick="javascript:funLoadOnDashboard(\''+bitName+'\');" />');
					}
					else
					{
						ihBitz.append('<img id="img_'+bitName+'" style="cursor:pointer;" class="crsr" src="../../wt/'+bkTheme+'/images/dashboard/toolbarIcons/'+bitImg+'"  title="" alt="'+bitTitle+'" onclick="javascript:funLoadOnMap(\''+bitName+'\');" />');
					}	
				ihBitz.append('</td>');
			ihBitz.append('</tr>');
		ihBitz.append('</table>');
		if($('divImg_'+bitName))
		{
            $('divImg_'+bitName).innerHTML = ihBitz.toString();
            $('img_'+bitName).onmouseover = revealThumbnail;
            $('img_'+bitName).onmouseout = hideThumbnail;
        }
}
function funLoadedOnMap(bitName,page)
{
	//alert('This bit is already loaded on map.'); 
	if(bitName == "wikipedia")
	{
		mapItCtrl.removeIcon_(mapItCtrl.getContainer_(),bitName);
		map.removeOverlay(wikiLayer);
		funMakeBitClickable(bitName);
		
		var currUrl = location.href;
		if(!currUrl.include("singlePropertyLanding.php"))
			unfillLoaded(bitName);
		return;
	}
	if(typeof(unfillLoaded)!="undefined")
	{
		unfillLoaded(bitName);
	}
	closeMapBit (bitName);
	funMakeBitClickable (bitName);
	return;
}
function funLoadedOnDashboard(bitName,page)
{
	//alert('This bit is already loaded on Dashboard.'); 
	funCloseWidget(null,bitName);
	return;
}
function funMakeBitNonClickable(bitName,page)
{
	var ihBitz = new StringBuffer();
		ihBitz.append('<table border="0" style="font-size:0.7em;width:100%;height:100%;border-spacing:0px;">');
			ihBitz.append('<tr>');
				if(page != null && trim(page) == 'dashboard')
				{
					var innerTitleText = "Click on the bit to remove.";
				}
				else
				{
					var innerTitleText = "Click on the bit to remove.";
				}	
				ihBitz.append('<td align="center" valign="top"  class="maskNonClickableBit" onmouseover="try{showTooltip(\''+innerTitleText.stripTags()+'\',event);}catch(e){}" onmouseout="try{hideTooltip();}catch(e){}">');
					var bitImg = eval('widgetsData.'+bitName+'.img_n');
					var bitTitle = eval('widgetsData.'+bitName+'.title');
					if(page != null && trim(page) == 'dashboard')
					{
						ihBitz.append('<img  id="img_'+bitName+'"  class="crsr" src="../../wt/'+bkTheme+'/images/dashboard/toolbarIcons/'+bitImg+'"  title="" alt="'+bitTitle+'" onclick="javascript:funLoadedOnDashboard(\''+bitName+'\');" />');
					}
					else
					{
						ihBitz.append('<img  id="img_'+bitName+'"  class="crsr" src="../../wt/'+bkTheme+'/images/dashboard/toolbarIcons/'+bitImg+'"  title="" alt="'+bitTitle+'" onclick="javascript:funLoadedOnMap(\''+bitName+'\');" />');
					}	
				ihBitz.append('</td>');
			ihBitz.append('</tr>');
		ihBitz.append('</table>');
	$('divImg_'+bitName).innerHTML = ihBitz.toString();
	$('img_'+bitName).onmouseover = hideThumbnail;
	$('img_'+bitName).onmouseout = hideThumbnail;
//	$('divImg_'+bitName).style.display = 'none';
}
function funMakeSummaryHeader(page)
{
	/*var ihSummaryHeader = new StringBuffer();
	if(page != null && trim(page) == 'dashboard')
		ihSummaryHeader = ihSummaryHeader + '<table style="width:180px;height:17px;" cellspacin="0" cellpadding="0" id="tblSummaryHeader">';
	else
		ihSummaryHeader = ihSummaryHeader + '<table style="width:178px;height:17px;" cellspacin="0" cellpadding="0" id="tblSummaryHeader">';
        ihSummaryHeader = ihSummaryHeader + '<tr>';
			ihSummaryHeader = ihSummaryHeader + '<td class="bgLeftSummaryHeader">&nbsp;</td>';
			if(page != null && trim(page) == 'dashboard')
				ihSummaryHeader = ihSummaryHeader + '<td class="bgMiddleSummaryHeader" align="center" valign="middle" id="tdSummaryHeader" style="width:164px;">';
			else
				ihSummaryHeader = ihSummaryHeader + '<td class="bgMiddleSummaryHeader" align="center" valign="middle" id="tdSummaryHeader" style="width:164px;">';
				
					ihSummaryHeader = ihSummaryHeader + '<span class="textSummaryHeader" id="spanSummaryHeader" >';
					if(page != null && trim(page) == 'dashboard')
						ihSummaryHeader = ihSummaryHeader + 'Currently active on dashboard';
					else
						ihSummaryHeader = ihSummaryHeader + 'Currently active on map';
					ihSummaryHeader = ihSummaryHeader + '</span>';
					
			ihSummaryHeader = ihSummaryHeader + '</td>';
			ihSummaryHeader = ihSummaryHeader + '<td class="bgRightSummaryHeader">&nbsp;</td>';
		ihSummaryHeader = ihSummaryHeader + '</tr>';
		
	ihSummaryHeader = ihSummaryHeader + '</table>';
	
	var myDiv = document.createElement('div');
	if(page != null && trim(page) == 'dashboard')
		myDiv.style.width = '180px';
	else
		myDiv.style.width = '170px';
	myDiv.style.position = 'absolute';
	if(page != null && trim(page) == 'dashboard')
	{
		var objSummaryArea = document.getElementById('divSummaryArea');
		var posLeft = getPositionLeft(objSummaryArea);
		var posTop = getPositionTop(objSummaryArea);
		myDiv.style.left = posLeft+'px';
		myDiv.style.top = (posTop-17)+'px';
	}
	else
	{
		var objIconContaner = document.getElementById('myIconContainer');
		var posLeft = getPositionLeft(objIconContaner);
		var posTop = getPositionTop(objIconContaner);
		myDiv.style.left = posLeft+'px';
		myDiv.style.top = (posTop-17)+'px';
	}	
	myDiv.innerHTML = ihSummaryHeader;
	document.body.appendChild(myDiv);*/
}
function funMakeSummaryArea(page)
{
	/*var objBitzBarHeader = document.getElementsByClassName('menuTrTb')[0];
	var posLeft = getPositionLeft(objBitzBarHeader);
	var posTop = getPositionTop(objBitzBarHeader);
	
	var divSummaryArea = document.createElement("div");
	divSummaryArea.id="divSummaryArea";
	divSummaryArea.className = "containerClass";
	
	if(page != null && trim(page) == 'dashboard')
		divSummaryArea.style.width = "178px";
	else
		divSummaryArea.style.width = "168px";
	divSummaryArea.style.cursor = 'default';	
	divSummaryArea.style.height = "50px";
	divSummaryArea.style.position = "absolute";
	divSummaryArea.style.left = eval(posLeft-190)+'px';
	divSummaryArea.style.top = eval(posTop+35)+'px';
	if(page != null && trim(page) == 'dashboard')
	{
		divSummaryArea.innerHTML = '<table cellspacing="0" cellpadding="0" style="cursor:default;width:100%;height:100%;"><tr><td style="width:100%;height:100%;" align="center" valign="middle" class="infoSummaryHeader">Click icons on right to populate dashboard.</td></tr></table>';
	}
	else
	{
		divSummaryArea.innerHTML = '<table cellspacing="0" cellpadding="0" style="cursor:default;width:100%;height:100%;"><tr><td style="width:100%;height:100%;" align="center" valign="middle" class="infoSummaryHeader">Click icons on right to populate map.</td></tr></table>';
	}
	//document.body.appendChild(divSummaryArea);
	funMakeSummaryHeader(page);*/
}
function funShowCrossedImage(objImg)
{
	var imgSrc = objImg.src;
	var newSrc = imgSrc.replace('.gif','Crossed.gif');
	objImg.src = newSrc;
}
function funHideCrossedImage(objImg)
{
	var imgSrc = objImg.src;
	var newSrc = imgSrc.replace('Crossed.gif','.gif');
	objImg.src = newSrc;
}
var cntLoadedBitz = 0;
function funAddBitToSummaryArea(bitName,page)
{
	if(page != null && trim(page) == 'dashboard')
	{
		if(cntLoadedBitz == 0)
		{
			//$('divSummaryArea').innerHTML = '';
		}
		var objDiv = document.createElement('div');
		objDiv.id = 'divSumBit_'+bitName;
		if(isIE)
			objDiv.style.styleFloat = 'left';
		else
			objDiv.style.cssFloat = 'left';
		objDiv.style.position = 'relative';
		objDiv.style.display = 'inline';
		objDiv.style.width = '29px';
		objDiv.style.height = '25px';
		objDiv.innerHTML = '<img src="/wt/'+bkTheme+'/images/common/'+bitName+'.gif" title="Remove '+unescape(widgetsData[bitName]['title']).stripTags()+'" alt="'+unescape(widgetsData[bitName]['title']).stripTags()+'" style="cursor:pointer" onmouseover="javascript:funShowCrossedImage(this);" onmouseout="javascript:funHideCrossedImage(this);" onclick="javascript:funRemoveBit(\''+bitName+'\',\''+page+'\');">';		
		//$('divSummaryArea').appendChild(objDiv);
		cntLoadedBitz = cntLoadedBitz + 1;
	}	
}
function funRemoveBit(bitName,page)
{
	if(page != null && trim(page) == 'dashboard')
	{
		funCloseWidget(null,bitName);
	}
}
function funRemoveImageFromSummaryArea(bitName,page,removeAll)
{
	if(removeAll != null && removeAll == true)
	{
		cntLoadedBitz = 0;
		//$('divSummaryArea').innerHTML = '<table cellspacing="0" cellpadding="0" style="cursor:default;width:100%;height:100%;"><tr><td style="width:100%;height:100%;" align="center" valign="middle" class="infoSummaryHeader">Click icons on right to populate dashboard.</td></tr></table>';
		return;
	}
	if(page != null && trim(page) == 'dashboard')
	{
		//if(($('divSummaryArea') != null) && ($('divSumBit_'+bitName) != null))
		//	$('divSummaryArea').removeChild($('divSumBit_'+bitName));
		cntLoadedBitz = cntLoadedBitz - 1;
		if(cntLoadedBitz == 0)
		{
		//	$('divSummaryArea').innerHTML = '<table cellspacing="0" cellpadding="0" style="cursor:default;width:100%;height:100%;"><tr><td style="width:100%;height:100%;" align="center" valign="middle" class="infoSummaryHeader">Click icons on right to populate dashboard.</td></tr></table>';
		}
	}
}

function openChatPage()
{
	var url = '/help/interoContactUs.php?hCity=' + getSearchCookie("city") + '&hState=' + getSearchCookie("state");
	window.open (url, '', '');
}

function setMapItckBlank(dshbrdUsrId)
{
	if(typeof(dshbrdUsrId) != "undefined" && dshbrdUsrId != "")
		setCookie('strMapitCK','');
}

function addCommas(num)
{
	var nStr = new String(num);
	if(nStr.indexOf(',') > 0)
	{					
		nStr = nStr.replace(/\,/g,'');
	}
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function numFormat(txtPrice)
{
	if($(txtPrice).value != '')
	{
		var price = $(txtPrice).value;
	
		if(price.indexOf(',') > 0)
		{					
			price = price.replace(/\,/g,'');
		}
		$(txtPrice).value = addCommas(price);
	}
}

function keyDown(e,txtprice)
{
	var keycode = e.keyCode;
	if(keycode!=37&& keycode!=38 &&keycode!=39&&keycode!=40)
	{
		numFormat(txtprice);
	}
}

function roundPrice(txtPrice)
{
	if($(txtPrice).value != '')
	{
		var valPrice = $(txtPrice).value;
		
		if(valPrice.indexOf(',') >= 0)
		{			
			valPrice = valPrice.replace(/\,/g,'');
		}
		if (!isNaN(valPrice))
		{
		   //$(txtPrice).value=addCommas(Math.round(valPrice));
		   $(txtPrice).value=addCommas(Math.round(valPrice));
		}
	}
}

function setAllCheckedStyle(from)
{
	if(typeof(from)!="undefined")
	{
		divId = "RSpropStyleDv";
		chkAllId = "RSchkStyleAll";
	}
	else
	{
		divId = "propStyleDv";
		chkAllId = "chkStyleAll";
	}

	if($(divId))
	{
		var arrChkBox = $(divId).getElementsByTagName("input");
		var lenChkBox = arrChkBox.length;

		for(var i=0;i<lenChkBox;i++)
		{	
			if(arrChkBox[i].id == chkAllId)
				continue;
			if(($(chkAllId).checked == true) && (arrChkBox[i].type == "checkbox"))
				arrChkBox[i].checked = true;
			else if(arrChkBox[i].type == "checkbox")
				arrChkBox[i].checked = false;
		}
	}
}

/*function setAllCheckedParkingStyle()
{
	if($("parkingStyleDv"))
	{
		var arrChkBox = $("parkingStyleDv").getElementsByTagName("input");
		var lenChkBox = arrChkBox.length;

		for(var i=0;i<lenChkBox;i++)
		{	
			if(arrChkBox[i].id == "chkParkingStyleAll")
				continue;
			if(($('chkParkingStyleAll').checked == true) && (arrChkBox[i].type == "checkbox"))
				arrChkBox[i].checked = true;
			else if(arrChkBox[i].type == "checkbox")
				arrChkBox[i].checked = false;
		}
	}
}*/

function chkAllOpt(chkAllID,divId)
{
   if($(divId))
	{
   var arrChkBox = $(divId).getElementsByTagName("input");
   lenOptWA = arrChkBox.length;
   lenOpt = arrChkBox.length - 1;
   chkCnt = 0;
   for(i=0;i<lenOptWA;i++)
   {
     if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
     {
       if(arrChkBox[i].id == chkAllID)
        continue;
       else
        chkCnt++; 
     }
   }
   if(chkCnt == lenOpt)
       $(chkAllID).checked = true;
   else
       $(chkAllID).checked = false; 
	}
}

function chkAllUnderDiv(divId,val)
{
	if($(divId)) {
		var arrChkBox = $(divId).getElementsByTagName("input");
		lenOptWA = arrChkBox.length;
		for(i=0;i<lenOptWA;i++)
		{
			if(arrChkBox[i].type == "checkbox" && val)		
				arrChkBox[i].checked = true;
			else
				arrChkBox[i].checked = false;
		}
	}
}

/*************** START ******************** USED FOR NEW POWER SEARCH AND LIST SEARCH CODE **********************/
function ClrQckSrchCookies()
{	
	funClrQckSrchCookies();
	deleteCookie("latLongCk");
	if($("helpBox")) $("helpBox").hide();
	if($('mlsSearchDiv')) $('mlsSearchDiv').hide();	
	if($('propHeroDiv')) $('propHeroDiv').hide();
	if($('botPagiRow')) $('botPagiRow').hide();	
	if($("paginationTd")) $("paginationTd").style.display = "none";	
	if($("recOperationDiv")) $('recOperationDiv').hide();
	if($('proListingDiv')) { $('proListingDiv').innerHTML = ""; $('proListingDiv').hide();	}
	if($('lrgSmlMapDiv')) $('lrgSmlMapDiv').hide();
	if($('limitBar')) $('limitBar').innerHTML ='';
	if($('divAutoComp')) $('divAutoComp').hide();
	if($('divLocalSearch')) $('divLocalSearch').hide();

	totalRecords = 0;	
	//TO CLEAR POWER SEARCH NEIGHBORHOOD
	if(typeof(clearNbr) == 'function' )
		clearNbr();
	if(typeof(clearGarage) == 'function' )
		clearGarage();
	tmpSpanMCTCookie = '';
	tmpSpanNBRCookie = '';
	if($('searchAddress')) $('searchAddress').disabled = false;
	if($('RSsearchAddress')) $('RSsearchAddress').disabled = false;	
	
	chkAllUnderDiv('divLocalSearch',false);
	removeSearchCookie("multicity");	
	removeSearchCookie("multizip");
	removeSearchCookie("mctSpanHTML");
	if($('showMultiCity')) $('showMultiCity').innerHTML = "";
	if($('showMultiZip')) $('showMultiZip').innerHTML = "";
	
	removeSearchCookie("minPrice");
	removeSearchCookie("maxPrice");
	removeSearchCookie("listType");
	if(bkTheme == "reotexashomes")
	{ setSearchCookie("listType","bankOwned"); }
	removeSearchCookie("propDesc");
	removeSearchCookie("ckLFDate");
	removeSearchCookie("ckLTDate");
	removeSearchCookie("mlsno");
	removeSearchCookie("nbrSpanHTML");
	//removeSearchCookie("spanHTML");
	removeSearchCookie("lat");
	removeSearchCookie("lng");	
	removeSearchCookie("polygon");
	removeSearchCookie("area");		
	if($('clrSerArea')) $('clrSerArea').style.display='none';
	if($('drawSerArea')) $('drawSerArea').style.display='';	
	lfDate = ''; ltDate = ''; mlsno = '';
	if($("RStxtLFDate"))  $("RStxtLFDate").value = '';
	if($("RStxtLTDate"))  $("RStxtLTDate").value = '';
	if($("RSsearchMLS")) $("RSsearchMLS").value = '';
	if($('frmAdvanceSearch')) $('frmAdvanceSearch').reset();
	if($('frmPropSearch')) $('frmPropSearch').reset();
	if($('rsNHoodCntr')) $('rsNHoodCntr').style.display='none';	
	if($('shoNbhood')) $('shoNbhood').innerHTML= '';
	if($('keySerDiv'))  $('keySerDiv').innerHTML= '';
	//Added by surya for clearing the data from  temp string
	unChkstr  = "";
	chkdDat   = "";
	alwdCnt = 0 ;
	if (typeof(alwdCntMCT) != "undefined") alwdCntMCT = 0;
	if($('RSchbSHTypeAll')) $('RSchbSHTypeAll').checked = true;
	if($('polygonDiv')) $('polygonDiv').style.display='';	
	if($('serByNbrhood')) $('serByNbrhood').style.display='';		
	if($('searchMLS')) $('searchMLS').value = '';
	if($('pStatusList')) $('pStatusList').innerHTML = "";
	if($('pTypeList')) $('pTypeList').innerHTML = "";	
	if ($('crawlerNotificationArea'))
		$('crawlerNotificationArea').innerHTML = '';
	try 
	{
		funSetSHTypeAll('RS'); 
	} 
	catch (err)
	{ 
	}
	if($('RSsearchMLS')) $('RSsearchMLS').value = '';	
	if(typeof(initPower) != 'undefined' && !initPower) 
	{
		try {
				savePrpType(); 
			}
		catch(err)
		{
		
		}
	}
	if($('bit_select_box')) $('bit_select_box').value = "";
	totalRecords = 0;		
	if($('noRecTbl'))
	{		
		if(typeof(initPower) != 'undefined' && initPower)
		{
			var noRMsg = 'Select search criteria and Click "Agent View" Or "Consumer View".';
		}
		else
		{
			var noRMsg = 'Select search criteria and Click "UPDATE RESULTS".';
		}
		$('noRecTblMsg').innerHTML = noRMsg;
		$('noRecTbl').show();
	}

	if(!goToMap)
	{
		if($('SortPageTbl')) { $('SortPageTbl').hide(); }
		if($("picdivImg_0") && totalRecords > 0)
		{
			if($('favRoloDiv')) $('favRoloDiv').style.display = '';
		}
		else
		{
			if($('favRoloDiv')) $('favRoloDiv').style.display = 'none';
		}
		
		if( $("mapDiv") ) { $("mapDiv").style.display = 'none'; }
		if( $("drawsearchinfobar") ) { $("drawsearchinfobar").style.display = 'none'; }		
		if($('impMapShow'))
		{
			$('impMapShow').hide(); 
			$('impMapShow').innerHTML='View On Map'; 
		}
	}
	clearChkBoxInDiv("prpTyp");
    clearChkBoxInDiv("prpStat");
	if($("searchAddress")) $("searchAddress").className = "textboxSH";
	removeSearchCookie("spanStyleHTML");
	removeSearchCookie("propStyle")
	if($('prpStyleText')) $('prpStyleText').innerHTML = "";
	if(typeof(showMultiCityRelated) != "undefined" && typeof(showMultiCityRelated) == "function") 
	{
		showMultiCityRelated();
	}	
}

/************************** USED FOR NEW POWER SEARCH AND LIST SEARCH CODE **********************/

/************************************* Lead Management For Ezee Doc Function Starts Here ***************************/

function createHomeValuePopUp()
{		
	
		if($('errLeadPro'))$('errLeadPro').innerHTML = "";
		if($('txtConsEmail')){$('txtConsEmail').className = "";$('txtConsEmail').value="";}
		if($('txtConsAddress'))$('txtConsAddress').className = "";
		if($('txtConsPhone'))$('txtConsPhone').className = "";
		if($('txtConsCity'))$('txtConsCity').className = "";
		if($('txtConsState'))$('txtConsState').className = "";
		if($('txtConsZip'))$('txtConsZip').className = "";

				flg=false;	
				
					if(($("txtAddress") && $("txtCSZ")) && ($("txtAddress") != null && $("txtCSZ")!= null))
					{
						var adr = escape($("txtAddress").value + "," + $("txtCSZ").value);
						var url = "/agentsite/processAgent.php";
						var qs = "process=validateAddress&address="+adr;
						ajaxRequest(url,qs,function(reqobj){ 
							var varResponse = trim(reqobj.responseText);
								if(varResponse != "")
								{
									flg = true;
									var arr = varResponse.split("|");
									
									if($("txtAddress"))$("txtAddress").value = arr[0];
									if($("txtCSZ"))$("txtCSZ").value = arr[1] + ", " + arr[2] + " " + arr[3];
									city=arr[1];
									state=arr[2];
									zip= arr[3];
								}
								else
								{
									alert("Invalid Address");
								}
						},false);

						if(flg)
						{
							
							top.$('leadFrmHomePopUp').style.display= "block";
							top.$('txtConsAddress').value=$('txtAddress').value;
							top.$('txtConsCity').value=city;
							top.$('txtConsState').value=state;
							top.$('txtConsZip').value=zip;
							top.$('errEmailPro').innerHTML="&nbsp;";		
							top.leadEmailDlg1.show();
							if(top.$('txtConsName'))top.$('txtConsName').focus();	
						}
					}
					else
						{
							
							if(typeof(estimateAddress) != "undefined"  && (typeof(estimateCity)!= "undefined" && typeof(estimateState)!= "undefined" && typeof(estimateZip)!= "undefined" ))
								{

										if($('leadFrmHomePopUp1')) $('leadFrmHomePopUp1').style.display= "block";	
										if($('txtConsName') != null)$('txtConsName').value = "";
										if($('txtConsAddress') != null){$('txtConsAddress').className=""; $('txtConsAddress').value=estimateAddress ; }
										if($('txtConsCity') != null){$('txtConsCity').className="" ; $('txtConsCity').value=estimateCity ;}
										if($('txtConsState') != null){$('txtConsState').className="" ; $('txtConsState').value=estimateState ;}
										if($('txtConsZip') != null){$('txtConsZip').className=""; $('txtConsZip').value=estimateZip ;}
										if(document.saleform.sale)
											document.saleform.sale[0].checked = true ;
										if($("txtConsComments") != null)$("txtConsComments").value = "";
										if($('errEmailPro')) $('errEmailPro').innerHTML="&nbsp;";		
										if(leadEmailDlg1 != "undefined") leadEmailDlg1.show();
										if($('leadFrmHomePopUp1_c')) $('leadFrmHomePopUp1_c').style.zIndex='17';
										if($('leadFrmHomePopUp1_mask')) $('leadFrmHomePopUp1_mask').style.zIndex='16';
										
								}
						}

			
				
				
			
}
	
/************************* Lead Management For Ezee Doc Function Ends Here *********************/

/*********************** USED FOR NEW POWER SEARCH AND LIST SEARCH CODE **********************/

function goToListSearch()
{	
	url = 	'/Search/'+getSearchCookie("state")+'/'+getSearchCookie("city");
	var qs = new Querystring();
	if(qs.get("frm") != null && trim(qs.get("frm")) == 'agt' && qs.get("aid") != null)
	{
		url += "?frm="+trim(qs.get("frm"))+"&aid="+trim(qs.get("aid"));
	}
	location.href=url;
}
function goToTools()
{
	url = 	'/terabitzApi/finance/index.php?city='+getSearchCookie("city")+'&state='+getSearchCookie("state");
	var qs = new Querystring();
	if(qs.get("frm") != null && trim(qs.get("frm")) == 'agt' && qs.get("aid") != null)
	{
		url += "&frm="+trim(qs.get("frm"))+"&aid="+trim(qs.get("aid"));
	}
	location.href=url;
}


function clearChkBoxInDiv(divId)
{
        if($(divId))
		{			
			var arrChkBox = $(divId).getElementsByTagName("input");
			for(i=0;i<arrChkBox.length;i++)
			{
				if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
				{
					arrChkBox[i].checked = false;
				}
			}
        }
}

function clearCityStateMLS()
{
	removeSearchCookie("city");	
	removeSearchCookie("state");
	removeSearchCookie("mlsno");
}

// Added For Giving Alert To Registered User When It Clicks On Vendor Login Page

function redirectUser()
{
  var confirmation = confirm("All your current sessions will expire if you navigate to this page. Do u wish to continue. !!")
	if(confirmation == true)
	{
	    location.href = 'http://'+document.location.host+'/app/vendor/login.php';
	}
	else
		return false;
}

function checkInArray(fStr,serArr)
{
    for (key in serArr)
    {
        if(serArr[key] == fStr)
        return true;
    }
    return false;
}

function cmImplodeArr(arr,sep)
{
	var arrStr="";
	for(i=0;i<arr.length;i++)
	{	
		arrStr += arr[i];
		if(i<((arr.length) - 1)){arrStr += sep;}
	}
	return arrStr;
}

function cmExplodeArr(arrStr,sep)
{
	var arrSplt=Array();
	arrSplt=arrStr.split(sep);
	return arrSplt;
}

function goToToolsWithBit(bit, chkVar)
{
	url = 	'/terabitzApi/finance/index.php?city='+getSearchCookie("city")+'&state='+getSearchCookie("state");
	var qs = new Querystring();	
	if(qs.get("frm") != null && trim(qs.get("frm")) == 'agt' && qs.get("aid") != null)
	{
		url += "&frm="+trim(qs.get("frm"))+"&aid="+trim(qs.get("aid"));
	}	
	if(bit != '')
		url += "&bit="+bit+"&chkVar=" + chkVar;
	location.href=url;
}

// To set value of list box
// used on list search and property alert
function setListBoxValue (listId, listVal)
{
	if ($(listId))
	{
		for (i=0; i<$(listId).length; i++)
		{
			if ($(listId)[i].value == listVal)
			{
				$(listId).selectedIndex = i;
				break;
			}
		}	
	}
}

function setMultiselectListBoxValue (listId, listVal, separator)
{
	if (separator == null)
		separator = ",";

	if ($(listId))
	{
		listVal = separator + listVal + separator;

		for (i=0; i<$(listId).length; i++)
		{
			if (listVal.indexOf (separator + $(listId)[i].value + separator) != -1)
			{
				$(listId)[i].selected = true;
			}
		}	
	}
}

function goToMapSearchEmerge()
{
	if(getSearchCookie("polygon"))
		removePolyRelated();
	if(getSearchCookie("neighborhood") && bkTheme != 'pruone')
		removeSearchCookie("neighborhood");

	if(getSearchCookie("city") == "")
	{
		defCity = defCity.replace('%20',' ');
		setSearchCookie("city",defCity);
		setSearchCookie("state",defState);
		setSearchCookie("lat",defLat);
		setSearchCookie("lng",defLng);
	}

	if(getSearchCookie("mlsno") && getSearchCookie("mlsno") != "")
		setSearchCookie("mlsno","");

	flgPoly = true;	
	if(flgPoly)
	{
		if(getSearchCookie("lat") && getSearchCookie("lat") != "")
		{
			//DO NOTHING
		}
		else if(getCookie("latLongCk") && getCookie("latLongCk") != "")
		{
			var mainLatLng = eval(getCookie("latLongCk"))[0];
			if(mainLatLng.lat == "")
				setSearchCookie("lat",defLat);
			else
				setSearchCookie("lat",mainLatLng.lat);

			if(mainLatLng.lng == "")
				setSearchCookie("lng",defLng);
			else
				setSearchCookie("lng",mainLatLng.lng);
		}
		else
			setSearchCookie("lat",defLat);

		if(getSearchCookie("lng") && getSearchCookie("lng") != "")
		{
			//DO NOTHING
		}
		else
			setSearchCookie("lng",defLng);
			
		setSearchCookie("searchAddress","");
		var url = "";
        if(typeof(mapToShow) != "undefined" && mapToShow == "")
			url='/app/listing/singlePropertyLanding.php?status=EXP&address=,'+getSearchCookie("city")+','+getSearchCookie("state")+','+getSearchCookie("zip")+',,,,'+getSearchCookie("lat")+','+getSearchCookie("lng")+'&widgetnames=';
		else
			url='/app/listing/singlePropertyLanding.php?status=N&code=propView=1:::searchAddress='+getSearchCookie("searchAddress")+':::city='+getSearchCookie("city")+':::state='+getSearchCookie("state")+':::zip='+getSearchCookie("zip")+':::neighborhood=:::county=:::minPrice=:::maxPrice=:::searchBeds=:::searchBaths=&mapCenter=('+getSearchCookie("lat")+','+getSearchCookie("lng")+')&valChkMapSearchSelect=1&fe=&f=1&propLatitude='+getSearchCookie("lat")+'&propLongitude='+getSearchCookie("lng")+'&clrbitz=1&mapZoom=13';
  		 
		 var qs = new Querystring();
		 var ct = getSearchCookie("city");
 		 var st = getSearchCookie("state");
		 if(typeof(agentSiteRendering) != 'undefined' && agentSiteRendering == true)
			 url += "&frm=agt&aid="+agentId;

	
		goToMap = true;
		//ClrQckSrchCookies(); commented by dhaval
		
		setSearchCookie("city",ct);
		setSearchCookie("state",st);
		
		location.href=url;
	}
}

function getApiData(map2, city, state, nhood, lat, lng, aid)
{
	if($("apiLoading")) $("apiLoading").show();
	if(city == null || city == 'undefined') {
		city = '';
		state = '';
	}
	else if(nhood == null || nhood == 'undefined') {
		nhood = '';
	}

	if (map2 != null && typeof(map2) != 'undefined')
	{
		glatlng = map2.getCenter();

		minx = glatlng.lng()-0.05;
		miny = glatlng.lat()-0.05;
		maxx = glatlng.lng()+0.05;
		maxy = glatlng.lat()+0.05;

		lat = glatlng.lat();
		lng = glatlng.lng();
	}
	else if (typeof(lat) != 'undefined' && typeof(lng) != 'undefined')
	{
		minx = lng-0.05;
		miny = lat-0.05;
		maxx = lng+0.05;
		maxy = lat+0.05;
	}
	else
	{
		minx = 0;
		miny = 0;
		maxx = 0;
		maxy = 0;

		lat = 0;
		lng = 0;
	}

    var url = "/getApiData.php?lat="+lat+"&lng="+lng+'&minx='+minx+'&miny='+miny+'&maxx='+maxx+'&maxy='+maxy + '&city=' + city + '&state=' + state + '&nhood=' + nhood + '&aid=' + aid;
    if($("schoolratingsdiv")) $("schoolratingsdiv").innerHTML = '';
    if($("areaphotosdiv")) $("areaphotosdiv").innerHTML = '';


	new Ajax.Request(url,{onCreate: function()
		{
			if($("apiLoading")) $("apiLoading").show();
		},method:"get",
		onComplete: function(){
			if($("apiLoading")) $("apiLoading").hide();
		},
		onSuccess:function(r) {
			if($("apiDiv")) $("apiDiv").show();
			apiresp = r.responseText.evalJSON(true);
            if($("schoolratingsdiv"))  $("schoolratingsdiv").innerHTML = apiresp.schools;
            if($("areaphotosdiv"))  $("areaphotosdiv").innerHTML = apiresp.areaphotos;
	}});
}

function doGeoCode(csz,addr)
{
	var url = "/classes/getCSZ.php";
	var qs = "csz="+trim(csz)+"&address="+addr;	
    var err = false;            
    var retArray = new $H();

	ajaxRequest(url,qs,function(r)
	{      
		var ge_response = eval('(' + trim(r.responseText) + ')');
		if(ge_response[0].status == "0")
		{			
			retArray['addr'] = ge_response[0].address;
			retArray['city'] = ge_response[0].city;
			retArray['state'] = ge_response[0].state;
			retArray['zip'] = ge_response[0].zip;
			retArray['lat'] = ge_response[0].latitude;
			retArray['lng']= ge_response[0].longitude;
			var latLongStr = "[{'lat':'"+retArray['lat']+"','lng':'"+retArray['lng']+"'}]";
			var now = new Date();
			now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
			setCookie("latLongCk",latLongStr,now);	
		}
		else
		{			
			if(addr != "" && addr != "undefined" && addr != undefined)
				alert("Sorry, We couldn't find a location for '"+ addr+ " " +csz+"'");			
			else
				alert("Sorry, We couldn't find a location for '"+csz+"'");
                        err = true; 
		}               
	},false);
	 
	 if(err)               
		  return false;
	  else 
		return retArray;
}

/*Function for cameraview-for powersearch*/
function setHeroDiv(imgIndex,pics,link,divId)
{
	if($("propHeroDiv")==null || $("propHeroDiv")=="undefined")
	{
		var propHeroDiv = document.createElement("div");
		propHeroDiv.id = "propHeroDiv";
		document.body.appendChild(propHeroDiv);

	}

	
	$("propHeroDiv").setStyle({position:'absolute',zIndex:'4',display:'none',backgroundImage:'url(/vendor/rolodex/Images/heroFrame.png)',backgroundRepeat:'no-repeat',height:'205px',width:'270px'});
	if($(divId))
	{
		var top = getPositionTop(divId);
		var left = getPositionLeft(divId);
		//alert(top + " == "+ left);
		$("propHeroDiv").style.top =  top+"px";
		if(divId == 'mapDiv')
		{
			$("propHeroDiv").style.left = (left)+"px";
		}
		else	
		{
			$("propHeroDiv").style.left = (left+100)+"px";
		}
	}
	else
	{
		$("propHeroDiv").style.top =  ((screen.height/2)-100)+"px";
		$("propHeroDiv").style.left = ((screen.width/2)-300)+"px";
	}
	var strPics = unescape(pics);
	var picArr = strPics.split(",");
	var htmlStr = new StringBuffer();

	if(picArr ==  "" || (picArr.length == 1 && picArr[0].include("/images/listing/noImageThmb.jpg"))) //please do not remove this condition added by abhishek
	{
		var image = "http://"+window.location.hostname+"/wt/"+bkTheme+"/images/listing/noImageThmbBig.jpg";
		htmlStr.append('<img src="'+image+'" height="185" width="250" style="position:absolute;top:10px;left:10px"/>');
		htmlStr.append('<div class="imgPointer" onclick="hideHeroDiv();" style="background-image:url(\'/vendor/rolodex/Images/savedDelBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;left:240px;top:12px;width:20px;height:20px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/savedDelBtn.png\', sizingMethod=\'scale\');"/></div>');
		htmlStr.append('<a id="roloDetailImg" style="background-image:url(\'/vendor/rolodex/Images/roloInfoBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;left:96px;top:177px;width:75px;height:19px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/roloInfoBtn.png\', sizingMethod=\'scale\');" href="'+link+'" target="_blank"></a>');
	}
	else if(imgIndex == 0)
	{
		if(imgIndex == (picArr.length-1))
		{	
			var image = picArr[imgIndex];
			htmlStr.append('<img width="250" height="185" src="'+image+'" style="position:absolute;top:10px;left:10px"/>');
			htmlStr.append('<div class="imgPointer" onclick="javascript:alert(\'No additional photos are available for this property\');" style="background-image:url(\'/vendor/rolodex/Images/roloLtBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;left:20px;top:172px;width:30px;height:30px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/roloLtBtn.png\', sizingMethod=\'scale\');"	/></div>');
			htmlStr.append('<div class="imgPointer" onclick="javascript:alert(\'No additional photos are available for this property\');" style="background-image:url(\'/vendor/rolodex/Images/roloRtBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;right:18px;top:172px;width:30px;height:30px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/roloRtBtn.png\', sizingMethod=\'scale\');"/></div>');
			htmlStr.append('<div class="imgPointer" onclick="hideHeroDiv();" style="background-image:url(\'/vendor/rolodex/Images/savedDelBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;left:240px;top:12px;width:20px;height:20px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/savedDelBtn.png\', sizingMethod=\'scale\');"/></div>');	
			htmlStr.append('<a id="roloDetailImg" style="background-image:url(\'/vendor/rolodex/Images/roloInfoBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;left:96px;top:177px;width:75px;height:19px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/roloInfoBtn.png\', sizingMethod=\'scale\');" href="'+link+'" target="_blank"></a>');
		}
		else
		{
			var image = picArr[0];
			htmlStr.append('<img width="250" height="185" src="'+image+'" style="position:absolute;top:10px;left:10px"/>');
			htmlStr.append('<div class="imgPointer" onclick="setHeroDiv('+(picArr.length-1)+',\''+pics+'\',\''+link+'\',\''+divId+'\')" style="background-image:url(\'/vendor/rolodex/Images/roloLtBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;left:20px;top:172px;width:30px;height:30px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/roloLtBtn.png\', sizingMethod=\'scale\');"	/></div>');
			htmlStr.append('<div class="imgPointer" onclick="setHeroDiv('+(imgIndex+1)+',\''+pics+'\',\''+link+'\',\''+divId+'\')" style="background-image:url(\'/vendor/rolodex/Images/roloRtBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;right:18px;top:172px;width:30px;height:30px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/roloRtBtn.png\', sizingMethod=\'scale\');"/></div>');
			htmlStr.append('<div class="imgPointer" onclick="hideHeroDiv();" style="background-image:url(\'/vendor/rolodex/Images/savedDelBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;left:240px;top:12px;width:20px;height:20px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/savedDelBtn.png\', sizingMethod=\'scale\');"/></div>');
			htmlStr.append('<a id="roloDetailImg" style="background-image:url(\'/vendor/rolodex/Images/roloInfoBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;left:96px;top:177px;width:75px;height:19px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/roloInfoBtn.png\', sizingMethod=\'scale\');" href="'+link+'" target="_blank"></a>');
		}
	}
	else if(imgIndex == (picArr.length-1))
	{
		var image = picArr[imgIndex];
		htmlStr.append('<img width="250" height="185" src="'+image+'" style="position:absolute;top:10px;left:10px"/>');
		htmlStr.append('<div class="imgPointer" onclick="setHeroDiv('+(imgIndex-1)+',\''+pics+'\',\''+link+'\',\''+divId+'\')" style="background-image:url(\'/vendor/rolodex/Images/roloLtBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;left:20px;top:172px;width:30px;height:30px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/roloLtBtn.png\', sizingMethod=\'scale\');"	/></div>');
		htmlStr.append('<div class="imgPointer" onclick="setHeroDiv(0,\''+pics+'\',\''+link+'\',\''+divId+'\')" style="background-image:url(\'/vendor/rolodex/Images/roloRtBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;right:18px;top:172px;width:30px;height:30px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/roloRtBtn.png\', sizingMethod=\'scale\');"/></div>');
		htmlStr.append('<div class="imgPointer" onclick="hideHeroDiv();" style="background-image:url(\'/vendor/rolodex/Images/savedDelBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;left:240px;top:12px;width:20px;height:20px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/savedDelBtn.png\', sizingMethod=\'scale\');"/></div>');	
		htmlStr.append('<a id="roloDetailImg" style="background-image:url(\'/vendor/rolodex/Images/roloInfoBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;left:96px;top:177px;width:75px;height:19px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/roloInfoBtn.png\', sizingMethod=\'scale\');" href="'+link+'" target="_blank"></a>');
	}
	else
	{
		var image = picArr[imgIndex];
		htmlStr.append('<img width="250" height="185" src="'+image+'" style="position:absolute;top:10px;left:10px"/>');
		htmlStr.append('<div class="imgPointer" onclick="setHeroDiv('+(imgIndex-1)+',\''+pics+'\',\''+link+'\',\''+divId+'\')" style="background-image:url(\'/vendor/rolodex/Images/roloLtBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;left:20px;top:172px;width:30px;height:30px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/roloLtBtn.png\', sizingMethod=\'scale\');"	/></div>');
		htmlStr.append('<div class="imgPointer" onclick="setHeroDiv('+(imgIndex+1)+',\''+pics+'\',\''+link+'\',\''+divId+'\')" style="background-image:url(\'/vendor/rolodex/Images/roloRtBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;right:18px;top:172px;width:30px;height:30px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/roloRtBtn.png\', sizingMethod=\'scale\');"/></div>');
		htmlStr.append('<div class="imgPointer" onclick="hideHeroDiv();" style="background-image:url(\'/vendor/rolodex/Images/savedDelBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;left:240px;top:12px;width:20px;height:20px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/savedDelBtn.png\', sizingMethod=\'scale\');"/></div>');
		htmlStr.append('<a id="roloDetailImg" style="background-image:url(\'/vendor/rolodex/Images/roloInfoBtn.png\');background-repeat:no-repeat;*background-image:none;cursor:pointer;*cursor:hand;position:absolute;left:96px;top:177px;width:75px;height:19px;z-index:11;*filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/vendor/rolodex/Images/roloInfoBtn.png\', sizingMethod=\'scale\');" href="'+link+'" target="_blank"></a>');
	}
	$("propHeroDiv").style.display="";
	$("propHeroDiv").innerHTML = htmlStr.toString();
}

function hideHeroDiv()
{
	if($("propHeroDiv")) $("propHeroDiv").style.display="none";
}

function getSearchCriteriaString()
{
	var searchCrtStr = '';
	if(trim(getSearchCookie('searchCriteria')) != "")
	{
		var searchCriteriaStr = trim(getSearchCookie('searchCriteria'));
		switch(searchCriteriaStr)
		{
			case 'brokeropenHome':
					searchCriteriaStr = "broker open home";
					break;	
			case 'officeListing':
					searchCriteriaStr = "office listing";
					break;		
		}
		searchCrtStr += "Only " + searchCriteriaStr +" properties having ";
	}
	else
		searchCrtStr += "Having ";
	
	if(trim(getSearchCookie('area')) != "" && trim(getSearchCookie('subNhood')) == "")
		searchCrtStr += "area surrounded by "

	if(trim(getSearchCookie('city')) != "")
		searchCrtStr += trim(getSearchCookie('city')) +", "+trim(getSearchCookie('state'));
	if(trim(getSearchCookie('zip')) != "")
		searchCrtStr += " " + trim(getSearchCookie('zip'));
		
	if(trim(getSearchCookie('neighborhood')) != "" )
	{
		if(trim(searchCrtStr) != "") searchCrtStr += " ";
		searchCrtStr += "neighborhood: " + trim(getSearchCookie('neighborhood'));
	}
		
	if(trim(getSearchCookie('subNhood')) != "")
	{
		if(trim(searchCrtStr) != "") searchCrtStr += " ";
		searchCrtStr += "sub-neighborhood: " + trim(getSearchCookie('subNhood'));
	}
	
	if(trim(getSearchCookie('address')) != "")
	{
		if(trim(searchCrtStr) != "") searchCrtStr += ", ";
		searchCrtStr += "address: " + trim(unescape(getSearchCookie('address').replace(/\|/g, ',')));
	}
	
	if(trim(getSearchCookie('minPrice')) != "")
	{
		if(trim(searchCrtStr) != "") searchCrtStr += ", ";
		searchCrtStr += "minimum price: " + trim(getSearchCookie('minPrice'));
	}
	if(trim(getSearchCookie('maxPrice')) != "")
		searchCrtStr += " and maximum price: " + trim(getSearchCookie('maxPrice'));

	if(trim(getSearchCookie('searchBeds')) != "")
	{
		if(trim(searchCrtStr) != "") searchCrtStr += ", ";
		searchCrtStr += "beds: " + trim(getSearchCookie('searchBeds'))+"+";
	}

	if(trim(getSearchCookie('searchBaths')) != "")
	{
		if(trim(searchCrtStr) != "") searchCrtStr += ", ";
		searchCrtStr += "baths: " + trim(getSearchCookie('searchBaths'))+"+";
	}

	if(trim(getSearchCookie('searchType')) != "")
	{
		if(trim(searchCrtStr) != "") searchCrtStr += ", ";
		if(trim(getSearchCookie('searchTypeText')))
			searchCrtStr += "property type: " + trim(getSearchCookie('searchTypeText'));
		else
			searchCrtStr += "property type: Any " ;

	}
	
	if(trim(getSearchCookie('minPSize')) != "")
	{
		if(trim(searchCrtStr) != "") searchCrtStr += ", ";
		searchCrtStr += "minimum sqft: " + trim(getSearchCookie('minPSize'));
	}
	if(trim(getSearchCookie('maxPSize')) != "")
		searchCrtStr += " and maximum sqft: " + trim(getSearchCookie('maxPSize'));
	
	if(trim(getSearchCookie('mlsno')) != "")
	{		
		searchCrtStr = "Having "
		searchCrtStr += "mls no: " + trim(getSearchCookie('mlsno').replace(/\,/g,", "));
		return trim(searchCrtStr);
	}
	
	if(trim(getSearchCookie('mul_nbrhood')) != "")
	{
		searchCrtStr += ", Neighborhood: " + trim(getSearchCookie('mul_nbrhood').replace(/\,/g,", "));
		return trim(searchCrtStr);
	}

	if(trim(getSearchCookie('keywordSrch')) != "")
	{
		searchCrtStr += ", Keyword having " + trim(getSearchCookie('keywordSrch'));
		return trim(searchCrtStr);
	}

	//GETTING TEMPLATE SEARCH CRITERIA
	if(typeof(getTplSearchCriteria) == "function")
	{
		var searchCrtStr1 = getTplSearchCriteria();
		if(trim(searchCrtStr1) != "") searchCrtStr += ", ";
		searchCrtStr += searchCrtStr1;
	}

	return trim(searchCrtStr);
}

function getSearchCriteriaStringForEmail()
{
	var searchCrtStr = '';
	if(trim(getSearchCookie('searchCriteria')) != "")
	{
		var searchCriteriaStr = trim(getSearchCookie('searchCriteria'));
		switch(searchCriteriaStr)
		{
			case 'brokeropenHome':
					searchCriteriaStr = "broker open home";
					break;	
			case 'officeListing':
					searchCriteriaStr = "office listing";
					break;		
		}
		searchCrtStr += "Only " + searchCriteriaStr +" properties having ";
	}
	else
		searchCrtStr += "";
	
	if(trim(getSearchCookie('area')) != "" && trim(getSearchCookie('subNhood')) == "")
		searchCrtStr += "Area surrounded by "

	if(trim(getSearchCookie('city')) != "")
		searchCrtStr += " City: " + trim(getSearchCookie('city')) +", State: "+trim(getSearchCookie('state'));
	if(trim(getSearchCookie('zip')) != "")
		searchCrtStr += ", Zip: " + trim(getSearchCookie('zip'));
		
	if(trim(getSearchCookie('neighborhood')) != "" )
	{
		if(trim(searchCrtStr) != "") searchCrtStr += " ";
		searchCrtStr += "Neighborhood: " + trim(getSearchCookie('neighborhood'));
	}
		
	if(trim(getSearchCookie('subNhood')) != "")
	{
		if(trim(searchCrtStr) != "") searchCrtStr += " ";
		searchCrtStr += "Sub-neighborhood: " + trim(getSearchCookie('subNhood'));
	}
	
	if(trim(getSearchCookie('address')) != "")
	{
		if(trim(searchCrtStr) != "") searchCrtStr += ", ";
		searchCrtStr += "Address: " + trim(unescape(getSearchCookie('address').replace(/\|/g, ',')));
	}
	
	if(trim(getSearchCookie('minPrice')) != "")
	{
		if(trim(searchCrtStr) != "") searchCrtStr += ", ";
		searchCrtStr += "Minimum price: " + trim(getSearchCookie('minPrice'));
	}
	if(trim(getSearchCookie('maxPrice')) != "")
		searchCrtStr += " and Maximum price: " + trim(getSearchCookie('maxPrice'));

	if(trim(getSearchCookie('searchBeds')) != "")
	{
		if(trim(searchCrtStr) != "") searchCrtStr += ", ";
		searchCrtStr += "Bedroom(s): " + trim(getSearchCookie('searchBeds'))+"+";
	}

	if(trim(getSearchCookie('searchBaths')) != "")
	{
		if(trim(searchCrtStr) != "") searchCrtStr += ", ";
		searchCrtStr += "Bathroom(s): " + trim(getSearchCookie('searchBaths'))+"+";
	}

	if(trim(getSearchCookie('searchType')) != "")
	{
		if(trim(searchCrtStr) != "") searchCrtStr += ", ";
		if(trim(getSearchCookie('searchTypeText')))
			searchCrtStr += "Property type: " + trim(getSearchCookie('searchTypeText'));
		else
			searchCrtStr += "Property type: Any " ;

	}
	
	if(trim(getSearchCookie('minPSize')) != "")
	{
		if(trim(searchCrtStr) != "") searchCrtStr += ", ";
		searchCrtStr += "Minimum sqft: " + trim(getSearchCookie('minPSize'));
	}
	if(trim(getSearchCookie('maxPSize')) != "")
		searchCrtStr += " and Maximum sqft: " + trim(getSearchCookie('maxPSize'));
	
	if(trim(getSearchCookie('mlsno')) != "")
	{		
		searchCrtStr = "Having "
		searchCrtStr += "Mls no: " + trim(getSearchCookie('mlsno').replace(/\,/g,", "));
		return trim(searchCrtStr);
	}

	if(trim(getSearchCookie('mul_nbrhood')) != "")
	{
		searchCrtStr += "Neighborhood: " + trim(getSearchCookie('mul_nbrhood').replace(/\,/g,", "));
		return trim(searchCrtStr);
	}

	if(trim(getSearchCookie('keywordSrch')) != "")
	{
		searchCrtStr += ", Keyword having " + trim(getSearchCookie('keywordSrch'));
		return trim(searchCrtStr);
	}

	return trim(searchCrtStr);
}


/*imageSlideShow.js*/

/***********************************************************************************************

Copyright (c) 2005 - Alf Magne Kalleland post@dhtmlgoodies.com
UPDATE LOG:
March, 10th, 2006 : Added support for a message while large image is loading
Get this and other scripts at www.dhtmlgoodies.com
You can use this script freely as long as this copyright message is kept intact.
***********************************************************************************************/ 

var displayWaitMessage=true;// Display a please wait message while images are loading?
var activeImage = false;
var imageGalleryLeftPos = false;
var imageGalleryWidth = false;
var imageGalleryObj = false;
var maxGalleryXPos = false;
var slideSpeed = 0;

var imageGalleryCaptions = new Array();
function startSlide(e)
{
	if(document.all)e = event;
	var id = this.id;	
	var leftPos = imageGalleryObj.offsetLeft;	
	//alert(leftPos+"=="+minGalleryXPos+"=="+maxGalleryXPos);
	if(this.id=='arrowsliderRight')
	{	
		if(leftPos != minGalleryXPos)
		{
			this.getElementsByTagName('IMG')[0].src = '/wt/'+bkTheme+'/images/dashboard/' + this.id + 'Over.gif';
		}
		slideSpeedMultiply = Math.floor((e.clientX - this.offsetLeft) / 5);
		slideSpeed = -1*slideSpeedMultiply;
		slideSpeed = Math.max(-10,slideSpeed);
	}
	else
	{			
		if(leftPos != 0)
		{
			this.getElementsByTagName('IMG')[0].src = '/wt/'+bkTheme+'/images/dashboard/' + this.id + 'Over.gif';			
		}
		slideSpeedMultiply = 10 - Math.floor((e.clientX - this.offsetLeft) / 5);
		slideSpeed = 1*slideSpeedMultiply;
		slideSpeed = Math.min(10,slideSpeed);
		if(slideSpeed<0)slideSpeed=10;		
	}
}

function releaseSlide()
{
var id = this.id;
this.getElementsByTagName('IMG')[0].src = '/wt/'+bkTheme+'/images/dashboard/' + this.id + '.gif';
slideSpeed=0;
}

function gallerySlide()
{	
	if(slideSpeed!=0)
	{
		var leftPos = imageGalleryObj.offsetLeft;
		leftPos = leftPos/1 + slideSpeed;
		if(leftPos>maxGalleryXPos)
		{
			leftPos = maxGalleryXPos;
			slideSpeed = 0;
		}
		if(leftPos<minGalleryXPos)
		{
			leftPos = minGalleryXPos;
			slideSpeed=0;
		}
		imageGalleryObj.style.left = leftPos + 'px';
	}
	setTimeout('gallerySlide()',50);
}

function showImage()
{
	/*if(activeImage)
		{
			activeImage.style.filter = 'alpha(opacity=50)';
			activeImage.style.opacity = 0.5;
		}
	this.style.filter = 'alpha(opacity=100)';
	this.style.opacity = 1;*/
	activeImage = this;
}

function initSlideShow_prop()
{
document.getElementById('arrowsliderLeft').onmousemove = startSlide;
document.getElementById('arrowsliderLeft').onmouseout = releaseSlide;
document.getElementById('arrowsliderRight').onmousemove = startSlide;
document.getElementById('arrowsliderRight').onmouseout = releaseSlide;

imageGalleryObj = document.getElementById('theImages');
imageGalleryLeftPos = imageGalleryObj.offsetLeft;
imageGalleryWidth = document.getElementById('galleryContainer').offsetWidth - 30;
maxGalleryXPos = imageGalleryObj.offsetLeft;
minGalleryXPos = imageGalleryWidth - document.getElementById('slideEnd').offsetLeft;

var slideshowImages = imageGalleryObj.getElementsByTagName('IMG');
for(var no=0;no<slideshowImages.length;no++)
	{
		slideshowImages[no].onmouseover = showImage;
	}
var divs = imageGalleryObj.getElementsByTagName('DIV');
for(var no=0;no<divs.length;no++)
	{
		if(divs[no].className=='imageCaption')imageGalleryCaptions[imageGalleryCaptions.length] = divs[no].innerHTML;
	}
gallerySlide();
}

function showPreview(imagePath,imageIndex)
	{
	var img = document.getElementById('propertyMainPhoto');		
	/*if(displayWaitMessage){
	document.getElementById('waitMessage').style.display='inline';
	} */

	//document.getElementById('largeImageCaption').style.display='none';
	img.onload = function() { hideWaitMessageAndShowCaption(imageIndex-1); };
	img.src ="";
	img.src = imagePath;
	img.style.width = 342;
	img.style.height = 235;
}

function hideWaitMessageAndShowCaption(imageIndex)
{
document.getElementById('waitMessage').style.display='none';
//document.getElementById('largeImageCaption').innerHTML = imageGalleryCaptions[imageIndex];
//document.getElementById('largeImageCaption').style.display='block';
}
//window.onload = initSlideShow;