var timeOut = new Array();
var trade =  '';

function setTN(tn) {
	n = ((tn.src.substring((tn.src.lastIndexOf('/',tn.src.length)+1),(tn.src.length-4))*1)+1);
	if(n > 16 && tn.src.indexOf('porn.fr')) n = 1;
	if(n > 15 && tn.src.indexOf('sexedenfer.com')) n = 1;
	if(n > 12 && tn.src.indexOf('totale-defonce.com')) n = 1;
	tn.src = tn.src.substring(0,(tn.src.lastIndexOf('/',tn.src.length)+1))+n+'.jpg';
	timeOut['tn'] = setTimeout(function() { setTN(tn); },500);
}

function getHTTPObject() {
	var xmlhttp = false;
	try { xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); }
	catch(e) { xmlhttp = new XMLHttpRequest() }
	if(xmlhttp) {
		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200) {
					trade = xmlhttp.responseText;
				}
			}
		}
  	}
	return xmlhttp;
}

function sendXMLhttp(XMLfile,vars) {
	var xmlhttp = getHTTPObject();
	xmlhttp.open('POST',XMLfile,true);
	xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttp.send(vars+'&time='+Math.round((new Date().getTime())/1000));
}

sendXMLhttp('./trade.php','init=1');

if(document.getElementById && document.getElementsByTagName) {
	_div = document.getElementsByTagName('div');
	i = _div.length-1;
	for(i;i>=0;i--) {
		if(_div[i].id.indexOf('V') == 0) {
			_div[i].onmouseover = function() {
				this.style.cursor = 'pointer';
				clearTimeout(timeOut['tn']);
				var ref = this.id.substr(1,this.id.length);
				timeOut['tn'] = setTimeout(function() { setTN(document.getElementById('T'+ref)) },200);
			}
			_div[i].onmouseout = function() {
				clearTimeout(timeOut['tn']);
			}
			_div[i].onclick = function() {
				if(trade.length != 0) {
					window.open(trade);
					sendXMLhttp('./trade.php','');
					return false;
				}
				else {
					sendXMLhttp('./trade.php','');
					document.location = document.getElementById('L'+this.id.substr(1,this.id.length)).href;
					return false;
				}
			}
		}
	}
}