/// <reference name="MicrosoftAjax.debug.js" />
/// <reference name="MicrosoftAjaxTimer.debug.js" />
/// <reference name="MicrosoftAjaxWebForms.debug.js" />
/// <reference name="AjaxControlToolkit.Common.Common.debug.js" assembly="AjaxControlToolkit" />
/// <reference name="AjaxControlToolkit.ExtenderBase.BaseScripts.debug.js" assembly="AjaxControlToolkit" />
/// <reference name="AjaxControlToolkit.DynamicPopulate.DynamicPopulateBehavior.debug.js" assembly="AjaxControlToolkit" />
/// <reference name="AjaxControlToolkit.HoverExtender.HoverBehavior.debug.js" assembly="AjaxControlToolkit" />
/// <reference name="AjaxControlToolkit.Compat.Timer.Timer.debug.js" assembly="AjaxControlToolkit" />
/// <reference name="AjaxControlToolkit.Animation.Animations.debug.js" assembly="AjaxControlToolkit" />
/// <reference name="AjaxControlToolkit.Animation.AnimationBehavior.debug.js" assembly="AjaxControlToolkit" />
/// <reference name="AjaxControlToolkit.PopupExtender.PopupBehavior.debug.js" assembly="AjaxControlToolkit" />
/// <reference name="AjaxControlToolkit.HoverMenu.HoverMenuBehavior.debug.js" assembly="AjaxControlToolkit" />
/// <reference path="./javascript/Utils.js" />

if (!document.getElementById) {
    if (document.all) {
        document.getElementById = function() {
            if (typeof document.all[arguments[0]] != "undefined") { return document.all[arguments[0]]; } else { return null; }
        }
    } else if (document.layers) {
        document.getElementById = function() {
            if (typeof document[arguments[0]] != "undefined") { return document[arguments[0]]; } else { return null; }
        }
    }
}

function show_hideflash(monflash, show_hide) {

    monflash_div = document.getElementById(monflash)
    if (monflash_div) {
        if (show_hide == "hide") monflash_div.style.visibility = "hidden";
        else
            monflash_div.style.visibility = "visible";
    }
}

//verif checexbox ident

function check_certifier() {
    mon_checkbox = document.getElementById("ctl00_cph_main_chk_certify");
    if (mon_checkbox.checked == false) alert("Pour continuer, vous devez absolument cocher la case ci-dessus \"JE DECLARE...\" (texte en rouge) pour certifier exactes les informations que vous nous transmettez.");
}


//calques

function show_hide(laction, calquelib, calqueaction, libtitle, libplus, txtlien) {
    lib = "";
    mon_div_lib = document.getElementById(calquelib);
    mon_div_action = document.getElementById(calqueaction);

    if (laction == "show") {
        lib = "Masquer" + libplus;
        if (txtlien != "standard") lib = txtlien;
        mon_div_action.style.display = "block";
        //document.all[calquelib].style.color="yellow"
        mon_div_lib.innerHTML = "<a href='javascript:show_hide(\"hide\",\"" + calquelib + "\",\"" + calqueaction + "\",\"" + libtitle + "\",\"" + libplus + "\",\"" + txtlien + "\")' onmouseover=\"this.className='ButtonMouseOver'\" onclick=\"this.className='ButtonPressed'\" onmouseOut=\"this.className='ButtonNormal'\" class='ButtonNormal' title='Masquer " + libtitle + "'>" + lib + "</a>";
    }
    else {
        lib = "Afficher" + libplus;
        if (txtlien != "standard") lib = txtlien;
        mon_div_action.style.display = "none";
        mon_div_lib.innerHTML = "<a href='javascript:show_hide(\"show\",\"" + calquelib + "\",\"" + calqueaction + "\",\"" + libtitle + "\",\"" + libplus + "\",\"" + txtlien + "\")' onmouseover=\"this.className='ButtonMouseOver'\" onclick=\"this.className='ButtonPressed'\" onmouseOut=\"this.className='ButtonNormal'\" class='ButtonNormal' title='Afficher " + libtitle + "'>" + lib + "</a>";
    }
}

