//***Code Is Intellectual Property Of crmmetrix inc.(Copyright 2010).
//***The use os this code is permitted for this project only as per the license agreement.

maindirurlpopcrm="/popup/barometre";
maindirurlpopcrm2="/popup/barometre";


//-------Declare the intercept rates (Should add up to 100%)
var exit=30;     //Enter percent
var entry=0;    //Enter percent
var nosurvey=70; //Enter percent
var exiturl= maindirurlpopcrm2+"/cookie.htm"; //enter the stealth.htm path
 
var insec=3;//Timer that delays the show of pop-in (in seconds)

var cookieexp_seen=3*24*30; //Cookie for 3 months
var cookieexp_enabled=20; //Cookie for 20 hours
var cookieexp_no=20*24; //Cookie for 20 days
var cookieexp_donex=5;//Cookie for 5 hours
var cookieexp_nosurvey=24;//Cookie for 1 day


var wtx=(screen.width);
var htx=(screen.height);
var wtx2=((wtx-600)*0.5);
var htx2=50; //From to 150

var sniffernet=1;

/*determination of the domain*/
	var crmmetrix={
	 cldomaine:window.location.hostname,
	 reg:new  RegExp("[.]+", "g")
	}
	crmmetrix.tableau=crmmetrix.cldomaine.split(crmmetrix.reg);
	crmmetrix.i=crmmetrix.tableau.length;
	if(crmmetrix.i>2)
	{
	crmmetrix.cldomaine=crmmetrix.tableau[crmmetrix.i-2]+'.'+crmmetrix.tableau[crmmetrix.i-1];           
	}


//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=/;domain="+crmmetrix.cldomaine+";";
}


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;
}

function GetParam(name)
{
  var start=location.search.indexOf("?"+name+"=");
  if (start<0) start=location.search.indexOf("&"+name+"=");
  if (start<0) return '';
  start += name.length+2;
  var end=location.search.indexOf("&",start)-1;
  if (end<0) end=location.search.length;
  var result=location.search.substring(start,end);
  var result='';
  for(var i=start;i<=end;i++) {
    var c=location.search.charAt(i);
    result=result+(c=='+'?' ':c);
  }
  return unescape(result);
}


writeCookie("crm_cookieEnabled","1",cookieexp_enabled);	//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("cntr");
		
	if (visitctr!="1")
	{
		//-------Capturing Referring URL
		if (document.referrer&&document.referrer!="")
		{
			writeCookie("refer",document.referrer,cookieexp_enabled);			
		}
		writeCookie("cntr","1",cookieexp_enabled);
	}

}
else
{
	sniffernet=2;
}

//--------------------------------------------------------------------------------------------
//-------------------------------------- DO NOT EDIT -----------------------------------------
//--------------------------------------------------------------------------------------------

function hideAd(divId) 

{ 
	if (document.layers) document.layers[divId].visibility = 'hide';
	else if (document.all) document.all[divId].style.visibility = 'hidden';
	else if (document.getElementById) document.getElementById(divId).style.visibility = 'hidden';
	//writeCookie("crmseen","seen",24);
}

function showAd(divId) 
{ 
	if (document.layers) document.layers[divId].visibility = 'show';
	else if (document.all) document.all[divId].style.visibility = 'visible';
	else if (document.getElementById) document.getElementById(divId).style.visibility = 'visible';
	//writeCookie("crmseen","seen",24);
}

function create(divId) 
{ 
	if (document.layers) document.layers[divId].visibility = 'show';
	else if (document.all) document.all[divId].style.visibility = 'visible';
	else if (document.getElementById) document.getElementById(divId).style.visibility = 'visible';
	//writeCookie("crmseen","seen",24);
}

function adDown(divId) 
{ 
	state=typeof topPos;
	var fposi;
	if (divId=='bg')
	{
	fposi=0;
	}
	else
	{
	fposi=80;
	}

	if(state=='undefined') {topPos=-440;}
	if(topPos < fposi)
	{ 
		topPos+=40;
		if (document.layers)
		{
			document.layers[divId].top = topPos;
		}
		else
		{
			if(document.all)
			{
				document.all[divId].style.top = topPos;
			}
			else
			{
				if(document.getElementById)
				{
					document.getElementById(divId).style.top = topPos;
				}
			}
		}
		
		{setTimeout("adDown('"+divId+"');",5);}
	 }
}


function stealthfx(lang)
{
	var win2=window.open(exiturl+"?lang="+lang,'stealth','height=10,width=10,scrollbars=yes,toolbars=no,location=no,resizable=yes');
	if(win2!=null)
	{
		win2.blur();
		writeCookie("crmseen","seen",cookieexp_seen);
	}
	hideAd('stealth_pop');

	window.focus();
}

function crmlinkfx()
{
popupWin = window.open('http://fr.crmmetrix.com/','open_window','menubar, toolbar, location, directories, status, scrollbars, resizable, dependent, width=640, height=480, left=100, top=100')
}


