var dloc = userName = "" + document.location;
dloc = dloc.substring(dloc.indexOf("?")+1);
var p = dloc.split("&");
var rs2 = "";

for (i=0; i < p.length; i++) {
	if (p[i].split("=")[0] == "tracking") {
		rs2 = p[i].split("=")[1];
		break;
	}
}

var now = new Date();
var month = now.getMonth()+1;
var date = now.getDate();
var year = now.getYear();

function SetCookie(sName, sValue) {
	if(! sValue) {
		sValue = "UNKNOWN";
	}

	document.cookie = sName + "=" + "|rs4:" + month + "/" + date + "/" + year + "|rs2:" + rs2 + "|rs5:" + escape(sValue) + "; path=/; expires=Fri, 25 Dec 2037 23:59:59 GMT";
}


var flag = true;
var flagLanded = true;
var a = document.cookie.split(";");

for (i=0; i < a.length; i++) {
	if (a[i].split("=")[0] == " firstVisit" || a[i].split("=")[0] == "firstVisit") {
		flag = false;
	}
	if (a[i].split("=")[0] == " Landed" || a[i].split("=")[0] == "Landed") {
		flagLanded = false;
	}
}

if (flag) {
	SetCookie("firstVisit", document.referrer);
}
if (flagLanded) {
	SetCookie("Landed", document.location);
}

SetCookie("mostRecentVisit", document.referrer);
