
if (!ToggleImages) {
    var ToggleImages = true;  // Uses images by default
}
if (!ToggleImageOpen) {
    var ToggleImageOpen = "url(../Images/btnToggleDown.gif)";  // Uses this image by default for the open button
}
if (!ToggleImageClose) {
    var ToggleImageClose = "url(../Images/btnToggleUp.gif)";  // Uses this image by default fot the close button
}
if (!ToggleCloseAll) {
    var ToggleCloseAll = true;  // By default, only one Toggle div can be opened
}


function toggleCloseAll(which, whichNotToClose) {
    // Close all Toggles
    // which = the div containing all the "ToggleContainer" classed Divs
    // l is the number of sibling "ToggleContainer"s
    l = which.childNodes.length;

    // We need to search all the siblings to close all the toggles
    for (i=0; i < l; i++) {
        // te = this element
        te = which.childNodes[i];

        if (te.className == "ToggleContainer" && te != whichNotToClose) {
            // We've found a sibbling, we need to search it for a "ToggleContent" to hide and
            // a "ToggleH2" to switch the +/- background
            // sl = number of elements in this toggleContainer
            sl = te.childNodes.length;
            for (j=0; j < sl; j++) {
            
                // tse = this sub-element
                tse = te.childNodes[j];
                if (te.childNodes[j].className) {
                    // hide this content
                    if (te.childNodes[j].className == "ToggleContent") {
                            te.childNodes[j].style.display = "none";
                    }
                    // Change this icon
                    if (te.childNodes[j].className == "ToggleH2" && ToggleImages) {
                         te.childNodes[j].style.backgroundImage = ToggleImageClose;
                    }
                }
            }               
        }
    }
}

function toggle(which) {
    // Close all Toggles before we open another
    if (ToggleCloseAll) {
        toggleCloseAll(which.parentNode.parentNode, which.parentNode); // Close all toggles EXCEPT this one
    }
    
    // Check all elements whithin this ToggleContainer    
    l = which.parentNode.childNodes.length;
    
    for (i = 0; i < l; i++) {
        cn = which.parentNode.childNodes[i];
        // Find the title h2 and the content div
        if (cn.className) { 
            if (cn.className == "ToggleH2") {
                title = which.parentNode.childNodes[i];
            }
            if (cn.className == "ToggleContent") {
                content = which.parentNode.childNodes[i];
            }
        }
    }

    // Toggle them on / off
    if (content.style.display != "inline") {
        content.style.display = "inline";
        if (ToggleImages) {
            title.style.backgroundImage = ToggleImageOpen;
            title.style.backgroundImage = ToggleImageOpen;
        }    
    } else {
        content.style.display = "none";
        if (ToggleImages) {
            title.style.backgroundImage = ToggleImageClose;
            title.style.backgroundImage = ToggleImageClose;
        }
    }
}

function openToggle(which) {
    // To Open a Toggle by it's ID
    // Assign an id to the ToggleH2 classed <h2> tag
    
    findElement = document.getElementById(which);
    toggle(findElement)
}

    function xPansCustom(valId, lbl, txtIN, txtOUT) {
        var div = document.getElementById(valId);
        var lbl = document.getElementById(lbl)
        div.style.display = (div.style.display == "none" ? "block" : "none");
        lbl.innerHTML =  (div.style.display == "none" ? txtIN : txtOUT);

    }


    var westcliff = {
        concoursSaisons: function() {

            $("input[id$=tbxNom]").attr("title", "Nom <span class='asterix'>*</span>");
            $("input[id$=tbxPrenom]").attr("title", "Pr&eacute;nom <span class='asterix'>*</span>");
            $("input[id$=tbxCourriel]").attr("title", "Courriel <span class='asterix'>*</span>");
            $("input[id$=tbxAdresse]").attr("title", "Adresse <span class='asterix'>*</span>");
            $("input[id$=tbxVille]").attr("title", "Ville <span class='asterix'>*</span>");
            $("input[id$=tbxCP]").attr("title", "Code postal <span class='asterix'>*</span>");
            $("input[id$=tbxTel]").attr("title", "T&eacute;l&eacute;phone");



            $.fn.formLabels();

            $('[id$=btnSend]').click(function() {
                return false;
            });

            $('#pageConcours').validate({
                postBackLink: $('[id$=btnParticiper]'),
                submit: false,
                showImage: false,
                asterisk: false,
                tooltip: false
            });


            $('#btFermer').click(function() {
                window.parent.Shadowbox.close();
            });
            westcliff.validerCaptcha();
        },


        //permet de mettre la valeur de ce que l'on entre dans le champs du captcha dans un champ caché qui est validé
        validerCaptcha: function() {
            $('#recaptcha_response_field').val($('input[id$=hiddenCapcha]').val());

            $('#recaptcha_response_field').keyup(function(e) {

                $('input[id$=hiddenCapcha]').val($(this).val());
                $('input[id$=hiddenCapcha]').focus();
                $('input[id$=hiddenCapcha]').blur();
                $(this).focus();


            });
        }
    }
    
 

