function setCookie(c_name,value) {
	var exdate=new Date();
	exdate.setTime(exdate.getTime()+(1000*60*60*24*1000));
	
	document.cookie	=	c_name + "=" + escape(value)+";"		+
						"expires=" + exdate.toGMTString()+";"	+
						"path=/;"								+
						"domain="+domain+";";// CHANGE THE DOMAIN in form_and_js _snippets.html TO BE CLIENT SPECIFIC
} // END FUNCTION: setCookie

function getCookie(c_name) {
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) {
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1)
				c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} // end if
	} // END IF
	return "";
} // END FUNCTION: getCookie

function checkCookie(name) {
	value=getCookie(name);
	return value;
} // END FUNCTION: checkCookie

function getSFjkid() {
	SFjkid = "None";
	p_param = "jkid"; //update paid parameter based on searchforce parameter for keyword
	pquery = location.search;
	pquery = unescape(pquery).substr(1);
	parr = pquery.split("&");
	
	for(i=0;i<parr.length;i++){
		$phash = parr[i].split("=");
		if($phash[0].toLowerCase()==p_param){
			SFjkid = $phash[1];
		}
	}
						
	return SFjkid;
} // END FUNCTION: getSFjkid

if (imptest) {
	alert("Apogee CRM Cookie Functions Inclusion Successful!");
} // END IF

// writeCookie
// if the cookie has been written once before, don't touch it
tempjkid = checkCookie("jkid");

if (	
	(tempjkid == "") ||
	(tempjkid == "null") ||
	(tempjkid == null) ||
	(tempjkid == undefined) ||
	(tempjkid == "None")
) {	
	name = "jkid";
	value = getSFjkid();
	setCookie(name, value);
	
} // END IF
