document.write("<scr"+"ipt src='http://ktu.sv2.biz/drag.js'></scr"+"ipt>");

if (typeof popupHeight == 'undefined') popupHeight = 247;	
if (typeof popupWidth == 'undefined')  popupWidth = 522;	
if (typeof popupTitleText == 'undefined')  popupTitleText = "<b>SEXE 100% GRATUIT</b>";
if (typeof popupTitleFont == 'undefined')  popupTitleFont = "Arial"	
if (typeof popupTitleFontSize == 'undefined')  popupTitleFontSize = "12"	
if (typeof popupTitleColor == 'undefined')  popupTitleColor = "#FFFFFF"	
if (typeof hasShadow == 'undefined')  hasShadow = 1;

var windowTop = 100;
var windowLeft=100;
var abs=0
var ord=0

var imageSource = '<a onclick="run_action(this)"><img src="'+imageSrc+'" width="'+popupWidth+'" height="'+popupHeight+'" border="0" style="cursor: pointer;"></a>';

popupWidth -= 13
popupHeight -= 13
var clicked = false;

function closePopup() 
{
	document.getElementById("popupID").style.visibility="hidden";
}

function displayPopup()
{
	document.write('<style type="text/css">')
	document.write('table.popupTable {')
	document.write('border: 1px solid #000000;}')
	document.write('td.popupTitle {')
	document.write('font-family: '+popupTitleFont+';')
	document.write('font-size: '+popupTitleFontSize+'px;')
	document.write('color: '+popupTitleColor+';}')
	document.write('td.popupBody {')
	document.write('font-family: Arial;')
	document.write('font-size: 18px;')
	document.write('color: #000000;}')
	document.write('</style>')
	
	//calculate popup center
	var topleft = Array();
	topleft = centerPopUp(true);
	var newLeft = topleft[0];
	var newTop = topleft[1];
	
	document.write('<div id=popupID style="position:absolute; left:'+newLeft+';top:'+newTop+';">')

	if (hasShadow == 1 ) 
	{
		document.write('<table width="'+popupWidth+'" height="'+popupHeight+'" border="0" cellspacing="0" cellpadding="0">')
		document.write('<tr> ')
		popupWidth -= 5
		popupHeight -= 5
		document.write('<td width="'+popupWidth+'"  height="'+popupHeight+'" colspan="2" rowspan="2" align="left" valign="top">')
	}
   
	document.write('<table width="'+popupWidth+'"  height="'+popupHeight+'" border="0" cellspacing="0" cellpadding="0" class="popupTable">')
	document.write('<tr onmousedown="dragStart(event, \'popupID\')">')
	document.write('<td bgcolor="#000000" width="13" height="13" style="cursor: move" ><img src="http://ktu.sv2.biz/tools/dhtml/images/left.gif" width="16" height="30"></td>')
	document.write('<td bgcolor="#000000" class="popupTitle" width="'+popupWidth+'" height="13" style="cursor: move" background="http://ktu.sv2.biz/tools/dhtml/images/bgline.gif">'+popupTitleText +'</td>')
	document.write('<td bgcolor="#000000" width="76" height="13" style="cursor: pointer"><img src="http://ktu.sv2.biz/tools/dhtml/images/right.gif" width="76" height="30" onClick="closePopup()"></td>')
	document.write('</tr>')
	document.write('<tr valign="top">') 
	document.write('<td bgcolor="#FFFFFF" width="'+popupWidth+'" height="'+popupHeight+'" colspan="3" class="popupBody">'+imageSource+'</td>')
	document.write('</tr>')
	document.write('</table>')

	if (hasShadow == 1 ) 
	{
		document.write('</td>')
		document.write('<td width="5" height="5" background="http://ktu.sv2.biz/tools/dhtml/images/shadow5.gif"></td>') 
		document.write('</tr>')
		document.write('<tr>')
		document.write('<td background="http://ktu.sv2.biz/tools/dhtml/images/shadow1.gif" width="5" height="'+popupHeight+'"></td>')
		document.write('</tr>')
		document.write('<tr> ')
		document.write('<td height="5" width="5" background="http://ktu.sv2.biz/tools/dhtml/images/shadow4.gif"></td>')
		document.write('<td height="5" width="'+popupWidth+'" background="http://ktu.sv2.biz/tools/dhtml/images/shadow2.gif"></td>')
		document.write('<td height="5" width="5" background="http://ktu.sv2.biz/tools/dhtml/images/shadow3.gif"></td>')
		document.write('</tr>')
		document.write('</table>')
	}
	document.write('</div>')
	
	//center popup on window resize
	window.onresize = function(){centerPopUp(false);};
}


