function $(I) { return document.getElementById(I); }
if($('q')) $('q').focus();
var a = document.getElementsByTagName('a');
var eravage = 0;
var onlink = false;
if(top != self) { top.location.href = location.href; }

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) { eval(xmlhttp.responseText); } } } } return xmlhttp; }
function sendAjax(ajax,vars) { var xmlhttp = getHTTPObject(); xmlhttp.open('POST',ajax,true); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); xmlhttp.send(vars); }

if($('video')) {
	$('video').disabled = false;
	$('video').onclick = function() {
		if($('q').value != '') document.location.href = 'videos?q='+$('q').value;
		else document.location.href = 'videos';
	} 
}

for(i = 0; i < a.length; i++) {
	if(a[i].className == 'extern') {
		if(a[i].id) {
			if(a[i].id.indexOf('/',0) != -1) {
				a[i].onclick = function () {
					sendAjax('out.php','id='+this.id);
					if(navigator.appName != 'Microsoft Internet Explorer') {
						// if(eravage == 0) window.open('http://gateway.eravage.com/rotation_pdv.php?ida=1896&id_product=1&main_id_cat=31&offer=cb302m90&rebill=0&d=0&e=1&tracker=mpe');
						eravage++;
					}
					return true;
				}
			}
		}
	}
	else if(a[i].className == 'small_disk') { a[i].onclick = function () { window.open(this.href,'_blank','toolbar=no, location=no, scrollbars=yes, resizable=yes'); return false; } }
	else if(a[i].className == 'contact') { a[i].onclick = function () { document.location.href = 'mai'+'lto:'+'contact'+'@'+'mypornengine'+'.'+'com'; return false; } }
	else if(a[i].className == 'heart') a[i].onclick = function() { if(navigator.appName != 'Microsoft Internet Explorer') window.sidebar.addPanel('MyPornEngine.com - Moteur de recherche porno !','http://www.mypornengine.com/',''); else window.external.AddFavorite('http://www.mypornengine.com/','MyPornEngine.com - Moteur de recherche porno !'); return false; }
	else if(a[i].className == 'house') a[i].onclick = function() { if(navigator.appName == 'Microsoft Internet Explorer') { this.style.behavior = 'url(#default#homepage)'; this.setHomePage('http://www.mypornengine.com/'); } else alert('Votre navigateur n\'est pas compatible avec cette option.\nSi vous souhaitez que MyPornEngine.com soit la page de démarrage de votre navigateur,\nallez dans le menu "Outils" > "Options"'); return false; }
}

function add_player(p) {
	var so = new SWFObject('./player.swf','mpl',xy[0],xy[1],'9');
	so.addParam('allowfullscreen','true');
	so.addParam('allowscriptaccess','always');
	so.addParam('wmode','transparent');
	so.addVariable('file',players[p][0]);
	so.addVariable('image',players[p][1]);
	so.addVariable('volume',volume);
	so.addVariable('controlbar','none');
	so.addVariable('autostart','true');
	so.addVariable('repeat','always');
	so.addVariable('stretching','exactfit');
	so.write('player_'+p);
}

function delete_player(p) {
	if(p > 0 && p <= 9) {
		$('player_'+p).innerHTML = '<img src="./img/play.png" id="play_'+p+'" alt="Extrait gratuit vidéo porno en streaming" />';
		$('play_'+p).style.cursor = 'pointer';
		$('play_'+p).onclick = function () {
			play_button(this.id.charAt(5));
		}
	}
}

function play_button(p) {
	delete_player(playing);
	playing = p;
	add_player(playing);
	if(volume == 100 && navigator.appName == 'Microsoft Internet Explorer') {
		window.open($('dl_'+p).href,'_blank','toolbar=no, location=no, scrollbars=yes, resizable=yes');
		self.focus();
	}
	volume = 100;
}

var playing = 0;
var volume = 0;

if($('player_1')) {
	for(i = 1; i <= 9; i++) {
		if($('player_'+i)) {
			$('play_'+i).onclick = function () {
				play_button(this.id.charAt(5));
				return false;
			}
		}
		else break;
	}
	if(xy[0] == 205) play_button(1);
	else volume = 100;
}