function largePreview(anchorId) {
	try{
	    if(anchorId=="photoPreviewImgBid" || anchorId=="photoPreviewImgOffer"){
		var imgSrc=document.getElementById(anchorId).src;
		imgSrc1=imgSrc.replace(".X295.Y192.JPEG","");
		document.getElementById(anchorId).src=imgSrc1;		
	    }
	}catch(e){}	
	var pxTop = $("#"+anchorId).offset().top - 130;
	$("#popup_largePreview").css("top",pxTop+"px");
	$("#popup_largePreview").css("display","block");
	$("#popup_largePreview").attr("src",$("#"+anchorId).attr("src"));
	$("#popup_largePreviewX").css("top", ($("#popup_largePreview").offset().top - 23) + "px");
	$("#popup_largePreviewX").css("left", ($("#popup_largePreview").offset().left + 630) + "px");
	$("#popup_largePreviewX").css("display", "");
	$("#popup_largePreviewX").css("z-index", "999");

	$("#buyersPremiumPopup").css("display","none");
	$("#webTransactionFeesPopup").css("display","none");
	$("#depositEarnestFeesPopup").css("display","none");
	closeBidHistory();
	closePopup('#popup_zillowSingleHomeValueWidget');
	closePopup('#popup_zillowRecentlySoldHomesWidget');
	closePopup('#titlePolicyIssued');
}

function showBidHistory(listingId) 
{
var bh=AJAX("get","/"+listingId+"/getBidHistory.htm","","text/html");
var popHTML = "<div id=\"bidHistoryPopup\" style=\"position:absolute;top:110px;width:395px;left:550px;background-color:white;border:5px solid #b1bccb;\"><div class=\"popHeader2\" style=\"width:380px;\"><div style=\"float:left;\">Bid History</div><input type=\"button\" class=\"popClose\" onclick=\"javascript:closeBidHistory();\" value=\"\" /></div>";
	popHTML += "<div class=\"popArea\"><div class=\"popTitle\"><br/></div><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr style=\"background-color:#e5edf0\"><th>Date</th><th>Screen Name</th><th>Amount</th><th style=\"border-right:1px solid #777777;\">Placed By</th></tr></table><div class=\"popTitle\"><br/></div><div class=\"popFooter2\" style=\"width:395px;\"><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr><td align=\"right\" width=\"30\"><img src=\"/images/winningBid.gif\" height=\"8\" width=\"18\" /></td><td align=\"left\">Winning Bid</td><td><input type=\"button\" class=\"popFooterClose\" onclick=\"javascript:closeBidHistory();\" value=\"\" /></td></tr></table></div></div>";
	parent.document.getElementById("showBidHistory").innerHTML=popHTML;

parent.document.getElementById("buyersPremiumPopup").style.display="none";
parent.document.getElementById("webTransactionFeesPopup").style.display="none";
parent.document.getElementById("depositEarnestFeesPopup").style.display="none";
closePopup('#popup_largePreview');
closePopup('#popup_zillowSingleHomeValueWidget');
closePopup('#popup_zillowRecentlySoldHomesWidget');
closePopup('#titlePolicyIssued');
}
function closeBidHistory() {
	var sURL = document.location.href;
	if (sURL.indexOf("autopopup=historypopup") > 0) {document.location.href=$.query.remove("autopopup");}
	$("#bidHistoryPopup").remove();
}
function autoPopup() {
pageAutoPopup = true;
var sURL = document.location.href;sURL = sURL.toLowerCase();
if (sURL.indexOf("autopopup=bid") > 0) {placeOfferFrame(listingId);}
if (sURL.indexOf("autopopup=buyitnow") > 0) {buyItNow(listingId);}
if (sURL.indexOf("autopopup=openhouse") > 0) {showOpenHouse();}
if (sURL.indexOf("autopopup=askq") > 0) {detailsAskQuestion('askQuestion',propertyId,listingId);}
if (sURL.indexOf("autopopup=watchlisting") > 0) {detailsWatchListing('watchListing',propertyId,listingId);}
if (sURL.indexOf("autopopup=watchListing") > 0) {detailsWatchListing('watchListing',propertyId,listingId);}
if (sURL.indexOf("autopopup=detailsOpenHouse") > 0) {detailsOpenHouse(OpenHouse,propertyID,startDate,startTime);}
if (sURL.indexOf("autopopup=registration") > 0) {var flag="N";registerFrame(flag)}
if (sURL.indexOf("autopopup=historypopup") > 0) {showBidHistoryPopUp()}
pageAutoPopup = false;
}

function showBidHistoryPopUp()
{
	var pdpURL=document.location.href;
	var listingId=$.query.get("listingId");
	showBidHistory(listingId);
}
function resultsView(layout) {

var sURL = document.location.href;
if (sURL.indexOf("search-results.htm") > 0) {document.location.href=sURL.replace("search-results.htm",layout+"-results.htm");}
if (sURL.indexOf("photo-results.htm") > 0) {document.location.href=sURL.replace("photo-results.htm",layout+"-results.htm");}
if (sURL.indexOf("map-results.htm") > 0) {document.location.href=sURL.replace("map-results.htm",layout+"-results.htm");}
if (sURL.indexOf("search-results-coming.htm") > 0) {document.location.href=sURL.replace("search-results-coming.htm",layout+"-results-coming.htm");}
if (sURL.indexOf("photo-results-coming.htm") > 0) {document.location.href=sURL.replace("photo-results-coming.htm",layout+"-results-coming.htm");}
if (sURL.indexOf("map-results-coming.htm") > 0) {document.location.href=sURL.replace("map-results-coming.htm",layout+"-results-coming.htm");}
	trackEvent("Page Layout", layout.toProperCase().replace("Search", "List"));
}

