/*  Site.js V1.2
 *  (c) 2005-2009 Nebulous Marketing LLC
 *
 *
 *--------------------------------------------------------------------------*/
function st3_globalErrorHandler(e,f,g) {
return;
/* 	alert('Description: ' + e + ',\n URL: ' + f + ',\n Line #: ' + g); */
	try {
		st3_showLoading(false);
	}catch(e){}
	if(bDoJSErrors){
		var doAjax = new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
			parameters: {
				method: 'Ajax_LogError',
				vcURL: window.location.href,
				vcDesc: e,
				vcPage: f,
				vcLineNbr: g
			}
		});
	}
return;
}
window.onerror=st3_globalErrorHandler;
 
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
	ieversion = new Number(RegExp.$1) // capture x.x portion and store as a number

	if (ieversion>=8){

	} else if (ieversion>=7) {

	} else if (ieversion>=6) {
/* alert('Please make sure activeX is enabled!'); */
	} else if (ieversion>=5) {

	}
} else {

}

/* **************************** Results page functions... ************************************** */
function st3_getCompRecords(arrRecords){
	return st3_dspModal('dspComp',arrRecords);
}
function st3_RemoveComp(id,nListingsID){
	var Index = id.split('_')[2];
	confirm("Are you sure you want to remove this listing."); 
	$('st3_Address_' + Index,'st3_City_State_' + Index,'st3_Zip_' + Index,'st3_Photo_' + Index,'st3_Price_' + Index,'st3_Type_' + Index,'st3_Bedrooms_' + Index,'st3_Bathrooms_' + Index,'st3_SqFootage_' + Index,'st3_Remove_' + Index).invoke('remove');
	return;
}
function st3_dspResultsPhotoModal(item){
	var doModal = new Control.Modl(item,{
		hover: true,
		position: 'mouse',
		offsetTop: 20,
		contents: function(){
			return '<img src="' + item.src + '" width="160" alt="Listing Pic" border="0" />';
		}
	});
return;
}
function st3_registerResultsMiniModals(){
	$$('#st3 img.ResultsMiniThumbNail','#st3 img.ResultsThumbNail').each(function(item){
		var theItem = item.up();
	if(!Prototype.Browser.IE) {
		doModal = new Control.ToolTip(theItem,'<img src="' + item.src + '" width="220" alt="Listing Pic" border="0" />',{
			className: 'modal_container',
			closeOnClick:true
		});
	}
		if(item.hasClassName('ResultsMiniThumbNail')){theItem.hide()}
	});
return;
}
function st3_editSearch(){
	window.location.href = st3_SearchRoot + '?' + st3_strHREF.split('?')[1].replace(/&searchaction=[a-zA-Z_]+/i,"") + '&action=refine&searchaction=' + st3_arrURL.prevsearchaction;
return false;
}
function st3_buttonRollOvers(){
	$$('#st3 .st3_button').each(function(item){
		Event.observe(item, 'mouseover', function(e){
			var strImgName = item.src.split('/').pop();
			var strImgRoot = strImgName.split('.').shift();
			return item.src = st3_DomainRoot + 'images/buttons/' + strImgRoot + '_o.jpg';
		});
		Event.observe(item, 'mouseout', function(e){
			var strImgName = item.src.split('/').pop();
			return strImgName.indexOf('_') > 0?(item.src = st3_DomainRoot + 'images/buttons/' + strImgName.split('_').shift() + '.jpg'):(item.src = st3_DomainRoot + 'images/buttons/' + strImgName.split('.').shift() + '_o.jpg');
		});
	});
return;
}
function st3_resultsIconMouseOver(){
	$$('#st3 .st3_button').each(function(item){
		Event.observe(item, 'mouseover', function(e){
			var strImgName = item.src.split('/').pop();
			var strImgRoot = strImgName.split('.').shift();
			return item.src = st3_DomainRoot + 'images/buttons/' + strImgRoot + '_o.jpg';
		});
		Event.observe(item, 'mouseout', function(e){
			var strImgName = item.src.split('/').pop();
			return strImgName.indexOf('_') > 0?(item.src = st3_DomainRoot + 'images/buttons/' + strImgName.split('_').shift() + '.jpg'):(item.src = st3_DomainRoot + 'images/buttons/' + strImgName.split('.').shift() + '_o.jpg');
		});
	});
return;
}
function st3_showHide(img,ele,eff,dur){
	if(ele.split('_')[1]!='Details'){
		var index = ele.split('_')[1];
		$('ListingHeaderPicTH_' + index).toggle();
		$('ListingHeaderPicTH_' + index).up().toggle();
		$('ListingHeaderAdditionalFields_' + index).toggle();
	}
	($(ele).visible()) ? $(img).src = st3_DomainRoot + 'images/buttons/show-sm-btn_o.jpg' : $(img).src = st3_DomainRoot + 'images/buttons/hide-sm-btn_o.jpg';
	var doEffect = new Effect.toggle(ele,eff,{duration:dur});
return;
}
function st3_changeRPP(nbr){
	var cleanHref = window.location.href.replace(/&?rpp=[0-9]+/i, '');
	if (cleanHref.indexOf('?') > 0) {
		var strRPP = '&rpp=' + nbr;
	} else {
		var strRPP = '?rpp=' + nbr;
	}
	window.location.href = cleanHref + strRPP;
return false;	
}
function st3_changeSort(sort,order){
	var cleanHref = window.location.href.replace(/&?sort=[a-zA-Z]+/i, '');
 	cleanHref = cleanHref.replace(/&?order=[a-zA-Z]+/i, '');
	return window.location.href = cleanHref + '&sort=' + sort + '&order=' + order;
}
function st3_getModalWindowWidth(x){
	return parseInt(document.viewport.getWidth() - x);
}
function st3_getModalWindowHeight(y){
	return parseInt(document.viewport.getHeight() - y);
}
function st3_viewDetails(index){
	window.location.href = st3_SearchRoot + '?nListingsID=' + $('nListingsID_' + index).value + '&searchaction=details';
}
function st3_doSortables(id,onlyID){
//DISABLED DRAGGING FOR IE7 ISSUES
	if(Prototype.Browser.IE) {
		return;
	}

	if (!onlyID){
		onlyID = '';
	}
	var sortable = Sortable.create(id, {
		dropOnEmpty: true,
		tag: 'div',
		handle: 'Results_Header',
		constraint: false,
		only: onlyID,
		ghosting: false,
		revert: true
	});
}
function st3_doDroppables(){
//DISABLED DRAGGING FOR IE7 ISSUES
	if(Prototype.Browser.IE) {
		return;
	}

	var savedListingsDroppable = Droppables.add('st3_Saved_Listings_Display', {
		accept: 'Results_Draggable',
		hoverclass: 'st3_Cart_Hover',
		onDrop: function(element){			
			var nListingsID = element.id.split('_')[1];
			if(!st3_loggedin){
				arrDropListings.push(nListingsID);
				return st3_savedListings(nListingsID,'save','shoppingcart');
			}
			if (arrDropListings.indexOf(nListingsID) < 0){
				st3_savedListings(nListingsID,'save','shoppingcart');
				arrDropListings.push(nListingsID);
				var arrData = new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
					method: 'post',
					parameters: {
						nListingsID: nListingsID,
						arrListings: [],
						rpp: 1,
						method: 'Ajax_getCompRecords',
						id: siteID,
						uuid: st3_getUUID()
					},
					onSuccess: function(transport){
						var JSONResult = transport.responseText.evalJSON();
						JSONResult.QUERY.DATA.each(function(item,index){
							var eSaved = $('st3_Saved_Listings_Display');
							var a = new Element('div',{'id':'st3_saved_thumb_' + nListingsID,'style':'overflow:hidden;height:55px;width:98%;padding:2px;border-bottom:1px solid #CCC;display:table;text-align:left;'});
							var b = new Element('img',{'src':st3_ImageRoot+'buttons/close-sm-btn.jpg','style':'float:left;','onclick':'st3_RemoveSavedTH('+nListingsID+');return false;'});
							var c = new Element('div',{'style':'float:left;padding:0px 2px 0px 2px;height:55px;width:120px;overflow:hidden;'});
							var d = new Element('div').update(item[0]);
							var e = new Element('div').update(item[2] + ', ' + item[4] + ' ' + item[3]);
							var f = new Element('div').update(st3_formatCurrency(item[1],false));
							var g = new Element('img',{'src':item[5],'style':'height:40px;float:right;'});
							var h = new Element('div',{'class':'st3_clear_2'});
							a.insert(b).insert(c).insert(g);
							c.insert(d).insert(e).insert(f);
							eSaved.insert(a).insert(h);
						});
					}
				});
			} else {
				var mAlreadySaved = new Control.Modal.open(st3_showClose() + 'Sorry, you have already saved this listing.', {
					className:'modal_container',
					overlayOpacity:.01,
					closeOnClick:'container'
				});
			}
		}
	});
}
function st3_showClose(bUserTool){
	var content = '';
	content += '<div id="st3"><div id="st3_modal_header" style="cursor:move;"><div id="st3_close_modal"><a id="st3_modal_closer" href="javascript: void(0);" onclick="return false;" title="Close Window" style="float: left;vertical-align:top;font-size:13px;font-family:verdana;text-decoration:none;font-style:italic;">';
	content += '<img src="'+st3_DomainRoot+'images/buttons/close-sm-btn.jpg" alt="close" style="vertical-align:text-top;" border="0" />';
	content += ' &nbsp;Close This Window</a>&nbsp;';
	content += '</div>';
	if(arguments.length>0){
		content += '<div id="st3_Modal_Header_Message" style="float: right;width: 50%;text-align: center;border:0px none;"></div>';
	}
	content += '<div class="st3_clear_2"></div>';
	content += '<hr /></div></div>';
	return content;

/* 	return '<div id="st3_close_modal"><a href="javascript:void(0);" onclick="return false;" title="Close Window" style="vertical-align:top;font-size:13px;font-family:verdana;text-decoration:none;font-style:italic;"><img src="' + st3_DomainRoot + 'images/buttons/close-sm-btn.jpg" alt="close" border="0" /> Close This Window</a></div><hr style="border:0px none;border-top:1px solid #CCC !important;" />'; */
}
function st3_savedListings(nListingsID,strAction,mode){
	if (strAction!='save') {
		var bContinue = confirm('Are you sure you want to remove your saved listing?');
		if (!bContinue) {return false;}
	}
	if(strAction=='unsave'){
		if(Object.isElement($('st3_saved_thumb_'+nListingsID))){
			arrDropListings = arrDropListings.without(nListingsID);
			st3_RemoveSavedTH(nListingsID,false);
		}
	}
	if (!st3_loggedin){
		if(mode!='Ajax'){
			return st3_displayLoginForm('listing',nListingsID);
		} else {
			return st3_swapUserToolContent('SavedSearches_LoginForm','st3_Logout_Login','searchaction=SavedSearches_LoginForm&ListingNbr=' + nListingsID + '&strAction=' + strAction + '&mode=' + mode);
		}
	}
	var quotedMode = "'" + mode + "'";
	var theAction = strAction=='save'?"'unsave'":"'save'";
	var button = strAction=='save'?'remove-lrg-btn.jpg':'Save-lrg-btn.jpg';
	var doIt = new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
		showloading:mode=='SavedListings'||mode=='MapListings'||mode=='Ajax'?false:true,
		parameters: {
			method: 'Ajax_SavedListings',
			id: siteID,
			nListingsID: nListingsID,
			strAction: strAction,
			uuid: st3_getUUID()
			},
		method: 'post',
		onLoading: function() {
			if (mode=='SavedListings'||mode=='Ajax'){
				return $('st3_Modal_Header_Message').update('<img src="' + st3_DomainRoot + 'images/progress_bar.gif" alt="loading" border="0" /> Loading...');
			}
		},
		onSuccess: function(transport){
			var JSONResult = transport.responseText.evalJSON();
			if (mode=='SavedListingsFromLogin'){
				return $('st3_Modal_Header_Message').update(JSONResult.MESSAGE);
			}
			if(Object.isElement($('st3_saved_listing_' + nListingsID))){
				$('st3_saved_listing_' + nListingsID).update('<a href="javascript:void(0);" onclick="st3_savedListings(' + nListingsID + ',' + theAction + ',' + quotedMode + '); return false;"><img src="'+ st3_DomainRoot +'images/buttons/' + button + '" alt="Saved" border="0" class="st3_button" /></a>');
				return st3_doSubtleMessage(JSONResult.MESSAGE,'st3_saved_listing_' + nListingsID);
			}		
			if (mode=='SavedListings'){
				$('Listing_' + nListingsID + '_Ajax').remove();
				return $('st3_Modal_Header_Message').update(JSONResult.MESSAGE);
			} else if(mode=='MapListings'){
				$('st3_Map_footer_' + nListingsID).update('<a href="javascript:void(0);" onclick="st3_savedListings(' + nListingsID + ',' + theAction + ',' + quotedMode + '); return false;" id="st3_saved_listing_'+nListingsID+'"><img src="'+ st3_DomainRoot +'images/buttons/' + button + '" alt="Saved" border="0" /></a>');
				return st3_doSubtleMessage(JSONResult.MESSAGE,'st3_saved_listing_' + nListingsID);
			}
			if (mode=='Ajax'){
				return $('st3_Modal_Header_Message').update(JSONResult.MESSAGE);
			}
			if(Object.isElement($('st3_Modal_Header_Message'))){
				$('st3_Modal_Header_Message').update(JSONResult.MESSAGE);
			}
			st3_doSubtleMessage(JSONResult.MESSAGE,'ToolTable_' + nListingsID);
			return;
		}
	});
}
function st3_unSaveSearch(searchID,strName){
	var bContinue = confirm('Are you sure you want to delete your saved search?');
	if (!bContinue) {return false;}
	if (!st3_loggedin){
		return st3_displayLoginForm('listing',ListingNbr);
	}
	var doIt = new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
		parameters: {
			method: 'Ajax_unSaveSearch',
			id: siteID,
			nSearchesID: searchID,
			strName: strName,
			uuid: st3_getUUID()
			},
		method: 'post',
		onLoading: function() {
			return $('st3_Modal_Header_Message').update('<img src="' + st3_DomainRoot + 'images/progress_bar.gif" alt="loading" border="0" /> Loading...');
		},
		onSuccess: function(transport){
			var JSONResult = transport.responseText.evalJSON();
			$('st3_Modal_Header_Message').update(JSONResult.MESSAGE);
			$('Listing_' + searchID).remove();
		}
	});
}
function st3_initResults(){
	if(!Object.isElement('Results_Container')) {
		try{
			if(st3_isDefined(stURL)){
				st3_getSearchCount(Object.toQueryString(stURL));
			} else {
				st3_getSearchCount(window.location.href.split('?')[1].unescapeHTML());
			}
		}catch(e){
			st3_getSearchCount(window.location.href.split('?')[1].unescapeHTML());
		}
	}
	st3_initToolsDropDown('results');
	st3_registerResultsMiniModals();
	st3_resultsIconMouseOver();
	st3_state = 'hide';
	if(Object.isElement($('Results_Container'))) {
		st3_doSortables('Results_Container');

//DISABLED DRAGGING FOR IE7 ISSUES
		if(!Prototype.Browser.IE) {
			st3_ShoppingCart = st3_doDroppables();
		}

	}
	previousY = 0;

		if (Object.isElement($('st3_results_map_container'))) {	
			return initresultsmap();
		}
}

function st3_Load_Results_Map_Proxy() {
	return st3_Load_Results_Map($('st3_ResultsMap_LstnListingsID').value,$('st3_ResultsMap_dblLatitude').value,$('st3_ResultsMap_dblLongitude').value);
}

function st3_Load_Results_Map (nListingsID,lat,lon){
	st3_map = new GMap2($('st3_results_map'));
	var point = new GLatLng(lat,lon);
/* 	st3_map.setCenter(point,12); */
	var MapControl = new GLargeMapControl();
	var OverViewControl = new GOverviewMapControl();
		
		GEvent.addListener(st3_map, "mouseover", function(){
			st3_map.addControl(MapControl);
			st3_map.addControl(OverViewControl);
		});
		GEvent.addListener(st3_map, "mouseout", function(){
			st3_map.removeControl(MapControl);
			st3_map.removeControl(OverViewControl);
		});

	st3_getMapListings(true,nListingsID,true);
	return;
}
function initresultsmap(){
	st3_gloadScript('st3_Load_Results_Map_Proxy');
}

function st3_toggleAllResults(e){
	var e = $(e);
	$$('#st3 .ResultsTable').each(function(item,index){
		if (st3_state == 'hide'){
			var doBlindUp = new Effect.BlindUp(item,{duration: 0});
		    $('ListingHeaderAdditionalFields_' + (index + 1)).show();
			$('ListingHeaderPicTH_' + (index + 1)).show();
			$('ListingHeaderPicTH_' + (index + 1)).up().show();
			if(e.id=='st3_ResultsNavToggle'){
				e.update('<strong>Show All</strong>');
			}
		} else {
			var doBlindDown = new Effect.BlindDown(item,{duration: 0});
		    $('ListingHeaderAdditionalFields_' + (index + 1)).hide();
			$('ListingHeaderPicTH_' + (index + 1)).hide();
			$('ListingHeaderPicTH_' + (index + 1)).up().hide();
			if(e.id=='st3_ResultsNavToggle'){
				e.update('<strong>Hide All</strong>');
			}
		}
	});
	st3_state = (st3_state=='hide')?'show':'hide';
	$$('#st3 .st3_button').each(function(e,i){
		if(e.src.indexOf('hide-lrg') > 0){
			e.src = st3_DomainRoot + 'images/buttons/show-lrg-btn_o.jpg'
		}else if(e.src.indexOf('show-lrg') > 0){
			e.src = st3_DomainRoot + 'images/buttons/hide-lrg-btn_o.jpg'
		}else if(e.src.indexOf('hide-sm') > 0){
			e.src = st3_DomainRoot + 'images/buttons/show-sm-btn.jpg'
		}else if(e.src.indexOf('show-sm') > 0){
			e.src = st3_DomainRoot + 'images/buttons/hide-sm-btn.jpg'
		}else{}
	})
}
function st3_changeMLS(newmls){
	vcMLSName = newmls.split('_')[1];
	$$('.mls_select').each(function(e){e.value=newmls.split('_')[0]});
	currentForm = $$('.selectedTab')[0].id.split('_')[1];
	VCCITY = new Array();
	st3_loadMetaData();
	st3_loadMetaDataFile('VCCITYBYCOUNTY','','','',vcMLSName);
	st3_loadMetaDataFile('VCCOUNTY','vcCountyList','Select County',true,vcMLSName);
	st3_loadMetaDataFile('VCCITY','vcCityFrom','Select All',true,vcMLSName);

		new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
			method: 'post',
			parameters: {
				nmlsid: newmls.split('_')[0],
				method: 'Ajax_getMapSettingByMLSID',
				id: siteID,
				uuid: st3_getUUID()
			},
			onSuccess: function(transport){
				var JSONResult = transport.responseText.evalJSON(true);
				arrMapCoords = JSONResult.DATA.DATA[0][32].split(';');
				$('st3_vcLocation_Lon').value = arrMapCoords[1];
				$('st3_vcLocation_Lat').value = arrMapCoords[0];
	/* 			$('st3_vcLocation_Zoom').value = parseInt(arrMapCoords[4]); */
				$('st3_vcLocation_Zoom').value = 8;

				if(currentForm == 'Map'){
					st3_MapLoaded = false;
					st3_loadMap();
				}
			}
		});
	try{
		$('mlsdisclaimer_'+vcMLSName).show();
	}catch(err){
	}
	$$('.mlsfooter').each(function(e){
		if(e.id != 'mlsdisclaimer_'+vcMLSName){
			e.hide();
		}
	});
	st3_postForm('SearchForm_'+currentForm);
	return;
}