function popwindow(lurl, winname) {
    top4 = 0;
    leftX = top.screen.width;
    leftX2 = leftX / 2;
    leftX3 = leftX2 - 350;
    leftX4 = leftX - 505
    topY = top.screen.height;
    topY2 = topY / 2;
    topY3 = topY2 - 250;
    topY4 = 0;
    if (topY > 600) top4 = topY3
    winprops = "top=" + topY4 + ",left=" + leftX4 + ",width=500,height=550,scrollbars";
    window.open(lurl, winname, winprops);
}

function popenseigne(idenseigne) {
    top4 = 0;
    leftX = top.screen.width;
    leftX2 = leftX / 2;
    leftX3 = leftX2 - 340;
    leftX4 = leftX - 635
    topY = top.screen.height;
    topY2 = topY / 2;
    topY3 = topY2 - 230;
    topY4 = 0;
    //if (topY>600)top4=topY3
    winprops = "top=" + topY4 + ",left=" + leftX4 + ",width=690,height=590,scrollbars";
    window.open("/enseignes/pop_enseigne.aspx?id=" + idenseigne, "", winprops);
}

function popenseigne_bg(idenseigne) {
    top4 = 0;
    leftX = top.screen.width;
    leftX2 = leftX / 2;
    leftX3 = leftX2 - 340;
    leftX4 = leftX - 635
    topY = top.screen.height;
    topY2 = topY / 2;
    topY3 = topY2 - 230;
    topY4 = 0;
    //if (topY>600)top4=topY3
    winprops = "top=" + topY4 + ",left=" + leftX4 + ",width=570,height=470,scrollbars";
    window.open("/enseignes/pop_enseigneBG.aspx?id=" + idenseigne, "", winprops);
}

function poppicto(idpicto) {
    top4 = 0;
    leftX = top.screen.width;
    leftX2 = leftX / 2;
    leftX3 = leftX2 - 360;
    leftX4 = leftX - 655;
    topY = top.screen.height;
    topY2 = topY / 2;
    topY3 = topY2 - 250;
    topY4 = 0;
    //if (topY>600)top4=topY3
    winprops = "top=" + topY4 + ",left=" + leftX4 + ",width=500,height=500,scrollbars";
    window.open("/enseignes/pop_picto.aspx?id=" + idpicto, "", winprops);
}

function popexternalurl(idetablissement) {
    top4 = 0;
    leftX = top.screen.width;
    leftX2 = leftX / 2;
    leftX3 = leftX2 - 360;
    leftX4 = leftX - 485;
    topY = top.screen.height;
    topY2 = topY / 2;
    topY3 = topY2 - 250;
    topY4 = 0;
    //if (topY>600)top4=topY3
    winprops = "top=" + topY4 + ",left=" + leftX4 + ",width=480,height=550,scrollbars";
    window.open("/enseignes/pop_externalUrl.aspx?id=" + idetablissement, "", winprops);
}

function popflash(monflash) {
    top4 = 0;
    leftX = top.screen.width;
    leftX4 = leftX - 680;
    topY = top.screen.height;
    topY2 = topY / 2;
    topY3 = topY2 - 250;
    topY4 = 0;
    //if (topY>600)top4=topY3
    winprops = "top=" + topY4 + ",left=" + leftX4 + ",width=670,height=510,scrollbars";
    window.open("/enseignes/pop_flash.aspx?swf=" + monflash, "", winprops);
}


function popactu(fichierActu) {
    fichierActu2 = fichierActu.toLowerCase();
    if (fichierActu2.indexOf(".gif") != -1) {

        top4 = 0;
        leftX = top.screen.width;
        leftX4 = leftX - 630
        topY = top.screen.height;
        topY2 = topY / 2;
        topY3 = topY2 - 250;
        topY4 = 0;
        //if (topY>600)top4=topY3
        winprops = "top=" + topY4 + ",left=" + leftX4 + ",width=620,height=620,scrollbars";
        window.open("/enseignes/popactugif.aspx?gif=" + fichierActu, "", winprops)

    }
    else//swf
    {
        top4 = 0;
        leftX = top.screen.width;
        leftX4 = leftX - 680
        topY = top.screen.height;
        topY2 = topY / 2;
        topY3 = topY2 - 250;
        topY4 = 0;
        //if (topY>600)top4=topY3
        winprops = "top=" + topY4 + ",left=" + leftX4 + ",width=670,height=510,scrollbars";
        window.open("/enseignes/popactuflash.aspx?swf=" + fichierActu, "", winprops);
    }
}



