//This is javascript code that will allow INETPortals to store a campaign ID code in a client cookie on the landing pages that come from online ad campaigns

	//Get variables from the url string
	function getQueryVariable(variable)
	{
	   var query = window.location.search.substring(1);
	   var vars = query.split("&");
	   for (var i=0;i<vars.length;i++) {
	           var pair = vars[i].split("=");
	           if(pair[0] == variable){return pair[1];}
	   }
	   return(false);
	}

	//Get Cookie Information to check if cookie exists.  If it does then grab the campID
	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));
	    }
	  }
	return "";
	}

	//Check to see if cookie exists, if it does then check if campid = 0, if so then recreate the cookie with the new campid
	var expiremilliseconds = 178 * 24 * 60 * 60 * 1000;
	var currdate = new Date();
	var expirationdate = new Date(currdate.getTime() + expiremilliseconds);
	CampTrackerID = getQueryVariable('inetcampid');
	if(CampTrackerID == false){
		CampTrackerID = getCookie('INETAdTracker');
	}
	document.cookie = "INETAdTracker=" + CampTrackerID + ";expires=" + expirationdate.toGMTString() + ";path=/" + ";domain=sonobello.com"
	
	
	campID=getCookie('INETAdTracker');
	if (CampTrackerID == '' && campID == 0)
		{
			CampTrackerID = parent.document.contactform.Camp_ID.value;
		}
	else{if(campID != 0){
			CampTrackerID = campID;
	}
	else{
		CampTrackerID = 0;
	}
	}
	var checkform = typeof parent.document.forms['contactform'] != 'undefined';
	if (checkform == true) 
	{
		campnum = Number(parent.document.contactform.Camp_ID.value);
		if (CampTrackerID != 0) {
			switch (campnum) {
				case 18:
					parent.document.contactform.Camp_ID.value = 18;
					break;
				case 159:
					parent.document.contactform.Camp_ID.value = 159;
					break;
				case 160:
					parent.document.contactform.Camp_ID.value = 160;
					break;
				default:
					parent.document.contactform.Camp_ID.value = CampTrackerID;
			}
		}
		
	}
			
	
	