function st3_toggleResult(id){
	return new Effect.toggle(id,'blind');
}
/* **************************** //Results page functions... ************************************** */
/* **************************** Search page functions... ************************************** */
function st3_loadMetaDataFile(type,id,selectAll,showLoading,arrMLS){
/* 	if(bAdmin && (type=='VCCITY' || type=='VCCITYBYCOUNTY')){ */
/* 		plist=''; */
/* 		$A(arguments).each(function(e){ */
/* 			plist += e + ';'; */
/* 		}); */
/* 		alert(plist + st3_searchaction); */
/* 	} */
//vccity;vccountybycity;select all;tr;;rmls-;detailed
//vccitybycounty;;;;rmls;detailed

//vccity;vccityfrom;select all;true;sac;detailed
//vccitybycounty;;;;rmls;detailed

	var bCustomMetaData = true;
/* 	(id=='autocompleter')?bCustomMetaData = false:bCustomMetaData = true; */
	if((type=='VCCITY' || type=='VCZIPCODE') && typeof(type)!='undefined'){
		if(eval(type).length > 0){
			new Autocompleter.Local('SearchByParamValue', 'SearchByParamValue_Autocomplete', eval(type), {tokens:',',choices:20,partialSearch:true,fullSearch:true,partialChars:1});
			return;
		}
	}
	new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
		method: 'post',
		parameters: {
			method: 'Ajax_getMetaData',
			arrMLS: arrMLS,
			type: type,
			uuid: st3_getUUID(),
			id: siteID,
			custom: bCustomMetaData
		},
		onLoading: function(tranport){
			if (type != 'VCCITYBYCOUNTY' && type != 'VCCITY'){
				optLoading = $(id).options[0] = new Option('Select All','',true);
			}
		},
		onSuccess: function(transport){
			if (type != 'VCCITYBYCOUNTY' && type != 'VCCITY' && type != 'VCZIPCODE'){
				$(id).options[0].text='Select All';
				$(id).options[0].selected=true;
			}
			var data = transport.responseText.evalJSON().METADATA;
			if(type=='VCTYPE'){
				st3_vcTypeList = data
			}
			if (type == 'VCCITYBYCOUNTY'){
				VCCITYBYCOUNTY = data;
				if(st3_searchaction=='quicksearch'){
					st3_PopSel('vcCityFrom','');
				}
			} else if (type == 'VCCITY' && id == 'autocompleter'){
				VCCITY = data;
				new Autocompleter.Local('SearchByParamValue', 'SearchByParamValue_Autocomplete', VCCITY, {tokens:',',choices:20,partialSearch:true,fullSearch:true,partialChars:1});
			} else if (type == 'VCZIPCODE' && id == 'autocompleter'){
				VCZIPCODE = data;
				new Autocompleter.Local('SearchByParamValue', 'SearchByParamValue_Autocomplete', VCZIPCODE, {tokens:',',choices:20,partialSearch:true,fullSearch:true,partialChars:1});
/* 			} else if (type == 'VCSUBDIV' && id == 'autocompleter'){ */
/* 				VCSUBDIV = data; */
/* 				new Autocompleter.Local('SearchByParamValue', 'SearchByParamValue_Autocomplete', VCSUBDIV, {tokens:',',choices:20,partialSearch:true,fullSearch:true,partialChars:1}); */
			} else {
				$(id).options.length = 0;
				var doSelect = new st3_PopGenericSel(id,data,selectAll,st3_init_type);
				return true;
			}
		}
	});
}
function st3_loadMetaData(){
	var arrSearchTypes = new Array('quicksearch','mapsearch','citycountysearch','schoolsearch','waterfrontsearch','areasearch','subdivisionsearch');
	loadType = st3_loadMetaDataFile('VCTYPE','Type','Select All',false,vcMLSName);
	loadStyle = st3_loadMetaDataFile('VCSTYLE','Style','Select All',false,vcMLSName);
	if(st3_searchaction=='quicksearch'||st3_searchaction=='') {
		loadCity = st3_loadMetaDataFile('VCCITY','autocompleter','','',vcMLSName);
	}
	var arrSqFeet = new Array('600','800','1000','1200','1400','1600','1800','2000','2250','2500','2750','3000','3500','4000');
	$('sqft').options.length = 0;
	var laodSqFeet = st3_PopGenericSel('sqft',arrSqFeet,'Any',st3_init_sqft);
	var arrBeforeAfter = new Array('1950','1951','1952','1953','1954','1955','1956','1957','1958','1959','1960','1961','1962','1963','1964','1965','1966','1967','1968','1969','1970','1971','1972','1973','1974','1975','1976','1977','1978','1979','1980','1981','1982','1983','1984','1985','1986','1987','1988','1989','1990','1991','1992','1993','1994','1995','1996','1997','1998','1999','2000','2001','2002','2003','2004','2005','2006','2007','2008');
	$('before').options.length = 0;
	st3_PopGenericSel('before',arrBeforeAfter.reverse(false),'Any');
	$('after').options.length = 0;
	st3_PopGenericSel('after',arrBeforeAfter,'Any');
	var arrSince = new Array('30 Days','15 Days','1 Week','1 Day');
	if(Object.isElement($('since'))){
		$('since').options.length = 0;
		st3_PopGenericSel('since',arrSince,'Any');
	}
	$('beds').options.length = 0;
	st3_PopGenericSel('beds',['1','2','3','4','5','6','7','8'],'Any',st3_init_beds);
	$('bath').options.length = 0;
	st3_PopGenericSel('bath',['1','2','3','4','5','6','7','8'],'Any',st3_init_bath);
	if(Object.isElement($('garages'))){
		$('garages').options.length = 0;
	st3_PopGenericSel('garages',['1','2','3','4','5','6','7','8'],'Any',st3_init_garages);
	}
}
function st3_doLoadData(id,arr,showAll){
	var opt = $(id)
	if (arguments.length==3){
		arr.unshift(showAll)
	} else {
		var showAll = ''
	}
	for (var i = 0; i < arr.length; i++){
		if (arr[i] == showAll){
			opt.options[i] = new Option(arr[i],'',true);
		} else {
			opt.options[i] = new Option(arr[i],arr[i]);
		}
	}
}
function st3_SwapContent(content_id,container_id,init){
/* st3_CityCounty_Content */
	st3_CurrentForm = 'SearchForm_' + content_id.split('_')[1];
	st3_ToggleTab(content_id,init);
	var eContent = $('st3_' + content_id.split('_')[1] + '_Content');
	var eStandard = $('StandardSearchCriteria');
	$('AddSearchCriteria_' + content_id.split('_')[1]).appendChild(eStandard);
	var QuickSearchHeader = $('st3_SearchHeader');
	$('st3_searchHeader_help').childElements().invoke('hide');
/* 	if (content_id != 'tabButton_Map' && Object.isElement($('st3_MapSearchCount'))){ */
/* 		$('st3_MapSearchCount').remove(); */
/* 	} */
	if (content_id == 'tabButton_Map'){
		QuickSearchHeader.update('Map Search: ');
		$('MapSearch_help').show();
	} else if (content_id == 'st3_Quick_Content' || content_id == 'tabButton_Quick'){
		QuickSearchHeader.update('Quick Search: ');
		$('QuickSearch_help').show();
	} else if (content_id == 'tabButton_CityCounty'||content_id=='st3_CityCounty_Content'){
		QuickSearchHeader.update('City/County Search: ');
		if (!loadCounty){
			st3_loadMetaDataFile('VCCOUNTY','vcCountyList','Select County',true,vcMLSName);
			st3_loadMetaDataFile('VCCITY','vcCityFrom','Select All',true,vcMLSName);
			st3_loadMetaDataFile('VCCITYBYCOUNTY','','','',vcMLSName);
			loadCounty = true;
		}
		$('CityCountySearch_help').show();
	} else if (content_id == 'tabButton_School'||content_id=='st3_School_Content'){
		QuickSearchHeader.update('School Search: ');
		if (!loadSchool){
			st3_loadMetaDataFile('VCSCHOOLNAME','vcSchoolFrom','Select All',true,vcMLSName);
			loadSchool = true;
		}
		$('SchoolSearch_help').show();
	} else if (content_id == 'tabButton_WaterFront' || content_id == 'st3_WaterFront_Content'){
		QuickSearchHeader.update('Lake/Waterfront Search: ');
		if (!loadWaterName){
			st3_loadMetaDataFile('VCWATERNAME','vcWaterNameFrom','Select All',true,vcMLSName);
			loadWaterName = true;
		}
		$('WaterFrontSearch_help').show();
	} else if (content_id == 'st3_Subdiv_Content' || content_id == 'tabButton_Subdiv'){
		QuickSearchHeader.update('Subdivision Search: ');
		if (!loadSubdiv){
			st3_loadMetaDataFile('VCSUBDIV','vcSubdivFrom','Select All',true,vcMLSName);
			loadSubdiv = true;
		}
		$('SubDivSearch_help').show();
	} else if (content_id == 'st3_Area_Content' || content_id == 'tabButton_Area'){
		QuickSearchHeader.update('Area Search: ');
		if (!loadArea){
			st3_loadMetaDataFile('VCAREA','vcAreaFrom','Select All',true,vcMLSName);
			loadArea = true;
		}
		$('AreaSearch_help').show();
	} else {
		QuickSearchHeader.update('Search: ');
	}
	return eContent.show();
}
function st3_ToggleTab(content_id,init){
/* 	if(bAdmin){ */
/* 		alert('tab switch'); */
/* 	} */
	var strTab = content_id.split('_')[1];
	var eClickedTab = 'st3_' + strTab + '_Tab';
	$$('.tab').invoke('removeClassName','selectedTab')
	if (!init){
		$$('div.content').invoke('hide')
	}
	return $(eClickedTab).addClassName('selectedTab');
}
function st3_toggleQuickSearchParam(val,id){
	if (val == 'vclisting'){
		//Need to diable autocompleter
		Event.stopObserving('SearchByParamValue','blur');
		Event.stopObserving('SearchByParamValue','keypress');
		return $(id).value = 'Enter Listing Number';
	} else if (val == 'vcaddress1'){
		//Need to diable autocompleter
		Event.stopObserving('SearchByParamValue','blur');
		Event.stopObserving('SearchByParamValue','keypress');
		return $(id).value = 'Enter Address';
/* 	} else if (val == 'vcsubdiv'){ */
/* 		$(id).value = 'Enter Subdivision'; */
/* 		st3_loadMetaDataFile('VCSUBDIV','autocompleter','','',vcMLSName); */
/* 		return st3_setAutoComplete(val,val.toUpperCase()); */
	} else if (val == 'vccity'){
		$(id).value = 'Enter City';
		st3_loadMetaDataFile('VCCITY','autocompleter','','',vcMLSName);
		return;	
/* 		return st3_setAutoComplete(val,val.toUpperCase()); */
	} else if (val == 'vczipcode'){
		 $(id).value = 'Enter Zipcode';
		st3_loadMetaDataFile('VCZIPCODE','autocompleter','','',vcMLSName);
		return;
/* 		return st3_setAutoComplete(val,val.toUpperCase()); */
	}
}
function st3_toggleLabel(value,id){
	if (value == 'vcsubdiv'){
		return st3_setAutoComplete(value,value.toUpperCase());
	} else if (value == 'vccity'){
		return st3_setAutoComplete(value,value.toUpperCase());
	} else if (value == 'vczipcode'){
		return st3_setAutoComplete(value,value.toUpperCase());
	}
}
function st3_postForm(id,e){
	if (arguments.length == 2) {
		if (e.target.id == 'vcCountyList' || e.target.id == 'vcCityFrom') {
			return;
		}
	}
	if(st3_CurrentForm=='SearchForm_Map' && st3_MapLoaded){
		st3_getMapListings(false);
	}
	st3_getSearchCount($(id).serialize());
}
function st3_submitSearchForm(){
	if(arguments.length==0){
		var id = $(st3_CurrentForm);
	} else {
		var id = $(arguments[0]);
	}
	id.action = st3_SearchRoot + '?';
	return id.submit();
}
function st3_getSearchCount(query_string){
	if($('st3_Accordion_Container')==null){
		return false;
	}

	if (!$('st3_Accordion_Container').visible()){
		if (st3_CurrentForm!='SearchForm_Map'){
			return;
		}
	}
	if (query_string == st3_init_Query_String && query_string != ''){
		return;
	}
	st3_init_Query_String = query_string;
	new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
		showloading:false,
		requestHeaders: {
			Accept: 'application/json'
		},
		method: 'post',
		parameters: {
			method: 'Ajax_getSearchCount',
			query_string: query_string,
			uuid: st3_getUUID(),
			id: siteID
		},
		onLoading: function(){
			$('countLoading').show();
		},
		onComplete: function(){
			$('countLoading').hide();
		},
		onSuccess: function(transport){
			$('countLoading').hide();
			st3_getSearchCountComplete = true;
			var JSONResult = transport.responseText.evalJSON();
			$('Total_Results').update('');
			if (JSONResult.RECORDCOUNT.DATA.length > 0){
				var jsonQuery_String = query_string.toLowerCase().toQueryParams();
				var typeSelected = '';
				var totalResults = JSONResult.TOTALRECORDS>999?JSONResult.TOTALRECORDS.numberFormat("0,0"):JSONResult.TOTALRECORDS;
				$$('#st3 h3.st3_SearchCount_Header')[0].update('Search Count (' +  totalResults + ')');
				JSONResult.RECORDCOUNT.DATA.each(function(data){
					var quotedData1 = "'" + data[1] + "'";
					var quotedquery_string = "'" + query_string + "'";
					var ntListingCount = data[0]>999?data[0].numberFormat("0,0"):data[0];
					try{typeSelected = jsonQuery_String.type.indexOf(data[1].toLowerCase())>-1?' st3_TypeSelected':'';}catch(e){}
						if(quotedData1.toLowerCase().search(/supplemental=true/i)) {
							var newResult = new Element('a',{'style':'cursor:text;','class':'st3_ResultsCount'+typeSelected,'href':'javascript:void(0);','title':'There are '+ntListingCount+' results for:'+data[1]}).update(st3_toProperCase(data[1])+': <strong style="padding-left: 10px;">'+ntListingCount+'</strong>');
						} else {
							var newResult = new Element('a',{'class':'st3_ResultsCount'+typeSelected,'href':'javascript:st3_viewResults('+encodeURIComponent(quotedData1)+','+quotedquery_string+');','title':'Click to view '+ntListingCount+' results for:'+data[1]}).update(st3_toProperCase(data[1])+': <strong style="padding-left: 10px;">'+ntListingCount+'</strong>');				
						}
					return $('Total_Results').appendChild(newResult);
				});

				if(Object.isElement($('st3_MapSearchCount')) && Object.isElement($('st3_map_tool_Total_Results_Data'))){
					$('st3_map_tool_Total_Results_Data').update(totalResults);
/* 					$('st3_map_tool_Total_Displayed_Data').update(st3_getMapListingsRPP); */
				}


			} else {
				var newResult = new Element('a',{'class': 'st3_ResultsCount', 'href': 'javascript: void(0);', 'title': 'NO RESULTS FOUND'}).update('Sorry, no results found.');
				$$('#st3 h3.st3_SearchCount_Header')[0].update('Search Count (0)');
				if(Object.isElement($('st3_map_tool_Total_Results_Data'))) $('st3_map_tool_Total_Results_Data').update('0');
				return $('Total_Results').appendChild(newResult);
			}
		}
	});
}
function st3_viewResults(type,query_string){
	return document.location.href = st3_SearchRoot + '?currentPage=1&' + 'type=' + encodeURIComponent(type) + '&searchAction=Results' + '&' + query_string.replace(/&searchaction=[a-zA-Z_/ ]+/i,"").replace(/&type=[+%0-9a-zA-Z_/ ]+/i,"");
	if (arguments.length == 1){
		return document.location.href = st3_SearchRoot + '?' + Form.serialize(st3_CurrentForm) + '&type=' + type;
	} else {
        if (window.location.href.indexOf('?') > 0){
			if(type==''){
				return document.location.href = st3_DomainRoot + query_string;
			}else{
	    		return document.location.href = st3_SearchRoot + '?currentPage=1&' + 'type=' + type + '&searchAction=Results' + '&' + query_string.replace(/&searchaction=[a-zA-Z_/ ]+/i,"").replace(/&type=[a-zA-Z_/ ]+/i,"");
		    }
		} else {
    		return document.location.href = st3_SearchRoot + '?currentPage=1&' + 'type=' + type + '&searchAction=Results' + '&' + query_string.replace(/&searchaction=[a-zA-Z_/ ]+/i,"").replace(/&type=[a-zA-Z_/ ]+/i,"");
		}
	}
}
function st3_saveSearch(query_string){
	if(query_string){
		var vcSearchURL = query_string;
	}else{
		var vcSearchURL = $(st3_CurrentForm).serialize();
	}
	if(st3_loggedin == true){
		return st3_displaySaveSearchForm(vcSearchURL);
	}
	var bLoggedIn = new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
		method: 'post',
		parameters: {
			method: 'Ajax_Login',
			uuid: st3_getUUID(),
			id: siteID
		},
		onSuccess: function(transport){
			var JSONResult = transport.responseText.evalJSON();
			if (JSONResult.LOGIN){
				return st3_displaySaveSearchForm(vcSearchURL);
			}
			return st3_displayLoginForm('search',vcSearchURL);
		}
	});
}
function st3_doSavedSearch(){
	$('st3_Modal_Header_Message').update('<img src="' + st3_DomainRoot + 'images/progress_bar.gif" alt="loading" border="0" /> Loading...');
	var doAjax = new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
		showloading:false,
		requestHeaders: {
			Accept: 'application/json'
		},
		method: 'post',
		parameters: {
			method: 'Ajax_SaveSearch',
			vcSearchURL: $('vcSearchURL').value,
			nAccountsID: $('nAccountsID').value,
			vcName: $('vcName').value,
			vcComments: $('vcComments').value,
			bEmail: $('bEmail').checked,
			uuid: st3_getUUID(),
			id: siteID
		},
		onSuccess: function(transport){
			var JSONResult = transport.responseText.evalJSON();
			$('st3_Modal_Header_Message').update(JSONResult.MESSAGE);
			st3_swapUserToolContent('SavedSearches','st3_SavedSearches');
			return;
		}
	});
}
function st3_dspPreview(nListingsID,index){
	var strHREF = st3_AjaxRoot + '?SearchAction=details&nListingsID=' + nListingsID + '&Ajax=true&currentpage=' + index;
	var bri = new Element('a',{'href':strHREF});
	var eCloser = new Element('div').update(st3_showClose());
	var modal = new Control.Modal(bri,{
		overlayOpacity:.01,
		height: st3_getModalWindowHeight(100),
		width: st3_getModalWindowWidth(100),
		className:'modal_container'
	});
	modal.container.insert(eCloser);
	Event.observe(eCloser,'click',function(e){
		st3_clean_modals();
		modal.close();
		modal.destroy();
	});
	modal.open();
	return false;
}
function st3_displayModal(type,data,showclose){
	if(arguments.length==1){
		var data = '';
	}
	if(arguments.length!=3){
		var eCloser = new Element('div').update(st3_showClose(true));
	} else {
		var eCloser = new Element('div',{id:'st3_eCloser_Hidden'}).update(st3_showClose(true)).hide();
	}
	var strHREF = st3_AjaxRoot + '?nListingsID='+data+'&SearchAction=Details&Ajax=true';
	var bri = new Element('a',{'href':strHREF});
	var detail_Preview_Modal = new Control.Modal(bri,{
		overlayOpacity:.01,
		method: 'post',
		parameters: {
			type: type,
			data: data
		},
		className: 'modal_container_temp',
		height: st3_getModalWindowHeight(100),
		width: st3_getModalWindowWidth(100),
		closeOnClick:eCloser,
		afterClose: function(){
			this.destroy();
			this.container.remove();
		}
	});
	detail_Preview_Modal.container.insert(eCloser);
	return detail_Preview_Modal.open();
}
function st3_displayLoginForm(type,data,showclose){
	if(arguments.length==1){
		var data = '';
	}
	if(arguments.length!=3){
		var eCloser = new Element('div').update(st3_showClose(true));
	} else {
		var eCloser = new Element('div',{id:'st3_eCloser_Hidden'}).update(st3_showClose(true)).hide();
	}
	var strHREF = st3_AjaxRoot + '?SearchAction=SavedSearches_LoginForm&Ajax=true';
	var bri = new Element('a',{'href':strHREF});
	var Login_modal = new Control.Modal(bri,{
		overlayOpacity:.01,
		method: 'post',
		parameters: {
			type: type,
			data: data
		},
		className: 'modal_container_temp',
		height: st3_getModalWindowHeight(100),
		width: st3_getModalWindowWidth(100),
		closeOnClick:eCloser,
		afterClose: function(){
			this.destroy();
			this.container.remove();
		}
	});
	Login_modal.container.insert(eCloser);
	return Login_modal.open();
}
function st3_displaySaveSearchForm(vcSearchURL){
	var bri = new Element('a',{'href': st3_AjaxRoot + '?SearchAction=SaveSearchForm&Ajax=true&vcSearchURL=' + vcSearchURL.unescapeHTML().replace(/=/gi,'~').replace(/&/gi,'|')});
	var eCloser = new Element('div').update(st3_showClose(true));
	var modal = new Control.Modal(bri,{
		overlayOpacity:.01,
		width: st3_getModalWindowWidth(100),
		height: st3_getModalWindowHeight(100),
		className: 'modal_container',
		closeOnClick:eCloser,
		afterClose: function(){
			this.destroy();
			this.container.remove();
		}		
	});
	modal.container.insert(eCloser);
	return modal.open();
}
function st3_doLoginForm(type,data){
	var vcUserName = $('st3_vcUserName').value;
	var vcPassword = $('st3_vcPassword').value;
	var nAccountsID = $('st3_nAccountsID').value;
	$('st3_Modal_Header_Message').update('<img src="' + st3_DomainRoot + 'images/progress_bar.gif" alt="loading" border="0" /> Loading...');
	var doAjax = new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
		requestHeaders: {
			Accept: 'application/json'
		},
		method: 'post',
		parameters: {
			method: 'Ajax_Login',
			vcUserName: vcUserName,
			vcPassword: vcPassword,
			nAccountsID: nAccountsID,
			uuid: st3_getUUID(),
			id: siteID
		},
		onSuccess: function(transport){
			var JSONResult = transport.responseText.evalJSON();
			if (JSONResult.LOGGEDIN == true){
				if(Object.isElement($('st3_eCloser_Hidden'))){
					$('st3_eCloser_Hidden').show();
				}
				st3_loggedin = true;
				var content = '<a href="javascript:void(0);" onclick="st3_editUser(); return false;"><strong>' + vcUserName + '</strong> | <strong>My Account</strong> </a> | <a href="javascript:void(0);" onclick="st3_LogoutUser(); return false;"><strong>Logout</strong></a>';
				$('st3_Login_Status').update(content);
				st3_toggleUserToolMenu();
				$('st3_Modal_Header_Message').update('Welcome, <a href="javascript:void(0);" onclick="st3_editUser(); return false;"><strong>' + vcUserName + '</strong></a>');
				if(type=='login'){
					return st3_swapUserToolContent('EditUser');
				}
				if(type=='listing'){
					st3_savedListings(data,'save');
					st3_swapUserToolContent('SavedListings');
					return $('st3_Modal_Header_Message').insert('Listing# '+data+' saved successfully!');
				}
				if(type=='search'){
					return st3_swapUserToolContent('SaveSearchForm','st3_SavedSearches','searchaction=SaveSearchForm&vcSearchURL='+data.unescapeHTML().replace(/=/gi,'~').replace(/&/gi,'|'));
/* 					return st3_displaySaveSearchForm(data); */
				}
			} else {
				st3_loggedin = false;
				return $('st3_Modal_Header_Message').update(JSONResult.MESSAGE);
			}
		}
	});
}

