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 CalcIMC(){
  interval = setInterval("IMC()",1);
}

function calc(){
  one = Number(document.modif.item_price.value.replace(/,/, '.')) ;
  two = document.modif.item_pricereduction.value;
  three = document.modif.item_vat.value;
  //document.modif.thirdBox.value = (((one * 1) * ((100-(two * 1))/100)) * ((three/100)+1));
  var prod = ((one * ((three/100)+1)) * ((100-two)/100))
  //var prod = (((one * 1) * ((100-(two * 1))/100)) * ((three/100)+1))
  document.modif.thirdBox.value=custRound(prod,2);
}

function IMC(){
  one = Number(document.healthIMC.IMCpoids.value.replace(/,/, '.')) ;
  two = Number(document.healthIMC.IMCtaille.value.replace(/,/, '.')) ;
  var prodIMC = (one/(two*two))
  document.healthIMC.IMC.value=custRound(prodIMC,2);
}

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

// LANCER RECHERCHE ---------------------------------------------------------------------------------------------------------------------------------
function send_recherche(){
	document.form.submit();
}

function LaunchSearch(langue)
{
	var msg;
	if (document.form.critere.value != '' && document.form.critere.value != null)
	{
	document.form.submit();
	} else {
		if (langue == "fr")
		{
			msg = 'Merci d\'entrer un mot clef';
		} else {
			if (langue == "en")
			{
				msg = 'Please, enter a keyword';
			} else {
				msg = 'Please, enter a keyword';
			}
		}
		alert(msg);
	}

	/*
	if (lang == "fr")
	{
		msg = 'Cette fonction est en cours de développement\nMerci de votre compréhension';
	} else {
		msg = 'This feature has not been implemented.\nThanks for your comprehension';
	}
	alert(msg);
	*/

}

function PopupImage(val) {
	titre="ephyto.com - 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 showlayer(layername) {
if (!loaded) return;
if (navigator.appName.indexOf("Microsoft") == -1) {
document.layers[layername].visibility = "visible"
}
else {
document.all[layername].style.visibility = "visible"
}
}

function hidelayer(layername) {
if (!loaded) return;
if (navigator.appName.indexOf("Microsoft") == -1) {
document.layers[layername].visibility = "hide"
}
else {
document.all[layername].style.visibility = "hidden"
}
}*/
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 MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

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 kill()
{
hidelayer('health1');
hidelayer('health13');
hidelayer('health3');
hidelayer('health4');
hidelayer('health5');
hidelayer('health6');
hidelayer('health7');
hidelayer('health8');
hidelayer('health9');
hidelayer('health10');
hidelayer('health11');
hidelayer('health12');
hidelayer('health14');
hidelayer('bag');
}

function imprime(){
	var tmp = document.getElementById("impression").innerHTML;
	yepyep = window.open("print.php",'','width=550,height=550,toolbar=no,scrollbars=yes,resizable=no');
	yepyep.document.write("<HTML><HEAD><TITLE>IMPRESSION</TITLE><link href=\"library/ephyto1.css\" rel=\"stylesheet\" type=\"text/css\"></HEAD><BODY onload=\"window.print();\">"+tmp+"\r\n</BODY></HTML>");
	yepyep.document.close();
}

function imprime_admin(){
	var tmp = document.getElementById("impression").innerHTML;
	yepyep = window.open("../print.php",'','width=550,height=550,toolbar=no,scrollbars=yes,resizable=no');
	yepyep.document.write("<HTML><HEAD><TITLE>IMPRESSION</TITLE><link href=\"../library/css3.css\" rel=\"stylesheet\" type=\"text/css\"></HEAD><BODY onload=\"window.print();\">"+tmp+"\r\n</BODY></HTML>");
	yepyep.document.close();
}
