

function doOnLoad() {
	// hover images
	var allimgs = document.getElementsByTagName('img');
	for(var i=0; i<allimgs.length; ++i) {
		if(allimgs[i].getAttribute('hoversrc')) {
			preloadImage(allimgs[i].getAttribute('hoversrc'));

			allimgs[i].onmouseover = function() {
				this.setAttribute('__src_orig', this.getAttribute('src'));
				this.setAttribute('src', this.getAttribute('hoversrc'));

				if(this.getAttribute('rel')) {
					var m = this.getAttribute('rel').match(/mainmenu\[([a-z]+)\]/i);
					if(m &&window.mainmenus && window.mainmenus[m[1]]) window.mainmenus[m[1]].mouseOver(this);
				}
			};
			allimgs[i].onmouseout = function() {
				this.setAttribute('src', this.getAttribute('__src_orig'));

				if(this.getAttribute('rel')) {
					var m = this.getAttribute('rel').match(/mainmenu\[([a-z]+)\]/i);
					if(m && window.mainmenus[m[1]]) window.mainmenus[m[1]].mouseOut(this);
				}
			};
		}
	}


}

function preloadImage(href) {
	if(!window.preloadImageList) window.preloadImageList = new Array();
	var i = window.preloadImageList.length;

	window.preloadImageList[i] = new Image();
	window.preloadImageList[i].src = href;
}



function popupWin(that, w, h, options) {
	if(!w) w = 500;
	if(!h) h = 500;

	var x = (screen.availWidth - w) / 2;
	var y = (screen.availHeight - h) / 2;

	if(!options) options = '';

	var optslist = new Array();
	optslist[optslist.length] = 'width='+w;
	optslist[optslist.length] = 'height='+h;
	optslist[optslist.length] = 'scrollbars=auto';
	optslist[optslist.length] = 'resizable=yes';
	optslist[optslist.length] = 'left='+x;
	optslist[optslist.length] = 'top='+y;

	var bits = options.split(/,/);
	for(var i=0; i<bits.length; ++i) {
		var b = bits[i].split(/=/);
		optslist[optslist.length] = b[0] + '=' + b[1];
	}
	var optionstring = optslist.join(',');



	var href;
	if(that.href) href = that.href;
	else href = that;

	var win = window.open(that.href, 'popwin', optionstring);

	win.resizeTo(w, h);
	win.focus();

	return false;
}

function getLeft(obj) {
	return (obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft + getLeft(obj.offsetParent));
}
function getTop(obj) {
	return (obj.offsetParent==null ? obj.offsetTop : obj.offsetTop + getTop(obj.offsetParent));
}