function st3_submitEditUserForm(theForm){
	var eMessage = $('st3_Modal_Header_Message');
	var doAjax = new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
		method: 'post',
		parameters: {
			method: 'Ajax_UpdateUser',
			formdata: $('Form_1').serialize(),
			uuid: st3_getUUID(),
			id: siteID
		},
		onLoading: function() {
			$('st3_Modal_Header_Message').update('<img src="' + st3_DomainRoot + 'images/progress_bar.gif" alt="loading" border="0" /> Loading...');
		},
		onSuccess: function(transport){
			var JSONResult = transport.responseText.evalJSON();
			return eMessage.update(JSONResult.MESSAGE);
		}
	});
	return false;
}
function st3_doRegistrationForm(action,data){
	var userToolMode = false;
	if (Object.isElement($('st3_Logged_In_Nav'))){
		userToolMode = true;
	}
	if (userToolMode){
		$('st3_Modal_Header_Message').update('<img src="' + st3_DomainRoot + 'images/progress_bar.gif" alt="loading" border="0" /> Loading...');
	}
	var doAjax = new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
		requestHeaders: {
			Accept: 'application/json'
		},
		method: 'post',
		parameters: {
			method: 'Ajax_RegisterAccount',
			formdata: $('st3_Register_Form').serialize(),
			uuid: st3_getUUID(),
			id: siteID
		},
		onSuccess: function(transport){
			var JSONResult = transport.responseText.evalJSON();
			if (JSONResult.LOGGEDIN == true){
			st3_toggleUserToolMenu();
				if(Object.isElement($('st3_eCloser_Hidden'))){
					$('st3_eCloser_Hidden').show();
				}
				st3_loggedin = true;
/* 				var content = 'Welcome, <a href="javascript:void(0);" onclick="st3_editUser(); return false;"><strong>' + JSONResult.VCUSERNAME + '</strong></a> | <a href="javascript:void(0);" onclick="st3_LogoutUser(); return false;"><strong>Logout</strong></a>'; */
				var content = '<a href="javascript:void(0);" onclick="st3_editUser(); return false;"><strong>' + JSONResult.VCUSERNAME + '</strong> | <strong>My Account</strong> </a> | <a href="javascript:void(0);" onclick="st3_LogoutUser(); return false;"><strong>Logout</strong></a>';
				$('st3_Login_Status').update(content);
				if (action=='listing'){
					st3_savedListings(data,'save','SavedListingsFromLogin');
					return st3_swapUserToolContent('SavedListings');
				} else if(action=='search') {
					return st3_displaySaveSearchForm(data);
				} else if(action=='login') {
					$('st3_Modal_Header_Message').update(JSONResult.MESSAGE + '<br />This page will refresh in 3 seconds.');
					return setTimeout(function(){location.reload(true)},3000);
				}
			} else {
				$('st3_modal_closer').hide();
				$('st3_eCloser_Hidden').show();
				return $('st3_Modal_Header_Message').update(JSONResult.MESSAGE + '<br />Please try again!');
			}
			return $('st3_Modal_Header_Message').update(JSONResult.MESSAGE);
		}
	});
}
function st3_doLostPasswordForm(){
	var doAjax = new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
		requestHeaders: {
			Accept: 'application/json'
		},
		method: 'post',
		parameters: {
			method: 'Ajax_emailLostPassword',
			formdata: $('st3_Lost_Password_Form').serialize(),
			uuid: st3_getUUID(),
			id: siteID
		},
		onSuccess: function(transport){
			var JSONResult = transport.responseText.evalJSON();
			return $('st3_Modal_Header_Message').update(JSONResult.MESSAGE);
		}
	});
}
function st3_toggleModalSize(){
	$('st3_MaximizeModal','st3_MinimizeModal').invoke('toggle');
	if(st3_isModalMaximized){
		st3_isModalMaximized = false;
		$('modal_container').setStyle({'height':st3_getModalWindowHeight(100) + 'px','width':st3_getModalWindowWidth(100) + 'px'});
		return;
		return Control.Modl.center($('modal_container'));
	} else {
		st3_isModalMaximized = true;
		$('modal_container').setStyle({'height':'100%','width':'98%'});
		return;
		return Control.Modl.center($('modal_container'));
	}
}
function st3_LogoutUser(){
	var userToolMode = false;
	if (Object.isElement($('st3_Logged_In_Nav'))){
		userToolMode = true;
	}
	var logout = new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
		showloading:!userToolMode,
		method: 'post',
		parameters: {
			method: 'Ajax_Logout',
			uuid: st3_getUUID(),
			id: siteID
		},
		onLoading: function(){
			if (userToolMode) {
				st3_toggleUserToolMenu();
				$('st3_Modal_Header_Message').update('<img src="' + st3_DomainRoot + 'images/progress_bar.gif" alt="loading" border="0" /> Loading...');
			}
		},
		onSuccess: function(){
			$('st3_Login_Status').update('<a href="javascript:void(0);" onclick="st3_displayLoginForm(\'login\');" class="st3_Modal"><strong>Login</strong></a>');
			$$('#st3 img.st3_Save_Remove_Btn').invoke('setAttribute','src',st3_DomainRoot + 'images/buttons/Save-lrg-btn.jpg');
			st3_loggedin = false;
			if (userToolMode) {
				return $('st3_Modal_Header_Message').update('You have been logged out.');
			}
			return;
		}
	});
}
function st3_initSearch(){
	VCCITY = new Array();
	VCZIPCODE = new Array();
	st3_arrSelectedCounties = new Array();
	loadCounty=false;loadCities=false;loadSchool=false;loadWaterName=false;loadSubdiv=false;loadArea=false;loadSchool=false;
	strQuickSearchText = 'Enter Search Criteria...';
	if(Object.isElement($('SearchByParamValue'))){
		$('SearchByParamValue').value = strQuickSearchText;
	}
	$('min').value = st3_formatCurrency(st3_init_min,false);
	$('max').value = st3_formatCurrency(st3_init_max,false);
	$('min').observe('change', function(e1){
		$('min').value = st3_formatCurrency($('min').value,false);
	});
	var Prices = new Array('10000','$10,000','20000','$20,000','30000','$30,000','40000','$40,000','50000','$50,000','60000','$60,000','70000','$70,000','80000','$80,000','90000','$90,000','100000','$100,000','110000','$110,000','120000','$120,000','130000','$130,000','140000','$140,000','150000','$150,000','160000','$160,000','170000','$170,000','180000','$180,000','190000','$190,000','200000','$200,000','210000','$210,000','220000','$220,000','230000','$230,000','240000','$240,000','250000','$250,000','260000','$260,000','270000','$270,000','280000','$280,000','290000','$290,000','300000','$300,000','310000','$310,000','320000','$320,000','330000','$330,000','340000','$340,000','350000','$350,000','360000','$360,000','370000','$370,000','380000','$380,000','390000','$390,000','400000','$400,000','410000','$410,000','420000','$420,000','430000','$430,000','440000','$440,000','450000','$450,000','460000','$460,000','470000','$470,000','480000','$480,000','490000','$490,000','500000','$500,000','510000','$510,000','520000','$520,000','530000','$530,000','540000','$540,000','550000','$550,000','560000','$560,000','570000','$570,000','580000','$580,000','590000','$590,000','600000','$600,000','610000','$610,000','620000','$620,000','630000','$630,000','640000','$640,000','650000','$650,000','660000','$660,000','670000','$670,000','680000','$680,000','690000','$690,000','700000','$700,000','710000','$710,000','720000','$720,000','730000','$730,000','740000','$740,000','750000','$750,000','760000','$760,000','770000','$770,000','780000','$780,000','790000','$790,000','800000','$800,000','810000','$810,000','820000','$820,000','830000','$830,000','840000','$840,000','850000','$850,000','860000','$860,000','870000','$870,000','880000','$880,000','890000','$890,000','900000','$900,000','910000','$910,000','920000','$920,000','930000','$930,000','940000','$940,000','950000','$950,000','960000','$960,000','970000','$970,000','980000','$980,000','990000','$990,000','1000000','$1,000,000','1010000','$1,010,000','1020000','$1,020,000','1030000','$1,030,000','1040000','$1,040,000','1050000','$1,050,000','1060000','$1,060,000','1070000','$1,070,000','1080000','$1,080,000','1090000','$1,090,000','1100000','$1,100,000','1110000','$1,110,000','1120000','$1,120,000','1130000','$1,130,000','1140000','$1,140,000','1150000','$1,150,000','1160000','$1,160,000','1170000','$1,170,000','1180000','$1,180,000','1190000','$1,190,000','1200000','$1,200,000','1210000','$1,210,000','1220000','$1,220,000','1230000','$1,230,000','1240000','$1,240,000','1250000','$1,250,000','1260000','$1,260,000','1270000','$1,270,000','1280000','$1,280,000','1290000','$1,290,000','1300000','$1,300,000','1310000','$1,310,000','1320000','$1,320,000','1330000','$1,330,000','1340000','$1,340,000','1350000','$1,350,000','1360000','$1,360,000','1370000','$1,370,000','1380000','$1,380,000','1390000','$1,390,000','1400000','$1,400,000','1410000','$1,410,000','1420000','$1,420,000','1430000','$1,430,000','1440000','$1,440,000','1450000','$1,450,000','1460000','$1,460,000','1470000','$1,470,000','1480000','$1,480,000','1490000','$1,490,000','1500000','$1,500,000','1510000','$1,510,000','1520000','$1,520,000','1530000','$1,530,000','1540000','$1,540,000','1550000','$1,550,000','1560000','$1,560,000','1570000','$1,570,000','1580000','$1,580,000','1590000','$1,590,000','1600000','$1,600,000','1610000','$1,610,000','1620000','$1,620,000','1630000','$1,630,000','1640000','$1,640,000','1650000','$1,650,000','1660000','$1,660,000','1670000','$1,670,000','1680000','$1,680,000','1690000','$1,690,000','1700000','$1,700,000','1710000','$1,710,000','1720000','$1,720,000','1730000','$1,730,000','1740000','$1,740,000','1750000','$1,750,000','1760000','$1,760,000','1770000','$1,770,000','1780000','$1,780,000','1790000','$1,790,000','1800000','$1,800,000','1810000','$1,810,000','1820000','$1,820,000','1830000','$1,830,000','1840000','$1,840,000','1850000','$1,850,000','1860000','$1,860,000','1870000','$1,870,000','1880000','$1,880,000','1890000','$1,890,000','1900000','$1,900,000','1910000','$1,910,000','1920000','$1,920,000','1930000','$1,930,000','1940000','$1,940,000','1950000','$1,950,000','1960000','$1,960,000','1970000','$1,970,000','1980000','$1,980,000','1990000','$1,990,000','2000000','$2,000,000');
	new Autocompleter.Local('min', 'min_AutoComplete', Prices);
	new Autocompleter.Local('max', 'max_AutoComplete', Prices);
	$('max').observe('change', function(e2){
		if (st3_formatCurrency($('max').value,false) != '$0'){
			$('max').value = st3_formatCurrency($('max').value,false);
		} else {
			$('max').value = '';
		}
	});
	var contentID = 'st3_Quick_Content';
	if (st3_searchaction == 'mapsearch'){
		st3_CurrentForm = 'SearchForm_Map';
		st3_gloadScript('st3_loadMap');
		contentID = 'st3_Map_Content';
	} else if (st3_searchaction == 'detailed'){
		contentID = 'st3_CityCounty_Content';
	} else if (st3_searchaction == 'school'){
		contentID = 'st3_School_Content';
	} else if (st3_searchaction == 'lake'){
		contentID = 'st3_WaterFront_Content';
	} else if (st3_searchaction == 'subdiv'){
		contentID = 'st3_Subdiv_Content';
	} else if (st3_searchaction == 'area'){
		contentID = 'st3_Area_Content';
	}
	st3_loadMetaData();
	st3_SwapContent(contentID,'DisplayArea',true);
	$$('.tabButton').each(function(item1){
		Event.observe(item1, 'click', function(){
			st3_SwapContent.delay(0,item1.id,'DisplayArea',false);
		});
	});
	$$('#st3 .optionPlaceHolder').each(function(item2){
		if(item2.options.length == 1){
			if(item2.options[0].text==''){
				item2.options.length = 0;
			}
		}
	});
	if(st3_arrURL.action == 'refine'){
		st3_RefineSearch();
	}
	st3_postForm('SearchForm_' + contentID.split('_')[1]);
/* 	if(Prototype.Browser.IE){ */
/* 		$$('input','select').each(function(item5){ */
/* 			Event.observe(item5, 'change', function(e5){ */
/* 				st3_postForm(st3_CurrentForm,e5); */
/* 			});			 */
/* 			Event.observe(item5, 'blur', function(e5_2){ */
/* 				st3_postForm(st3_CurrentForm,e5_2); */
/* 			});			 */
/* 			Event.observe(item5, 'click', function(e5_3){ */
/* 				st3_postForm(st3_CurrentForm,e5_3); */
/* 			});			 */
/* 		}); */
/* 		 */
/* 	} else { */
		$$('#st3 .SearchForm').each(function(item3){
			Event.observe(item3, 'submit', function(e3){
				item3.action = st3_SearchRoot + '?';
				return true;
			});
			Event.observe(item3, 'change', function(e4){
				st3_postForm(item3.id,e4);
			});
		});
/* 	} */
	Event.observe('SearchForm_School', 'submit', function(e6){
		var arrSelectedSchools = new Array();
		for (var i = 0; i < $('vcSchoolTo').options.length; i++){
			arrSelectedSchools =  arrSelectedSchools.concat($('vcSchoolTo').options[i].value)
		}
		$('school').value = arrSelectedSchools;
		return true;
	});
	Event.observe('SearchForm_WaterFront', 'submit', function(e6){
		var arrSelectedWaterFront = new Array();
		for (var i = 0; i < $('vcWaterNameTo').options.length; i++){
			arrSelectedWaterFront =  arrSelectedWaterFront.concat($('vcWaterNameTo').options[i].value)
		}
		$('Lake').value = arrSelectedWaterFront;
		return true;
	});
	Event.observe('SearchForm_CityCounty', 'submit', function(e7){
		var arrSelectedCities = new Array();
		for (var j = 0; j < $('vcCityTo').options.length; j++){
			arrSelectedCities =  arrSelectedCities.concat($('vcCityTo').options[j].value)
		}
		$('city').value = arrSelectedCities;
		return true;
	});
	Event.observe('SearchByParamValue', 'focus', function(e8){
		if($('st3_QuickSearch_Select').value == 'vccity'){
			if(VCCITY.length==0){
				loadCity = st3_loadMetaDataFile('VCCITY','autocompleter','','',vcMLSName);
			}
		}
		if($('SearchByParamValue').value.search('Enter ') > -1){
			$('SearchByParamValue').value = '';
		}
	});
	st3_setAutoComplete('vccity','vccity'.toUpperCase());
	st3_toggleLabel('vccity','label');
}
function st3_loadToolTips(){
	//results
	show_hide_TT = 'Please Enter Minimum Price.</span><br /><span class="toolTip_Example">(Example: $350,000)</span><br /><span class="toolTip_Hint">$\'s and commas are not required.';
	//Search

	QuickSearch_help_TT = 'Select the which method you would like to search by and enter your criteria below</span><br /><span class="toolTip_Hint">Example: Select "Zipcode" and type in zipcodes seperated by commas.</span>';
	MapSearch_help_TT = 'Use Google Maps to pan and zoom to the area you are interested in. <br />The Map Tools will let you filter your results, view a list of properties displayed on the map and more!</span>';
	CityCountySearch_help_TT = 'Select a county from the drop down menu to filter the city list.<br /> You can search by multiple counties by selecting a county and use the "Search All" function that appears.<br /><span class="toolTip_Hint">Hold Control or Command and click to select multiple cities</span>';
	SchoolSearch_help_TT = 'Add area schools by selecting them from the box and clicking the ">" button to add them to your search.</span<br /><span class="toolTip_Hint">Hold Control or Command and click to select multiple schools</span>';
	WaterFrontSearch_help_TT = 'Add Lakes & Rivers by selecting them from the box and clicking the ">" button to add them to your search.</span<br /><span class="toolTip_Hint">Hold Control or Command and click to multiple select lakes/rivers.</span>';
	SubDivSearch_help_TT = 'Add Subdivisions by selecting them from the box and clicking the ">" button to add them to your search.</span<br /><span class="toolTip_Hint">Hold Control or Command and click to select multiple Subdivisions.</span>';
	AreaSearch_help_TT = 'Add Areas by selecting them from the box and clicking the ">" button to add them to your search.</span<br /><span class="toolTip_Hint">Hold Control or Command and click to select multiple Areas.</span>';




	detailpreview_help_TT = 'Preview details for this listing.';
	savelisting_help_TT = 'Save this listing.';
	showhide_help_TT = 'Show/Hide this table.';
	Type_help_TT = 'Select One or More Property Types.</span><br /><span class="toolTip_Hint">Hold Ctrl and click to select multiple Property Types.';
	Style_help_TT = 'Select One or More Property Styles.</span><br /><span class="toolTip_Hint">Hold Ctrl and click to select multiple Property Styles.';
	min_help_TT = 'Please Enter Minimum Price.</span><br /><span class="toolTip_Example">(Example: $350,000)</span><br />';
	max_help_TT = 'Please Enter Maximum Price.</span><br /><span class="toolTip_Example">(Example: $650,000)</span><br />';
	beds_help_TT = 'Please Select a Minimum Number of Bedrooms.';
	bath_help_TT = 'Please Select a Minimum Number of Bathrooms.';
	garages_help_TT = 'Please Select a Minimum Number of Garages.';
	sqft_help_TT = 'Please Select a Minimum Number of Square Feet.';
	before_help_TT = 'Please Select a "Built Before the Year" value.</span><br /><span class="toolTip_Example">(Example: Built before the year- 1999)';
	after_help_TT = 'Please Select a "Built After the Year" value.</span><br /><span class="toolTip_Example">(Example: Built after the year- 1980)';
	openhouses_help_TT = 'Show only listings with scheduled upcoming open houses.</span>';
	tour_help_TT = 'Show only listings with Virtual Tours.</span>';
	since_help_TT = 'Show listings that have been listed in a certain time frame.</span>';
	fireplace_help_TT = 'Show only listings one or more fireplaces.</span>';
	air_help_TT = 'Show only listings with central air.</span>';
	rooms_help_TT = 'Select number of rooms.<br /><span class="toolTip_Hint">Values selected represent minimums.</span></span>';
	additionalamenities_help_TT = 'Return listings that have these options</span>';
	results_help_TT = 'Choose how the results are ordered</span>';
	moreoptions_help_TT = 'More options to narrow your search.';
	pool_help_TT = 'Show only listings with a pool.';
	golf_help_TT = 'Show only properties near golf course.';
	waterfront_help_TT = 'Show only properties near bodies of water.';
	st3_QuickSearch_Select_help_TT = 'Select the primary criteria you want to search by.</span>'
	st3_save_quicksearch_help_TT = 'Save this search and recieve updates via email.</span>'
	st3_submit_quicksearch_help_TT = 'Find listings based on your search criteria.</span>'
	garage_help_TT = 'Show only listings one or more garages.';
	sort_help_TT = 'What order should the results be displayed in?';
	rpp_help_TT = 'How many listings should be displayed on each page?';
	order_help_TT = 'In what order should the listings be displayed?';
	st3_save_search_help_TT = 'Save this search and recieve updates via email.';
	st3_submit_search_help_TT = 'Find listings based on your search criteria.';
	vcCountyList_help_TT = 'Filter city list below by county.';
	vcCityFrom_help_TT = 'Select cities you wish to add to your search.</span><span class="toolTip_Hint">Shift-click or Ctrl-click to select multiple values.';
	vcCityTo_help_TT = 'Cities added to your search.</span><span class="toolTip_Hint">Shift-click or Ctrl-click to select multiple values.';
	st3_add_city_help_TT = 'Add your selected cities to the search box.';
	st3_remove_city_help_TT = 'Remove cities to the search box.';
	vcSchoolFrom_help_TT = 'Filter city list below by county.</span><span class="toolTip_Hint">Shift-click or Ctrl-click to select multiple values.';
	st3_ListingThubnail_Table_help_TT = 'Click Image to enlarge';
	SearchByParamValue_help_TT = 'Enter Your Search Criteria.';
	showhidemap_btn_TT = 'Click to display results shown on map.';
	UnderConstruction = '<span class="toolTip_Normal">This feature is currently being developed.';
}
function st3_registerToolTips(){
	if(Prototype.Browser.IE) {
		return;
	}
	$$('#st3 img.st3_ToolTipImg').each(function(item){
		try{
		new Control.ToolTip(item,'<span class="toolTop_Img"><img src="'+st3_ImageRoot+'buttons/tooltip-sm-btn.jpg" /></span><span class="toolTip_Normal">' + eval(item.id + '_TT') + '</span>',{
			className: 'modal_container'
		});
		} catch(e) {}
	});
/* 	$$('#st3 img.detailpreview_TT','#st3 img.showhide_TT','#st3 img.savelisting_TT').each(function(item){ */
/* 		new Control.Modl(item,{ */
/* 			hover: true, */
/* 			position: 'relative', */
/* 			offsetTop: 20, */
/* 			contents: function(){ */
/* 				st3_showClose(); */
/* 				if($(item).hasClassName('detailpreview_TT')){ */
/* 					return detailpreview_TT; */
/* 				}else if($(item).hasClassName('showhide_TT')){ */
/* 					return showhide_TT; */
/* 				}else if($(item).hasClassName('savelisting_TT')){ */
/* 					return savelisting_TT; */
/* 				}else{ */
/* 					return; */
/* 				} */
/* 			} */
/* 		}); */
/* 	}); */
}