function nosurveyfx(divId)
{
	hideAd(divId);
	writeCookie("crmseen","seen",cookieexp_no);
}

	var thiscookie=readCookie("crmseen");



if (parseInt(navigator.appVersion) >= 4 ) 
{ 	
	
function writeJS(){
var strCrm='';
strCrm=strCrm+'<div align="center"  id="stealth_pop">';
strCrm=strCrm+'  <center>';
strCrm=strCrm+'  <table width="600px" border="0" cellspacing="0" cellpadding="0" height="400px">';
strCrm=strCrm+'  <tr>';
strCrm=strCrm+'    <td background="'+maindirurlpopcrm+'/images/paris.jpg" valign="top"> ';
strCrm=strCrm+'      <p style="height:102px;"> <\/p>';
strCrm=strCrm+'      <p> <\/p>';
strCrm=strCrm+'      <p> <\/p>';
strCrm=strCrm+'      <p> <\/p>';
strCrm=strCrm+'      <table width="600px" border="0" cellspacing="0" cellpadding="0">';
strCrm=strCrm+'        <tr align="left" valign="top"> ';
strCrm=strCrm+'          <td width="24px"> <\/td>';
strCrm=strCrm+'          <td width="18px"><font face="Arial, Helvetica, sans-serif" size="3"><b><font face="Arial, Helvetica, sans-serif" size="3"><b><font color="#666666"><img src="'+maindirurlpopcrm+'/images/arrow.gif" width="12" height="16"><\/font><\/b><\/font><font color="#666666"><br>';
strCrm=strCrm+'            <br>';
strCrm=strCrm+'            <\/font><\/b><\/font><\/td>';
strCrm=strCrm+'          <td width="246px"><font face="Arial, Helvetica, sans-serif" size="3"><b><font color="#666666">votre ';
strCrm=strCrm+'            opinion compte !<\/font><\/b><\/font><\/td>';
strCrm=strCrm+'          <td width="24px"> <\/td>';
strCrm=strCrm+'          <td width="18px"><font face="Arial, Helvetica, sans-serif" size="3"><b><img src="'+maindirurlpopcrm+'/images/arrow.gif" width="12" height="16"><\/b><\/font><\/td>';
strCrm=strCrm+'          <td width="246px"><font face="Arial, Helvetica, sans-serif" size="3"><b>we ';
strCrm=strCrm+'            value your opinion!<\/b><\/font><\/td>';
strCrm=strCrm+'          <td width="24px"> <\/td>';
strCrm=strCrm+'        <\/tr>';
strCrm=strCrm+'        <tr align="left" valign="top" > ';
strCrm=strCrm+'          <td width="24px"> <\/td>';
strCrm=strCrm+'          <td width="18px"> <\/td>';
strCrm=strCrm+'          <td width="246px"><font face="Arial, Helvetica, sans-serif" size="2" color="#666666"><b>Merci ';
strCrm=strCrm+'            de votre visite. <br>';
strCrm=strCrm+'            Pour encore mieux vous satisfaire, nous vous invitons &agrave; prendre ';
strCrm=strCrm+'            3 ou 4 minutes pour r&eacute;pondre &agrave; un court questionnaire ';
strCrm=strCrm+'            en cliquant ci-dessous. Nous vous remercions.<\/b><\/font><\/td>';
strCrm=strCrm+'          <td width="24px"> <\/td>';
strCrm=strCrm+'          <td width="18px"> <\/td>';
strCrm=strCrm+'          <td width="246px"><b><font face="Arial, Helvetica, sans-serif" size="2" color="#666666">Thank ';
strCrm=strCrm+'            you for your visit.<br>';
strCrm=strCrm+'            We would appreciate your feedback to help us maximize your satisfaction. ';
strCrm=strCrm+'            This should take 3-4 minutes of your time.<br>';
strCrm=strCrm+'            We thank you in advance.<\/font><\/b><\/td>';
strCrm=strCrm+'          <td width="24px"> <\/td>';
strCrm=strCrm+'        <\/tr>';
strCrm=strCrm+'        <tr align="left" valign="top" style="height:12px;"> ';
strCrm=strCrm+'          <td width="24px"> <\/td>';
strCrm=strCrm+'          <td colspan="2"> <\/td>';
strCrm=strCrm+'          <td width="24px"> <\/td>';
strCrm=strCrm+'          <td colspan="2"> <\/td>';
strCrm=strCrm+'          <td width="24px"> <\/td>';
strCrm=strCrm+'        <\/tr>';
strCrm=strCrm+'        <tr align="left" valign="top"> ';
strCrm=strCrm+'          <td width="24px"> <\/td>';
strCrm=strCrm+'          <td align="left" width="18px"> <\/td>';
strCrm=strCrm+'          <td align="left" width="246px"><a href="javascript:stealthfx(\'fr\');"><img src="'+maindirurlpopcrm+'/images/repondre.gif" width="121" height="26" alt="r&eacute;pondre" border="0"><\/a><br>';
strCrm=strCrm+'            <br>';
strCrm=strCrm+'            <a href="javascript:nosurveyfx(\'stealth_pop\');"><img src="'+maindirurlpopcrm+'/images/non.gif" width="121" height="26" border="0" alt="non merci"><\/a><\/td>';
strCrm=strCrm+'          <td width="24px"> <\/td>';
strCrm=strCrm+'          <td align="left" width="18px"> <\/td>';
strCrm=strCrm+'          <td align="left" width="246px"><a href="javascript:stealthfx(\'en\');"><img src="'+maindirurlpopcrm+'/images/answer.gif" width="121" height="26" alt="answer" border="0"><\/a><br>';
strCrm=strCrm+'            <br>';
strCrm=strCrm+'            <a href="javascript:nosurveyfx(\'stealth_pop\');"><img src="'+maindirurlpopcrm+'/images/no.gif" width="121" height="26" alt="no thank you" border="0"><\/a> ';
strCrm=strCrm+'          <\/td>';
strCrm=strCrm+'          <td width="24px"> <\/td>';
strCrm=strCrm+'        <\/tr>';
strCrm=strCrm+'      <\/table>';
strCrm=strCrm+'    <\/td>';
strCrm=strCrm+'  <\/tr>';
strCrm=strCrm+'<\/table>';
strCrm=strCrm+'  <\/center>';
strCrm=strCrm+'<\/div>';document.write(strCrm);
}
writeJS();

	if (document.layers) document.layers.stealth_pop.left = 10;
	else if (document.all) document.all.stealth_pop.style.left = 10;
	else if (document.getElementById) document.getElementById("stealth_pop").style.left = 10;
	
	if (document.layers) document.layers.stealth_pop.zIndex = 1000000;
	else if (document.all) document.all.stealth_pop.style.zIndex = 1000000;
	else if (document.getElementById) document.getElementById("stealth_pop").style.zIndex = 1000000;
	
	hideAd('stealth_pop'); 
 
}
//--------------------------------------------Floating code------------------------------------
//--------------------------------------------Pl do not modify it------------------------------

