function SetCookie() {
	var survey_value = "TRUE";
	var the_date = new Date("December 31, 2023");
	var the_cookie_date = the_date.toGMTString();

	var the_cookie = "PCCL_WebContent=WCSurveyV1:" + escape(survey_value);
	the_cookie = the_cookie + ";expires=" + the_cookie_date + ";path=/";
	document.cookie = the_cookie;
}

function readCookie(name) {
	if (document.cookie == '') {
		return false;
	} 
	else {
		var firstChar, lastChar;
		var theBigCookie = document.cookie;
		firstChar = theBigCookie.indexOf(name);
		var NN2Hack = firstChar + name.length;
		if ((firstChar != -1) && (theBigCookie.charAt(NN2Hack) == '=')) {
			firstChar += name.length + 1;
			lastChar = theBigCookie.indexOf(';', firstChar);
			if (lastChar == -1) lastChar = theBigCookie.length;
			return unescape(theBigCookie.substring(firstChar, lastChar));
		} 
		else {
			return false;
		}
	}
}

function GetElement(name, cookie) {
	var cookieValue = readCookie(cookie);
	if (cookieValue != false) {
		var elements = cookieValue.split("|");
		var loop = 0;
		for (loop = 0; loop < elements.length; loop++) {
			var currentElement = elements[loop].split(":");
			if (currentElement[0] == name) {
				return currentElement[1];
				break;
			}
		}
		return false;	
	} else {
		return false;
	}
}

function validateCookie(name, cookie) {
	var returnedValue = GetElement(name, cookie);
	if (returnedValue == "TRUE") {
		window.open("/thankyou.html","Mail","toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,menubar=no,top=400,left=300,width=400,height=200");
	} else {
		window.location = "/iw_survey.cfm";
	}
}