function sendAgentEmail() {
	var agentEmail = $("#agentEmail").val();
	var agentName = $("#agentName").val();
	var listingId = $("#listingId").val();
	var leadFirstName = $("#leadFirstName").val();
	var leadLastName = $("#leadLastName").val();
	var leadName = $("#leadFirstName").val() + " " + $("#leadLastName").val();
	var leadEmail = $("#leadEmail").val();
	var leadPhone = $("#leadPhone").val();
	var leadSubject = $("#leadSubject").val();
	var leadMessage = $("#leadMessage").val();
	var leadType = $("#leadType").val();
	var leadPaymentType = $("#leadPaymentType").val();
	var message = "The following lead was submitted on GoHoming.com (or an Affiliate Web Site) related to one of your properties:||";
	message += "Listing Id: "+listingId+"|Name: "+leadName+"|Email: "+leadEmail+"|Phone: "+leadPhone+"|Message: "+leadMessage;
	message += "||Our Best,|GoHoming.com|http://www.gohoming.com||";
	var uriParam = "agentEmail="+agentEmail+"&agentName="+agentName+"&leadName="+leadName+"&leadEmail="+leadEmail+"&leadSubject="+leadSubject+"&leadMessage="+message;
	if (leadFirstName == "" || leadLastName == "" || leadEmail == "" || leadPhone == "" || leadMessage == "" || leadType == "0" || leadPaymentType == "0") {
		alert("All Fields Required");
	} else {
		var tmpAJAX = AJAX("GET", "/"+listingId+"/emailLead.htm?"+uriParam, "", "");
		if (tmpAJAX == "true") {
			$("#emailAgentArea").html("<br/>Your message was sent directly to the property listing agent and a copy has also been sent to you at "+leadEmail+".<br/><br/>You should hear back shortly.<br/><br/>Feel free to search for more properties.");
			var tmpLEAD = AJAX("GET", "/"+listingId+"/saveLead.htm?"+uriParam, "", "");
		} else {
			alert(tmpAJAX);
		}
	}
	return false;
}
function setSearchResultsFields() {
  $("#currentRefinements").html("");try{addCityCurrentRefinement()}catch(e){};try{addZipCurrentRefinement();}catch(e){}
  $.each($.query.get(), function(key, val) { if (key != "sortOrder") {setCurrentRefinements(key, val); }});
  if ($("#currentRefinements").html() == "") { $("#currentRefinementBox").css("display", "none"); }
  if ($("#availableRefinement").html() == "") { $("#availableRefinementBox").css("display", "none"); }
  var tmpStr = freeTextVal();
  if (!isNaN(tmpStr) || tmpStr.indexOf(",") > 0) { $("#zipCityStateInput").val(tmpStr.replace(/%20/g, " ")); }
	currentSort = $.query.get("sortfield");
	currentSortDirection = $.query.get("orderbydirection");
	if (currentSort.toUpperCase() == "CURRENTBID") {
		if (currentSortDirection.toUpperCase() == "ASC") {$("#currentBidSort").css("background","url('/images/sr-sort-ASC.png') bottom right no-repeat");}
		if (currentSortDirection.toUpperCase() == "DESC") {$("#currentBidSort").css("background","url('/images/sr-sort-DESC.png') bottom right no-repeat");}
	}
	if (currentSort.toUpperCase() == "TIMEREMAINING") {
		if (currentSortDirection.toUpperCase() == "ASC") {$("#timeRemainingSort").css("background","url('/images/sr-sort-ASC.png') bottom right no-repeat");}
		if (currentSortDirection.toUpperCase() == "DESC") {$("#timeRemainingSort").css("background","url('/images/sr-sort-DESC.png') bottom right no-repeat");}
	}
}
function refinementsAddMoreLink() 
{
	$("#availableRefinement").children().each(function(i) {
	 if ($(this).html() == "City") 
	 {
	    var itemCount = 1;
	    $(this).next("div").children().each(function(i) {
	      if (itemCount > 6) {
	          $(this).css("display", "none");
	      }
	      itemCount++;
	    });
	    if (itemCount > 7) 
	    {
	      $(this).next("div").append("<a id=\"showMoreCities\" href=\"javascript:refinementsShowMoreCities();\">Show More Cities...</a>");
	    }
	        
	  }
	  if ($(this).html() == "County") {
	    var itemCount = 1;
	    $(this).next("div").children().each(function(i) {
	      if (itemCount > 6) {
		  $(this).css("display", "none");
	      }
	      itemCount++;
	    });
	    if (itemCount > 7) {
	      $(this).next("div").append("<a id=\"showMoreCounties\" href=\"javascript:refinementsShowMoreCounties();\">Show More Counties...</a>");
	    }
	 	   
	 }
	 if ($(this).html() == "Agent") {
	    var itemCount = 1;
	    $(this).next("div").children().each(function(i) {
	      if (itemCount > 6) {
	          $(this).css("display", "none");
	      }
	      itemCount++;
	    });
	    if (itemCount > 7) {
	      $(this).next("div").append("<a id=\"showMoreAgents\" href=\"javascript:refinementsShowMoreAgents();\">Show More Agents...</a>");
	    }
			$(this).css("display", "none");
			$(this).next("div").css("display", "none");
	  }
	});
}
function formatRange(sRange) {var range = sRange.split("-");return formatNumber(range[0])+"-"+formatNumber(range[1]);}

function refinementsShowMoreCities() { 
	var itemCount = 1;
	$("#A2").next("div").children().each(function(i) 
	{ 
		if (itemCount =="7") {
			$(this).css("display", "block");
			$(this).css("border-top", "1px solid #ccc");
			$(this).css("margin-top", "10px");
			$(this).css("padding-top", "10px");
			
		}else{
			$(this).css("display", "block");
		}
	itemCount++;
	
		
	}); 
	$("#showMoreCities").remove(); 
}
function refinementsShowMoreCounties() { 
	var itemCount = 1;
	$("#A1").next("div").children().each(function(i) 
	{ 
		if (itemCount =="7") {
			$(this).css("display", "block");
			$(this).css("border-top", "1px solid #ccc");
			$(this).css("margin-top", "10px");
			$(this).css("padding-top", "10px");
		}else{
			$(this).css("display", "block"); 
		}
		itemCount++;
	}); 
	$("#showMoreCounties").remove(); 
}

function refinementsShowMoreAgents() { $("#A3").next("div").children().each(function(i) { $(this).css("display", "block"); }); $("#showMoreAgents").remove(); }

function setCurrentRefinements(key, value) {try {var keyDisplay = refinementLabel(key);var valDisplay = value;if(key=="financingTypes"){keyDisplay="Financing Types";}if(key=="occupancyStatus"){keyDisplay="Occupancy Status";if(valDisplay=="Y"){valDisplay="Occupied";}else{valDisplay="Vacant";}}if(key=="reserveMet"){keyDisplay="Reserve Met";} if (key=="showopenhouse") {keyDisplay="Open House"; if(valDisplay=="Y"){ valDisplay="Scheduled";} if(valDisplay=="N"){valDisplay="Not Scheduled";}} if (key=="squareFeetRange") {valDisplay=formatRange(value);} if (valDisplay=="AUCN") {valDisplay="Time Limit Offer";} if (valDisplay=="TRNL") {valDisplay="No Limit-Best Offer";} if (keyDisplay != "") {if (key == "agent") {var tmpAJAX = AJAX("GET", "/" + value + "/" + "/getAgent.htm?statecode=", "", "");valDisplay = tmpAJAX;}if (key == "maxPrice") {valDisplay="$"+addCommas(valDisplay);}if (key == "minPrice") {valDisplay="$"+addCommas(valDisplay);}$("#currentRefinements").html($("#currentRefinements").html() + "<a href=\"javascript:removeRefinement('" + key + "');\"><strong>" + keyDisplay + ":</strong> " + valDisplay.toString().replace(/\+/g," ") + "</a>");}} catch (e) { }}

