function ouvrehome()
{
var extension = ".html";
var url = "FR/index" + extension;
var ecran = window.screen;
var largeurecran = ecran.width;
var hauteurecran = ecran.height;
if (largeurecran > '1024')
 {var hauteur = '825';
 var largeur = '825';}
else
 {
 if( largeurecran >= '825' )
 {largeur = '825';}
 else
 {var largeur = largeurecran;}
 var hauteur = hauteurecran;
 }

//var newfenetre=window.open( url , "MARTY" , "width=790,height="+hauteur+",scrollbars=yes, resizable=yes, toolbar=yes, location=yes");
//var close = self.close();

window.resizeTo(largeur,hauteur);
window.moveTo(0,0);
top.location.href = url;
}

function ouvre(x)
{
var extension = ".html";
var url = "../catalogue/"+ x + extension;
var newfenetre=window.open( url , x , "width=453,height=620,scrollbars=yes");
}

function nuancier(x)
{
var extension = ".html";
var url = "nuance" + extension +"?nuci="+x;
var newfenetre=window.open( url , "Nuance" , "width=400,height=400");
}

function article(x)
{
var extension = ".html";
var url = "news" + extension +"?art="+x;
var newfenetre=window.open( url , "Article" , "width=453,height=600,scrollbars=yes");
}

function woodloc(x)
{
var extension = ".html";
var url = "wl" + extension +"?num="+x;
var newfenetre=window.open( url , "Montage" , "width=400,height=400");
}


function faq(x)
{
var extension = ".html";
var url = "faq" + x + extension;
var newfenetre=window.open( url , "FAQ" , "width=453,height=395,menubar=no,toolbar=no,resizable=no");
}

function job(x)
{
var extension = ".html";
var url = "job" + extension +"?art="+x;
var newfenetre=window.open( url , "Emploi" , "width=453,height=600,scrollbars=yes");
}

function popup(x, y)
{
var extension = ".html";
var url = x + extension;
var newfenetre=window.open( url , x , "width=350,height="+y+",scrollbars=no");
}

function newsHome(x)
{
var newfenetre=window.open( x , "" , "width=453,height=620,scrollbars=yes");
}

function voirPhoto(x)
{
var extension = ".html";
var url = "photo" + x + extension +"?photo="+x;
var newfenetre=window.open( url , "Photo" , "width=400,height=400");
}

function articleasp(x,y)
{
var url = "news.asp" +"?d1="+x+"&d2="+y;
var newfenetre=window.open( url , "Article" , "width=453,scrollbars=yes");
}

function faqasp(x,y)
{
var url = x.toLowerCase()+",faq,"+y+".html";
var newfenetre=window.open( url , "FAQ" , "width=453,height=395,menubar=no,toolbar=no,resizable=no");
}

function popupasp(x,y,z)
{
var url = x.toLowerCase() +".asp" + "?d1="+y ;
var newfenetre=window.open( url , "Marty" , "width=350,height="+z+",scrollbars=no");
}

function ouvreasp(x,y,z)
{
var url = y.toLowerCase()+','+x +".html";
var newfenetre=window.open( url , x , "width=453,height="+z+",scrollbars=yes");
}

function decorsasp(x,y)
{
var url = x.toLowerCase()+",decor,"+y+".html";
var newfenetre=window.open( url , "DECORS" , "width=453,height=600,scrollbars=no,menubar=no,toolbar=no,resizable=no");
}

function nuancierasp(x,y)
{
var url=x.toLowerCase()+',';
switch(y){
    case 2:
        url = url+'nuancier,multi.html';
        break;
    case 4:
        url = url+'nuancier,normal.html';
        break;
    case 5:
        url = url+'nuancier,dalles.html';
        break;
    default:
        url = url+'nuancier,normal.html';
        break;
}
//var newfenetre=window.open( url , "Nuancier" , "width=453,height=600,scrollbars=yes");
window.open(url,'mapage',config='height=700, width=420, toolbar=no, menubar=no, scrollbars=yes');
}

function voirphotoasp(x,y)
{

var url = "photo.asp"+ "?d1="+x +"&d2="+y;
var newfenetre=window.open( url , "Photo" , "width=400,height=400");
}


function trim(myString){
    return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
}

function getNameInp(txtIn){
    var id=txtIn.getAttribute("id");
    var labels=document.getElementsByTagName("label");
    var name=txtIn.name;
    for(var i=0;i<labels.length;i++){
        if(labels.item(i).getAttribute("for")==id){
            name=labels.item(i).innerHTML;
        }
    }
    return name;
}

function verifMdp(txtIn){
    var mdp=txtIn.value;
    mdp=trim(mdp);
    if(mdp.length!=8){
        alert("Votre mot de passe doit comporter 8 caractères, il en comporte "+mdp.length);
        txtIn.focus();
        return false;
    }
    return true;
}

function verifNonVide(txtIn,name){
    var txt=txtIn.value;
    txt=trim(txt);
    if(txt.length==0){
        //var name=getNameInp(txtIn);
        alert("Votre "+name+" ne doit pas être laissé vide");
        txtIn.focus();
        return false;
    }
    return true;
}

