// Popup function
// Author: Janwillem Borleffs
// Date: 8/31/2001


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');
}