function addCityCurrentRefinement() {var cityVal =$.query.get("city"); if (cityVal != "") {cityVal.replace(/%20/g, " ");$("#currentRefinements").html($("#currentRefinements").html() + "<a href=\"javascript:removeCityRefinement();\"><strong>City:</strong> " + cityVal + "</a>");}}
function addZipCurrentRefinement() {var sURL = document.location.href.replace("http://", "");if (sURL.indexOf("?") > 0) { sURL = sURL.split("?"); sURL = sURL[0].split("/"); } else { sURL = sURL.split("/"); }var zipVal = "";if (sURL.length > 3) {if (sURL[3].indexOf(".htm") == -1) { zipVal = sURL[3].replace(/%20/g, " "); }if (zipVal != "") {$("#currentRefinements").html($("#currentRefinements").html() + "<a href=\"javascript:removeZipRefinement();\"><strong>Zip Code:</strong> " + zipVal + "</a>");}}}
function getCityCurrentRefinement() {var sURL = document.location.href.replace("http://", "");if (sURL.indexOf("?") > 0) { sURL = sURL.split("?"); sURL = sURL[0].split("/"); } else { sURL = sURL.split("/"); }var cityVal = "";if (sURL[2].indexOf(".htm") == -1) { cityVal = sURL[2].replace(/%20/g, " "); }return cityVal;}
function getZipCurrentRefinement() {var sURL = document.location.href.replace("http://", "");if (sURL.indexOf("?") > 0) { sURL = sURL.split("?"); sURL = sURL[0].split("/"); } else { sURL = sURL.split("/"); }var zipVal = "";if (sURL.length > 3) {if (sURL[3].indexOf(".htm") == -1) { zipVal = sURL[3].replace(/%20/g, " "); }}return zipVal;}
function removeCityRefinement() {
	var sURL=document.location.href.replace("http://", "");
	sURL = sURL.split("/");
	var urlRef="";
	var pos="";
	for(var j=0;j<sURL.length;j++){
		if (sURL[j].indexOf(".htm") > 0){
			urlRef=sURL[j];
			pos=j;
		}
	}	
	if (urlRef.indexOf(".htm") > 0) {
		cityStrArray=urlRef.split("&");
		if(cityStrArray.length>1){			
			for(var i=0;i<cityStrArray.length;i++){
				if(cityStrArray[i].indexOf("city=")!=-1){					
					cityStrArray.splice(i,1);
					break;
				}
			}
			var tempUrl="";
			for(var i=0;i<cityStrArray.length;i++){
				if(i==cityStrArray.length-1){
					tempUrl+=cityStrArray[i];
				}else{
					tempUrl+=cityStrArray[i]+"&";
				}
			}
			if(tempUrl!=""){
				sURL[3]=tempUrl;
			}
		}
		if(pos=="1"){
			newURL = "http://" + sURL[0] + "/" +sURL[3];
		}else{
			newURL = "http://" + sURL[0] + "/" + sURL[1] + "/" +sURL[3];
		}
	} else {
		newURL = "http://" + sURL[0] + "/" + sURL[1] + "/" +sURL[4];
	}
	document.location.href = newURL;
}
function removeZipRefinement() {var sURL=document.location.href.replace("http://","");sURL=sURL.split("/");newURL="http://"+sURL[0]+ "/"+sURL[1]+"/"+sURL[2]+"/"+sURL[4];document.location.href=newURL;}
function removeRefinement(key) {var sURL=document.location.href;sURL=sURL.split("/");	
  if (key == "city") {
      var tmpURL = "";
      if (sURL[4].indexOf(".htm?") > 0) {
          tmpURL = sURL[0] + "/" + sURL[1] + "/" + sURL[2] + "/" + sURL[3] + "/" + sURL[4];
      } else {
          tmpURL = sURL[0] + "/" + sURL[1] + "/" + sURL[2] + "/" + sURL[3] + "/" + sURL[5];
      }
      document.location.href = tmpURL;
  } else {document.location.href=$.query.remove(key).set("pagenumber", "1");}
}
function changeSort() {
	trackEvent("Sort Properties", $("#sortBy").val());
	document.location.href=$.query.set("sortOrder",$("#sortBy").val()).set("pagenumber", "1");
}
function toggleSort(newSort) {
	currentSort = $.query.get("sortfield");
	currentSortDirection = $.query.get("orderbydirection");
	if (currentSortDirection.toUpperCase() == "DESC" || currentSortDirection == "") {currentSortDirection = "ASC";} else {currentSortDirection = "DESC";}
	if (newSort.toUpperCase() == "CURRENTBID") {currentSort = "currentBid";}
	if (newSort.toUpperCase() == "TIMEREMAINING") {currentSort = "timeRemaining";}
	trackEvent("Sort Properties", currentSort);
	document.location.href=$.query.set("sortfield",currentSort).set("orderbydirection",currentSortDirection).set("pagenumber", "1");
}
function addRefinement(sKey, sValue) {
  try{
  if (sKey == "city") {
    var sQUERY = $.query.remove("type").set("pagenumber", "1").set("city", sValue).set("type", "reo-properties");   
    var sURL = document.location.href;    
    sURL = sURL.split("/");
	 if (sURL[3].indexOf(".htm?") > 0) {		
	      sQUERY = sURL[3].substring(0,sURL[3].indexOf("?")) + sQUERY;
    }else if (sURL[4].indexOf(".htm?") > 0) {
	      sQUERY = sURL[4].substring(0,sURL[4].indexOf("?")) + sQUERY;
    } else if (sURL[4].indexOf(".htm") > 0) {
        sQUERY = sURL[4].substring(0,sURL[4].indexOf(".htm")+4) + sQUERY;
    } else if (sURL[5].indexOf(".htm?") > 0) {
	sQUERY = sURL[5].substring(0,sURL[5].indexOf("?")) + sQUERY;
    } else if (sURL[5].indexOf(".htm") > 0) {
        sQUERY = sURL[5].substring(0,sURL[5].indexOf(".htm")+4) + sQUERY;
    }   	    
    sValue=sValue.replace(/ /g,"-");	
	if(sURL.length<5){
    document.location.href = sURL[0] + "/" + sURL[1] + "/" + sURL[2] + "/" + sQUERY;    
	}else{
	document.location.href = sURL[0] + "/" + sURL[1] + "/" + sURL[2] + "/" + sURL[3] + "/" + sValue + "/" + sQUERY;    
	}
  } else {			
			var isOk = true;var errorTxt = "";
			if (sKey == "squareFeetRange") {sValue = sValue.replace(/,/g,"");}
			if (sKey == "minPrice") {
				var tmpVal = $.query.get("maxPrice");
				if (tmpVal != "") {if (tmpVal < sValue) {isOk = false;errorTxt = "Minimum Price must be less than Maximum Price.";}				}
			}
			if (sKey == "maxPrice") {
				var tmpVal = $.query.get("minPrice");
				if (tmpVal != "") {if (tmpVal > sValue) {isOk = false;errorTxt = "Minimum Price must be less than Maximum Price.";}				}
			}
			if (isOk) {document.location.href = $.query.remove("type").set(sKey, sValue).set("pagenumber", "1").set("type", "reo-properties");} else {alert(errorTxt);}
  }
  }catch(e){}
}
function srTypeInfoPopup(anchorId, contentId) {
	var top = $("#"+anchorId).offset().top + 20;
	$("#"+contentId).css("top",top+"px");
	$("#"+contentId).css("display","block");
}
function srTypeInfoHide(contentId) {$("#"+contentId).css("display", "none");}
function sellerInfoCall() { $("#sellerInfoCall").css("display", "block");trackEvent("Call"); }
function sellerInfoEmail() { $("#sellerInfoEmail").css("display", "block");trackEvent("Email"); }
function sellerInfoFax() { $("#sellerInfoFax").css("display", "block");trackEvent("Fax"); }