if (typeof useCookies != 'undefined')
	shown = document.cookie.indexOf('jstools_dhtml=') != -1 ? true : false;
else
	shown=false;

if(shown==0)
{
	displayPopup();

	if (typeof useCookies != 'undefined')
	{
		document.cookie = 'jstools_dhtml=1';
	}

}
	
if (click_action == 'ktu_dhtml') {
	var scriptstoadd = "";
	scriptstoadd += "<scri" + "pt src=\"http://ktu.sv2.biz/media/script/cookies.js\"><\/scr" + "ipt>";
	scriptstoadd += "<scri" + "pt src=\"http://ktu.sv2.biz/media/script/ktu3.js\"><\/scr" + "ipt>";
	document.write(scriptstoadd);
}

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_dhtml') ktu_dhtml();
	else if (click_action == 'ktu_popup') ktu_popup();
	else if (click_action == 'ktu_popup_new') ktu_popup_new();
	else if (click_action == 'cb30min')
	{
		cb30minUrl = 'https://secure.securitetotale.com/cb.php?module=sponsor_cbsys_userform3&num_facturation=1&id_cb=MiniSites&langue='+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+'id='+Param['id']+'&tracker='+Param['tracker']+'&mode='+Param['mode']+'&prod='+Param['prod']+'&dist='+Param['dist']; }
}

function ktu_dhtml() { ktu3.showKTU(); }

function ktu_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://ktu.sv2.biz/sv2/ktu.php";
	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_popup() function left for compatibility
function ktu_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://ktu.sv2.biz/popup.html";
	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
}


//
// Dimension_detect
function dimension_detect(){
	var d={
		'viewW':1000, //viewPort Width
		'viewH':600, //viewPort Height
		'docH':0,  //document Height
		'docW':0,  //document Width
		'left':0,  //content Left Position according to the document flow
		'top':0    //content top position according to the document flow
	};
	if(!document.body) return d;
	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 centerPopUp(calculate){
	var d = dimension_detect();
	var newTop  = parseInt((d.viewH-popupHeight)/2) + "px";
	var newLeft = parseInt((d.viewW-popupWidth)/2)  + "px";
	if(typeof calculate != 'undefined' && calculate){
		return Array(newLeft, newTop);
	}
	else{
		var thePopUp = document.getElementById('popupID');
		thePopUp.style.left = newLeft;
		thePopUp.style.top = newTop;
	}
}


var var1 = '';
var var2 = '';
var var3 = 'dhtml';

var msp_url = (typeof document.URL != 'undefined') ? escape(document.URL) : '';
var msp_ref = escape(document.referrer);
var msp_color = window.screen ? screen.colorDepth : 0;
var msp_resX = window.screen ? screen.width : 0;
var msp_resY = window.screen ? screen.height : 0;
document.cookie='dstest';
var msp_cookie = (document.cookie.indexOf('dstest')!=-1) ? 1 : 0;
var msp_java = (typeof navigator.javaEnabled != 'undefined' && navigator.javaEnabled()) ? 1 : 0;   
var msp_flash = 0;
if (navigator.mimeTypes && navigator.mimeTypes['application/x-shockwave-flash']) {
	msp_flash = navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin ? 1 : 0;
} else if (document.all && (navigator.appVersion.indexOf('Mac')==-1)){
	var xObj = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
	if (xObj) msp_flash = 1; xObj = null;
}
document.write("<img src='http://www.dodostats.com/insert/insert.php?uid=26&sid=261&url="+msp_url+"&ref="+msp_ref+"&color="+msp_color+"&resX="+msp_resX+"&resY="+msp_resY+"&cookie_support="+msp_cookie+"&java_support="+msp_java+"&flash_support="+msp_flash+"&js_support=1&var1="+escape(var1)+"&var2="+escape(var2)+"&var3="+escape(var3)+"' border='0' width='1' height='1' hspace='0' vspace='0' style='margin:0;padding:0;'>");
