window.onload = function() {
	var menuDivs = new Array('mainmenu', 'submenu');
	
	for (n = 0; n < menuDivs.length; n++) {
		var menu = document.getElementById(menuDivs[n]); 
		if (menu) {
			var menuUL = menu.childNodes[0];
			for (m = 0; m < menuUL.childNodes.length; m++) {
				var menuLI = menuUL.childNodes[m];
				if (menuLI.nodeName == 'LI') {
					menuLI.onmouseover = function() {
						this.className += ' over';
					}
					menuLI.onmouseout = function() {
						this.className = this.className.replace(' over', '');
					}
				}
			}			
		}
	}
}

var openLightbox = function(img, width, height) {
	var body  = document.getElementsByTagName("body").item(0);
	
	var fade = document.createElement('div');
	fade.className = 'lightbox_black_overlay'; 
	fade.style.display = 'block';
	fade.onclick = function() {
		body.removeChild(light);
		body.removeChild(fade);
		body.style.overflow = 'auto';		
	}
	
	var light = document.createElement('div');
	light.className = 'lightbox_white_content';
	
	var newWidth;
	if (screen.width > width) {
		newWidth = width;
	} else {
		newWidth = screen.width;
	}
	
	var newHeigth;
	if (screen.height > height) {
		newHeight = height;
	} else {
		newHeight = screen.height;
	}
	
	light.style.width = newWidth + 'px';
	light.style.height = newHeight + 'px';
	light.style.left = '50%';
	light.style.top = '50%';
	light.style.marginLeft = -(newWidth / 2) + 'px';
	light.style.marginTop = -(newHeight / 2) + 'px';
	
	light.style.display = 'block';
	light.innerHTML = '<img src="' + img + '">';
	light.onclick = function () {
		body.removeChild(light);
		body.removeChild(fade);
		body.style.overflow = 'auto';
	}	
	
	body.style.overflow = 'hidden';
	body.appendChild(fade);
	body.appendChild(light);
}