function placeOfferFrame(listingId) 
{
	showPopupFrame(590,950,30,30);
	autoRefresh=true;
	var sURLbidOffer = document.location.href;
	var search = 0;  	  
	if (sURLbidOffer.indexOf("autopopup=bid") > 0) 
	{search = sURLbidOffer.search("autopopup=bid");}
	var appendbid = "?autopopup=bid";
	if(search > 1)
	appendbid = "";
	$("#iframePopup").attr("src",pageTracker._getLinkerUrl(baseURL+"placeBid.action?domain="+baseDomain+"&listingId="+listingId+"&bidType=PlaceBid&refUrl="+escape(document.location.href)+appendbid));
}
function buyItNow(listingId) 
{
	showPopupFrame(590, 950, 30, 30);
	autoRefresh=true;
	var sURLbidOffer = document.location.href;
	var search = 0;  	  
	if (sURLbidOffer.indexOf("autopopup=buyitnow") > 0) 
	{search = sURLbidOffer.search("autopopup=buyitnow");}
	var appendbid = "?autopopup=buyitnow";
	if(search > 1)
	appendbid = "";
	$("#iframePopup").attr("src",pageTracker._getLinkerUrl(baseURL+"placeBid.action?domain="+baseDomain+"&listingId="+listingId+"&bidType=BuyNow&refUrl="+escape(document.location.href)+appendbid));
}
function viewAccessCode(pageName,propertyId,propertyState)
{
	showPopupFrame(506, 873, 30, 100);
	if(pageName=="home"){$("#iframePopup").attr("src",baseURL+"processAccessCode.action?domain="+baseDomain+"&refUrl="+escape(document.location.href));}
	if(pageName=="PDP"){$("#iframePopup").attr("src",baseURL+"processAccessCode.action?domain="+baseDomain+"&propertyId="+propertyId+"&propertyState="+propertyState+"&refUrl="+escape(document.location.href));}
}

function registerFrame(flag){
	showPopupFrame(590,950,30,30);
	autoRefresh=true;	
	if(flag=='Y'){
		$("#iframePopup").attr("src",pageTracker._getLinkerUrl(baseURL+"getUserDetailsForm.action?domain="+baseDomain+"&refUrl="+escape(document.location.href)+"?autopopup=registration"));	
	}else{
		$("#iframePopup").attr("src",pageTracker._getLinkerUrl(baseURL+"registerUser.action?domain="+baseDomain+"&refUrl="+escape(document.location.href)+"?autopopup=registration"));	
	}
}

function detailsAskQuestion(oTag,propertyId,listingId) 
{
	showPopupFrame(590, 900,$("#"+oTag).offset().top-650,$("#"+oTag).offset().left-650);
	$("#iframePopup").attr("src",pageTracker._getLinkerUrl(baseURL+"askAQuestion.action?domain="+baseDomain+"&propertyId="+propertyId+"&listingId=" + listingId + "&refUrl="+escape(document.location.href)+"?autopopup=askQ"));
	trackEvent("Ask Question");

}

function detailsOpenHouse(OpenHouse,propertyID,startDate,startTime)
{	
	showPopupFrame(590, 900,$("#"+OpenHouse).offset().top-250,$("#"+OpenHouse).offset().left-525);
	//autoRefresh=true;
	$("#iframePopup").attr("src",pageTracker._getLinkerUrl(baseURL+"attendOpenHouse.action?propertyId="+propertyID+"&openHousedate="+startDate+"&openHouseStartTime="+startTime+"&domain="+baseDomain+ "&refUrl="+escape(document.location.href)+"?autopopup=detailsOpenHouse"));
	trackEvent("Open House");
}
function detailsWatchListing(oTag,propertyId,listingId) 
{
	showPopupFrame(590, 900,$("#"+oTag).offset().top-350,$("#"+oTag).offset().left-135);
	$("#iframePopup").attr("src",pageTracker._getLinkerUrl(baseURL+"createWatch.action?domain="+baseDomain+"&propertyId="+propertyId+"&listingId=" + listingId + "&refUrl="+escape(document.location.href)+"?autopopup=watchListing"));
	trackEvent("Watch Listing");
}
function detailsWatchListingPropertyDetails(oTag,propertyId,listingId) 
{
  
	showPopupFrame(590, 900,$("#"+oTag).offset().top-650,$("#"+oTag).offset().left-525);
	$("#iframePopup").attr("src",pageTracker._getLinkerUrl(baseURL+"createWatch.action?domain="+baseDomain+"&propertyId="+propertyId+"&listingId=" + listingId + "&refUrl="+escape(document.location.href)+"?autopopup=watchListing"));
	trackEvent("Watch Listing");
}
function detailsScheduleVisit(oTag,propertyId,listingId) 
{
	showPopupFrame(380,750,$("#"+oTag).offset().top-200,$("#"+oTag).offset().left-450);
	$("#iframePopup").attr("src",pageTracker._getLinkerUrl(baseURL+"openScheduleVisitForm.action?domain="+baseDomain+"&propertyId=" + propertyId + "&listingId=" + listingId +"&refUrl="+escape(document.location.href)));
	trackEvent("Schedule Visit");
}

