
//declaring global vars outside function
var AdRefer = "";
var cat = "";
var AdStr = unescape(location.search.substring(1, location.search.length));

function adTracker() {
//new code test

//new to set an expiry in case the computer is at a school and it is share
// create an instance of the Date object
var now = new Date();

// cookie expires in one year (actually, 365 days)
// 365 days in a year
// 24 hours in a day
// 60 minutes in an hour
// 60 seconds in a minute
// 1000 milliseconds in a second

//this means expire in half hour
now.setTime(now.getTime() + 30 * 60 * 1000);

//write cookie
//the string needs to be composed as follows:
//cat= category of keyword service the camp is running ie prom or wedding
//somepage.htm?cat=xyz&camp=prom


if (AdStr != ""){

var tmpstr = AdStr.split('&');

	if (tmpstr.length>1) {

//if we are here then we must have come from an Ad

		var AdReferTmp = tmpstr[1].split('=');
		var catTmp = tmpstr[0].split('=');

		 AdRefer = AdReferTmp[1];

//this cat I need to fill in the event_type when coming from an adpage
		 cat = catTmp[1];

//lets grab the url referer and put in a cookie for the rsvp to read it

	SetCookie("UrlReferer", document.referrer, now);

	}else if ((tmpstr.length==1)){

		 AdRefer = "Non-Ad Based";
		 var catTmp = tmpstr[0].split('=');
		 cat = catTmp[1];
	}else {
		 AdRefer = "Non-Ad Based";	
		 cat = "";
}

}else{

	 AdRefer = "Non-Ad Based";;
	 cat = "";
}

if(GetCookie("AdRefer")!=null){
//read cookie

 AdRefer = GetCookie("AdRefer");
 cat = cat;

} else {


SetCookie("AdRefer", AdRefer, now);


}

}//end of function

adTracker();