
// PHP Path
var w_php = 'http://ulala.online.fr/lapis/w.php';

// Domain
var domain = document.domain;

// Domain Check
var domainFlag = (w_php.match(domain)) ? true : false;

// Ajax Object
var xmlhttp = createXMLHttp();

// Mode
var args = (xmlhttp) ? '?mode=ajax' : '?mode=js';

// Referrer
var ref = parent.document.referrer;

if(ref){ref = (ref.match(domain)) ? '' : ref.replace(/&/g,"::");}

args += '&ref=' + ref;

// Document Title
//args += '&title=' + encodeURIComponent(document.title);

// Document URL
args += '&url=' + document.URL;

// Color Depth
args += '&cd=' + screen.colorDepth;

// Screen Width
args += '&sw=' + screen.width;

// Screen Height
args += '&sh=' + screen.height;

// Client Width
var cw = (window.innerWidth) ? parent.window.innerWidth : '';

if(!cw){cw = (document.documentElement.clientWidth) ? parent.document.documentElement.clientWidth : '';}
if(!cw){cw = (document.body.clientWidth) ? parent.document.body.clientWidth : '';}

args += '&cw=' + cw;

// Client Height
var ch = (window.innerHeight) ? parent.window.innerHeight : '';

if(!ch){ch = (document.documentElement.clientHeight) ? parent.document.documentElement.clientHeight : '';}
if(!ch){ch = (document.body.clientHeight) ? parent.document.body.clientHeight : '';}

args += '&ch=' + ch;

// Cookie Enabled
var co = (navigator.cookieEnabled) ? navigator.cookieEnabled : '';

args += '&co=' + co;

// Request URL
var request = w_php + args;

// Ajax Mode
if(xmlhttp && domainFlag)
{
	
	// Ajax Request
	requestLapis(request);
	
	////////////////////////////////////////////////////////////
	
	// Set Out Links Event
	var obj,link;
	
	var linksLength = document.getElementsByTagName('a').length;
	
	for(i = 0;i < linksLength;i++)
	{
		
		obj = document.getElementsByTagName('a')[i];
		
		link = obj.href;
		
		if(link.match(domain)){continue;}
		
		obj.onclick = jumpOutLink;
		
		
	}
	
}

// <img> Mode
else{document.write('<img width="0" height="0" src="' + request + '" style="visibility:hidden;">');}

//////////////////////////////////////////////////////////////

function jumpOutLink()
{
	
	var url = encodeURIComponent(this.href);
	
	var word = encodeURIComponent(this.innerHTML);
	
	var requestOut = w_php + '?mode=out&url=' + url + '&word=' + word;
	
	requestLapis(requestOut);
	
}

//////////////////////////////////////////////////////////////

function createXMLHttp()
{
	
	try{return new ActiveXObject("Microsoft.XMLHTTP");}
	
	catch(e)
	{
		
		try{return new XMLHttpRequest();}
		
		catch(e){return null;}
		
	}
	
	return null;
	
}

//////////////////////////////////////////////////////////////

function requestLapis(requestURL)
{
	
	xmlhttp.open('GET', requestURL);
	xmlhttp.send(null);
	
}