function detailsSendListing(oTag, propertyId, listingId) {showPopupFrame(400,510,$("#"+oTag).offset().top-350,$("#"+oTag).offset().left+10);$("#iframePopup").attr("src", "http://addthis.com/bookmark.php?v=250&amp;pub=xa-4aa7b20d54ca2f48");trackEvent("Send Listing");}
function askQuestion(oTag,propertyId,listingId) {showPopupFrame(590, 900,$(oTag).offset().top-250,$(oTag).offset().left-500);$("#iframePopup").attr("src",pageTracker._getLinkerUrl(baseURL+"askAQuestion.action?domain="+baseDomain+"&propertyId="+propertyId+"&listingId="+listingId + "&refUrl="+escape(document.location.href)));trackEvent("Ask Question");}
function scheduleVisit(oTag,propertyId,listingId) {showPopupFrame(330,650,$(oTag).offset().top-140,$(oTag).offset().left-320);$("#iframePopup").attr("src",pageTracker._getLinkerUrl(baseURL+"openScheduleVisitForm.action?domain="+baseDomain+"&propertyId="+propertyId+"&listingId="+listingId));trackEvent("Schedule Visit");}


/* function watchListing(oTag,propertyId,listingId,watchListingURL) 
{
	var watListingFullCampainURL=document.location.href;
	var watListingFullCampainURLPartOne=watListingFullCampainURL.split('?');
	if(watListingFullCampainURLPartOne[1]!=null){	
		 watchListingURL=watchListingURL+"&"+watListingFullCampainURLPartOne[1];
	}
	showPopupFrame(590, 900,$(oTag).offset().top-250,$(oTag).offset().left-500);
	$("#iframePopup").attr("src",pageTracker._getLinkerUrl(baseURL+"createWatch.action?domain="+baseDomain+"&propertyId="+propertyId+"&listingId="+listingId + "&refUrl="+escape(watchListingURL)));
	trackEvent("Watch Listing");
} */


function watchListing(oTag,propertyId,listingId,watchListingURL)  
{
	document.location.href=watchListingURL;
}


function closeOpenHouse() {$("#openHousePopup").css("display","none");}
function showOpenHouse() {$("#openHousePopup").css("display","block");}
function closePropertyFees(sDiv) {$("#"+sDiv).css("display","none");}
function showPropertyFees(sDiv) {$("#"+sDiv).css("display","block");
	switch (sDiv) {
		case "buyersPremiumPopup": trackEvent("Property Fees", "Buyer's Premium");
					   $("#webTransactionFeesPopup").css("display","none");
					   $("#depositEarnestFeesPopup").css("display","none");
					   closeBidHistory();
					   closePopup('#popup_largePreview');
					   closePopup('#popup_zillowSingleHomeValueWidget');
					   closePopup('#popup_zillowRecentlySoldHomesWidget');
					   closePopup('#titlePolicyIssued');
					   break;
		
		case "webTransactionFeesPopup": trackEvent("Property Fees", "Web Technology Fee"); 
						$("#buyersPremiumPopup").css("display","none");
						$("#depositEarnestFeesPopup").css("display","none");
						closeBidHistory();
						closePopup('#popup_largePreview');
						closePopup('#popup_zillowSingleHomeValueWidget');
						closePopup('#popup_zillowRecentlySoldHomesWidget');
						closePopup('#titlePolicyIssued');
						break;
		case "depositEarnestFeesPopup": trackEvent("Property Fees", "Deposit/Earnest Money"); 
						$("#buyersPremiumPopup").css("display","none");
						$("#webTransactionFeesPopup").css("display","none");
						closeBidHistory();
						closePopup('#popup_largePreview');
						closePopup('#popup_zillowSingleHomeValueWidget');
						closePopup('#popup_zillowRecentlySoldHomesWidget');
						closePopup('#titlePolicyIssued');
						break;
		case "titlePolicyIssued": trackEvent("Property Fees", "Title Policy Issued"); 
						$("#buyersPremiumPopup").css("display","none");
						$("#webTransactionFeesPopup").css("display","none");
						closeBidHistory();
						closePopup('#popup_largePreview');
						closePopup('#popup_zillowSingleHomeValueWidget');
						closePopup('#popup_zillowRecentlySoldHomesWidget');
						break;
		
		case "termsPopup": trackEvent("Property Fees", "Terms/Contingencies"); break;
	}
}
function closeNetOfferPercent(sDiv) {$("#"+sDiv).css("display","none");}
function showNetOfferPercent(sDiv) {$("#"+sDiv).css("display","block");}

function mortageCal(lendarsOneValue) 
{
	showPopupFrame(330,430,450,340);$("#iframePopup").attr("src",pageTracker._getLinkerUrl(baseURL+"mortgageCalculator.action?showLendersOneLink="+lendarsOneValue+"&domain="+baseDomain));trackEvent("Calculate Monthly Payment");
}