function st3_ObjSearch(a){
	var o = {};
	for(var i=0;i<a.length;i++) {
		o[a[i]]='';
	}
	return o;
}


function st3_RefineSearch(){
	var forminputs = {
		"checkboxes":["properties","photo","sold","openhouses","tour","fireplace","waterfront","pool","garage","golf","air"],
		"textboxes":["minAcre","maxAcre","min","max","SearchByParamValue","openHouseEnd","openHouseStart"],
		"singleselects":["soldwithin","AcreageRange"]
		}
	forminputs.singleselects.each(function(v,c){
		var searchval = eval('st3_arrURL.' + v.toLowerCase())
		if(searchval != 'undefined'){
			if(Object.isElement($(v))){
				for(var i=0;i<$(v).options.length;i++) {
					if($(v)[i].value==searchval){
						$(v)[i].selected = true;
					}
				}
			}
		}
	});
	forminputs.checkboxes.each(function(v,c){
		var searchval = eval('st3_arrURL.' + v.toLowerCase())
		if(searchval == 'on' || searchval == '1' || searchval == 'true' || searchval == 'yes'){
			if(Object.isElement($(v))){
				$(v).checked = true;
				if(v.toLowerCase() == 'openhouses'){
					$('openhousedatecontainer').show();
				}
				if(v.toLowerCase() == 'sold'){
					$('solddatecontainer').show();
				}
			}
		}
	});
	forminputs.textboxes.each(function(v,c){
		var searchval = eval('st3_arrURL.' + v.toLowerCase())
		if(typeof searchval != 'undefined'){
			if(Object.isElement($(v))){
				$(v).value = searchval;
			}
		}
	});
}

/*
function st3_RefineSearch(){
	var checkboxes = ['openhouses','tour','fireplace','waterfront','pool','garage','golf','air'];	
	var textboxes = ['min','max'];	
	alert(Object.keys($H(st3_arrURL)));
	$($H(st3_arrURL)).each(function(v,c){
		searchVar = v[0]
		searchVal = v[1]
		if(searchVal!=''){
			if(searchVar=='searchbyparamvalue'){
				if(Object.isElement($('SearchByParamValue')))$('SearchByParamValue').value = st3_toProperCase(searchVal.replace(/\+/g,' ').unescapeHTML());
			}else if(searchVar in st3_ObjSearch(textboxes)){
				$(searchVar).value = searchVal;
			}else if(searchVar in st3_ObjSearch(checkboxes)){
				$(searchVar).checked = true;
			}
		}
	})
}
*/



function st3_setAutoComplete(value,arr){
//Event.stopObserving
/* alert(value); */
/* alert(eval(arr)); */
//For now we aren't loading any other data for the autocompleter anyway, so disable it because it
//causes the autocompleter to malfunction anyway
/* 	$('SearchByParamValue_Autocomplete').show(); */
/* 		if (value == ''){ */
/* 			new Autocompleter.Local('SearchByParamValue', 'SearchByParamValue_Autocomplete', eval(value.toUpperCase()), {tokens: ','}); */
/* 		} else { */
/* 			new Autocompleter.Local('SearchByParamValue', 'SearchByParamValue_Autocomplete', arr, {tokens: ','});		 */
/* 		} */
	return;
}
function st3_PopSel(id,arr){
	if (arr==''){
		$('st3_selectCountyLink').hide();
	} else {
		$('st3_selectCountyLink').show();
	}	
	$(id).options.length = 0;
	var i = 0;
	if (arr == ''){
		VCCITY.each(function(n,i){
			$(id)[i] = new Option(n,n)
		})
	} else {
		try {
			VCCITYBYCOUNTY[arr.toUpperCase().replace(/ /i, '_')].each(function(n){
				$(id)[i] = new Option(n,n)
				i++
			});
		} catch(e) {
			$(id)[0] = new Option('No Cities Available','')		
		}
	}
}
function st3_PopGenericSel(id,arr,all,selectedIndex){
	var selectedIndex = arguments.length==4?selectedIndex:'';
	if (st3_arrURL[id.toLowerCase()]){
		var aID = st3_arrURL[id.toLowerCase()]
	} else {
		var aID = ''
	}
	$(id).options.length = 0;
	var i = 0;
	if (all){
		$(id)[i] = new Option(all,'');
		if (aID.length <= 0){
			$(id)[i].selected = true;
		}
	i++
	}
	if (aID.length > 0){
		arr.each(function(n){
			$(id)[i] = new Option(n,n,aID.indexOf(n.toLowerCase()) > -1);
			i++;
		});
	} else {
		arr.each(function(n){
			$(id)[i] = new Option(n,n,false);
			i++;
		});
	}
	if(!st3_arrURL[id] && selectedIndex != ''){
		$(id)[selectedIndex].selected = true;
	}
}
function st3_addSelectedCounty(){
	var eSelectedCountyValue = $('st3_selected_county');
	var eSelectedCountyValueQuoted = "'" + eSelectedCountyValue.innerHTML + "'";
	if (st3_arrSelectedCounties.indexOf(eSelectedCountyValue.innerHTML) > -1){
		var eCloser = new Element('div').update(st3_showClose());
		var modal = new Control.Modal.open('Sorry, you have already added the county: ' + eSelectedCountyValue.innerHTML + '!!!',{
			overlayOpacity:.01,
			className:'modal_container',
			closeOnClick:eCloser
		});
		modal.container.insert(eCloser);
		return;
	}
	st3_arrSelectedCounties.push(eSelectedCountyValue.innerHTML);
	var e = new Element('div').update(eSelectedCountyValue.innerHTML + '&nbsp;&nbsp;(<a href="javascript:void(0);" onclick="st3_RemoveSelectedCounty(this,' + eSelectedCountyValueQuoted + '); return false;">Remove</a>)');
	$('st3_SelectedCountyList').appendChild(e);
	$('st3_County').value = st3_arrSelectedCounties;
	st3_postForm(st3_CurrentForm);
}
function st3_RemoveSelectedCounty(elem,value){
	st3_arrSelectedCounties = st3_arrSelectedCounties.without(value);
	$('st3_County').value = st3_arrSelectedCounties;
	$(elem).ancestors()[0].remove();
}
function st3_MoveOptions(from,to){
	var of = $(from).options
	var ot = $(to).options
	var act = new Array()
	for (var k=0; k<ot.length; k++){
		act.push(ot[k].value)
	}
	for (var i=of.length-1; i>-1; i--){
		if (of[i].selected == true){
			act.push(of[i].value)
			of[i] = null
		}
	}
	for (var l = 0; l < act.length; l++){
		ot[l] = new Option(act[l],act[l]);
	}
	var arrSelectedVals = new Array();
	switch(from){
		case "vcCityFrom":
			for (var i = 0; i < $('vcCityTo').options.length; i++){
				arrSelectedVals =  arrSelectedVals.concat($(to).options[i].value)
			}
			$('city').value = arrSelectedVals;
			st3_postForm('SearchForm_CityCounty');
		break;
		case "vcWaterNameFrom":
			for (var i = 0; i < $('vcWaterNameTo').options.length; i++){
				arrSelectedVals =  arrSelectedVals.concat($(to).options[i].value)
			}
			$('Lake').value = arrSelectedVals;
			st3_postForm('SearchForm_WaterFront');
		break;
		case "vcSubdivFrom":
			for (var i = 0; i < $('vcSubdivTo').options.length; i++){
				arrSelectedVals =  arrSelectedVals.concat($(to).options[i].value)
			}
			$('Subdiv').value = arrSelectedVals;
			st3_postForm('SearchForm_Subdiv');
		break;
		case "vcAreaFrom":
			for (var i = 0; i < $('vcAreaTo').options.length; i++){
				arrSelectedVals =  arrSelectedVals.concat($(to).options[i].value)
			}
			$('Area').value = arrSelectedVals;
			st3_postForm('SearchForm_Area');
		break;
		case "vcCityTo":
			for (var i = 0; i < $('vcCityTo').options.length; i++){
				arrSelectedVals =  arrSelectedVals.concat($('vcCityTo').options[i].value)
			}
			$('city').value = arrSelectedVals;
			st3_postForm('SearchForm_CityCounty');
		break;
		case "vcWaterNameTo":
			for (var i = 0; i < $('vcWaterNameTo').options.length; i++){
				arrSelectedVals =  arrSelectedVals.concat($('vcWaterNameTo').options[i].value)
			}
			$('Lake').value = arrSelectedVals;
			st3_postForm('SearchForm_WaterFront');
		break;
		case "vcSubdivTo":
			for (var i = 0; i < $('vcSubdivTo').options.length; i++){
				arrSelectedVals =  arrSelectedVals.concat($('vcSubdivTo').options[i].value)
			}
			$('Subdiv').value = arrSelectedVals;
			st3_postForm('SearchForm_Subdiv');
		break;
		case "vcAreaTo":
			for (var i = 0; i < $('vcAreaTo').options.length; i++){
				arrSelectedVals =  arrSelectedVals.concat($('vcAreaTo').options[i].value)
			}
			$('Area').value = arrSelectedVals;
			st3_postForm('SearchForm_Area');
		break;
		default:
		break;
	}
}
function st3_SelVal(id){
	for (var i=0; i<$(id).options.length; i++){
		$(id).options[i].selected = true;
	}
}
function st3_valPrice(id,vid){
	if ($F(id) != ''){
		$(vid).value = $(id).value*1000;
	}
}
function st3_SubmitForm(theForm){
	return $(theForm).submit();
}
/* **************************** //Search page functions... ************************************** */
/* **************************** Details page functions... ************************************** */
function st3_gotoDetailsFromMap(nListingsID,Count){
	try {
		var vcSearchURL = $(st3_CurrentForm).serialize();
		var updateSession = st3_UpdateSessionVar('RecentSearch',vcSearchURL,Count,nListingsID);
	} catch(e) {return document.location.href = st3_SearchRoot + '?nListingsID='+nListingsID+'&SearchAction=Details&FromMap=true';}
}
function st3_initDetails(){
	if(Object.isElement($('strLastSearch'))){
		st3_getSearchCount($('strLastSearch').value);
	}
	st3_vcThisMLSName = $('vcMLSName').value;
	st3_CurrentForm = $('st3_SearchForm');
	st3_initPhotoSlideShow($$('#st3 img.st3_DetailsPhotoTH').length);
	st3_initToolsDropDown('results');
	st3_buttonRollOvers();
/* 	st3_showMiniMap('st3_detail_thMap_container'); */
}
function st3_initPhotoSlideShow(nCount){
	if(nCount<=4){return;}
	try{
	Event.observe('left','click',function(event){
		var currentpos = $('st3_Thumbnail_Gallery').positionedOffset()[0];
		if(currentpos<=-(50*nCount)){
			return;
		}
		new Effect.Move('st3_Thumbnail_Gallery',{
			x: -71,
			y: 0,
			mode: 'relative',
			transition: Effect.Transitions.sinoidal
		});
	});

	Event.observe('right','click',function(event){
		var currentpos = $('st3_Thumbnail_Gallery').positionedOffset()[0];
		if(currentpos<=0){
			return;		
		}
		new Effect.Move('st3_Thumbnail_Gallery',{
			x: 71,
			y: 0,
			mode: 'relative',
			transition: Effect.Transitions.sinoidal
		});
	});
	}catch(err){}
}
function st3_showMiniMap(id){
	if (GBrowserIsCompatible()) {
		var map = new GMap2($(id));
		var nListingsID = $('st3_details_nListingsID').value;
		var point = new GLatLng($('st3_' + nListingsID + '_lat').value, $('st3_' + nListingsID + '_lon').value);
		map.setCenter(point, 13);
		var marker = new GMarker(point);
		map.addOverlay(marker);
	 }
}
function st3_initDetailPhotoSS(){
return;
	if(typeof(ieversion)!='undefined'){
		return
	}
/* IE THROW ERRORS IN THIS FUNCTION  */
	_1DS('slideshow').style.display='none';
	_1DS('wrapper').style.display='block';
	slideshow = new TINY.slideshow("slideshow");
	slideshow.auto = true;
	slideshow.speed = 5;
	slideshow.link="linkhover";
	slideshow.info="information";
	slideshow.thumbs="slider";
	slideshow.left="slideleft";
	slideshow.right="slideright";
	slideshow.scrollSpeed=4;
	slideshow.spacing=5;
	slideshow.active="##fff";
	slideshow.init("slideshow","image","imgprev","imgnext","imglink");
/* 	st3_arrPhotos = $$('img.st3_thumbnail_img'); */
/* 	st3_currentPhoto = 0; */
/* 	st3_photoCount = st3_arrPhotos.length; */
/* 	st3_autoIncPhoto = true; */
/* 	$$('td.st3_thumbnail').each(function(c,i){ */
/* 		Event.observe(c,'mouseover',function(){ */
/* 			c.setStyle({'background':'#ccc'}) */
/* 		}); */
/* 		Event.observe(c,'mouseout',function(){ */
/* 			c.setStyle({'background':'#fff'}) */
/* 		}); */
/* 	}); */
/* 	$$('img.st3_thumbnail_img').each(function(item,index){ */
/* 		Event.observe(item,'click',function(){ */
/* 			st3_swapDetailImage(item.src,'st3_detail_photo'); */
/* 			st3_currentPhoto = index; */
/* 		}); */
/* 	}); */
}



/* function st3_incrementPhoto(dir){ */
/* 	(dir=='next') ? st3_currentPhoto++ : st3_currentPhoto-- ; */
/* 	if (st3_currentPhoto > st3_photoCount - 1){ */
/* 		st3_currentPhoto = 0; */
/* 	}else if(st3_currentPhoto < 0){ */
/* 		st3_currentPhoto = st3_photoCount - 1; */
/* 	} */
/* 	st3_swapDetailImage(st3_arrPhotos[st3_currentPhoto].src,'st3_detail_photo'); */
/* } */
/* function st3_autoIncrementPhoto(ele){ */
/* 	if(st3_autoIncPhoto){ */
/* 		st3_autoIncPhoto = false; */
/* 		$(ele).update('Stop') */
/* 		st3_incrementPhoto('next') */
/* 		st3_photoTimer = setInterval('st3_incrementPhoto(\'next\')','3000') */
/* 	}else{ */
/* 		st3_autoIncPhoto = true; */
/* 		$(ele).update('Start') */
/* 		clearInterval(st3_photoTimer) */
/* 		return */
/* 	} */
/* } */



function st3_swapDetailImage(path,target){
	Effect.Fade(target, {
		duration : 0.25,
		from: 1.0,
		to: 0.01,
		afterFinish: function(){
			$(target).src = path;

			Event.observe(target, 'load', function(e){
				Effect.Fade(target, {
					duration : 0.25,
					from: 0.01,
					to: 1.0
				});
			})

		}
	});
}
function st3_initToolsDropDown(type){
	if(type=='results'){
		var elems = '#st3 a.st3_more_tools_container';
		var jsonSearchActions = {'EmailToAFriend':'Email to a friend','Mapit':'Map Listing','Comp':'Select to Compare','MortgageCalc':'Mortgage Calculator','RequestShowing':'Request A Showing','ShareLink':'Share a Link'};
	} else {
		var elems = '#st3 div.st3_comp_tools';
		var jsonSearchActions = {'EmailToAFriend':'Email to a friend1','Mapit':'Map Listing','Comp':'Select to Compare','MortgageCalc':'Mortgage Calculator','PrinterFriendly':'Printer Friendly Version','RequestShowing':'Request A Showing','ShareLink':'Share a Link'};
	}
	$$(elems).each(function(item){
		var nListingsID = item.id.split('_')[3];
		var strOut = '';
		var theContentID = 'more_tools_content_'+nListingsID;
		var eT = new Element('div',{'id':theContentID,'class':'more_tools_content','style':'width:200px;height:auto;'}).hide();
		Object.keys(jsonSearchActions).each(function(item2,index){
			strOut += '<a href="javascript:void(0);" class="st3_more_tools_links" onclick="st3_dspModal(';
			strOut += "'" + item2 + "',";
			strOut += "'" + nListingsID + "'";
			if(item2=='EmailToAFriend'||item2=='MortgageCalc'||item2=='RequestShowing'){
				strOut += ",{'height':'425','width':'500'}";
			}
			strOut += ');">&raquo;&nbsp;' + jsonSearchActions[item2] + '</a>';
		});
		eT.update(strOut);
		eT.insert(eCloser);
		$('st3').appendChild(eT);
		var eCloser = new Element('div').update(st3_showClose());
/* 		var modal = new Control.Modal(item, { */
/* 			overlayOpacity:.01, */
/* 			className:'modal_container', */
/* 			closeOnClick:true, */
/* 			overlayOpacity:.01, */
/* 			hover:false, */
/* 			position:'relative', */
/* 			offsetTop:15, */
/* 			offsetLeft:-180, */
/* 			beforeOpen:function(e){ */
/* 				$$('#st3 div.modal_container').invoke('hide'); */
/* 			} */
/* 		}); */
	});
}

