// var banners = new Array();banners[0] = '<a href="http://www.idxcentral.com/syaor/idxsearch.cfm?idxid=krealty&pg=hnlmapmns" target="_top"><img src="http://www.kingrealty-norcal.com/images/global/banner/email_listing.gif" alt="" height="60" width="468" border="0"></a>';banners[1] = '<a href="http://www.idxcentral.com/ncbor/idxsearch.cfm?idxid=krealty&pg=featured&lo=king%20realty" target="_top"><img id="banner_ad" src="http://www.kingrealty-norcal.com/images/global/banner/banner_featuredlistings.gif" alt="" name="banner_ad" height="60" width="468" border="0"></a>';// Image swapping by element id and string parse.// The "_o" is for on, add or remove this for on|off states of a graphic.// This assumes that both images are in the same directory. You can force a state with the state flag.function setImageByParse(id, state) {	if (document.images) {		var ext = document.getElementById(id).src.substring(document.getElementById(id).src.lastIndexOf('.'));		var path = document.getElementById(id).src.substring(0, document.getElementById(id).src.lastIndexOf('.'))		var end = path.lastIndexOf('/');		var file = path.substring(end + 1);		path = path.slice(0, end + 1);		// now do the test		if (file.length > 2) {			if (file.substring(file.length -2) == "_o") { // it's on turn off			if (state == "on") { return true; } // it's  already on just return				document.getElementById(id).src = path + (file.slice(0, file.length -2)) + ext;			} else {				if (state == "off") { return true; } // it's allready off just return				document.getElementById(id).src = path+file+"_o"+ext;			}		}	}}// Return the id of the first child html element.function returnFirstChild(argObj) {var obj = getRawObject(argObj); for (var i = 0; i < obj.childNodes.length; i++) { 	if (obj.childNodes[i].nodeType == 1) {			return obj.childNodes[i].id;	 }	} }// Convert object name string or object reference into a valid element object reference.function getRawObject(obj) {var theObj;	if (typeof obj == "string") {		theObj = document.getElementById(obj);	} else {	// pass on object reference	theObj = obj;	}return theObj;	}// preload all the images required based on the image idsfunction autoload() {var elems = document.getElementsByTagName("img");for (var i = 0; i < elems.length; i++) {					if (elems[i].id.indexOf("pre_") != -1) { // preload required				var path = elems[i].src.substring(0, (elems[i].src.lastIndexOf('/')+1)); // get the path				var ext = elems[i].src.substring(elems[i].src.lastIndexOf('.')) // get the file ext				var image = elems[i].src.substring((elems[i].src.lastIndexOf('/')+1)) // get the imagename				var image = image.slice(0, image.lastIndexOf('.'));				preloadImages(path + image + "_o" + ext);			 }		}	}// preload rollover imagesfunction preloadImages(img) {  if(document.images){   	var imageObj = new Image;  	imageObj.src=img;	}}// open a new window and center itvar myWindow; // global window objectfunction openCenteredWindow(url) {	var width = screen.availWidth - 200; 	var height = screen.availHeight - 200;	var left = parseInt((screen.availWidth/2)-(width/2));	var top = parseInt((screen.availHeight/2)-(height/2));	var windowFeatures = "width=" + width + ",height=" + height + ",status,scrollbars,resizable,left=" + left + ",top=" + top + ",screenX=" + left + ",screenY=" + top;	myWindow = window.open(url, "subWind", windowFeatures);	myWindow.focus();}// display a random banner adfunction getBanner() {var currIndex = Math.floor(Math.random() * (banners.length));return banners[currIndex];}