	String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };
    var ymeta=document.getElementsByTagName('meta');
    var xencoding='';
	var t;
	var z;
	var ibcl=0;
	var atabspan = new Array();
	var afchdvd = new Array();

   	for(i in ymeta)
	{
		if(/charset=([A-Za-z0-9_-]*)/i.test(ymeta[i].content))
		{
			xencoding='&charset='+/charset=([A-Za-z0-9_-]*)/i.exec(ymeta[i].content)[1].toLowerCase();
   		}
  	}

	var aryspedtmsg=document.getElementsByName("spedtmsg");
	var slkdvd="";	
	for (xxmi=0;xxmi<aryspedtmsg.length;xxmi++)
	{
		var bupdmsg=false;
		var bupdmsg1=false;
		var ospedtmsg=aryspedtmsg[xxmi];
//		alert(ospedtmsg.innerHTML);
		if(/\{fiche:(\d+)\}/i.test(ospedtmsg.innerHTML))
		{
			x=ospedtmsg.innerHTML.replace(/\{fiche:(\d+)\}/ig,'<span id="fiche$1">chargement ...</span>');
			bupdmsg=true;
   		}
		var wspedtmsg=ospedtmsg.innerHTML;
		var areg=wspedtmsg.match(/\{dvd:(\d+)(.*?)\}/igm);
		if (areg)
		{
			for (var i=0; i<areg.length; i++) {
				var areg1=/\{dvd:(\d+)-?(.*?)(?:(?:-url=)(.*))?\}/i.exec(areg[i]);
				slkdvd += (slkdvd==""?"":",")+areg1[1].trim();
				if (areg1[3]===undefined) areg1[3]="";
				if (areg1[2]===undefined) areg1[2]="";
				if (areg1[3]!=""&&areg1[3].toLowerCase()!="no")  // areg1[3]!==undefined
				{
					wspedtmsg=wspedtmsg.replace(areg[i],"<span id=\"lkdvd"+areg1[1]+"\"><a href=\""+areg1[3]+"\">"+areg1[2]+"</a></span>");
				}
				else if (areg1[2]!="")
				{
					wspedtmsg=wspedtmsg.replace(areg[i],"<span id=\"lkdvd"+areg1[1]+"\">"+areg1[2]+"</span>");
				}
				else
				{
					wspedtmsg=wspedtmsg.replace(areg[i],"<span id=\"lkdvd"+areg1[1]+"\">title not defined</span>");
				}
				bupdmsg1=true;
			}
		}
		if (bupdmsg1)
		{
			x=wspedtmsg;
		}		
		if (bupdmsg||bupdmsg1)
		{
			ospedtmsg.innerHTML=x;
		}

  	}
	
	if (slkdvd!="")
	{
		var DSLScript  = document.createElement("script");
		DSLScript.id = "jsdsl";
//		DSLScript.src = "sendfichette.php?nrdvd="+slkdvd;
		DSLScript.src = "http://www.dvdlib.be/my/sendfichette.php?nrdvd="+slkdvd+xencoding;
		DSLScript.type = "text/javascript";
		document.body.appendChild(DSLScript);
	}
	function callfichetdvd() 
	{
		for(var i= 0; i < afchdvd.length; i++)
		{
			var olkdvd = "lkdvd"+afchdvd[i][0];
			var oidspan = "spfchtdvd"+afchdvd[i][0];
			var olink=document.getElementById(olkdvd).getElementsByTagName('a');
			if (olink[0])
			{
				document.getElementById(olkdvd).innerHTML="<a href=\""+olink[0].href+"\" onmouseover=\"TagToTip('"+oidspan+"', WIDTH, 400)\" onmouseout=\"UnTip()\">"+olink[0].innerHTML+"</a>"; 
			}else{
				document.getElementById(olkdvd).innerHTML="<a style=\"text-decoration:none; cursor:default;\" href=\"http://my.dvdlib.be/viewtopic.php?t=46\" onmouseover=\"TagToTip('"+oidspan+"', WIDTH, 400)\" onmouseout=\"UnTip()\">"+document.getElementById(olkdvd).innerHTML+"</a>"; 
			}
			var ospan = document.createElement("span");
			ospan.id = oidspan;
			ospan.style.display="none";
			ospan.innerHTML="<img src=http://www.dvdlib.be/dvd/img"+afchdvd[i][1]+" style='padding:2px 2px 2px 5px;' align=right width=120 height=168>"+afchdvd[i][2];
			document.body.appendChild(ospan);		
		}	
		var script;
		while (script = document.getElementById('jsdsl'))
		{
			script.parentNode.removeChild(script);
			// Browsers won't garbage collect this object.
			// So castrate it to avoid a major memory leak.
			for (var prop in script) {
			//      delete script[prop];
			}
		}
	}
	
    function include(file)
    {
		var oScript = document.createElement("script");
		oScript.src = file;
		oScript.type = "text/javascript";
		document.body.appendChild(oScript);
	}
    var y = document.getElementsByTagName("span");
	var sfiche="";
	for(i in y)
	{
		var wregidfich=/fiche/;
		if(wregidfich.test(y[i].id))
		{
			var w=parseInt(y[i].id.substr(5));
			sfiche+=((sfiche=="")?"":",")+w;
   		}
  	}
	if (sfiche!="")
	{
		include("http://www.dvdlib.be/forum/getfiche.php?nrfiche="+sfiche+xencoding);
//		include("/forum/getfiche.php?nrfiche="+sfiche+xencoding);
	}
	function fsetfiche()
	{
		ibcl++;
		if (z==undefined)
		{
			if (ibcl<10)
				t=setTimeout("fsetfiche()",1000);  // problème avec IE de variable non définie
		} else {
		    var y=document.getElementsByTagName("span");
			for(var i = 0; i < y.length; i++)
			{
				if(/fiche/.test(y[i].id))
				{
					var w=parseInt(y[i].id.substr(5));
					y[i].innerHTML=eval("z"+w);
		   		}
		  	}
		}
	}

	window.onload=function(){
		ibcl=0;
		fsetfiche();
	}

