function checkPrice(val) {
var i = -1;
if (val.indexOf(".") >= 0)
i = val.indexOf(".");
else if (val.indexOf(",") >= 0)
i = val.indexOf(",");
if((i >= 0 && val.length - i) > 3) {
// trop de decimales
return val.substr(0, i+3);
}
else {
return val;
}
}

function startCalc(){
  interval = setInterval("calc()",1);
}

function calc(){
  one = Number(document.modif.productdetail_priceref.value.replace(/,/, '.')) ;
  two = document.modif.productdetail_reduction.value;
  three = 19.6;
  //document.modif.thirdBox.value = (((one * 1) * ((100-(two * 1))/100)) * ((three/100)+1));
  var prod = (((one * 1) * ((100-(two * 1))/100)) * ((three/100)+1))
  document.modif.thirdBox.value=custRound(prod,2);
}
function startIdeal(){
  interval = setInterval("Ideal()",1);
}

function Ideal(){
  pricefournisseur = Number(document.modif.productdetail_pricefournisseur.value.replace(/,/, '.')) ;
  vingttrois = 19.6;
  //document.modif.thirdBox.value = (((one * 1) * ((100-(two * 1))/100)) * ((three/100)+1));
  var priceideal = (pricefournisseur * 2.3)
  document.modif.IdealBox.value=custRound(priceideal,2);
}

function startTaux(){
  interval = setInterval("Taux()",1);
}

function Taux(){
  pricefournisseur = Number(document.modif.productdetail_pricefournisseur.value.replace(/,/, '.')) ;
  thirdBox = Number(document.modif.thirdBox.value.replace(/,/, '.')) ;
  var TauxBox = (thirdBox / pricefournisseur)
  document.modif.TauxBox.value=custRound(TauxBox,2);
}

function custRound(x,places) {
return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places)
}
function stopCalc(){
  clearInterval(interval);
}
function stopIdeal(){
  clearInterval(interval);
}
function stopTaux(){
  clearInterval(interval);
}

function PopupImage(val) {

	titre="howdoyouwantme - Zoom";

	w=open('','zoom','width=100,height=100,toolbar=no,scrollbars=no,resizable=yes');	

	w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE>");

	w.document.write("<script language='javascript'> function resizeMe() { if (navigator.appName == 'Netscape') { adjWidth = document.images[0].width; adjHeight = document.images[0].height;}else{ adjWidth = document.images[0].width+13; adjHeight = document.images[0].height+32;} self.resizeTo(adjWidth, adjHeight);}");

	w.document.write("</script></HEAD>");	

	w.document.write("<BODY onload='resizeMe();window.focus();' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><a href=javascript:window.close();><IMG src='"+val+"' alt=Click&nbsp;to&nbsp;close border=0></a></BODY></HTML>");

	w.document.close();

}



function confirmation(mesg,url)

{

if ((url != null) && (url != '') && (mesg != null) && (mesg != ''))

	if (confirm(mesg)) location.href = url;

}





function Start(page) {

OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,width=641, height=400, ");

}





function MM_reloadPage(init) {  //reloads the window if Nav4 resized

  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {

    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}

  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();

}

MM_reloadPage(true);



function imprime(){

	var tmp = document.getElementById("impression").innerHTML;

	yepyep = window.open("print.php",'','width=800,height=600,toolbar=no,scrollbars=yes,resizable=no');

	yepyep.document.write("<HTML><HEAD><TITLE>IMPRESSION</TITLE><link href=\"library/css4.css\" rel=\"stylesheet\" type=\"text/css\"></HEAD><BODY onload=\"window.print();\">"+tmp+"\r\n</BODY></HTML>");

	yepyep.document.close();

}

