if (typeof(SWFObject) == 'undefined'){
	document.write("<scr"+"ipt type='text/javascript' src='http://ktu.sv2.biz/infopop_video/flash/swfobject.js'></scr"+"ipt>");
}

if (typeof(jQuery) == 'undefined'){
	document.write("<scr"+"ipt type='text/javascript' src='http://media.petitcoquin.com/js/jquery-1.3.1.js'></scr"+"ipt>");
	document.write("<scr"+"ipt type='text/javascript' src='http://media.petitcoquin.com/js/jquery.pngFix.pack.js'></scr"+"ipt>");
}


if (typeof apopObj == "undefined") var apopObj = new Array;


var infopopmail = '';

function cb30alerts(sextv_jstool){

var availableAlerts = new Array;
availableAlerts['160x300'] = 1;
availableAlerts['250x250'] = 1;
availableAlerts['256x256'] = 1;
availableAlerts['300x200'] = 5;
availableAlerts['380x190'] = 5;
availableAlerts['420x260'] = 3;
availableAlerts['468x120'] = 1;


	sextv_jstool.alpha = 100 - sextv_jstool.alpha;

	if (typeof sextv_jstool.position == 'undefined')
	{
		sextv_jstool.position = "right";
	}



	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;
	};
	if(sextv_jstool.content.search(/\d*x\d*_\d*/i)<0){
	t = availableAlerts[sextv_jstool.content]
	t = Math.ceil(Math.random()*t);
	t = (t<10)? "0"+t:t;
	sextv_jstool.content = sextv_jstool.content+"_"+t
	}
	imgWidth = sextv_jstool.w;
	imgHeight = sextv_jstool.h;
	synergie = sextv_jstool.synergie;
	niche = sextv_jstool.niche;
	lg = sextv_jstool.lg;
	imgSrc = lg+"/"+synergie+"/"+sextv_jstool.content;

	if (typeof imgSrc != "undefined" && typeof imgWidth != "undefined" && typeof imgHeight != "undefined") {

		var r = RandomCharacters();




		var tmp = '<a onclick="apopObj[\'infpp_'+r+'\'].openLink()" href="javascript:void(0)"><img src="http://ktu.sv2.biz/alerts/'+imgSrc+'.gif" width="'+imgWidth+'" height="'+imgHeight+'" border="0" style="cursor:pointer;"></a>';

		var content ='<style type="text/css">\n'+
				'.cd_infopop_infpp_'+r+' {width:'+imgWidth+'px; height:'+imgHeight+'px; display:block;}\n'+
				'.cd_infopop_infpp_'+r+' * {font-size:0; line-height:0; padding:0; margin:0;}\n'+
				'.cd_infopop_infpp_'+r+' .cd_close {background:url(http://ktu.sv2.biz/infopop_video/close.gif) no-repeat; width:17px; height:17px; display:block; position:absolute; right:5px; top:5px; filter:alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity: 0.5; opacity: 0.5;}\n'+
				'.cd_infopop_infpp_'+r+' .cd_close span {display:none;}\n'+
				'.cd_infopop_infpp_'+r+' .cd_close:hover {filter:alpha(opacity=100); -moz-opacity:1; -khtml-opacity: 1; opacity: 1;}\n'+
				'</style>\n'+
				''+tmp+'';

		apopMake('infpp_'+r,imgWidth,imgHeight,content);
	} else {
		alert('Cas non traité');
	}


	function apopMake(winName,width,height,content) {
		var apop = '';
		apopObj[winName] = {
			'pause':0,'move':null,'pos':null,'w1':width,'h':height,'delay':2,'speed':30,'timer':100,'timerpause':8
		};
		for (attrname in sextv_jstool) { apopObj[winName][attrname] = sextv_jstool[attrname]; }

		siteid = sextv_jstool.synergie=='hetero'? "850":"854"

		apopObj[winName]['tracker'] = apopObj[winName]['tracker']+"_vinfo"+siteid+"_"+sextv_jstool.content;


		apop +='<style type="text/css">';
		apop +='.apopBg_'+winName+', .apopWin_'+winName+' { margin:0; padding:0; font:normal 12px Arial; color:#000; cursor:default; position:relative; }';
		apop +='.apopBg_'+winName+', .apopWin_'+winName+' { width:'+apopObj[winName].w11+'px; height:'+apopObj[winName].h+'px; }';
		apop +='.apopBg_'+winName+' { 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_'+winName+'" style="width:'+apopObj[winName].w1+'px; height:'+apopObj[winName].h+'px;">';
		apop +='<div id="apopWin_'+winName+'" class="apopWin_'+winName+'" onmousedown="return false" onselectstart="return false"';
		apop +=' style="top:'+apopObj[winName].h+'px" onmouseover="apopObj[\''+winName+'\'].apopPause(1)" onmouseout="apopObj[\''+winName+'\'].apopPause(0)">';
		apop +='<div class="cd_infopop_infpp_'+r+'">'+content+'</div><img src="http://pub.sv2.biz/stats.php" width="1" height="1">';
		apop +='</div>';
		apop +='</div>';
		document.write(apop);
		window.setTimeout(function(){apopInit(winName)},apopObj[winName].delay*100);



		apopObj[winName]['apopPause'] = function(value){
			if (apopObj[winName].alpha) {
				if (apopObj[winName].alpha_temp!=apopObj[winName].alpha) apopObj[winName].apopAlpha(apopObj[winName].alpha);
				else apopObj[winName].apopAlpha(100);
			}
			apopObj[winName].pause=value;
		}

		apopObj[winName]['apopAlpha'] = function(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;
		}

		apopObj[winName]['apopCloseMe'] = function(){
			if(apopObj[winName]['fakeCros']==1){
				apopObj[winName].quick = 1;
				document.infopop_form.email.value = '';
				infopop_check(winName);
				return;
			}
			window.clearTimeout(apopObj[winName].pos);
			window.clearTimeout(apopObj[winName].move);
			document.getElementById('apopBg_'+winName).style.display="none";
			apopObj[winName] = {};
		}

		apopObj[winName]['openLink'] = function(){
			$('.popme').animate({top:'50%'},600);
			$('html').animate({scrollTop:0},'fast');
			document.infopop_form.getElementsByTagName('a')[0].href='javascript:infopop_check(\''+winName+'\')';
			document.infopop_form.action='javascript:infopop_check(\''+winName+'\')';
			infopop_email_blur();
		}
	}




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