function verifCP(txtIn){
    if(verifNonVide(txtIn,'code postal')){
        var cp=txtIn.value;
        cp=trim(cp);
        if(isNaN(cp)){
            alert("Votre code postal : "+cp+", ne doit comporter que des chiffres");
            txtIn.focus();
            return false;
        }
        if(cp.length!=5){
            alert("Votre code postal : "+cp+", doit comporter 5 chiffres, il en comporte "+cp.length);
            txtIn.focus();
            return false;
        }
        return true;
    }else{
        return false;
    }
}

function verifTel(txtIn){
    if(verifNonVide(txtIn)){
        var no=txtIn.value;
        no=trim(no);
        for(var i=0;i<10;i++){
            no=no.replace(".", "");
            no=no.replace(" ", "");
            no=no.replace("-", "");
            no=no.replace("/", "");
        }
        if(isNaN(no)){
            var name=getNameInp(txtIn);
            alert("Votre "+name+" : "+no+", ne doit comporter que des chiffres");
            txtIn.focus();
            return false;
        }
        if(no.length!=10){
            var name=getNameInp(txtIn);
            alert("Votre "+name+" : "+no+", doit comporter 10 chiffres, il en comporte "+no.length);
            txtIn.focus();
            return false;
        }
        return true;
    }else{
        return false;
    }
}

function verifMail(txtIn){
    var mail=txtIn.value;
    mail=trim(mail);
    if(mail.length==0){
        alert("Votre e-mail ne doit pas être laissé vide");
        txtIn.focus();
        return false;
    }
    var arI=mail.indexOf('@');
    if(arI==-1){
        alert("Votre e-mail : "+mail+", doit comporter un arobase (@)");
        txtIn.focus();
        return false;
    }
    var ptI=mail.indexOf('.');
    if(ptI>0 && ptI<=arI+1){
        ptI=mail.indexOf('.', arI);
    }
    if(ptI==-1 || ptI>=mail.length-2){
        alert("Votre e-mail : "+mail+", doit finir par '.fr' ou '.com' par exemple");
        txtIn.focus();
        return false;
    }
    return true;
}

function verifNombre(txtIn){
    var nb=txtIn.value;
    nb=trim(nb);
    if(nb.length==0){
        var name=getNameInp(txtIn);
        alert("Votre "+name+" ne doit pas être laissé vide");
        txtIn.focus();
        return false;
    }
    if(isNaN(nb)){
        var name=getNameInp(txtIn);
        alert("Votre "+name+" : "+nb+", ne doit comporter que des chiffres");
        txtIn.focus();
        return false;
    }
    return true;
}

function verifDate(txtIn){
    if(verifNonVide(txtIn)){
        var date=txtIn.value;
        date=trim(date);
        var name=getNameInp(txtIn);
        if(date.length<6){
            alert("La "+name+" : "+date+", doit comporter au minmum 6 caractères, elle en comporte "+date.length);
            txtIn.focus();
            return false;
        }
        var res=date.split('/');
        if(res.length!=3){
            res=date.split('-');
            if(res.length!=3){
                alert("La "+name+" : "+date+", doit être séparée par des slashs (/) ou des tirets (-)");
                txtIn.focus();
                return false;
            }
        }
        var jour=res[0];
        var mois=res[1];
        var annee=res[2];
        if(isNaN(jour)){
            alert("Le jour de la "+name+" : "+jour+", ne doit comporter que des chiffres");
            txtIn.focus();
            return false;
        }
        if(isNaN(mois)){
            alert("Le mois de la "+name+" : "+mois+", ne doit comporter que des chiffres");
            txtIn.focus();
            return false;
        }
        if(isNaN(annee)){
            alert("L'année de la "+name+" : "+annee+", ne doit comporter que des chiffres");
            txtIn.focus();
            return false;
        }
        if(jour.length!=1&&jour.length!=2){
            alert("Le jour de la "+name+" : "+jour+", doit comporter un ou deux chiffres");
            txtIn.focus();
            return false;
        }
        if(mois.length!=1&&mois.length!=2){
            alert("Le mois de la "+name+" : "+mois+", doit comporter un ou deux chiffres");
            txtIn.focus();
            return false;
        }
        if(annee.length!=2&&annee.length!=4){
            alert("L'année de la "+name+" : "+annee+", doit comporter deux ou quatre chiffres");
            txtIn.focus();
            return false;
        }
        if(jour<1||jour>31){
            alert("Le jour de la "+name+" : "+jour+", doit être compris entre 1 et 31");
            txtIn.focus();
            return false;
        }
        if(mois<1||mois>12){
            alert("Le mois de la "+name+" : "+mois+", doit être compris entre 1 et 12");
            txtIn.focus();
            return false;
        }
        if(annee.length==4){
            if(annee<1880||annee>2030){
                alert("L'année de la "+name+" : "+annee+", doit être comprise entre 1880 et 2030");
                txtIn.focus();
                return false;
            }
        }else{
            var an=new Date();
            an=(an.getFullYear()+1).toString();
            an=an.substr(2,2);
            if(annee>an){
                annee="19"+annee;
            }else{
                annee="20"+annee;
            }
        }
        txtIn.value=jour+"/"+mois+"/"+annee;
        return true;
    }else{
        return false;
    }
}


