var isNav, isIE;
var currentMenu = '';


if(parseInt(navigator.appVersion) >= 4) {
	if(navigator.appName == "Netscape") {
		isNav = true
	} else {
		isIE = true
	}
}


function setLocation(menuName, x, y) {
	if (isNav) {
		screenWidth = window.innerWidth;
		document.layers[menuName].left = x;
		document.layers[menuName].top = y;
	} else {
		screenWidth = document.body.clientWidth + 18;
		document.all[menuName].style.pixelLeft = x;
		document.all[menuName].style.pixelTop = y;
	}
}

function showPopup(menuName, x, y) {
	hidePopup();
	currentMenu = menuName;
	setLocation(currentMenu, x, y);
	if (isNav) {
		document.layers[menuName].visibility = "show";
	} else {
		document.all[menuName].style.visibility = "visible";
	}
}


function hidePopup() {
	if(currentMenu != '') {
		if (isNav) {
			document.layers[currentMenu].visibility = "hide";
		} else {
			document.all[currentMenu].style.visibility = "hidden";
		}
	}
}


function popup(url,name,abs,width,height,toolbar,status,scrollbars,resizable,top,left,cookie_name,expire) {
	// Don't execute function when there aren't enough arguments
	if (arguments.length < 10) { alert('Onvoldoende argumenten'); return true; }
	// Some vars needed for positioning
	var x = screen.width; 
    var y = screen.height;

	// Properties
    var Width = width; 
    var Height = height; 
    var Top = (abs) ? parseInt((y-Height)/2) : top; 
    var Left = (abs) ? parseInt((x-Width)/2) : left; 
	var Toolbar = (toolbar) ? "yes":"no";
	var Status = (status) ? "yes":"no";
	var Scrollbars = (scrollbars) ? "yes":"no";
	var Resizable = (resizable) ? "yes":"no";

	// Get the cookie of the calling document (if any)
	var cookie = document.cookie;

	// Build the properties string
	var properties = "width=" + Width + ",height=" + Height + ",toolbar=" + Toolbar + ",status=" + Status + ",scrollbars=" + Scrollbars + ",resizable=" + Resizable + ",top=" + Top + ",left=" + Left;

	if (arguments.length > 11) {
		// Check if cookie exists
		if (cookie.indexOf(cookie_name)>-1) return true;

		// Cookie doesn't exist, so continue
		if (arguments.length == 13) {
			// require a session cookie
			document.cookie = cookie_name + "=1";
		} else {
			// Set a cookie with the expire date set
			document.cookie = cookie_name + "=1;expire=" + expire;
		}
	} 
		var popname = name.split(" ").join("_");
		// Create a popup
		eval('var ' + popname + '= window.open("' + url + '","' + popname + '","' + properties + '");');
		eval(popname + '.focus();');
}

// Included for backwards site compatibility
function openPopup(source_page) { 
	var NewWindow = window.open(source_page,'titel','toolbars=no,resizable=no,scrollbars=no,width=399,height=340');
}