function popflash_interne(monflash, width_flash, height_flash) {
    top4 = 0;
    winWidth = width_flash + 30
    winHeight = height_flash + 20
    leftX = top.screen.width;
    leftX4 = leftX - 6(width_flash + 50)
    topY = top.screen.height;
    topY2 = topY / 2;
    topY3 = topY2 - 250;
    topY4 = 0;
    //if (topY>600)top4=topY3
    winprops = "top=" + topY4 + ",left=" + leftX4 + ",width=" + winWidth + ",height=" + winHeight;
    urlflash = "/divers/pop_flash.aspx?swf=" + monflash + "&width=" + width_flash + "&height=" + height_flash;
    window.open(urlflash, "", winprops);
}


function popflash2(monflash) {
    top4 = 0;
    leftX = top.screen.width;
    leftX4 = leftX - 600
    topY = top.screen.height;
    topY2 = topY / 2;
    topY3 = topY2 - 250;
    topY4 = 0;
    //if (topY>600)top4=topY3
    winprops = "top=" + topY4 + ",left=" + leftX4 + ",width=550,height=600";
    window.open("/divers/pop_flash.aspx?swf=" + monflash, "", winprops);
}


function popgif(gif) {
    top4 = 0;
    leftX = top.screen.width;
    leftX4 = leftX - 630;
    topY = top.screen.height;
    topY2 = topY / 2;
    topY3 = topY2 - 250;
    topY4 = 0;
    //if (topY>600)top4=topY3
    winprops = "top=" + topY4 + ",left=" + leftX4 + ",width=250,height=250,scrollbars";
    window.open("/enseignes/pop_gif.aspx?gif=" + gif, "", winprops);
}

function popvisuel(visuel) {
    top4 = 0;
    leftX = top.screen.width;
    leftX4 = leftX - 630;
    topY = top.screen.height;
    topY2 = topY / 2;
    topY3 = topY2 - 250;
    topY4 = 0;
    winprops = "top=" + topY4 + ",left=" + leftX4 + ",width=510,height=500,scrollbars";
    window.open("/enseignes/pop_visuel.aspx?id=" + visuel, "", winprops);
}


function show_hide_by_button(laction, calquelib, calqueaction, button_url) {
    mon_div_lib = document.getElementById(calquelib);
    mon_div_action = document.getElementById(calqueaction);

    if (laction == "show") {
        mon_div_action.style.display = "block";
        mon_div_lib.innerHTML = "<a href='javascript:show_hide_by_button(\"hide\",\"" + calquelib + "\",\"" + calqueaction + "\",\"" + button_url + "\")' ><img src=" + button_url + "_off.png  border=0  vspace=10></a>";
    }
    else {
        mon_div_action.style.display = "none";
        mon_div_lib.innerHTML = "<a href='javascript:show_hide_by_button(\"show\",\"" + calquelib + "\",\"" + calqueaction + "\",\"" + button_url + "\")' ><img src=" + button_url + ".png  border=0  vspace=10></a>";
    }
}


function resize_pop() {
    /*var ie = (document.all) ? 1:0;
    pageHeight=(ie)?document.all["content0"].offsetHeight:innerHeight;
    pageHeight2=pageHeight+90
    topY=top.screen.height;
    if (pageHeight2<550)self.resizeTo(650, pageHeight2)*/


}

hauteur = 0;
function resize_pop2() {
    /*var ie = (document.all) ? 1:0;
    pageHeight=(ie)?document.all["content0"].offsetHeight:innerHeight;
    pageHeight2=pageHeight+90
    topY=top.screen.height;
    maxH=topY-25

if(ie)
    {
    if (pageHeight2<=maxH)
    {
    top.resizeTo(690, pageHeight2)
    }
    else 
    {
    self.resizeTo(690, maxH)
    }
    }
    else
    resize_pop()

*/
}

