function gup(name)
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function createCampaignIDCookie(name, value, minutes)
{
		if(minutes)
		{
			var date = new Date();
			date.setTime(date.getTime()+(minutes*60*1000));
			var expires = "; expires="+date.toGMTString();
			document.cookie = name+"="+value+expires+"; path=/; domain=murad.com";		
		}
		else
		{	
			document.cookie = name+"="+value+"; path=/; domain=murad.com;";
		}
	
}


// Parsing the URL to get parameters
var segmentVar 	= gup("XID");
if(segmentVar.length == 0)
	segmentVar 	= gup("xid");

//Added the below lines of code to include affiliate id check Arthy 01-27-11
if(segmentVar=="") {
	//check for affliate id param and its value
    var affliateVar = gup("affilnet");
    if(affliateVar.length != 0 && affliateVar == "cj") {
    	segmentVar = "A:10000";
    }
}
 //end code to include affiliate id check   	
	   
var days	 	= gup("days");
var noOfDays	= parseInt(days);

if(typeof noOfDays == "number"){
	var	minutes		= noOfDays*60*24;	
}

// Creating a cookie, muradCampaignID
if(segmentVar.length != 0)
{	
	createCampaignIDCookie("muradCampaignID", segmentVar, minutes);
}

