    //// _nbItemPanier : variable global, nombre d'item dans le panier
///*@cc_on @*/
///*@if (@_win32)
//document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
//var script = document.getElementById("__ie_onload");
//script.onreadystatechange = function() {
//if (this.readyState == "complete") {
// init(); // call the onload handler
//  }
//  };
//  /*@end@*/
//function init() {
//alert('iZZZZEn')
//    // quit if this function has already been called
//    if (arguments.callee.done) return;

//    // flag this function so we don't do the same thing twice
//    arguments.callee.done = true;

//    // do stuff
//};
//registerInit(init);

//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
    });
}

window.onload = function() {
    var qnt;
    /* recherche rapide 
    $('ctl00_encart1_rr_produits').observe('change', function(e) {
    $('ctl00_encart1_univ1').hide();
    $('ctl00_encart1_univ2').hide();
    $('ctl00_encart1_univ3').hide();
    $('ctl00_encart1_univ4').hide();
    $('ctl00_encart1_univ5').hide();
    $('ctl00_encart1_univ' + ($('ctl00_encart1_rr_produits').getValue())).show();
    })*/

    updateTimbre()

    $('ctl00_encart1_rr_produits').observe('change', function(e) {

        var Cat = this.getValue()
        var vars = null
        var dmc = null
        // alert(Cat)
        var i;
        for (i = $('ctl00_encart1_univ').options.length - 1; i >= 0; i--) {
            $('ctl00_encart1_univ').remove(i);
        }
        var j;
        for (j = $('ctl00_encart1_ssCat').options.length - 1; j >= 0; j--) {
            $('ctl00_encart1_ssCat').remove(j);
        }

        $('ctl00_encart1_ssCat').update('<option>Sous cat\351gorie</option>')
        params = 'action=9&Cat=' + Cat
        var a = new Ajax.Request('panier.ajax', {
            method: 'POST',
            postBody: params,
            onSuccess: function(transport) {
                var r = transport.responseText
                vars = r.split(";");
                $('ctl00_encart1_univ').options[0] = new Option('Cat\351gorie', '0')
                for (var i = 1; i <= vars.length; i++) {
                    var pair = vars[i].split(":");
                    $('ctl00_encart1_univ').options[i] = new Option(pair[1], pair[0]);

                }

            }
        })
    })
    $('ctl00_encart1_univ').observe('change', function(e) {
        var Cat = this.getValue()
        var vars = null
        var dmc = null
        // alert(Cat)
        var i;
        for (i = $('ctl00_encart1_ssCat').options.length - 1; i >= 0; i--) {
            $('ctl00_encart1_ssCat').remove(i);
        }
        params = 'action=9&Cat=' + Cat
        var a = new Ajax.Request('panier.ajax', {
            method: 'POST',
            postBody: params,
            onSuccess: function(transport) {
                var r = transport.responseText
                vars = r.split(";");
                $('ctl00_encart1_ssCat').options[0] = new Option('Sous cat\351gorie', '0')
                for (var i = 1; i <= vars.length; i++) {

                    var pair = vars[i].split(":");
                    $('ctl00_encart1_ssCat').options[i] = new Option(pair[1], pair[0]);
                }

            }
        })
    })



    $('ctl00_encart1_ssCat').observe('change', function(e) {
        params = 'action=10&LCat=' + this.getValue()
        var a = new Ajax.Request('panier.ajax', {
            method: 'POST',
            postBody: params,
            onSuccess: function(transport) {
                var r = transport.responseText

            }
        })
    })

    /*                  */
    var d = $('ctl00_menugauche_menuselected').getValue()



    if (d == '') {
        window._menuSelected = null;
    } else {
        window._menuSelected = $('m' + d);
    }
    var ul1 = document.getElementById("m1");
    if (ul1.style.display == "") {
        if (window._menuSelected == null) { window._menuSelected = ul1; }

    }
    var ul2 = document.getElementById("m2");
    if (ul2.style.display == "") {
        if (window._menuSelected == null) { window._menuSelected = ul2; }

    }
    var ul3 = document.getElementById("m3");
    if (ul3.style.display == "") {
        if (window._menuSelected == null) { window._menuSelected = ul3; }

    }
    var ul4 = document.getElementById("m3");
    if (ul4.style.display == "") {
        if (window._menuSelected == null) { window._menuSelected = ul4; }

    }

    $('ctl00_recherche1_rechercherapide').observe('click', function(e) {
        $('ctl00_recherche1_rechercherapide').setValue('')
    });
    initMenuGauche()
    if (typeof (onLoad) == 'function') {
        onLoad();
    }
}

function initMenuGauche() {

    //window._menuSelected = null;
   
   //var t= $('menuGauche').getElementsByTagName('DIV')
   //for (var i = 0; i < t.length; i++) {
    $('menuGauche').observe('click', function(e) {
  
    if (e.findElement('A') && !e.findElement('UL')) {
        var d = (e.findElement('DIV')).next()
           if (window._menuSelected != d) {
               if (window._menuSelected != null) { Effect.BlindUp(window._menuSelected, { duration: 0.5 }); }
               //d.show()
              
               Effect.BlindDown(d, { duration: 0.5 });
               window._menuSelected = d
               return false;
           } else {
                Effect.BlindUp(window._menuSelected, { duration: 0.5 });
                window._menuSelected = null;
            }
           }
       });
        
  // }

}




