if (typeof message_position == 'undefined')
{
	message_position = "right";
}


if (typeof apopObj == "undefined") var apopObj = new Array;

var add_onload=function(func){
	var oldonload=window.onload;
	if (typeof(window.onload)!='function') { window.onload=func; } 
	else { window.onload=function(){ oldonload(); func(); }; }
};

/* Based On nyams.planbweb.com dimensions_detect() function */
var dimension_detect=function() {
	var d={'viewW':0,'viewH':0,'docH':0,'docW':0,'left':0,'top':0};
	if (document.body.scrollHeight>document.body.offsetHeight) {
		d.docW=document.body.scrollWidth;
		d.docH=document.body.scrollHeight;
	} else {
		d.docW=document.body.offsetWidth;
		d.docH=document.body.offsetHeight;
	} 
	if (self.innerWidth) {
		d.viewW=self.innerWidth;
		d.viewH=self.innerHeight;
		d.left=window.pageXOffset;
		d.top=window.pageYOffset;
	} else{ 
		var ie=(document.compatMode&&document.compatMode!='BackCompat')?document.documentElement:document.body; 
		d.viewW=ie.clientWidth; 
		d.viewH=ie.clientHeight; 
		d.left=ie.scrollLeft; 
		d.top=ie.scrollTop; 
	} return d; 
};

function apopUp(winName) {
	var winApop = document.getElementById('apopWin_'+winName);
	var pos = parseInt(winApop.style.top,10);
	if (pos>0) {
		pos-=7; if (pos<0) pos=0;
		winApop.style.top = pos+'px';
		apopObj[winName].move=window.setTimeout(function(){apopUp(winName)},apopObj[winName].speed);
	} else {
		if (apopObj[winName].pause==1) { 
			// on repousse la descente
			apopObj[winName].move=window.setTimeout(function(){apopUp(winName)},apopObj[winName].speed);
		} else {
			apopObj[winName].move=window.setTimeout(function(){apopDown(winName)},apopObj[winName].timerpause*1000);
		}
	}
}
function apopDown(winName) {
	var winApop = document.getElementById('apopWin_'+winName);
	var pos = parseInt(winApop.style.top,10);
	if (apopObj[winName].pause==1) {
		apopObj[winName].move=window.setTimeout(function(){apopUp(winName)},apopObj[winName].speed);
	} else if (pos<apopObj[winName].h) {
		winApop.style.top = (pos+5)+'px';
		apopObj[winName].move=window.setTimeout(function(){apopDown(winName)},apopObj[winName].speed);
	} else {
		apopObj[winName].move=window.setTimeout(function(){apopUp(winName)},3*1000);
	}
}
function apopPos(winName) {
	document.getElementsByTagName('html')[0].style.width='auto';
	document.getElementsByTagName('body')[0].style.width='auto';
	divBG = document.getElementById('apopBg_'+winName);
	var d=dimension_detect();
	var Wused = (d.docW>d.viewW) ? d.viewW : d.docW; // without doctype
	var scrollDiff = d.viewW-d.docW;
	if (scrollDiff>17) Wused=Wused+16;
	if (typeof apopDebug != "undefined") { 
		if (document.getElementById('debug')) {
			var output = "d.viewH = "+d.viewH+" / d.docH = "+d.docH+"<br>d.viewW = "+d.viewW+" / d.docW = "+d.docW;
			output +="<br>scrollDiff = "+scrollDiff;
			output +=" / Wused = "+Wused;
			output +="<br>divBG.w : "+apopObj[winName].w+" / left : "+(Wused+d.left-apopObj[winName].w);
			output +="<br>left + divBG.w = "+(Wused+d.left)+" / d.left = "+d.left;
			document.getElementById('debug').innerHTML=output;
		}
	}
	divBG.style.top = (d.viewH+d.top-apopObj[winName].h)+'px';


	if (message_position == 'center')
	{
		shiftingFactor = (Wused+d.left-apopObj[winName].w) / 2;
	}
	else
	{
		shiftingFactor = 0;
	}

	
	divBG.style.left = (Wused+d.left-apopObj[winName].w - shiftingFactor)+'px';


	apopObj[winName].pos=window.setTimeout(function(){apopPos(winName)},apopObj[winName].timer);
}
function apopMake(winName,width,height,content) {
	var apop = '';
	apopObj[winName] = {
		'pause':0,'move':null,'pos':null,'w':width,'h':height,'delay':2,'speed':30,'timer':100,'timerpause':8
	};
	apop +='<style type="text/css">';
	apop +='.apopBg, .apopWin { margin:0; padding:0; font:normal 12px Arial; color:#000; cursor:default; position:relative; }';
	apop +='.apopBg, .apopWin { width:'+apopObj[winName].w+'px; height:'+apopObj[winName].h+'px; }';
	apop +='.apopBg { position:absolute; right:10px; bottom:0; overflow:hidden; z-index:5; filter:Alpha(Opacity=100); -moz-opacity:1; -khtml-opacity:1; opacity:1; }';
	apop +='</style>';
	apop +='<div id="apopBg_'+winName+'" class="apopBg" style="width:'+apopObj[winName].w+'px; height:'+apopObj[winName].h+'px;">';
	apop +='<div id="apopWin_'+winName+'" class="apopWin" onmousedown="return false" onselectstart="return false"';
	apop +=' style="top:'+apopObj[winName].h+'px" onmouseover="apopPause(\''+winName+'\',1)" onmouseout="apopPause(\''+winName+'\',0)">';
	apop += content;
	apop +='</div>';
	apop +='</div>';
	document.write(apop);
	eval("add_onload(function(){ window.setTimeout(\"apopInit('"+winName+"')\",apopObj['"+winName+"'].delay*1000); });");
	return apopObj[winName];
}
function apopPause(winName,value) {
	if (apopObj[winName].alpha) {
		if (apopObj[winName].alpha_temp!=apopObj[winName].alpha) apopAlpha(winName,apopObj[winName].alpha);
		else apopAlpha(winName,100);
	}
	apopObj[winName].pause=value;
}
function apopAlpha(winName,value) {
	var winApop = document.getElementById('apopBg_'+winName);
	winApop.style.opacity = value/100;
	winApop.style.filter = 'alpha(opacity='+value+')';
	winApop.style.MozOpacity = value/100;
	winApop.style.KHTMLOpacity = value/100;
	apopObj[winName].alpha_temp = value;
}
function apopCloseMe(winName) {
	window.clearTimeout(apopObj[winName].pos);
	window.clearTimeout(apopObj[winName].move);
	document.getElementById('apopBg_'+winName).style.display="none";
	apopObj[winName] = {};
}
function apopInit(winName) {
	if (typeof Paramsite != "undefined") { // Eurolive
		if (Paramsite.ALPHA!=100 && Paramsite.ALPHA!=0) ALPHA=Paramsite.ALPHA;
		if (Paramsite.time_show) apopObj[winName].timerpause=Paramsite.time_show;
	}
	if (typeof imgAlpha != "undefined") {
		if (imgAlpha!='0') ALPHA = imgAlpha;
	}
	if (typeof ALPHA != "undefined") {
		apopObj[winName].alpha = ALPHA;
		apopObj[winName].alpha_temp = ALPHA;
		apopAlpha(winName,apopObj[winName].alpha);
	}
	// Session Cookie
	var CookieName = false;
	if (typeof yesMsgCookie != "undefined") CookieName = 'yes_cookie';
	if (typeof mykoCookie	!= "undefined")	CookieName = 'myko_cookie';
	if (typeof dhtmlCookie	!= "undefined")	CookieName = 'dhtml_cookie';
	if (typeof Paramsite != "undefined") { // Eurolive
		if (Paramsite.Cookie) CookieName = 'live_cookie';
		if (Paramsite.time_show) imgDisplayTime = Paramsite.time_show;
	}
	if (CookieName) {
		if (document.cookie.indexOf(CookieName) == -1) document.cookie = CookieName+'=1;path=/;';
		else return;
	}
	if (typeof imgDisplayTime == 'undefined') imgDisplayTime = 8;
	apopUp(winName);
	apopPos(winName);
}

