
function gocat(o){
	if (o!=''){
		document.location.href= '/categorie-'+o+'.htm';
		}
	}

comboover = 0;
function showmecombocat(o){
    //document.getElementById("combocatdiv").className = 'combocatdiv_aveccombo';

    recup_xmlHttp=getXMLHTTP('');
    recup_xmlHttp.open("GET", "combo.php", false);
    recup_xmlHttp.send(null);
    resultats = recup_xmlHttp.responseText;

	combocatdiv.style.visibility = "visible";
	articlecombocat.style.visibility = "hidden";
	content = resultats;
    if(comboover==0){
        document.getElementById("combocatdiv").innerHTML = content;
        }
    comboover = 1;
    document.navcat.cat.value = o;
    }
function hidemecombocat(){
    //combocatdiv.style.visibility = "hidden";
    articlecombocat.style.visibility = "visible";
    }
/*
function yo(){
    alert('ya click');
    }
document.onDblClick = yo;
*/

// [FONCTION] tof v4.2
// popUp dynamique image
function tof(monImage){

    var AddXPH = 0;
    
    var chercheXP       = new RegExp("Windows NT 5.1","gi");// cherche XP pr agrandir les popUp
    var chercheVISTA    = new RegExp("Windows NT 6.0","gi");// cherche Vista pr agrandir les popUp
    if(chercheXP.test(navigator.appVersion)==true){
        AddXPH = 25;
        } else if (chercheVISTA.test(navigator.appVersion)==true){
        AddXPH = 50;
        }

    Lwindow = 700;
    Hwindow = 500;
	posX = (((screen.width)-Lwindow)/2);
	posY = (((screen.height)-Hwindow)/2);
    
	w = window.open('','chargement','width='+Lwindow+',height='+Hwindow+',scrollbars=1,status=no,top='+posY+',left='+posX);
	w.document.write( "<html><head><title>Photo</title>\n" );
	w.document.write( "<script language='JavaScript'>\n");
	w.document.write( "IE5=NN4=NN6=false;\n");
	w.document.write( "if(document.all)IE5=true;\n");
	w.document.write( "else if(document.getElementById)NN6=true;\n");
	w.document.write( "else if(document.layers)NN4=true;\n");
	w.document.write( "function autoSize() {\n");
	w.document.write( "LI = document.images[0].width; HI = document.images[0].height;\n");     // Image
	w.document.write( "LS = screen.width; HS = screen.height;\n");                             // Screen
	w.document.write( "LF = LI; HF = HI+50;\n");                                                  // Fenetre (si on ajoute pas de la hauteur, l'image est coupe)
	w.document.write( "moveToX = ((LS-LF)/2); moveToY = ((HS-HF)/2);\n");                        // Position Fenetre
	w.document.write( "if (LI>=LS){LF=LS-10;moveToX=0;}\n");
	w.document.write( "if (HI>=HS){HF=HS-30;moveToY=0;LF=LF+20;}\n");
	w.document.write( "self.moveTo(moveToX,moveToY);\n");  // on deplace avant de redimentionner sinon Pb
	w.document.write( "if(IE5) self.resizeTo(LF+10, HF+"+AddXPH+" );\n");
	w.document.write( "else window.resizeTo(LF, HF+15+"+ AddXPH+" );\n");
	w.document.write( "self.focus();\n");
	w.document.write( "document.getElementById('photo').style.display = 'none';\n");
	w.document.write( "if (moveToX!=0 && moveToY!=0) {document.body.style.overflow='hidden';}\n");
	w.document.write( "" );
	w.document.write( "}\n</scri");
	w.document.write( "pt>\n");
    w.document.write( "<meta http-equiv='imagetoolbar' content='no'>\n");
	w.document.write( "</head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onLoad='javascript:autoSize();'>" );
	w.document.write( "<div id=photo style='position:absolute;top:0;left:0;z-index:10;width:"+Lwindow+";text-align:center;background-color:#FF6600;color:#000000;font-weight:bold;'><br>Chargement...<br><br></div>" );
	w.document.write( "<a href='javascript:window.close();'><img src='"+monImage+"' border=0 alt='Cliquez pour FERMER'></a>");
	w.document.write( "</body></html>" );
	w.document.close();
	}