function st3_createMainMenu(){
	return;
	var eTools = $('st3_MainMenu_Container');
	var jsonSearchActions = {'Hide Tools':'icon/hide_icon.png','Move Tools':'icon/move_icon.png','Pin Tools':'icon/pin_icon.png','Tool Help':'icon/help_icon.png'};
	var strOut = '';
	Object.keys(jsonSearchActions).each(function(item,index){
		var eleId = item.strip().replace(/ /g,'');
	});
	var eToolsMenu = new Element('div',{'id':'st3_MainMenu_content','class':'more_MainMenu','style':'height:120px;position:absolute;top:20px;border:1px solid #ccc;background-color:#fff;width:200px;display:none;'});
	eToolsMenu.innerHTML = strOut;
	$('st3_MainMenu_Container').appendChild(eToolsMenu);
}

/* function st3_createAccordTools() { */
/* 	if(!Object.isElement($('st3_Accordion_Container'))){ */
/* 		return; */
/* 	} */
/* 	var eTools = $('st3_Accordion_Container'); */
/* 	var jsonSearchActions = {'Hide Tools':'icon/hide_icon.png','Move Tools':'icon/move_icon.png','Pin Tools':'icon/pin_icon.png','Tool Help':'icon/help_icon.png'}; */
/* 	var strOut = ''; */
/* 		strOut += '<div id="st3_close_modal"><a href="javascript: void(0);" onclick="$('; */
/* 		strOut += "'st3_more_tools_content'"; */
/* 		strOut += ').hide();" title="Close Window" style="vertical-align:top;font-size:13px;font-family:verdana;text-decoration:none;font-style:italic;"><img src="'+ st3_DomainRoot; */
/* 		strOut += 'images/buttons/close-sm-btn.jpg" alt="close" border="0" /> Close Menu</a></div><hr style="border:0px none;border-top:1px solid #CCC !important;" />'; */
/* 	Object.keys(jsonSearchActions).each(function(item,index){ */
/* 		var eleId = item.strip().replace(/ /g,''); */
/* 		strOut += '<a href="javascript:void(0);" class="st3_more_tools_links" id="st3_accTools_'+ eleId +'"onclick="st3_doToolAction('; */
/* 		strOut += "'" + item + "',"; */
/* 		strOut += "'" + '' + "'"; */
/* 		strOut += ');">' + item + '</a>'; */
/* 	}); */
/* 	var eToolsMenu = new Element('div',{'id':'st3_more_tools_content','class':'more_tools_content','style':'height:150px;position:absolute;top:20px;left:-180px;border:1px solid #ccc;background-color:#fff;width:200px;display:none;'}); */
/* 	eToolsMenu.innerHTML = strOut; */
/* 	$('st3_Accordion_Container').appendChild(eToolsMenu); */
/* } */
function st3_onResize(){
	if(Object.isElement('st3_more_tools_content') && Object.isElement('st3_Accordion_Container')){
		$('st3_more_tools_content').hide();
		$('st3_more_tools_content').clonePosition('st3_Accordion_Container',{offsetLeft:-180,offsetTop:20}).setStyle({'height':'161px'});
	}
	if(Object.isElement($$('.modal_container')[0])){
/* 		if($$('.modal_container')[0].visible()){ */
/* 			$$('.modal_container')[0].setStyle({'height':st3_getModalWindowHeight(100) + 'px','width':st3_getModalWindowWidth(100) + 'px'}); */
/* 		} */
	}

return;
}
function st3_doToolAction(theTool){
try {
	var eTools = $('st3_Accordion_Container');
	switch(theTool) {
		case 'Hide Tools':
			return st3_toggleAccordion();
		break;
		case 'Move Tools':
			if(typeof(DragTools)!='undefined'){
				/* Pin Tools */
				eTools.clonePosition('st3_Accordion_Container_Outter');
				eTools.setStyle({'position':'static'});
				/* unPin Tools */
				eTools.setStyle({'position':'fixed'});
				eTools.clonePosition('st3_Accordion_Container_Outter',{offsetTop:eTools.cumulativeScrollOffset().top});
				DragTools = null
				$('st3_accTools_MoveTools').update('Move Tools')
				return;
			}else{
				eTools.setStyle({'cursor':'move'});
				DragTools = new Draggable(eTools,{handle:'st3_Accord_Header'});
				$('st3_accTools_MoveTools').update('Stop Moving Tools')
				return;
			}
		break;
		case 'Pin Tools':
			if (eTools.getStyle('position')=='fixed'){
				$('st3_accTools_PinTools').update('Un-pin Tools')
				eTools.clonePosition('st3_Accordion_Container_Outter');
				eTools.setStyle({'position':'static'});
				st3_deleteCookie('PinTools');
				st3_createCookie('PinTools',true,3650);
			} else {
				$('st3_accTools_PinTools').update('Pin Tools')
				eTools.setStyle({'position':'fixed'});
				eTools.clonePosition('st3_Accordion_Container_Outter',{offsetTop:eTools.cumulativeScrollOffset().top});
				st3_deleteCookie('PinTools');
				st3_createCookie('PinTools',false,3650);
			}
		break;
		case 'Tool Help':
			return st3_dspModal('ToolHelp');
		break;
		default:
	}
} catch(e) {}
}
function st3_ToggleToolActions(theTool){
	

}
function st3_doDemoRegistration(id){
	if(arguments.length==0){
		var a = new Element('a',{'href': st3_AjaxRoot + '?SearchAction=DemoRegistration&Ajax=true'});
		mReg = new Control.Modal.open(a,{className:'modal_container',closeOnClick:false});	
	} else {
		if($('IAgree').checked==false){
			return;
		}
		var doAjax = new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
			method: 'post',
			parameters: {
				method: 'Ajax_doDemoReg',
				strForm: $(id).serialize(),
				id: siteID,
				uuid: st3_getUUID()
			},
			onSuccess: function(transport){
				var JSONResult = transport.responseText.evalJSON();
				if(JSONResult.BSUCCESS){
					bRegistered = true;
					mReg.close();
					st3_deleteCookie('bRegistered');
					st3_createCookie('bRegistered',true,3650);
					var a = new Element('a',{href:'javascript:window.location.reload();'}).update('<br />Continue...');
					var mReg2 = new Control.Modal('Thanks for registering!<br />',{className:'modal_container',closeOnClick:a});
					mReg2.container.insert(a);
					return mReg2.open();
				} else if(JSONResult.BBADEMAIL){
					return $('EmailaddressHeader').update('<span style="color:#FF0000;">Email Address (Invalid):</span>');
				}
			}
		});
	}
}
function st3_dspModal(searchAction,nListingsID,options){
	if (searchAction == 'Mapit') {
		if(!st3_gScriptLoaded) {
			var delay = 1;
			st3_gloadScript('');
		} else {
			var delay = 0;
		}
		try {
			st3_ExpandMap.delay(delay,nListingsID,$('st3_' + nListingsID + '_lat').value,$('st3_' + nListingsID + '_lon').value);
		} catch(e) {
			/* st3_globalErrorHandler(e); */
			st3_ExpandMap.delay(1,nListingsID,$('st3_' + nListingsID + '_lat').value,$('st3_' + nListingsID + '_lon').value);
		}
		return;
	}
	if(arguments.length==1){
		nListingsID='';
	}
	if(arguments.length==3){
		(options.width)?modalWidth=options.width:modalWidth=st3_getModalWindowWidth(100);
		(options.height)?modalHeight=options.height:modalHeight=st3_getModalWindowheight(100);
	}else{
		modalWidth=st3_getModalWindowWidth(100);
		modalHeight=st3_getModalWindowHeight(100);
	}
	if (searchAction=='st3_inquire' || searchAction=='contact'){
		var searchAction = 'contact';
		modalWidth=450;
		modalHeight=550;
	}
	if (searchAction=='Comp'){
		$('st3_pop_menus_results_' + nListingsID).hide();
		return st3_addComp(nListingsID,false);
	}
	
	if (searchAction=='EmailToAFriend' || searchAction=='Mapit' || 
		searchAction=='MortgageCalc' || 
		searchAction=='RequestShowing' || searchAction=='ShareLink'){
			modalWidth=450;
			modalHeight=550;	
	}
	
	var page = new Element('a',{'href': st3_AjaxRoot + '?SearchAction=' + searchAction + '&Ajax=true&nListingsID=' + nListingsID});
	var eCloser = new Element('div').update(st3_showClose(true));
	var modal = new Control.Modal.open(page,{
		overlayOpacity:.01,
		width: modalWidth,
		height: modalHeight,
		closeOnClick:eCloser,
		className: 'modal_container',
		afterClose: function(){
			try {
			this.destroy();
			this.container.remove();
			}catch(e){}
		}
	});
	modal.container.insert(eCloser);
	return modal;
}
function st3_clean_modals(){
	return $$('#st3 div.modal_container_temp').invoke('remove');
}
function st3_addComp(nListingsID,init){
	if(!init){
		if(st3ArrCompListings.indexOf(nListingsID)>-1){
			st3_doSubtleMessage('You are already comparing this listing.','more_tools_img_' + nListingsID);
			return false;
		}
		if(st3ArrCompListings.length==5){
			st3_doSubtleMessage('Sorry, you may only compare up to 5 listings at a time.','more_tools_img_' + nListingsID);
			return false;
		}
		st3ArrCompListings.push(nListingsID);
		st3_UpdateCompSession(st3ArrCompListings);
		$$('.st3_compare_tab')[0].update('Compare (' + st3ArrCompListings.length + ')');
		if(st3ArrCompListings.length>1){
			$('st3_Comp_Listings_Display_Header').update('<a onclick="st3_getCompRecords(st3ArrCompListings); return false;" href="javascript:void(0);" style="font-size: 10px;">Click here to compare <strong>'+st3ArrCompListings.length+'</strong> listings</a>');
		} else {
			$('st3_Comp_Listings_Display_Header').update('Select 2 or more listings to compare.');
		}
	}
	var arrData = new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
		method: 'post',
		parameters: {
			nListingsID: nListingsID,
			arrListings: st3ArrCompListings,
			rpp: 1,
			method: 'Ajax_getCompRecords',
			id: siteID,
			uuid: st3_getUUID()
		},
		onSuccess: function(transport){
			var JSONResult = transport.responseText.evalJSON();
			JSONResult.QUERY.DATA.each(function(item,index){
				var eComp = $('st3_Comp_Listings_Display');
				var a = new Element('div',{'id':'st3_comp_thumb_' + nListingsID,'style':'overflow:hidden;height:55px;width:98%;padding:2px;border-bottom:1px solid #CCC;display:table;text-align:left;'});
				var b = new Element('img',{'src':st3_ImageRoot+'buttons/close-sm-btn.jpg','style':'float:left;','onclick':'st3_RemoveCompTH('+nListingsID+');return false;'});
				var c = new Element('div',{'style':'float:left;padding:0px 2px 0px 2px;height:55px;width:100px;overflow:hidden;'});
				var d = new Element('div').update(item[0]);
				var e = new Element('div').update(item[2] + ', ' + item[4] + ' ' + item[3]);
				var f = new Element('div').update(st3_formatCurrency(item[1],false));
				var g = new Element('img',{'src':item[5],'style':'height:40px;float:right;'});
				var h = new Element('div',{'class':'st3_clear_2'});
				var theBrLogo = vcMLSName.indexOf('REIN') > -1?'/st3/MLSDisclaimers/REIN-THbrlogo.gif':'';
				if(theBrLogo.length && !item[6]) {
					var i = new Element('img',{'src':theBrLogo,'style':'clear:both;float:right;'});
				} else {
					var i = new Element('div',{'style':'clear;both;float:right;font-weight:bolder;'}).update(item[7]);
				}
				a.insert(b).insert(c).insert(g);
				if(theBrLogo.length){a.insert(i);}
				c.insert(d).insert(e).insert(f);
				eComp.insert(a).insert(h);
			});
		}
	});
}
function st3_RemoveCompTH(nListingsID){
	confirm("Are you sure you want to remove this listing."); 
	$("st3_comp_thumb_" + nListingsID).remove();
	st3ArrCompListings=st3ArrCompListings.without(nListingsID);
	st3_UpdateCompSession(st3ArrCompListings);
	if(st3ArrCompListings.length>1){
		$('st3_Comp_Listings_Display_Header').update('<a onclick="st3_getCompRecords(st3ArrCompListings); return false;" href="javascript:void(0);" style="font-size: 10px;">Click here to compare <strong>'+st3ArrCompListings.length+'</strong> listings</a>');
	} else {
		$('st3_Comp_Listings_Display_Header').update('Select 2 or more listings to compare.');
	}
	$$('.st3_compare_tab')[0].update('Compare (' + st3ArrCompListings.length + ')');
}
function st3_RemoveSavedTH(nListingsID){
	if(arguments.length==1){
		confirm("Are you sure you want to remove this listing."); 
		$("st3_saved_thumb_" + nListingsID).remove();
	} else {
		$("st3_saved_thumb_" + nListingsID).remove();
		arrDropListings = arrDropListings.without(nListingsID);
	}
}
function st3_UpdateCompSession(arrListings){
	if(arrListings==''){
		arrListings = 0;
	}
	var doAjax = new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
		showloading:false,
		method:'post',
		parameters: {
			method: 'Ajax_updateCompSession',
			arrListings: arrListings,
			id: siteID,
			uuid: st3_getUUID()
		}
	});
}
function st3_UpdateSessionVar(type,data,count,nListingsID){
	var doAjax = new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
		showloading:false,
		method:'post',
		parameters: {
			method: 'Ajax_updateSessionVar',
			type: type,
			data: data,
			count: count,
			id: siteID,
			uuid: st3_getUUID()
		},
		onSuccess: function(transport){
			return document.location.href = st3_SearchRoot + '?nListingsID='+nListingsID+'&SearchAction=Details&FromMap=true';
		}
	});
}
function st3_editUser(){
	return st3_dspModal('editUser');
}
function st3_editSearchComments(nSearchesID){
	var a = $('st3_editComments_container_' + nSearchesID);
	origContent = a.innerHTML;
	var CommentDiv = $('st3_SavedSearchTA_'+nSearchesID);
	if (!Object.isElement(CommentDiv)) {
		var eTextArea = new Element('textarea',{'id':'st3_SavedSearchTA_'+nSearchesID,'onblur':'st3_UpdateComment('+nSearchesID+');return false;'});
		a.update('');
		a.appendChild(eTextArea);
		return;
	}
}
function st3_UpdateComment(nSearchesID){
	var b = $('st3_SavedSearchTA_'+nSearchesID).value;
	var a = $('st3_editComments_container_' + nSearchesID);

	var doUpdate = confirm('Are you sure you want to update your saved search comments?');
	if(!doUpdate){return a.update(origContent)}
	a.update(b);
	var doAjax = new Ajax.Request('?searchaction=ajax', {
		method: 'post',
		parameters: {
			method: 'Ajax_updateSavedSearchComment',
			nSearchesID: nSearchesID,
			vcComments: b,
			id: siteID,
			uuid: st3_getUUID()
		},
		onLoading: function(){
			$('st3_Modal_Header_Message').update('<img src="' + st3_DomainRoot + 'images/progress_bar.gif" alt="loading" border="0" /> Loading...');
		}
	});
}
function st3_updateSavedSearchEmail(nSearchesID){
	var bEmail = $('bEmail_' + nSearchesID).checked;
	var doAjax = new Ajax.Request('?searchaction=ajax', {
		method: 'post',
		parameters: {
			method: 'Ajax_updateSavedSearchEmail',
			nSearchesID: nSearchesID,
			bEmail: bEmail,
			id: siteID,
			uuid: st3_getUUID()
		}
	});	
}
function st3_submitContactForm(eForm){
}

function floor(number) {
	return Math.floor(number*Math.pow(10,2))/Math.pow(10,2);
}



/* *******
Please add any modifications to st3_dosum()
to the mortgagecalculator page as well
******* */
function st3_dosum(id) {
	var MCform = $(id);

	var mi = $('IR').value.replace(/[^0-9\.]/gi,'') / 1200;
	var base = 1;
	var mbase = 1 + mi;
	for (i=0; i<$('YR').value * 12; i++) {
		base = base * mbase;
	}
	$('PI').value = st3_formatCurrency(floor(($('LA').value.replace(/[^0-9\.]/gi,'') - $('DP').value.replace(/[^0-9\.]/gi,'')) * mi / ( 1 - (1/base))),false);
	$('MT').value = st3_formatCurrency(floor($('AT').value.replace(/[^0-9\.]/gi,'') / 12),false);
	$('MI').value = st3_formatCurrency(floor($('AI').value.replace(/[^0-9\.]/gi,'') / 12),false);
	var dasum = ($('LA').value.replace(/[^0-9\.]/gi,'') - $('DP').value.replace(/[^0-9\.]/gi,'')) * mi / ( 1 - (1/base)) +
		$('AT').value.replace(/[^0-9\.]/gi,'') / 12 +
		$('AI').value.replace(/[^0-9\.]/gi,'') / 12;
	$('MP').value = st3_formatCurrency(floor(dasum,false));
}
/* *******
Please add any modifications to st3_dosum()
to the mortgagecalculator page as well
******* */



/* **************************** Details page functions... ************************************** */
/* **************************** Map page functions... ************************************** */
function st3_getMapIcon(strType){
/* 	alert(st3_vcTypeList.length); */
/* 	return; */
	var typeIndex = 1;
	if(arguments.length==0){
		typeIndex = 1;
	} else {
		typeIndex = st3_vcTypeList.indexOf(strType) + 1;
	}
	
	if(typeIndex>11) {
		typeIndex = 11;
	}
	
	var eIcon = new GIcon();
	eIcon.image = st3_ImageRoot+'mapicons/'+typeIndex+'.png';
	eIcon.shadow = 'http://maps.google.com/intl/en_us/mapfiles/shadow50.png';
	eIcon.iconSize = new GSize(20, 34);
	eIcon.iconAnchor = new GPoint(9, 34);
	eIcon.infoWindowAnchor = new GPoint(20, 0);
	return eIcon;
}
function st3_gloadScript(callBack) {
	st3_gScriptLoaded = true;
	var script = document.createElement("script");
	script.type = "text/javascript";
	script.src = "http://maps.google.com/maps?file=api&v=2.x&key="+strGoogleAPIKey+"&async=2&callback=" + callBack;
	document.body.appendChild(script);
}
function st3_CustomControl() {
	}