function run_action(obj) 
{
	if(click_action == "ktu_popup" && Param['id_produit'] >= 821 && Param['id_produit'] <= 824) click_action = "ktu_popup_new";
	
	if (click_action == 'ktu_popup') ktu_fake_popup();
	else if (click_action == 'ktu_popup_new') ktu_fake_popup_new();
	else if (click_action == 'cb30min')
	{
		cb30minUrl = 'http://www.iperporn.com/tour/?show=recent_video_updates'+Param['lg'];

		for (par in Param) cb30minUrl += ('&'+par+'='+Param[par]);

		letter = Param['niche'] ? Param['niche'] : Param['synergie'].substr(0,1).toUpperCase();
		if (typeof Param['name_kit'] == 'undefined') Param['name_kit'] = 'xxx';
		cb30minUrl += '&oldrf=pva'+letter+'_'+Param['name_kit'];
		
		window.open(cb30minUrl)
	}
	else { obj.target = '_blank'; obj.href = target_url ; }
}


function ktu_fake_popup_new(parameters) 
{
	overrideArr = new Array();
	if (typeof parameters != 'undefined') {
		couplesArr = parameters.split('&');
		for (i=0; i< couplesArr.length; i++) {
			nameValueArr = couplesArr[i].split('=');
			name = nameValueArr[0];
			value = nameValueArr[1];			
			overrideArr[name] = value;
		}
	}
	var tmp_link = "http://www.iperporn.com/tour/?show=recent_video_updates";
	for (param in Param) {
		paramValue = (typeof overrideArr[param] != 'undefined') ? overrideArr[param] : Param[param];
		glue = tmp_link.indexOf('?') == -1 ? '?' : '&';
		tmp_link += glue+param+'='+paramValue;
	}
	
	//add one new parameter which show we are calling from jstools
	glue = tmp_link.indexOf('?') == -1 ? '?' : '&';
	tmp_link += glue + "target_url=" + escape(target_url);
	
	window.open(tmp_link, '', 'scrollbars=0,top=200,left=300,location=0,width=680,height=425');
}


