var urlroot = 'http://www.centercityrealestate.com/propsearch';

var zipCode = '';

var mls = '';

var keyword = '';

var priceMin = 0;

var priceMax = 5000000;

var bedrooms = '';

var baths = '';

var parking = '';

var sqft = '';

var nList = new Array();

var nListID = new Array();

var neighborhoods = '';

var styles = '';

var ptype = '';

var age = '';

var basement = '';

var exclusive = '';

var havePhoto = '';

var haveOpenHouse = '';

var ownership = '';

var newListings = '';

var garage = '';

var ac = '';

var waterfront = '';

var fireplace = '';

var page = 0;

var flashReady = 0;

var sortBy ='flistdate desc';

var sqftLow =0;

var sqftHigh=10000;

var sqftFrom = '';

var sqftTo = '';

var streetSearch = '';

var sortDiv = new Array();

var nCount = 0;

var me;

var photoDir = 'http://www.centercityrealestate.com/prop_pics/';

var defaultLatitude = '39.953492';

var defaultLongitude = '-75.164192';

var nHoodList = new Array();

var swfID = "hoodFlash";

var smallSwfID = "smallMap";

var chks = new Array();

var lastaction = 'newPage';

var legal = 0;

var viewMode = 'normal';

var realtorImages = ['realtor_adam.jpg', 'realtor_antonio.jpg', 'realtor_dave.jpg', 'realtor_karoline.jpg', 'realtor_stephanie.jpg', 'realtor_aaron.jpg', 'realtor_jaclyn.jpg', 'realtor_terry.jpg', 'realtor_jenn.jpg'];

var curRealtor = 0;

var curTab = 'tabConsultants';

var curTabOn = 'consultantsTab';

var searchType = 'normal';

var searchData = new Array();

searchData['normal'] = new Array();

searchData['favorite'] = new Array();

searchData['recent'] = new Array();

searchData['default'] = new Array();





//Tab Switching JS

function switchSearch(w) {

	saveState(searchType);

	searchType=w;

	$('searchTabs').className='st' + w;

	$('btnfavorite').style.color="#FFFFFF";

	$('btnrecent').style.color="#FFFFFF";

	$('btnnormal').style.color="#FFFFFF";

	$('btn' + w).style.color="#669933";

	if (searchData[searchType]['zipCode']!='') {

		processSearch(searchData[searchType]);

	} else {

		updateListings();

	}

}



function getID(){

     /*if(navigator.appName.indexOf("Microsoft") != -1){

          flashMovie = window[swfID];

		  

     }else{

          flashMovie = document[swfID];

     }*/

/*

	 

     if(navigator.appName.indexOf("Microsoft") != -1){

          smallFlashMovie = window[smallSwfID];

		  

     }else{

          smallFlashMovie = document[smallSwfID];

     }	

*/ 

}





function js_to_as( str, checkedStatus, checkedName ){

     //flashMovie.communicate( str, checkedStatus, checkedName );

	 js_to_small_fs( str, checkedStatus, checkedName );

}



function js_to_small_fs( str, checkedStatus, checkedName ) {

	/*  smallFlashMovie.miniMapCommunicate( str, checkedStatus, checkedName );	 */

}



function initImage() {

  imageId = 'realtorImage';

  image = document.getElementById(imageId);

  setOpacity(image, 0);

  image.style.visibility = 'visible';

  fadeIn(imageId,0);

}



function setOpacity(obj, opacity) {

  opacity = (opacity == 100)?99.999:opacity;

  

  // IE/Win

  obj.style.filter = "alpha(opacity:"+opacity+")";

  

  // Safari<1.2, Konqueror

  obj.style.KHTMLOpacity = opacity/100;

  

  // Older Mozilla and Firefox

  obj.style.MozOpacity = opacity/100;

  

  // Safari 1.2, newer Firefox and Mozilla, CSS3

  obj.style.opacity = opacity/100;

}



/*

function fadeIn(objId,opacity) {

  if (document.getElementById) {

    obj = document.getElementById(objId);

    if (opacity <= 100) {

      setOpacity(obj, opacity);

      opacity += 10;

      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);

    }

	else {

			document.getElementById("realtorImagea").style.backgroundImage = 'url(http://' + location.host + '/images/agents/' + realtorImages[previousHood] + ')';		

	}

  }

}

*/



function slideOut(w) {

	fxthis=document.getElementById(w);



	var fx = new Fx.Styles(fxthis, {duration:700, wait:false});



	fx.start({

		'height': '0px'

	});

}



function slideIn(w) {

	fxthis=document.getElementById(w);



	var fx = new Fx.Styles(fxthis, {duration:700, wait:false});



	fx.start({

		'height': '90px'

	});

}





function tabOn(w) {

	$(w).className='tabOn';

}



function tabOff(w) {

	if (w!=curTabOn) {

	$(w).className='tabOff';

	}

}



function realtorTimer() {



/* 	alert('hi'); */

/*

			document.getElementById("realtorImagea").style.backgroundImage = 'url(http://' + location.host + '/images/agents/' + realtorImages[previousHood] + ')';

			initImage();

			previousHood=currentHood;

			

			if (currentHood <= 11) {

				currentHood++;

			}

			else {

				currentHood=0;

			}

*/

	

	$("realtorPicka").style.backgroundImage = 'url(http://' + location.host + '/images/agents/' + realtorImages[curRealtor] + ')';

	$("realtorPicka").style.height="90px";

	

	if (curRealtor <= 7) {

		curRealtor++;

	}

	else {

		curRealtor=0;

	}

	

	$("realtorPickb").style.backgroundImage = 'url(http://' + location.host + '/images/agents/' + realtorImages[curRealtor] + ')';

	slideOut("realtorPicka");

	

	t=setTimeout("realtorTimer()",10000);

}



function load(lat,long) {

	loadMap(defaultLatitude,defaultLongitude);

	saveState('default');

	loadCheckBoxes();

	getSavedSearches();

	getID();

	

	if ($("realtorPicka")) {

	realtorTimer();

	}

	

	var styleSlider = new Fx.Slide('styleDiv', {duration: 500, transition: Fx.Transitions.linear});

	var priceSlider = new Fx.Slide('priceDiv', {duration: 500});

	var sqftSlider = new Fx.Slide('sqftDiv', {duration: 500});

	var ageSlider = new Fx.Slide('ageDiv', {duration: 500});

	var bedsSlider = new Fx.Slide('bedsDiv', {duration: 500});

	
	var bathsSlider = new Fx.Slide('bathsDiv', {duration: 500});

	var typeSlider = new Fx.Slide('typeDiv', {duration: 500});

	var addrSlider = new Fx.Slide('addrDiv', {duration: 500});	

	var ltypeSlider = new Fx.Slide('listingTypeDiv', {duration: 500});		

	var featuresSlider = new Fx.Slide('featuresDiv', {duration: 500});

	var descSlider = new Fx.Slide('descDiv', {duration: 500});

		

	//hoodsSlider = new Fx.Slide('popHoodsDiv', {duration: 500});	

	zipSlider = new Fx.Slide('zipDiv', {duration: 500});	

	mlsSlider = new Fx.Slide('mlsDiv', {duration: 500});	

	nhSlider = new Fx.Slide('nhDiv', {duration: 500});	



	sqftSlider.hide();

	ihtml=document.getElementById('sqftToggle').innerHTML;

	ihtml = ihtml.replace('down','side');		

	document.getElementById('sqftToggle').innerHTML = ihtml;	


	featuresSlider.hide();

	ihtml=document.getElementById('featuresToggle').innerHTML;

	ihtml = ihtml.replace('down','side');		

	document.getElementById('featuresToggle').innerHTML = ihtml;


	ageSlider.hide();

	ihtml=document.getElementById('ageToggle').innerHTML;

	ihtml = ihtml.replace('down','side');		

	document.getElementById('ageToggle').innerHTML = ihtml;	



	styleSlider.hide();	

	ihtml=document.getElementById('styleToggle').innerHTML;

	ihtml = ihtml.replace('down','side');		

	document.getElementById('styleToggle').innerHTML = ihtml;



	/*

	var node = dojo.byId("someId");	

	var obj = {

		thinger: function(arg1, arg2){

		},

		goDrinking: function(whatToDrink){

			console.debug("I'm drinking:", whatToDrink);

		}

	}



	dojo.connect(obj, "thinger", obj, "goDrinking");

	

	obj.thinger("gin!");

	

	dojo.connect(node, "onclick", obj, "thinger");

	// obj.addEventListener("thinger", function(){ ... });



	*/

		

	if (!document.all) {

		document.getElementById("priceToggle").addEventListener("click",function () {  toggle('priceDiv','priceToggle',priceSlider); },false);	

		document.getElementById("sqftToggle").addEventListener("click",function () {  toggle('sqftDiv','sqftToggle',sqftSlider); },false);	

		document.getElementById("ageToggle").addEventListener("click",function () { toggle('ageDiv','ageToggle',ageSlider); },false);	

		

				
				

		document.getElementById("bedsToggle").addEventListener("click",function () { toggle('bedsDiv','bedsToggle',bedsSlider); },false);		

		document.getElementById("bathsToggle").addEventListener("click",function () { toggle('bathsDiv','bathsToggle',bathsSlider); },false);		

		//	document.getElementById("mapToggle").addEventListener("click",function () { toggle('mapDiv'); },false);	

		document.getElementById("typeToggle").addEventListener("click",function () { toggle('typeDiv','typeToggle',typeSlider); },false);	

		document.getElementById("styleToggle").addEventListener("click",function () { toggle('styleDiv','styleToggle',styleSlider); },false);	

		document.getElementById("featuresToggle").addEventListener("click",function () { toggle('featuresDiv','featuresToggle', featuresSlider); },false);

		//document.getElementById("hoodsToggle").addEventListener("click",function () { toggle('popHoodsDiv','hoodsToggle',hoodsSlider); },false);	

		document.getElementById("zipToggle").addEventListener("click",function () { toggle('zipDiv','zipToggle',zipSlider); },false);	

		document.getElementById("mlsToggle").addEventListener("click",function () { toggle('mlsDiv','mlsToggle',mlsSlider); },false);			

		document.getElementById("nhToggle").addEventListener("click",function () { toggle('nhDiv','nhToggle',nhSlider); },false);	

		document.getElementById("addrToggle").addEventListener("click",function () { toggle('addrDiv','addrToggle',addrSlider); },false);		

		document.getElementById("listingTypeToggle").addEventListener("click",function () { toggle('listingTypeDiv','listingTypeToggle',ltypeSlider); },false);	

		document.getElementById("descToggle").addEventListener("click",function () { toggle('descDiv','descToggle',descSlider); },false);			

	} else {

		document.getElementById("priceToggle").attachEvent("onclick",function () {  toggle('priceDiv','priceToggle',priceSlider); });	

		document.getElementById("sqftToggle").attachEvent("onclick",function () {  toggle('sqftDiv','sqftToggle',sqftSlider); });	

		document.getElementById("ageToggle").attachEvent("onclick",function () { toggle('ageDiv','ageToggle',ageSlider); });	

		

		

		

		document.getElementById("bedsToggle").attachEvent("onclick",function () { toggle

('bedsDiv','bedsToggle',bedsSlider); });		

		document.getElementById("bathsToggle").attachEvent("onclick",function () { toggle('bathsDiv','bathsToggle',bathsSlider); });		

		//	document.getElementById("mapToggle").addEventListener("click",function () { toggle('mapDiv'); });	

		document.getElementById("typeToggle").attachEvent("onclick",function () { toggle('typeDiv','typeToggle',typeSlider); });	

		document.getElementById("styleToggle").attachEvent("onclick",function () { toggle('styleDiv','styleToggle',styleSlider); });	

		document.getElementById("featuresToggle").attachEvent("onclick",function () { toggle('featuresDiv','featuresToggle', featuresSlider); });

		//document.getElementById("hoodsToggle").addEventListener("click",function () { toggle('popHoodsDiv','hoodsToggle',hoodsSlider); });	

		document.getElementById("zipToggle").attachEvent("onclick",function () { toggle('zipDiv','zipToggle',zipSlider); });	

		document.getElementById("mlsToggle").attachEvent("onclick",function () { toggle('mlsDiv','mlsToggle',mlsSlider); });	

		document.getElementById("nhToggle").attachEvent("onclick",function () { toggle('nhDiv','nhToggle',nhSlider); });	

		document.getElementById("addrToggle").attachEvent("onclick",function () { toggle('addrDiv','addrToggle',addrSlider); });		

		document.getElementById("listingtypeToggle").attachEvent("onclick",function () { toggle('listingTypeDiv','listingTypeToggle',ltypeSlider); });		

		document.getElementById("descToggle").attachEvent("onclick",function () { toggle('descDiv','descToggle',descSlider); });		

	}



	//document.getElementById("modalBox").addEventListener("click",function () { nModalToggleOff(); },false)



	syncSmallMap();

	if (loadSearch!=0) {

		getSearch(loadSearch);

	} else { 

		getSearchSession();

		//updateListings();

	}

	

}



function syncSmallMap() {

/*

	if ((flashReady==1) && (smallFlashMovie)) {

		for (x=0;x<chks.length;x++) {

				//alert(chks[x]);

				js_to_small_fs(chks[x],true,'');

		}

	} else {

		window.setTimeout("syncSmallMap", 1000);

	}

*/

}