function whatcolor(c){
      document.getElementById("whatcolor").innerHTML = c;
      }
function whatcoloroff(){
      document.getElementById("whatcolor").innerHTML = '';
      }

// [FONCTION] caracteres_autorises v1.5
// caracteres autaurisés dans un champs
// caracteres_autorises('valeur a tester', 'liste des caracteres a controler', [affichage du nom du champs dans l'alert] )
// ex : caracteres_autorises(o.variable.value,'ct','nom');
//        if (testchaine!='ok'){
//                return false;
//                }
// a = alphaber, c = chiffres, t = trait d'union, u = underscore
function caracteres_autorises(atester, autorise ,nomchamps){
      testchaine = 'ok';
      chaine = autorise;
      var a = 'a-z'; // alphabet
      if (autorise.indexOf('a') < 0) { a = ''; }
      var c = '0-9'; // chiffre
      if (autorise.indexOf('c') < 0) { c = ''; }
      var t = '\\-'; // trait d'union
      if (autorise.indexOf('t') < 0) { t = ''; }
      var u = '\\_'; // underscore
      if (autorise.indexOf('u') < 0) { u = ''; }
      var e = '\\s'; // espace
      if (autorise.indexOf('e') < 0) { e = ''; }
      var caract_ok = '['+a+c+t+u+e+']';
      
      // on test les caractere valides
      jeTest = atester;
      for (var j=0 ; j<(jeTest.length) ; j++) {
            //var mon_exp = /[a-z0-9\-\_]/gi ;
            //var mon_exp = new RegExp ('[a-z0-9\-\_]','gi');
            var mon_exp = new RegExp (caract_ok, 'gi');
            var x = mon_exp.test(jeTest.charAt(j));
            var lepasbon = jeTest.charAt(j);
            if (lepasbon==' '){lepasbon = 'ESPACE';}
            if ( x == false ) {
                  alert('Le caractère \''+ lepasbon +'\' n\'est pas autorisé'+(nomchamps ? ' dans le champs "'+nomchamps+'"':''));
                  testchaine = 'ko';
                  return false;
                  }
        	}
        return testchaine=='ok'
        }

function panier_qt (qui, q, pr){
    nq = document.fpan.elements['qt'+qui].value;
    caracteres_autorises(nq, 'c', 'quantité');

    if(nq==q){
        alert('Veuillez saisir une quantité différente de celle actuelle');
        }else if(testchaine=='ok' && nq >0){
		url = document.location.pathname+'?newq='+nq+'&oldq='+q+'&pr='+pr;
        document.location.href=url;
        }
    }

function liste_qt (qui, q, pr, list){
    nq = document.fliste.elements['qt'+qui].value;
    caracteres_autorises(nq, 'c', 'quantité');

    if(nq==q){
        alert('Veuillez saisir une quantité différente de celle actuelle');
        }else if(testchaine=='ok' && nq >0){
		url = document.location.pathname+'?newq='+nq+'&oldq='+q+'&pr='+pr+'&voir='+list;
        document.location.href=url;
        }
    }

function dep(o, page){
	ou = o.departement.options[o.departement.selectedIndex].value;
	url = page+'?dep='+ou;
	document.location.href = url;
	}

// affiche/cache calque 1.0
	/*
	<a href='javascript:void(0);' onClick="javascript: showdiv('monId')">test</a>
	<div id='monId' style="position: relative; z-index:1; display: none; border: 1px solid #808080; padding:5; background-color:#F4F4F4">ok</div>
	*/
function showdiv(qui){
	if(document.getElementById(qui).style.display == "none"){
		document.getElementById(qui).style.display = "block";
		}else{
		document.getElementById(qui).style.display = "none";
		}
	}