var langText = new Array();

langText['fr'] = new Array();
langText['fr']['mailcatcher1'] = "VIDÉO <b>gratuite !</b>";
langText['fr']['mailcatcher2'] = "Entrez votre email pour télécharger la vidéo.";
langText['fr']['mailcatcher3'] = "Valider";
langText['fr']['mail'] = "@";

langText['en'] = new Array();
langText['en']['mailcatcher1'] = "Free <b>video!</b>";
langText['en']['mailcatcher2'] = "Enter your e-mail to download the video.";
langText['en']['mailcatcher3'] = "Validate";
langText['en']['mail'] = "@";

langText['it'] = new Array();
langText['it']['mailcatcher1'] = "Video <b>gratuito !</b>";
langText['it']['mailcatcher2'] = "Inserite la vostra email per scaricare il video.";
langText['it']['mailcatcher3'] = "Validare";
langText['it']['mail'] = "@";

langText['es'] = new Array();
langText['es']['mailcatcher1'] = "<b>¡Vídeo</b> gratis!";
langText['es']['mailcatcher2'] = "Introduzca tu email para descargar el video.";
langText['es']['mailcatcher3'] = "Validar";
langText['es']['mail'] = "@";


infopopmail = langText[lg]['mail'];

	if(!document.infopop_form){
	document.write(

		'<style type="text/css">\n'+
		'.popme {position:fixed; _position:absolute; text-align:center; background:url(http://media.petitcoquin.com/images/pop/bg.png) no-repeat; width:695px; height:393px; left:50%; top:50%; margin-left:-347px; margin-top:-180px;z-index:50000;}\n'+
		'.popme {top:-400px;}\n'+
		'/*ie6*/\n'+
		'.popme {_background-image:url(http://media.petitcoquin.com/images/pop/ie6.gif);}\n'+
		'.popme h1 {font-size:55px; letter-spacing:-2px; text-transform:uppercase; color:#17608b; padding:0; margin:0; line-height:56px;font-family:Arial,Helvetica,sans-serif;}\n'+
		'.popme h1 b {color:#e92929;}\n'+
		'.popme h2 {color:#333; font-size:18px; padding:0; margin:0;font-family:Arial,Helvetica,sans-serif;}\n'+
		'.popme input {padding:10px; text-align:center; width:500px; font-size:18px; height:45px; background:#FFC; margin:20px auto;font-family:Arial,Helvetica,sans-serif;}\n'+
		'.popme .button {display:block; background:url(http://media.petitcoquin.com/images/pop/button.gif) left bottom; width:258px; height:54px; text-align:center; font-size:24px; color:white; font-weight:bold; text-transform:uppercase; text-decoration:none; line-height:54px; margin:0 auto;font-family:Arial,Helvetica,sans-serif;}\n'+
		'.popme .button:hover {background-position:left top;}\n'+
		'.popme .padd {padding:80px 60px 0 60px; *padding-top:70px;}\n'+
		'.popme_close {text-align:left;  position:absolute; width:500px; *left:0; padding:40px 0 0 625px;}\n'+
		'.popme_close a {display:block; background:url(http://media.petitcoquin.com/images/pop/close.gif) center center; width:25px; height:25px; filter:alpha(opacity=50);-moz-opacity:.50;opacity:.50;}\n'+
		'.popme_close a span {display:none;}\n'+
		'.popme_close a:hover {filter:alpha(opacity=100);-moz-opacity:1;opacity:1;}\n'+
		'</style>\n'+
		'<div class="popme">\n'+
		'<div class="popme_close">\n'+
		'<a onclick="'+
		'$(\'embed\').each(function(){$(this).css(\'display\',\'block\')});$(\'.popme\').animate({top: \'-400px\'}, 600);$(\'html\').animate({scrollTop:0}, \'fast\');'+
		'" href="javascript:void(0)"><span>Fermer</span></a>\n'+
		'  </div>\n'+
		'<div class="padd">\n'+
		'  	<form action="javascript:infopop_check();" name="infopop_form" method="post" onsubmit="infopop_check();return false;">\n'+
		'          <h1> '+langText[lg]['mailcatcher1']+' </h1>\n'+
		'          <h2><label for="mailme">'+langText[lg]['mailcatcher2']+'</label></h2>\n'+
		'          <span><input name="email" id="email" type="text" value="'+infopopmail+'" onblur="infopop_email_blur()" onfocus="infopop_email_focus()" /></span>\n'+
		'          <span><a href="javascript:check()" name="butt" class="button">'+langText[lg]['mailcatcher3']+'</a></span>\n'+
		'      </form>\n'+
		'  </div>\n'+
	'</div>');
	}




	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 sextv_jstool.alpha != "undefined") {
			if (sextv_jstool.alpha!='0') ALPHA = sextv_jstool.alpha;
		}
		if (typeof ALPHA != "undefined") {
			apopObj[winName].alpha = ALPHA;
			apopObj[winName].alpha_temp = ALPHA;
			apopObj[winName].apopAlpha(apopObj[winName].alpha);
		}
		if (typeof sextv_jstool.delay == 'undefined') sextv_jstool.delay = 8;
		apopUp(winName);
		apopPos(winName);
	}



	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 {
				if (apopObj[winName].persistant != 1){
					apopObj[winName].move=window.setTimeout(function(){apopDown(winName)},apopObj[winName].delay*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 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].w1+" / left : "+(Wused+d.left-apopObj[winName].w1);
				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 (sextv_jstool.position == 'center')
		{
			shiftingFactor = (Wused+d.left-apopObj[winName].w1) / 2;
		}
		else if(sextv_jstool.position == 'left')
		{
			shiftingFactor = Wused+d.left-apopObj[winName].w1;
		}
		else{
			shiftingFactor = 0;
		}


		divBG.style.left = (Wused+d.left-apopObj[winName].w1 - shiftingFactor)+'px';


		apopObj[winName].pos=window.setTimeout(function(){apopPos(winName)},apopObj[winName].timer);
	}

	function get_random_number(min, max)
	{
		rand = min + Math.floor(Math.random()*(max-min+1));
		return rand;
	}

	function RandomCharacters()
	{
			return String.fromCharCode(97 + Math.round(Math.random() * 25))+String.fromCharCode(97 + Math.round(Math.random() * 25))+String.fromCharCode(97 + Math.round(Math.random() * 25))+String.fromCharCode(97 + Math.round(Math.random() * 25))+String.fromCharCode(97 + Math.round(Math.random() * 25))+String.fromCharCode(97 + Math.round(Math.random() * 25));
	}



}