function st3_initCustomControl(){
	/* Custom Map Controls */
	st3_CustomControl.prototype = new GControl();
	st3_CustomControl.prototype.initialize = function(map) {
		var container = new Element("div");
		var strContent = '';
			strContent += '<div id="st3_map_tool_container" style="font-size:10px;display:table;width:300px;padding:0px;background:#1F2429;-moz-border-radius: 10px;-webkit-border-radius: 10px;font-family:Verdana;font-size:13px;font-weight:bold;color:#fff;text-align:center;" class="window1">';
			strContent += '	<a href="javascript:void(0);" onclick="$(\'toolmenu\').toggle();return false;" title="Minimize and Maximize Map Tools."><img src="'+st3_ImageRoot+'icon/maximize_icon.png" border="0" alt="Show/Hide Tools" style="float:right;padding: 1px 4px 0px 0px;"></a>';
			strContent += '	<div id="st3_map_tool_Header" style="font-size:12px;padding:2px 0px 0px 20px;" title="Double Click to Minimize and Maximize Map Tools." ondblclick="$(\'toolmenu\').toggle();return false;" style="cursor:pointer;">';
			strContent += 'Map Tools-';
			strContent += '	</div>';
			strContent += '	<div id="toolmenu" style="padding:4px;">';
			strContent += '<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" style="margin-top:5px;padding:0px;">';
			strContent += '	<tr>';
			strContent += '		<td width="50%" align="center" valign="top" style="border-right:1px dashed #EFEFEF;">';
			strContent += '<!--- Left Column --->';
			strContent += '<table id="st3_map_tool_left_col" style="width:140px;margin:4px 0px 0px 0px;float:left;">';
			strContent += '	<tr>';
			strContent += '		<td nowrap="nowrap" style="color:#FFF;padding:2px;font-size:10px;text-align:right;" title="Current search result count.">Total Results: </td>';
			strContent += '		<td nowrap="nowrap" style="color:#FFF;padding:2px;font-size:10px;text-align:left;" id="st3_map_tool_Total_Results_Data" title="Current search result count.">Loading...</td>';
			strContent += '	</tr>';
			strContent += '	<tr>';
			strContent += '		<td nowrap="nowrap" style="color:#FFF;padding:2px;font-size:10px;text-align:right;" title="Click here to show/hide traffic.">Display Traffic: </td>';
			strContent += '		<td nowrap="nowrap" style="color:#FFF;padding:2px;font-size:10px;text-align:left;">';
			strContent += '<a href="javascript:void(0);" onclick="st3_showHideTraffic();return false;" title="Click here to show/hide traffic." style="font-weight:bolder;font-size:10px;color:#F5CF45;" id="st3_map_tool_ToggleTraffic_ID" class="st3_maptoollink">'+st3_bTrafficOn+'</a>';
			strContent += '		</td>';
			strContent += '	</tr>';
			strContent += '	<tr>';
			strContent += '		<td nowrap="nowrap" style="color:#FFF;padding:2px;font-size:10px;text-align:right;" title="Click here to show/hide results pane.">Show Results Pane: </td>';
			strContent += '		<td nowrap="nowrap" style="color:#FFF;padding:2px;font-size:10px;text-align:left;">';
			strContent += '<a href="javascript:void(0);" onclick="st3_showHideMap();return false;" title="Click here to show/hide traffic." style="font-weight:bolder;color:#FFF;font-size:10px;color:#F5CF45;" id="st3_map_tool_ToggleResultsPane_ID" class="st3_maptoollink">'+st3_bResultsPane+'</a>';
			strContent += '		</td>';
			strContent += '	</tr>';
			strContent += '	<tr>';
			strContent += '		<td nowrap="nowrap" style="color:#FFF;padding:2px;font-size:10px;text-align:right;" title="Change the number of results displayed on the map.">Displayed: </td>';
			strContent += '		<td nowrap="nowrap" style="color:#FFF;padding:2px;font-size:10px;text-align:left;">';
			strContent += '<select style="height:16px;font-size:9px;width:50px;" onchange="st3_getMapListingsRPP=this.value;st3_getMapListings(false); return false;" title="Change the number of results displayed on the map.">';
			strContent += '	<option value="0">0</option>';
			strContent += '	<option value="10">10</option>';
			strContent += '	<option value="20" selected>20</option>';
			strContent += '	<option value="30">30</option>';
			strContent += '	<option value="40">40</option>';
			strContent += '	<option value="50">50</option>';
			strContent += '</select>';
			strContent += '		</td>';
			strContent += '	</tr>';
			strContent += '</table>';
			strContent += '		</td>';
			strContent += '		<td width="50%" align="center" valign="top">';
			strContent += '<!--- Right col --->';
			strContent += '<table id="st3_map_tool_left_col" style="width:140px;margin:4px 0px 0px 0px;float:left;">';
			strContent += '	<tr>';
			strContent += '		<td nowrap="nowrap" style="color:#FFF;padding:2px;font-size:10px;text-align:right;" title="Click here to view all results.">View Results: </td>';
			strContent += '		<td nowrap="nowrap" style="color:#FFF;padding:2px;font-size:10px;text-align:left;">';
			strContent += '<a href="javascript:void(0);" onclick="st3_submitSearchForm();return false;" title="Click here to view all results." style="font-weight:bolder;color:#F5CF45;font-size:10px;" class="st3_maptoollink"> GO! </a>';
			strContent += '		</td>';
			strContent += '	</tr>';
			strContent += '	<tr>';
			strContent += '		<td nowrap="nowrap" style="color:#FFF;padding:2px;font-size:10px;text-align:right;" title="Click here to save this search.">Save Search: </td>';
			strContent += '		<td nowrap="nowrap" style="color:#FFF;padding:2px;font-size:10px;text-align:left;">';
			strContent += '<a href="javascript:void(0);" onclick="st3_saveSearch();return false;" title="Click here to save this search." style="font-weight:bolder;color:#F5CF45;font-size:10px;" class="st3_maptoollink"> GO! </a>';
			strContent += '		</td>';
			strContent += '	</tr>';
			strContent += '	<tr>';
			strContent += '		<td nowrap="nowrap" style="color:#FFF;padding:2px;font-size:10px;text-align:right;" title="Click here to reset map to starting point.">Reset Map: </td>';
			strContent += '		<td nowrap="nowrap" style="color:#FFF;padding:2px;font-size:10px;text-align:left;">';
			strContent += '<a href="javascript:void(0);" onclick="st3_resetMap();return false;" title="Click here to reset map to starting point." style="font-weight:bolder;color:#F5CF45;font-size:10px;" class="st3_maptoollink"> GO! </a>';
			strContent += '		</td>';
			strContent += '	</tr>';
			strContent += '	<tr>';
			strContent += '		<td nowrap="nowrap" style="color:#FFF;padding:2px;font-size:10px;text-align:right;" title="Change map type (Map, Satellite, Hybrid).">Map Type: </td>';
			strContent += '		<td nowrap="nowrap" style="color:#FFF;padding:2px;font-size:10px;text-align:left;">';
			strContent += '<select style="height:16px;font-size:9px;width:50px;" onchange="st3_doMapChange(this.value); return false;" title="Change map type (Map, Satellite, Hybrid).">';
			strContent += '	<option value="0">Map</option>';
			strContent += '	<option value="1">Satellite</option>';
			strContent += '	<option value="2">Hybrid</option>';
			strContent += '</select>';
			strContent += '		</td>';
			strContent += '	</tr>';
			strContent += '</table>';
			strContent += '		</td>';
			strContent += '	</tr>';
			strContent += '	<tr>';
			strContent += '		<td colspan="2" align="center" valign="top" style="padding:0px;margin:0px;height:10px;font-size:1px;">';
			strContent += '		</td>';
			strContent += '	</tr>';
			strContent += '	<tr>';
			strContent += '		<td colspan="2" align="center" valign="top" style="padding:5px 2px 5px 2px;margin:0px;border-top:1px dashed #EFEFEF;">';
			strContent += '<form onsubmit="st3_showAddress($(\'gaddress\').value);return false;" style="margin:0px;padding:0px;">';
			strContent += '<input style="-moz-border-radius:5px;-webkit-border-radius:5px;font-size:10px;height:16px;padding:0px;width:250px;background:url('+st3_ImageRoot+'tblContent_bg.jpg) #FFF repeat-x bottom;" type="text" title="Enter an Address, City or Zipcode." name="gaddress" id="gaddress" value="Address, Zipcode or City" onclick="st3_Focus_GAddress_Search();return false;">';
			strContent += '<a href="javascript:void(0);" onclick="st3_showAddress($(\'gaddress\').value);return false;" style="font-weight:bolder;color:#F5CF45;font-size:10px;border:1px solid #F5CF45;padding:1px;" title="Get new search results.">GO!</a>';
			strContent += '</form>';
			strContent += '		</td>';
			strContent += '	</tr>';
			strContent += '	<tr>';
			strContent += '		<td colspan="2" align="center" valign="top" style="padding:5px 0px 0px 0px;margin:0px 2px 0px 2px;border-top:1px dashed #EFEFEF;">';
			strContent += '<strong style="font-size:12px;color:#EFEFEF;" title="Each icon represents a different property type.">Property Type Legend:</strong>';
			strContent += '		</td>';
			strContent += '	</tr>';
			strContent += '	<tr>';
			strContent += '		<td colspan="2" align="center" valign="top" style="padding:2px 2px 0px 2px;margin:0px;">';
			strContent += '<div style="color:#000;padding:4px;width:85%;height:50px;overflow-x:hidden;overflow-y:auto;text-align:left;background:#FFF;" title="Each icon represents a different property type.">';
			strContent += st3_getTypeLegend();
			strContent += '</div>';
			strContent += '		</td>';
			strContent += '	</tr>';
			strContent += '	<tr>';
			strContent += '		<td colspan="2" align="center" valign="top" style="padding:0px;margin:0px;height:10px;font-size:1px;">';
			strContent += '		</td>';
			strContent += '	</tr>';
			strContent += '</table>';
			strContent += '	</div>';
			strContent += '</div>';
		container.innerHTML = strContent;	
		st3_map.getContainer().appendChild(container);
		
		if(HideMapTools){
			$('toolmenu').toggle();
		}

		return container;
	}
	st3_CustomControl.prototype.getDefaultPosition = function() {
		return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 7));
	}
	/* //Custom Map Controls */
}
function st3_getTypeLegend(){
	var strTypeLegendContent = '';
	var theIndex = 0;
	try{
	st3_vcTypeList.each(function(item,index){
		if(index+1>11) {
			theIndex = 11;
		} else {
			theIndex = index+1;
		}
		strTypeLegendContent += '<div style="float:left;"><img style="height:17px;" src="'+st3_ImageRoot+'mapIcons/'+theIndex+'.png" alt="Icon ' + item + '" border="0" title="This is the Icon for Property Type: '+item+'" /></div><div id="st3_mapLegendIcon_Header_'+theIndex+'" style="padding-left:2px;display:table;float:left;"> - ' + item + '</div><div class="st3_clear_2"></div>';
	});
	} catch(e){
		return;
	}
	return strTypeLegendContent;
}
function st3_Focus_GAddress_Search(){
	if($('gaddress').value=='Address, Zipcode or City'){
		$('gaddress').value = '';
	}
}
function st3_resetMap(){
	st3_map.setCenter(new GLatLng($('st3_vcLocation_Lon').value,$('st3_vcLocation_Lat').value), parseInt($('st3_vcLocation_Zoom').value));
}
function st3_showAddress(address){
	if (geocoder){
		geocoder.getLatLng(address,function(point){
			if (!point) {
				alert("Sorry, the location: " + address + " was not found.");
			} else {
				st3_map.setCenter(point, 12);
				var yellowIcon = st3_getMapIcon();
				var addressmarker = new GMarker(point,{icon:yellowIcon,zIndexProcess:function(){return 10000}});
				st3_map.addOverlay(addressmarker);
			}
		});
	}
}
function st3_loadMap(id,init){
	var id = 'st3_map_elem';
/* 	var id = 't'; */
	var init = true;
	if (st3_MapLoaded){
		return;
	}
	st3_MapLoaded = true;
	if (GBrowserIsCompatible()){	
		if(!Prototype.Browser.IE){
			$('st3_Map_Content').setStyle({'display':'table'});
		}
		$(id).setStyle({'width':'100%','height':'600px'});
		var eMapSearchCount = new Element('div',{'id':'st3_MapSearchCount','style':'margin-left:10px;'});
		$('st3_SearchHeader').appendChild(eMapSearchCount);
		//new Insertion.After('st3_SearchHeader',eMapSearchCount);
		//$('st3_MapSearchCount').update('RESULTS COUNT');
		st3_map = new GMap2($(id));
		st3_map.setCenter(new GLatLng($('st3_vcLocation_Lon').value,$('st3_vcLocation_Lat').value), parseInt($('st3_vcLocation_Zoom').value));

		var cmc = st3_initCustomControl();
		geocoder = new GClientGeocoder();
		var CustomControl = new st3_CustomControl();
		st3_map.addControl(CustomControl);
		var MapControl = new GLargeMapControl();
		var TypeControl = new GMapTypeControl();
		var OverViewControl = new GOverviewMapControl();
/* 		var ScrollWheelZoom = st3_map.enableScrollWheelZoom(); */
		st3_getMapListings(true);
		GEvent.addListener(st3_map, "mouseover", function(){
			st3_map.addControl(MapControl);
/* 			st3_map.addControl(TypeControl); */
			st3_map.addControl(OverViewControl);
/* 			$('st3_map_tool_container').show(); */
		});
		GEvent.addListener(st3_map, "movestart", function(){
			if (st3_map.infowindowopen){
				st3_map.closeInfoWindow();
			}
		});
		GEvent.addListener(st3_map, "dragstart", function(){
			if (st3_map.infowindowopen){
				st3_map.closeInfoWindow();
			}
		});
		GEvent.addListener(st3_map, "dragend", function(){
			st3_getMapListings(false);
			if (st3_map.infowindowopen){
				st3_map.closeInfoWindow();
			}
		});
		GEvent.addListener(st3_map, "zoomend", function(){
			st3_getMapListings(false);
			try{$('st3_vcLocation_Zoom').value = st3_map.getZoom()} catch(e) {}
			if (st3_map.infowindowopen){
				st3_map.closeInfoWindow();
			}
		});
		GEvent.addListener(st3_map, "dblclick", function(){
/* 			st3_getMapListings(false); */
			try{$('st3_vcLocation_Zoom').value = st3_map.getZoom()} catch(e) {}
			if (st3_map.infowindowopen){
				st3_map.closeInfoWindow();
			}
		});
		GEvent.addListener(st3_map, "mouseout", function(){
			st3_map.removeControl(MapControl);
/* 			st3_map.removeControl(TypeControl); */
			st3_map.removeControl(OverViewControl);
/* 			$('st3_map_tool_container').hide(); */
		});
		GEvent.addListener(st3_map, "infowindowclose", function(){
			MarkerClicked = 0;
		});
		GEvent.addListener(st3_map, "change", function(){
		});
	}
}
function st3_doMapChange(index){
	return st3_map.setMapType(st3_map.getMapTypes()[index]);
}

function st3_viewThumbNailMap(listing,lat,lon){
	if (GBrowserIsCompatible()){
		$('st3_map_th_' + listing,'ListingPhotoLoading_' + listing,'View_Map_' + listing,'View_Photo_' + listing).invoke('toggle');
		var element = $('st3_map_th_' + listing);
		var photo = $('ListingPhotoLoading_' + listing);
		var st3_map = new GMap2(element);
		var point = new GLatLng(lat,lon);
		var marker = new GMarker(point);
		st3_map.setCenter(point,10);
		st3_map.addOverlay(new GMarker(point));
	}
}
function st3_showHideMap(){
	$('st3_Map_Thumbnail_Listings').toggle();
	if(st3_bResultsPane=='Off'){
		st3_bResultsPane = 'On';
	} else {
		st3_bResultsPane = 'Off';
	}
	$('st3_map_tool_ToggleResultsPane_ID').update(st3_bResultsPane);
}
function st3_showHideTraffic(){
	if(!st3_bTrafficInitialized){
		var trafficOptions = {incidents:true};
		trafficInfo = new GTrafficOverlay(trafficOptions);
		st3_bTrafficInitialized = true;
		st3_bTrafficOn = 'On';
		TrafficOverlay = st3_map.addOverlay(trafficInfo);
		$('st3_map_tool_ToggleTraffic_ID').update(' ' + st3_bTrafficOn);
		return;
	}
	if(st3_bTrafficOn=='On'){
		st3_bTrafficOn = 'Off';
 		trafficInfo.hide();
	} else {
		st3_bTrafficOn = 'On';
		trafficInfo.show();
	}
	$('st3_map_tool_ToggleTraffic_ID').update(' ' + st3_bTrafficOn);
}
function st3_ExpandMap(nListingsID,lat,lon){
	if (document.location.href.search(/showmaponly=true/i) > -1 && document.location.href.search(/searchaction=results/i) > -1) {
		var viewMapOnly = true;
		var eCloser = new Element('div').update('');
		var mheight = st3_getModalWindowHeight(50);
		var mwidth = st3_getModalWindowWidth(50);
	} else {
		var viewMapOnly = false;
		var eCloser = new Element('div').update(st3_showClose());
		var mheight = st3_getModalWindowHeight(100);
		var mwidth = st3_getModalWindowWidth(100);
	}
	var mapID = 'st3_expanded_map_'+nListingsID;
	if(Object.isElement($(mapID))){
		$(mapID).remove();
	}
	if(vcMLSName.indexOf('REIN') > -1){
		var eMLSDisclaimer = new Element('div').update($$('.mlsfooter')[0].innerHTML);
	} else {
		var eMLSDisclaimer = new Element('div');
	}
	var modal = new Control.Window('<div id="'+mapID+'" style="border:1px solid #CCC;height:95%;width:100%px;margin-bottom:10px;"></div>',{
		closeOnClick:eCloser,
		className:'modal_container',
		height: mheight,
		width: mwidth,
		afterClose: function(){
			this.destroy();
		},
		afterOpen: function(){
			this.container.setStyle({'overflow':'hidden'});
			st3_map = new GMap2($(mapID));
			var point = new GLatLng(lat,lon);

			st3_map.setCenter(point,10);
/* 			var cmc = st3_initCustomControl(); */
/* 			var CustomControl = new st3_CustomControl(); */
/* 			st3_map.addControl(CustomControl); */
			
			if(!st3_MapControlsCreated){
				var MapControl = new GLargeMapControl();
				var OverViewControl = new GOverviewMapControl();
			}
			st3_MapControlsCreated = true;
			
			st3_getMapListings(true,nListingsID,viewMapOnly);
			GEvent.addListener(st3_map, "mouseover", function(){
				try {
					st3_map.addControl(MapControl);
					st3_map.addControl(OverViewControl);
				} catch(e) {}
			});
			GEvent.addListener(st3_map, "movestart", function(){
				if (st3_map.infowindowopen){
					st3_map.closeInfoWindow();
				}
			});
			GEvent.addListener(st3_map, "dragstart", function(){
				if (st3_map.infowindowopen){
					st3_map.closeInfoWindow();
				}
			});
			GEvent.addListener(st3_map, "dragend", function(){
				st3_getMapListings(true,nListingsID,viewMapOnly);
				if (st3_map.infowindowopen){
					st3_map.closeInfoWindow();
				}
			});
			GEvent.addListener(st3_map, "zoom", function(){
				st3_getMapListings(true,nListingsID,viewMapOnly);
				if (st3_map.infowindowopen){
					st3_map.closeInfoWindow();
				}
			});
			GEvent.addListener(st3_map, "dblclick", function(){
				st3_getMapListings(true,nListingsID,viewMapOnly);
				if (st3_map.infowindowopen){
					st3_map.closeInfoWindow();
				}
			});
			GEvent.addListener(st3_map, "mouseout", function(){
				st3_map.removeControl(MapControl);
				st3_map.removeControl(OverViewControl);
			});
			GEvent.addListener(st3_map, "infowindowclose", function(){
				MarkerClicked = 0;
			});
		}
	});
	st3_prependChild(modal.container,eCloser);
	st3_prependChild(modal.container,eMLSDisclaimer);
	modal.open();
}
function st3_getMapListings(init,listing,viewMapOnly){
	if (arguments.length >= 2){
		if(arguments.length == 2) {viewMapOnly = false;}
		new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
			method: 'post',
			parameters: {
				useSessionSearch: true,
				getAccordionCount: $('st3_Accordion_Container').visible(),
				method: 'Ajax_getMapSearchListings',
				RPP: st3_getMapListingsRPP,
				id: siteID,
				listing: listing,
				uuid: st3_getUUID()
			},
			onSuccess: function(transport){
				var JSONResult = transport.responseText.evalJSON(true);
				var strOut = '';
				st3_map.clearOverlays();
				var bounds = new GLatLngBounds();
				var markerImage = [
				"http://www.google.com/intl/en_ALL/mapfiles/marker.png",
				"http://maps.google.com/mapfiles/dd-start.png",
				"http://maps.google.com/mapfiles/dd-end.png",
				"http://esa.ilmari.googlepages.com/markeryellow.png",//3 yellow
				"http://www.google.com/uds/samples/places/temp_marker.png",//4 turquoise
				]
				var yellowIcon = new GIcon();
				yellowIcon.image = markerImage[3];
				yellowIcon.iconSize = new GSize(20, 34);
				yellowIcon.iconAnchor = new GPoint(9, 34);
				JSONResult.QUERY.DATA.each(function(row,index){
					var photoTab = new GInfoWindowTab('Photos', '');
					var tabContent = new Array();
						if(viewMapOnly) {
							tabContent.push(new GInfoWindowTab('Details', st3_doMapListingDetailsSmall(row,index)));
						} else {
							tabContent.push(new GInfoWindowTab('Details', st3_doMapListingDetails(row,index)));
							tabContent.push(photoTab);
						}
					var point = new GLatLng(row[13],row[14]);
					if (row[0] == listing){
						var marker1 = new GMarker(point,{icon:yellowIcon,zIndexProcess:function(){return 10000}});
						st3_map.addOverlay(marker1);
					}
					var marker = new GMarker(point);
					GEvent.addListener(marker, "click", function(){
						st3_doMapListingPhotos(row[12],photoTab);
						marker.openInfoWindowTabs(tabContent);
					});
					st3_map.addOverlay(marker);
					if(row[12]==listing && !viewMapOnly){
						marker.openInfoWindowTabs(tabContent);
						st3_doMapListingPhotos(row[12],photoTab);
					}
					delete tabContent;
					bounds.extend(point);
				});
					var thiszoom = st3_map.getBoundsZoomLevel(bounds)>=15?15:st3_map.getBoundsZoomLevel(bounds);
					st3_map.setCenter(bounds.getCenter(), thiszoom); 
			}
		});
		return;
	}
	$('vcCoords').value = st3_map.getBounds().toString();
	$('vcMapCenter').value = st3_map.getCenter().toString();
	st3_getSearchCount($(st3_CurrentForm).serialize().replace(/(&|\?)vcCoords=[^&]*/gi,'') + '&vcCoords=' + st3_map.getBounds().toString());
	$('SearchForm_Map').action = st3_AjaxRoot + '?searchaction=ajax';
	$('SearchForm_Map').request({
		parameters: {
			method: 'Ajax_getMapSearchListings',
			id: siteID,
			rpp: st3_getMapListingsRPP,
			uuid: st3_getUUID()
			},
		method: 'post',
		onSuccess: function(transport){
			var JSONResult = transport.responseText.evalJSON(true);
			var strOut = '';
			st3_map.clearOverlays();
			var bounds = new GLatLngBounds();
			$('st3_Map_Thumbnail_Listings').update();
			aTabContent = [];
			aMarker = [];
			JSONResult.QUERY.DATA.each(function(row,index){
				st3_addListingThumbnail(row,index);
				var tabContent = new Array();
				var detailTab = new GInfoWindowTab('Details', st3_doMapListingDetails(row,index));
				var photoTab = new GInfoWindowTab('Photos', '')
				tabContent.push(detailTab);
				tabContent.push(photoTab);
				var point = new GLatLng(row[13],row[14]);
				var cIcon = st3_getMapIcon(row[5]);
				var marker = new GMarker(point,{icon:cIcon});
				GEvent.addListener(marker, "click", function(){
					st3_doMapListingPhotos(row[12],photoTab);
					marker.openInfoWindowTabs(tabContent);
				});
				GEvent.addListener(marker, "mouseover", function(){
					$('st3_Thumbnail_' + row[0]).childElements().invoke('addClassName','highlight');
				});
				GEvent.addListener(marker, "mouseout", function(){
					$('st3_Thumbnail_' + row[0]).childElements().invoke('removeClassName','highlight');
				});
				st3_map.addOverlay(marker);
				aTabContent[index] = tabContent;
				aMarker[index] = marker;
				delete tabContent;
				bounds.extend(point);
			})
		}
	});
}
function st3_addListingThumbnail(row,index){
	var cleanPrice = st3_formatCurrency(parseInt(row[2]),false);
	var displayPrice = '';
	
	if(cleanPrice.length<6){
		displayPrice = cleanPrice;
	} else if(cleanPrice.split(',').length==2) {
		displayPrice = cleanPrice.split(',')[0] + ' k';
	} else if(cleanPrice.split(',').length==3) {
		displayPrice = cleanPrice.split(',')[0] + '.' + cleanPrice.split(',')[1] + ' m';
	}
	
	if (index == 0){
	var eListingDisplayContainer = $('st3_Map_Thumbnail_Listings');
	var clearDiv = new Element('div',{'class': 'st3_clear_2'});
	var eNewListingThumb_Container = new Element('div',{'class':'st3_T_Container','id':'st3_Thumbnail_Header_Row'});
	var eNewListingThumb_Addr = new Element('div',{'class':'st3_Map_Listing_Thumb st3_T_Addr st3_Map_Listing_Thumb_Head'}).update('Addr');
	var eNewListingThumb_Price = new Element('div',{'class':'st3_Map_Listing_Thumb st3_T_Price st3_Map_Listing_Thumb_Head'}).update('Price');
	var eNewListingThumb_Bed_Bath = new Element('div',{'class':'st3_Map_Listing_Thumb st3_Bed_Bath st3_Map_Listing_Thumb_Head'}).update('Bd/Ba');
	eNewListingThumb_Container.appendChild(eNewListingThumb_Addr);
	eNewListingThumb_Container.appendChild(eNewListingThumb_Price);
	eNewListingThumb_Container.appendChild(eNewListingThumb_Bed_Bath);
	eNewListingThumb_Container.appendChild(clearDiv);
	eListingDisplayContainer.appendChild(eNewListingThumb_Container);
	}
	var eListingDisplayContainer = $('st3_Map_Thumbnail_Listings');
	var clearDiv = new Element('div',{'class': 'st3_clear_2'});
	var eNewListingThumb_Container = new Element('div',{'onmouseout':'aMarker[' + index + '].setImage("http://maps.google.com/intl/en_us/mapfiles/marker.png")','onmouseover':'aMarker[' + index + '].setImage("http://esa.ilmari.googlepages.com/markeryellow.png")','onclick':'aMarker[' + index + '].openInfoWindowTabs(aTabContent[' + index + '])','class':'st3_T_Container','id':'st3_Thumbnail_' + row[0]});
	var eNewListingThumb_Addr = new Element('div',{'class':'st3_Map_Listing_Thumb st3_T_Addr'}).update(row[1].truncate(12));
	var eNewListingThumb_Price = new Element('div',{'class':'st3_Map_Listing_Thumb st3_T_Price'}).update(displayPrice);
	var eNewListingThumb_Bed_Bath = new Element('div',{'class':'st3_Map_Listing_Thumb st3_Bed_Bath'}).update(row[3] + '/' + row[11]);
	eNewListingThumb_Container.appendChild(eNewListingThumb_Addr);
	eNewListingThumb_Container.appendChild(eNewListingThumb_Price);
	eNewListingThumb_Container.appendChild(eNewListingThumb_Bed_Bath);
	eNewListingThumb_Container.appendChild(clearDiv);
	eListingDisplayContainer.appendChild(eNewListingThumb_Container);
}

