﻿// *************************************************************************************
//	EntitiesToNormalChar
// Convertit un séquence HTML en séquence UNICODE 
// et affiche une boite de dialogue
// *************************************************************************************
function EntitiesToNormalChar(s)
{
	var d = document.createElement("DIV"); 
	s = s.replace(/</g, "&lt;").replace(/>/g, "&gt;"); 
	d.innerHTML = s; 
	s = d.innerHTML; 
	return(s.replace(/&lt;/g, "<").replace(/&gt;/g, ">")); 
}

function addslashes( str ) {
    return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0");   
}

// *************************************************************************************
//	alert_conv
//
//
// *************************************************************************************
function alert_conv(s) 
{ 
	alert(EntitiesToNormalChar(s));
} 
// *************************************************************************************
//	alert_conv
//
//
// *************************************************************************************
function confirm_conv(s) 
{ 
	confirm(EntitiesToNormalChar(s));
}
// *************************************************************************************
//	PrmUrl
//
//
// *************************************************************************************
function PrmUrl(url)
{
 var prm = new Array();
 var tmp;
 var inter;

	tmp = unescape(url).substr(1).split("&");

	for ( i=0; i<tmp.length; i++)
 {
  inter=tmp[i].indexOf("=");
  if ( inter>=0 )
    {
     prm[tmp[i].substr(0,inter)]=tmp[i].substr(inter+1)
    }
  else {
     prm[tmp[i]]="";
    }
 }
 return prm;
}

function GotoIndex(langue)
{
	if (langue=="") alert("No language precised");
	window.moveTo(0,0);
	if (document.getElementById || document.all) 
	{
		window.resizeTo(screen.availWidth, screen.availHeight);
	}
	document.location.replace("index.php?lang="+langue);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// *************************************************************************************
//	centrer
//
//
// *************************************************************************************
function centrer() {
	x = (screen.availWidth - document.body.clientWidth)/2 
	y = (screen.availHeight - document.body.clientHeight)/2 
	moveTo(x,y)
}
// *************************************************************************************
//	fermer
//
// Ferme et reload la fenetre parent 
// *************************************************************************************
function fermer() 
{
  // On recharge la fenetre parent
  window.opener.location.reload()
  window.close()
}
// *************************************************************************************
//	VerificationEmail
//
//
// *************************************************************************************
function VerificationEmail(elm)
{
	if (elm.value.indexOf("@") != "-1" &&
	    elm.value.indexOf(".") != "-1" &&
	    elm.value.indexOf(" ") == "-1" &&
	    elm.value != "" )
	{
	    return true;
	}
	return false;
}
// *************************************************************************************
//	VerificationSaisie
//
//
// *************************************************************************************
function VerificationSaisie(elm)
{
	if (elm.value.indexOf("#") == "-1"/* &&
	    elm.value.indexOf("*") == "-1"*/) return true;

	return false;
}
// *************************************************************************************
//	popup
//
// Ouvre et centre une popup 
// *************************************************************************************
function popup(page,content,hauteur,largeur) 
{
	//popup centree, soit ouvre la page specifiee soit ecrit le content 
	var top=(screen.height-hauteur)/2
	var left=(screen.width-largeur)/2; 
	winpop=window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur); 
	if (!winpop)
		alert("Unable to open popup window. If yuo are using one anti-popup, please open it for this web site and try again")
} 

