function addLoadEvent (funcName) {
	var oldonload = window.onload;
	if (typeof oldonload == "function") {
		window.onload = function () {
			oldonload();
			funcName();
		}
	} else {
		window.onload = function () {
			funcName();
		}
	}
}

function showListingPreview (targ) {
	if (document.createElement) {
		var ni = document.createElement("img");
		ni.id = targ.id.replace(/Thumb/,"Image");
		ni.src = targ.src.replace("thumb","preview");
		ni.alt = "";
		ni.className = "listingPreviewImage";
		targ.parentNode.appendChild(ni);
	}
}
function removeListingPreview (targ) {
	var di;
	if (di = document.getElementById(targ.id.replace(/Thumb/,"Image"))) {
		targ.parentNode.removeChild(di);
	}															 
}

function addListPreviewEvents () {
	var imgs;
	if (imgs = document.getElementsByTagName('img')) {
		for (i=0; i<imgs.length; i++) {
			if (imgs[i].className ==  "listing_thumb") {
				imgs[i].onmouseover = function () {
					showListingPreview(this);
				}
				imgs[i].onmouseout = function () {
					removeListingPreview(this);
				}
				imgs[i].id = "previewThumb"+i;
			}
		}
	}
}	

addLoadEvent(addListPreviewEvents);
