var ns4 = (document.layers); 
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);

function Affiche(nObjet) {


 var nbchpaffiche=0;
 
 Init(nObjet); 
 
 var nObjet="div_name";
 obj = (document.getElementById) ? document.getElementById(nObjet) : eval("document.all['nObjet']");
 
 if(ns4) obj.visibility = "visible";
 else obj.style.visibility = "visible";
}

function attach(id)
{
 var obj;
  if(ns4) obj = document.layers[id];
  else if(ie4) obj = document.all[id];
          else if(ie5 || ns6) obj = document.getElementById(id);

 return obj;
}

function hide_obj(id)
{
 obj = attach(id);
 if(ns4) obj.visibility = "hide";
 else obj.style.visibility = "hidden";
}
function Init(i)
{
 var contenu;
 
	switch(i)
	{
		case 1 : 
			contenu = '&nbsp;';
			contenu += '&raquo;<a href="?chap=prof&req=presentation&rub=1"> pr&eacute;sentation </a>';
			contenu += '&raquo;<a href="?chap=prof&req=equipe&rub=1"> &eacute;quipe </a>';
			contenu += '&raquo;<a href="?chap=prof&req=valaj&rub=1"> valeur ajout&eacute;e </a>';
			contenu += '&raquo;<a href="?chap=prof&req=rd&rub=1"> R&amp;D </a>';
			contenu += '&raquo;<a href="?chap=prof&req=dist&rub=1"> distinction </a>';
			contenu += '&raquo;<a href="?chap=prof&req=acces&rub=1"> plan d\'acc&egrave;s </a>';
			contenu += '&raquo;<a href="?chap=prof&req=contact&rub=1"> contact </a>';
			break;
		case 2 :
			contenu =  '&nbsp';
			contenu += '&raquo;<a href="?chap=offer&req=produits&rub=2"> produits </a>'; 
			contenu += '&raquo;<a href="?chap=offer&req=services&rub=2"> services </a>';
			contenu += '&raquo;<a href="?chap=offer&req=infratech&rub=2"> infrastructures techniques </a>';
			break;
		case 3 :
			contenu = '&nbsp;';
			contenu += '&raquo;<a href="?chap=cust&req=ref&rub=3"> r&eacute;f&eacute;rences </a>';
			contenu += '&raquo;<a href="?chap=cust&req=temoigne&rub=3"> t&eacute;moignages</a>';
			break;
		case 4 :
			contenu = '&nbsp;';
			contenu += '&raquo;<a href="?chap=plus&req=liensutiles&rub=4"> liens utiles </a>';
			contenu += '&raquo;<a href="?chap=plus&req=virus&rub=4"> alertes virales </a>';
			contenu += '&raquo;<a href="?chap=plus&req=whois&rub=4"> whois </a>';
			contenu += '&raquo;<a href="?chap=plus&req=lookup&rub=4"> DNS lookup </a>';
			contenu += '&raquo;<a href="?chap=plus&req=libnet&rub=4"> LibNet </a>';
			break;
		case 5 : 
			contenu = '&nbsp;';
			contenu += '&raquo;<a href="?chap=news&req=revuepresse&rub=5"> revue de presse </a>';
			contenu += '&raquo;<a href="?chap=news&req=communiques&rub=5"> communiqu&eacute;s </a>';
			contenu += '&raquo;<a href="?chap=news&req=events&rub=5"> &eacute;v&egrave;nements </a>';
			break;
		case 6 : 
			contenu = '&nbsp;';
			contenu += '&raquo;<a href="?chap=down&req=ns&rub=6"> Netlor Studio </a>';
			contenu += '&raquo;<a href="?chap=down&req=fichprod&rub=6"> Fiches Produits </a>';
			contenu += '&raquo;<a href="?chap=down&req=whitebooks&rub=6"> Lives Blancs</a>';
			break;
		
		default : 
			contenu = '&nbsp;';
			contenu += '&raquo;<a href="?chap=prof&req=presentation&rub=1"> pr&eacute;sentation </a>';
			contenu += '&raquo;<a href="?chap=prof&req=equipe&rub=1"> &eacute;quipe </a>';
			contenu += '&raquo;<a href="?chap=prof&req=valaj&rub=1"> valeur ajout&eacute;e </a>';
			contenu += '&raquo;<a href="?chap=prof&req=rd&rub=1"> R&amp;D </a>';
			contenu += '&raquo;<a href="?chap=prof&req=distinction&rub=1"> distinction </a>';
			contenu += '&raquo;<a href="?chap=prof&req=acces&rub=1"> plan d\'acc&egrave;s </a>';
			contenu += '&raquo;<a href="?chap=prof&req=contact&rub=1"> contact </a>';
			break;
			
	}
	nObjet='div_name';
	obj = (document.getElementById) ? document.getElementById(nObjet) : eval("document.all['nObjet']");
	if(ns4)
	{
		obj.visibility = "hide";
		obj.innerHTML=contenu;
	}
	else 
	{
		obj.style.visibility = "hidden";
		obj.innerHTML=contenu;
	}


}

