function popup(url,top,left,width,height,windowname,toolbar,location,status,menubar,scrollbars,resizable,aspercent) {
	if (windowname == null || windowname == 'undefined' || windowname == '') {
		windowname = 'unnamedwindow';
	}
	
	if (width == null || width == 'undefined' || width == -1) {
		width = window.screen.availWidth / 2;
	} else {
		if (aspercent) {
			width = (width/100.0) * window.screen.availWidth;
		}
	}
	
	if (height == null || height == 'undefined' || height == -1) {
		height = window.screen.availHeight / 2;
	} else {
		if (aspercent) {
			height = (height/100.0) * window.screen.availHeight;
		}
	}

	if (top == null || top == 'undefined' || top == -1) {
		top = (window.screen.height / 2) - (height / 2);
	}
	
	if (left == null || left == 'undefined' || left == -1) {
		left = (window.screen.width / 2) - (width / 2);
	}

	var options = "top=" + top + ",left=" + left + ",width=" + width + ",height=" + height;
	
	if (toolbar)	options += ",toolbar=yes";		else options += ",toolbar=no";
	if (location)	options += ",location=yes";		else options += ",location=no";
	if (status)		options += ",status=yes";		else options += ",status=no";
	if (menubar)	options += ",menubar=yes";		else options += ",menubar=no";
	if (scrollbars)	options += ",scrollbars=yes";	else options += ",scrollbars=no";
	if (resizable)	options += ",resizable=yes";	else options += ",resizable=no";

	var w = window.open(url,windowname,options,true);
	w.focus();
}

function getDim(el){
	for (var lx=0,ly=0;el!=null;
		lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
	return {x:lx,y:ly}
}

function createCookie(name,value,days) {
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		var expires = '; expires=' + date.toGMTString();
	}
	else var expires = '';
	document.cookie = name + '=' + value + expires + '; path=/';
}

function readCookie(name) {
	var nameEQ = name + '=';
	var ca = document.cookie.split(';');
	if (ca != null) {
		for(var i = 0; i < ca.length; i++)
		{
			if (ca[i] != null) {
				var c = ca[i];
				while (c.charAt(0) == ' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
		}
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
