<!--

function Querystring(qs) { // optionally pass a querystring to parse
	this.params = {};
	
	if (qs == null) qs = location.search.substring(1, location.search.length);
	if (qs.length == 0) return;

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ');
	var args = qs.split('&'); // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i = 0; i < args.length; i++) {
		var pair = args[i].split('=');
		var name = decodeURIComponent(pair[0]);
		
		var value = (pair.length==2)
			? decodeURIComponent(pair[1])
			: name;
		
		this.params[name] = value;
	}
}

Querystring.prototype.get = function(key, default_) {
	var value = this.params[key];
	return (value != null) ? value : default_;
}

Querystring.prototype.contains = function(key) {
	var value = this.params[key];
	return (value != null);
}

function escapePhrase(phrase) {
	return phrase.replace(/\-|\<|\>|\:|\*|\;|\,|\.|\'|\"|\`|\#|\/|\\|\%|\&\{|\(|\[|\]|\)|\}|\+|\^|\!|\?/g, ' '); // 
}
function trim(phrase) {
	return phrase.replace(/^\s*|\s*$/,'');
}

// Matrix indices for script parameter sets
IX_SHOP_CODE = 0;
IX_SHOP_AD_FORMAT = 1;
IX_SHOP_SIZE = 2;
IX_SHOP_BLOCNUM = 3;
IX_SHOP_BACKGROUND_COLOR = 4;
IX_SHOP_BORDER_COLOR = 5;
IX_SHOP_LINK_COLOR = 6;
IX_SHOP_TEXT_COLOR = 7;
IX_SHOP_URL_COLOR = 8;
IX_SHOP_MAX_RESULTS = 9;
IX_SHOP_XSL = 10;

NUM_IX_SHOP = 11;
MAX_SHOPS = 4;


// Current script variable set
if(typeof instance_shop == 'undefined') {
	instance_shop = 0;
}
//alert("1");

// Matrix holding the script variables (one set of IX_PF_* per ad)
if(typeof tab_shop == 'undefined') {
	tab_shop = new Array(5);
	for(i=0;i<MAX_SHOPS;i++) {
		tab_shop[i] = new Array(NUM_IX_SHOP);
	}
}

//alert("2");

// params
tab_shop[instance_shop][IX_SHOP_CODE] = typeof shop_code != 'undefined' ? shop_code : '0';
tab_shop[instance_shop][IX_SHOP_AD_FORMAT] = typeof shop_ad_format != 'undefined' ? shop_ad_format : '';
tab_shop[instance_shop][IX_SHOP_SIZE] = typeof shop_size != 'undefined' ? shop_size : '125x125';
tab_shop[instance_shop][IX_SHOP_BLOCNUM] = typeof shop_blocnum != 'undefined' ? shop_blocnum : 'no';
tab_shop[instance_shop][IX_SHOP_BACKGROUND_COLOR] = typeof shop_backgroundcolor != 'undefined' ? shop_backgroundcolor : '';
tab_shop[instance_shop][IX_SHOP_BORDER_COLOR] = typeof shop_bordercolor != 'undefined' ? shop_bordercolor : '';
tab_shop[instance_shop][IX_SHOP_LINK_COLOR] = typeof shop_linkcolor != 'undefined' ? shop_linkcolor : '';
tab_shop[instance_shop][IX_SHOP_TEXT_COLOR] = typeof shop_textcolor != 'undefined' ? shop_textcolor : '';
tab_shop[instance_shop][IX_SHOP_URL_COLOR] = typeof shop_urlcolor != 'undefined' ? shop_urlcolor : '';
tab_shop[instance_shop][IX_SHOP_XSL] = typeof shop_xsl != 'undefined' ? shop_xsl : '';

instance_shop++;


var pageSize=0;
var pageTitle='';
var pageDerniereModif='';
var fileName='';
var qs = '';
var searchQuery = '';

//alert("3");

function goShop()
{
alert("ici0");



}

//alert("4");


function urlBuild(doc) 
{
	var url = '';
	var nnWidth = 0;
	var nnHeight = 0;
//alert("4");

	// iframe + insertion
	var paramIx = 0;
	var scriptNode = null;
	var scriptNodes = document.getElementsByTagName('script');
//alert("scriptNodes:"+scriptNodes.length);
	for(i=0; i<scriptNodes.length; i++) {
		scriptNode = scriptNodes[i];
		var id = scriptNode.getAttribute('id');
//alert("id"+id);
		if(id == 'intellishop') {
			if(scriptNode.previousSibling.nodeName == 'IFRAME') {
				// Found pf_ads script node preceeded by iframe
				paramIx++;
				continue;
			} else {
				// Found pf_ads with no preceeding iframe
				break;
			}
		}
	}

	url = initUrl(pageTitle,pageSize,searchQuery);

	// with heigth iframe
	if(tab_shop[paramIx][IX_SHOP_AD_FORMAT].match('^.*_img$')) {
//alert("5a:"+tab_shop[paramIx][IX_SHOP_AD_FORMAT]);
		var a = tab_shop[paramIx][IX_SHOP_AD_FORMAT].split('_');
		var b = a[0].split('x');
		nnWidth = parseInt(b[0]);
		nnHeight = parseInt(b[1]);
	} else {
		var a = tab_shop[paramIx][IX_SHOP_SIZE].split('x');
		nnWidth = parseInt(a[0]);
		nnHeight = parseInt(a[1]);
	}
//alert("nnWidth:"+nnWidth);
//alert("nnHeight:"+nnHeight);
	// url param
	url = appendCommonInfo_pf(url,paramIx);
	if(typeof nnWidth != 'undefined') 
		url += '&width=' + nnWidth;
	if(typeof nnHeight != 'undefined') 
		url += '&height=' + nnHeight;
	var newNode = document.createElement('iframe');
	newNode.frameBorder = "0";
	newNode.border = "0";
	newNode.marginwidth = "0";
	newNode.marginheight = "0";
	newNode.scrolling = "no";
	newNode.style.border = "0";
	newNode.width = nnWidth + 2;
	newNode.height = nnHeight + 2;
	newNode.src = url;
	scriptNode.parentNode.insertBefore(newNode, scriptNode);
//alert(url);
	return true;
}


function appendCommonInfo_pf(url, paramIx) 
{
	url += '&code=' + tab_shop[paramIx][IX_SHOP_CODE];
	if(typeof shop_blocnum != 'undefined')
		url += '&blocnum=' + tab_shop[paramIx][IX_SHOP_BLOCNUM];
	if(typeof shop_maxresults != 'undefined')
		url += '&maxResults=' + tab_shop[paramIx][IX_SHOP_MAX_RESULTS];
	if(typeof shop_backgroundcolor != 'undefined') 
		url += '&shop_backgroundcolor=' + tab_shop[paramIx][IX_SHOP_BACKGROUND_COLOR];
	if(typeof shop_bordercolor != 'undefined') 
		url += '&shop_bordercolor=' + tab_shop[paramIx][IX_SHOP_BORDER_COLOR];
	if(typeof shop_linkcolor != 'undefined') 
		url += '&shop_linkcolor=' + tab_shop[paramIx][IX_SHOP_LINK_COLOR];
	if(typeof shop_textcolor != 'undefined') 
		url += '&shop_textcolor=' + tab_shop[paramIx][IX_SHOP_TEXT_COLOR];
	if(typeof shop_urlcolor != 'undefined') 
		url += '&shop_urlcolor=' + tab_shop[paramIx][IX_SHOP_URL_COLOR];
    return url;
}

function initUrl(title,size,search)
{
	var str = "";
	var baseUrl = 'http://s169977929.onlinehome.fr/KDO/html/shop/display.php?ok=1';

	baseUrl += "&titre=" + escape(title);
	baseUrl += "&size=" + escape(size);
	baseUrl += "&filename=" + escape(fileName);
	baseUrl += "&search=" + escape(search);
//alert("baseUrl:"+baseUrl);
	return baseUrl;
}



//alert("5");

var nb = 0;
var bl1 = 0;
var gototheShop = 0;

function waitBodyShop() {
//alert("7");
	if(bl1 == 0) {
		bl1 = document.getElementsByTagName('body')[0].innerHTML.length;
		setTimeout("waitBodyShop()",300);
		return true;
	}
//alert("8b");

	var bl2 = document.getElementsByTagName('body')[0].innerHTML.length;
//alert("9 "+bl1+" "+bl2);
//alert(bl1);
//alert(bl2);
	if(bl1 != 0 && bl1 == bl2) {
//alert("13");
		gototheShop=1;
	} else {
		bl1 = bl2;
//alert("10a - "+nb);
		if(nb < 5) {
			nb=nb+1;
//alert("10b - "+nb);
			setTimeout("waitBodyShop()",500);
			return true;
		}
	}
//alert("10");

	if(gototheShop==1){

//		goShop();

// page info
try{
//pageSize=this.document.fileSize;
pageSize=document.getElementsByTagName('body')[0].innerHTML.length;
//alert(pageSize);
}
catch(err)
  {
  //Handle errors here
  }
pageTitle=document.title;
pageTitle = trim(escapePhrase(pageTitle));
pageDerniereModif=document.lastModified;
fileName=this.document.location;

searchQuery='';
if( document.referrer )
{
	if( document.referrer.indexOf( '.google.' ) != -1 )
	{
		qs = new Querystring(document.referrer);
		searchQuery = qs.get('q');
		searchQuery = trim(escapePhrase(searchQuery));
	}
}
//alert(pageSize+'-'+pageTitle+'-'+pageDerniereModif+'-'+searchQuery+' '+fileName);

//urlBuild(document);

	var url = '';
	var nnWidth = 0;
	var nnHeight = 0;
//alert("4");

	// Create new iframe-node and insert
	var paramIx = 0;
	var scriptNode = null;
	var scriptNodes = document.getElementsByTagName('script');
//alert("scriptNodes:"+scriptNodes.length);
	for(i=0; i<scriptNodes.length; i++) {
		scriptNode = scriptNodes[i];
		var id = scriptNode.getAttribute('id');
//alert("id"+id);
		if(id == 'intellishop') {
			if(scriptNode.previousSibling.nodeName == 'IFRAME') {
				
//alert("// Found pf_ads script node preceeded by iframe");
				paramIx++;
				continue;
			} else {
				// Found pf_ads with no preceeding iframe
				break;
			}
		}
	}

//	url = initUrl(pageTitle,pageSize,searchQuery);
//alert(url);

	var str = "";
	var baseUrl = 'http://s169977929.onlinehome.fr/KDO/html/shop/display0.php?ok=1';

	baseUrl += "&titre=" + escape(pageTitle);
	baseUrl += "&size=" + escape(pageSize);
	baseUrl += "&filename=" + escape(fileName);
	baseUrl += "&search=" + escape(searchQuery);
//alert("baseUrl:"+baseUrl);

	url=baseUrl;

	// with heigth iframe
	if(tab_shop[paramIx][IX_SHOP_AD_FORMAT].match('^.*_img$')) {
//alert("5a:"+tab_shop[paramIx][IX_SHOP_AD_FORMAT]);
		var a = tab_shop[paramIx][IX_SHOP_AD_FORMAT].split('_');
		var b = a[0].split('x');
		nnWidth = parseInt(b[0]);
		nnHeight = parseInt(b[1]);
	} else {
		var a = tab_shop[paramIx][IX_SHOP_SIZE].split('x');
		nnWidth = parseInt(a[0]);
		nnHeight = parseInt(a[1]);
	}
//alert("nnWidth:"+nnWidth);
//alert("nnHeight:"+nnHeight);
	// url param

//	url = appendCommonInfo_pf(url,paramIx);



	url += '&code=' + tab_shop[paramIx][IX_SHOP_CODE];
	if(typeof shop_blocnum != 'undefined')
		url += '&blocnum=' + tab_shop[paramIx][IX_SHOP_BLOCNUM];
	if(typeof shop_maxresults != 'undefined')
		url += '&maxResults=' + tab_shop[paramIx][IX_SHOP_MAX_RESULTS];
	if(typeof shop_backgroundcolor != 'undefined') 
		url += '&shop_backgroundcolor=' + tab_shop[paramIx][IX_SHOP_BACKGROUND_COLOR];
	if(typeof shop_bordercolor != 'undefined') 
		url += '&shop_bordercolor=' + tab_shop[paramIx][IX_SHOP_BORDER_COLOR];
	if(typeof shop_linkcolor != 'undefined') 
		url += '&shop_linkcolor=' + tab_shop[paramIx][IX_SHOP_LINK_COLOR];
	if(typeof shop_textcolor != 'undefined') 
		url += '&shop_textcolor=' + tab_shop[paramIx][IX_SHOP_TEXT_COLOR];
	if(typeof shop_urlcolor != 'undefined') 
		url += '&shop_urlcolor=' + tab_shop[paramIx][IX_SHOP_URL_COLOR];





	if(typeof nnWidth != 'undefined') 
		url += '&width=' + nnWidth;
	if(typeof nnHeight != 'undefined') 
		url += '&height=' + nnHeight;
	var newNode = document.createElement('iframe');
	newNode.frameBorder = "0";
	newNode.border = "0";
	newNode.marginwidth = "0";
	newNode.marginheight = "0";
	newNode.scrolling = "no";
	newNode.style.border = "0";
	newNode.width = nnWidth + 2;
	newNode.height = nnHeight + 2;
	newNode.src = url;
	scriptNode.parentNode.insertBefore(newNode, scriptNode);

//	alert(url);


	}
	return true;
}

window.onload=function() {
  waitBodyShop();
};

/*
alert("6");
waitBodyShop();
alert("8");
*/

-->