function slideDownUp(element) {
  isUsed = true;
  var el = $(element);
  if (el.style.display == 'none') {
    Effect.BlindDown(el,{duration:0.3}); return false;
  } else {
    Effect.BlindUp(el,{duration:0.3}); return false;
  }
  setTimeOut('isUsed=false', 1000);
}

function updateTimbre() {

    var t = document.getElementsByClassName('timbrePanier')
//    alert(_nbItemPanier);
    for (var i = 0; i < t.length; t++) {
        if (typeof (_nbItemPanier) != 'undefined') { t[i].update(_nbItemPanier); }
    }
}


function addItem(id) {
    var qnt = $('quantitePanier').getValue() *1
    params = 'action=1&idProd=' + id + '&quantite='+ qnt +''
    var a = new Ajax.Request('panier.ajax', {
        method: 'POST',
        postBody: params,
        onComplete: function(transport) {
            var r = transport.responseJSON
            
            if (r.result == true) {
            
                window._nbItemPanier = r.nbItem
                window._lastAdded = r.guid
                window._lastAddedQnt = qnt
               // showQteUpdate()
                updateTimbre()
                $('nbAticlesMess').update(r.nbItem)
                hideQteUpdate()
                 //var tab_form = document.getElementsByTagName('FORM'); tab_form[0].submit();
            }
        }
    })

}

function addItemExist(id, oldqnt) {
    var i = oldqnt * 1
    var y = qnt *1
 qntadd =  i + y 
  window._lastAddedQnt = qntadd  
    params = 'action=3&idProd=' + id + '&quantite='+ qntadd +''
    var a = new Ajax.Request('panier.ajax', {
        method: 'POST',
        postBody: params,   
        onComplete: function(transport) {
            var r = transport.responseJSON
            if (r.result == true) {
                window._nbItemPanier = r.nbItem
                window._lastAdded = r.guid
                //showQteUpdate()
                updateTimbre()
                $('nbAticlesMess').update(r.nbItem)
                hideQteUpdate()
                
            }
        }
    })
}

function quantiteChange() {
  
    if (qte != '') {
        if (IsANumber(qte) == true) {
            $('quantitePanier').removeClassName("error")
            params = 'action=3&gui=' + id + '&quantite=' + qte
            var a = new Ajax.Request('panier.ajax', {
                method: 'POST',
                postBody: params,
                onComplete: function(transport) {
                    var r = transport.responseJSON
                    window._nbItemPanier = r.nbItem
                    updateTimbre()
                    $('nbAticlesMess').update(r.nbItem)
                    hideQteUpdate()
                }
            })
        } else {
            $('quantitePanier').addClassName("champerreur")
        }
    } else {
        $('quantitePanier').addClassName("champerreur")
    }


}
function IsANumber(value) {
    if (isNaN(value)) {
        return false
    } else {
        return true
    }
}

function hideQteUpdate() {
    $('step1').hide()
    $('step2').show()
}
function showQteUpdate() {
    $('step1').show()
    $('step2').hide()
    $('quantitePanier').setValue('1')
    Lightview.show({ href: "#checkPanier", options: { width: 500, height: 200} });
}


function updateLigthViewQnt(objt) {
    qnt = objt.value
}



function showQteUpdate(id, btn_clicked) {

    $('step1').show()
    $('step2').hide()
    $('quantitePanier').setValue('1')
    Lightview.show({ href: "#checkPanier", options: { width: 500, height: 200} });

    if (btn_clicked == 'ajoutpanier') {
    
    $('quantitePanier').setValue( $('quantite').value )
    qnt = $('quantitePanier').value   
    
    $('btnUpdateQuantite').observe('click', function(e) {addItemFp("" + id, qnt + ""); });
    }else{
    $('btnUpdateQuantite').observe('click', function(e) {addItem("" + id + ""); });
    
    }

 }

 function showQteUpdateQnt(id, oldqnt) {
 
    $('step1').show()
    $('step2').hide()
    if ($('quantite') != null) { $('quantitePanier').setValue($('quantite').value); }
    else
    { $('quantitePanier').setValue('1'); }
    Lightview.show({ href: "#checkPanier", options: { width: 500, height: 200} });
    qnt = $('quantitePanier').value
    $('btnUpdateQuantite').observe('click', function(e) {addItemExist("" + id,oldqnt + ""); });
}

function renderDiv(val, div) {
    if (val == 'True') {
        $(div).style.display = "block";
    } else {
        $(div).style.display = "none";
    }
}

function checkconcmd() {

    var trustcmd = $('ctl00_contenuCentre_cb_condition_vente').checked

    if (trustcmd == true) {
        document.getElementById("cmdref").href = "identification.aspx";
        renderDiv('False', 'error_condition_vente');
      }
      else {
          document.getElementById("cmdref").href = "#";
          renderDiv('True', 'error_condition_vente'); 
     } 
   
    
}