function pagerGOTO(pageNumber) { trackEvent("Pagination");document.location.href = $.query.set("pagenumber", pageNumber); }
function toggleRefinement(sPlace,sDiv,sTitle) {if ($("#"+sPlace).attr("class")=="refinementClosed") {$("#"+sPlace).attr("class","refinementOpen");trackEvent("Refinement", "Maximize " + sTitle);} else {$("#"+sPlace).attr("class","refinementClosed");trackEvent("Refinement", "Minimize " + sTitle);} $("#"+ sDiv).toggle("slow");}
function loadPropertyBuyItNow(url) {
	if(url.indexOf("?")!=-1){
	   trackEvent('Buy It Now');
	   var Full_campainURL=document.location.href;
	   var Full_campainURLPartOne=Full_campainURL.split('?');
	   if(Full_campainURLPartOne[1]!=null){
		url=url+"&"+Full_campainURLPartOne[1];
	   }	
	   document.location.href=url+"&propDetailsBySearch=Y";		
	}else{
	   document.location.href=url+"?propDetailsBySearch=Y";
	}
}
function showPopupFrame(pxHeight, pxWidth, pxTop, pxLeft, fitWidth, fitHeight) {
  /* $("body").css("overflow", "hidden"); */
  $("#WebSiteGrad").css("visibility", "visible");
  $("#WebSiteGrad").css("z-index", "998");
  $("#WebSiteGrad").css("height", "100%");
  $("#WebSiteGrad").css("width", "100%");
  $("#WebSiteGrad").css("position", "fixed");
  $("#WebSiteGrad").css("_position", "absolute");
  
  var currentScroll = getTopScroll();var maxHeight;var maxWidth;
  if (window.innerHeight == null) {
      maxHeight = document.documentElement.clientHeight;maxWidth = document.documentElement.clientWidth;
  } else {
      maxHeight = window.innerHeight;maxWidth = window.innerWidth;
  }
  /* apply rules */
  if (fitWidth == true) { 
    pxLeft = 20;maxWidth = maxWidth - 90;
  } else {
    if (pxWidth > 0) { maxWidth = pxWidth; }
  }
  if (fitHeight == true) { 
    pxTop = 30;maxHeight = maxHeight - 70;
  } else {
    if (pxHeight > 0) { maxHeight = pxHeight; }
  }
  /* make it so */
  $("#iframePopup").css("top", pxTop + "px");$("#iframePopup").css("left", pxLeft + "px");$("#iframePopup").css("width", maxWidth + "px");$("#iframePopup").css("height", maxHeight + "px");$("#iframePopup").css("visibility", "visible");
  $("#iframePopupX").css("top", (pxTop - 16) + "px");$("#iframePopupX").css("left", (pxLeft + maxWidth - 0) + "px");$("#iframePopupX").css("visibility", "visible");$("#iframePopupX").css("z-index", "999");
  $("#iframePopup").css("z-index", "999");
}
function closeFrame() {
  if (autoRefresh == true) {
    var sURL = document.location.href;
    autoRefresh = false;
    if (sURL.indexOf("autopopup=bid") > 0) {sURL = sURL.replace("autopopup=bid","");}
    if (sURL.indexOf("autopopup=watchListing") > 0) {sURL = sURL.replace("autopopup=watchListing","");}
    if (sURL.indexOf("autopopup=watchlisting") > 0) {sURL = sURL.replace("autopopup=watchlisting","");}
    
    if (sURL.indexOf("autopopup=openhouse") > 0) {sURL = sURL.replace("autopopup=openhouse","");}
    if (sURL.indexOf("autopopup=buyitnow") > 0) {sURL = sURL.replace("autopopup=buyitnow","");}
    if (sURL.indexOf("autopopup=registration") > 0) {sURL = sURL.replace("autopopup=registration","");}
    if (sURL.indexOf("autopopup=askQ") > 0) {sURL = sURL.replace("autopopup=askQ","");}
    document.location.href = sURL;
  } else {
		setUserDisplay();
  	$("body").css("overflow","auto");$("#WebSiteGrad").css("height","1px");$("#WebSiteGrad").css("visibility","hidden");$("#iframePopup").attr("src","");$("#iframePopup").css("visibility","hidden");$("#iframePopupX").css("visibility","hidden");
	}
}
function refinementLabel(key) {
  var returnVal = "";
  switch (key) {
    case "sortOrder": returnVal = "Sort"; break;
    case "beds": returnVal = "Beds"; break;
    case "baths": returnVal = "Baths"; break;
    case "listingType": returnVal = "Listing Type"; break;
    case "squareFeetRange": returnVal = "Size (Sq. Ft.)"; break;
    case "yearBuiltRange": returnVal = "Year Built"; break;
    case "minPrice": returnVal = "Minimum Price"; break;
    case "maxPrice": returnVal = "Maximum Price"; break;
    case "propertySubType": returnVal = "Property Type"; break;
    case "agent": returnVal = "Agent"; break;
    case "county": returnVal = "County"; break;
    case "propertyStatus": returnVal = "Property Status"; break;
     case "showopenhouse": returnVal = "showopenhouse"; break;
     case "financingTypes": returnVal = "financingTypes"; break;
     case "reserveMet": returnVal = "Reserve met"; break;
  }
  return returnVal;
}
function loadComparePage() {var compare=getCookie("compare");if (compare=="null") {compare="";}var compareCheck=compare.split("||");if (compareCheck.length<2) {alert("Select 2 or more properties to compare");} else {document.location.href="/compare.htm";}}
function listingCompareHTML(listing) {
    var sHTM = "<td style=\"vertical-align:top;\">";
    var qs = listing.split("&");
    var qsKEY = []; var qsVAL = [];
    for (var r = 0; r < qs.length; r++) { var tmpPair = qs[r].split("="); qsKEY[r] = tmpPair[0]; qsVAL[r] = tmpPair[1]; }
    sHTM += "<a href=\"javascript:removeCompare('" + qsVAL[$.inArray("listingid", qsKEY)] + "');\">remove</a><br />";
    sHTM += "<img src=\"" + qsVAL[$.inArray("photo", qsKEY)] + "\" alt=\"\" onerror=\"javascript:this.src='/images/no-photo.jpg';\" />";
    sHTM += qsVAL[$.inArray("address", qsKEY)] + "<br />";
    sHTM += qsVAL[$.inArray("city", qsKEY)] + ", " + qsVAL[$.inArray("state", qsKEY)] + " " + qsVAL[$.inArray("zip", qsKEY)] + "<br />";
    sHTM += "<strong>Beds:</strong>" + qsVAL[$.inArray("beds", qsKEY)] + "<br />";
    sHTM += "<strong>Baths:</strong>" + qsVAL[$.inArray("baths", qsKEY)] + "<br />";
    sHTM += "<strong>Type:</strong>" + qsVAL[$.inArray("propertytype", qsKEY)] + "<br />";
    sHTM += "<strong>Year Built:</strong>" + qsVAL[$.inArray("yearbuilt", qsKEY)] + "<br />";
    sHTM += "<strong>Sq.Ft.:</strong>" + qsVAL[$.inArray("sqft", qsKEY)] + "<br />";
    sHTM += "<strong>Listing Price:</strong>" + qsVAL[$.inArray("listingprice", qsKEY)] + "<br />";
    sHTM += "<strong>Fireplace:</strong>" + qsVAL[$.inArray("fireplace", qsKEY)] + "<br />";
    sHTM += "<strong>Deck/Patio:</strong>" + qsVAL[$.inArray("deckpatio", qsKEY)] + "<br />";
    sHTM += "<strong>HOA Dues:</strong>" + qsVAL[$.inArray("hoadues", qsKEY)] + "<br />";
    sHTM += "<strong>County:</strong>" + qsVAL[$.inArray("county", qsKEY)] + "<br />";
    sHTM += "<strong>Highest Bid:</strong>" + qsVAL[$.inArray("highestbid", qsKEY)] + "<br />";
    sHTM += "<strong>Auction End Date:</strong>" + qsVAL[$.inArray("auctionenddate", qsKEY)] + "<br />";
    sHTM += "<strong>MLS#:</strong>" + qsVAL[$.inArray("mls", qsKEY)] + "<br />";
    sHTM += "<strong>Description:</strong>" + qsVAL[$.inArray("description", qsKEY)] + "<br />";
    sHTM += "<a href=\"" + qsVAL[$.inArray("url", qsKEY)] + "\">View Details</a><br />";
    sHTM += "</td>";
    return sHTM;
}
function addCompare(compareId,valueSet) {
if(valueSet==1){
	var compare=setCookie("compare", "", 1);
}else{
  var autoLoadCompare = false;
  var compare = getCookie("compare");
  if (compare == "null") { compare = ""; }
  var checkIt = $("#" + compareId);
  var listingId = compareId.substring(8);
  var compareCheck = compare.split("||");
  var compareCount = compareCheck.length;
  if (checkIt.attr("checked") == true) {
  if (compareCount <= 3) {
  if (compare.indexOf("|" + listingId + "|") == -1) { compare += "|" + listingId + "|"; }
  } else {
  $("#" + compareId).attr("checked", false);
  autoLoadCompare = true;
  }
  } else {
  if (compare.indexOf("|" + listingId + "|") > -1) { compare = compare.replace("|" + listingId + "|", ""); }
  }
  setCookie("compare", compare, 1);
  //if (autoLoadCompare == true) { document.location.href = "/compare.htm"; }
}
}
function removeCompare(listingId) {var compare=getCookie("compare");if (compare=="null") {compare="";}compare=compare.replace("|"+listingId+"|","");setCookie("compare",compare,1);document.location.href="/compare.htm";}
function loadCompareFromCookie() {
  var sHTML = "<h1>No Properties to compare</h1>";
  var compare = getCookie("compare");
  if (compare == "null") { compare = ""; }
  if (compare != "") {
    var compareCheck = [];
    if (compare.indexOf("||") > 0) {
      compareCheck = compare.split("||");
    } else {
      compareCheck[0] = compare;
    }
    sHTML = "<table><tr>";
    for (var x = 0; x < compareCheck.length; x++) {
        var listing = AJAX("get", "/" + compareCheck[x].replace(/\|/g, "") + "/getListing.htm", "", "text/html");
        listing = listing.replace(/~/g, "&").replace(/\n/g, "");
        sHTML += listingCompareHTML(listing);
    }
    sHTML += "</tr></table>";
  }
  $("#compareListings").html(sHTML);
}
function saveSearch() 
{
     trackEvent("Save");
     var offsetTop = $(".saveSearch").offset().top - 450;
     if (offsetTop < 40) {offsetTop = 40;}
     showPopupFrame(590, 900, offsetTop, $(".saveSearch").offset().left + 40);
     saveSearchQuery = "";
     var sURL = document.location.href;
     sURL = sURL.split("/");
      try{
           if(sURL[3].indexOf(".htm") < 0){
               saveSearchQuery += "&statecode="+sURL[3];
            }
            }catch(e){}
  try{
           var currentCity = getCityCurrentRefinement();
            //if (currentCity != "") {saveSearchQuery += "&city=" + currentCity;}
            }catch(e){}
   try{
           var currentZip = getZipCurrentRefinement();
            if (currentZip != "") {saveSearchQuery += "&zip=" + currentZip;}
  }catch(e){}
  $.each($.query.get(), function(key, val) { saveSearchQuery += "&" + key + "=" + val; });
  $("#iframePopup").attr("src", pageTracker._getLinkerUrl(baseURL + "createSaveSearchAction.action?domain="+baseDomain+saveSearchQuery+"&refUrl="+escape(document.location.href)));
}