function TestParam(mylabel,myparam,mytype)
{
var ok = true;
var i;
var nbpoint=0;

if (mytype=='Email')
	{

	var email = myparam;
	var aroba = email.indexOf("@");

	if (aroba == -1) {
		alert("L'adresse Email n'est pas valide...\nIl n'y a pas de caractère @\nUne adresse Email valide est du type \"adresse@domaine.com\"");
		ok=false;
		}

	if (ok==true)
		{
		var point = email.indexOf(".", aroba);
		if ((point == -1) || (point == (aroba + 1))) {
			alert("L'adresse mèl n'est pas valide...\nIl ne peut pas y avoir un point (.) juste après @\nUne adresse mèl valide est du type \"adresse@domaine.com\"");
			ok=false;
			}
		}

	if (ok==true)
		{
		var point = email.lastIndexOf(".");
		if ((point + 1) == email.length) {
			alert("L'adresse mèl n'est pas valide...\nL'adresse mèl ne peut pas finir par un point (.)\nUne adresse mèl valide est du type \"adresse@domaine.com\"");
			ok=false;
			}
		}

	if (ok==true)
		{
		point = email.indexOf("..")
		if (point != -1) {
			alert("L'adresse mèl n'est pas valide...\nL'adresse mèl ne peut pas contenir 2 points (.) qui se suivent.\nUne adresse mèl valide est du type \"adresse@domaine.com\"");
			ok=false;
			}
		}
	}

if (mytype=='String')
	{
	if (myparam.length==0) 
		{
		ok=false;
		alert("Le champ '" + mylabel + "' ne doit pas être vide");
		}
	}
if (mytype=='Int')
	{
	if (myparam.length==0 || myparam.length>12) ok = false;
	for (i=0;i<myparam.length;i++)
		{
		if (myparam.charAt(i)<'0' || myparam.charAt(i)>'9')
			ok = false;
		}
	if (ok==false) alert("Le champ '" + mylabel + "' doit être un nombre entier valide");
	}
if (mytype=='Date')
	{
	if (myparam.length!=10) ok = false;
	else
		{
		j=myparam.substring(0,2);
		m=myparam.substring(3,5);
		a=myparam.substring(6,10);
		madate=new Date(a,m,j);
		if (madate=="NaN" || myparam.charAt(2)!='/' || myparam.charAt(5)!='/') ok = false;
		}
	if (ok==false) alert("Le champ '" + mylabel + "' doit être une date au format 'jj/mm/aaaa'");
	}
if (mytype=='Time')
	{
	if (myparam.length!=5) ok = false;
	else
		{
		h=myparam.substring(0,2);
		m=myparam.substring(3,5);
		if (parseInt(h)<0 || parseInt(h)>23) ok = false;
		if (parseInt(m)<0 || parseInt(m)>59) ok = false;
		madate=new Date(01,01,2000,h,m);
		if (madate=="NaN" || myparam.charAt(2)!=':') ok = false;
		}
	if (ok==false) alert("Le champ '" + mylabel + "' doit être une heure au format 'hh:mm'");
	}

if (mytype=='DateVide')
	{
	if (myparam.length!=0)
		{
		if (myparam.length!=10) ok = false;
		else
			{
			j=myparam.substring(0,2);
			m=myparam.substring(3,5);
			a=myparam.substring(6,10);
			madate=new Date(a,m,j);
			if (madate=="NaN" || myparam.charAt(2)!='/' || myparam.charAt(5)!='/') ok = false;
			}
		if (ok==false) alert("Le champ '" + mylabel + "' doit être une date au format 'jj/mm/aaaa'");
		}
	}
	
if (mytype=='TimeVide')
	{
	if (myparam.length!=0)
		{
		if (myparam.length!=5) ok = false;
		else
			{
			h=myparam.substring(0,2);
			m=myparam.substring(3,5);
			if (parseInt(h)<0 || parseInt(h)>23) ok = false;
			if (parseInt(m)<0 || parseInt(m)>59) ok = false;
			madate=new Date(01,01,2000,h,m);
			if (madate=="NaN" || myparam.charAt(2)!=':') ok = false;
			}
		if (ok==false) alert("Le champ '" + mylabel + "' doit être une heure au format 'hh:mm'");
		}
	}

if (mytype=='Float')
	{
	if (myparam.length==0) ok = false;
	for (i=0;i<myparam.length;i++)
		{
		if (myparam.charAt(i)=='.') nbpoint++;
		if (myparam.charAt(i)<'0' || myparam.charAt(i)>'9')
			ok = false;
		}
	if (nbpoint>1) ok = false;
	
	if (ok==false) alert("Le champ '" + mylabel + "' doit être un nombre réel");
	}


return (ok);
}