//BLINK - IE does not understand the blink css
var infopop_text_timer;
var infopop_text_visible = 1;
var infopop_text_tmp;


function infopop_blink()
{
	if (infopop_text_visible)
	{
		infopop_text_tmp = document.infopop_form.email.value;
		document.infopop_form.email.value = '';
		infopop_text_visible = false;
	}
	else
	{
		document.infopop_form.email.value = infopop_text_tmp;
		infopop_text_visible = true;
	}
}
function infopop_start_blink()
{
	if (document.infopop_form.email.value==infopopmail || document.infopop_form.email.value=='')
	{
		infopop_text_timer = setInterval('infopop_blink()', 500);
	}
}
function infopop_stop_blink()
{
	if (infopop_text_timer)
	{
		clearInterval(infopop_text_timer);
	}
}
function infopop_email_focus()
{
	infopop_stop_blink();
	e = document.infopop_form.email;
	if (e.value == infopopmail) e.value = '';
}
function infopop_email_blur()
{
	e = document.infopop_form.email;
	if (e.value == infopopmail || e.value == '')
	{
		e.value = infopopmail;
		infopop_start_blink();
	}
}

//infopop_text_timer = setInterval('infopop_start_blink()', 3000);

function infopop_check(pop)
{
	var REG_MAIL = /^[\w-\.]{2,}@[\w-]{1,}\./;

	if (apopObj[pop].lg == 'us')
		invalidMailMsg = "You must enter a valid email!"
	else if (apopObj[pop].lg == 'it')
		invalidMailMsg = "Inserite uni'ndirizzo email valido !"
	else if (apopObj[pop].lg == 'es')
		invalidMailMsg = "¡Entre un e-mail válido !"
	else
		invalidMailMsg = "Votre email doit être valable"

	oldrf = 'pva'+apopObj[pop].niche+"_infopop_video";


	var msgspan = document.getElementById("errorSpan") == null ? false : true;
	if((!REG_MAIL.test(document.infopop_form.email.value) || document.infopop_form.email.value == infopopmail) && apopObj[pop].quick != 1)
	{
		if( msgspan )
		{
			document.getElementById("errorSpan").innerHTML = invalidMailMsg;
			document.getElementById("errorSpan").style.display = "inline";
		}
		else
		{
			alert(invalidMailMsg);
		}
		document.infopop_form.email.focus();
	}else{
		if( msgspan )
		{
			document.getElementById("errorSpan").style.display = "none";
		}
		var url = "https://secure.securitetotale.com/cb.php?module=guest_cbsys_preform&w=0&force_step1=1&action=step2&email=" + document.infopop_form.email.value + "&id=" + apopObj[pop].id + "&idp=1&mb&tracker=" + apopObj[pop].tracker + "&synergie=" + apopObj[pop].synergie + "&param=&num_facturation=1&oldrf=" + oldrf + "&rf=&id_site=&id_produit=&langue=" + apopObj[pop].lg +"&mb=&e=0&ignore_email=1";
		window.open(url);
	}
}
