//-------Declare the intercept rates (Should add up to 100%)
urldir=clexiturl;
var exit=2;     //Enter percent
var entry=0;    //Enter percent
var nosurvey=98; //Enter percent
var exiturl=urldir+"sitecrm/stealth.htm"; //enter the stealth.htm path
var cookieexp=3*24*30



//Note : To deactivate project assign sniffernet=2;
//The below sniffernet code is to centrally activate,deactivate the project.
//The survey is by default disabled and its only enabled if the site visitor has cookies enabled
//on his system

//-----------------------------------------------------FUNCTIONS---DO NOT EDIT BELOW THIS
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire +";path=/;";
}


function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}


//------To block the survey for people who are visiting from http://video.msn.com/v/us/v.htm,www.fusionamerica.com/zsitecrm.asp

writeCookie("crm_cookieEnabled","1",20);	//writing cookie to check if cookies are enabled or disabled.
var cookieEnabled=readCookie("crm_cookieEnabled");	//reading the cookie value to see if cookie is written or not.

if(cookieEnabled=="1")
{

	//-------Determining whether this is the first visit to tagged page. Tracking the referer url.
	var visitctr=readCookie("ctr");
		
	if (visitctr!="1")
	{
		//-------Capturing Referring URL
		if (document.referrer&&document.referrer!="")
		{
			writeCookie("refer",document.referrer,20);			
		}
		writeCookie("ctr","1",20);
	}

}
else
{
	sniffernet=2;
}



function recontact_crmfx()
{
 //reading popseen cookie to make sure the user hasn't taken the survey within past 6 months
	var thiscookie=readCookie("crmseen");
	if((thiscookie!="seen")&&(sniffernet==1))
	{

		//***Random Number Generated For Control Sample / Test Sample.
		rndNumber=readCookie("rndNumber");
			var x;
			x=Math.random()*100;
			writeCookie("rndNumber",x,1);
		//alert(x);
		
		//****************
		//***Entry Survey Interception Rate. (30% Interception Rate)		
		if (x>(100-exit))
		{
			writeCookie("crmseen","seen",cookieexp);	
			return(1);
			
		}

		else
		{
			writeCookie("crmseen","seen",24*20);
			return(2);

		}
		
	}	
	
	else
	 {
		return(2);
	 }	
	
}

