//***Code Is Intellectual Property Of crmmetrix inc.(Copyright 2006).
//***The use os this code is permitted for this project only as per the license agreement.
//***Code Has Been Developed For The Sole Purpose Of crmmetrix inc./Noxema.com Project.
//***Licensed For crmmetrix inc./Noxema.com Project.



//-------Declare the intercept rates (Should add up to 100%)
var exit=70;     //Enter percent
var entry=25;    //Enter percent
var nosurvey=5; //Enter percent
var exiturl="../sitecrm/stealth.htm"; //enter the stealth.htm path
var entryurl="../sitecrm/entry.htm"; //enter the entry.htm path



//Note : To deactivate project assign sniffernet=2;
//The below sniffernet code is to centrally activate,deactivate the project.
var sniffernet;
sniffernet=1;
if (sniffernet==1)
{
	document.write("<body onclick='javascript:recontact_crmfx()'>");	
	recontact_crmfx();
}

function recontact_crmfx()
{

	// Example: writeCookie("myCookie", "my name", 24);
	// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
	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=/;";
	}
	
	// Example: alert( readCookie("myCookie") );
	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;
	}
	
	//Browser Sniffer
	var agt=navigator.userAgent.toLowerCase();
	var client=(agt.indexOf("msie"));

	//reading popseen cookie to make sure the user hasn't taken the survey within past 6 months
	var thiscookie=readCookie("crmseen");



	if((thiscookie!="seen")&&(client>0))
	{

		//***Random Number Generated For Control Sample / Test Sample.
		rndNumber=readCookie("rndNumber");
		if(rndNumber=='')
		{
			var x;
			x=Math.random()*100;
			writeCookie("rndNumber",x,1);
		}
		else
		{
			var x;
			x=parseFloat(rndNumber);
		}
		
		/*
		//*************
		//***Exit Survey Interception Rate
		if (x>(100-exit))
		{
			win2=window.open(exiturl,'stealth','height=4,width=4,scrollbars=yes,toolbars=no,location=no,resizable=yes');
			win2.blur();
			window.focus();
		}
		
		
		//****************
		//***Entry Survey Interception Rate. (30% Interception Rate)		
		if (x<=entry)
		{
			window.open(entryurl,'entry','top=5,left=5,height=400,width=600,scrollbars=yes,toolbars=no,location=no,resizable=yes');
		}
		*/	
		
		//****************
		//***NO Survey Interception Rate (10% Interception Rate) 
		//(Cookie Expires In 20 Hrs)
		
		if (x>entry && x<=(100-exit))
		{
			//writing cookie which expires in 20 hrs
			writeCookie("crmseen","seen",20);
		
		}
	}
}
//End bracket for function recontact_crmfx()





