var isNetscape4 = document.layers;
var isNetscape6 = document.getElementById && !document.all
var isNetscape = isNetscape4 || isNetscape6;
var isIE = document.all && !isNetscape;
var DHTML = document.getElementById || document.all || document.layers;


function flash(tag) { 
  document.write(tag);
}


function getStyle(nom) {
  if (isNetscape6)
    style = document.getElementById(nom).style;
  else if (isNetscape4)
    eval("style = document."+nom);
  else
    style = document.all[nom].style;
  return(style);
}


function clipping(nom, x1, y1, x2, y2) {
  if (isNetscape4) {
    getStyle(nom).clip.left = x1;
    getStyle(nom).clip.top = y1;
    getStyle(nom).clip.right = x2; 
    getStyle(nom).clip.bottom =  y2;
  }
  else if (isNetscape6)
    getStyle(nom).clip = "rect("+y1+" "+x1+" "+y2+" "+x2+")";
  else
    getStyle(nom).clip = "rect("+y1+" "+x2+" "+y2+" "+x1+")";
}

function deplacement_absolu(nom, abscisse, ordonnee) {
  if (!DHTML)
    return;
  getStyle(nom).left = abscisse;
  getStyle(nom).top = ordonnee;
}

function deplacement_relatif(nom, deltaX, deltaY) {
  if (!DHTML)
    return;
  getStyle(nom).left = parseInt(getStyle(nom).left) + deltaX;
  getStyle(nom).top = parseInt(getStyle(nom).top) + deltaY;
}

function nonStock(phrase){
    jAlert(phrase,'information');
}

function findPos(obj) {
            var curleft = obj.offsetLeft || 0;
            var curtop = obj.offsetTop || 0;
            while (obj = obj.offsetParent) {
                    curleft += obj.offsetLeft
                    curtop += obj.offsetTop
            }
            return {x:curleft,y:curtop};
} 

function check_email(email) {
        b = true;
        if (email.lastIndexOf('@') < 1)
            b = false;
        if (email.lastIndexOf('@') > email.lastIndexOf('.'))
            b = false;
        if (email.lastIndexOf('@') == email.lastIndexOf('.')+1)
            b = false;
        if (email.length-email.lastIndexOf('.') < 3 || email.length-email.lastIndexOf('.') > 5)
            b = false;
        if (email.length<6)
            b = false;
        return(b);
    }


// retourne un objet xmlHttpRequest.
// méthode compatible entre tous les navigateurs (IE/Firefox/Opera)
function getXMLHTTP(){
  var xhr=null;
  if(window.XMLHttpRequest) // Firefox et autres
  xhr = new XMLHttpRequest();
  else if(window.ActiveXObject){ // Internet Explorer
    try {
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e1) {
        xhr = null;
      }
    }
  }
  else { // XMLHttpRequest non supporté par le navigateur
    return null;
  }
  return xhr;
}


function ajoutPanier(PDT_ID, QUANTITE, phrase){
  //var xhr=getXMLHTTP();
  //xhr.open("GET", "panier.php?so=a&PDT_ID="+PDT_ID+"&QUANTITE="+QUANTITE, false);
  //xhr.send(null);
  //alert(xhr.responseText);

  //$('#articles').html('<img src="jquery/indicator.gif" alt="" />');

  $.get("panier.php", { PDT_ID: PDT_ID, QUANTITE: QUANTITE },
    function(data){ 
    if(data == phrase)
            modificationPanier('panier',QUANTITE);
      //alert("<?php echo $DIC_TEXTE_PRODUIT_AJOUTE_PANIER; ?>");
      //$('#articles').load('selection.php');
      //jAlert(data, 'Information');

        document.location.replace('mon_panier.php');
     
       
    }); 
    

}


function modificationPanier(SO,QUANTITE){
  
      $.get("ajax.php",{so: SO,nb: QUANTITE},
          function(data){
              var nombre = document.getElementById('articlePanier').innerHTML;
              nombre = parseInt(nombre) + parseInt(QUANTITE);
              document.getElementById('articlePanier').innerHTML = nombre;
              if(nombre > 1)
                 document.getElementById('terminaison').innerHTML = "s";
          });
}

function arrondiPrix(nombre){
  nombre = Math.round(nombre*100)/100 + 0.001;
  nombre += '';
  return nombre.substr(0, nombre.indexOf('.')+3);
}

function redirigeCatalogue(famille){
    if(famille != ""){
        //window.location.replace("catalogue.php?FAM_ID="+famille);
        window.location.replace("catalogue-"+famille+".html");
    }
}

function afficheSousFamille(famille,sousFamille){
    if(famille != "" && sousFamille != ""){
        //window.location.replace("catalogue.php?FAM_ID="+sousFamille+"&FAM_FAM_ID="+famille);
        window.location.replace("catalogue-"+famille+"-"+sousFamille+".html");
    }   
}
              /*
function rechercheAJAX(famille,ssfamille,mot,fabriquant,designer,finition){
  $.post("ajax.php", {so:'r',' FAM_ID: "John", FAM_FAM_ID: "2pm" },
   function(data){
     alert("Data Loaded: " + data);
   });
}           */

function arianne(fam_id,fam_fam_id){
//$.post("recherche.php", { famille: fam_id, ssfamille: fam_fam_id });
window.location.replace("recherche.php?famille="+fam_id+"&ssfamille="+fam_fam_id+"");
}


function carte(carte){
  document.getElementById('type').value = carte;
  document.cb.submit();
}