function format_number(p,d) 
{
  var r;
  if(p<0){p=-p;r=format_number2(p,d);r="-"+r;}
  else   {r=format_number2(p,d);}
  return r;
}

function format_number2(pnumber,decimals) 
{
  var strNumber = new String(pnumber);
  var arrParts = strNumber.split('.');
  var intWholePart = parseInt(arrParts[0],10);
  var strResult = '';
  if (isNaN(intWholePart))
    intWholePart = '0';
  if(arrParts.length > 1)
  {
    var decDecimalPart = new String(arrParts[1]);
    var i = 0;
    var intZeroCount = 0;
     while ( i < String(arrParts[1]).length )
     {
       if( parseInt(String(arrParts[1]).charAt(i),10) == 0 )
       {
         intZeroCount += 1;
         i += 1;
       }
       else
         break;
    }
    decDecimalPart = parseInt(decDecimalPart,10)/Math.pow(10,parseInt(decDecimalPart.length-decimals-1)); 
    Math.round(decDecimalPart); 
    decDecimalPart = parseInt(decDecimalPart)/10; 
    decDecimalPart = Math.round(decDecimalPart); 

    //If the number was rounded up from 9 to 10, and it was for 1 'decimal' 
    //then we need to add 1 to the 'intWholePart' and set the decDecimalPart to 0. 

    if(decDecimalPart==Math.pow(10, parseInt(decimals)))
    { 
      intWholePart+=1; 
      decDecimalPart="0"; 
    } 
    var stringOfZeros = new String('');
    i=0;
    if( decDecimalPart > 0 )
    {
      while( i < intZeroCount)
      {
        stringOfZeros += '0';
        i += 1;
      }
    }
    decDecimalPart = String(intWholePart) + "." + stringOfZeros + String(decDecimalPart); 
    var dot = decDecimalPart.indexOf('.');
    if(dot == -1)
    {
      decDecimalPart += '.'; 
      dot = decDecimalPart.indexOf('.'); 
    } 
    var l=parseInt(dot)+parseInt(decimals); 
    while(decDecimalPart.length <= l) 
    {
      decDecimalPart += '0'; 
    }
    strResult = decDecimalPart;
  }
  else
  {
    var dot; 
    var decDecimalPart = new String(intWholePart); 

    decDecimalPart += '.'; 
    dot = decDecimalPart.indexOf('.'); 
    var l=parseInt(dot)+parseInt(decimals); 
    while(decDecimalPart.length <= l) 
    {
      decDecimalPart += '0'; 
    }
    strResult = decDecimalPart;
  }
  return strResult;
}

function addNS()
{

	if (document.form_commande.quantite.value < 999)
	{
		document.form_commande.quantite.value++;
		document.form_commande.total.value = format_number((parseFloat(document.form_commande.quantite.value) * (parseFloat((24.9)*100))/100),2);
	}
}

function delNS()
{
	if (document.form_commande.quantite.value >= 1)
	{
		document.form_commande.quantite.value--; 
		document.form_commande.total.value = format_number((parseFloat(document.form_commande.quantite.value) * (parseFloat((24.9)*100))/100),2);
	}
}

function addNSB()
{
	if (document.form_commande.quantiteb.value < 999)
	{
		document.form_commande.quantiteb.value++;
		document.form_commande.totalb.value = format_number((parseFloat(document.form_commande.quantiteb.value) * (parseFloat((34.9)*100))/100),2);
	}
}

function delNSB()
{
	if (document.form_commande.quantiteb.value >= 1)
	{
		document.form_commande.quantiteb.value--; 
		document.form_commande.totalb.value = format_number((parseFloat(document.form_commande.quantiteb.value) * (parseFloat((34.9)*100))/100),2);
	}
}