function updateOnReturn(e) {

		if (window.event) {

			if (e.keyCode==13) updateListings();			

		} else {

			if (e.which==13) updateListings();

		}

}



function updateZipOnReturn(e) {

		if (window.event) {

			if (e.keyCode==13) updateZipcode();

		} else {

			if (e.which==13) updateZipcode();

		}

}



function nModalToggle(e) {

	//document.getElementById("hoodBreakdown").style.visibility="hidden";

	//document.getElementById("hoodBreakdown").style.left= "-50px";

	/*m = document.getElementById("modalBox");

	w = document.getElementById("whiteBox");

	m.style.height=document.body.clientHeight + 'px';

	w.style.top='20px';

	w.style.left='20px';	

	w.style.height=(getWindowHeight() - 40) + 'px';	

	w.style.width=(getWindowWidth() - 40) + 'px';	

	m.style.zIndex = 200;	

	m.style.visibility = "visible";

	m.style.display = "block";	*/

}



function nModalToggleOff() {

	document.getElementById("hoodBreakdown").style.visibility="visible";	

	m = document.getElementById("modalBox");

	m.style.visibility = "hidden";

	m.style.zIndex = -200;

	updateListings();

}

function modalFlashReady() {

	flashReady = 1;	

	return chks;

}

function loadCheckBoxes() {

	chkboxes=document.getElementsByTagName("input");

	for (x=0;x<chkboxes.length;x++) {

		if (chkboxes[x].type=='checkbox') {

			if (chkboxes[x].checked==true) {

				if (chkboxes[x].id.indexOf('nac') != -1) chks.push(chkboxes[x].id);

				//document.getElementById(chkboxes[x].id + '_img').src='images/chk_on.png';

			}

			//document.write(document.getElementById(chkboxes[x].id + '_img').src);

			//document.write(chkboxes[x].name);

		}

	}

}



function checkChildren(first, last, parent) {

	var PlsCheck='';

	var boxes=document.getElementsByName("hoodBoxes");

	pnt=document.getElementById('pac' + parent + '_img');

	switch (pnt.src) {

			case urlroot + "/images/chk_off.png": pnt.src=urlroot + "/images/chk_on.png"; break;

			case urlroot + "/images/chk_on.png":  pnt.src=urlroot + "/images/chk_off.png";  break;			

	}

	for(x=0;x<boxes.length;x++) {

		if (boxes[x].id=='nac' + first) { PlsCheck=1; }

		if (PlsCheck==1) {

			i=boxes[x].id;

			v=document.getElementById(i + '_img');

			box=document.getElementById(i);

			switch (pnt.src) {

					case urlroot + "/images/chk_off.png": v.src=urlroot + '/images/chk_off.png'; box.checked=false; break;

					case urlroot + "/images/chk_on.png": v.src=urlroot + '/images/chk_on.png'; box.checked=true; break;			

			}

			js_to_as(i, box.checked, box.value);

		}

		if (boxes[x].id=='nac' + last) { PlsCheck=0; }		

	}

}





function selectAllHoods(first,last,status) {

	var boxes=document.getElementsByName("hoodBoxes");

	for(x=0;x<boxes.length;x++) {

		if (boxes[x].id=='nac' + first) { PlsCheck=1; }

		if (PlsCheck==1) {

			i=boxes[x].id;

			box=document.getElementById(i);

			if (status=="off") {

				box.checked=false;

			} else {

				box.checked=true;		

			}

			js_to_as(i, box.checked, box.value);

		}

		if (boxes[x].id=='nac' + last) { PlsCheck=0; }

	}

}





function getElementsByClass(searchClass,node,tag) {

	var classElements = new Array();

	if ( node == null )

		node = document;

	if ( tag == null )

		tag = '*';

	var els = node.getElementsByTagName(tag);

	var elsLen = els.length;

	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");

	for (i = 0, j = 0; i < elsLen; i++) {

		if ( pattern.test(els[i].className) ) {

			classElements[j] = els[i];

			j++;

		}

	}

	return classElements;

}





function toggle(v,f,s) {

	//heres the thing

	//Effect.toggle(v, 'blind');

	s.toggle();

	setTimeout ( function () {

		ihtml=document.getElementById(f).innerHTML;

		if (ihtml.indexOf('down')>-1) {

			ihtml = ihtml.replace("down","side");

		} else {

			ihtml = ihtml.replace('side','down');		

		}

		document.getElementById(f).innerHTML = ihtml;	

	},510 );		

}



function nToggle() {

		if (document.getElementById("hoodPanel").style.display=='block') { 

				document.getElementById("hoodPanel").style.zIndex = -1; document.getElementById("hoodPanel").style.display = 'none';

			} else { 

				document.getElementById("hoodPanel").style.zIndex = 100;document.getElementById("hoodPanel").style.display = 'block'; 

			}

		nTop = (parseInt(document.getElementById("showAllHoods").offsetTop) - parseInt(document.getElementById("hoodPanel").offsetHeight));

		document.getElementById("hoodPanel").style.top = nTop + 'px';

		document.getElementById("hoodPanel").style.left = '10px';			

	//if (document.getElementById("neighborhoods").style.opacity==0) { document.getElementById("neighborhoods").style.zIndex = 10; Effect.Appear(v); } else {	Effect.toggle(v, 'Appear'); }

}



function updatePriceSlider(low,high) {

	//priceRangeSlider.setRange(low,high);

	//show_range();

}



function hoodOver() {

	document.getElementById(arguments[0] + "_div").className = "nChildOver";

	//document.getElementById(arguments[0] + "_div").innerHTML = arguments[0];

}



function hoodOut() {

	document.getElementById(arguments[0] + "_div").className = "nChild";

}



function getHoodList() {

	

	new Ajax ('/myinc/ajax/getneighborhoods.php',

	  {

		method:'get',

	    onComplete: function(response){

		  var njson = eval('(' + response + ')');

		  if (njson) {

			  for (var j = 0; j < njson.neighborhoods.length; j++) {

				nHoodList[njson.neighborhoods[j].id]=njson.neighborhoods[j].name;

			  }

		  }

		  flashMovie.getHoods(nHoodList);

		},

		onFailure: function(){  }

	  }).request();



}


function nUpdate(n) {

	var deleteIndex = 'a';

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

		if (nList[i]==n) {

			deleteIndex=i;

		}

	}

	if (deleteIndex!='a') {

		nList.splice(deleteIndex,1);

	} else {

		nList.push(n);

	}

	updateListings();

}





function checkRadio(i,v,t) {

	for (x=1;x<(parseInt(t) + 1);x++) {

		if (x==v) { 

//			document.getElementById(i + x + '_img').src = 'images/radio_on.png';

		} else {

	//		document.getElementById(i + x + '_img').src = 'images/radio_off.png';			

		}

	}

	//alert("clicked");

	updateListings();

}



function checkDependent(i,q,d,t) {

	//v=document.getElementById(i + q + '_img');

	box=document.getElementById(i + q);

	if (box.checked==false) {

		//box.checked=true;

		//v.src='images/chk_on.png';

	} else {

		//box.checked=false;

		/*if (q!=d) { v.src='images/chk_off.png';	}*/

	}

	var depCheck=false;

	if (q==d) {

		for (x=1;x<(parseInt(t) + 1);x++) {

			if (x!=d) {

			//document.getElementById(i + x + '_img').src='images/chk_off.png';

			document.getElementById(i + x).checked=false;			

			}

		}

	} else {

		for (x=1;x<(parseInt(t) + 1);x++) {

			if (x!=d) {

				if (document.getElementById(i + x).checked==true) {

					depCheck=true;

				}

			}

		}

		if (depCheck==true) {

			//document.getElementById(i + d + '_img').src='images/chk_off.png';

			document.getElementById(i + d).checked=false;

		} else {

			//document.getElementById(i + d + '_img').src='images/chk_on.png';		

			document.getElementById(i + d).checked=true;

		}

	}

	

	updateListings();

}





function checkLinked(i,l) {

	//v=document.getElementById(i + '_img');

	box=document.getElementById(i);

	//v2=document.getElementById(l + '_img');	

	box2=document.getElementById(l);

	chks.push(l);

	if (box.checked==false) {

		box.checked=true;

		box2.checked=true;		

		//v.src='images/chk_on.png';

		//v2.src='images/chk_on.png';		

	} else {

		box.checked=false;

		box2.checked=false;		

		//v.src='images/chk_off.png';

		//v2.src='images/chk_off.png';		

	}

	//updateListings();

	js_to_as(i, box.checked, box.value);	

	js_to_small_fs( i, box.checked, box.value );

}



function checkBoth(i,l) {

	box=document.getElementById(i);

	box2=document.getElementById(l);

	box2.checked=box.checked;

	updateListings();

}





function checkLinkedFromFlash(i,l) {

	//v=document.getElementById(i + '_img');

	box=document.getElementById(i);

	//v2=document.getElementById(l + '_img');	

	box2=document.getElementById(l);

	chks.push(l);

	if (box.checked==false) {

		box.checked=true;

		box2.checked=true;		

		//v.src='images/chk_on.png';

		//v2.src='images/chk_on.png';		

	} else {

		box.checked=false;

		box2.checked=false;		

		//v.src='images/chk_off.png';

		//v2.src='images/chk_off.png';		

	}

	//updateListings();

	 js_to_small_fs( i, box.checked, box.value );	

}





function checkLinkedUpdate(i,l) {

	//v=document.getElementById(i + '_img');

	box=document.getElementById(i);

	//v2=document.getElementById(l + '_img');	

	box2=document.getElementById(l);

	chks.push(l);

	if (box.checked==false) {

		box.checked=true;

		box2.checked=true;		

		///v.src='images/chk_on.png';

		//v2.src='images/chk_on.png';		

	} else {

		box.checked=false;

		box2.checked=false;		

		//v.src='images/chk_off.png';

		//v2.src='images/chk_off.png';		

	}

	js_to_as(l, box.checked, box.value);		

	updateListings();

}



function CheckBoxFromFlash(i) {

	//v=document.getElementById(i + '_img');

	box=document.getElementById(i);

	if (box.checked==false) {

		box.checked=true;

		//v.src='images/chk_on.png';

	} else {

		box.checked=false;

		//v.src='images/chk_off.png';		

	}

	//alert(i);

	 js_to_small_fs( i, box.checked, box.value );

}



function checkBox(i) {

	//v=document.getElementById(i + '_img');

	box=document.getElementById(i);

	/*if (box.checked==false) {

		box.checked=true;

		//v.src='images/chk_on.png';

	} else {

		box.checked=false;

		//v.src='images/chk_off.png';		

	}*/

	updateListings();

}



function checkBoxNoUpdate(i) {

	//v=document.getElementById(i + '_img');

	box=document.getElementById(i);

	/*if (box.checked==false) {

		box.checked=true;

		//v.src='images/chk_on.png';

	} else {

		box.checked=false;

		//v.src='images/chk_off.png';		

	}*/

}



function CheckBoxToFlash(i) {

	//v=document.getElementById(i + '_img');

	box=document.getElementById(i);

	if (box.checked==false) {

		box.checked=true;

		//v.src='images/chk_on.png';

	} else {

		box.checked=false;

		//v.src='images/chk_off.png';		

	}

	js_to_as(i, box.checked, box.value);

}





function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}





function 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 updateHoods() {

	var hoods=document.getElementsByName("hoodBoxes");

	nList.length=0;

	nListID.length=0;

	for (x=0;x<hoods.length;x++) {

		if (hoods[x].checked==true) { nList.push(hoods[x].value); nListID.push(hoods[x].id); }		

	}

}





function updateValues() {

	updateHoods();

	zipCode = document.getElementById("zipcode").value;

	mls = document.getElementById("mls").value;	

	priceMin = document.getElementById("min").value

	if (priceMin!='') { priceMin=priceMin + '000'; }

	priceMax = document.getElementById("max").value

	if (priceMax!='') { priceMax=priceMax + '000'; }	

	sqftFrom = document.getElementById("sqftFrom").value;

	sqftTo = document.getElementById("sqftTo").value;

	streetSearch = document.getElementById("searchBar").value;

	keyword = document.getElementById("keyword").value;

	

	age='';

	var ageElements = document.getElementsByName("age");

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

		if (ageElements[i].checked==true) 

		{

			age='&age=' + ageElements[i].value;

		}

	}





	styles='';

	var styleElements = document.getElementsByName("style");

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

		if (styleElements[i].checked==true) 

		{

			styles+='&s[]=' + styleElements[i].value;

		}

	}



	bedrooms='';

	var bedElements = document.getElementsByName("beds");

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

		if (bedElements[i].checked==true) 

		{

			bedrooms+='&beds[]=' + bedElements[i].value;

		}

	}	

	

	baths='';

	var bathElements = document.getElementsByName("baths");

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

		if (bathElements[i].checked==true) 

		{

			baths+='&baths[]=' + bathElements[i].value;

		}

	}	



	/*parking='';

	var parkingElements = document.getElementsByName("parking");

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

		if (parkingElements[i].checked==true) 

		{

			parking+='&park[]=' + parkingElements[i].value;

		}

	}*/

	

	ptype='';

	var ptypeElements = document.getElementsByName("ptype");

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

		if (ptypeElements[i].checked==true) 

		{

			switch (ptypeElements[i].value) {

				case "SNG": styles+='&p[]=SNG'; styles+='&p[]=RTC'; break;

				default: ptype+='&p[]=' + ptypeElements[i].value; break;

			}



		}

	}	

	

	



	if (document.getElementById("basement").checked==true) { basement = 'Y'; } else { basement = ''; }

	if (document.getElementById("garage").checked==true) { garage = 'Y'; } else { garage = ''; }

	if (document.getElementById("ac").checked==true) { ac = 'Y'; } else { ac = ''; }

	if (document.getElementById("fireplace").checked==true) { fireplace = 'Y'; } else { fireplace = ''; }

	if (document.getElementById("parking").checked==true) { parking = 'Y'; } else { parking = ''; }	

	if (document.getElementById("el").checked==true) { exclusive = 'Y'; } else { exclusive = ''; }

	if (document.getElementById("newListings").checked==true) { newListings = 'Y'; } else { newListings = ''; }	

	if (document.getElementById("havePhoto").checked==true) { havePhoto = 'Y'; } else { havePhoto = ''; }

	if (document.getElementById("haveTour").checked==true) { vtour = 'Y'; } else { vtour = ''; }	
	
	if (document.getElementById("haveOpenHouse").checked==true) { haveOpenHouse = 'Y'; } else { haveOpenHouse = ''; }	

	



	neighborhoods = '';

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

		neighborhoods += '&n[]=' + nList[i];

	}

}