function st3_doMapListingDetailsSmall(row,index){
/* VCLISTING,VCADDRESS1,MPRICE,NBEDROOMS,NSQFEET,VCTYPE,VCCITY,VCZIPCODE,VCSTATE,VCAGENTNAME,VCOFFICENAME,DBLBATHROOMS,NLISTINGSID,DBLLATITUDE,DBLLONGITUDE,NMLSID,VCMLSNAME,DTOPENHOUSESTARTS,VCSQFEET,VCURL,BSOB,VCPHOTOPATH,BSAVED,VCSTATUS */
var bSaved = row[21]?true:false;
var action = bSaved?"'unsave'":"'save'";
var actionimage = bSaved?'remove-lrg-btn.jpg':'Save-lrg-btn.jpg';
var mapListing = "'MapListings'";
var quotedRow10 = "'" + row[10] + "'";
var a1 = new Element('div',{'id':'st3'});
var a = new Element('div',{'id':'st3_map_listing_container_'+row[12],'style':'font-family:verdana;font-size:10px;border:0px solid #EFEFEF;height:80px;width:200px;'});
var b = new Element('div',{'id':'st3_map_header_container'});
var c = new Element('div',{'id':'st3_map_header_left','style':'float:left;padding:5px;font-style:italic;'}).update('<a style="font-size:10px;" href="?searchaction=details&nListingsID='+row[12]+'&currentpage='+index+'" title="View Details for listing: '+row[0]+'" id="st3_details">' + row[1] + ': ' + row[6] + ', ' + row[8] + ' ' + row[7] + '</a>');
/* var e = new Element('div',{'id':'st3_map_header_right','style':'float:right;padding:5px;'}).update(row[6] + ', ' + row[8] + ' ' + row[7]); */
var f = new Element('div',{'class':'st3_clear_2'});
var g = new Element('div',{'id':'st3_map_body_container','style':'height:auto;width:auto;overflow:hidden;border-top:0px none;background:#FFF;'});
var h = new Element('div',{'id':'st3_map_body_left','style':'float:left;padding:5px;'});
var h2 = new Element('img',{'class':'st3_MapPhoto','id':'st3_map_photo'+row[12],'style':'height:40px;width:50px;border:1px solid #EFEFEF;','src':row[21]});
	try{
	Event.observe(h2,'error',function(x){
		h2.src='http://216.17.83.120/nophoto.gif';
	});
	}catch(e){}
var i = new Element('div',{'id':'st3_map_body_right','style':'float:left;padding:5px;'});
/* var j = new Element('div',{'id':'st3_map_Address','style':'border-bottom:1px dashed #707070;width:140px;padding:2px 2px 2px 0px;'}).update('<strong>'+row[1]+'</strong>'); */
/* var k = new Element('div',{'id':'st3_map_City','style':'margin-left:8px;'}).update(row[6] + ', ' + row[8] + ' ' + row[7]); */
var l = new Element('div',{'id':'st3_map_Price','style':'margin-left:8px;'}).update(st3_formatCurrency(row[2],false));
var m = new Element('div',{'id':'st3_map_BedBath','style':'margin-left:8px;'}).update(row[3] + ' Beds/' + row[11] + ' Baths');
var n = new Element('div',{'id':'st3_map_Type','style':'margin-left:8px;'}).update(row[5]);
var o = new Element('div',{'id':'st3_map_Sqft','style':'margin-left:8px;'}).update(row[4]=='null'?row[4] + ' sqft':'');
var p = new Element('div',{'class':'st3_clear_2'});
var q = new Element('div',{'class':'st3_clear_2'});
var r = new Element('div',{'id':'st3_footer','style':'background:url('+st3_ImageRoot+'tblContent_bg.jpg) #FFF repeat-x bottom;'});
/* var s = new Element('div',{'id':'st3_footer_1','style':'width:30%;text-align:center;float:left;padding:5px;border:0px solid;font:10px verdana;'}).update('<a href="javascript:void(0);" title="Inquire about listing: '+row[0]+'" onclick="st3_dspModal(\'contact\','+row[12]+'); return false;" id="st3_inquire"><img border="0" src="'+st3_ImageRoot+'buttons/Inquire-lrg-btn.jpg" alt="Inquire about listing: '+row[0]+'" /></a>'); */
/* var t = new Element('div',{'id':'st3_footer_2','style':'width:30%;text-align:center;float:left;padding:5px;border:0px solid;font:10px verdana;'}).update('<a href="javascript:void(0);" title="View Details for listing: '+row[0]+'" onclick="st3_dspPreview('+row[12]+',1); return false;" id="st3_details">View Details</a>'); */
/* var u = new Element('div',{'id':'st3_Map_footer_' + row[12],'style':'width:30%;text-align:center;float:left;padding:5px;border:0px solid;font:10px verdana;'}).update('<a href="javascript:void(0);" title="Save/Unsave listing: '+row[0]+'" onclick="st3_savedListings('+row[12]+','+action+','+mapListing+'); return false;" id="st3_saved_listing_'+row[12]+'"><img border="0" src="'+st3_ImageRoot+'buttons/'+actionimage+'" alt="Save/Unsave listing: '+row[0]+'" /></a>'); */
var v = new Element('div',{'class':'st3_clear_2'});
a1.appendChild(a);
a.appendChild(b);
b.appendChild(c);
/* b.appendChild(e); */
b.appendChild(f);
a.appendChild(g);
g.appendChild(h);
h.appendChild(h2);
g.appendChild(i);
/* i.appendChild(j); */
/* i.appendChild(k); */
i.appendChild(l);
i.appendChild(m);
i.appendChild(n);
i.appendChild(o);
i.appendChild(p);
g.appendChild(q);
g.appendChild(r);
/* r.appendChild(s); */
/* r.appendChild(t); */
/* r.appendChild(u); */
r.appendChild(v);
return a1;
}

function st3_doMapListingDetails(row,index){
/* VCLISTING,VCADDRESS1,MPRICE,NBEDROOMS,NSQFEET,VCTYPE,VCCITY,VCZIPCODE,VCSTATE,VCAGENTNAME,VCOFFICENAME,DBLBATHROOMS,NLISTINGSID,DBLLATITUDE,DBLLONGITUDE,NMLSID,VCMLSNAME,DTOPENHOUSESTARTS,VCSQFEET,VCURL,BSOB,VCPHOTOPATH,BSAVED,VCSTATUS */
var bSaved = row[21]?true:false;
var action = bSaved?"'unsave'":"'save'";
var actionimage = bSaved?'remove-lrg-btn.jpg':'Save-lrg-btn.jpg';
var mapListing = "'MapListings'";
var theBrLogo = vcMLSName.indexOf('REIN') > -1 && !row[20]?'<img src="/st3/MLSDisclaimers/REIN-THbrlogo.gif" style="float:right;">':'';
var quotedRow10 = "'" + row[10] + "'";
var a1 = new Element('div',{'id':'st3'});
var a = new Element('div',{'id':'st3_map_listing_container_'+row[12],'style':'font-family:verdana;font-size:10px;border:0px solid #EFEFEF;height:160px;width:400px;'});
var b = new Element('div',{'id':'st3_map_header_container','style':'border:1px solid #CCC;background:url('+st3_ImageRoot+'tblContent_bg.jpg) #FFF repeat-x bottom;-moz-border-radius-topright: 5px;-moz-border-radius-topleft: 5px;-webkit-border-top-left-radius: 5px;-webkit-border-top-right-radius: 5px;'});
var c = new Element('div',{'id':'st3_map_header_left','style':'float:left;padding:5px;font-style:italic;'}).update(row[1]);
var e = new Element('div',{'id':'st3_map_header_right','style':'float:right;padding:5px;'}).update(row[6] + ', ' + row[8] + ' ' + row[7]);
var f = new Element('div',{'class':'st3_clear_2','style':'clear:both;'});
var g = new Element('div',{'id':'st3_map_body_container','style':'height:auto;width:auto;overflow:hidden;border:1px solid #CCC;border-top:0px none;background:#FFF;-moz-border-radius-bottomright: 5px;-moz-border-radius-bottomleft: 5px;-webkit-border-bottom-left-radius: 5px;-webkit-border-bottom-right-radius: 5px;'});
var h = new Element('div',{'id':'st3_map_body_left','style':'float:left;padding:5px;'});
var h2 = new Element('img',{'class':'st3_MapPhoto','id':'st3_map_photo'+row[12],'style':'height:80px;width:100px;border:1px solid #EFEFEF;','src':row[21]});
	try{
	Event.observe(h2,'error',function(x){
		h2.src='http://216.17.83.120/nophoto.gif';
	});
	}catch(e){}
var i = new Element('div',{'id':'st3_map_body_right','style':'float:left;padding:5px;'});
var j = new Element('div',{'id':'st3_map_Address','style':'border-bottom:1px dashed #707070;width:240px;padding:2px 2px 2px 0px;'}).update('<strong>'+row[1]+'</strong>');
var k = new Element('div',{'id':'st3_map_City','style':'margin-left:8px;'}).update(theBrLogo + row[6] + ', ' + row[8] + ' ' + row[7]);
var l = new Element('div',{'id':'st3_map_Price','style':'margin-left:8px;'}).update(st3_formatCurrency(row[2],false));
var m = new Element('div',{'id':'st3_map_BedBath','style':'margin-left:8px;'}).update(row[3] + ' Beds/' + row[11] + ' Baths');
var n = new Element('div',{'id':'st3_map_Type','style':'margin-left:8px;'}).update(row[5]);
var o = new Element('div',{'id':'st3_map_Sqft','style':'margin-left:8px;'}).update(row[4]=='null'?row[4] + ' sqft':'');
var p = new Element('div',{'class':'st3_clear_2'});
var q = new Element('div',{'class':'st3_clear_2'});
var r = new Element('div',{'id':'st3_footer','style':'overflow:hidden;width:400px;border-collapse:collapse;height:auto;background:url('+st3_ImageRoot+'tblContent_bg.jpg) #FFF repeat-x bottom;border-top:1px solid #CCC !important;display:block;-moz-border-radius-bottomright: 5px;-moz-border-radius-bottomleft: 5px;-webkit-border-bottom-left-radius: 5px;-webkit-border-bottom-right-radius: 5px;'});
var s = new Element('div',{'id':'st3_footer_1','style':'width:30%;text-align:center;float:left;padding:5px;border:0px solid;font:10px verdana;'}).update('<a href="javascript:void(0);" title="Inquire about listing: '+row[0]+'" onclick="st3_dspModal(\'contact\','+row[12]+'); return false;" id="st3_inquire"><img border="0" src="'+st3_ImageRoot+'buttons/Inquire-lrg-btn.jpg" alt="Inquire about listing: '+row[0]+'" /></a>');
var t = new Element('div',{'id':'st3_footer_2','style':'width:30%;text-align:center;float:left;padding:5px;border:0px solid;font:10px verdana;'}).update('<a href="javascript:void(0);" title="View Details for listing: '+row[0]+'" onclick="st3_dspPreview('+row[12]+',1); return false;" id="st3_details"><img border="0" src="'+st3_ImageRoot+'buttons/Details-lrg-btn.jpg" alt="View Details for listing: '+row[0]+'" /></a>');
var u = new Element('div',{'id':'st3_Map_footer_' + row[12],'style':'width:30%;text-align:center;float:left;padding:5px;border:0px solid;font:10px verdana;'}).update('<a href="javascript:void(0);" title="Save/Unsave listing: '+row[0]+'" onclick="st3_savedListings('+row[12]+','+action+','+mapListing+'); return false;" id="st3_saved_listing_'+row[12]+'"><img border="0" src="'+st3_ImageRoot+'buttons/'+actionimage+'" alt="Save/Unsave listing: '+row[0]+'" /></a>');
var v = new Element('div',{'class':'st3_clear_2'});
a1.appendChild(a);
a.appendChild(b);
b.appendChild(c);
b.appendChild(e);
b.appendChild(f);
a.appendChild(g);
g.appendChild(h);
h.appendChild(h2);
g.appendChild(i);
i.appendChild(j);
i.appendChild(k);
i.appendChild(l);
i.appendChild(m);
i.appendChild(n);
i.appendChild(o);
i.appendChild(p);
g.appendChild(q);
g.appendChild(r);
r.appendChild(s);
r.appendChild(t);
r.appendChild(u);
r.appendChild(v);
return a1;
}

function st3_doMapListingPhotos(strNListingsID,eID){
	var getPhotos = new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax',{
		requestHeaders: {
			Accept: 'application/json'
		},
		method: 'post',
		parameters: {
			method: 'Ajax_getDetailPhotos',
			nListingsID: strNListingsID,
			uuid: st3_getUUID(),
			id: siteID
		},
		onSuccess: function(transport){
			var contents  = '<div class="st3_gmap_photo_container" style="overflow:hidden;height:150px;width:360px;overflow-x:hidden;overflow-y:scroll;">';
			var JSONResult = transport.responseText.evalJSON();
			JSONResult.DATA.DATA.DATA.each(function(e,i){
				contents += '<img src="'+e[0]+'" style="width:80px;padding:2px;">';
			});
			$(eID.contentElem).update(contents + '</div>');
		}
	});
	return;
}

