// JavaScript Document
//user cookies to track whether the user has come from the Banner 08 campaign
// 6 ad networks are linking to clarkson.edu, using the URL variable "banner08"

//track the possible banner08 values
var networkArray = new Array("google","yahoo","burst","videoegg","alloy","eyeblaster")

function checkForBanner08()
{

	var earl = new String(document.location);

	var banner08Start = earl.indexOf("banner08=");
	if(banner08Start != -1)//set the cookie
	{
		var cookieVal = "";
		var adnetworkend = earl.indexOf("&",banner08Start);//starting at banner08, look for &
		if(adnetworkend == -1)//Must be last vaiable
		{
			cookieVal = earl.substring(banner08Start+9,earl.length);
		}
		else
		{
			cookieVal = earl.substring(banner08Start+9,adnetworkend);
		}
		document.cookie = cookieVal+"=1;domain=.clarksongene.com;path=/";
		//alert(document.cookie.indexOf("yahoo"));
	}
}

function checkForCookie()//return a string of the network, or empty
{
	var theNetwork = "";
	
	for(var i = 0;i < networkArray.length; i++)
	{
		if(document.cookie.indexOf(networkArray[i]) != -1)
		{
			theNetwork = networkArray[i];
		}
	}
	
	return theNetwork;
}


function writeNavigation()
{
	if(	checkForCookie() != "" )//we have a network to track, so modify the form action so the URL reflects the ad network upon request
	{
		//build the links so they carry the ad network along for the ride
		document.write('<a href="http://www.clarkson.edu/index.html?banner08='+checkForCookie()+'">Visit Clarkson.edu</a> | <a href="http://www.clarkson.edu/admission/apply_now.html?banner08='+checkForCookie()+'">Apply Now</a> | <a href="http://www.clarkson.edu/admission/request_more_info.php?banner08='+checkForCookie()+'">Request Information</a> | <a href="http://www.clarkson.edu/contact_us.html?banner08='+checkForCookie()+'">Contact Us</a>');
		
	}
	else
	{
		document.write('<a href="http://www.clarkson.edu">Visit Clarkson.edu</a> | <a href="http://clarkson.edu/admission/apply_now.html">Apply Now</a> | <a href="http://www.clarkson.edu/admission/request_more_info.php">Request Information</a> | <a href="http://clarkson.edu/contact_us.html">Contact Us</a>');
	}
}

