var hauteur = screen.height;
var largeur = screen.width;

function ouvrirRecherche() {
    var recherche = window.open("/recherche.shtml", "recherche", "left=" + (largeur - 700) / 2 + ", top=" + (hauteur - 500) / 2 + ",height=500, width=710, scrollbars=1,status=1");
    recherche.focus();
}

function choisir(siren) {
    document.recherche.reset();
    document.recherche.siren.value = siren;
    document.recherche.submit();
}

function afficherMenu(numero) {
    var menu = document.getElementById("Menu" + numero);
    var lien = document.getElementById("lienMenu" + numero);
    lien.className = "texteMenuOver";
    var x = findPos(lien)[0];
    var y = findPos(lien)[1];
    menu.x = x;
    menu.y = y;
    menu.style.left = x + "px";
    menu.style.top = (y + 22) + "px";
    menu.style.visibility = "visible";
}

function masquerMenu(numero) {
    var menu = document.getElementById("Menu" + numero);
    var lien = document.getElementById("lienMenu" + numero);
    lien.className = 'texteMenu';
    menu.style.visibility = 'hidden';
}

function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) {
            curleft += obj.offsetLeft
            curtop += obj.offsetTop
        }
    }
    return [curleft,curtop];
}

function envoi(formulaire) {
    var text = "";
    with (formulaire) {
        if (nom.value <= " ") {
            text += "- votre nom\n";
        }
        if (prenom.value <= " ") {
            text += "- votre prénom\n";
        }
        if (adresse.value <= " ") {
            text += "- votre adresse\n";
        }
        if (cp.value <= " ") {
            text += "- le code postal\n";
        }
        if (ville.value <= " ") {
            text += "- la ville\n";
        }
        if (choix.value == "e-mail" && email.value <= " ") {
            text += "- votre e-mail\n";
        }
        if (choix.value == "téléphone" && tel.value <= " ") {
            text += "- votre téléphone\n";
        }
        if (choix.value == "fax" && fax.value <= " ") {
            text += "- votre fax\n";
        }
        if (prof.value <= " ") {
            text += "- votre profession\n";
        }
        if (text != "") {
            alert("Vous n'avez pas saisi :\n" + text);
            return(false);
        } else {
            return(true);
        }
    }
}

function envoi_es(formulaire) {
    var text = "";
    with (formulaire) {
        if (nom.value <= " ") {
            text += "- Su appellido\n";
        }
        if (prenom.value <= " ") {
            text += "- su nombre\n";
        }
        if (adresse.value <= " ") {
            text += "- su dirección\n";
        }
        if (cp.value <= " ") {
            text += "- el código postal\n";
        }
        if (ville.value <= " ") {
            text += "- la ciudad\n";
        }
        if (choix.value == "e-mail" && email.value <= " ") {
            text += "- su e-mail\n";
        }
        if (choix.value == "téléphone" && tel.value <= " ") {
            text += "- su teléfono\n";
        }
        if (choix.value == "fax" && fax.value <= " ") {
            text += "- su fax\n";
        }
        if (prof.value <= " ") {
            text += "- su profesión\n";
        }
        if (text != "") {
            alert("Usted no ha entrado :\n" + text);
            return(false);
        } else {
            return(true);
        }
    }
}

function candidature(formulaire) {
    var text = "";
    with (formulaire) {
        if (nom.value <= ' ') {
            text += "- votre nom\n";
        }
        if (prenom.value <= ' ') {
            text += "- votre prénom\n";
        }
        if (adresse.value <= ' ') {
            text += "- votre adresse\n";
        }
        if (cp.value <= ' ') {
            text += "- le code postal\n";
        }
        if (ville.value <= ' ') {
            text += "- la ville\n";
        }
        if (email.value.length < 5) {
            text += "- votre e-mail\n";
        }
        if (choix.value == 'téléphone' && tel.value <= ' ') {
            text += "- votre téléphone\n";
        }
        if (prof.value <= ' ') {
            text += "- votre profession\n";
        }
        if (text == "") {
            return(true);
        } else {
            alert("Vous n'avez pas saisi :\n" + text);
            return(false);
        }
    }
}

function ouvrirSondage(sondage) {
    t = ((screen.height - 600) / 2)
    l = ((screen.width - 1024) / 2)
    var win = window.open("/sondages/" + sondage, "_blank", "width=1024,height=500,scrollbars=1,resizable=1,left=" + l + ",top=" + t)
    win.focus();
}

/*******************
 Ecriture d'un cookie
 *******************/
function definirCookie(nom, valeur) {
    var argv = definirCookie.arguments;
    var argc = definirCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = nom + "=" + escape(valeur) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}

function ecrireCookie(nom, valeur) {
    var expiration = new Date();
    var cinqAns = expiration.getTime() + (5 * 365 * 24 * 60 * 60 * 1000);
    expiration.setTime(cinqAns);
    definirCookie(nom, valeur, expiration);
}

function lienClient(site) {
    document.accesClient.action = site;
    document.accesClient.submit();
}

function afficher(info) {
    var infoBulle = document.getElementById("L" + info);
	var infoSpan = document.getElementById("I" + info);
    var posx = findPos(infoSpan)[0];
    var posy = findPos(infoSpan)[1];
    infoBulle.style.left = (posx - 80) + "px";
    infoBulle.style.top = (posy + 20) + "px";
    infoBulle.style.visibility = "visible";
}

function masquer(info) {
    var infoBulle = document.getElementById("L" + info);
    infoBulle.style.left = 0;
    infoBulle.style.top = 0;
    infoBulle.style.visibility = "hidden";
}

function imprimer(page) {
    var impression = window.open(page, "impression", "width=750,height=550,left=10,top=10,menubar=1,status=1,titlebar=1,toolbar=1,scrollbars=1");
    impression.focus();
}

function retour() {
    if (history.previous == null)
        self.close();
    else
        history.back();
}