/* **************************** //Map page functions... ************************************** */
/* **************************** General page functions... ************************************** */
function st3_getUUID(){
	var date = new Date();
	return Date.UTC(date.getFullYear(),date.getMonth(),date.getDay(),date.getHours(),date.getMinutes(),date.getSeconds(),date.getMilliseconds());
}
function st3_Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function st3_Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
function st3_ShowHideDebugPanel(id){
	id.ancestors()[0].childElements()[2].toggle();
}
function st3_RemoveDebugPanel(id){
	id.ancestors()[0].remove();
}
function aa() {
	var str = 'debug';
	if(arguments.length) str = arguments[0];
	if(document.location.href.search(/jsdebug=/i) > -1) {
		alert(str)
	}
}
function st3_debug(str){
	var OutterE = new Element('div',{'class':'st3_Debug_Panel_Outter'}).update('<a href="javascript:void(0);" onclick="st3_ShowHideDebugPanel($(this));">Show/Hide</a> | <a href="javascript:void(0);" onclick="st3_RemoveDebugPanel($(this));">Remove</a>');
	if (str.isJSON()){
		var strJSON = str.evalJSON(true);
		var debugDiv = new Element('div').addClassName('debug');
		try{
		debugDiv.innerHTML += 'Method: ' + strJSON.REQUESTINFO.METHOD + '<hr />';
		} catch(e){
		debugDiv.innerHTML += 'Method: Undefined. | ';
		}
		try{
		debugDiv.innerHTML += 'Ajax Exec Time: ' + strJSON.AJAXEXECTIME + '<hr />';
		} catch(e){
		debugDiv.innerHTML += 'Akax Exec Time: Undefined. | ';
		}
		try{
		debugDiv.innerHTML += 'UUID: ' + strJSON.REQUESTINFO.UUID + '<hr />';
		} catch(e){
		debugDiv.innerHTML += 'UUID: Undefined. | ';
		}
		try{
		debugDiv.innerHTML += 'Error: ' + strJSON.ERROR + '<hr />';
		} catch(e){
		debugDiv.innerHTML += 'Error: Undefined. | ';
		}
		debugDiv.innerHTML += 'Data: ' + str;
		OutterE.appendChild(debugDiv);
		$('st3_Debug_Panel_Body').appendChild(OutterE);
	} else {
/* 		var content = !Prototype.Browser.IE?str:'Can Not Display Content due to IE duplicate field issue!!!'; */
		var content = 'Can Not Display Content because it messes with other content on the page.';
		var debugDiv = new Element('div').addClassName('debug');
		try{
		debugDiv.innerHTML += 'Non-JSON Return: ' + content + '<hr />';
		} catch(e){
		debugDiv.innerHTML += 'Error Occurred: ' + e + '<hr />';
		}
		OutterE.appendChild(debugDiv);
		$('st3_Debug_Panel_Body').appendChild(OutterE);
	}
}
function st3_FormAutoFocus(){
	formExists = false;
	if (document.forms.length >= 1){
		Form.focusFirstElement(document.forms[0]);
		formExists = true;
	}
	return formExists;
}
function st3_toggleAccordion(){
	$('st3_Accordion_Container').toggle();
	$('st3_Accordion_Container_Outter').toggle();
	$('st3_show_accord').toggle();
/* 	Event.observe(ShowAccord,'mouseover',function(e){ */
/* 		new Effect.Morph(ShowAccord, { */
/* 		  style: 'width:100px;background:#CCC;', */
/* 		  duration: 0.8 */
/* 		}); */
/* 	}); */
/* 	Event.observe(ShowAccord,'mouseout',function(e){ */
/* 		new Effect.Morph(ShowAccord, { */
/* 		  style: 'width:15px;background:#FFF;', */
/* 		  duration: 0.8 */
/* 		}); */
/* 	}); */

	st3_deleteCookie('ShowAccord');
	st3_createCookie('ShowAccord',$('st3_Accordion_Container').visible(),3650);
	if (!st3_getSearchCountComplete){
		try{
			st3_getSearchCount($(st3_CurrentForm).serialize());
		} catch(e){
			st3_getSearchCount('id=' + siteID);
		}
	}
}
function st3_accordion(el){
    if ($('visible') == el){
        return;
    }
    if ($('visible')){
        var eldown = el.parentNode.id+'-body';
        var elup = $('visible').parentNode.id+'-body';
        new Effect.Parallel(
        [
            new Effect.SlideUp(elup),
            new Effect.SlideDown(eldown)
        ], {
            duration: 0.5
        });
        $('visible').id = '';
    }
    el.id = 'visible';
/*     $$('.panel_body').each(function(item){ */
/*     	if(item.parentNode.id!='visible'){ */
/* 			if(item.visible() && item != eldown && item != elup){ */
/* 				return item.hide(); */
/* 			} */
/*     	} */
/*     }); */
}
function st3_formatCurrency(num,showcents){
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
	if(cents<10)
		cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
			num = num.substring(0,num.length-(4*i+3))+','+
			num.substring(num.length-(4*i+3));
	if(showcents){
		return (((sign)?'':'-') + '$' + num + '.' + cents);
	} else {
		return (((sign)?'':'-') + '$' + num);
	}
}
function st3_doSubtleMessage(msg,parentID,options){
	var msgBox = new Element('div', {'class': 'st3_absolute_top'}).update(msg);
	$(parentID).insert(msgBox);
	return setTimeout(function(){msgBox.remove()},3000);
}

function st3_initAccordion(id){
	if(!Object.isElement($('st3_Accordion_Container'))){
		return;
	}
	var eShowAccord = new Element('div',{'id':'st3_show_accord','style':'height:20px;width:20px;padding: 2px;display:none;'}).update('<a href="javascript:void(0);" onclick="st3_toggleAccordion(); return false;"><img src="'+st3_DomainRoot+'images/buttons/expand-sm-btn.jpg" border="0" alt="Show/Hide" /></a>');
	$('st3_AccordionContainerCell').appendChild(eShowAccord);
	var lclShowAccord = st3_readCookie('ShowAccord') == null || st3_readCookie('ShowAccord') == true || ShowAccord == true;
	st3_ShowAccord = lclShowAccord;
	$('st3_Accordion_Container_Outter').setStyle({'width':$('st3_Accordion_Container').getWidth() + 'px'});
	if (st3_ShowAccord){
		$('st3_Accordion_Container').setStyle({'position':'fixed'}).show();
		$('st3_Accordion_Container_Outter').show();
		$('st3_show_accord').hide();
	} else {
		$('st3_Accordion_Container').hide();
		$('st3_Accordion_Container_Outter').hide();
		$('st3_show_accord').show();
	}
    var acc = $(id);
	var apanels = acc.getElementsByTagName('div');
	$$('#st3 div.panel_body').invoke('hide');
	var avis = document.getElementById('visible').parentNode.id+'-body';
	document.getElementById(avis).style.display = 'block';
	return true;
}
function st3_sendInquiry(inqForm){
	var doAjax = new Ajax.Request(st3_AjaxRoot + '?searchaction=ajax', {
		method: 'post',
		parameters: {
			method: 'Ajax_postContactForm',
			id: siteID,
			formData: $(inqForm).serialize(),
			uuid: st3_getUUID()
		},
		onSuccess: function(transport){
			var JSONResult = transport.responseText.evalJSON();
			var eCloser = new Element('div').update(st3_showClose());
			var modal = new Control.Modal(null,{
				overlayOpacity:.01,
				className:'modal_container',
				closeOnClick:eCloser,
				afterClose: function(){
/* 					this.destroy(); */
/* 					this.container.remove(); */
				}
			});
			modal.container.insert(eCloser);
			modal.container.insert(JSONResult.MESSAGE);
			modal.open();
		}
	});
}
function st3_incSize(inc,init){
	if (inc == 0){
		inc = fontIndex * -1;
		fontIndex = 0;
	} else {
		if (init){
			fontIndex = inc;
		} else {
			fontIndex += inc;
		}
	}
	var arrElements = $$('#st3 div','#st3 td','#st3 th','#st3 strong','#st3 b','#st3 li','#st3 ul','#st3 ol','#st3 p','#st3 a','#st3 h1','#st3 h2','#st3 h3','#st3 h4','#st3 h5','#st3 h6','#st3 form','#st3 span','#st3 label','#st3 legend','#st3 fieldset','#st3 input','#st3 select','#st3 option','#st3 textarea')
	arrElements.each( function(item){
		var origFontSize = item.getStyle('font-size');
		var newFontSize = parseInt(origFontSize) + inc;
		newFontSize = newFontSize + 'px';
		item.setStyle({fontSize: newFontSize})
	})
	st3_createCookie("fontIndex",fontIndex,1000);
	if (fontIndex > 0){
		$('eFontIndex').update('( +' + fontIndex + ' )');
	} else if (fontIndex < 0){
		$('eFontIndex').update('( -' + fontIndex + ' )');
	} else {
		$('eFontIndex').update('');
		st3_deleteCookie('fontIndex');
	}
}
function st3_createCookie(cookie_name,value,days){
	if (days){
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else {
		expires = "";
	}
	document.cookie = cookie_name+"="+value+expires+"; path=/";
}
function st3_deleteCookie(cookie_name){
  var cookie_date = new Date ( );
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}
function st3_readCookie(cooke_name){
	regexpr = cooke_name+ '=(.*?)(;|$)';
	var results = document.cookie.match (regexpr);
	if ( results ){
		 return ( unescape ( results[1] ) );
	}
	else {
		return null;
	}
}
function st3_doUnload(){
	try{
		GUnload();
	}catch(e){}
	try{
		Control.Window.windows.each(function(item){
			item.destroy();
			try{
				item.container.remove();
			}catch(e3){}
		});
	}catch(e2){}
}
function st3_isDefined(variable){
	try{
		if (typeof(variable) == 'undefined'){
			return false;
		}
	}
	catch(err){
		return false;
	}
	return true;
}
function st3_toProperCase(s){
  return s.toLowerCase().replace(/-(.)| \((.)|\/(.)|^(.)|\s(.)/g, function($1){ return $1.toUpperCase(); });
}
function st3_getURLParams(str){
	return str.toQueryParams();
}
function st3_registerModals(strClass){

/* This was causing part of the clicking sound */
/* 	if(Prototype.Browser.IE) { */
/* 		return; */
/* 	} */

	$$('#st3 a.st3_Modal').each(function(item){
		var eCloser = new Element('div').update(st3_showClose());
		var heightOffset = item.hasClassName('st3_Small_Modal')?10000:100;
		var widthOffset = item.hasClassName('st3_Small_Modal')?10000:100;
		var modal = new Control.Modal(item, {
			overlayOpacity:.01,
			className:'modal_container',
			closeOnClick:eCloser,
			height: item.hasClassName('st3_Small_Modal')?375:st3_getModalWindowHeight(heightOffset),
			width: item.hasClassName('st3_Small_Modal')?500:st3_getModalWindowWidth(widthOffset),
			iframe: item.hasClassName('st3_iframe'),
			afterClose: function(){
/* 				this.destroy(); */
/* 				this.container.remove(); */
			}
		});
		modal.container.insert(eCloser);
	});
}
function st3_toggleUserToolMenu(){
	if(Object.isElement($('st3_Logged_Out_Nav'))){
/* 	$('st3_UserToolsLoading').hide(); */
		$$('.st3_Logged_Out_Nav').invoke('removeClassName','st3_Light_UserToolNav');
		$$('.st3_Logged_In_Nav').invoke('removeClassName','st3_Light_UserToolNav');
		$('st3_Logged_In_Nav').toggle();
		$('st3_Logged_Out_Nav').toggle();
	}
return;

	if(st3_loggedin){
		$('st3_Logged_In_Nav').show();
		$('st3_Logged_Out_Nav').hide();
	} else {
		$('st3_Logged_Out_Nav').show();
		$('st3_Logged_In_Nav').hide();
	}
return;
}
function st3_swapUserToolContent(SearchAction,eid,vcURL){
	var eDisplayArea = $('st3_UserToolContentArea_Inner');
	if (arguments.length==3) {
		var doAjax = new Ajax.Request(st3_AjaxRoot + '?' + vcURL + '&ajax=true&contentOnly=true', {
			onSuccess: function(transport){
				var strContent = transport.responseText;
				strContent = strContent.replace(/\/CFIDE\/scripts\//gi,Domain+'CFIDE/scripts/');
				eDisplayArea.update(strContent);
				return;
			}
		});	
	} else {
		var doAjax = new Ajax.Request(st3_AjaxRoot + '?SearchAction=' + SearchAction + '&ajax=true&contentOnly=true', {
			onSuccess: function(transport){
				var strContent = transport.responseText;
				strContent = strContent.replace(/\/CFIDE\/scripts\//gi,Domain+'CFIDE/scripts/');
				eDisplayArea.update(transport.responseText);
				return;
			}
		});
		//st3_initToolsDropDown(true);
		$$('a.st3_Light_UserToolNav').invoke('addClassName','st3_Dark_UserToolNav').invoke('removeClassName','st3_Light_UserToolNav');
		$(eid).addClassName('st3_Light_UserToolNav');		
	}
return;
}
function st3_prependChild(parent, node){
	if (parent.firstChild){
		parent.insertBefore(node, parent.firstChild);
	} else {
		parent.appendChild(node);
	}
}
function st3_initFontSize(){
	if (st3_readCookie('fontIndex')){
		fontIndex = parseInt(st3_readCookie('fontIndex'));
		st3_incSize(fontIndex,true);
	} else {
		fontIndex = 0;
	}
}
function st3_initPageSpecs(){
	if (st3_searchaction == 'quicksearch' || st3_searchaction == 'mapsearch' || st3_searchaction == 'subdiv' || st3_searchaction == 'school' || 
			st3_searchaction == 'detailed' || st3_searchaction == 'lake' || st3_searchaction == 'area' || st3_searchaction == 'addresszip'){
		st3_initSearch();
	} else if (st3_searchaction == 'results'){
		st3_initResults();
	} else if (st3_searchaction == 'details'){
		st3_initDetails();
	}
	st3_loadToolTips();
	st3_registerToolTips();
}
function st3_debugAjax(transport){
    if (transport.responseText.length > 160000){
        try{
            st3_debug(transport.responseText);
            throw('Ajax response is too long. Length is ' + transport.responseText.length + 'chars.');
        } catch(e){
/*             alert(e); */
        }
    }
	    st3_debug(transport.responseText);
}
function st3_ShowHideDebug(){
    $('st3_Debug_Panel_Body').toggle();
}
function st3_registerAjaxResponders(){
	Ajax.Responders.register({
		onCreate: function(request){
			if (st3_isDefined(request.options.showloading)) {
				return st3_showLoading(request.options.showloading);
			}
			return st3_showLoading(true);
		},
		onComplete: function(transport){
			$('countLoading').hide();
			st3_showLoading(false);
			if (st3_bShowJSDebug) {
				return st3_debugAjax(transport.transport);
			}
		},
		onFailure: function(transport){
			$('countLoading').hide();
			st3_showLoading(false);
			Control.Window.close();
		}
	});
}
function st3_isEmail(str){
	return str.match(/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i) ? true : false;
}
function st3_showLoading(show){
if(Prototype.Browser.IE){
	return;
}
	if(show) {return eLoadingIndicator.open();}
	return eLoadingIndicator.close();
}
/* function sfHover(id){ */
/* 	var sfEls = $$('li'); */
/* 	sfEls.each(function(item){ */
/* 		item.onmouseover=function() { */
/* 			item.addClassName('sfhover'); */
/* 		} */
/* 		item.onmouseout=function() { */
/* 			$$('li').invoke('removeClassName','sfhover'); */
/* 		}	 */
/* 	}); */
/* } */
/* **************************** //General page functions... ************************************** */
/* **************************** onLoad function... ************************************** */

function st3_preLoadImages(){
	var arrMapIcons = new Array();
	var arrImages = ['buttons/tools-lrg-btn_o.jpg','buttons/Inquire-lrg-btn_o.jpg','buttons/Save-lrg-btn_o.jpg','buttons/details-lrg-btn_o.jpg','buttons/hide-lrg-btn_o.jpg','buttons/details-sm-btn_o.jpg','buttons/hide-sm-btn_o.jpg','buttons/tools-sm-btn_o.jpg','buttons/Expand-sm-btn_o.jpg','buttons/close-sm-btn_o.jpg'];
	$R(1,11,true).each(function(i){
		arrMapIcons.push('mapIcons/'+i+'.png');
	});
	arrImages = arrImages.concat(arrMapIcons);
	arrImages.each(function(item){
		var myImg = new Element('img',{src:st3_ImageRoot+item});
	});
}
function initAll(){
/* 	sfHover(); */
/* Set Global Vars Here */

	if(!Object.isElement($('st3'))){
		return false;
	}

	st3_SearchRoot = SearchRoot;
	arrDropListings = new Array();
	st3_MapControlsCreated = false;
	st3_vcTypeList = new Array();
	st3_bTrafficInitialized = false;
	st3_bTrafficOn = 'Off';
	st3_bResultsPane = 'Off';
	st3_CurrentForm = '';
	st3_getMapListingsRPP = 20;
	st3_bShowJSDebug = st3_bShowDebug;
	var st3_loadGoogle = new Element('script',{'src':'http://www.google.com/jsapi?key=' + strGoogleAPIKey,'type':'text/javascript'});
	$('st3').insert(st3_loadGoogle);
	this.st3_applicationRoot = '';
	this.Domain = strDomain;
	this.st3_DomainRoot = st3_Init_DomainRoot;
	this.st3_ImageRoot = st3_DomainRoot + 'images/';
	this.st3_AjaxRoot = Domain + siteID + '/index.cfm/search/';
	this.st3_userid = siteID;
	this.st3_init_Query_String = '';
	st3ArrCompListings = arrCompListings.uniq();
	st3_isModalMaximized = false;
	var st3_eLoading = new Element('div',{'id':'st3_eLoading','onclick':'$(this).hide();','style':'color:#CCC;width:150px;padding:10px;border:1px solid #CCC;position:fixed;z-index:99999;background:url(' + st3_DomainRoot + '/images/tblContent_bg.jpg) #FFF repeat-x bottom;'}).update('<img src="' + st3_DomainRoot + 'images/st3loading.gif" alt="loading" border="0" /> Loading...');

if(!Prototype.Browser.IE){
	eLoadingIndicator = new Control.Window(null,{
		position: 'center',
		closeOnClick: true
	});
	eLoadingIndicator.container.insert(st3_eLoading);
}

	st3_strHREF = window.location.href.toLowerCase().unescapeHTML();
	st3_doTools = '';
	st3_loggedin = loggedin;
	st3_MapLoaded = false;
	st3_gScriptLoaded = false;
	st3_getSearchCountComplete = false;
	
	st3_arrURL = st3_getURLParams(window.location.href.toLowerCase());

	try{
		if(st3_isDefined(st3_arrURL.searchaction)){
			st3_searchaction = st3_arrURL.searchaction;
		} else if(typeof(stURL.searchaction) != 'undefined'){
			st3_searchaction = stURL.searchaction;
		}
	}catch(e){
		st3_searchaction = 'quicksearch';
	}
	st3_initAccordion('accordion');
	if(PinTools){
		st3_doToolAction('Pin Tools');
	}
	st3_initPageSpecs();
	st3_registerAjaxResponders();
	st3_bAcceptingCookies = st3_readCookie('CFID') == null?false:true;
	if (!st3_bAcceptingCookies){
		modal = new Control.Modal.open(st3_showClose() + 'Your browser is NOT accepting cookies. This site requires cookies to function properly. Please change your settings. If you need assistance, please click <a href="http://www.google.com/cookies.html" style="color:#FF0000;text-decoration:underline;">here</a> for a guide to enabling cookies on all major browsers. <br /><br />', {
			overlayOpacity:.01,
			className:'modal_container',
			closeOnClick:'container',
			height: 0,
			width: 400,
			afterClose: function(){
				this.destroy();
				this.container.remove();
			}
		});
	}
	var theForms = $$('#st3 form');
	theForms.each(function(item){
		var theInputs = item.getInputs('checkbox');
		theInputs.each(function(item2){
			item2.setStyle({'border':'0px none'});
		});
	});
	if(!Object.isElement($('modal_container'))){
		var z = new Element('div',{'id':'modal_container','style':'height:1px;width:1px;'}).hide();
		$('st3').appendChild(z);
	}
	if(arrCompListings.length>0 && Object.isElement($('st3_Comp_Listings_Display'))){
		arrCompListings.each(function(listing,index){
			st3_addComp(listing,true);
		});
	}
	if(Object.isElement($$('.st3_compare_tab')[0])){
		if(st3ArrCompListings.length>1){
			Effect.Pulsate($$('.st3_compare_tab')[0], { pulses: 5, duration: 5, from: .7 });
		}
	}
	st3_preLoadImages();
	st3_createMainMenu();
	if(bValidationRequired) {
		st3_displayLoginForm('login','Please Register!',false);
	}

	if(document.location.href.search(/showProfile=tru/i) > -1) {
		return st3_dspModal('savedSearches');
	}

/* 	if(!Prototype.Browser.IE){ */
		try {
			st3_registerModals();
		} catch(e) {}
/* 	} */

}
window.onload=initAll;
window.onunload=st3_doUnload;
window.onresize=st3_onResize;
/* **************************** //onLoad function... ************************************** */