function sortListings(by) {

	page=0;

	switch (by) {

		case "streetname":

			sortDiv[0]="addressArrow";

			sortDiv[1]="Address";

		break

		case "assoc_fee":

			sortDiv[0]="assocArrow";

			sortDiv[1]="Fee";

		break

		case "tot_re_tax":

			sortDiv[0]="taxArrow";

			sortDiv[1]="Tax";

		break		

		case "listprice":

			sortDiv[0]="priceArrow";

			sortDiv[1]="Price";			

		break

		case "bedrooms":

			sortDiv[0]="bedsArrow";

			sortDiv[1]="Beds";			

		break

		case "fullbaths":

			sortDiv[0]="bathsArrow";

			sortDiv[1]="Baths";			

		break	

		case "approx_sqft":

			sortDiv[0]="sqftArrow";

			sortDiv[1]="Sqft";			

		break

		case "flistdate":

			sortDiv[0]="dateArrow";

			sortDiv[1]="Days";			

		break

		case "pps":

			sortDiv[0]="ppsArrow";

			sortDiv[1]="$/Sqft";		

		break



	}

	if (sortBy==by) {

		sortBy=by + ' desc';

		sortDiv[1] += '&nbsp;<img src="/propsearch/images/sortDown.png">';

	} else {

		sortBy=by;

		sortDiv[1] += '&nbsp;<img src="/propsearch/images/sortUp.png">';		

	}

	updateListings();

}



function prevPhoto(i) {

	currentImage = listImages[i][0];

	imageCount = (listImages[i].length - 1);

	imageElem = document.getElementById('photo' + i);

	countElem = document.getElementById('pnum' + i);

	if (currentImage==1) {

		imageElem.src=photoDir + listImages[i][imageCount];

		listImages[i][0]=imageCount;

		countElem.innerHTML=imageCount + ' of ' + imageCount;		

	} else {

		if ((showPhotos[i]==1) || (currentImage<=4)) {

			imageElem.src=photoDir + listImages[i][(currentImage - 1)];

		} else {

			imageElem.src="/propsearch/images/view_more_photos.gif";					

		}

		listImages[i][0]=(currentImage - 1);

		countElem.innerHTML=(currentImage - 1) + ' of ' + imageCount;

	}

}



function nextPhoto(i) {

	currentImage = listImages[i][0];

	imageCount = (listImages[i].length - 1);

	imageElem = document.getElementById('photo' + i);

	countElem = document.getElementById('pnum' + i);

	if (currentImage==imageCount) {

		imageElem.src=photoDir + listImages[i][1];

		listImages[i][0]=1;

		countElem.innerHTML='1 of ' + imageCount;		

	} else {

		if ((showPhotos[i]==1) || (currentImage<3)) {

			imageElem.src=photoDir + listImages[i][(currentImage + 1)];		

		} else {

			imageElem.src="/propsearch/images/view_more_photos.gif";					

		}

		listImages[i][0]=(currentImage + 1);

		countElem.innerHTML=(currentImage + 1) + ' of ' + imageCount;

	}

}



function showLoader() {

	ld=document.getElementById("loadingCover");

	/*document.getElementById("hoodBreakdown").style.visibility="hidden";

	ld.innerHTML='<div id="ResultLoader"><img src="http://www.centercityrealestate.com/propsearch/images/atacan_loading.gif" /></div>';

	rl=document.getElementById("ResultLoader");

	st = getScrollTop();

	rl.style.top = parseInt(getWindowHeight() / 2) + st + "px";

	ld.style.height=document.body.clientHeight + 'px';

	ld.style.width=document.body.clientWidth + 'px';

	ld.style.visibility = "visible";*/

	ld.style.display = "block";

	ld.style.visibility="visible";

	ld.style.top=document.getElementById("results").offsetTop + 'px';

	ld.style.left=document.getElementById("results").offsetLeft + 'px';

	ld.style.height=document.getElementById("results").offsetHeight + 'px';

	ld.style.width=document.getElementById("results").offsetWidth + 'px';		

	if (document.getElementById("results").offsetTop==381) { ld.style.top='465px'; ld.style.left='280px' }

}



function hideLoader() {

	/*ld=document.getElementById("loading");

	ld.style.display="none";	

	ld.innerHTML='';

	document.getElementById("hoodBreakdown").style.visibility="visible";*/

	ld.style.visibility="hidden";

	ld.style.display="none";

}



function resultOver(i) {

/*	if (marker[i]) {

		GEvent.trigger(marker[i],"mouseOver");

	} else {*/



	if (i==activeResult) {

		resultOn(i);

	} else {

		resultHighlight(i);

	}

	//}

}



function resultOn(i) {

	t = document.getElementById("resultDiv" + i);

	//l = document.getElementById("resultCornerLeft" + i);		

	//r = document.getElementById("resultCornerRight" + i);	

	

	

	if (t) t.style.border='4px solid #6699cc';

	if (t) t.style.padding='0px';	

	//if (l) l.className="resultRowBottomOn";

	//if (r) r.className="resultRowBottomOn";	

}

function resultHighlight(i) {

	t = document.getElementById("resultDiv" + i);

	//l = document.getElementById("resultCornerLeft" + i);		

	//r = document.getElementById("resultCornerRight" + i);	

	

	

	if (t) t.style.border='4px solid #6699cc';

	if (t) t.style.padding='0px';

	

	//if (l) l.className="resultRowBottomOver";

	//if (r) r.className="resultRowBottomOver";	

}

function resultOff(i) {

	t = document.getElementById("resultDiv" + i);

	//l = document.getElementById("resultCornerLeft" + i);		

	//r = document.getElementById("resultCornerRight" + i);		

	

	if (t) { t.style.border='1px solid #cccccc'; }

	if (t) t.style.padding='3px';

	//if (l) l.className="resultRowBorder";

	//if (r) r.className="resultRowBorder";	

}



function resultOut(i) {

	if (i!=activeResult) {		

		resultOff(i);

	}

}



function processAT(a,t) {

	if (a) {

		assn = '$' + addCommas(Math.round(a));

	} else {

		assn = "No";

	}



	if (t) {

		tax = '$' + addCommas(Math.round(t));

	} else {

		tax = "No";

	}

	return assn + ' / ' + tax;

}



function updateSelectedHoods() {

	var listHTML = '';

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

		if (nList[i]!='') {

		listHTML += '<div class="modLine"  onClick="CheckBoxToFlash(\'' + nListID[i] + '\'); updateListings();"><table><tr><td><img src="' + urlroot + '/images/chk_on.png"></td><td><span class="optionText">' + nList[i] + '</span></td></tr></table></div>'; }

	}

	nh=document.getElementById("nhDiv");

	if (listHTML=='') { listHTML='<div id="noHoods">No neighborhoods selected.</div>'; }

	if (nh) { nh.innerHTML=listHTML; }

}



function resetHoods() {

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

		CheckBoxToFlash(nListID[i]);

	}

	nList.length=0;

	nListID.length=0;

	updateSelectedHoods();

}



function resetLocationSearch() {

	resetHoods();

	document.getElementById("searchBar").value="";

}



function updateZipcode() {

	resetLocationSearch();

	updateListings();

}



function trackProperty(pid) {

	var rurl='http://www.centercityrealestate.com/propsearch/myinc/ajax/trackproperty.php?pid=' + pid;

	//document.getElementById("debug").innerHTML=rurl;

	new Ajax(rurl,

	{

	  method:'get',

	  onComplete: function(response){

	alert("You are now tracking "  + response + ". You will be notified when the price changes or new images are updated for this property.");
		  
	},

	onFailure: function(){

	}

	}).request();

}



function saveProperty(pid) {

	var rurl='http://www.centercityrealestate.com/propsearch/myinc/ajax/saveproperty.php?pid[0]=' + pid;

	//document.getElementById("debug").innerHTML=rurl;

	new Ajax(rurl,

	{

	  method:'get',

	  onComplete: function(response){

	alert("Property Save Successfully.");

	},

	onFailure: function(){

	}

	}).request();

}




function saveProperties(pids) {

	var pidString = '';

	for (x=0;x<pids.length;x++) {

		if (x>0) pidString+='&';

		pidString+='pid[' + x + ']=' + pids[x];

	}

	var rurl='http://www.centercityrealestate.com/propsearch/myinc/ajax/saveproperty.php?'+ pidString;

	//document.getElementById("debug").innerHTML=rurl;

	new Ajax(rurl,

	{

	  method:'get',

	  onComplete: function(response){

	  //alert(response);

	alert("Properties Saved Successfully.");

	},

	onFailure: function(){

	}

	}).request();

}





function selectAllResults() {

	var toSelect;

	for (x=1;x<myPids.length;x++) {

		toSelect = document.getElementById("resultCheck" + x);

		if (toSelect) toSelect.checked=true;

	}

}



function clearResultSelections() {

	var toSelect;

	for (x=1;x<myPids.length;x++) {

		toSelect = document.getElementById("resultCheck" + x);

		if (toSelect) toSelect.checked=false;

	}

}







function saveSelectedResults() {

	var toSave;

	var pids = [];

	for (x=1;x<myPids.length;x++) {

		toSave = document.getElementById("resultCheck" + x);

		if (toSave.checked==true) pids[pids.length]=myPids[x];

	}

	if (pids.length>0) saveProperties(pids);

}





function urlIt(w) {

	w=w.toLowerCase();

	w=w.replace(" ","-");	

	w=w.replace(",","");

	w=w.replace(".","");

	w=w.replace("'","");	

	w=w.replace("/","");

	w=w.replace(" ","-");	

	w=w.replace(",","");

	w=w.replace(".","");

	w=w.replace("'","");	

	w=w.replace("/","");

	w=w.replace(" ","-");	

	w=w.replace(",","");

	w=w.replace(".","");

	w=w.replace("'","");	

	w=w.replace("/","");

	w=w.replace(" ","-");	

	w=w.replace(",","");

	w=w.replace(".","");

	w=w.replace("'","");	

	w=w.replace("/","");

	w=w.replace(" ","-");	

	w=w.replace(",","");

	w=w.replace(".","");

	w=w.replace("'","");	

	w=w.replace("/","");

	w=w.replace(" ","-");	

	w=w.replace(",","");

	w=w.replace(".","");

	w=w.replace("'","");	

	w=w.replace("/","");					

	return(w);

}