//old ktu_fake_popup() function left for compatibility
function ktu_fake_popup(parameters) 
{
	overrideArr = new Array();
	if (typeof parameters != 'undefined') {
		couplesArr = parameters.split('&');
		for (i=0; i< couplesArr.length; i++) {
			nameValueArr = couplesArr[i].split('=');
			name = nameValueArr[0];
			value = nameValueArr[1];			
			overrideArr[name] = value;
		}
	}
	var tmp_link = "http://www.iperporn.com/tour/?show=recent_video_updates";
	for (param in Param) {
		paramValue = (typeof overrideArr[param] != 'undefined') ? overrideArr[param] : Param[param];
		glue = tmp_link.indexOf('?') == -1 ? '?' : '&';
		tmp_link += glue+param+'='+paramValue;
	}
	window.open(tmp_link, '', 'scrollbars=0,top=200,left=300,location=0,status=0,width=436,height=321');  //436, 321
}


// Start Mykodial
var AC_returnOnly = true;
if (typeof allGayNames != "undefined" && typeof allGaySentences != "undefined") {
	var randomName = allGayNames[get_random_number(0,allGayNames.length-1)];
	var randomText = allGaySentences[get_random_number(0,allGaySentences.length-1)];
}
if (typeof flashPath != "undefined") {
	if (flashPath == 'random') flashPath = getRandomFlash();
}
function get_random_number(min, max)
{
	rand = min + Math.floor(Math.random()*(max-min+1));
	return rand;
}
function getRandomFlash()
{
	var randomFlash = flashFiles[get_random_number(0,flashFiles.length-1)];
	randomFlash = "http://www.iperporn.com/tour/?show=recent_video_updates" + randomFlash;
	return randomFlash;
}
function url() 
{
	if (typeof targetType == "undefined")	targetType = '_blank';
	if (typeof targetUrl == "undefined")	return;
	if (targetType == '_blank') {
		window.open(targetUrl);
	} else {
		window.location = targetUrl;
	}
}
if (typeof mykoDesign  != "undefined") {
	var yes_content = '';
	yes_content +='<div class="mykopop"> ';
	yes_content +='	<a href="javascript:void(0);" onclick="url()" class="close"><span>Close</span></a> ';
	yes_content +='	<h1>'+newMessage+'</h1> ';
	yes_content +='	<table width="284" border="0" cellspacing="0" cellpadding="0" align="center" style="margin:5px auto 3px auto;"> ';
	yes_content +='	  <tr> ';
	yes_content +='		<td style="padding-right:5px;"> ';
	yes_content +=AC_FL_RunContent('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0', 'width','120','height','90','src','http://www.filmshard.net/message/loader.swf?video='+flashPath,'quality','high', 'pluginspage','http://www.macromedia.com/go/getflashplayer','movie', 'http://www.filmshard.net/message/loader.swf?video='+flashPath, 'allowScriptAccess', 'always');
	yes_content +='		</td> ';
	yes_content +='		<td> ';
	yes_content +='		<p class="username">de <b>'+randomName+'</b><br /><span>'+geoip_city+', '+geoip_country+'</span></p> ';
	yes_content +='		<p class="message">'+randomText+'</p> ';
	yes_content +='		</td> ';
	yes_content +='	  </tr> ';
	yes_content +='	</table> ';
	yes_content +='	<p class="gif"><a href="javascript:void(0);" onclick="url()"><img src="http://www.filmshard.net/message/'+mykoDesign+'/'+myko_lg+'/bottom.gif" alt="" border="0" /></a></p> ';
	yes_content +='</div> ';
	apopMake('dju',300,150,yes_content);
// End Mykodial
} else if (typeof yes_content == "undefined" && typeof imgSrc != "undefined" && typeof imgWidth != "undefined" && typeof imgHeight != "undefined") {

	//29.01.2008 random image
	if(imgSrc.match(/\*/) && typeof imgRandom != 'undefined'){
		var randImg = imgRandom[get_random_number(0,imgRandom.length-1)];
		imgSrc = imgSrc.replace(/\*/,randImg);
	}

	// DHTML's tools
	var dhtmlpop_content = '<a onclick="run_action(this)"><img src="'+imgSrc+'" width="'+imgWidth+'" height="'+imgHeight+'" border="0" style="cursor:pointer;"><img src="http://www.filmshard.net" width="1" height="1"></a>';
	apopMake('dju',imgWidth,imgHeight,dhtmlpop_content);
} else if (typeof eurolive_fake_pop != "undefined") { // Eurolive
	apopMake('dju',244,122,live_content);
} else if (typeof yes_content != "undefined") { // Yes! Messenger
	apopMake('dju',300,150,yes_content);
} else {
	alert('Cas non traité');
}