function closePopup(popupKey) {$(popupKey).css('display','none');$(popupKey+"X").css("display", "none");$("#WebSiteGrad").css("height","1px");$("#WebSiteGrad").css("visibility","hidden");}
function addCommas(nStr) {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 loadStandardMessagePopup() {
  $("#WebSiteGrad").css("visibility", "visible");$("#WebSiteGrad").css("z-index", "998");$("#WebSiteGrad").css("height", "2000px");
	$("#standardMessage").css("width","800px");
	$("#standardMessage").css("height","283px");
	$("#standardMessage").css("position","absolute");
	$("#standardMessage").css("top","70px");
	$("#standardMessage").css("left","100px");
	$("#standardMessage").css("display","");
	$("#standardMessage").css("z-index","999");
}

function popup_zillowSingleHomeValueWidget(aPoint) 
{

	$("#popup_zillowSingleHomeValueWidget").css("width","302px");
	$("#popup_zillowSingleHomeValueWidget").css("height","406px");
	$("#popup_zillowSingleHomeValueWidget").css("position","absolute");
	$("#popup_zillowSingleHomeValueWidget").css("top",($(aPoint).offset().top - 380) + "px");
	$("#popup_zillowSingleHomeValueWidget").css("left",($(aPoint).offset().left - 30) + "px");
	$("#popup_zillowSingleHomeValueWidget").css("display","");
	$("#popup_zillowSingleHomeValueWidgetX").css("top", ($("#popup_zillowSingleHomeValueWidget").offset().top - 15) + "px");
	$("#popup_zillowSingleHomeValueWidgetX").css("left", ($("#popup_zillowSingleHomeValueWidget").offset().left + 297) + "px");
	$("#popup_zillowSingleHomeValueWidgetX").css("display", "");
	$("#popup_zillowSingleHomeValueWidgetX").css("z-index", "999");

	$("#buyersPremiumPopup").css("display","none");
	$("#webTransactionFeesPopup").css("display","none");
	$("#depositEarnestFeesPopup").css("display","none");
	closePopup('#popup_largePreview');
	closeBidHistory();
	closePopup('#popup_zillowRecentlySoldHomesWidget');
	closePopup('#titlePolicyIssued');
}

function popup_zillowRecentlySoldHomesWidget(aPoint) 
{
	$("#popup_zillowRecentlySoldHomesWidget").css("width","160px");
	$("#popup_zillowRecentlySoldHomesWidget").css("height","378px");
	$("#popup_zillowRecentlySoldHomesWidget").css("position","absolute");
	$("#popup_zillowRecentlySoldHomesWidget").css("top",($(aPoint).offset().top - 350) + "px");
	$("#popup_zillowRecentlySoldHomesWidget").css("left",($(aPoint).offset().left - 0) + "px");
	$("#popup_zillowRecentlySoldHomesWidget").css("display","");
	$("#popup_zillowRecentlySoldHomesWidgetX").css("top", ($("#popup_zillowRecentlySoldHomesWidget").offset().top - 15) + "px");
	$("#popup_zillowRecentlySoldHomesWidgetX").css("left", ($("#popup_zillowRecentlySoldHomesWidget").offset().left + 157) + "px");
	$("#popup_zillowRecentlySoldHomesWidgetX").css("display", "");
	$("#popup_zillowRecentlySoldHomesWidgetX").css("z-index", "999");

	$("#buyersPremiumPopup").css("display","none");
	$("#webTransactionFeesPopup").css("display","none");
	$("#depositEarnestFeesPopup").css("display","none");
	closePopup('#popup_largePreview');
	closeBidHistory();
	closePopup('#popup_zillowSingleHomeValueWidget');
	closePopup('#titlePolicyIssued');

}
/* Google Maping code */
var geocoder;
var map;
var myPano;
var markerBounds = null;
var infowindowLevel = 0;
function stateBrowsePathMap() {
    geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var myOptions = { mapTypeId: google.maps.MapTypeId.ROADMAP };
    map = new google.maps.Map(document.getElementById("statePageMap"), myOptions);
    for (var x = 0; x < browsePathCityState.length; x++) {
        var newMarker = codeAddress(browsePathCityState[x], true);
    }
}
function searchResultsMap() {
    geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var myOptions = { mapTypeId: google.maps.MapTypeId.ROADMAP };
    map = new google.maps.Map(document.getElementById("searchResultsPageMap"), myOptions);
    for (var x = 0; x < searchResultsAddress.length; x++) {
        var newMarker = codeAddress(searchResultsAddress[x], true);
    }
}

function handleNoFlash(errorCode) {
	if (errorCode == 600) {
		// document.getElementById("detailsPageMap").innerHTML = "<br /><br /><b><h2 style='padding-left:15px;'>Street View data does not exist for this address.</h2></b>";
		return;
	}
  if (errorCode == FLASH_UNAVAILABLE) {
    alert("Error: Flash doesn't appear to be supported by your browser");
    return;
  }
}
function propertyDetailsMap() {
    if (propertyDetailsLAT != null && propertyDetailsLONG != null) {
        var latlng = new google.maps.LatLng(propertyDetailsLAT, propertyDetailsLONG);
        var myOptions = { zoom: 11, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP };
        map = new google.maps.Map(document.getElementById("detailsPageMap"), myOptions);
    } else if (propertyADDRESS != null) {
        geocoder = new google.maps.Geocoder();
        var latlng = new google.maps.LatLng(-34.397, 150.644);
        var myOptions = { zoom: 11, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP };
        map = new google.maps.Map(document.getElementById("detailsPageMap"), myOptions);
        var x = codeAddress(propertyADDRESS, false);
    } else {
        alert("Address or Lat/Long required to map property");
    }
}
function codeAddress(data, autoZoom) {
    var returnLatLng;
    dataItems = data.split("|");
    address = dataItems[0];
    if (geocoder) {
        geocoder.geocode({ 'address': address }, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
                    map.setCenter(results[0].geometry.location);
                    var marker = new google.maps.Marker({
                        map: map,
                        position: results[0].geometry.location,
                        title: address,
                        icon: (dataItems.length == 2) ? "" : "/images/map-marker.gif"
                    });
                    if (autoZoom == true) {
                      /* Create the markerBounds object starting with the first marker */
                      if (markerBounds == null)
                      {
                        markerBounds = new google.maps.LatLngBounds(marker.getPosition(), marker.getPosition()); 
                      }  
                      markerBounds.extend(marker.getPosition());
                      map.fitBounds(markerBounds); 
                      attachInfowindow(marker, data);
                      returnLatLng = marker.getPosition().toString();
                    }
                } else {
                    /* alert("No results found"); */
                }
            } else {
                /* alert("Geocode was not successful for the following reason: " + status); */
            }
        });
    } else {
        /* alert("Missing geocoder object."); */
    }
    //return returnLatLng;
}
function attachInfowindow(marker, data) {
	var infowindow;
  dataItems = data.split("|");
	if (dataItems.length == 2) {
	  infowindow = new google.maps.InfoWindow(
	    { content: 
	        dataItems[0] +
					"<br /><a href=\"" + dataItems[1] + "\">View " + dataItems[0] + " search results</a>"
	    });
	} else {
	  infowindow = new google.maps.InfoWindow(
	    { content: 
	        "<a class=\"srViewListing\" href=\"" + dataItems[7] + "\"><!-- --></a>" +
	        "<br/><b>#</b> " + dataItems[8] +
	        "<br/><b>Address:</b> " + dataItems[0] +
	        "<br/><b>Property ID:</b> " + dataItems[1] +
	        "<br/><b>MLS #:</b> " + dataItems[2] + 
	        "<br/>" + dataItems[3] +
	        "<br/>" + dataItems[4] + " Beds, " + dataItems[5] + " Baths" +
	        "<br/><b>Listing Date:</b> " + dataItems[6]
	    });
	}
  google.maps.event.addListener(marker, 'click', function() { infowindow.zIndex = infowindowLevel++; infowindow.open(map, marker); });
}

