function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

init = function() {
	// Set background
	var resolution;
	if (screen.width / screen.height < 1.4) {
		if (screen.width <= 1024) {
			resolution = "1024x768";
		} else if (screen.width <= 1280) {
			resolution = "1280x960";
		} else if (screen.width <= 1400) {
			resolution = "1400x1050";
		} else if (screen.width <= 1600) {
			resolution = "1600x1200";
		} else {
			resolution = "2048x1536";
		}
	} else {
		if (screen.width <= 1280) {
			resolution = "1280x800";
		} else if (screen.width <= 1440) {
			resolution = "1440x900";
		} else if (screen.width <= 1680) {
			resolution = "1680x1050";
		} else if (screen.width <= 1920) {
			resolution = "1920x1200";
		} else {
			resolution = "2560x1600";
		}
	}
	document.body.style.backgroundImage = "url(/images/misc/bck/bck_" + resolution + ".jpg)";

	// Simulate li:hover for IE
	if (document.all && document.getElementById) {
		navRoot = document.getElementById("nav").childNodes[0];
		for (i = 0; i < navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName == "LI") {
				node.onmouseover = function() {
					this.className +=" over";
				}
				node.onmouseout=function() {
					this.className = this.className.replace(" over", "");
				}
			}
		}
	}

	// Position the dropdown lists
	if (!document.all) {
		root = document.getElementById("nav");
		for (i = 0; i < root.childNodes.length; i++) {
			if (root.childNodes[i].nodeName == "UL") {
				navRoot = root.childNodes[i];
				break;
			}
		}
	}
	for (i = 0; i < navRoot.childNodes.length; i++) {
		node = navRoot.childNodes[i];
		if (node.nodeName == "LI") {
			for (j = 0; j < node.childNodes.length; j++) {
				nd = node.childNodes[j];
				arrPos = findPos(node);
				if (nd.nodeName == "UL") {
					nd.style.left = "" + arrPos[0] + "px";
					nd.style.top = "" + (arrPos[1] + node.offsetHeight) + "px";
				}
			}
		}
	}
}

window.onload = init;
