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";
}

function CheckSurveyCookie() {
	if (Get_Cookie("survnw") == null) {
		winopen('../asp/survey/nw_survey_survnw.asp','survey','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,WIDTH=720,HEIGHT=400');
	}
}

Pairs = [];
Names = [];
Values = [];

function ParseString(param) {
	if (param != null) {
		paircounter = 0;
		amp = param.indexOf("&");
		while (amp != -1) {
			Pairs[paircounter] = param.substring(0, amp);
			param = param.substring(amp+1, param.length);
			amp = param.indexOf("&");
			paircounter++;
		}
		Pairs[paircounter] = param;

		for (j = 0; j < Pairs.length; j++) {
			eq = Pairs[j].indexOf("=");
			if (eq == -1) {
				alert("No equals sign in param " + j);
			}
			else {
				Names[j] = Pairs[j].substring(0, eq);
				Values[j] = Pairs[j].substring(eq+1, Pairs[j].length);
			}
		}
	}
} // end ParseString

function GetParam(name) {
	found = false;
	index = 0;
	result = null;

	while ((index < Names.length) && (! found) ) {
		if (Names[index] == name) {
			found = true;
			result = Values[index];
		}
		index++;
	}
	return result;
} // end GetParam


ParseString( Get_Cookie("nwreg") );
firstname = GetParam("firstname");
lastname = GetParam("lastname");
firstinit = "";
lastinit = "";
if (firstname != null) {
	firstinit =  String(firstname).charAt(0);
}
if (lastname != null) {
	lastinit =  String(lastname).charAt(0);
}
initials = firstinit + lastinit;

uid = GetParam("userid")
if (!(uid)) { uid = ""; }
handle = GetParam("handle")
if (!(handle)) { handle = ""; }


sw3value = uid + " " + handle + " " + initials

