//<!--

//********************* POPUP ************************//
var newWin = null;

function closeWin()
{
  if (newWin != null)
  {
    if(!newWin.closed)
    {
      newWin.close();
    }
  }
}

function popUp(strURL,strType,strHeight,strWidth)
{
  closeWin();
  var strOptions="";
  if (strType=="console")
  {
		var left = (screen.width - 460)/2;
		var top = (screen.height - 150)/2;
    strOptions="left="+left+",top="+top+",scrollbars,height="+strHeight+",width="+strWidth;
  }
  if (strType=="fixed")
  {
    strOptions="status,height="+strHeight+",width="+strWidth;
  }
  if (strType=="elastic")
  {
    strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
  }
  newWin = window.open(strURL, 'newWin', strOptions);
  newWin.focus();
}
//********************* FIN POPUP ************************//

function addBookmark(title,url)
{
  if (window.sidebar)
  { 
    alert('Fermez cette fenêtre et cliquez sur Ctrl + D\nou\nallez dans "Marque-pages > marquer cette page"'); 
  }
  else if ( document.all )
  {
    window.external.AddFavorite( url, title);
  }
  else if ( window.opera && window.print )
  {
    return true;
  }

  return false;
}


function js_product_in_cart ()
{
  $('#cart_area').fadeIn();
  
  setTimeout('$(\'#cart_area\').fadeOut()', 5000);
  
  return false;
}


function CloseAlert ()
{
  Effect.BlindDown('alert_div');
  
  setTimeout('Effect.BlindUp(\'alert_div\')', 5000);
}


function DisplayHide (id)
{ 
  if (document.getElementById(id).style.display == 'block')
  {
    document.getElementById(id).style.display = 'none';
  }
  else
  {
    document.getElementById(id).style.display = 'block';
  }
}

function Display_menu(id, back)
{
  
  var arVersion = navigator.appVersion.split("MSIE")
  var version = parseFloat(arVersion[1])
  
  if ((version < 7) && (document.body.filters)) 
  {
    document.getElementById(id).style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop src='"+ FTP +"/img/back_menu_"+ back +".png')";
  }
  else
  {
    document.getElementById(id).style.backgroundImage="url("+ FTP +"/img/back_menu_"+ back +".png)";
  }
}

function xGetElementById(e)
{
  if(typeof(e)=='string')
  {
    if(document.getElementById)
    {
      e=document.getElementById(e);
    }
    else if(document.all)
    {
      e=document.all[e];
    }
    else
    {
      e=null;
    }
  }
  return e;
}

function PrintDeclinaisonChoice()
{
  var choice = document.getElementById('CHOICE').options[document.getElementById('CHOICE').options.selectedIndex].value ;
  
  if (tabArticles[choice].price2 != "")
  {
    document.getElementById('price').innerHTML = tabArticles[choice].price;
    document.getElementById('price2').innerHTML = tabArticles[choice].price2;
  }
  else if (tabArticles[choice].price != "")
  {
    document.getElementById('price').innerHTML = tabArticles[choice].price+" &euro;";
    document.getElementById('price2').innerHTML = "";
  }
  else
  {
    document.getElementById('price').innerHTML = "--";
    document.getElementById('price2').innerHTML = "--";
  }
}

function Display (id)
{ document.getElementById(id).style.display = 'block'; }

function Hide (id)
{ document.getElementById(id).style.display = 'none'; }


function ajout (id, max)
{
  var idname = 'QTY_'+id;
  if (xGetElementById(idname))
  {
    // on force à être en entier... 
    var val=parseInt( xGetElementById(idname).value );
    if (isNaN(val)) { val=0; }
    val++;
    if (val > max)
    {
      alert ('La commande maximale est de '+max+'.');
      xGetElementById(idname).value = max;
      return false;
    }
    xGetElementById(idname).value = val;

    return true;
  }
  return false;
}

function enlev (id)
{
  var idname = 'QTY_'+id;
  if (xGetElementById(idname))
  {
    // on force à être en entier... 
    var val=parseInt( xGetElementById(idname).value );
    if (isNaN(val)) { val=0; }

    if (val == 0)
    {
      alert ('Déjà vide.');
      xGetElementById(idname).value = 0;
      return false;
    }

    xGetElementById(idname).value = val - 1;
    
    return true;
  }
  return false;
}

function vide (id)
{
  var idname = 'QTY_'+id;
  if (xGetElementById(idname))
  {
    // on force à être en entier... 
    var val=parseInt( xGetElementById(idname).value );
    if (isNaN(val)) { val=0; }

    if (val == 0)
    {
      alert ('Déjà vide.');
      xGetElementById(idname).value = 0;
      return false;
    }

    xGetElementById(idname).value = 0;
    
    return true;
  }
  return false;
}

