function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   myfield.form.submit();
   return false;
   }
else
   return true;
}


function lisaaRivi(tid)  {
	var table = tid+"_table"
	var lastRow = document.getElementById(table).rows.length
	var x=document.getElementById(table).insertRow(lastRow)
	var y=x.insertCell(0)
	var z=x.insertCell(1)
	var e=x.insertCell(2)
	if(tid=='teo')
		var count = lastRow - 1;
	else 
		var count = lastRow;
	y.innerHTML= "<input type='text' name='"+tid+"_1_" + count + "' style='width:100%;' value=''>"
	z.innerHTML= "<input type='text' name='"+tid+"_2_" + count + "' style='width:100%;' value=''>"
	e.innerHTML= "<input type='text' name='"+tid+"_3_" + count + "' style='width:100%;' value=''>"
	y.style.backgroundColor = "#f1f1f1"
	z.style.backgroundColor = "#f1f1f1"
	e.style.backgroundColor = "#f1f1f1" 
}
function poistaRivi(table) {
  var tbl = document.getElementById(table);
  var lastRow = tbl.rows.length;
  if (lastRow > 1) tbl.deleteRow(lastRow - 1);
}
function print_page(id,lang) {
	var url = "inc/print.php" + id + "&lang=" + lang;
	window.open(url,'_blank','width=700,height=891,scrollbars=1');
}
function avaa(id,lang) {
	var url = "inc/view_prod.php?id=" + id + "&lang=" + lang;
	window.open(url,'_blank','width=700,height=891,scrollbars=1');
}

function avaa_u(id,lang,prod) {
	if(prod=='j') {
		var url = "view_prod_jotun.php?id=" + id + "&lang=" + lang;
	}
	else {
		var url = "view_prod.php?id=" + id + "&lang=" + lang;
	}
	window.open(url,'_blank','width=700,height=891,scrollbars=1');
}
function hideDiv(div) {
	document.getElementById(div).style.visibility = 'hidden';
}
function showDiv(div) {
	document.getElementById(div).style.visibility = 'visible';
}
function printProd(div) {
	hideDiv(div)
	document.body.scroll="no" /* ie -jemmaus */
	/*document.body.style.overflowY = "hidden"  ff -jemmaus */
	window.print()
	window.close()
}
function print_jot() {
	hideDiv('header')
	document.body.scroll="no" /* ie -jemmaus */
	window.print()
	window.close()
}
function lisaaLogo(logo,but,val)  {
	var file = "../gfx/logo_" + logo + ".jpg"
	if(val==1) {
		document.getElementById(logo).src = file
		document.getElementById(but).value = 2
	}
	else {
		document.getElementById(logo).src = "../gfx/empty.png"
		document.getElementById(but).value = 1
	}
}
function checkLisaa()  {
	var val = document.getElementById("roppi").value
	if(val==0) {
		document.getElementById("lisbut").disabled = true;
	}
	else {
		document.getElementById("lisbut").disabled = false;
	}
}
function checkVal(lang) {
	var val = document.getElementById("kulutus").value
	var anum=/(^\d+$)|(^\d+\.\d+$)/
	if (anum.test(val)) {
		testresult=true
	}
	else {
		switch (lang) {
			case 'fi': alert("Anna kulutus numeroina."); break;
			case 'se': alert("Please input a valid number!"); break;
			case 'ru': alert("Please input a valid number!"); break;
			case 'en': alert("Please input a valid number"); break;
		}
		testresult=false
	}
	return (testresult)
}