// [FONCTION] verifMail v2
function verifMail(a) {
	testm =	false ;
	
	// on donne les caracteres autorisés
      testchaine = 'ok';
      chaine = a;
      var alphabet     = 'a-z';     // alphabet
      var chiffre      = '0-9';     // chiffre
      var trait        = '\\-';     // trait d'union
      var underscore   = '\\_';     // underscore
      var caract_ok    = '['+alphabet+chiffre+trait+underscore+'@\.]';
      // on test les caractere valides
      jeTest = a;
      for (var j=0 ; j<(jeTest.length) ; j++) {
            var mon_exp = new RegExp (caract_ok, 'gi');
            var x = mon_exp.test(jeTest.charAt(j));
            var lepasbon = jeTest.charAt(j);
            if (lepasbon==' '){lepasbon = 'ESPACE';}
            if ( x == false ) {
            	alert('Le caractère \''+ lepasbon +'\' n\'est pas valide dans une adresse Email');
            	testchaine = 'ko';
                  return false;
            	}
            }
      // on regarde la coherence de la structure du mail
	for (var j=1 ; j<(a.length) ; j++) {
            if (a.charAt(j)=='@') {
			if (j<(a.length-4)){
				for (var k=j ; k<(a.length-2) ;	k++) {
					if (a.charAt(k)=='.') testm = true;
						}
				}
			}
		}
	if (testm==false) { alert('Votre adresse e-mail est incorrecte.');return false}
	else { return true; }
	
		// ELSE	facultatif ; la	fonction retournant testm, la suite du traitement du formulaire	peut donc avoir	lieu
	return testm ; 
	}

// [FONCTION] getXMLHTTP v1.5
// retourne un objet xmlHttpRequest, méthode compatible entre tous les navigateurs (IE/Firefox/Opera)
// recup_xmlHttp=getXMLHTTP('');
// recup_xmlHttp.open("GET", "mapage.php", false);
// recup_xmlHttp.send(null);
// resultats = recup_xmlHttp.responseText;
function getXMLHTTP(err){
    var xhr=null;
    if(window.XMLHttpRequest) // Firefox et autres
    xhr = new XMLHttpRequest();
    else if(window.ActiveXObject){ // Internet Explorer
    try {
    xhr = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e1) {
    xhr = null;
    }
    }
    }
    else { // XMLHttpRequest non supporté par le navigateur
    if(err==1){alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");}
    }
    return xhr;
    }

// [FONCTION] remplichamps v1
// rempli automatiquement les champs
// remplichamps('nomFormulaire','texts de remplissage','typeDeChampsAexclure');
function remplichamps(qui,quoi,exclu){
    
    for(var i = 0; i < window.document.forms[qui].length ; i++) { 
        typechamps = window.document.forms[0].elements[i].type;
        //alert(typechamps);
        if(typechamps=='radio' && typechamps!=exclu){
            window.document.forms[0].elements[i].checked=true;
            }else if (typechamps=='checkbox'){
            window.document.forms[0].elements[i].checked=true;
            }else if (typechamps=='text'){
            window.document.forms[0].elements[i].value=quoi;
            }else if (typechamps=='textarea'){
            window.document.forms[0].elements[i].value=quoi;
            }else if (typechamps=='select-one'){
            //alert();
            window.document.forms[0].elements[i].options[window.document.forms[0].elements[i].selectedIndex].selected=true;
            //o.effectif.options[o.effectif.selectedIndex].value
            }else if (typechamps=='password'){
            window.document.forms[0].elements[i].value=quoi;
            }
        } 
    }

function viderpanier(){
    confirmation = confirm('Etes vous sur de vouloir vider la totalité de votre panier ?')
    if (confirmation=='0'){
        //return false;
        }else{
        //alert();
        document.location.href = 'panier.php?quoi=del_id&id=panier';
        }
    }