var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
function JSFX_FloatDiv(id, sx, sy)
{
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	var px = document.layers ? "" : "px";
	window[id + "_obj"] = el;
	if(d.layers)el.style=el;
	el.cx = el.sx = sx;el.cy = el.sy = sy;
	el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};

	el.floatIt=function()
	{
		var pX, pY;
		pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
		document.documentElement && document.documentElement.clientWidth ? 
		document.documentElement.clientWidth : document.body.clientWidth;
		pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
		document.documentElement.scrollTop : document.body.scrollTop;
		if(this.sy<0) 
		pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
		document.documentElement.clientHeight : document.body.clientHeight;
		this.cx += (pX + this.sx - this.cx)/8;this.cy += (pY + this.sy - this.cy)/8;
		this.sP(this.cx, this.cy);
		setTimeout(this.id + "_obj.floatIt()", 40);
	}
	return el;
}


//-----------------------------End of floating code-------------------------------------

if (sniffernet==1)
{
	timerfx();
	document.write("<img id='imgx' height='0' width='0'>");

}

//Timer function
// to declare timer example - for 10 minutes assign secs = 600
var secs = insec;
var timerID = null;
var timerRunning = false;
var delay = 1000;

function timerfx()
{ 
	if (secs==0)
    {
        if(timerRunning)
        clearTimeout(timerID);
    	timerRunning = false;
		recontact_crmfx();
		window.onerror=null;
    }
    else
    {
        //self.status = secs;
        secs = secs - 1;
        timerRunning = true;
        timerID = self.setTimeout("timerfx()", delay);
    }
}


function recontact_crmfx()
{

	//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")
	{

		//***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))
		{
			showAd('stealth_pop');
			adDown('stealth_pop');
			JSFX_FloatDiv("stealth_pop", wtx2,htx2).floatIt();

		}

		if (x>entry && x<=(100-exit))
		{
			writeCookie("crmseen","seen",cookieexp_nosurvey);
		}
		
	}
}

//------------------------------------------------------------------------------------------------------------
//-------------------------- CRMMETRIX TRACKING CODES - DO NOT MODIFY ----------------------------------------
//------------------------------------------------------------------------------------------------------------

function loadStyleSheet(file)
{
	// Create script DOM(Document Object Model) element
	var script = document.createElement('link');
	script.rel = 'stylesheet';
	script.type = 'text/css';
	script.href = file;

	// Alert when the script is loaded
	if (typeof(script.onreadystatechange) == 'undefined') // W3C
		script.onload = function(){ this.onload = null;  };
	else // IE
		script.onreadystatechange = function(){ if (this.readyState != 'loaded' && this.readyState != 'complete') return; this.onreadystatechange = null;  }; // Unset onreadystatechange, leaks mem in IE

	// Add script DOM(Document Object Model) element to document tree
	document.getElementsByTagName('head')[0].appendChild(script);
}

loadStyleSheet(maindirurlpopcrm+"/style.css");