function TabChangeList(obj)
{
	var url=location.href;		
	var appendQueryString='';
	if (document.getElementById(obj).className.indexOf('On') == -1)
	{
		document.getElementById(obj).className = obj + 'On';
		if (curTab != '')
		{
			document.getElementById(curTab).className = curTab;
		}
		if(obj=='comingSoonTab')
		{	
			appendQueryString=$.query.set("pagenumber", "1").set("phase", "Coming");
			location.href="search-results-coming.htm"+appendQueryString;
			
		}		
		if(obj=='currentTab')
		{
			appendQueryString=$.query.remove("phase").set("pagenumber", "1");
			location.href="search-results.htm"+appendQueryString;
			
		}
		curTab = obj;
	}
	
}
function TabChangePhoto(obj)
{
	var url=location.href;
	var appendQueryString='';	
	if (document.getElementById(obj).className.indexOf('On') == -1)
	{
		document.getElementById(obj).className = obj + 'On';
		if (curTab != '')
		{
			document.getElementById(curTab).className = curTab;
		}
		if(obj=='comingSoonTab')
		{
			appendQueryString=$.query.set("pagenumber", "1").set("phase", "Coming");
			location.href="photo-results-coming.htm"+appendQueryString;
			
		}		
		if(obj=='currentTab')
		{
			appendQueryString=$.query.remove("phase").set("pagenumber", "1");
			location.href="photo-results.htm"+appendQueryString;			
		}
		curTab = obj;
	}
	
}
function TabChangeMap(obj)
{
	var url=location.href;
	var appendQueryString='';	
	if (document.getElementById(obj).className.indexOf('On') == -1)
	{
		document.getElementById(obj).className = obj + 'On';
		if (curTab != '')
		{
			document.getElementById(curTab).className = curTab;
		}
		if(obj=='comingSoonTab')
		{			
			appendQueryString=$.query.set("pagenumber", "1").set("phase", "Coming");			
			location.href="map-results-coming.htm"+appendQueryString;			
		}		
		if(obj=='currentTab')
		{			
			appendQueryString=$.query.remove("phase").set("pagenumber", "1");
			location.href="map-results.htm?"+appendQueryString;			
		}
		curTab = obj;
	}
	
}
function changeUrlBasedOnPropCount(activeCount,comingSoonCount){	
	var url=location.href;
	var appendQueryString='';
	var pos=url.indexOf('?');
	if(pos!=-1){
		queryString=url.split('?');
		appendQueryString=queryString[1];
	}
	
	if(activeCount==0 && comingSoonCount>0){
		var pos=appendQueryString.indexOf('&');
		if(pos==0){
			appendQueryString=appendQueryString.replace('&','');
		}		
		location.href="search-results-coming.htm?phase=Coming&"+appendQueryString;			
	}
}

