//GENERAL FUNCTIONS
function setSideBar(){
	var footerElem = $('ContentFooter');
	var sidebarElem = $('sidebarImageBox');
	if(footerElem != null && sidebarElem != null){
		var footerPosition = footerElem.viewportOffset();
		var sidebarPosition = sidebarElem.viewportOffset();
		if(sidebarPosition.top < footerPosition.top){
			sidebarElem.setStyle({height: ( (footerPosition.top - sidebarPosition.top) + footerElem.getHeight() ) + 'px'});	
			footerElem.setStyle({marginTop: '7px'});
		}else{
			var newheight = (sidebarPosition.top - footerPosition.top) - footerElem.getHeight() + 20;
			if(newheight < 7){
				newheight = 7;
			}
			footerElem.setStyle({marginTop: newheight + 'px'});	
		}
	}
}
//CLASS DEFINITIONS
var sidebarInteraction = Class.create({
	initialize: function(element,trigger) {
		this.element = element;
		this.accordionRelation = null;
		this.accordionElements = $$('.'+trigger);
		if(this.element.attributes['rel'])
			this.accordionRelation = this.element.attributes['rel'].nodeValue;
		this.initEventHandlers();
	}	,
	initEventHandlers: function() {
		this.element.observe('click',this.handleClick.bind(this));			
	},
	handleClick: function() {
		if(this.accordionRelation != null){
			var ele = this.accordionRelation.split('_');
			if(ele[0] == 'level1'){
				if(this.accordionElements[ele[1]].next().visible()){
					this.accordionElements[ele[1]].down().src='/images/btn_expand.gif';
				}else{
					this.accordionElements[ele[1]].down().src='/images/btn_collapse.gif';
				}
				Effect.toggle(this.accordionElements[ele[1]].next(),'blind',{duration:.5, transition: Effect.Transitions.sinoidal});
				if(!this.accordionElements[ele[1]].next().visible()){
					this.element.addClassName('current');
				}else{
					this.element.removeClassName('current');
				}
			}else{
				var childselector = this.accordionElements[ele[1]].next().down(1).next('.accordionContentBlock',ele[2]);
				if(!this.accordionElements[ele[1]].next().visible()){
					Effect.toggle(this.accordionElements[ele[1]].next(),'blind',{duration:.5, transition: Effect.Transitions.sinoidal, afterFinish: function(){Effect.toggle(childselector,'blind',{duration:.5, transition: Effect.Transitions.sinoidal});}});
					if(this.accordionElements[ele[1]].next().visible()){
						this.accordionElements[ele[1]].down().src='/images/btn_expand.gif';
					}else{
						this.accordionElements[ele[1]].down().src='/images/btn_collapse.gif';
					}
				}else{
					Effect.toggle(childselector,'blind',{duration:.5, transition: Effect.Transitions.sinoidal});
				}
				if(!childselector.visible()){
					childselector.previous().down().src = '/images/btn_collapse_sub.gif';
					this.element.addClassName('current');
				}else{
					childselector.previous().down().src = '/images/btn_expand_sub.gif';
					this.element.removeClassName('current');
				}
			}
		}
	}		
});
var uberAccordion = Class.create({
	initialize: function(element,trigger) {
		this.element = element;
		this.accordionH2 = this.element.select('.'+trigger);
		this.accordionContainers = this.element.select('.accordionContentBlock');
		this.handleTriggers();
		this.initialHide();
	},
	handleTriggers: function() {
		this.accordionH2.each(function(elem){ new accordionEffectMgr(elem); });
	},
	initialHide: function() {
		this.accordionContainers.each(function(elem){elem.hide();});
	}
});
var accordionEffectMgr = Class.create({
	initialize: function(element) {
		this.element = element;
		this.sidebarTrigger = null;
		if(this.element.attributes['rel'])
			this.sidebarTrigger = $(this.element.attributes['rel'].nodeValue);
		this.initEventHandlers();	
	},
	initEventHandlers: function() {
		this.element.observe('click',this.handleEffect.bind(this));
	},	
	handleEffect: function() {
		if(!this.element.next().visible()){
			if(this.sidebarTrigger != null)
				this.sidebarTrigger.addClassName('current');
			if(this.element.down().hasClassName('childExpandButton'))
				this.element.down().src='/images/btn_collapse_sub.gif';
			else
				this.element.down().src='/images/btn_collapse.gif';
		}else{
			if(this.sidebarTrigger != null)
				this.sidebarTrigger.removeClassName('current');
			if(this.element.down().hasClassName('childExpandButton'))
				this.element.down().src='/images/btn_expand_sub.gif';
			else
				this.element.down().src='/images/btn_expand.gif';
		}
		Effect.toggle(this.element.next(),'blind',{duration:.5, transition: Effect.Transitions.sinoidal});
	}		
});
var selectBoxCounter = Class.create({
	initialize: function(element) {
		this.element = element ;
		this.SourceList = this.element.select('.Src')[0];
		this.AddButton = this.element.select('.Add')[0];
		this.RemoveButton = this.element.select('.Remove')[0];
		this.DistributionList = this.element.select('.Dst')[0];
		this.countElement = null;
		if(this.DistributionList.attributes['rel']){
			this.countElement = $(this.DistributionList.attributes['rel'].nodeValue);
		}
		this.initEventHandlers();
	},
	initEventHandlers: function() {
		this.AddButton.observe('click',function(e){
			var counter = 0;
			for(var i = 0; i < this.SourceList.options.length; i++){
				if(this.SourceList.options[i].selected == true)
					counter++;
			}
			this.handleChange(e, counter);
		}.bind(this));
		this.RemoveButton.observe('click',function(e){
			var counter = 0;
			for(var i = 0; i < this.DistributionList.options.length; i++){
				if(this.DistributionList.options[i].selected == true)
					counter++;
			}
			this.handleChange(e,(-1 * counter));
		}.bind(this));
		
		this.SourceList.observe('dblclick',function(e){
			this.handleChange(e,1);
		}.bind(this));
		
		this.DistributionList.observe('dblclick',function(e){
			this.handleChange(e,-1);
		}.bind(this));
	},
	handleChange: function(e, diff) {
		var count = this.DistributionList.options.length + diff;
		if(this.countElement != null){
			if(count > 0)
				this.countElement.innerHTML =  '['+count+'&nbsp;items]';
			else
				this.countElement.innerHTML = '';
		}
	}
});
var showSearchElements = Class.create({
	initialize: function(element) {
		this.element = element;
		this.nodes = this.element.attributes['rel'].nodeValue.split(',');
		this.containerID = $(this.nodes[0]);
		this.checkboxes = $$('input.refineTriggerClass');
		this.checkBoxElement = $(this.nodes[1]);
		this.initEventHandlers();
	},
	initEventHandlers: function() {
		this.element.observe('click',this.handleClickEvent.bind(this));
		this.element.observe('change',this.handleClickEvent.bind(this));
	},
	transitionEffect: function() {
		Effect.toggle(this.containerID, 'blind', {afterFinish: function(){
				this.handlePostEffect();
			}.bind(this)
		});	
	},
	closeEffect: function() {
		var test = this.containerID;
		var boxes = this.checkboxes;
		$$('.searchOptionBlock').each(function(elem){
			if (elem.identify() != test && elem.visible()) {
				Effect.toggle(elem, 'blind',{afterFinish: function(){
					boxes.each(function(elem){elem.enable();});	
				}});
			}
		});			
	},
	handlePostEffect: function() {
		if(this.containerID.visible()){
			Effect.ScrollTo(this.containerID);
			this.checkboxes.each(function(elem){
				elem.enable();
			});		
		}
		setSideBar();
	},		
	handleClickEvent: function(e) {
		this.checkboxes.each(function(elem){elem.disable()});
		this.closeEffect();
		this.transitionEffect();
		if(this.containerID.visible() && this.checkBoxElement != null){
			this.checkBoxElement.checked = false;
		}
	}
});
var searchSwapClass = Class.create({
	initialize: function(element) {
		this.element = element;
		this.nodes = this.element.attributes['rel'].nodeValue.split(',');
		this.containerClass = this.nodes[1];
		this.selectionListID = $(this.nodes[0]);
		this.elementLabelClass = this.nodes[2];
		this.elementLabelID = $(this.nodes[3]);
		this.initEventHandlers();
	},
	initEventHandlers: function() {
		this.element.observe('click',this.handleChange.bind(this));
	},
	handleChange: function(e) {
		$$('label.' + this.elementLabelClass).each(function(elem){elem.removeClassName('bold');});
		this.elementLabelID.addClassName('bold');
		$$('div.' + this.containerClass).each(function(elem){elem.hide();});
		this.selectionListID.show();
	}
});
var viewSwap = Class.create({
	initialize: function(element) {
		this.element = element;
		this.containerID = $(this.element.attributes['rel'].nodeValue);
		this.initEventHandlers();
		this.addStyles();
	},
	initEventHandlers: function() {
		this.element.observe('click',this.handleClick.bind(this));
		
	},
	addStyles: function() {
		$$('img.viewTrigger').each(function(elem){
			elem.setStyle({
				cursor:'pointer'
			})
		});
	},
	handleClick: function(e) {
		var currentVisibleIcon = $$('img.selected')[0];
		var currentVisibleView = $(currentVisibleIcon.attributes['rel'].nodeValue);
		if(currentVisibleIcon != this.element){
			this.fixPagingLinks(this.element.attributes['rel'].nodeValue);
			currentVisibleIcon.removeClassName('selected');
			this.element.addClassName('selected');
			currentVisibleView.fade({ duration: .5, afterFinish: function(){setSideBar();}});
			this.containerID.appear({ duration: 1, afterFinish: function(){setSideBar();}});
		}
	},
	fixPagingLinks: function(viewname) {
		$$('a.resultsLink').each(function(elem){
			if(elem.href.match(/useView=\w+/) != null){
				elem.href = elem.href.replace(/useView=\w+/, 'useView=' + viewname);
			}else{
				elem.href = elem.href + '?useView=' + viewname;	
			}
		});
	}	
});
var propertyDetailsSwap = Class.create({
	initialize: function(element) {
		this.element = element;
		this.containerReference = null
		this.containerReferenceClass = $$('.detailsHideable');
		if(this.element.attributes['rel'])
			this.containerReference = $(this.element.attributes['rel'].nodeValue);
		this.hideElements();
		this.containerReferenceClass[0].show();
		this.initEventHandlers();
	},
	hideElements: function() {
		this.containerReferenceClass.each(function(elem){elem.hide();});
	},
	initEventHandlers: function() {
		this.element.observe('click',this.handleClick.bind(this));
	},
	handleClick: function(e) {
		$$('.sectionTrigger').each(function(elem){elem.removeClassName('activeTrigger');});
		this.element.addClassName('activeTrigger');
		this.hideElements();
		this.containerReference.show();
		new Effect.ScrollTo(this.containerReference);
	}
});
var checkboxManager = Class.create({
	initialize: function(element) {
		this.element = element;
		this.boxes = this.element.select('input');
		this.allbox = this.element.select('.checkbox_all')[0];
		this.initEventHandlers();
	},
	initEventHandlers: function() {
		this.boxes.each(function(elem){elem.observe('click',this.handleClick.bind(this))}.bind(this));
	},
	handleClick: function(e) {
		var ele = Event.element(e);
		if(ele.hasClassName('checkbox_all')) {
			this.boxes.each(function(elem){elem.checked = false});
			this.allbox.checked = true;
		}else{
			this.allbox.checked = false;
		}
	}
});
var headerNotifications = Class.create({
	initialize: function(element) {
		this.element = element;
		this.containerID = $(this.element.attributes['rel'].nodeValue);	
		try {
			this.closeBtn = this.containerID.select('.popupClose')[0];
		} catch(e){
			this.closeBtn = null;
		}
		try {
			this.preventPopup = this.containerID.select('[name="hide_popups"]')[0];
		} catch(e){
			this.preventPopup = null;
		}
		if(this.element.attributes['flag'] != undefined && this.element.attributes['flag'].nodeValue == 'map') {	
			this.mapFlag = true;
		} else {
			this.mapFlag = false;
		}
		this.initEventHandlers();
	},
	initEventHandlers: function() {
		this.element.observe('click',this.handleClick.bind(this));
		if(this.closeBtn != null) {
			this.closeBtn.observe('click', this.handleClose.bind(this));
		}
		if(this.preventPopup != null) {
			this.preventPopup.observe('change', this.handlePopupHider.bind(this));
		}
	},
	handlePopupHider: function(e) {
		if(this.preventPopup.checked == true){
			Cookie.setData('preventPopup', true);
		}else{
			Cookie.removeData('preventPopup');
		}
	},
	handleClick: function(e) {
		if(this.preventPopup == null || Cookie.getData('preventPopup') != true || Cookie.getData('preventPopup') == undefined) {
			Event.stop(e);
			if(this.mapFlag){
				$$('div.noMap').each( function(el){ el.hide(); } );
				$$('div.yesMap').each( function(el){ el.show(); } );	
			}else{
				$$('div.noMap').each( function(el){ el.show(); } );
				$$('div.yesMap').each( function(el){ el.hide(); } );	
			}
			var sizes = document.viewport.getDimensions();
			var popupDimensions = this.containerID.getDimensions();
			var offsets = document.viewport.getScrollOffsets();
			this.containerID.setStyle({
				left: ((sizes.width - popupDimensions.width) / 2) + 'px',
				top: (((sizes.height - popupDimensions.height) / 2)) + offsets.top + 'px'
			});
			this.containerID.show();
		}
	},
	handleClose: function(e) {
		this.containerID.hide();
	}
});
var priceManager = Class.create({
	initialize: function(element) {
		this.element = element;
		this.initEventHandlers();
	},
	initEventHandlers: function() {
		this.element.observe('change',this.handleChange.bind(this));
	},
	handleChange: function(e){
		if(this.element[this.element.selectedIndex].text.indexOf('+') >= 0){
			this.element.name = 'Min_Price'; 
		} else if(this.element.value == 'yes' || this.element.value == 'no/Min_Price/999999999') {
			 this.element.name = 'IsForBid'
	     } else {
			this.element.name = 'Max_Price';
		}
	}
});
var rentalPriceManager = Class.create({
	initialize: function(element) {
		this.element = element;
		this.initEventHandlers();
	},
	initEventHandlers: function() {
		this.element.observe('change',this.handleChange.bind(this));
	},
	handleChange: function(e){
		if(this.element[this.element.selectedIndex].text.indexOf('+') >= 0){
			this.element.name = 'Rental_Min_Price'; 
		} else {
			this.element.name = 'Rental_Max_Price';
		}
	}
});
var acreManager = Class.create({
	initialize: function(element) {
		this.element = element;
		this.initEventHandlers();
	},
	initEventHandlers: function() {
		this.element.observe('change',this.handleChange.bind(this));
	},
	handleChange: function(e){
		if(this.element[this.element.selectedIndex].text.indexOf('+') >= 0){
			this.element.name = 'Acres';
		}
		else if(this.element[this.element.selectedIndex].text.indexOf('to') >= 0){
			this.element.name = 'Acres';	
		}
		else{
			this.element.name = 'AcresMax';
		}
	}
});
var popup_item = Class.create({
	initialize: function() {
		this.list = [];
		this.site = 'Landvest.com';
		this.footer = 'To return to landvest.com, click on <strong>Luxury Real Estate</strong> at the top of the page, or click on the <strong>LandVest logo</strong>.';
	},
	setSite: function(site,footer){
		this.site = (site != undefined && site.length > 0) ? site : this.site;
		this.footer = (footer != undefined && footer.length > 0) ? footer : this.footer;
	},
	render: function(items){
		var template = null;
		this.list = items;
		this.list.each(function(pop){
			switch(pop){
				case 'TimberlandPopup':
					template = '<div id="TimberlandPopup" class="SitePopupStyle" style="display:none;">'
						+	'<div class="closeBtn">'
						+		'<img src="/images/btn_close.gif" alt="close button" style="cursor:pointer;" title="Close Window" class="popupClose floatRight" />'
						+	'</div>'
						+	'<div class="SitePopupInnerWrapper">'
						+		'<div class="SitePopupInnerShell">'
						+			'<div class="LogoWrapper">'
						+				'<img border="0" alt="landVest" src="/images/home_landvest_logo.gif" />'
						+			'</div>'
						+			'<div class="clearAll">&nbsp;</div>'
						+			'<p class="topPopupText">You are leaving ' + this.site + ' and heading to the </p>'
						+			'<div class="goBtnWrapper">'
						+				'<p style="text-align:center;">'
						+					'<strong>LandVest Timberland<br />Division site</strong>'
						+					'<div class="clearAll">&nbsp;</div>'
						+					'<a href="http://timberland.landvest.com" title="Timberland Division">'
						+						'<img src="/images/goBtn.gif" alt="Timberland Division" border="0" />'
						+					'</a>'
						+					'<span class="no_more_popup"><input type="checkbox" name="hide_popups" value="1" /> Don\'t show this again.</span>'
						+				'</p>'
						+			'</div>'
						+			'<p class="bottomText">' + this.footer + '</p>'
						+		'</div>'
						+	'</div>'
						+'</div>';
					break;
				case 'ConsultingPopup':
					template = '<div id="ConsultingPopup" class="SitePopupStyle" style="display:none;">'
						+	'<div class="closeBtn">'
						+		'<img src="/images/btn_close.gif" alt="close button" style="cursor:pointer;" title="Close Window" class="popupClose floatRight" />'
						+	'</div>'
						+	'<div class="SitePopupInnerWrapper">'
						+		'<div class="SitePopupInnerShell">'
						+			'<div class="LogoWrapper">'
						+				'<img border="0" alt="landVest" src="/images/home_landvest_logo.gif" />'
						+			'</div>'
						+			'<div class="clearAll">&nbsp;</div>'
						+			'<p class="topPopupText">You are leaving ' + this.site + ' and heading to the </p>'
						+			'<div class="goBtnWrapper">'
						+				'<p style="text-align:center;">'
						+					'<strong>LandVest Consulting <br />Group site</strong>'
						+					'<div class="clearAll">&nbsp;</div>'
						+					'<a href="http://consulting.landvest.com" title="Consulting Group">'
						+						'<img src="/images/goBtn.gif" alt="Consulting Group" border="0" />'
						+					'</a>'
						+					'<span class="no_more_popup"><input type="checkbox" name="hide_popups" value="1" /> Don\'t show this again.</span>'
						+				'</p>'
						+			'</div>'
						+			'<p class="bottomText">' + this.footer + '</p>'
						+		'</div>'
						+	'</div>'
						+'</div>';
					break;
				case 'MarthasPopup':
					template = '<div id="MarthasPopup" class="SitePopupStyle" style="display:none;">'
						+	'<div class="closeBtn">'
						+		'<img src="/images/btn_close.gif" alt="close button" style="cursor:pointer;" title="Close Window" class="popupClose floatRight" />'
						+	'</div>'
						+	'<div class="SitePopupInnerWrapper">'
						+		'<div class="SitePopupInnerShell">'
						+			'<div class="LogoWrapper">'
						+				'<img border="0" alt="landVest" src="/images/home_landvest_logo.gif" />'
						+			'</div>'
						+			'<div class="clearAll">&nbsp;</div>'
						+			'<p class="topPopupText">You are leaving ' + this.site + ' and heading to the</p>'
						+			'<div class="goBtnWrapper">'
						+				'<p style="text-align:center;">'
						+					'<strong>LandVest Martha\'s <br />Vineyard site</strong>'
						+					'<div class="clearAll">&nbsp;</div>'
						+					'<a href="http://marthasvineyard.landvest.com" title="Martha\'s Vineyard Office">'
						+						'<img src="/images/goBtn.gif" alt="Martha\'s Vineyard Office" border="0" />'
						+					'</a>'
						+					'<span class="no_more_popup"><input type="checkbox" name="hide_popups" value="1" /> Don\'t show this again.</span>'
						+				'</p>'
						+			'</div>'
						+			'<p class="bottomText">' + this.footer + '</p>'
						+		'</div>'
						+	'</div>'
						+'</div>';
					break;
				case 'LuxuryPopup':
					template = '<div id="LuxuryPopup" class="SitePopupStyle" style="display:none;">'
						+	'<div class="closeBtn">'
						+		'<img src="/images/btn_close.gif" alt="close button" style="cursor:pointer;" title="Close Window" class="popupClose floatRight" />'
						+	'</div>'
						+	'<div class="SitePopupInnerWrapper">'
						+		'<div class="SitePopupInnerShell">'
						+			'<div class="LogoWrapper">'
						+				'<img border="0" alt="landVest" src="/images/home_landvest_logo.gif" />'
						+			'</div>'
						+			'<div class="clearAll">&nbsp;</div>'
						+			'<p class="topPopupText">You are leaving ' + this.site + ' and heading to </p>'
						+			'<div class="goBtnWrapper">'
						+				'<p style="text-align:center;">'
						+					'<strong>Landvest.com</strong>'
						+					'<div class="clearAll">&nbsp;</div>'
						+					'<a href="http://www.landvest.com" title="Landvest.com">'
						+						'<img src="/images/goBtn.gif" alt="Landvest.com" border="0" />'
						+					'</a>'
						+					'<span class="no_more_popup"><input type="checkbox" name="hide_popups" value="1" /> Don\'t show this again.</span>'
						+				'</p>'
						+			'</div>'
						+			'<p class="bottomText">' + this.footer + '</p>'
						+		'</div>'
						+	'</div>'
						+'</div>';					
					break;
			}
			var tempdiv = document.createElement('div');
			var bodyElement = document.getElementsByTagName('body')[0];
			tempdiv.innerHTML = template;
			bodyElement.appendChild(tempdiv);
		}.bind(this));
	}
});

