var coords = 'BALANDREAU - 61 chemin de la Muette - 07100 ANNONAY - Tél: 04.75.33.21.22 - Fax: 04.75.67.01.51';
window.defaultStatus = coords;

var table = '%0123456789_-.ab cdefgh+i=jklm:no/p?qrs@tuvwxyz%0123456789_-.ab cdefgh+i=jklm:no/p?qrs@tuvwxyz';
var key = 'croix2fer';

// Utiliser la fonction crypt_me pour coder adresse mail
// var mail_crypt = 'e/xnr8b4nd/3gpwzn86suhrw.208-'

function decrypt_me(valeur) {
    var result = '';
    if (key.length>0) {
        var t1 = table.length;
        var nMax = key.length - 1;
        var iMax = valeur.length;

        n = nMax;
        for (i=0; i<iMax; i++) {
            d = valeur.charAt(i);
            e = key.charAt(n);
            p = table.indexOf(d, 0);
            if (p>=0) {
                q = table.indexOf(e, 0);
                if (q>=0) {
                    p -= q
                    if (p<0)
                        p += t1;
                    n--;
                    if (n<0)
                        n = nMax;
                    }
                result += table.charAt(p);
                }
            else
                result += d;
            }
        }
    return result;
    }

var mail1 = '89rc=03k7mppn_72kq3./fm5';
var mail2 = 'os3w  %3y32st sj2ph0';

function write_mailto(titre) {
    // document.writeln('<a href="'+decrypt_me('e/xnr8benkqvh? %3y32st sj2ph07us@_8p:xSxw tI :qk2@w')+'">'+titre+'</a>');
    // document.writeln('<a href="'+decrypt_me('e/xnr8b876/0k a+mo3%ppba33_2q4oobj4w8q.lSgc3rfsI2.hp73:')+'">'+titre+'</a>');
    var courriel = decrypt_me(mail1);
    document.writeln('<a href="mailto:'+courriel+'?subject=Site%20Internet">'+titre+'</a>');
    }

function write_mail() {
    var courriel = decrypt_me(mail1);
    document.write('<a href="mailto:'+courriel+'?subject=Site%20Internet">'+courriel+'</a>');
    }
 
function write_mail_vente() {
    var courriel = decrypt_me(mail2);
    document.write('<a href="mailto:'+courriel+'?subject=vente%20machines">'+courriel+'</a>');
    }
 
var win1;

function enlarge(id) {
    var x,y;
    x = (screen.width-810)/2;
    y = 15;
    win1 = window.open("detail.php?id=" + id, "win1", "left="+x+",top="+y+",width=810,height=650,status=no,location=no");
    }
 
var verifMail = /^[.a-zA-Z0-9_-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,3}$/;
var verifSiret = /^[0-9]{14}$/;
var verifCP = /^[0-9]{5}$/;
var
verifTel = /^0\d\.(\d\d\.){3}\d\d$/;

function trim(value) {
    return value.replace(/(^\s*)|(\s*$)/g,'');
    }
 
/*
function adherentSaisieValid() {
    var result = false;
    if (document.adherent_edit.suppr_adh.value!='ok') {
        var nom = document.adherent_edit.nom;
        if (trim(nom.value)=='') {
            nom.focus();
            alert('Nom obligatoire !');
            }
        else {
            var ctrl = document.adherent_edit.mail;
            if (! verifMail.test(ctrl.value)) {
                ctrl.focus();
                alert('Adresse courriel non valide !');
                result = false;
                }
            else
                result = true;
            }
        }
    else
        result = true;
    if (result ) setTimeout('self.close();', 500);
    return result;
    }
*/
function validContact() {
	/* verifier nom, tel, mail, cp */
	var result = false;
	var frm = document.contact;
	var ctrl = frm.nom;
	if (trim(ctrl.value)=='') {
	    ctrl.focus();
	    alert('Le nom est obligatoire !');
	    }
	else {
	    ctrl = frm.mail;
	    if (! verifMail.test(ctrl.value)) {
		ctrl.focus();
        	alert('L\'adresse mail est incorrecte !');
	        }
		else {
			ctrl = frm.tel;
			if (! verifTel.test(ctrl.value)) {
				ctrl.focus();
				alert('Entrez votre n° de tél. au format suivant:\n01.23.45.67.89')
				}
			else { 
			    ctrl = frm.cp;
			    if (! verifCP.test(ctrl.value)) {
				ctrl.focus();
				alert('Merci de préciser votre code postal\navec 5 chiffres !')
				}
			else
			result = true;
			}
		    }
	    }
	return result;
	}

var dim = 1;
function autreDimensions() {
    dim++;
    if (dim>2) dim = 0;
    var s = document.dimensions.src;
    s = s.slice(0, -5);
    document.dimensions.src = s+dim+'.jpg';
    }

var win2;
function afficheEssence(nom) {
  if (nom!='') {
    win2 = window.open('essence.php?id=' + nom, 'win2', 'left=40, top=30, width=760, height=620');
    }
  return false;
  }
 
var win3;

function zoom(image1, titre1) {
  win3 = window.open('', 'win3', 'left=40, top=30, width=600, height=800');
  win3.document.open();
  win3.document.writeln('<html>\n<head><title>'+titre1+'</title><body>');
  win3.document.writeln('<a href="#" onclick="window.close(); return false;" title="Cliquez pour fermer"><img src="'+image1+'"></a>');
  win3.document.writeln('</body></html>');
  win3.document.close();
  p
  }

