function OpenWin(URL,width,height,nom) {
	window.open(URL,nom,"toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=" + width + ",height=" + height + ",resizable=no");
}

function OpenWin2(URL,width,height,nom) {
	window.open(URL,nom,"toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=" + width + ",height=" + height + ",resizable=yes");
}

function AfficheMaxi(URL1, URL2, nom_jv, CSS) {
  var agent = navigator.userAgent.toLowerCase();
  var amajor = parseInt(navigator.appVersion);
  var aie = ((agent.indexOf('msie') != -1) && (agent.indexOf('opera') == -1));
  var offsetie7 = 0;
  if (aie && (amajor == 4)) {
    var tie = agent.split(';');
    var ver = 0;
    for(var k = 0; k < tie.length; k++) {
        if (tie[k].indexOf('msie') != -1) {
            xx = tie[k].replace(/msie/g,'');
            ver = xx.replace(/ /g,'');
            k = tie.length;
        }
    }
    if (ver >= 7) {offsetie7 = 24;}
  }
  var nom = stripslashes(nom_jv);

  var html = '<html><head><title>Zoom</title><script type="text/javascript">function Max (a, b){if (a > b) {return a;} else {return b;}}function Min (a, b){if (a < b) {return a;} else {return b;}}function autoSize(){self.resizeTo(Max(Min((document.images[0].width+40), screen.width-10),160),Min((document.images[0].height+' + (offsetie7 + 130) + '), screen.height-25));}</script></head><body bgcolor="#303030" leftMargin="0" topMargin="0" rightMargin="0" bottomMargin="0" MARGINHEIGHT="0" MARGINWIDTH="0" onLoad="javascript:autoSize();"><link REL="stylesheet" type="text/css" href="' + CSS + '"><center><table width="100%" cellpadding="0" cellspacing="0" align="center"><tr><td bgcolor="black"><font class="jauneik">&nbsp;&nbsp;&nbsp;&nbsp;<b>' + nom + '</b></font></td></tr><tr><td align="center"><font class="jauneik"><br></font><img src="' + URL1 + URL2 + '"></td></tr><tr><td height="5"><font class="jauneik">&nbsp;</font></td></tr><tr><td align="center"><a href="javascript:close();"><img src="' + URL1 + '/images/b_fermer.png" border="0"></a></td></tr></table></center></body></html>';

  popupImage = window.open('', '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0, width=300, height=30, left=180, top=50');
  popupImage.document.open();
  popupImage.document.write(html);
  popupImage.document.close();
  popupImage.document.focus();
}

function AfficheStock(P1) {
  
  html = '<html><head><meta http-equiv="Refresh" content="0; URL='+P1+'"></head><body bgcolor="#772B4E" leftMargin="0" topMargin="0" rightMargin="0" bottomMargin="0" MARGINHEIGHT="0" MARGINWIDTH="0">&nbsp;</body></html>';

  popupImage = window.open('','_blank','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1, width=300, height=30, left=180, top=50');
  popupImage.document.open();
  popupImage.document.write(html);
  popupImage.document.close();
}

function AfficheW(P1) {
  html = '<html><head><meta http-equiv="Refresh" content="0; URL='+P1+'"></head><body bgcolor="#772B4E" leftMargin="0" topMargin="0" rightMargin="0" bottomMargin="0" MARGINHEIGHT="0" MARGINWIDTH="0">&nbsp;</body></html>';
  popupImage = window.open('','_blank','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1, width=300, height=30, left=50, top=50');
  popupImage.document.open();
  popupImage.document.write(html);
  popupImage.document.close();
}

function expandingWindow(website, id_author) {
    var id_auth = id_author;
    var sizer = window.open('','_blank','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1, width=400, height=350, left=70, top=50');
    sizer.location = website + "?id_auth=" + id_auth;
}

