//-----------------------------------------------------------------------------//
//   -----------------------------------------------------------------------   //
//                       BIBLIOTHEQUE JAVASCRIPT                               //
//                                                                             //
//-----------------------------------------------------------------------------//
defaultStatus = "Tech Buro, le Spécialiste des Consommables Constructeurs";
strHAUTEURDEFAUT = screen.height;
strLARGEURDEFAUT = screen.width;

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];}
}
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_openBrWindow(theURL,winName,features) { //v2.0
   window.open(theURL,winName,features);
}


function OpenPop(u,n,w,h,t,l,d,s,m,sc,r){//url;name;width;height;toolbar;location;direction;status;menubar;scrollbar;resizable
  var top=(window.screen.availHeight-h)/2;
  var left=(window.screen.availWidth-w)/2;

  window.open(u,n,'top='+top+',left='+left+',toolbar='+t+',location='+l+',directories='+d+',status='+s+',menubar='+m+',scrollbars='+sc+',resizable='+r+',width='+w+',height='+h);
}
//   ---------------------------------
//   FONCTIONS DATES FR ET US
//   --------------------------------
function Jours(){
  this[0]="Dimanche"; this[1]="Lundi";
  this[2]="Mardi"; this[3]="Mercredi";
  this[4]="Jeudi"; this[5]="Vendredi";
  this[6]="Samedi";
}
//   --------------------------------
function Mois(){
  this[0]="Janvier"; this[1]="Février";
  this[2]="Mars"; this[3]="Avril";
  this[4]="Mai"; this[5]="Juin";
  this[6]="Juillet"; this[7]="Août";
  this[8]="Septembre"; this[9]="Octobre";
  this[10]="Novembre"; this[11]="Décembre";
}
//   --------------------------------
function Days(){
  this[0]="sunday"; this[1]="Monday";
  this[2]="tuesday"; this[3]="Wednesday";
  this[4]="Thursday"; this[5]="Friday";
  this[6]="Saturday";
}
//   --------------------------------
function Months() {
  this[0]="January"; this[1]="February";
  this[2]="March"; this[3]="April";
  this[4]="May"; this[5]="June";
  this[6]="July"; this[7]="August";
  this[8]="September"; this[9]="October";
  this[10]="November"; this[11]="December";
}
//   -------------------------------
function DateFr(){
  var now = new Date();
  var jour = new Jours();
  var mois=new Mois();

 // return " " + jour[now.getDay()] + " " + now.getDate() + " " + mois[now.getMonth()] + " " + now.getFullYear();
 return " " + jour[now.getDay()] + " " + now.getDate() + " " + mois[now.getMonth()]+ " " + now.getFullYear();
}
//   -------------------------------
function DateUs(){
  var now = new Date();
  var day=new Days();
  var month=new Months();
  return " " + day[now.getDay()] + ", " + now.getDate() + " " + month[now.getMonth()] + " " + now.getFullYear();
}
//   --------------------------------
function DateNumFr(){
  var now = new Date();
  var jour = now.getDate();
  var mois = now.getMonth()+1;

  return " " + ((jour > 9) ? "" : "0") + jour + "." + ((mois > 9) ? "" : "0") + mois + "." + now.getFullYear();
}
//   ---------------------------------
function DateNumUs(){
  var now = new Date();
  var day = now.getDate();
  var month = now.getMonth()+1;
  return " " + ((month > 9) ? "" : "0") + month + "." + ((day > 9) ? "" : "0") + day + "." + now.getFullYear();
}
//   ---------------------------------
function TimeNow() {
  var now=new Date(); var hour=now.getHours(); var min=now.getMinutes(); var sec=now.getSeconds();
  return " " + ((hour > 9) ? "" : "0") + hour + ":" + ((min > 9) ? "" : "0") + min + ":" + ((sec > 9) ? "" : "0") + sec;
}
//   ----------------------------------
//   ----------------------------------
function ValidIinscription() {

  var objForm = document.frmINSCRIPTION;

  missinginfo = "";

  if (objForm.strMAIL.value == "" || objForm.strMAIL.value.indexOf('@',0) == -1 || objForm.strMAIL.value.indexOf('.',0) == -1 || objForm.strMAIL.value.indexOf('\'',0) == 0 || objForm.strMAIL.value.indexOf('"',0) == 0 ){
    missinginfo += "\n     -  Email";
  }
  if (objForm.strPWD.value == ""){
    missinginfo += "\n     -  Mot de Passe";
  }
  if (objForm.strPWD2.value == "" || objForm.strPWD2.value != objForm.strPWD.value){
    missinginfo += "\n     -  Confirmation du mot de passe";
  }

  if (missinginfo != "") {
    missinginfo ="______________________________\n" + "Vous n'avez pas rempli correctement:\n" + missinginfo + "\n______________________________" +  "\nRecommencez s'il vous plait.";
    alert(missinginfo);
    return false;
  }

}
//   ----------------------------------
//   ----------------------------------
function ValidEnvoi() {

  var objForm = document.frmINSCRIPTION;

  missinginfo = "";

  if (objForm.strMAIL.value == "" || objForm.strMAIL.value.indexOf('@',0) == -1 || objForm.strMAIL.value.indexOf('.',0) == -1 || objForm.strMAIL.value.indexOf('\'',0) == 0 || objForm.strMAIL.value.indexOf('"',0) == 0 ){
    missinginfo += "\n     -  Email";
  }

  if (missinginfo != "") {
    missinginfo ="______________________________\n" + "Vous n'avez pas rempli correctement:\n" + missinginfo + "\n______________________________" +  "\nRecommencez s'il vous plait.\ntech-Buro 2003";
    alert(missinginfo);
    return false;
  }

}
//   ----------------------------------
function ValidMembre() {

  var objForm = document.frmINSCRIPTION;

  missinginfo = "";

  if (objForm.strMAIL.value == ""){
    missinginfo += "\n     -  Identifiant";
  }
  if (objForm.strPWD.value == ""){
    missinginfo += "\n     -  Mot de Passe";
  }

  if (missinginfo != "") {
    missinginfo ="______________________________\n" + "Vous n'avez pas rempli correctement:\n" + missinginfo + "\n______________________________" +  "\nRecommencez s'il vous plait.\ntech-Buro 2003";
    alert(missinginfo);
    return false;
  }

}
//   ----------------------------------
//   ----------------------------------
function ValidADHERENT() {

  var objForm = document.frmADHERENT;

  missinginfo = "";

	if (objForm.soc.checked) {
		if (objForm.strRSF.value =="") {
			missinginfo += "\n     -  Raison sociale";
		}
		if (objForm.strSIRETF.value =="") {
			missinginfo += "\n     -  N° de Siret";
		}
		if (objForm.strAPEF.value =="") {
			missinginfo += "\n     -  Code APE";
		}
		if (objForm.strTVAF.value =="") {
			missinginfo += "\n     -  N° de Tva";
		}
	}
  if (objForm.strCIVILITEF.value == ""){
    missinginfo += "\n     -  Civilité";
  }
  if ( (objForm.strNOMF.value == "") || (objForm.strNOMF.value.length <3)) {
    missinginfo += "\n     -  Nom";
  }
  if (objForm.strPRENOMF.value == ""){
    missinginfo += "\n     -  Prénom";
  }
  if (objForm.strADRESSEF.value == ""){
    missinginfo += "\n     -  Adresse";
  }
  if ( (objForm.intCPF.value == "") || (isNaN(objForm.intCPF.value) ) ){
    missinginfo += "\n     -  Code Postal";
  }
  if (objForm.strVILLEF.value == ""){
    missinginfo += "\n     -  Ville";
  }
  if (objForm.strPAYSF.value == ""){
    missinginfo += "\n     -  Pays";
  }
  if (objForm.strTELF.value == ""){
    missinginfo += "\n     -  Téléphone";
  }
  if (objForm.strMAILF.value == "" || objForm.strMAILF.value.indexOf('@',0) == -1 || objForm.strMAILF.value.indexOf('.',0) == -1 || objForm.strMAILF.value.indexOf('\'',0) == 0 || objForm.strMAILF.value.indexOf('"',0) == 0 ){
    missinginfo += "\n     -  Email";
  }
  if (objForm.action.value =='INS') {
  	if (objForm.pwd.value == ""){
    	missinginfo += "\n     -  Mot de Passe";
  	}
  	if (objForm.pwd2.value == ""){
    	missinginfo += "\n     -  Confirmation du Mot de Passe";
  	}
  }
  if (objForm.pwd.value != objForm.pwd2.value){
    missinginfo += "\n     -  Confirmation du Mot de Passe incorrecte";
  }

  if (missinginfo != "") {
    missinginfo ="______________________________\n" + "Vous n'avez pas rempli correctement:\n" + missinginfo + "\n______________________________" +  "\nRecommencez s'il vous plait.\ntech-Buro 2003";
    alert(missinginfo);
    return false;
  }

}
//   ----------------------------------
// FONCTION AJOUT +- 1 DE LA QUANTITE
function modifQUANT(strINDEX, intQUANT){
  majQUANT(strINDEX,intQUANT);
}
//   ----------------------------------
// FONCTION DE MAJ DE LA QUANTITE
function majQUANT(strINDEX, intNEW){

                var intVAL=0;
                var intQUANT=Number(document.sele["INTQUANT["+ String(strINDEX)+"]"].value);


                if ( isNaN(intQUANT)) {
                        intVAL = 1;
                }
                else {
                        intVAL = intQUANT;
                }

                if (intNEW == 1) {
                        intVAL=intVAL+1 ;
                }
                if (intNEW == -1) {
                        intVAL=intVAL-1 ;
                }

                if (intNEW == 0) {
                        if (intVAL < 0) {
                                intVAL = 0;
                        }
                        intVAL=intVAL ;
                }
                if (intVAL < 0) {
                                intVAL = 0;
                }
                document.sele["INTQUANT["+ String(strINDEX)+"]"].value = String(intVAL);
}
//   ----------------------------------
// FONCTION IMPRESSION
function Print(){self.print();}
//   ----------------------------------
//   ----------------------------------
// FONCTION DATE
function PopupTime(){window.setTimeout('self.close();',5000);}
//   ----------------------------------

/**
 *
 * @access public
 * @return void
 **/
function majHt_TTC( form, value, loc ) {
//	document.forms["sele"].elements["HT_TTC"].value = value;
	form.elements["HT_TTC"].value = value;
	regexist = new RegExp ( "(&HT_TTC=[0-9])", "gi");
	if ( loc.match (regexist) ){
		if ( value == 0 ) {
			reg = "(&HT_TTC=1)";
		} else reg = "(&HT_TTC=0)";
		regrpl = new RegExp ( reg, "gi" );
		window.location.href = loc.replace ( regrpl, "&HT_TTC=" + value );
	} else window.location.href = loc + "&HT_TTC=" + value;
}

/**
 *
 * @access public
 * @return void
 **/
function switchRS( value ){
	if (value) {
		document.getElementById("divRS").className="visible";
//		document.getElementById("msgSoc").className="visible";
	}else {
		document.getElementById("divRS").className="hidden";
//		document.getElementById("msgSoc").className="hidden";
	}
}