﻿//ANIMATIONS FLASH
function CreateFlash(id, chemin, width, height, vars) {
    document.observe('dom:loaded', function() {
        //id : id de l'element dans lequel on va ecrire le flash    
        var d = document.getElementById(id);
        var flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '">' +
        '<param name="movie" value="' + chemin + '" />' +
        '<param name="quality" value="high" />' +
        '<param name="wmode" value="transparent" />' +
        '<param name="flashvars" value="' + vars + '">' +
        '<embed src="' + chemin + '" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" flashvars="' + vars + '" width="' + width + '" height="' + height + '"></embed></object>'
        d.innerHTML = flash
    });
}


function popup(url, titre, largeur, hauteur, scrollbar) {
    window.open(url, titre, 'width=' + largeur + ', height=' + hauteur + ', scrollbars=' + scrollbar);
}


// ##### VERIFICATION FORMULAIRES #####
var _nom, _prenom, _tel, _mail, _cp, _message, _login, _pw, _tva

function VerifFormContact() {
    if (!VerifChamps(document.getElementById("ctl00_Droite_nom"))) { _nom = false } else { _nom = true }
    if (!VerifChamps(document.getElementById("ctl00_Droite_prenom"))) { _prenom = false } else { _prenom = true }
    if (!VerifChamps(document.getElementById("ctl00_Droite_tel"))) { _tel = false } else { _tel = true }
    if (!VerifMail(document.getElementById("ctl00_Droite_email"))) { _mail = false } else { _mail = true }
    if (!VerifChamps(document.getElementById("ctl00_Droite_cp"))) { _cp = false } else { _cp = true }
    if (!VerifChamps(document.getElementById("ctl00_Droite_siret"))) { _tva = false } else { _tva = true }
    if (!VerifChamps(document.getElementById("ctl00_Droite_message"))) { _message = false } else { _message = true }


    if (_tva == false ||_nom == false || _prenom == false || _tel == false || _mail == false || _cp == false || _message == false) {
        document.getElementById("ctl00_Droite_laerror").style.display = 'block';
        return false
    }
    document.getElementById("ctl00_Droite_laerror").style.display = 'none';
    return true
}

function VerifFormNewsletter() {
    if (!VerifMail(document.getElementById("ctl00_Droite_email"))) { _mail = false } else { _mail = true }
    
    if ( _mail == false ) {
        document.getElementById("ctl00_Droite_laerror").style.display = 'block';
        return false
    }
    document.getElementById("ctl00_Droite_laerror").style.display = 'none';
    return true
}

function VerifFormLog() {
    //if (!VerifChamps(document.getElementById("ctl00_Droite_login"))) { _login = false } else { _login = true }
    if (!VerifChamps(document.getElementById("ctl00_Droite_pw"))) { _pw = false } else { _pw = true }

    if ( _pw == false) {
        document.getElementById("ctl00_Droite_laerror").style.display = 'block';
        return false
    }
    document.getElementById("ctl00_Droite_laerror").style.display = 'none';
    return true
}

function inviteEmail(c) {
    if (c.value == 'adresse email') { c.value = ''; return false }
    else if (c.value == '') { c.value = 'adresse email'; return true }
}

function VerifChamps(c) {
    if (!c.value) { c.className = 'champcontacterreur bloq'; return false }
    else { c.className = 'champcontact bloq'; return true }
}

function FocusChamps(c) { c.className = 'champfocus bloq'; }

function BlurChamps(c) { c.className = 'champcontact bloq'; }

function VerifMail(c) {
    if (!c.value) { c.className = 'champcontacterreur bloq'; return false }
    else if (c.value.search(/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9]+)*$/) == -1) { c.className = 'champcontacterreur bloq'; return false }
    else { c.className = 'champcontact bloq'; return true }
}


///// Effet d'apparition / disparition
function bascule(c) {

    if ($('detail' + c)) {
        var current_previous = $('detail' + c).parentNode.previousSibling;
        while (current_previous != null) {
            current_previous.lastChild.style.display = 'none';
            current_previous = current_previous.previousSibling;
        }

        var current_next = $('detail' + c).parentNode.nextSibling;
        while (current_next != null) {
            if (current_next.lastChild != null) {
                if (current_next.lastChild.style != undefined) {
                    current_next.lastChild.style.display = 'none';
                }

            }
            current_next = current_next.nextSibling;
        }


        Effect.toggle('detail' + c, 'blind');
    }
    return false
}

window.onload = function () {


    //Affichage menu
    var current = $$('[keycat=' + categorie + ']')[0];
    //var currentproduit = $$('[keyproduit=' + produit + ']')[0];
    current.className = 'active';
    //currentproduit.className = 'active';

    while (current.tagName == 'UL' || current.tagName == 'LI') {
        current.style.display = 'block';
        current = current.parentNode;
    }

}