function modif (id, max)
{
  var idname = 'QTY_'+id;
  if (xGetElementById(idname))
  {
    var val=parseInt( xGetElementById(idname).value );
    if (isNaN(val)) { val=0; }

    if ((val > max) || (val < 0))
    {
      alert ('La quantité doit être comprise entre 0 et '+max+'.');
      val = 0;
    }
    xGetElementById(idname).value = val;

    return true;
  }
  return false;
}


function valide_mail ()
{
  var fo = document.contact_form;
  
  if (fo.last_name.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre nom");
    return false;
  }
  
  if (fo.first_name.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre prénom");
    return false;
  }
  
  if (fo.address.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre adresse");
    return false;
  }
  
  if (fo.zip_code.value.length == 0) {
    alert ("Vous avez oublié de saisir votre code postal");
    return false;
  }
  
  if (fo.city.value.length == 0) {
    alert ("Vous avez oublié de saisir votre ville");
    return false;
  }
  
  if (fo.phone.value.length == 0) {
    alert ("Vous avez oublié de saisir votre téléphone");
    return false;
  }
  
  if (!fo.email.value.match(/^[a-z0-9&\'\.\-_\+]*@[a-z0-9]+([\.\-][a-z0-9]+)*\.[a-z]{2,}$/i))
  {
    alert ("Vous devez saisir une adresse eMail valide (prenom.nom@monemail.com)");
    return false;
  }
  
  if (fo.email.value.match(/^www\./i))
  {
    alert ("Vous devez saisir une adresse email valide (prenom.nom@monemail.com)");
    return false;
  }
  
  if (fo.SECURITY_CODE.value.length == 0) {
    alert ("Vous avez oublié de saisir le code de sécurité");
    return false;
  }
  
  return true;
  
}


function valide_login_form (name_form, type)
{
  var fo = document.forms[name_form+'_'+type];
  
  if (!fo.LOGIN.value.match(/^[a-z0-9&\'\.\-_\+]*@[a-z0-9]+([\.\-][a-z0-9]+)*\.[a-z]{2,}$/i))
  {
    alert ("Vous devez saisir une adresse email valide (prenom.nom@monemail.com)");
    return false;
  }
  
  if (fo.LOGIN.value.match(/^www\./i))
  {
    alert ("Vous devez saisir une adresse email valide (prenom.nom@monemail.com)");
    return false;
  }
  
  if (fo.PASSWORD.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre mot de passe");
    return false;
  }
  
  return true;
  
} // valide_login_form (name_form, type)


function valide_print_access_bdc ()
{
  var fo = document.print_access_bdc;
  
  if (!fo.LOGIN.value.match(/^[a-z0-9&\'\.\-_\+]*@[a-z0-9]+([\.\-][a-z0-9]+)*\.[a-z]{2,}$/i))
  {
    alert ("Vous devez saisir une adresse email valide (prenom.nom@monemail.com)");
    return false;
  }
  
  if (fo.LOGIN.value.match(/^www\./i))
  {
    alert ("Vous devez saisir une adresse email valide (prenom.nom@monemail.com)");
    return false;
  }
  
  if (fo.PASSWORD.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre mot de passe");
    return false;
  }

  return true;
}

function valide_abo_newsletter ()
{
  var fo = document.abo_newsletter;
  

  if (!fo.email.value.match(/^[a-z0-9&\'\.\-_\+]*@[a-z0-9]+([\.\-][a-z0-9]+)*\.[a-z]{2,}$/i))
  {
    alert ("Vous devez saisir une adresse eMail valide (prenom.nom@monemail.com)");
    return false;
  }
  
  if (fo.email.value.match(/^www\./i))
  {
    alert ("Vous devez saisir une adresse email valide (prenom.nom@monemail.com)");
    return false;
  }
  
  return true;
  
}

function valide_password_forgotten ()
{
  var fo = document.password_forgotten;
  
  if (!fo.email.value.match(/^[a-z0-9&\'\.\-_\+]*@[a-z0-9]+([\.\-][a-z0-9]+)*\.[a-z]{2,}$/i))
  {
    alert ("Vous devez saisir une adresse email valide (prenom.nom@monemail.com)");
    return false;
  }
  
  if (fo.email.value.match(/^www\./i))
  {
    alert ("Vous devez saisir une adresse email valide (prenom.nom@monemail.com)");
    return false;
  }
  
  return true;
}


function valide_account (TYPE)
{
  var fo = document.form;
  
  if (fo.title.value.length == 0)
  {
    alert ("Vous devez choisir la civilité (M., Mme, Mlle)");
    return false;
  }
  if (fo.last_name.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre nom");
    return false;
  }
  if (fo.first_name.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre prénom");
    return false;
  }
  if (fo.address.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre adresse");
    return false;
  }
  if (fo.zip_code.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre code postal");
    return false;
  }  
  if (fo.city.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre ville");
    return false;
  }
  // special pour les codes postaux des DOM-TOM
  if (fo.country.value.substring(0,2) == 'FR' &&
      parseInt (fo.zip_code.value.substring(0,2), 10) >= 97)
  {
    alert ("Erreur : code postal invalide pour la France Métropolitaine");
    return false;
  }
  if (!fo.email.value.match(/^[a-z0-9&\'\.\-_\+]*@[a-z0-9]+([\.\-][a-z0-9]+)*\.[a-z]{2,}$/i))
  {
    alert ("Vous devez saisir une adresse email valide (prenom.nom@monemail.com)");
    return false;
  }
  if (fo.email.value.match(/^www\./i))
  {
    alert ("Vous devez saisir une adresse email valide (prenom.nom@monemail.com)");
    return false;
  }
  
  if(TYPE!="update")
  {
    if (fo.email.value != fo.email_confirm.value)
    {
      alert ("Les deux adresses Email ne sont pas identiques");
      return false;
    }
  }
  
  if (fo.password.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre mot de passe");
    return false;
  }
  if (fo.password.value.length > 10)
  {
    alert ("Votre mot de passe doit contenir au maximun 10 caractères");
    return false;
  }
  
  if(TYPE=="update")
  {
    if (fo.new_password && fo.new_password.value.length != 0)
    {
      if (fo.new_password.value != fo.new_password_confirm.value)
      {
        alert ("Les deux nouveaux mots de passe ne sont pas identiques");
        return false;      
      }
    }
  }
  else
  {
    if (fo.password.value != fo.password_confirm.value)
    {
      alert ("Les deux mots de passe ne sont pas identiques");
      return false;
    }
  }
  
  if (fo.phone.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre numéro de téléphone");
    return false;
  }
  
  // Spécial PRO
  /*
  if (document.getElementById('fax') && fo.fax.value.length == 0)
  {
    alert ("Vous avez oublié de saisir le fax");
    return false;
  }
  */
  
  /* LIVRAISON */
 if (fo.misc1.value.length == 0)
  {
    alert ("Vous devez choisir la civilité de livraison (M., Mme, Mlle)");
    return false;
  }
  if (fo.misc2.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre nom de livraison");
    return false;
  }
  if (fo.misc3.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre prénom de livraison");
    return false;
  }
  if (fo.misc7.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre adresse de livraison");
    return false;
  }
  if (fo.misc10.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre code postal de livraison");
    return false;
  }  
  if (fo.misc11.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre ville de livraison");
    return false;
  }
  // special pour les codes postaux des DOM-TOM
  if (fo.misc12.value.substring(0,2) == 'FR' &&
      parseInt (fo.misc10.value.substring(0,2), 10) >= 97)
  {
    alert ("Erreur : code postal invalide pour la France Métropolitaine");
    return false;
  }
  if (fo.misc13.value.length == 0)
  {
    alert ("Vous avez oublié de saisir votre numéro de téléphone de livraison");
    return false;
  }
  
  
  if (fo.cgv && !fo.cgv.checked)
  {
    alert ("Vous devez prendre connaissance des conditions d'utilisation du service.");
    return false;
  }

  return true;
}

function valid_submit_question ()
{
  var fo = document.submit_question;
  
  if (!fo.email.value.match(/^[a-z0-9&\'\.\-_\+]*@[a-z0-9]+([\.\-][a-z0-9]+)*\.[a-z]{2,}$/i))
  {
    alert ("Vous devez saisir une adresse eMail valide (prenom.nom@monemail.com)");
    return false;
  }
  
  if (fo.email.value.match(/^www\./i))
  {
    alert ("Vous devez saisir une adresse email valide (prenom.nom@monemail.com)");
    return false;
  }
  
  if (fo.question.value.length == 0) {
    alert ("Vous avez oublié de poser votre question");
    return false;
  }
  
  return true;
  
}


function IdemAddress ( chk )
{
  //var fo = document.form;
  if (!chk.checked) return;
  
  document.form.misc1.selectedIndex = document.form.title.selectedIndex;
  document.form.misc2.value = document.form.last_name.value;
  document.form.misc3.value = document.form.first_name.value;
  document.form.misc7.value = document.form.address.value;
  document.form.misc8.value = document.form.address2.value;
  document.form.misc9.value = document.form.address3.value;
  document.form.misc10.value = document.form.zip_code.value;
  document.form.misc11.value = document.form.city.value;
  document.form.misc12.selectedIndex = document.form.country.selectedIndex;
  document.form.misc13.value = document.form.phone.value;
  document.form.misc14.value = document.form.gsm.value;
}

function valide_send_friend ()
{
  var fo = document.send_friend;
  
  if (!fo.email_source.value.match(/^[a-z0-9&\'\.\-_\+]*@[a-z0-9]+([\.\-][a-z0-9]+)*\.[a-z]{2,}$/i))
  {
    alert ("Vous devez saisir une adresse E-Mail valide (prenom.nom@monemail.com)");
    return false;
  }
  
  if (fo.email_source.value.match(/^www\./i))
  {
    alert ("Vous devez saisir une adresse email valide (prenom.nom@monemail.com)");
    return false;
  }
  
  if (!fo.email_dest.value.match(/^[a-z0-9&\'\.\-_\+]*@[a-z0-9]+([\.\-][a-z0-9]+)*\.[a-z]{2,}$/i))
  {
    alert ("Vous devez saisir une adresse E-Mail valide pour le destinataire (prenom.nom@monemail.com)");
    return false;
  }
  
  if (fo.email_dest.value.match(/^www\./i))
  {
    alert ("Vous devez saisir une adresse E-Mail valide pour le destinataire (prenom.nom@monemail.com)");
    return false;
  }
  
  return true;
  
}

function valide_delivery_form ()
{
  var fo = document.goto_BDC_2;

  if (fo.title.value.length == 0)
  {
    alert ("Vous devez choisir la civilité (M., Mme, Mlle)");
    return false;
  }

  if (fo.last_name.value.length == 0)
  {
    alert ("Vous avez oublié de saisir le nom");
    return false;
  }
  if (fo.first_name.value.length == 0)
  {
    alert ("Vous avez oublié de saisir le prénom");
    return false;
  }
  if (fo.address.value.length == 0)
  {
    alert ("Vous avez oublié de saisir l'adresse");
    return false;
  }
  
  if (fo.zip_code.value.length == 0)
  {
    alert ("Vous avez oublié de saisir le code postal");
    return false;
  }  
  if (fo.city.value.length == 0)
  {
    alert ("Vous avez oublié de saisir la ville");
    return false;
  }
  
  // special pour les codes postaux des DOM-TOM
  if (fo.country.value.substring(0,2) == 'FR' &&
      parseInt (fo.zip_code.value.substring(0,2), 10) >= 97)
  {
    alert ("Erreur : code postal invalide pour la France Métropolitaine");
    return false;
  }
  
  // special pour les codes postaux des zones militaires
  if (fo.country.value.length > 2 &&
      fo.country.value.substring(0,3) == 'FR;')
  {
    var valid_zip = '00';
    if (fo.zip_code.value.substring(0,2) != valid_zip)
    {
      alert ("Erreur : code postal invalide pour cette zone militaire\nLe Code Postal doit être : '00xxx'");
      return false;
    }
  }
  
  return true;
}

/*-----------------------------------------------------------
    Toggles element's display value
    Input: any number of element id's
    Output: none 
    ---------------------------------------------------------*/
function toggleDisp() {
    for (var i=0;i<arguments.length;i++){
        var d = $(arguments[i]);
        if (d.style.display == 'none')
            d.style.display = 'block';
        else
            d.style.display = 'none';
    }
}
/*-----------------------------------------------------------
    Toggles tabs - Closes any open tabs, and then opens current tab
    Input:     1.The number of the current tab
                    2.The number of tabs
                    3.(optional)The number of the tab to leave open
                    4.(optional)Pass in true or false whether or not to animate the open/close of the tabs
    Output: none 
    ---------------------------------------------------------*/
function toggleTab(num,numelems,opennum,animate) {

    animate = false;

    if ($('tabContent'+num).style.display == 'none'){
        for (var i=1;i<=numelems;i++){
            if ((opennum == null) || (opennum != i)){
                var temph = 'tabHeader'+i;
                var h = $(temph);
                if (!h){
                    var h = $('tabHeaderActive');
                    h.id = temph;
                }
                var tempc = 'tabContent'+i;
                var c = $(tempc);
                if(c.style.display != 'none'){
                    if (animate || typeof animate == 'undefined')
                    {
                        Effect.toggle(tempc,'blind',{duration:0.3, queue:{scope:'menus', limit: 3}});
                        //Effect.toggle(tempc,'blind',{duration:0.5, queue:{scope:'menus', limit: 3}});
                    }
                    else
                        toggleDisp(tempc);
                }
            }
        }
        var h = $('tabHeader'+num);
        if (h)
            h.id = 'tabHeaderActive';
        h.blur();
        var c = $('tabContent'+num);
        c.style.marginTop = '2px';
        if (animate || typeof animate == 'undefined')
        {
            Effect.toggle('tabContent'+num,'blind',{duration:0.3, queue:{scope:'menus', position:'end', limit: 3}});
            //Effect.toggle('tabContent'+num,'blind',{duration:0.5, queue:{scope:'menus', position:'end', limit: 3}});
        }
        else{
            toggleDisp('tabContent'+num);
        }
    }
}

function hover(obj){
  if(document.all)
  {
    UL = obj.getElementsByTagName('ul');
    
    if(UL.length > 0)
    {
      sousMenu = UL[0].style;
      if(sousMenu.display == 'none' || sousMenu.display == '')
      {
        sousMenu.display = 'block';
        if(obj.className=="level1")
        {
        }
      }
      else
      {
        sousMenu.display = 'none';
        if(obj.className=="level1")
        {
        }
      }
    }
    else
    {
    }
  }
}

function setHover()
{
  LI = document.getElementById('menu').getElementsByTagName('li');
  nLI = LI.length;

  for(i=0; i < nLI; i++){
    LI[i].onmouseover = function()
    {
      //if (document.getElementById && document.getElementById('visite')) 
      //{
      //  document.getElementById('visite').style.display='none';
      //}
      hover(this);
    }
    LI[i].onmouseout = function()
    {
      hover(this);
      //if (document.getElementById && document.getElementById('visite'))
      //{
        //document.getElementById('visite').style.display='block';
      //}
    }
  }
}


////////////////////////////////////////////////////////////////
// http://java.sun.com/developer/technicalArticles/J2EE/AJAX/RealtimeValidation/
////////////////////////////////////////////////////////////////
function AJAXInteraction(url, callback, name, arg1, arg2, arg3) {

 var req = init();
 req.onreadystatechange = processRequest;

 function init() {
   if (window.XMLHttpRequest) {
     return new XMLHttpRequest();
   } else if (window.ActiveXObject) {
     return new ActiveXObject("Microsoft.XMLHTTP");
   }
 }

 function processRequest () {
   // readyState of 4 signifies request is complete
   if (req.readyState == 4) {
     // status of 200 signifies sucessful HTTP call
     if (req.status == 200) {
       // if (callback) callback(req.responseXML, name, arg1, arg2, arg3);
       if (callback) callback(req, name, arg1, arg2, arg3);
     }
   }
 }

 this.doGet = function() {
   // make a HTTP GET request to the URL asynchronously
   req.open("GET", url, true);
   req.send(null);
 }
}

function displayMessage( req, name, divid, email, elt )
{
  // Effacer un message d'attente ?

  if (divid)
  {
    //divid.innerHTML=email;
    //xGetElementById(divid).innerHTML=email;
    xGetElementById(divid).innerHTML="";
    //xGetElementById(divid).innerHTML="<img src=\"/gfm/10063/m/new/loading_small.gif\" alt=\"Chargement\" width=\"16\" height=\"16\" />";
  }
  if (elt) elt.value=email;

  if (req.responseText)
  {  
    if (req.responseText == 'ok')
    {
      //alert(req.responseText);
      xGetElementById('CHECK_EMAIL').innerHTML="<img src=\"/gfm/10063/m/new/valid_ok_16x16.png\" alt=\"\" width=\"16\" height=\"16\" />";
    }
    else if (req.responseText!='')
    {
      xGetElementById('CHECK_EMAIL').innerHTML="<img src=\"/gfm/10063/m/new/valid_bad_16x16.png\" alt=\"\" width=\"16\" height=\"16\" />";
      alert(req.responseText);
    }
  }
}

function searchEmail( elt, divid )
{
  if (!document.form.email.value.match(/^[a-z0-9&\'\.\-_\+]*@[a-z0-9]+([\.\-][a-z0-9]+)*\.[a-z]{2,}$/i))
  {
    alert ("Vous devez saisir une adresse email valide (prenom.nom@monemail.com)");
    return false;
  }
  
  if (document.form.email.value.match(/^www\./i))
  {
    alert ("Vous devez saisir une adresse email valide (prenom.nom@monemail.com)");
    return false;
  }
  
  
  
  if (!elt || elt.value=='')
  {
    alert("L'email doit être renseigné");
     return false;
  }

  var email=elt.value;

  // Prevoir un message d'attente ?
  if (divid)
  {
    //divid.innerHTML="Vérification email";
    //xGetElementById(divid).innerHTML="Vérification email";
    xGetElementById(divid).innerHTML="<img src=\"/gfm/10063/m/new/loading_small.gif\" alt=\"Chargement\" width=\"16\" height=\"16\" />";
  }
  else elt.value="Vérification email";


  // Format rewriting
  var url='';
   url+='/Contactez-nous/p/5/0/0/ACCOUNT=CREATE/AJAX=1';
   url+='/CHECK_EMAIL_AVAILABLE=' + encodeURIComponent( email );

  var ajax=new AJAXInteraction(url, displayMessage, 'email', divid, email, elt);
  ajax.doGet();
}


// SRI (Nabil)
function updateSRI(url)
{
	url1 = url.replace("#ajax_function#", "updateSRI");
	//alert(url1);
	$.ajax({
	   type: "GET",
	   url: url1,
	   success: function(msg){
		 //alert( "Data Saved: " + msg );
		 $("#sri_area").html(msg);
	   }
	 });
	 
	url2 = url.replace("#ajax_function#", "updateSRISearchProductList");
	$.ajax({
	   type: "GET",
	   url: url2,
	   success: function(msg){
		 //alert( "Data Saved: " + msg );
		 $("#content_with_sri").html(msg);
	   }
	 });
	 
	url3 = url.replace("#ajax_function#", "updateSRIKeyWordsSearchForm");
	$.ajax({
	   type: "GET",
	   url: url3,
	   success: function(msg){
		 //alert( "Data Saved: " + msg );
		 $(".search_form").html(msg);
	   }
	 });
	 
	window.scrollTo(0,0);
}

/*
 * @method : Fonction qui cache ou affiche un <div> .sri_brick_option fils d'un <div> désigné par un attribut
 * @param1 : Attribut du div père
 * @return : false
 */
function resizeSRIBrick(attribute)
{
	// Si la brique est visible, on la cache
	if($("#" + attribute + " .sri_brick_options").is(":visible"))
	{
		$("#" + attribute + " .sri_brick_options").hide("slow");
		$("#" + attribute + " .sri_brick_header .sri_brick_tab_resize img").attr("alt", T_SRI_INFOS["brick_tab"]["enlarge_name"]);
		$("#" + attribute + " .sri_brick_header .sri_brick_tab_resize img").attr("src", T_SRI_INFOS["brick_tab"]["enlarge_img"]);
	}
	// Si la brique est cachée, on l'affiche
	else if($("#" + attribute + " .sri_brick_options").is(":hidden"))
	{
		$("#" + attribute + " .sri_brick_options").show("slow");
		$("#" + attribute + " .sri_brick_header .sri_brick_tab_resize img").attr("alt", T_SRI_INFOS["brick_tab"]["reduce_name"]);
		$("#" + attribute + " .sri_brick_header .sri_brick_tab_resize img").attr("src", T_SRI_INFOS["brick_tab"]["reduce_img"]);
	}
	
	return false;
} // resizeSRIBrick()


/*
 * @method : Fonction qui redirige vers l'url en paramètre tout en désignant le nombre de produits à afficher par page
 * @param1 : Objet de sélection (un <select>)
 * @param2 : L'url vers laquelle on va faire la redirection
 * @return : rien vu que l'on fait une redirection
 */
function goTo(obj)
{
	var url = obj.options[obj.selectedIndex].value;
	window.location.replace(url);
} // goTo()


function showDetailBoxValueBySelect(obj, id, p_json_additionnal_infos, p_json_declinations)
{
	var jQ_obj = jQuery(obj);
	
	if ($.browser.msie && parseFloat($.browser.version) < 8)
	{
		if(jQ_obj.children('option:selected').hasClass('disabled_option'))
		{
			alert("Option indisponible pour les pré-requis sélectionnés.");
			
			// Remise à 0 du <select>
			jQ_obj.children('option').eq(0).attr("selected", "selected");
		}
	}
	
	if(jQ_obj.children("option:selected").val() != "") // Si on n'a pas de valeur nulle, on affiche le résultat de la sélection
	{
		manageDetailBoxView(obj, id, jQ_obj.children("option:selected").val(), jQ_obj.children("option:selected").html(), p_json_additionnal_infos, p_json_declinations);
	}
	else // Si on a une valeur nulle, on supprime le résultat de la sélection
	{
		manageDetailBoxView(obj, id, "", "", p_json_additionnal_infos, p_json_declinations);
	}
	
	return false;
} // showDetailBoxValueBySelect()

function showDetailBoxValueByLink(obj, value, id, p_json_additionnal_infos, p_json_declinations)
{
	var jQ_obj = jQuery(obj);
	var options = jQ_obj.parents(".detail_box_caps").find("select.select_"+id+" option");
	if(value != "") // Si on n'a pas de valeur nulle, on affiche le résultat de la sélection
	{
		// On met à jour le <select> associé
		for(var i=0; i < options.length; i++)
		{
			if(options.eq(i).attr("disabled") == "" && options.eq(i).val() == value)
			{
				options.eq(i).attr("selected", "selected");
			}
		}
		
		// On met à jour la vue
		manageDetailBoxView(obj, id, value, jQ_obj.attr("title"), p_json_additionnal_infos, p_json_declinations);
	}
	else // Si on a une valeur nulle, on supprime le résultat de la sélection
	{
		// On met à jour le <select> associé
		options.eq(0).attr("selected", "selected");
		
		// On met à jour la vue
		manageDetailBoxView(obj, id, value, "", p_json_additionnal_infos, p_json_declinations);
	}
	
	return false;
} // showDetailBoxValueByLink()


function manageDetailBoxView(obj, id, value, trad_value, p_json_additionnal_infos, p_json_declinations)
{
	var jQ_obj = jQuery(obj);
	
	var jQ_detail_box_product = jQ_obj.parents("#detail_box_product_"+p_json_additionnal_infos['generic_id']);
	
	var jQ_detail_box_caps_children = jQ_detail_box_product.find(".detail_box_caps");
	
	// On affiche le prix du produit générique qui sera modifié à la fin de la sélection
	jQ_detail_box_product.find(".detail_box_price").html(p_json_additionnal_infos["generic_price"]);
	
	var disabled = false;
	var price = "";
	// On parcours chaque critère
	for(var i=0; i < jQ_detail_box_caps_children.length; i++)
	{
		var id_children_i = jQ_detail_box_caps_children.eq(i).attr("id");
		
		// On désactive le bouton d'ajout au panier
		jQ_detail_box_product.find(".disabled").attr("style", "display: block;");
		json_additionnal_infos[p_json_additionnal_infos['generic_id']]['enabled_to_add_to_cart'] = false;
		jQ_detail_box_product.find(".detail_box_add_to_cart").attr("src", FTP+"/img/btn_add_to_cart_off.gif");
		
		jQ_detail_box_product.find(".detail_box_right .detail_box_quantity .detail_box_quantity_value").attr("name", "");
	
		// On affiche un message dans le résumé de la sélection
		if((i == 0) && (id_children_i == id))
		{
			if(value != "")
			{
				if(jQ_detail_box_product.find(".detail_box_summary .detail_box_summary_libel").length > 0)
				{
					jQ_detail_box_product.find(".detail_box_summary .detail_box_summary_libel").html("Vous avez choisi un parasol "+p_json_additionnal_infos["generic_name"]+" avec les options : ");
				}
				else
				{
					jQ_detail_box_product.find(".detail_box_summary").html("<div class=\"detail_box_summary_libel\">Vous avez choisi un parasol "+p_json_additionnal_infos["generic_name"]+" avec les options : </div>");
				}
			}
			else
			{
				jQ_detail_box_product.find(".detail_box_summary").html("");
			}
		}
	
	
		// Si on se trouve à la 2ème zone à partir de l'attribut sélectionné, on commence à remettre à 0
		if(disabled)
		{
			// On reinitialise les <select>
			jQ_detail_box_caps_children.eq(i).find("select").attr("disabled", "disabled");
			jQ_detail_box_caps_children.eq(i).find("select option").eq(0).attr("selected", "selected");
			// On cache les images
			jQ_detail_box_caps_children.eq(i).find(".detail_box_select_hidding_image").css("z-index", "20"); // On cache toutes les images
			// On nettoie le données résumé
			jQ_detail_box_product.find(".detail_box_summary #detail_box_summary_"+id_children_i).html("");
			jQ_detail_box_caps_children.eq(i).find(".detail_box_title .detail_box_value").remove();
			// On met le statut de l'étape sur En attente
			jQ_detail_box_caps_children.eq(i).find(".detail_box_step_state").attr("alt", "En attente");
			jQ_detail_box_caps_children.eq(i).find(".detail_box_step_state").attr("src", ""+FTP+"/img/detail_box_step_wait_"+(i+1)+".png");
		}
		
		// Si on trouve l'attribut qui vient juste d'être sélectionné
		if(id_children_i == id)
		{
			// On met à jour le titre
			jQ_detail_box_caps_children.eq(i).find(".detail_box_title").find(".detail_box_value").html(value);
      
			// On met à jour le résumé
			var jQ_detail_box_summary = jQ_detail_box_product.find(".detail_box_summary");
			var spacing = "";
			if(i != 0 && value != "") spacing = ",&nbsp;";
			if(jQ_detail_box_summary.find("#detail_box_summary_"+id).length == 0)
			{
				
				jQ_detail_box_summary.append("<span id=\"detail_box_summary_"+id+"\">"+spacing+trad_value+"</span>");
			}
			else
			{
				jQ_detail_box_summary.find("#detail_box_summary_"+id).html(""+spacing+trad_value+"");
			}
			// On met à jour le titre de l'attribut
			if(jQ_detail_box_caps_children.eq(i).find(".detail_box_title .detail_box_value").length == 0)
			{
				jQ_detail_box_caps_children.eq(i).find(".detail_box_title").append("<div class=\"detail_box_value\">" + trad_value + "</div>");
			}
			else
			{
				jQ_detail_box_caps_children.eq(i).find(".detail_box_title .detail_box_value").html(trad_value);
			}
			// On met à jour les statuts des étapes
			if(value != "")
			{
				jQ_detail_box_caps_children.eq(i).find(".detail_box_step_state").attr("alt", "Validé");
				jQ_detail_box_caps_children.eq(i).find(".detail_box_step_state").attr("src", ""+FTP+"/img/detail_box_step_check_"+(i+1)+".png");
			}
			else
			{
				jQ_detail_box_caps_children.eq(i).find(".detail_box_step_state").attr("alt", "En attente");
				jQ_detail_box_caps_children.eq(i).find(".detail_box_step_state").attr("src", ""+FTP+"/img/detail_box_step_wait_"+(i+1)+".png");
			}
			//jQ_detail_box_caps_children.eq(i).find(".detail_box_step_state").attr("alt", "Validé");
			
			// On permet à l'attribut suivant d'être sélectionné
			if(value != "" && ++i < jQ_detail_box_caps_children.length) // S'il existe un suivant, on le rend visible et on saute son traitement
			{
				id_children_i = jQ_detail_box_caps_children.eq(i).attr("id");
				jQ_detail_box_caps_children.eq(i).find("select").attr("disabled", "");
				jQ_detail_box_caps_children.eq(i).find("select").children("option").eq(0).attr("selected", "selected");
				jQ_detail_box_caps_children.eq(i).find(".detail_box_title .detail_box_value").remove();
				jQ_detail_box_product.find(".detail_box_summary #detail_box_summary_"+id_children_i).html("");
				jQ_detail_box_caps_children.eq(i).find(".detail_box_select_hidding_image").css("z-index", "20"); // On cache toutes les images
				
				// On initialise toutes nos options à disabled avant de permettre seulement les bonnes valeurs
				jQ_detail_box_caps_children.eq(i).find("select option[value!=\"\"]").attr("disabled", "disabled");
				jQ_detail_box_caps_children.eq(i).find("select option[value!=\"\"]").addClass("disabled_option"); // Gestion IE 7 et IE 8
				
				// On cache toutes nos images avant de permettre l'affichage des bonnes seulement
				if(jQ_detail_box_caps_children.eq(i).find(".detail_box_image_blocs").length > 0)
				{
					jQ_detail_box_caps_children.eq(i).find(".detail_box_select_hidding_image").css("z-index", "20");
				}
				
				// On parcours nos déclinaisons
				for(var i_decl=0; i_decl < p_json_declinations.length; i_decl++)
				{
					var find = true;
					// On parcours nos attributs
					var i_attr=0;
					for(; i_attr < i; i_attr++)
					{
						// Si une valeur ne correspond pas aux select précédent, on sort
						if(p_json_declinations[i_decl][p_json_additionnal_infos["visible_attributes"][i_attr]] != jQ_detail_box_product.find(".detail_box_caps#"+p_json_additionnal_infos["visible_attributes"][i_attr]+" select option:selected").val())
						{
							find = false;
							break;
						}
					}
					if(find)
					{					
					
						// On active les valeurs possibles dans le <select>
						jQ_detail_box_caps_children.eq(i).find("select option[value=\""+p_json_declinations[i_decl][id_children_i]+"\"]").attr("disabled", "");
						jQ_detail_box_caps_children.eq(i).find("select option[value=\""+p_json_declinations[i_decl][id_children_i]+"\"]").removeClass("disabled_option"); // Gestion IE 7 et IE 8
						// On active les valeurs possibles dans la liste d'images 
						if(jQ_detail_box_caps_children.eq(i).find(".detail_box_image_blocs").length > 0)
						{
							jQ_detail_box_caps_children.eq(i).find("#"+p_json_declinations[i_decl][id_children_i]+"").find(".detail_box_select_hidding_image").css("z-index", "0");
						}
					}
				}
				// On met à jour les statuts des étapes
				jQ_detail_box_caps_children.eq(i).find(".detail_box_step_state").attr("alt", "En attente");
				jQ_detail_box_caps_children.eq(i).find(".detail_box_step_state").attr("src", ""+FTP+"/img/detail_box_step_wait_"+(i+1)+".png");
				
			}
			// Si on est arrivé au dernier attribut
			else if(value != "" && i >= jQ_detail_box_caps_children.length)
			{
				// On affiche le prix correspondant //
				
				// On parcours nos déclinaisons
				for(var i_decl=0; i_decl < p_json_declinations.length; i_decl++)
				{
					var find = true;
					// On parcours nos attributs
					var i_attr=0;
					for(; i_attr < i; i_attr++)
					{
						// Si une valeur ne correspond pas aux select précédent, on sort
						if(p_json_declinations[i_decl][p_json_additionnal_infos["visible_attributes"][i_attr]] != jQ_detail_box_product.find(".detail_box_caps#"+p_json_additionnal_infos["visible_attributes"][i_attr]+" select option:selected").val())
						{
							find = false;
							break;
						}
					}
					
					if(find)
					{					
						jQ_detail_box_product.find(".detail_box_price").html(p_json_declinations[i_decl]["price"]);
						jQ_detail_box_product.find(".detail_box_quantity_value").attr("name", "QTY_"+p_json_declinations[i_decl]["id"]);
					}
				}
        
				// On active le bouton d'ajout au panier
				jQ_detail_box_product.find(".disabled").attr("style", "display: none;");
				json_additionnal_infos[p_json_additionnal_infos['generic_id']]['enabled_to_add_to_cart'] = true;
				jQ_detail_box_product.find(".detail_box_add_to_cart").attr("src", FTP+"/img/btn_add_to_cart_on.gif");
			}
			// On désactive le reste
			disabled = true;
		}
	}
	
	//alert(jQ_detail_box_product.find(".detail_box_add_to_cart").attr("onclick"));
}

function checkForm(id)
{
	return json_additionnal_infos[id]['enabled_to_add_to_cart'];
}