function popmail(idmail, code) {
    top4 = 0;
    leftX = top.screen.width;
    leftX2 = leftX / 2;
    leftX3 = leftX2 - 360;
    leftX4 = leftX - 655
    topY = top.screen.height;
    topY2 = topY / 2;
    topY3 = topY2 - 250;
    topY4 = 0;
    //if (topY>600)top4=topY3
    winprops = "top=" + topY4 + ",left=" + leftX4 + ",width=835,height=600,menubar='no',toolbar='no',location='no',status='no',scrollbars='no'";
    window.open("/MesOutils/WebMail/WF_popMail.aspx?id=" + idmail + "&code=" + code, "", winprops);
}

function confirm_nolog() {
    no_log = confirm("POUR ACCEDER A CETTE OFFRE VOUS DEVEZ ETRE IDENTIFIE.\nSOUHAITEZ-VOUS  ALLER SUR LA PAGE D'IDENTIFICATION?")
    if (no_log == 1) { document.location = "/MonDossier/WF_Inscription.aspx" }
    else
        self.focus()
}

function clickMe(id) {
    var cb = document.getElementById(id);
    if (cb.dispatchEvent) {
        var evt = document.createEvent("MouseEvents");
        evt.initEvent("click", true, true);
        cb.dispatchEvent(evt);
    }
    else {
        cb.click();
    }
}

function openPane(accordionId, paneIndex) {
    //MyAccordion is the ID of AJAX Accordion control
    var behavior = $get("<%="+ accordionId+"%>").AccordionBehavior;
    behavior.set_SelectedIndex(paneIndex);
}



function att(n, d) { var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) { d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p); } if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n]; for (i = 0; !x && d.layers && i < d.layers.length; i++) x = att(n, d.layers[i].document); return x; }
    function rok(){var i,x,a=document.Zsr;for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)x.src=x.oSrc;}
    function swap() { var i, j = 0, x, a = swap.arguments; document.Zsr = new Array; for (i = 0; i < (a.length - 2); i += 3) if ((x = att(a[i])) != null) { document.Zsr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; } }



    /*Disable button during treatement*/

    function disableBtn(btnID, newText, validationGroup) {
        var btn = document.getElementById(btnID);
        var oldValue = btn.value;
        btn.disabled = true;
        btn.value = newText;
        if (HasPageValidators()) {
            if (Page_Validators != undefined && Page_Validators != null) {
                //Looping through the whole validation collection.
                var isValid = true;
                for (var i = 0; i < Page_Validators.length; i++) {
                    ValidatorEnable(Page_Validators[i]);
                    //if condition to check whether the validation was successfull or not.

                    if (Page_Validators[i].validationGroup !== validationGroup)
                        continue;
                    if (!Page_Validators[i].isvalid) {
                        ResetToDefault(btn, oldValue);
                        isValid = false;
                        break;
                    }
                }
                if (isValid && Page_IsValid) {
                    EnableOnUnload(btn, btn.value);
                    SetImage(btn);
                    btn.disabled = false;
                }
            }
        }
        else {
            SetImage(btn);
            btn.disabled = true; btn.value = newText;
            EnableOnUnload(btn, btn.value);
        }
    }
    function ResetToDefault(btn, oldValue) {
        btn.disabled = false;
        btn.value = oldValue;
    }

    //Handle Page_Validators is not defined error
    function HasPageValidators() {
        var hasValidators = false;
        try {
            if (Page_Validators.length > 0) {
                hasValidators = true;
            }
        }
        catch (error) { }
        return hasValidators;
    }

    function SetImage(btn) {
        btn.style.background = '';
    }

    //enable the button and restore the original text value for browsers other than IE
    function EnableOnUnload(btn, btnText) {
        if (navigator.appName !== 'Microsoft Internet Explorer') {
            window.onunload = function() {
                ResetToDefault(btn, btnText);
            }
        }
    }
 