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 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, FLAG_RELOAD){
    $('#articles').html('<img src="jquery/indicator.gif" alt="" />');
    $.get("panier.php", {so: 'a', PDT_ID: PDT_ID, QUANTITE: QUANTITE },
        function(data){ 
            $('#articles').load('selection.php');
            if(data == 'OK') {
                $('#lp_'+PDT_ID).html("<span class='msg_panier'>Produit ajouté au panier</span>");
            } else {
                alert(data);
            } 
            if  (FLAG_RELOAD) {
                window.location.reload();
            } 
        }
    ); 
}


function arrondiPrix(nombre){
  nombre = Math.round(nombre*100)/100 + 0.001;
  nombre += '';
  return nombre.substr(0, nombre.indexOf('.')+3);
}
