function textCounter(field, countfield, maxlimit) {
if(document.getElementById) {
myfield = document.getElementById(field);
mycount = document.getElementById(countfield);
} else if(document.all) {
myfield = document.all[field];
mycount = document.all[countfield];
} else return;
if (myfield.value.replace(/\r\n/g,'x').length > maxlimit) {
myfield.value = myfield.value.substring(0, maxlimit);
mycount.value = 0;
var reg = new RegExp("(#SIZE#)", "g");
alert(message.replace(reg,maxlimit));
} else {
mycount.value = maxlimit - myfield.value.replace(/\r\n/g,'x').length;
}
}
function modquant(inputname,plusoumoins) {
if(document.getElementById) {
myinput = document.getElementById(inputname);
} else if(document.all) {
myinput = document.all[inputname];
} else return;
if(plusoumoins == 'plus') { 
if (myinput.value < 99) { 
myinput.value = +myinput.value + 1;
}
}
else if(plusoumoins == 'moins') { 
if(myinput.value > 1) { 
myinput.value = +myinput.value - 1;
}
}
}
function popup(dest,taille) {
var options = ',resizable=yes,location=no,scrollbars=yes,status=yes';
var popup;
if(dest.indexOf('?') == -1)
{
dest = dest + '?dontSaveLastForward';
}
else
{
dest = dest + '&dontSaveLastForward';
}
if(taille == 'gde') {
popup = window.open(dest + '&keepVolatileSession=','F2','width=700,height=510'+options);
if (window.focus) { popup.focus(); }
}
else if(taille == 'ptt') {
popup = window.open(dest+ '&keepVolatileSession=','F4','width=665,height=525'+options);
if (window.focus) { popup.focus(); }
}
else if(taille == 'pdf') {
popup = window.open(dest+ '&keepVolatileSession','F3','width=700,height=510'+options);
if (window.focus) { popup.focus(); }
}
else if(taille == 'aide') {
popup = window.open(dest+ '&keepVolatileSession','Aide','width=700,height=510'+options);
if (window.focus) { popup.focus(); }
}
else if(taille == 'flash') {
popup = window.open(dest, '','width=698,height=398,resizable=no,location=no,scrollbars=no,status=no');
if (window.focus) { popup.focus(); }
}
}
function ajoutArticle(ref, type, produit) {
popup('choisirCaracteristiquesProduit.do?ref='+ref+'&type='+type+'&produit='+produit,'gde');
}
function ajoutArticle(ref, type, produit, cdif) {
popup('choisirCaracteristiquesProduit.do?ref='+ref+'&type='+type+'&produit='+produit+'&cdif='+cdif,'gde');
}
function popupConfirm(key,form) {
popup('confirm.do?key='+key+'&form='+form,'ptt');
}
function popupConfirmSansFormulaire(key,forward) {
popup('confirm.do?key='+key+'&forward='+forward,'ptt');
}
function popupConfirmSansFormulaireOuiNon(key,forward) {
popup('confirmOuiNon.do?key='+key+'&forward='+forward,'ptt');
}
function popupMessage(key) {
popup('confirm.do?key='+key ,'ptt');
}
function popupErrorSansFormulaire(key,forward) {
popup('error.do?key='+key+'&forward='+forward,'ptt');
}
function popupErrorSansFormulaire(key) {
popup('error.do?keepVolatileSession=&key='+key+'&sujet='+key,'ptt');
}
function popupErrorMessage(key) {
popup('error.do?key='+key,'ptt');
}
function ShowHide(id,showorhide) {
if(document.getElementById) {
elem = document.getElementById(id);
} else if(document.all) {
elem = document.all[id];
} else return;
if(showorhide == 'show') {
elem.style.display = "block";
}
else if(showorhide == 'hide') {
elem.style.display = "none";
}
}
function CheckRadio(id,key,forward,msgalert) {
if(document.getElementById) {
elem = document.getElementById(id);
} else if(document.all) {
elem = document.all[id];
} else return;
if(elem.checked == true) {
popupConfirmSansFormulaire(key,forward);
return false;
}
else if(elem.checked == false) {
alert(msgalert);
}
}
function switchClass(elt, etat) {
var c= elt.className;
var l= c.length;
var isOn= false;
if(l == 2 && c == "on") isOn= true;
else isOn= (c.substr(l-3) == " on");
if (!isOn && (etat == undefined || etat == 'actif')) {
elt.className = c + " on";
}
else if (isOn && (etat == undefined || etat == 'passif')) {
elt.className = c.substr(0, l-3);
}
}
function ChangeSRC(img,etat,url) {
if (etat == 'actif') {
img.src = "img/carto/" + url + "_on" + ".gif";
}
else if (etat == 'passif') {
img.src = "img/carto/" + url + ".gif";
}
}
function switchSRC(img, etat) {
var source= img.src;
var l= source.length;
var isOn= (source.substr(l-7) == "_on.gif");
if (!isOn && (etat == undefined || etat == 'actif')) {
img.src = source.substr(0, l-4) + "_on" + ".gif";
}
else if (isOn && (etat == undefined || etat == 'passif')) {
img.src = source.substr(0, l-7) + ".gif";
}
}
function arrondirMesure(val){
if(val){
var ret= "" + (Math.round(val*100)/100);
if(ret.indexOf('.') == -1)
{
return ret + ".00";
}
else
if ((ret.length >= 2) && (ret.indexOf('.') == (ret.length - 2)))
{
return ret + "0";
}
else
{
return ret;
}
}else
return "0.00";
}
