/*

  Mediom Internet Copyright (Inc)
  
  Programme : jscript.js
  
  Description : fonctions javascript qui gère l'ensemble du site votre dossier
  				
    version 0.1
    Auteur : David REGNIER
    Date de création : 2004-05-11
    Date de modification : 
                    
*/


/*
  Validation code postal
*/
function isPostCode(entry)
{ 
    entry = entry.replace(" ","");
    strlen = entry.length; if (strlen != 6) {return false;}
    entry = entry.toUpperCase();        
    if ('ABCDEFGHJKLMNPQRSTUVWXYZ'.indexOf(entry.charAt(0)) < 0) {return false;}
    if ('0123456789'.indexOf(entry.charAt(1)) < 0) {return false;}
    if ('ABCDEFGHJKLMNPQRSTUVWXYZ'.indexOf(entry.charAt(2)) < 0) {return false;}
    if ('0123456789'.indexOf(entry.charAt(3)) < 0) {return false;}
    if ('ABCDEFGHJKLMNPQRSTUVWXYZ'.indexOf(entry.charAt(4)) < 0) {return false;}
    if ('0123456789'.indexOf(entry.charAt(5)) < 0) {return false;}
    return true;
}

/*
  Validation du numéro de téléphone
*/  
function validation_telephone(telephone)
{
    numero = telephone;
    var Valid="true";
    if (telephone.length != 12)
        Valid="false";

    if (Valid == "true")
    {
        if ('0123456789'.indexOf(numero.charAt(0)) < 0)
            Valid="false";
        if ('0123456789'.indexOf(numero.charAt(1)) < 0)
            Valid="false";
        if ('0123456789'.indexOf(numero.charAt(2)) < 0)
            Valid="false";
        if ('0123456789'.indexOf(numero.charAt(4)) < 0)
            Valid="false";
        if ('0123456789'.indexOf(numero.charAt(5)) < 0)
            Valid="false";
        if ('0123456789'.indexOf(numero.charAt(6)) < 0)
            Valid="false";
        if ('0123456789'.indexOf(numero.charAt(8)) < 0)
            Valid="false";
        if ('0123456789'.indexOf(numero.charAt(9)) < 0)
            Valid="false";
        if ('0123456789'.indexOf(numero.charAt(10)) < 0)
            Valid="false";
        if ('0123456789'.indexOf(numero.charAt(11)) < 0)
            Valid="false";
    }
    return Valid;
}

/*
  Valide l'adresse email
*/
function mail(str) {
                var at="@"
                var dot="."
                var lat=str.indexOf(at)
                var lstr=str.length
                var ldot=str.indexOf(dot)
                if (str.indexOf(at)==-1)
                {
                   alert("Votre Courriel est invalide")
                   return false
                }
                if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
                {
                   alert("Votre Courriel est invalide")
                   return false
                }
                if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
                {
                    alert("Votre Courriel est invalide")
                    return false
                }
                if (str.indexOf(at,(lat+1))!=-1)
                {
                    alert("Votre Courriel est invalide")
                    return false
                }
                if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
                {
                    alert("Votre Courriel est invalide")
                    return false
                }
                if (str.indexOf(dot,(lat+2))==-1)
                {
                    alert("Votre Courriel est invalide")
                    return false
                }
                if (str.indexOf(" ")!=-1)
                {
                    alert("Votre Courriel est invalide")
                    return false
                }
         return true
}
