function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;	
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function init() {
	function resetListings() {
		document.getElementById('popular').className = "closed listings";
		document.getElementById('popularlink').className = "";
		document.getElementById('new').className = "closed listings";
		document.getElementById('newlink').className = "";
		document.getElementById('rentals').className = "closed listings";
		document.getElementById('rentalslink').className = "";
	}
		document.getElementById('popularlink').onclick = function() { 
		resetListings();
		document.getElementById('popular').className = "open listings";
		document.getElementById('popularlink').className = "active";
		return false;
	};
	document.getElementById('newlink').onclick = function() { 
		resetListings();
		document.getElementById('new').className = "open listings";
		document.getElementById('newlink').className = "active";
		return false;
	};
	document.getElementById('rentalslink').onclick = function() { 
		resetListings();
		document.getElementById('rentals').className = "open listings";
		document.getElementById('rentalslink').className = "active";
		return false;
	};
}

//write in Flash
function writeFlash(src, width, height) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'"><param name="movie" value="'+src+'.swf"><param name="quality" value="high"><param name="wmode" value="transparent"><embed src="'+src+'.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" width="'+width+'" height="'+height+'"></embed></object>');
}

addLoadEvent(init);