var IB=new Object;
var posX=0;posY=0;
var xOffset=10;yOffset=10;
// *************************************************************************************
//
//
//
// *************************************************************************************
function AffBulle(texte) {
  contenu="<TABLE border=0 cellspacing=0 cellpadding="+IB.NbPixel+"><TR bgcolor='"+IB.ColContour+"'><TD><TABLE border=0 cellpadding=2 cellspacing=0 bgcolor='"+IB.ColFond+"'><TR><TD><FONT size='-1' face='arial' color='"+IB.ColTexte+"'>"+texte+"</FONT></TD></TR></TABLE></TD></TR></TABLE>&nbsp;";
  var finalPosX=posX-xOffset;
  if (finalPosX<0) finalPosX=0;
  if (document.layers) {
    document.layers["bulle"].document.write(contenu);
    document.layers["bulle"].document.close();
    document.layers["bulle"].top=posY+yOffset;
    document.layers["bulle"].left=finalPosX;
    document.layers["bulle"].visibility="show";}
  if (document.all) {
    //var f=window.event;
    //doc=document.body.scrollTop;
    bulle.innerHTML=contenu;
    document.all["bulle"].style.top=posY+yOffset;
    document.all["bulle"].style.left=finalPosX;//f.x-xOffset;
    document.all["bulle"].style.visibility="visible";
  }
  //modif CL 09/2001 - NS6 : celui-ci ne supporte plus document.layers mais document.getElementById
  else if (document.getElementById) {
    document.getElementById("bulle").innerHTML=contenu;
    document.getElementById("bulle").style.top=posY+yOffset;
    document.getElementById("bulle").style.left=finalPosX;
    document.getElementById("bulle").style.visibility="visible";
  }
}
// *************************************************************************************
//	getMousePos
//
//
// *************************************************************************************
function getMousePos(e) {
  if (document.all) {
  posX=event.x+document.body.scrollLeft; //modifs CL 09/2001 - IE : regrouper l'évčnement
  posY=event.y+document.body.scrollTop;
  }
  else {
  posX=e.pageX; //modifs CL 09/2001 - NS6 : celui-ci ne supporte pas e.x et e.y
  posY=e.pageY; 
  }
}
// *************************************************************************************
//	HideBulle
//
//
// *************************************************************************************
function HideBulle() {
	if (document.layers) {document.layers["bulle"].visibility="hide";}
	if (document.all) {document.all["bulle"].style.visibility="hidden";}
	else if (document.getElementById){document.getElementById("bulle").style.visibility="hidden";}
}

// *************************************************************************************
//	InitBulle
//
//
// *************************************************************************************
function InitBulle(ColTexte,ColFond,ColContour,NbPixel) 
{
	IB.ColTexte=ColTexte;IB.ColFond=ColFond;IB.ColContour=ColContour;IB.NbPixel=NbPixel;
	if (document.layers) {
		window.captureEvents(Event.MOUSEMOVE);window.onMouseMove=getMousePos;
		document.write("<LAYER name='bulle' top=0 left=0 visibility='hide'></LAYER>");
	}
	if (document.all) {
		document.write("<DIV id='bulle' style='position:absolute;top:0;left:0;visibility:hidden'></DIV>");
		document.onmousemove=getMousePos;
	}
	//modif CL 09/2001 - NS6 : celui-ci ne supporte plus document.layers mais document.getElementById
	else if (document.getElementById) {
	        document.onmousemove=getMousePos;
	        document.write("<DIV id='bulle' style='position:absolute;top:0;left:0;visibility:hidden'></DIV>");
	}
}
// *************************************************************************************
//	AdjustPageDim
//
//
// *************************************************************************************
function AdjustPageDim()
{
	var LeftBord, RightBord;

	LeftBord =document.getElementById("LeftBorderMainTab");
	RightBord=document.getElementById("RightBorderMainTab");
	if (RightBord) 
	{
		RightBord.setAttribute("RightBorderMainTab", "100");
		//alert('right '+RightBord.height);
	}
	if (LeftBord) 
	{
		LeftBord.setAttribute("LeftBorderMainTab", "100");
		//alert('Left '+LeftBord.height);
	}
}
function addslashes(ch) 
{ 
	ch = ch.replace(/\\/g,"\\\\") 
	ch = ch.replace(/\'/g,"\\'") 
	ch = ch.replace(/\"/g,"\\\"") 
	return ch 
}
function SetExportLicenceActive(var_pays)
{
	LicenceFieldLabel=document.getElementById("aff_licence_export");
	if (var_pays==3)
	{
		// Chine => Affichage du champ licence d'exportation
		LicenceFieldLabel.style.display = "block";
	}
	else
	{
		// On masque le champ licence d'exportation
		LicenceFieldLabel.style.display = "none";
	}
}