var Cookie = {
  data: {},
  options: {expires: 1, domain: "", path: "", secure: false},

init: function(options, data) {
  Cookie.options = Object.extend(Cookie.options, options || {});

  var payload = Cookie.retrieve();
        if(payload) {
            Cookie.data = payload.evalJSON();
        }
        else {
            Cookie.data = data || {};
        }
        Cookie.store();
    },
    getData: function(key) {
        return Cookie.data[key];
    },
    setData: function(key, value) {
        Cookie.data[key] = value;
        Cookie.store();
    },
    removeData: function(key) {
        delete Cookie.data[key];
        Cookie.store();
    },
    retrieve: function() {
        var start = document.cookie.indexOf(Cookie.options.name + "=");

        if(start == -1) {
            return null;
        }
        if(Cookie.options.name != document.cookie.substr(start, Cookie.options.name.length)) {
            return null;
        }

        var len = start + Cookie.options.name.length + 1;   
        var end = document.cookie.indexOf(';', len);

        if(end == -1) {
            end = document.cookie.length;
        } 
        return unescape(document.cookie.substring(len, end));
    },
    store: function() {
        var expires = '';

        if (Cookie.options.expires) {
            var today = new Date();
            expires = Cookie.options.expires * 86400000;
            expires = ';expires=' + new Date(today.getTime() + expires);
        }

        document.cookie = Cookie.options.name + '=' + escape(Object.toJSON(Cookie.data)) + Cookie.getOptions() + expires;
    },
    erase: function() {
        document.cookie = Cookie.options.name + '=' + Cookie.getOptions() + ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
    },
    getOptions: function() {
        return (Cookie.options.path ? ';path=' + Cookie.options.path : '') + (Cookie.options.domain ? ';domain=' + Cookie.options.domain : '') + (Cookie.options.secure ? ';secure' : '');      
    }
};
// DOM READY TRIGGER
Event.observe(window, 'load', function() {
	Cookie.init({name: 'LandvestJSCookies', expires: 30}); //build a cookie jar for landvest!
	$$('.popupInfoTarget').each(function(elem){new headerNotifications(elem);}); // header links app
	$$('.checkbox_manager').each(function(elem){new checkboxManager(elem);}); //checkboxes on advanced search
	$$('img.viewTrigger').each(function(elem){new viewSwap(elem);}); //results page view swap
	$$('input.swapTriggerElement').each(function(elem){new searchSwapClass(elem);}); //search page
	$$('.refineTriggerClass').each(function(elem){new showSearchElements(elem);}); //search page
	$$('.SelectBoxPair').each(function(elem){new selectBoxCounter(elem);}); //search page
	$$('.accordionChild').each(function(elem){ new uberAccordion(elem,'childTitleBlock'); }); //content accordion
	//$$('.accordion').each(function(elem){ new uberAccordion(elem,'titleBlock'); }); //content accordion
	//$$('.InfoTarget').each(function(elem){ new sidebarInteraction(elem,'titleBlock'); }); //content accordion
	$$('.sectionTrigger').each(function(elem){ new propertyDetailsSwap(elem); }); //property details swapsections
	$$('select.rentalmaxpricefield').each(function(elem){ new rentalPriceManager(elem); }); //search narrowers hack for rentals max price select box.
	$$('select.maxpricefield').each(function(elem){ new priceManager(elem); }); //search narrowers hack for max price select box.
	$$('select.acresmaxfield').each(function(elem){ new acreManager(elem); }); //search narrowers hack for acres select box.	 
	setSideBar(); //function call to position the sidebar image
});