var unnatiClicksGroup='';var unnatiClicksSite='';var unnatiClicksServer=host+'analytics/application/click.php';var unnatiClicksLastIframe=-1;var unnatiClicksTime=0;var unnatiClicksQuota=-1;var unnatiClicksBrowser='';var unnatiClicksDocument='';var unnatiClicksWait=500;var unnatiClicksLocalWait=0;var unnatiClicksDebug=(window.location.href.search(/debugunnatiClicks/)!==-1);function showunnatiClicksDebug(str){if(unnatiClicksDebug===true){document.getElementById('unnatiClicksDebuggerSpan').innerHTML=str;document.getElementById('unnatiClicksDebuggerDiv').style.display='block';}}
function catchunnatiClicks(e){try{showunnatiClicksDebug('Gathering click data...');if(unnatiClicksQuota===0){showunnatiClicksDebug('Click not logged: quota reached');return true;}
if(unnatiClicksGroup===''){showunnatiClicksDebug('Click not logged: group name empty (unnatiClicksGroup)');return true;}
if(e===undefined){e=window.event;c=e.button;element=e.srcElement;}
else{c=e.which;element=null;}
if(c===0){showunnatiClicksDebug('Click not logged: no button pressed');return true;}
if(element!==null&&element.tagName.toLowerCase()==='iframe'){if(element.sourceIndex===unnatiClicksLastIframe){showunnatiClicksDebug('Click not logged: same iframe (a click on iframe opens a popup and popup is closed => iframe gets the focus again)');return true;}
unnatiClicksLastIframe=element.sourceIndex;}
else{unnatiClicksLastIframe=-1;}
var x=e.clientX;var y=e.clientY;var w=unnatiClicksDocument.clientWidth!==undefined?unnatiClicksDocument.clientWidth:window.innerWidth;var h=unnatiClicksDocument.clientHeight!==undefined?unnatiClicksDocument.clientHeight:window.innerHeight;var scrollx=window.pageXOffset===undefined?unnatiClicksDocument.scrollLeft:window.pageXOffset;var scrolly=window.pageYOffset===undefined?unnatiClicksDocument.scrollTop:window.pageYOffset;if(x>w||y>h){showunnatiClicksDebug('Click not logged: out of document (should be a click on scrollbars)');return true;}
clickTime=new Date();if(clickTime.getTime()-unnatiClicksTime<1000){showunnatiClicksDebug('Click not logged: at least 1 second between clicks');return true;}
unnatiClicksTime=clickTime.getTime();if(unnatiClicksQuota>0){unnatiClicksQuota=unnatiClicksQuota-1;}
params='s='+unnatiClicksSite+'&g='+unnatiClicksGroup+'&x='+(x+scrollx)+'&y='+(y+scrolly)+'&w='+w+'&b='+unnatiClicksBrowser+'&c='+c+'&random='+Date();showunnatiClicksDebug('Ready to send click data...');var sent=false;if(unnatiClicksServer.substring(0,4)!=='http'){var xmlhttp=false;try{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch(er){try{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
catch(oc){xmlhttp=null;}}
if(!xmlhttp&&typeof XMLHttpRequest!==undefined){xmlhttp=new XMLHttpRequest();}
if(xmlhttp){if(unnatiClicksDebug===true){xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState===4){if(xmlhttp.status===200){showunnatiClicksDebug('Click recorded at '+unnatiClicksServer+' with the following parameters:<br />x='+(x+scrollx)+' ('+x+'px from left+'+scrollx+'px of horizontal scrolling)<br />y='+(y+scrolly)+' ('+y+'px from top+'+scrolly+'px of vertical scrolling)<br />width='+w+'<br />browser='+unnatiClicksBrowser+'<br />click='+c+'<br />site='+unnatiClicksSite+'<br />group='+unnatiClicksGroup+'<br /><br />Server answer: '+xmlhttp.responseText);}
else if(xmlhttp.status===404){showunnatiClicksDebug('click.php was not found at: '+(unnatiClicksServer!==''?unnatiClicksServer:'/unnatiClicks/click.php')+' please set unnatiClicksServer value');}
else{showunnatiClicksDebug('click.php returned a status code '+xmlhttp.status+' with the following error: '+xmlhttp.responseText);}
unnatiClicksLocalWait=0;}};}
xmlhttp.open('GET',unnatiClicksServer+'?'+params,true);xmlhttp.setRequestHeader('Connection','close');xmlhttp.send(null);sent=true;}}
if(sent===false){if(unnatiClicksDebug===true){showunnatiClicksDebug('Click recorded at '+unnatiClicksServer+' with the following parameters:<br />x='+(x+scrollx)+' ('+x+'px from left+'+scrollx+'px of horizontal scrolling)<br />y='+(y+scrolly)+' ('+y+'px from top+'+scrolly+'px of vertical scrolling)<br />width='+w+'<br />browser='+unnatiClicksBrowser+'<br />click='+c+'<br />site='+unnatiClicksSite+'<br />group='+unnatiClicksGroup+'<br /><br />Server answer:<br />'+'<iframe src="'+unnatiClicksServer+'?'+params+'" width="700" height="60"></iframe>');}
else{var unnatiClicksImg=new Image();unnatiClicksImg.src=unnatiClicksServer+'?'+params;}}
var now=new Date();unnatiClicksLocalWait=now.getTime()+unnatiClicksWait;while(unnatiClicksLocalWait>now.getTime()){now=new Date();}}
catch(err){showunnatiClicksDebug('An error occurred while processing click (Javascript error): '+e.message);}
return true;}
function initunnatiClicks(){if(unnatiClicksDebug===true){document.write('<div id="unnatiClicksDebuggerDiv" style="padding:5px;display:none;position:absolute;top:10px;left:10px;border:1px solid #888;background-color:#eee;z-index:99;"><strong>unnatiClicks debug: <a href="#" onmouseover="document.getElementById(\'unnatiClicksDebuggerDiv\').style.display=\'none\';return false">Rollover to close</a></strong><br /><br /><span id="unnatiClicksDebuggerSpan"></span></div>');}
if(unnatiClicksGroup===''||unnatiClicksServer===''){showunnatiClicksDebug('unnatiClicks NOT initialised: either unnatiClicksGroup or unnatiClicksServer is empty');return false;}
domain=window.location.href.match(/http:\/\/[^/]+\//);if(domain!==null&&unnatiClicksServer.substring(0,domain[0].length)===domain[0]){unnatiClicksServer=unnatiClicksServer.substring(domain[0].length-1,unnatiClicksServer.length);}
if(document.addEventListener){document.addEventListener('mousedown',catchunnatiClicks,false);}
else if(document.attachEvent){document.attachEvent('onmousedown',catchunnatiClicks);}
iFrames=document.getElementsByTagName('iframe');for(i=0;i<iFrames.length;i++){if(document.addEventListener){iFrames[i].addEventListener('focus',catchunnatiClicks,false);}
else if(document.attachEvent){iFrames[i].attachEvent('onfocus',catchunnatiClicks);}}
unnatiClicksDocument=(document.documentElement!==undefined&&document.documentElement.clientHeight!==0)?document.documentElement:document.body;var b=navigator.userAgent!==undefined?navigator.userAgent.toLowerCase().replace(/-/g,''):'';unnatiClicksBrowser=b.replace(/iceweasel/,'firefox').replace(/^.*(firefox|kmeleon|safari|msie|opera).*$/,'$1');if(b===unnatiClicksBrowser||unnatiClicksBrowser===''){unnatiClicksBrowser='unknown';}
showunnatiClicksDebug('unnatiClicks initialised with:<br />site='+unnatiClicksSite+'<br />group='+unnatiClicksGroup+'<br />server='+unnatiClicksServer+'<br />quota='+(unnatiClicksQuota===-1?'unlimited':unnatiClicksQuota)+'<br /><br />browser='+unnatiClicksBrowser);}