function updateListings(viewAction) {

	

	if (viewMode=='expanded') {

		document.getElementById("rightTop").style.display="block";	  

		showMap();

		document.getElementById("expandAllButton").innerHTML='<span class="jsLink" onClick="expandAllLoader();" style="font-size: 11px; font-weight: bold;"><img src="http://www.centercityrealestate.com/propsearch/images/arrow_blue_down.png"> Expand All Listings</span>';

		viewMode='normal';

	}	



	switch (lastaction) {

		case "changePage": showLoader(); break;

		//case "newPage": break;

		default: page=0; showLoader(); break;

	}

	

	var clickResult='';

	switch (viewAction) {

		case "preserveState":

			clickResult=activeResult;

		break;

	}

	

	lastaction='';

	clearInfowindows();

	updateValues();

	myLats.length=0;

	myLongs.length=0;

	myInfo.length=0;

	myImages.length=0;

	myLinks.length=0;

	myTips.length=0;

	myPids.length=0;

	showZoom.length=0;

	showPhotos.length=0;

	myUrls.length=0;

	activeResult='';

	json='';

	updateSelectedHoods();

	//document.getElementById("resultsContainer").innerHTML = "";

	//document.getElementById("pagination").innerHTML = "";

	clearMarkers();

	



	//alert(ownership);

	var rurl='/propsearch/myinc/ajax/getlistings.php?location=' + zipCode + '&min=' + priceMin + '&page=' + page + '&max=' + priceMax + '&sqftlow=' + sqftFrom + '&sqftHigh=' + sqftTo + '&age=' + age + '&basement=' + basement + '&garage=' + garage + '&ac=' + ac +  '&fireplace=' + fireplace + '&street=' + streetSearch + '&parking=' + parking + neighborhoods + ptype + styles + bedrooms + baths + '&sortby=' + sortBy + '&exclusive=' + exclusive + '&havePhoto=' + havePhoto + '&newListings=' + newListings + '&mls=' + mls + '&keyword=' + keyword + '&vtour=' + vtour + '&haveOpenHouse=' + haveOpenHouse + '&stype=' + searchType;

	saveSearchSession();



//	alert(rurl);



//document.getElementById('debug').innerHTML=rurl;





  new Ajax(rurl,

  {

    method:'get',

    onComplete: function(response){

		document.getElementById("resultsContainer").innerHTML="";

		if (response!='') {

			json = eval('(' + response + ')');		

		} else {

			json.count[0].count=0;

		}

		if (json.count[0].count!=0) {

		

		

		document.getElementById("bottomOptions").style.visibility="hidden";

		document.getElementById("topOptions").style.visibility="hidden";

		

		var strdir='';

		var addrInfo='';

		var halfBaths='';

		var unitNum='';

		

		for (var j = 0; j < json.listings.length; j++) {

			

			//Just for visual purposes

			if  (json.listings[j].streetdir!='') 
			{
			strdir=json.listings[j].streetdir + ' ';
			}
			else
			{
			strdir= '';
			}

			

			//Create new container div

			var newdiv = document.createElement('div');

  			newdiv.setAttribute('id', 'resultDiv' + (j+1));

  			newdiv.style.border='1px solid #cccccc';

  			newdiv.style.width='100%';

  			newdiv.style.display='block';

  			newdiv.style.padding='3px';

  			newdiv.style.marginBottom='10px'

  			newdiv.style.marginTop='10px';

  			newdiv.style.cursor="pointer";

  			document.getElementById("resultsContainer").appendChild(newdiv);

			ppsqft = (json.listings[j].pps <= 999998) ? Math.round(json.listings[j].pps) : 0;

			

			if ((j+1)==clickResult) 

			{

				var clickId=json.listings[j].propid;

				var clickListnum=json.listings[j].listnum;

			}

			

			

			//if (json.listings[j].streetname!='NA') {

			//output += '         ' + json.listings[j].streetnum + ' ' + strdir + json.listings[j].streetname + unitNum;

			

			

			if (json.listings[j].streetname!='NA') { 

				addrInfo=json.listings[j].streetnum + ' ' + strdir + json.listings[j].streetname + unitNum + '<br>';

			}

			

			if ((json.listings[j].partial_baths * 1)>0) {

				halfBaths=".5";

			} else {

				halfBaths="";

			}

			

			

			unit_num='';

			if (json.listings[j].unit_num!='') { unit_num='Unit ' + json.listings[j].unit_num + '<br/>'; } else { unit_num = '';}

			

			//Build content for div

			rTop='<div id="resultDivTop' + (j+1) + '">';

			rTop='<div style="float: left; width: 4%"><input type="checkbox" name="resultCheck' + (j+1) + '" id="resultCheck' + (j+1) + '"></div>';

			rTop+='<div style="float: left; width: 10%;" id="resultImage' + (j+1) + '"onClick="propClick(' + (j+1) + ',' + json.listings[j].propid +',' + json.listings[j].listnum +',\'results\')" >';

			if (json.listings[j].path) { rTop += '<img width="51" height="51" src="/propsearch/resize/small/' + json.listings[j].path + '">'; } else { rTop += '<img width="51" height="51" src="/propsearch/images/homeDefault.png">'; }

			rTop+='</div>';

			// @Revised 2/17/2009 by Adam 
			// Updated urls to show full property addresses

			if (json.listings[j].streetname=='NA') { rTop+='<div style="float: left; width: 18%;" onClick="propClick(' + (j+1) + ',' + json.listings[j].propid +',' + json.listings[j].listnum +',\'results\')" ><a target="_blank" href="http://www.centercityrealestate.com/philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetname) + '/' + urlIt(json.listings[j].listnum) + '/"><strong>' + addrInfo + '</strong></a>' + json.listings[j].sub_nbhd + '<div id="mi' + (j+1) + '"><img src="/propsearch/images/info.png" style="margin-right: 5px;">More Info</div></div>'; }
			
			else if ((json.listings[j].streetdir !='' && json.listings[j].unit_num!='')) { rTop+='<div style="float: left; width: 18%;" onClick="propClick(' + (j+1) + ',' + json.listings[j].propid +',' + json.listings[j].listnum +',\'results\')" ><a target="_blank" href="http://www.centercityrealestate.com/philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetnum) + '-' + urlIt(json.listings[j].streetdir) + '-' + urlIt(json.listings[j].streetname) + '-' + urlIt(json.listings[j].unit_num) + '/' + urlIt(json.listings[j].listnum) + '/"><strong>' + addrInfo + unit_num + '</strong></a>' + json.listings[j].sub_nbhd + '<div id="mi' + (j+1) + '"><img src="/propsearch/images/info.png" style="margin-right: 5px;">More Info</div></div>'; }

			else if (json.listings[j].streetdir !='' && json.listings[j].unit_num=='') { rTop+='<div style="float: left; width: 18%;" onClick="propClick(' + (j+1) + ',' + json.listings[j].propid +',' + json.listings[j].listnum +',\'results\')" ><a target="_blank" href="http://www.centercityrealestate.com/philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetnum) + '-' + urlIt(json.listings[j].streetdir) + '-' + urlIt(json.listings[j].streetname) + '/' + urlIt(json.listings[j].listnum) + '/"><strong>' + addrInfo + '</strong></a>' + json.listings[j].sub_nbhd + '<div id="mi' + (j+1) + '"><img src="/propsearch/images/info.png" style="margin-right: 5px;">More Info</div></div>'; }

			else if (json.listings[j].streetdir =='' && json.listings[j].unit_num !='') { rTop+='<div style="float: left; width: 18%;" onClick="propClick(' + (j+1) + ',' + json.listings[j].propid +',' + json.listings[j].listnum +',\'results\')" ><a target="_blank" href="http://www.centercityrealestate.com/philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetnum) + '-' + urlIt(json.listings[j].streetname) + '-' + urlIt(json.listings[j].unit_num) + '/' + urlIt(json.listings[j].listnum) + '/"><strong>' + addrInfo + unit_num + '</strong></a>' + json.listings[j].sub_nbhd + '<div id="mi' + (j+1) + '"><img src="/propsearch/images/info.png" style="margin-right: 5px;">More Info</div></div>'; }

			else { rTop+='<div style="float: left; width: 18%;" onClick="propClick(' + (j+1) + ',' + json.listings[j].propid +',' + json.listings[j].listnum +',\'results\')" ><a target="_blank" href="http://www.centercityrealestate.com/philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetnum) + '-' + urlIt(json.listings[j].streetname) + '/' + urlIt(json.listings[j].listnum) + '/"><strong>' + addrInfo + '</strong></a>' + json.listings[j].sub_nbhd + '<div id="mi' + (j+1) + '"><img src="/propsearch/images/info.png" style="margin-right: 5px;">More Info</div></div>'; }
			
			rTop+='<div style="float: left; width: 10%;" onClick="propClick(' + (j+1) + ',' + json.listings[j].propid +',' + json.listings[j].listnum +',\'results\')" ><strong>Price<br>$' + addCommas(json.listings[j].listprice) + '</strong></div>';

			rTop+='<div style="float: left; width: 8%;" onClick="propClick(' + (j+1) + ',' + json.listings[j].propid +',' + json.listings[j].listnum +',\'results\')" ><strong>$/Sqft</strong><br>$' + addCommas(ppsqft) + '</div>';

			rTop+='<div style="float: left; width: 8%;" onClick="propClick(' + (j+1) + ',' + json.listings[j].propid +',' + json.listings[j].listnum +',\'results\')" ><strong>Sqft</strong><br>' + addCommas(json.listings[j].approx_sqft) + '</div>';

			rTop+='<div style="float: left; width: 8%;" onClick="propClick(' + (j+1) + ',' + json.listings[j].propid +',' + json.listings[j].listnum +',\'results\')" ><strong>Tax</strong><br>';			

			if (json.listings[j].tot_re_tax) { rTop += '$' + addCommas(Math.round(json.listings[j].tot_re_tax));; } else { rTop += 'No';  }

			rTop+= '</div>';

			rTop+='<div style="float: left; width: 8%;" onClick="propClick(' + (j+1) + ',' + json.listings[j].propid +',' + json.listings[j].listnum +',\'results\')" ><strong>Fee</strong><br>';			

			if (json.listings[j].assoc_fee > 0 ) { rTop += '$' + addCommas(Math.round(json.listings[j].assoc_fee)) + '/' + json.listings[j].assoc_fee_freq; } else { rTop += 'No'; }

			rTop+= '</div>';

			rTop+='<div style="float: left; width: 14%;" onClick="propClick(' + (j+1) + ',' + json.listings[j].propid +',' + json.listings[j].listnum +',\'results\')" ><strong>Beds/Baths</strong><br>' + json.listings[j].bedrooms + 'B/' + json.listings[j].fullbaths + halfBaths + 'b</div>';

			
			rTop+='<div style="float: left; width: 10%;" onClick="propClick(' + (j+1) + ',' + json.listings[j].propid +',' + json.listings[j].listnum +',\'results\')" ><strong>Listed</strong><br>' 
			
				
			if (json.listings[j].daysonmarket > 0 )
			{
			rTop+= addCommas(json.listings[j].daysonmarket) + ' day(s)'
			}
			else
			{
				rTop+= 'Today';
			}
			
			rTop+='</div>';			

//			rTop+='</div><div style="float: right; font-size: 9px;">Courtesy of ' + json.listings[j].listofficename + '</div>';			

			rTop+='<div class="clearer"></div>';

			rTop+='</div>';

			

			addrInfo='';

						

			//Build Details Div			

			rBottom='';

			rBottom +='<div id="details' + (j + 1) + '" class="resultDetails" style="display: none;">';

			if (json.listings[j].path) { rBottom += '<div class="fullPic" id="photos' + (j + 1) + '"><img width="150" height="150" src="/propsearch/resize/med/' + json.listings[j].path + '"></div>'; } else { rBottom += '<div class="fullPic" id="photos' + (j + 1) + '"><img width="150" height="150" src="/propsearch/images/imageNotAvailable.gif"></div>'; }

			rBottom += '<div class="resultInfo"><div id="remark' + (j+1) + '" class="resultText"></div></div>';

			rBottom += '<div class="smallMapContainer" id="smallMapContainer' + (j + 1) + '"><div class="smallMap" style="width: 250px; height: 175px;" id="resultMap' + (j + 1) + '"></div><div class="clearer"></div></div>';		

			rBottom+='</div><div class="clearer"></div>';

			

			//Build the Toolbar
			// @Revised 5/1/2009 by Adam 
			// Updated Full Detail url to show full property addresses

			rToolbar='<div class="resultToolBar">';

			if (json.listings[j].streetname=='NA') { rToolbar+='<div class="toolbarButton" onMouseOver="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails_over.gif\')"" onMouseOut="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails.gif\')"><a target="_blank" href="http://www.centercityrealestate.com/philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetname) + '/' + urlIt(json.listings[j].listnum) + '/"><img src="/propsearch/images/icon_fullDetails.gif" border="0" id="fullDetailsIcon' + (j+1) + '"></a></div><div class="toolbarText" onMouseOver="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails_over.gif\')"" onMouseOut="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails.gif\')"><a target="_blank" href="http://www.centercityrealestate.com/philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetname) + '/' + urlIt(json.listings[j].listnum) + '/"><span class="vanillaLink">Full Details</span></a></div>'; }

			else if ((json.listings[j].streetdir !='' && json.listings[j].unit_num!='')) {rToolbar+='<div class="toolbarButton" onMouseOver="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails_over.gif\')"" onMouseOut="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails.gif\')"><a target="_blank" href="http://www.centercityrealestate.com/philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetnum) + '-' + urlIt(json.listings[j].streetdir) + '-' + urlIt(json.listings[j].streetname) + '-' + urlIt(json.listings[j].unit_num) + '/' + urlIt(json.listings[j].listnum) +  '/"><img src="/propsearch/images/icon_fullDetails.gif" border="0" id="fullDetailsIcon' + (j+1) + '"></a></div><div class="toolbarText" onMouseOver="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails_over.gif\')"" onMouseOut="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails.gif\')"><a target="_blank" href="http://www.centercityrealestate.com/philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetnum) + '-' + urlIt(json.listings[j].streetdir) + '-' + urlIt(json.listings[j].streetname) + '-' + urlIt(json.listings[j].unit_num) + '/' + urlIt(json.listings[j].listnum) +  '/"><span class="vanillaLink">Full Details</span></a></div>'; }

			else if (json.listings[j].streetdir !='' && json.listings[j].unit_num=='') {rToolbar+='<div class="toolbarButton" onMouseOver="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails_over.gif\')"" onMouseOut="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails.gif\')"><a target="_blank" href="http://www.centercityrealestate.com/philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetnum) + '-' + urlIt(json.listings[j].streetdir) + '-' + urlIt(json.listings[j].streetname) + '/' + urlIt(json.listings[j].listnum) + '/"><img src="/propsearch/images/icon_fullDetails.gif" border="0" id="fullDetailsIcon' + (j+1) + '"></a></div><div class="toolbarText" onMouseOver="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails_over.gif\')"" onMouseOut="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails.gif\')"><a target="_blank" href="http://www.centercityrealestate.com/philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetnum) + '-' + urlIt(json.listings[j].streetdir) + '-' + urlIt(json.listings[j].streetname) + '/' + urlIt(json.listings[j].listnum) + '/"><span class="vanillaLink">Full Details</span></a></div>'; }

			else if (json.listings[j].streetdir =='' && json.listings[j].unit_num !='') {rToolbar+='<div class="toolbarButton" onMouseOver="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails_over.gif\')"" onMouseOut="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails.gif\')"><a target="_blank" href="http://www.centercityrealestate.com/philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetnum) + '-' + urlIt(json.listings[j].streetname) + '-' + urlIt(json.listings[j].unit_num) + '/' + urlIt(json.listings[j].listnum) + '/"><img src="/propsearch/images/icon_fullDetails.gif" border="0" id="fullDetailsIcon' + (j+1) + '"></a></div><div class="toolbarText" onMouseOver="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails_over.gif\')"" onMouseOut="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails.gif\')"><a target="_blank" href="http://www.centercityrealestate.com/philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetnum) + '-' + urlIt(json.listings[j].streetname) + '-' + urlIt(json.listings[j].unit_num) + '/' + urlIt(json.listings[j].listnum) + '/"><span class="vanillaLink">Full Details</span></a></div>'; }
			
			else { rToolbar+='<div class="toolbarButton" onMouseOver="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails_over.gif\')"" onMouseOut="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails.gif\')"><a target="_blank" href="http://www.centercityrealestate.com/philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetnum) + '-' + urlIt(json.listings[j].streetname) + '/' + urlIt(json.listings[j].listnum) + '/"><img src="/propsearch/images/icon_fullDetails.gif" border="0" id="fullDetailsIcon' + (j+1) + '"></a></div><div class="toolbarText" onMouseOver="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails_over.gif\')"" onMouseOut="imgSwap(\'fullDetailsIcon' + (j+1) + '\',\'/propsearch/images/icon_fullDetails.gif\')"><a target="_blank" href="http://www.centercityrealestate.com/philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetnum) + '-' + urlIt(json.listings[j].streetname) + '/' + urlIt(json.listings[j].listnum) + '/"><span class="vanillaLink">Full Details</span></a></div>'; }


			// @Revised 8/21/2009 by Adam 
			// Updated Add to Favorites button behaviour for exclusive listings (when not signed in)

			if (json.listings[j].streetname!='NA' && json.listings[j].exclusive=='1') {

			rToolbar+='<div class="toolbarButton" onClick="showRegForm(\'listing\');" onMouseOver="imgSwap(\'addToFavIcon' + (j+1) + '\',\'/propsearch/images/icon_addToFavorites_over.gif\')"" onMouseOut="imgSwap(\'addToFavIcon' + (j+1) + '\',\'/propsearch/images/icon_addToFavorites.gif\')"><img src="/propsearch/images/icon_addToFavorites.gif" id="addToFavIcon' + (j+1) + '"></div><div class="toolbarText" onClick="showRegForm(\'listing\');" onMouseOver="imgSwap(\'addToFavIcon' + (j+1) + '\',\'/propsearch/images/icon_addToFavorites_over.gif\')"" onMouseOut="imgSwap(\'addToFavIcon' + (j+1) + '\',\'/propsearch/images/icon_addToFavorites.gif\')">Add to Favorites</div>';			


			} else if (json.listings[j].streetname!='NA') {

			rToolbar+='<div class="toolbarButton" onClick="saveProperty(' + json.listings[j].propid + ');" onMouseOver="imgSwap(\'addToFavIcon' + (j+1) + '\',\'/propsearch/images/icon_addToFavorites_over.gif\')"" onMouseOut="imgSwap(\'addToFavIcon' + (j+1) + '\',\'/propsearch/images/icon_addToFavorites.gif\')"><img src="/propsearch/images/icon_addToFavorites.gif" id="addToFavIcon' + (j+1) + '"></div><div class="toolbarText" onClick="saveProperty(' + json.listings[j].propid + ');" onMouseOver="imgSwap(\'addToFavIcon' + (j+1) + '\',\'/propsearch/images/icon_addToFavorites_over.gif\')"" onMouseOut="imgSwap(\'addToFavIcon' + (j+1) + '\',\'/propsearch/images/icon_addToFavorites.gif\')">Add to Favorites</div>';

			} else {

			rToolbar+='<div class="toolbarButton" onClick="showRegForm(\'listing\');" onMouseOver="imgSwap(\'addToFavIcon' + (j+1) + '\',\'/propsearch/images/icon_addToFavorites_over.gif\')"" onMouseOut="imgSwap(\'addToFavIcon' + (j+1) + '\',\'/propsearch/images/icon_addToFavorites.gif\')"><img src="/propsearch/images/icon_addToFavorites.gif" id="addToFavIcon' + (j+1) + '"></div><div class="toolbarText" onClick="showRegForm(\'listing\');" onMouseOver="imgSwap(\'addToFavIcon' + (j+1) + '\',\'/propsearch/images/icon_addToFavorites_over.gif\')"" onMouseOut="imgSwap(\'addToFavIcon' + (j+1) + '\',\'/propsearch/images/icon_addToFavorites.gif\')">Add to Favorites</div>';			

			}

			

			rToolbar+='<div class="toolbarButton" onMouseOver="imgSwap(\'setAppIcon' + (j+1) + '\',\'/propsearch/images/icon_setAppointment_over.gif\')"" onMouseOut="imgSwap(\'setAppIcon' + (j+1) + '\',\'/propsearch/images/icon_setAppointment.gif\')"><a target="_blank" href="http://www.centercityrealestate.com/cchomes/schdl.php?pid=' + json.listings[j].propid + '"><img border="0" src="/propsearch/images/icon_setAppointment.gif" id="setAppIcon' + (j+1) + '"></a></div><div class="toolbarText" onMouseOver="imgSwap(\'setAppIcon' + (j+1) + '\',\'/propsearch/images/icon_setAppointment_over.gif\')"" onMouseOut="imgSwap(\'setAppIcon' + (j+1) + '\',\'/propsearch/images/icon_setAppointment.gif\')"><a target="_blank" href="http://www.centercityrealestate.com/cchomes/schdl.php?pid=' + json.listings[j].propid + '"><span class="vanillaLink">Set Appointment</span></a></div>';

			

			rToolbar+='<div class="toolbarButton" onClick="javascript:window.open(\'http:\/\/hc2.humanclick.com/hc/28520344/?cmd=file&file=visitorWantsToChat&site=28520344&referrer=\'+escape(document.location),\'chat28520344\',\'width=472,height=320\'); return false;" onMouseOver="imgSwap(\'liveChatIcon' + (j+1) + '\',\'/propsearch/images/icon_liveChat_over.gif\')"" onMouseOut="imgSwap(\'liveChatIcon' + (j+1) + '\',\'/propsearch/images/icon_liveChat.gif\')"><img src="/propsearch/images/icon_liveChat.gif" id="liveChatIcon' + (j+1) + '"></div><div class="toolbarText" onClick="javascript:window.open(\'http:\/\/hc2.humanclick.com/hc/28520344/?cmd=file&file=visitorWantsToChat&site=28520344&referrer=\'+escape(document.location),\'chat28520344\',\'width=472,height=320\'); return false;" onMouseOver="imgSwap(\'liveChatIcon' + (j+1) + '\',\'/propsearch/images/icon_liveChat_over.gif\')"" onMouseOut="imgSwap(\'liveChatIcon' + (j+1) + '\',\'/propsearch/images/icon_liveChat.gif\')">Live Chat</div>';

			if (json.listings[j].VTourURL.search('http')!='-1') { rToolbar+='<div class="toolbarButton" onMouseOver="imgSwap(\'vTourIcon' + (j+1) + '\',\'/propsearch/images/icon_virtualTour_over.gif\')"" onMouseOut="imgSwap(\'vTourIcon' + (j+1) + '\',\'/propsearch/images/icon_virtualTour.gif\')"><a href="' + json.listings[j].VTourURL + '" target="_blank"><img src="/propsearch/images/icon_virtualTour.gif" id="vTourIcon' + (j+1) + '" border="0"></a></div><div class="toolbarText" style="margin-right: 0px;"><a href="' + json.listings[j].VTourURL + '" target="_blank"><span class="vanillaLink">Virtual Tour</span></a></div>'; 

			} else {

			rToolbar+='<div class="toolbarButton"><img src="/propsearch/images/icon_virtualTour_grey.gif"></div><div class="toolbarText" style="margin-right: 0px;"><span class="vanillaLink">Virtual Tour</span></div>';


			}
			
			
			// @Revised 8/21/2009 by Adam 
			// Updated Track Property button behaviour for exclusive listings (when not signed in)
			//##Block Added by Pavan Jha to Cater to Property Track Requirement on Feb 27, 2009
			
			//Block Start
						
			if (json.listings[j].streetname!='NA' && json.listings[j].exclusive=='1') {
		
			rToolbar+='<div class="toolbarButton" onClick="showRegForm(\'listing\');" onMouseOver="imgSwap(\'addToTrackIcon' + (j+1) + '\',\'/propsearch/images/icon_addToTracking_over.gif\')"" onMouseOut="imgSwap(\'addToTrackIcon' + (j+1) + '\',\'/propsearch/images/icon_addToTracking.gif\')"><img src="/propsearch/images/icon_addToTracking.gif" id="addToTrackIcon' + (j+1) + '"></div><div class="toolbarText" onClick="showRegForm(\'listing\');" onMouseOver="imgSwap(\'addToTrackIcon' + (j+1) + '\',\'/propsearch/images/icon_addToTracking_over.gif\')"" onMouseOut="imgSwap(\'addToTrackIcon' + (j+1) + '\',\'/propsearch/images/icon_addToTracking.gif\')">Track</div>';			

			} else if (json.listings[j].streetname!='NA') {

			rToolbar+='<div class="toolbarButton"7 onClick="trackProperty(' + json.listings[j].propid + ');" onMouseOver="imgSwap(\'addToTrackIcon' + (j+1) + '\',\'/propsearch/images/icon_addToTracking_over.gif\')"" onMouseOut="imgSwap(\'addToTrackIcon' + (j+1) + '\',\'/propsearch/images/icon_addToTracking.gif\')"><img src="/propsearch/images/icon_addToTracking.gif" id="addToTrackIcon' + (j+1) + '"></div><div class="toolbarText" onClick="trackProperty(' + json.listings[j].propid + ');" onMouseOver="imgSwap(\'addToTrackIcon' + (j+1) + '\',\'/propsearch/images/icon_addToTracking_over.gif\')"" onMouseOut="imgSwap(\'addToTrackIcon' + (j+1) + '\',\'/propsearch/images/icon_addToTracking.gif\')">Track</div>';

			} else {

			rToolbar+='<div class="toolbarButton" onClick="showRegForm(\'listing\');" onMouseOver="imgSwap(\'addToTrackIcon' + (j+1) + '\',\'/propsearch/images/icon_addToTracking_over.gif\')"" onMouseOut="imgSwap(\'addToTrackIcon' + (j+1) + '\',\'/propsearch/images/icon_addToTracking.gif\')"><img src="/propsearch/images/icon_addToTracking.gif" id="addToTrackIcon' + (j+1) + '"></div><div class="toolbarText" onClick="showRegForm(\'listing\');" onMouseOver="imgSwap(\'addToTrackIcon' + (j+1) + '\',\'/propsearch/images/icon_addToTracking_over.gif\')"" onMouseOut="imgSwap(\'addToTrackIcon' + (j+1) + '\',\'/propsearch/images/icon_addToTracking.gif\')">Track</div>';			

			}
			
			
			
			
			
			
			

			//Block End

			rToolbar+='</div>';

			

			//COMBINE ALL UNITS AS ONE TO FORM ULTIMATE RESULT LISTING!

			rStyle='defaultResult';

			if (json.listings[j].listagent=='209868') { rStyle='exclusiveResult'; }

			rContent='<div id="mainResultDiv' + (j+1) + '" style="padding: 10px;" onMouseOver="resultOver(' + (j+1) + ');" onMouseOut="resultOut(' + (j+1) + ');"  class="' + rStyle + '">' + rTop + '<div id="resultBar' + (j + 1) + '" class="resultBar">' + rBottom +  rToolbar + '</div><div class="clearer"></div></div>';

			newdiv.innerHTML=rContent;



			//Set Variables used by other functions
			// @Revised 5/1/2009 by Adam 
			// Updated urls to show full property addresses

			if (json.listings[j].streetname=='NA') {myUrls[j + 1]= 'philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetname) + '/' + urlIt(json.listings[j].listnum) + '/'; }
			
			else if ((json.listings[j].streetdir !='' && json.listings[j].unit_num!='')) {myUrls[j + 1]= 'philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetnum) + '-' + urlIt(json.listings[j].streetdir) + '-' + urlIt(json.listings[j].streetname) + '-' + urlIt(json.listings[j].unit_num) + '/' + urlIt(json.listings[j].listnum) + '/'; }

			else if (json.listings[j].streetdir !='' && json.listings[j].unit_num=='') {myUrls[j + 1]= 'philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetnum) + '-' + urlIt(json.listings[j].streetdir) + '-' + urlIt(json.listings[j].streetname) + '/' + urlIt(json.listings[j].listnum) + '/'; }

			else if (json.listings[j].streetdir =='' && json.listings[j].unit_num !='') {myUrls[j + 1]= 'philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetnum) + '-' + urlIt(json.listings[j].streetname) + '-' + urlIt(json.listings[j].unit_num) + '/' + urlIt(json.listings[j].listnum) + '/'; }

			else {myUrls[j + 1]= 'philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetnum) + '-' + urlIt(json.listings[j].streetname) + '/' + urlIt(json.listings[j].listnum) + '/'; }

			myPids[j + 1]=json.listings[j].propid;

			myLats[j]=json.listings[j].latitude;

			myLongs[j]=json.listings[j].longitude;

			myImages[j]=json.listings[j].path;

			myLinks[j]='http://www.centercityrealestate.com/philadelphia/listings/' + urlIt(json.listings[j].sub_nbhd) + '/' + urlIt(json.listings[j].streetname) + '/' + urlIt(json.listings[j].listnum) + '/';

			if (json.listings[j].streetname!='NA') {

				showZoom[j]=1;

				showPhotos[j]=1;	

				myInfo[j]='<div class="redBoldText">' + json.listings[j].streetnum + ' ' + strdir + json.listings[j].streetname + '</div><div>' + json.listings[j].bedrooms + ' br ' + (parseInt(json.listings[j].fullbaths)) + ' ba<br>'  + json.listings[j].type_of_prop + '<br>$'  + addCommas(json.listings[j].listprice) + '<br><a href="#resultDiv' + (j+1) + '">View Details</a></div>';

			} else {

				myInfo[j]='<div>' + json.listings[j].bedrooms + ' br ' + (parseInt(json.listings[j].fullbaths)) + ' ba<br>'  + json.listings[j].type_of_prop + '<br>$'  + addCommas(json.listings[j].listprice) + '<br><a href="#resultDiv' + (j+1) + '">View Details</a></div>';			

			}

			if (json.listings[j].streetname!='NA') {

				myTips[j]=json.listings[j].streetnum + ' ' + strdir + json.listings[j].streetname + ' - $' + addCommas(json.listings[j].listprice);

			} else {

				myTips[j]='$' + addCommas(json.listings[j].listprice);			

			}

			

		   

		}

		}

	

		//print out new table data

		//document.getElementById("resultsContainer").innerHTML = output;		

		//if (sortDiv[0]) { document.getElementById(sortDiv[0]).innerHTML = sortDiv[1]; }



		//print out pagination

		var pagination = '';

		//alert (page*20);

		//alert (json.count[0].count);

		numpages = Math.round((json.count[0].count / 20) + .5);

		displayPagination(numpages,json.count[0].count)

				

		//clear and restup markers

		if (myLats[0]==null) {

			map.setCenter(new GLatLng(defaultLatitude, defaultLongitude), 13);						

		} else {

			map.setCenter(new GLatLng(myLats[0], myLongs[0]), 13);			

		}

		setMarkers(myLats, myLongs, myInfo, myImages);

	

	if (clickResult!='') { propClick(clickResult,clickId,clickListnum,'results'); clickResult=''; }

	

	

	if (json.count[0].count==0) {

		document.getElementById("resultsContainer").innerHTML='<div style="font-size: 14px; border: 2px solid #ee3b34; padding: 5px; "><div style="float: left;"><img src="/images/error_logo.png"></div><div style="float: left; padding-top: 8px; padding-left: 15px;">Sorry your search yielded no results.</div><div class="clearer"></div></div><div style="font-size: 14px; margin-top: 10px; font-size: 14px;"><b>Here are some suggestions</b><ul><li>Check the spelling</li><li>Broaden your search by using less words</li><li>Use the neighborhood list to match neighborhoods</li></ul></div><div style="margin-top: 10px; font-size: 14px; ">Still having problems? <a href="mailto:ant@atacangroup.com">Let us know</a></div>';

		document.getElementById("pagination").innerHTML = "";

		document.getElementById("topPagination").innerHTML = "";				

	} else {

		document.getElementById("bottomOptions").style.visibility="visible";

		document.getElementById("topOptions").style.visibility="visible";	

	}

	

	hideLoader();

    },

    onFailure: function(){

		//document.getElementById("loading").style.display="none"; alert('Error while loading results. Please try again.');

	}

  }).request();



}



function changePage(p) {

	page=(p - 1);

	lastaction="changePage";

	updateListings();

}



function makePageButton(pageNum) {

	if (pageNum==(page+1)) {

		pageButton='<span class="pageSel">' + pageNum + ' | </span>';

	} else {

		pageButton='<span class="pageButton" onClick="changePage(' + pageNum + ');">' + pageNum + ' | </span>';

	}

	return (pageButton);

}







function displayPagination (numpages,ttlres) {

	var sHead = document.getElementById("resultCount");

	if (searchType!='recent') {

		sHead.innerHTML = 'Search Results <span style="color: #6699cc">(' + addCommas(ttlres) + ')</span>';

	} else {

		sHead.innerHTML = 'Recently Viewed';

	}

	if ((page+1)==numpages) { displayof=ttlres; } else { displayof=((page * 20) + 20); }

	var pagination ='';

	//if (page>0) pagination+='<td class="pageButton" onClick="changePage(' + (page) + ');"><img src="/propsearch/images/btn_prev.png"></td>';

	if (page>0) pagination+='<span class="pageButton" onClick="changePage(' + (page) + ');">Prev | </span>';

	if (numpages<=5) {

			for (p=1;p<=numpages;p++) {

				pagination+=makePageButton(p);			

				//pagination+='<td class="pageButton" onClick="changePage(' + p + ');">' + p + '</td>';

			}		

	} else {

/*

		if (page>3) {

			pagination+=makePageButton(1);

			pagination+=makePageButton(2);

			pagination+='<span class="pageElps">...</span>';

		}

*/



		if ((page+3)>=numpages) pagination+=makePageButton((page-3));			

		if ((page+2)>=numpages) pagination+=makePageButton((page-2));

		if ((page-1)>0) pagination+=makePageButton((page-1));

		if ((page)>0) pagination+=makePageButton((page));	

		pagination+=makePageButton((page+1));

		if ((page+2)<numpages) pagination+=makePageButton((page+2));			

		if ((page+3)<numpages) pagination+=makePageButton((page+3));

		if ((page)<=0) pagination+=makePageButton((page+4));			

		if ((page-1)<=0) pagination+=makePageButton((page+5));

		

/*

		if (page<(numpages-4)) {

			pagination+='<span class=="pageElps">...</span>';

			pagination+=makePageButton((numpages - 1));

			pagination+=makePageButton((numpages));

		}		

*/

	}

	

	//if ((page + 1)<numpages) pagination+='<td class="pageButton" onClick="changePage(' + (page + 2) + ');"><img src="/propsearch/images/btn_next.png"></td>';

	if ((page + 1)<numpages) pagination+='<span class="pageButton" onClick="changePage(' + (page + 2) + ');"> Next</span>';

	//pagination+='</tr></table>';

	if (numpages>0) {

	document.getElementById("pagination").innerHTML = pagination;

	document.getElementById("topPagination").innerHTML = pagination;	

	} else {

	document.getElementById("pagination").innerHTML = '';

	document.getElementById("topPagination").innerHTML = '';		

	}

}



function getWindowHeight() {

var windowHeight=0;

if (typeof(window.innerHeight)=='number') {

windowHeight=window.innerHeight;

}

else {

if (document.documentElement&&document.documentElement.clientHeight) {

windowHeight=document.documentElement.clientHeight;

}

else {

if (document.body&&document.body.clientHeight) {

windowHeight=document.body.clientHeight;

}

}

}

return windowHeight;

}



function getWindowWidth() {

	var windowWidth=0;

	if (typeof(window.innerWidth)=='number') {

		windowWidth=window.innerWidth;

	} else {

		if (document.documentElement&&document.documentElement.clientWidth) {

			windowWidth=document.documentElement.clientWidth;

		} else {

			if (document.body&&document.body.clientWidth) {

				windowWidth=document.body.clientWidth;

			}

		}

	}

	return windowWidth;

}



function login() {

	document.getElementById("hoodBreakdown").style.visibility="hidden";

	document.getElementById("hoodBreakdown").style.left= "-50px";	

	m = document.getElementById("loginBox");

	lc = document.getElementById("login");	

	m.style.height=document.body.clientHeight + 'px';

	m.style.zIndex = 200;	

	st = getScrollTop();

	lc.style.top = parseInt(getWindowHeight() / 2) + st - 221 + "px";

	lc.style.left = parseInt(getWindowWidth() / 2) - 415 + "px";	

	m.style.visibility = "visible";

	m.style.display = "block";	

	document.getElementById("username").focus();

}



function feedback() {

	if (document.getElementById("hoodBreakdown")) {

		document.getElementById("hoodBreakdown").style.visibility="hidden";

		document.getElementById("hoodBreakdown").style.left= "-50px";	

	}

	m = document.getElementById("feedbackBox");

	lc = document.getElementById("feedback");	

	m.style.height=document.body.clientHeight + 'px';

	m.style.zIndex = 200;	

	st = getScrollTop();

	lc.style.top = parseInt(getWindowHeight() / 2) + st - 221 + "px";

	lc.style.left = parseInt(getWindowWidth() / 2) - 251 + "px";	

	m.style.visibility = "visible";

	m.style.display = "block";	

}





function closeLoginWindow() {

	document.getElementById("hoodBreakdown").style.visibility="visible";	

	m = document.getElementById("loginBox");

	m.style.visibility = "hidden";

	m.style.zIndex = -200;

}



function closeFeedbackWindow() {

	if (document.getElementById("hoodBreakdown")) {	

		document.getElementById("hoodBreakdown").style.visibility="visible";	

	}

	m = document.getElementById("feedbackBox");

	m.style.visibility = "hidden";

	m.style.zIndex = -200;

}



function submitFeedback(username, passwd, message) {

	var rurl='/propsearch/myinc/ajax/feedback.php?name=' + document.getElementById("feedbackName").value + '&email=' + document.getElementById("feedbackEmail").value + '&message=' + document.getElementById("feedbackMessage").value;

	new Ajax(rurl,

	{

	method:'get',

	onComplete: function(response){

		if (response) {

			closeFeedbackWindow();

		} else {

			alert('There was an error submitting feedback please try again later.');

		}

	}

	}).request();

}



function submitLogin(username,passwd) {

	var rurl='/propsearch/myinc/ajax/login.php?username=' + username + '&passwd=' + passwd;

	new Ajax(rurl,

	{

	method:'get',

	onComplete: function(response){

		if (response) {

			closeLoginWindow();

			updateListings();

			document.getElementById("myAtacan").innerHTML='My Atacan';

		} else {

			alert('Invalid username and/or password.');

		}

	}

	}).request();

}



function submitLoginOnKey(username,passwd,e) {

	if (window.event) {

		if (e.keyCode==13) submitLogin(username,passwd);

	} else {

		if (e.which==13) submitLogin(username,passwd);

	}

}



function showLegal() {

		switch (legal) {

			case 1: 

				document.getElementById("kellerText").style.display="none";

				legal=0;

			break;				

			default: 

				document.getElementById("kellerText").style.display="block";

				legal=1;

			break;

		}

}



function getCheckedValue(el) {

 	var els = document.getElementsByName(el);

	for (var x=0;x<els.length;x++) {

		if (els[x].checked==true) {

			return els[x].value;

		}

	}

	return false;

}



function submitRegistration() {

	var msg = '';

	var firstname=document.getElementById('fname').value;

	var lastname=document.getElementById('lname').value;

	var email=document.getElementById('remail').value;

	var emailchk=document.getElementById('emailchk').value;

	var passwd=document.getElementById('setpasswd').value;

	var phone=document.getElementById('phone').value;

	var cnotice=document.getElementById('cnotice').checked;

	var foundout=document.getElementById('foundfrom').value;

	var agentyesno = getCheckedValue("agentyesno");

	var mortyesno = getCheckedValue("mortyesno");

	var analysisyesno = getCheckedValue("analysisyesno");

	var movetime = getCheckedValue("movetime");

	

	if (cnotice==false) { msg +='\nMust Read Consumer Notice'; }

	if (firstname=='') { msg +='\nFirst Name Missing'; }

	if (lastname=='') { msg +='\nLast Name Missing'; }

	if (passwd=='') { msg +='\nPassword missing'; }

	if (email=='') { msg +='\nEmail Address Missing'; }

	if (phone=='') { msg +='\nPhone Number Missing'; }

	if (foundout=='') { msg +='\nHow You Heard of Atacan Missing'; }

	if (agentyesno=='') { msg +='\nDo You Have an Agent Missing'; }

	if (mortyesno=='') { msg +='\nDo You Want Mortgage Info Missing'; }

	if (analysisyesno=='') { msg +='\nDo You Want a Market Analysis Missing'; }

	if (movetime=='') { msg +='\nWhen Do You Want to Move Missing'; }

	if (email!=emailchk) { msg+='\nEmails dont match' };

	if (msg!='') {

		alert('Please correct the following errors: ' + msg);

	} else {

		var rurl='/propsearch/myinc/ajax/register.php?firstname=' + firstname + '&lastname=' + lastname + '&email=' + email + '&passwd=' + passwd + '&phone=' + phone + '&foundout=' + foundout;

		rurl += '&agentyesno=' + agentyesno + '&mortyesno=' + mortyesno + '&analysisyesno=' + analysisyesno + '&movetime=' + movetime;

		//alert(rurl);

		new Ajax(rurl,

		{

		method:'get',

		onComplete: function(response){

			if (response) {

				closeLoginWindow();

				updateListings();

			} else {

				alert('Email address already exists!');

			}

		}

		}).request();

	}

}



function windimension(){

	if(window.innerHeight !==undefined)A= [window.innerWidth,window.innerHeight]; // most browsers

	else{ // IE varieties

		var D= (document.body.clientWidth)? document.body: document.documentElement;

		A= [D.clientWidth,D.clientHeight];

	}

	return A;

}



function credits() {

	m = document.getElementById("creditsBox");

	lc = document.getElementById("credits");	

	m.style.height=document.body.clientHeight + 'px';

	m.style.zIndex = 200;	

	st = getScrollTop();

	lc.style.top = parseInt(getWindowHeight() / 2) + st - 221 + "px";

	lc.style.left = parseInt(getWindowWidth() / 2) - 251 + "px";	

	m.style.visibility = "visible";

	m.style.display = "block";	

}



function closeCreditsWindow() {

	m = document.getElementById("creditsBox");

	m.style.visibility = "hidden";

	m.style.zIndex = -200;

}



function getScrollTop() {

	var st1 = document.documentElement.scrollTop;

	var st2 = document.body.scrollTop;

	var st3 = window.pageYOffset;

	var st = 0;

	if (st1 + st2 + st3 != 0) {

		if (st1 && st1 != 0) {

			st = st1;

		} else if (st2 && st2 != 0) {

			st = st2;

		} else if (st3 && st3 != 0) {

			st = st3;

		}

	}

	return st;

}





function move_in(img_name,img_src) {

	document[img_name].src=img_src;

}



function move_out(img_name,img_src) {

	document[img_name].src=img_src;

}



function popSearches() {

	var n_div = document.getElementById("savedSearchesDiv");

	switch (n_div.style.display) {

		case "block":

			n_div.style.display = "none";

			break;

		case "none":

			n_div.style.display = "block";

			break;

		default:

			n_div.style.display = "block";

			break;

	}

}





function nav_popNeighborhoodSelects() {

	var n_div = document.getElementById("nav_neighborhoodSelectsDiv");

	var n_arr = document.getElementById("nav_neighborhoodSelectsArrow");

	switch (n_div.style.display) {

		case "block":

			n_div.style.display = "none";

			n_arr.src = "/images/select_downarrow_blue.gif";

			break;

		case "none":

			n_div.style.display = "block";

			n_arr.src = "/images/select_uparrow_blue.gif";

			break;

		default:

			n_div.style.display = "block";

			n_arr.src = "/images/select_uparrow_blue.gif";

			break;

	}

}



function popNeighborhoodSelects() {

	var n_div = document.getElementById("neighborhoodSelectsDiv");

	var n_arr = document.getElementById("neighborhoodSelectsArrow");

	n_div.style.marginLeft = "9px";

	//n_div.style.top=document.getElementById("seeAllHoods").offsetHeight + document.getElementById("seeAllHoods").offsetTop;

	switch (n_div.style.display) {

		case "block":

			n_div.style.display = "none";

			updateListings();

			break;

		case "none":

			n_div.style.display = "block";

			break;

		default:

			n_div.style.display = "block";

			break;

	}

}







function expandAllLoader() {

	document.getElementById("expandAllButton").innerHTML='<span class="jsLink"><img src="/propsearch/images/waiting.gif"></span>';

	window.setTimeout("expandAll()", 500);

}



//Woah Boy Here We Go

function expandAll () {

	switch(viewMode) {

		case "expanded":

			document.getElementById("rightTop").style.display="block";	  

			showMap();

			document.getElementById("expandAllButton").innerHTML='<span class="jsLink" onClick="expandAllLoader();" style="font-size: 11px; font-weight: bold;"><img src="http://www.centercityrealestate.com/propsearch/images/arrow_blue_down.png"> Expand All Listings</span>';

			updateListings();

			viewMode='normal';

		break;

		default:

			hideMap();

			document.getElementById("rightTop").style.display="none";	  

			

			rurlId='';

			

			for (j=1;j<(myPids.length);j++) {

				if (rurlId!='') { rurlId+='&'; }

				rurlId+='rid[]=' + myPids[j];

			}

				
	//alert("1." + rurlId);
			rurl='/propsearch/myinc/ajax/getdetails.php?' + rurlId;

			//document.getElementById("debug").innerHTML=rurl;

			

			//rDiv = document.getElementById("remark" + x);

			//rDiv.innerHTML = '<img src="/propsearch/images/waiting.gif">';	

			//rid=myPids[x].substr(0,-2);

	

			new Ajax (rurl,

			 {

				method:'get',

				onComplete: function(response){

					json = eval('(' + response + ')');

					for (j=0;j<(json.remarks.length);j++) {

					  rDiv = document.getElementById("remark" + (j+1));

					  var remark="No Description Posted";

					  if (json.remarks[j]=='') { remark="No Description Posted"; } else { remark=json.remarks[j]; }

					  var elps = '';

					  if (remark.length>350) { elps = '...'; }

					  rDiv.innerHTML = remark.substr(0,350) + elps;

					}

				},

				onFailure: function(){ }

			 }).request();



			rurlId='';

			for (j=1;j<(myPids.length);j++) {

				if (rurlId!='') { rurlId+='&'; }

				rurlId+='rid[]=' + myPids[j];
				//.substr(0,(myPids[j].length - 2));

			}


			//alert("2." + rurlId);
			rurl='/propsearch/myinc/ajax/getphotos.php?' + rurlId;

			//document.getElementById("debug").innerHTML=rurl;

			
//alert(rurl);
			

			new Ajax (rurl,

			  {

				method:'get',

				onComplete: function(response){

				  var response = response;

				  json = eval('(' + response + ')');


				
					for (j=0;j<(json.photos.length);j++) {

										

						if (json.photos[j]) {
							
							
							if (json.photos[j].length>1) {

								var photoContainerHTML = '<table width="150" cellpadding="0" cellspacing="0"><tr height="150"><td colspan="3"><img width="150" height="150" id="photo' + (j + 1) + '" src="/propsearch/resize/med/' + json.photos[j][0].pic_name + '"></td></tr><tr><td><img class="photoButtons" src="/propsearch/images/left_arrow_on.gif" onClick="prevPhoto(\''+ (j+1) +'\');"></td><td align="center"><div id="pnum' + (j+1) + '">1 of ' + (json.photos[j].length) + '</div></td><td align="right"><img class="photoButtons" vspace="3" src="/propsearch/images/right_arrow_on.gif" onClick="nextPhoto(\''+ (j + 1) +'\');"></td></tr></table>';

								photoDiv = document.getElementById('photos' + (j+1));

								

								var photoList = new Array();

								photoList[0]=1;

								for (var v = 0; v < json.photos[j].length; v++) {

									photoList[(v + 1)]=json.photos[j][v].pic_name;

									//photoDiv.innerHTML = 'test';

									//alert(json.photos[j].pic_id);

								}

								listImages[j+1]=photoList;

								if (photoDiv) photoDiv.innerHTML = photoContainerHTML;

							}

						}

					}



				  

				},

				onFailure: function(){  }

			  }).request();			





			for (x=1;x<myPids.length;x++) {

			

				mi= document.getElementById('mi' + x);

				if (mi) { mi.innerHTML = '<div style="float: left; padding-right: 5px;"><img src="/propsearch/images/closeInfo.png"></div><div>Hide Info</div>'; }

				/*rurl='/propsearch/myinc/ajax/getphotos.php?rid=' + rid;



				new Ajax (rurl,

				  {

					method:'get',

					onComplete: function(response){

					  var response = response;

					  json = eval('(' + response + ')');

					  if (json.photos) {

						  if (json.photos.length>1) {

							var photoContainerHTML = '<table width="150" cellpadding="0" cellspacing="0"><tr height="150"><td colspan="3"><img width="150" height="150" id="photo' + (i) + '" src="resize/med/' + json.photos[0].pic_name + '"></td></tr><tr><td><img class="photoButtons" src="/propsearch/images/left_arrow_on.gif" onClick="prevPhoto(\''+ (i) +'\');"></td><td align="center"><div id="pnum' + (i) + '">1 of ' + (json.photos.length) + '</div></td><td align="right"><img class="photoButtons" vspace="3" src="/propsearch/images/right_arrow_on.gif" onClick="nextPhoto(\''+ (i) +'\');"></td></tr></table>';

							photoDiv = document.getElementById('photos' + x);

						  

							var photoList = new Array();

							photoList[0]=1;

							for (var j = 0; j < json.photos.length; j++) {

								photoList[(j + 1)]=json.photos[j].pic_name;

								//photoDiv.innerHTML = 'test';

								//alert(json.photos[j].pic_id);

							}

						listImages[i]=photoList;

						if (photoDiv) photoDiv.innerHTML = photoContainerHTML;

						  }

					  }

					},

					onFailure: function(){  }

				  }).request();*/



				rrow = document.getElementById('resultBar' + x); 

				drow= document.getElementById('details' + x);

				if (drow) { drow.style.display = "block"; }

				if (rrow) { rrow.style.display = "block";   }				  



				resultMap = new GMap2(document.getElementById("resultMap" + (x)));

				if (resultMap) {

					point=new GLatLng(myLats[(x-1)],myLongs[(x-1)]);

					resultMap.setCenter(point, 13);

					smallMarker=resultMap.addOverlay(new GMarker(new GLatLng(myLats[(x-1)],myLongs[(x-1)]), markerOptions));

				}





				mi= document.getElementById('mi' + x);

				if (mi) { mi.innerHTML = '<div style="float: left; padding-right: 5px;"><img src="/propsearch/images/closeInfo.png"></div><div>Hide Info</div>'; }		

			

			}



			viewMode="expanded";

			

			document.getElementById("expandAllButton").innerHTML='<span class="jsLink" onClick="expandAll();">Collapse All Listings</span>';





		break;

		

		

		

	}

}



function imgSwap(theImg,swpImg) {

	document.getElementById(theImg).src = swpImg;

}



function track(tusername,ttype,tpage,turl,tmisc,tlistnum) {

	var rurl='/myinc/ajax/track.php?username=' + tusername + '&type=' + ttype + '&url=' + tpage + '&misc=' + tmisc + '&listnum=' + tlistnum;

	new Ajax(rurl,

	{

	method:'get',

	onComplete: function(response){

		if (response) {

			

		} else {

			

		}

	}

	}).request()

}



function fadeOut(w) {

	fxthis=document.getElementById(w);



	var fx = new Fx.Styles(fxthis, {duration:700, wait:false});



	fx.start({

		'opacity': '0'

	});

}



function fadeIn(w) {

	fxthis=document.getElementById(w);



	var fx = new Fx.Styles(fxthis, {duration:700, wait:false});



	fx.start({

		'opacity': '1'

	});

}



function showTab(w) {

	switch (w) {

		case "tabConsultants":

			 curTabOn="consultantsTab";

			 $("techTab").className="tabOff";

			 $("toolsTab").className="tabOff";

		break;

		case "tabTechnology": 

			curTabOn="techTab";

			$("consultantsTab").className="tabOff";

			$("toolsTab").className="tabOff";

		break;

		case "tabTools": 

			curTabOn="toolsTab";

			$("techTab").className="tabOff";

			$("consultantsTab").className="tabOff";

		break;				

	}

	$(curTab).style.display="none";

	$(w).style.display="block";

	curTab=w;

}



function showTabOld(w) {

	switch (w) {

		case "tabConsultants":

			 curTabOn="consultantsTab";

			 $("techTab").className="tabOff";

			 $("toolsTab").className="tabOff";

		break;

		case "tabTechnology": 

			curTabOn="techTab";

			$("consultantsTab").className="tabOff";

			$("toolsTab").className="tabOff";

		break;

		case "tabTools": 

			curTabOn="toolsTab";

			$("techTab").className="tabOff";

			$("consultantsTab").className="tabOff";

		break;				

	}

	//Sometimes it works sometimes it does not so i put in this crap.

	$('tabConsultants').style.zIndex='-100';

	$('tabTechnology').style.zIndex='-100';

	$(w).style.zIndex='100';

	fadeIn(w);

	fadeOut(curTab);

	$(curTab).style.display='-100';

	curTab=w;

}



function getSavedProperties() {

	spBox=document.getElementById("savedProperties");

	var rurl='/propsearch/myinc/ajax/getsavedproperties.php';

	new Ajax(rurl,

	{

	method:'get',

	onComplete: function(response){

		if (response) {

			spBox.innerHTML=response;

		} else {

			spBox.innerHTML='Error Loading Saved Properties';

		}

	}

	}).request();	

}



function getSavedSearches() {

	var ssBox=document.getElementById("savedSearches");

	var rurl='/propsearch/myinc/ajax/getsavedsearches.php';

	new Ajax(rurl,

	{

	method:'get',

	onComplete: function(response){

		if (response) {

			ssBox.innerHTML=response;

		} else {

			ssBox.innerHTML='Error Loading Saved Searches';

		}

	}

	}).request();	

	getSavedSearchesCount();

}



function getSavedSearchesCount() {

	var ssBox=document.getElementById("savedSearchesCount");

	var rurl='/propsearch/myinc/ajax/getsavedsearchescount.php';

	new Ajax(rurl,

	{

	method:'get',

	onComplete: function(response){

		if (response) {

			ssBox.innerHTML=response;

		} else {

			ssBox.innerHTML='Error Loading Saved Searches';

		}

	}

	}).request();	

}



function saveState(s) {

	var fptype = new Array();

	var fstyles = new Array();

	var fneighborhoods = new Array();

	var fbedrooms = new Array();

	var fbathrooms = new Array();

	fptype=ptype.split("&p[]=");

	fstyles=styles.split("&s[]=");

	fneighborhoods=neighborhoods.split("&n[]=");

	fbedrooms=bedrooms.split("&beds[]=");

	fbaths=baths.split("&baths[]=");

	searchData[s]['location']=zipCode;

	searchData[s]['min']=priceMin;

	searchData[s]['page']=page;

	searchData[s]['max']=priceMax;

	searchData[s]['sqftlow']=sqftFrom;

	searchData[s]['sqftHigh']=sqftTo;

	searchData[s]['age']=age;

	searchData[s]['basement']=basement;

	searchData[s]['garage']=garage;

	searchData[s]['ac']=ac;

	searchData[s]['fireplace']=fireplace;

	searchData[s]['streetSearch']=streetSearch;

	searchData[s]['parking']=parking;

	searchData[s]['n']=fneighborhoods;

	searchData[s]['p']=fptype;

	searchData[s]['s']=fstyles;

	searchData[s]['beds']=fbedrooms[1];

	searchData[s]['baths']=fbaths[1];

	searchData[s]['sortby']=sortBy;

	searchData[s]['exclusive']=exclusive;

	searchData[s]['havePhoto']=havePhoto;

	searchData[s]['newListings']=newListings;
	
	

	searchData[s]['mls']=mls;

	searchData[s]['keyword']=keyword;

}



function saveSearchSession() {

	var sName = document.getElementById('searchName').value;

	var rurl='/propsearch/myinc/ajax/savesearchsession.php?location=' + zipCode + '&min=' + priceMin + '&page=' + page + '&max=' + priceMax + '&sqftlow=' + sqftFrom + '&sqftHigh=' + sqftTo + '&age=' + age + '&basement=' + basement + '&garage=' + garage + '&ac=' + ac +  '&fireplace=' + fireplace + '&street=' + streetSearch + '&parking=' + parking + neighborhoods + ptype + styles + bedrooms + baths + '&sortby=' + sortBy + '&exclusive=' + exclusive + '&havePhoto=' + havePhoto + '&newListings=' + newListings + '&mls=' + mls + '&keyword=' + keyword + '&name=' + sName;

	//document.getElementById("debug").innerHTML=rurl;

	

	

	

	new Ajax(rurl,

	{

	  method:'get',

	  onComplete: function(response){

	},

	onFailure: function(){

	}

	}).request();

}



function saveSearch() {

	var sName = document.getElementById('searchName').value;

	var rurl='/propsearch/myinc/ajax/savesearch.php?location=' + zipCode + '&min=' + priceMin + '&page=' + page + '&max=' + priceMax + '&sqftlow=' + sqftFrom + '&sqftHigh=' + sqftTo + '&age=' + age + '&basement=' + basement + '&garage=' + garage + '&ac=' + ac +  '&fireplace=' + fireplace + '&street=' + streetSearch + '&parking=' + parking + neighborhoods + ptype + styles + bedrooms + baths + '&sortby=' + sortBy + '&exclusive=' + exclusive + '&havePhoto=' + havePhoto + '&newListings=' + newListings + '&mls=' + mls + '&keyword=' + keyword + '&name=' + sName;

	//document.getElementById("debug").innerHTML=rurl;

	

	

	

	new Ajax(rurl,

	{

	  method:'get',

	  onComplete: function(response){

		alert("Search Saved Successfully.");

		$('searchName').value='';

		getSavedSearches();		

	},

	onFailure: function(){

	}

	}).request();

	

	

}





function processSearch(mySearch) {

			if (mySearch.sortby) {

				sortBy=mySearch.sortby;

			}

			if (mySearch.location) { document.getElementById("zipcode").value=mySearch.location; } else { document.getElementById("zipcode").value=""; }

			if (mySearch.min) { document.getElementById("min").value=(mySearch.min / 1000); } else { document.getElementById("min").value=""; }

			if (mySearch.max) { document.getElementById("max").value=(mySearch.max / 1000); } else { document.getElementById("max").value=""; }

			if (mySearch.sqftlow) { document.getElementById("sqftFrom").value=mySearch.sqftlow; } else { document.getElementById("sqftFrom").value=""; }

			if (mySearch.sqftHigh) { document.getElementById("sqftTo").value=mySearch.sqftHigh; }	else { document.getElementById("sqftTo").value=""; }	

			if (mySearch.mls) { document.getElementById("mls").value=mySearch.mls; } else { document.getElementById("mls").value=""; }

			if (mySearch.keyword)	{ document.getElementById("keyword").value=mySearch.keyword; } else { document.getElementById("keyword").value=""; }

			if (mySearch.streetSearch)	{ document.getElementById("searchBar").value=mySearch.streetSearch; } else { document.getElementById("searchBar").value=""; }

			

			if (mySearch.basement=='Y') { document.getElementById("basement").checked=true; } else { document.getElementById("basement").checked=false; }

			if (mySearch.fireplace=='Y') { document.getElementById("fireplace").checked=true; } else { document.getElementById("fireplace").checked=false; }			

			if (mySearch.parking=='Y') { document.getElementById("parking").checked=true; } else { document.getElementById("parking").checked=false; }

			if (mySearch.newListings=='Y') { document.getElementById("newListings").checked=true; } else { document.getElementById("newListings").checked=false; }

			if (mySearch.havePhoto=='Y') { document.getElementById("havePhoto").checked=true; } else { document.getElementById("havePhoto").checked=false; }

			if (mySearch.exclusive=='Y') { document.getElementById("el").checked=true; } else { document.getElementById("el").checked=false; }

			if (mySearch.garage=='Y') { document.getElementById("garage").checked=true; } else { document.getElementById("garage").checked=false; }

			if (mySearch.ac=='Y') { document.getElementById("ac").checked=true; } else { document.getElementById("ac").checked=false; }

			

			document.getElementById("type1").checked=false;


			document.getElementById("type3").checked=false;

			document.getElementById("type4").checked=false;								

			document.getElementById("type5").checked=false;

			document.getElementById("type6").checked=false;

			document.getElementById("type7").checked=false;

			

			

			if (mySearch.p) {

				var pType=mySearch.p;								

				

				

				for (var x=0;x<pType.length;x++) {

					switch (pType[x]) {

						case "SNG": document.getElementById("type1").checked=true; break;


						case "FLT": document.getElementById("type3").checked=true; break;

						case "MLT": document.getElementById("type4").checked=true; break;

						case "COM": document.getElementById("type5").checked=true; break;

						case "LOT": document.getElementById("type6").checked=true; break;

						case "OTH": document.getElementById("type7").checked=true; break;

					}

				}

			}





			document.getElementById("style1").checked=false;

			document.getElementById("style2").checked=false;

			document.getElementById("style3").checked=false;

			document.getElementById("style4").checked=false;

			document.getElementById("style5").checked=false;

			document.getElementById("style6").checked=false;

			document.getElementById("style7").checked=false;

			document.getElementById("style8").checked=false;

			document.getElementById("style9").checked=false;

			document.getElementById("style10").checked=false;

			document.getElementById("style11").checked=false;

			document.getElementById("style12").checked=false;

			document.getElementById("style13").checked=false;

			document.getElementById("style14").checked=false;

			document.getElementById("style15").checked=false;

			

			if (mySearch.s) {

				var sType=mySearch.s;





				for (var x=0;x<sType.length;x++) {

					

					switch (sType[x]) {

						case "StraightThru": document.getElementById("style1").checked=true; break;

						case "Contemporary": document.getElementById("style2").checked=true; break;

						case "Colonial": document.getElementById("style3").checked=true; break;

						case "AirLite": document.getElementById("style4").checked=true; break;

						case "EndUnit/Row": document.getElementById("style5").checked=true; break;

						case "Traditional": document.getElementById("style6").checked=true; break;

						case "Victorian": document.getElementById("style7").checked=true; break;

						case "Ranch": document.getElementById("style8").checked=true; break;

						case "SingleWide": document.getElementById("style9").checked=true; break;

						case "DoubleWide": document.getElementById("style10").checked=true; break;

						case "Bunglalow": document.getElementById("style11").checked=true; break;

						case "Cape": document.getElementById("style12").checked=true; break;																

						case "Tudor": document.getElementById("style13").checked=true; break;

						case "Trinity": document.getElementById("style14").checked=true; break;

						case "OtherStyle": document.getElementById("style15").checked=true; break;																		

					}

				}

			}							

			

			if (mySearch.age) {

				var age = mySearch.age;

				age=age.toString();

				switch(age) {

					case "1": document.getElementById("age2").checked=true; break;

					case "10": document.getElementById("age3").checked=true; break;

					case "20": document.getElementById("age4").checked=true; break;

					case "40": document.getElementById("age5").checked=true; break;

					case "60": document.getElementById("age6").checked=true; break;

					case "100": document.getElementById("age7").checked=true; break;										

					default: document.getElementById("age1").checked=true; break;

				}

			} else {

					document.getElementById("age1").checked=true;

			}

			


			document.getElementById("beds1").checked=true;

			document.getElementById("beds2").checked=false;

			document.getElementById("beds3").checked=false;			

			document.getElementById("beds4").checked=false;

			document.getElementById("beds5").checked=false;						

			if (mySearch.beds) {

				var beds = mySearch.beds;

				beds=beds.toString();

				

				document.getElementById("beds1").checked=false;

				document.getElementById("beds2").checked=false;

				document.getElementById("beds3").checked=false;

				document.getElementById("beds4").checked=false;

				document.getElementById("beds5").checked=false;

				

				switch(beds) {

					case "1": document.getElementById("beds2").checked=true; break;

					case "2": document.getElementById("beds3").checked=true; break;

					case "3": document.getElementById("beds4").checked=true; break;

					case "4": document.getElementById("beds5").checked=true; break;										

					default: document.getElementById("beds1").checked=true; break;

				}

			}

			

			document.getElementById("baths1").checked=true;

			document.getElementById("baths2").checked=false;

			document.getElementById("baths3").checked=false;			

			document.getElementById("baths4").checked=false;

			document.getElementById("baths5").checked=false;			

			if (mySearch.baths) {

				var baths = mySearch.baths;

				baths=baths.toString();

				

				document.getElementById("baths1").checked=false;

				document.getElementById("baths2").checked=false;

				document.getElementById("baths3").checked=false;

				document.getElementById("baths4").checked=false;

				document.getElementById("baths5").checked=false;

				

				switch(baths) {

					case "1": document.getElementById("baths2").checked=true; break;

					case "2": document.getElementById("baths3").checked=true; break;

					case "3": document.getElementById("baths4").checked=true; break;

					case "4": document.getElementById("baths5").checked=true; break;										

					default: document.getElementById("baths1").checked=true; break;

				}

			}			

			

			

			var boxes=document.getElementsByName("hoodBoxes");

			for (var x=0;x<boxes.length;x++) {

				boxes[x].checked=false;

			}



			if (mySearch.n) {

				nData=mySearch.n;

				for (var x=0;x<nData.length;x++) {

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

						if (boxes[i].value==nData[x]) boxes[i].checked=true;

					}

				}

			}

			updateListings();

}



function getSearchSession() {



	if (searchSession==1) {

	

	var rurl='/propsearch/myinc/ajax/getsavedsearchsession.php';

	//alert (rurl);

	new Ajax(rurl,

	{

	method:'get',

	onComplete: function(response){

		if ((response) && (response!=0)) {

			var json = eval('(' + response + ')');

			processSearch(json.sData[0]);

			

		} else {

			//alert(response);

			updateListings();

		}

	}

	}).request();

	} else {

		updateListings();

	}

}



function getSearch(s) {

	var rurl='/propsearch/myinc/ajax/getsearch.php?s=' + s;

	//alert (rurl);

	new Ajax(rurl,

	{

	method:'get',

	onComplete: function(response){

		if (response) {

			var json = eval('(' + response + ')');

			processSearch(json.sData[0]);

			

		} else {

			alert("Error Loading Search.");

		}

	}

	}).request();	

	$('savedSearchesDiv').style.display='None';

	//document.getElementById("searchBar").value='';

}