function msgliste(yo){
    var newimg = ''
        + '<table border=0 cellspacing=0 cellpadding=0 width="100" onClick="hidemsg()" id=tabmsgliste>'
        + '<tr>'
        + '<td align=right><img src="'+imgcom+'/close.gif" border=0 width=13 onClick="hidemsg()"></td>'
        + '</tr>'
        + '<tr>'
        + '<td valign=middle id=tabmsglistetxt>'+yo+'</td>'
        + '</tr>'
        + '</table>'
        + '';
    timer = setTimeout("hidemsg()", 3000);
    document.getElementById("msglisteadd").innerHTML = newimg;
    }
function hidemsg(){
    clearTimeout(timer);
    document.getElementById("msglisteadd").innerHTML = '';
    }

function check_listadd(o){
	couleurFocus = '#FFD8BA';
    //alert(o.listfrompanier.value.length);
    if ( o.listfrompanier.value.length < 4 ) {
          alert('Le nom de la liste doit contenir au moins 4 caractères');
          o.listfrompanier.style.background=couleurFocus;
          o.listfrompanier.focus();
          return false;
          }
    }

function lex(mot){
    lexique = window.open ("/lexique.php?def=1#"+mot, "f_lexique", "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,width=700,height=400");
    window.lexique.focus();
    }



// [FONCTION] coolPopUp 1.7.6 [12/08/2003 03:26] (n'est plus compatible avec les versions precedents 1.5)

// ex : javascript:goPopUp('../html/video.htm', l=200, h=100, nf=maFenetre, st=1, rs=1, mov=0, x=0, y=0, mb=yes)
//						l pour la largeur souhaité
//						h pour la hauteur souhaité
//						nf pour non de la fenetre
//						st=1 pour le status
//						rs=1 pour le resize
//						mov=1 pour center et/ou actionner
//						mb=[yes/no] menubar

// document.body.style.overflow='hidden';

var largeur = 500;
hauteur = 400;


var nomDeFenetre = "maFenetre";
var statu = "no";
var resize = "no";
var gomove = 0;
var dejaBouge = 0;

largeurEcran = screen.width;
hauteurEcran = screen.height;

// cherche XP pr agrandir les popUp
var chercheXP 	= new RegExp("Windows NT 5.1","gi");
cestXP	= chercheXP.test(navigator.appVersion);

function goPopUp (quelPage, l, h, nf, st, rs, mov, x, y, mb) {

	if ( typeof l   == 'undefined' || l  == '' ) { l   = largeur; } if (cestXP == true) { l = parseInt(l)+5;}
	if ( typeof h   == 'undefined' || h  == '' ) { h   = hauteur; } if (cestXP == true) { h = parseInt(h)+5;}
	if ( typeof nf  == 'undefined' || nf  == '') { nf  = nomDeFenetre; } 
	if ( typeof st  == 'undefined' || st  == '') { st  = statu; } else {st = "yes";}
	if ( typeof rs  == 'undefined' || rs  == '') { rs  = resize; } else {rs = "yes";}
	if ( typeof mov == 'undefined' || mov == '') { mov = gomove; }
	if ( typeof mb  == 'undefined' || mb == '') { mb = "no"; }

	posX = ((largeurEcran - l) / 2);
	posY = ((hauteurEcran - h) / 2);
	if ( typeof x  == 'undefined' || x  == '') { x  = posX; } else if ( x == 'd' && largeurEcran <= 1024 ){ x = largeurEcran - l; } else { x = 1024 - l; }

	if ( typeof y  == 'undefined' || y  == '') { y  = posY; }

	var adressePage       = quelPage;
	var parametresFenetre = "toolbar=no,location=no,directories=no,status="+st+",menubar="+mb+",scrollbars=yes,resizable="+rs+",width="+l+",height="+h+"'";
	coucou = window.open (adressePage, nf, parametresFenetre);
	
	window.coucou.resizeTo(l,h);
	if (mov == 1 && dejaBouge == 0) { window.coucou.moveTo(x,y); dejaBouge = 1;}
	mov = gomove;
	
	window.coucou.focus();
	}

