//-- popup for 911
var newwin;
function launchwin(winurl,winname,winfeatures)
{
	newwin = window.open(winurl,winname,winfeatures);
	if(javascript_version > 1.0)
	{
 		setTimeout('newwin.focus();',250);
	}
}

//-- survey script
function getCookie (name) {
	var dcookie = document.cookie; 
	var cname = name + "=";
	var clen = dcookie.length;
	var cbegin = 0;
	while (cbegin < clen) {
		var vbegin = cbegin + cname.length;
		if (dcookie.substring(cbegin, vbegin) == cname) { 
			var vend = dcookie.indexOf (";", vbegin);
			if (vend == -1) vend = clen;
			return unescape(dcookie.substring(vbegin, vend));
		}
		cbegin = dcookie.indexOf(" ", cbegin) + 1;
		if (cbegin == 0) break;
	}
	return null;
}

function writeCookie (cookieName, cookieValue, expiry) {
	var expDays = 60; // number of days the cookie should last
	var expDate = new Date();
	expDate.setTime (expDate.getTime() + (expDays*24*60*60*1000));
	document.cookie = cookieName + "=" + escape (cookieValue) + "; expires=" + expDate.toGMTString() + "; path=/";
}

function deleteCookie (name) {
	var expireNow = new Date();
	// null survey value and set cookie for one tick in the past
	expireNow.setTime(expireNow.getTime() - 1);
	document.cookie = name + "=" + "; expires=" + expireNow.toGMTString + "; path=/";
}
function surveyPopUp(pageIdentifier,freq) {
	var survey3 = getCookie("survey3");
	if (survey3 == "yes") {
		// Survey invite previously given, do nothing
	}
	else {
		// Survey invite has not been previously given, initiate 
		rrand = Math.random();  
		if (rrand < freq) {
			// random seed below threshhold, set cookie and pop survey
			writeCookie('survey3', 'yes');		
			window.open("/survey/pop-up.html?from=" + pageIdentifier, "surveyInvitation", "top=5,left=5,height=400,width=500,toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0");
		}
		else {
			// random seed above threshhold, do nothing
		}
	}
}


//-- launch BBS link
function liveworld(bbslink) {
bbswindow=window.open(bbslink,"","personalbar=no,menubar=yes,toolbar=no,location=no,resizable=yes,scrollbars=yes,status=yes,height=500,width=710");
}
