var PopUpWindow;

function openPopUpWindow(Url, Width, Height, Scrollbars)
{
    var DefaultHeight = 670;
    var DefaultWidth = 600;
    var DefaultScrollbars = "yes";
    
    if (Height == null) { Height = DefaultHeight; }
    if (Width == null) { Width = DefaultWidth; }
    if (Scrollbars == null) { Scrollbars = DefaultScrollbars; }
    
    if (PopUpWindow && !PopUpWindow.closed) { PopUpWindow.document.location.href = Url; }
    else
    {
        PopUpWindow = window.open(Url, "PopUpWindow", "scrollbars=" + Scrollbars + ",status=no,resizable=no,left=100,top=100,width=" + Width + ",height=" + Height);
    }
    return false;
}

function openBanner(Url, Width, Height, Scrollbars)
{
    if (readCookie("banner") != "no")
    {
        createCookie("banner", "no")
        return openPopUpWindow(Url, Width, Height, Scrollbars);
    }
}

function createCookie(name,value,days)
{
	document.cookie = name+"="+value+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i = 0; i < ca.length; i++)
	{
		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);
}

function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}

function Delete_Cookie(name,path,domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
        ( (path) ? ";path=" + path : "") +
        ( (domain) ? ";domain=" + domain : "") +
        ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
