var expDays = 0; // number of days the cookie should last
var left_pop = screen.width / 2 - 259
var top_pop = screen.height / 2 - 225

var windowprops = "width=518,height=450,left=" + left_pop + ",top=" + top_pop + ",location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=no";
// var windowprops = "width=518,height=450,left=" + screen.width - 709 + "location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=no";

function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
			return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}

function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = null;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = "/";  
	var domain = ".nb.com";  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
		((path == null) ? "" : ("; path=" + path)) +  
		((domain == null) ? "" : ("; domain=" + domain)) +    
		((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}


function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function loadEmergencyPopup(popup_url,nb_id) {

	var e_popup = GetCookie(nb_id);
	var sSuppress;
	var bOverride = false;
	var sURL = new String( document.URL );
	//document.write('<font color=white>' + sURL + '</font>') 

	if ( sURL.indexOf('showpopup=n' ) != -1 ) {
		SetCookie('suppresspopup', 'y');
		//alert('setting popup to y');
	//document.write('<br><font color=white>setting cookie to y </font>') 
	}
	
	sSuppress = GetCookie('suppresspopup');
	//alert('sSuppress = ' + sSuppress);
	//document.write('<br><font color=white> sSuppress:' + sSuppress + '</font>') 
	if ((e_popup != nb_id) && ( sSuppress != 'y' )) {
		SetCookie(nb_id, nb_id);
		window.open(popup_url, "", windowprops);
	}

}