function stripslashes(ch) {
  return ch.replace(/(\\)([\\\'\"])/g,"$2")
}
    
var ns6=document.getElementById && !document.all

function restrictinput(maxlength,e,placeholder){
    if (window.event&&event.srcElement.value.length>=maxlength)
        return false
    else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
        var pressedkey=/[a-zA-Z0-9\.\,\/]/ 
        if (pressedkey.test(String.fromCharCode(e.which)))
        e.stopPropagation()
    }
}

function countlimit(maxlength,e,placeholder){
    var theform = eval(placeholder)
    var lengthleft = maxlength - theform.value.length
    var placeholderobj = document.all ? document.all[placeholder] : document.getElementById(placeholder)
    if (window.event||e.target && e.target == eval(placeholder)){
    if (lengthleft < 0)
    theform.value = theform.value.substring(0,maxlength)
    placeholderobj.innerHTML = lengthleft
    }
}

function displaylimit(thename, theid, thelimit){
    var theform=theid!=""? document.getElementById(theid) : thename
    var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b>'
    if (document.all||ns6) document.write(limit_text)
    if (document.all){
        eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
        eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
    }
    else if (ns6){
        document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
        document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
    }
}

function divswitch(checkboxId, baliseId) {
    if (document.getElementById && document.getElementById(checkboxId) != null) {
        if (document.getElementById(baliseId) != null) {
            if (document.getElementById(checkboxId).checked == true) {
                document.getElementById(baliseId).style.visibility='visible';
                document.getElementById(baliseId).style.display='block';
            }
            else
            {
                document.getElementById(baliseId).style.visibility='hidden';
                document.getElementById(baliseId).style.display='none';
            }
        }
    }
}

function rb_divswitch(radioId, baliseId) {
    if (document.getElementById && document.getElementById(radioId) != null) {
        if (document.getElementById(baliseId) != null) {
            if (document.entryform.paiement[1].checked == true) {
                document.getElementById(baliseId).style.visibility='visible';
                document.getElementById(baliseId).style.display='block';
            }
            else
            {
                document.getElementById(baliseId).style.visibility='hidden';
                document.getElementById(baliseId).style.display='none';
            }
        }
    }
}

function affiche(id,oui_non) {
  var element_style=null
  if (document.getElementById) {
    element_style=document.getElementById(id).style;
  } else if (document.all) {
    element_style=document.all[id].style;
  } 
  if (element_style) {
     if (oui_non==true) element_style.display="inline";
     if (oui_non==false) element_style.display="none";
  } 
}

function get_total(totalId, nbline) {
    var thetotal=0
    var q=0
    var p=0
    var tot=0
    for (cnt = 1; cnt < nbline+1; cnt++){
        q = document.getElementById("qte"+cnt).value;
        p = document.getElementById("prix"+cnt).value;
        tot = q * p;
        thetotal += tot;
    }
    document.getElementById(totalId).innerHTML = thetotal;
}

function printPage() {
    document.getElementById('print').style.visibility = 'hidden';
    if (typeof(window.print) != 'undefined') {
        window.print();
    }
    document.getElementById('print').style.visibility = 'visible';
}

function getid(what){    
    if(document.layers){ where = eval("document."+what); }    
    if(document.all){ where = eval("document.all."+what); }    
    if(!document.all && document.getElementById){ where = eval("document.getElementById('"+what+"')" ); }    
    return where;
} 

function arrondi(nombre, chiffre) {
    virgule = Math.pow(10,chiffre);
    valeur_arrondi = (Math.round(nombre*virgule))/virgule;
    return (valeur_arrondi);
}

function convertchamps(champs) {
    valeur_sans_espaces = champs.replace(/\s/g,"");
    valeur_sans_virgule = valeur_sans_espaces.replace(/,/,".");
    valeur_convertie = parseFloat(valeur_sans_virgule);
    return (valeur_convertie);
}

function avecvirgule(champs) {
    return (champs.replace(".",","));
}

var ie = document.all;
var ns = document.layers;

function distXY(coor) {
    //retourne la distance X ou Y
    var scrOfX = 0, scrOfY = 0;
    if( typeof( window.pageYOffset ) == 'number' ) {
        //Netscape compliant
        scrOfY = window.pageYOffset;
        scrOfX = window.pageXOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        //DOM compliant
        scrOfY = document.body.scrollTop;
        scrOfX = document.body.scrollLeft;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        //IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
    }

    switch (coor) {
        case('X'):
        case('x'):
            return scrOfX;
            break;
        case('Y'):
        case('y'):
            return scrOfY;
            break;
    }
}

function enlarge(which,si,e){
    var cdx =0;
    var cdy = 0;
    if (ie||ns6){
        crossobj = document.getElementById ? document.getElementById(si) : document.all.showimage;
        if (crossobj.style.visibility == "hidden"){
            cdx = distXY('x'); 
            cdy = distXY('y'); 
            crossobj.style.left = cdx + e.clientX + 20;
            crossobj.style.top = cdy + e.clientY - 200;
            crossobj.innerHTML = '<img src="' + which + '" width="200" alt="">';
            crossobj.style.visibility = "visible";
            fSwapSelect(si); 
        }
        else {
            crossobj.style.visibility = "hidden";
            fSwapSelect(si); 
            return false;
        }
    }
    else if (document.layers){
        if (document.showimage.visibility == "hide"){
            document.showimage.document.write('<a href=JavaScript: onMouseover="drag_dropns(showimage)"><img src="' + which + '" width="200" border=0></a>');
            document.showimage.document.close();
            document.showimage.left = e.x;
            document.showimage.top = e.y;
            document.showimage.visibility = "show";
        }
        else {
            document.showimage.visibility = "hide";
            return false;
        }
    }
    else {
        return true;
    }        
}

function closepreview(si){
    crossobj.style.visibility = "hidden";
    fSwapSelect(si); 
}

fDomOffset = function( oObj, sProp ) {
    var iVal = 0;
    while (oObj && oObj.tagName != 'BODY') {
        eval('iVal += oObj.' + sProp + ';');
        oObj = oObj.offsetParent;
    }
    return iVal;
}

fSwapSelect = function( sId ) { 
    oObj = document.getElementById(sId); 
    Top_Element  = fDomOffset(oObj, 'offsetTop'); 
    Left_Element  = fDomOffset(oObj, 'offsetLeft'); 
    Largeur_Element = oObj.offsetWidth; 
    Hauteur_Element = oObj.offsetHeight; 
    oSelects = document.getElementsByTagName('SELECT'); 
    if (oSelects.length > 0) { 
        for (i = 0; i < oSelects.length; i++) { 
            oSlt = oSelects[i]; 
            Top_Select = fDomOffset(oSlt, 'offsetTop'); 
            Left_Select = fDomOffset(oSlt, 'offsetLeft'); 
            Largeur_Select = oSlt.offsetWidth; 
            Hauteur_Select = oSlt.offsetHeight; 
            isLeft = false; 
            if ((Left_Element > (Left_Select - Largeur_Element)) && (Left_Element < (Left_Select + Largeur_Select))) { 
                isLeft = true; 
            } 
            isTop = false; 
            if ((Top_Element > (Top_Select - Hauteur_Element)) && (Top_Element < (Top_Select + Hauteur_Select))) { 
                isTop = true; 
            } 
            if (isLeft && isTop) { 
                sVis = (oObj.style.visibility == 'hidden') ? 'visible' : 'hidden'; 
                if (oSlt.style.visibility != sVis) {oSlt.style.visibility = sVis;} 
            } else { 
                if (oSlt.style.visibility != 'visible') {oSlt.style.visibility = 'visible';} 
            } 
        } 
    } 
} 
