function measuresClick (element)
{
    var obj = EL(element);

    if (obj.className == "deplie")
    {
        obj.className = "plie";
    }
    else if (obj.className == "plie")
    {
        obj.className = "deplie";
    }

    return false;
}

function loadSheet (url, zoom)
{
    var query = Bw.IO.Query.create();
    
    query.setNoCache();
    
    query.get (url, function () { gotProductSheet (query, zoom); } );
}


function gotProductSheet (query, zoom)
{
    var sheet = query.getText();
    var div   = EL("popupficheproduit");

    div.innerHTML = sheet;
    window.scrollTo(0,0);
    switchZoomData (zoom);

    var leftDiv = EL('contenufp1');
    var rightDiv = EL('contenufp2');

    if (leftDiv.offsetHeight > rightDiv.offsetHeight)
    {
        var advertisementDiv = EL('bottom-advertisement');
        if (advertisementDiv != null)
        {
            var diff = leftDiv.offsetHeight - rightDiv.offsetHeight;
            advertisementDiv.style.marginTop = diff + 'px';
        }
    }

}


function switchZoomData (zoom)
{
    var divImg  = EL ('imagefp');
    var divinfo = EL ('contenufp');
    var fp      = EL ('fp');
    var img     = EL ('imgfp');
    var popup   = EL ('popupficheproduit');
    var fermer  = EL ('fermerPopup');

    var bottomFp1 = EL ('bottom-contenufp1');
    var bottomFp2 = EL ('bottom-contenufp2');

    var retour      = EL ('retour');
    var fluxLizeo   = EL ('fluxLizeo');

    if (zoom)
    {
        popup.style.width       = '300px';
        fp.style.width          = '300px';
        popup.style.marginLeft  = '341px';
        fermer.style.marginLeft = '120px';
        img.src                 = img.getAttribute("source");
        divinfo.style.display   = 'none';
        retour.style.display    = 'none';
        divImg.style.display    = 'block';

        if (fluxLizeo != null)
        {
            fluxLizeo.style.display = 'none';
        }
    }
    else
    {
        divinfo.className       = "contenufp";
        fp.style.width          = '780px';
        popup.style.width       = '780px';
        popup.style.marginLeft  = '100px';
        fermer.style.marginLeft = '350px';
        divinfo.style.display   = 'block';
        bottomFp1.style.display = 'block';
        bottomFp2.style.display = 'block';
        divImg.style.display    = 'none';
    }
    
}


function changeQuantityProductSheet (url)
{
    var quantity1 = null;
    var quantity2 = null;
    
    var elements = document.getElementsByTagName ('select');
    var length   = elements.length;
    
    for (i = 0; i < length; i++)
    {
        var pop = elements[i];
        var idx = pop.selectedIndex;
        var opt = pop.options[idx];
        
        if (elements[i].name == '_quantity1')
        {
            quantity1 = opt.value;
        }
        else if (elements[i].name == '_quantity2')
        {
            quantity2 = opt.value;
        }
    }
    
    if (quantity1 != null)
    {
        url += "&quantity1=" + quantity1;
    }
    if (quantity2 != null)
    {
        url += "&quantity2=" + quantity2;
    }
    
    loadSheet (url, false);
}

function switchFluxLizeo(display)
{
    var bottomFp1 = EL ('bottom-contenufp1');
    var bottomFp2 = EL ('bottom-contenufp2');

    var retour      = EL ('retour');
    var fluxLizeo   = EL ('fluxLizeo');

    if (fluxLizeo != null)
    {
        if (display)
        {
            bottomFp1.style.display = 'none';
            bottomFp2.style.display = 'none';

            retour.style.display    = 'block';
            fluxLizeo.style.display = 'block';
        }
        else
        {
            bottomFp1.style.display = 'block';
            bottomFp2.style.display = 'block';

            retour.style.display    = 'none';
            fluxLizeo.style.display = 'none';
        }
    }
}

function displayCadreForMSIE6()
{
    var version = navigator.appVersion.substring(17,23);

    if (version == 'MSIE 6')
    {
        var firstInterLigne  = EL('inter-ligne-first');
        var secondInterLigne = EL('inter-ligne-second');

        if (firstInterLigne != null)
        {
            firstInterLigne.innerHTML = "";
            firstInterLigne.style.borderBottom = "1px solid #B2B2B2";
            firstInterLigne.style.width = "938px";
            firstInterLigne.style.height = "5px";
            firstInterLigne.style.marginBottom = "15px";
        }

        if (secondInterLigne != null)
        {
            secondInterLigne.innerHTML = "";
            secondInterLigne.style.borderBottom = "1px solid #B2B2B2";
            secondInterLigne.style.width = "938px";
            secondInterLigne.style.height = "5px";
            secondInterLigne.style.marginBottom = "15px";
        }
    }
}

function displayQuantityForProductSheetWithoutAjax()
{
    var selectQuantity1 = EL('_quantity1');
    var selectQuantity2 = EL('_quantity2');

    if (selectQuantity1 != null)
    {
        selectQuantity1.style.visibility = "visible";
    }

    if (selectQuantity2 != null)
    {
        selectQuantity2.style.visibility = "visible";
    }
}