function getElement(formname,id) {
		var element;
		if (document.getElementById) {
			element = document.getElementById(id);
		} else if (document.all) {
			element = document.all[id];
		} else if (document.layers) {
			element = document.all[id];
		}
		return element;
	}

	function GetElement(id) {
		var element;
		if (document.getElementById) {
			element = document.getElementById(id);
		} else if (document.all) {
			element = document.all[id];
		} else if (document.layers) {
			element = document.all[id];
		}
		return element;
	}

	var $items = new Array();
	var $itemPrices = new Array();
	function calcSum()
	{
		var i = 0;
		var totalSum = 0;
		while (i < $items.length)
		{
			var lineID = $items[i];
			var elQuantity = GetElement('quantity'+lineID);
			if (elQuantity)
			{
				var sum;
				sum = $itemPrices[i] * elQuantity.value;
				totalSum = totalSum + sum;
			}
			i++;
		}
		var elTotalSum = GetElement('totalSum');
		if (elTotalSum) {
    		if (totalSum.toFixed)
				elTotalSum.value = totalSum.toFixed(2);
			else
	  	  		elTotalSum.value = totalSum;
		}
		return totalSum;
	}
	function doSelect(selectID,step) {
	  var elSelect = GetElement(selectID);
	  if (elSelect) {
	    if ((elSelect.selectedIndex+step) < elSelect.options.length && (elSelect.selectedIndex+step) >= 0) {
	    	elSelect.selectedIndex = elSelect.selectedIndex + step;
	    	calcSum();
			}
		}
	}
	
	function checkProductsSubmit()
	{
		if (calcSum() > 0) return true;
		return false;
	}

  function UpdateQty(item)
	{
	id = item.value;
	newQty = item.options[item.selectedIndex].text;
	document.location.href = '?id='+id;
	}
	
var imageWin;
function imgWin(imgSrc,pwidth,pheight,title) {
	var winw = (screen.width - pwidth) / 2;
	var winh = (screen.height - pheight) / 2;
	if (imageWin && imageWin.closed==false) {
		imageWin.close();
	}
		imageWin = open("/px/index.html", "pilt", "toolbar=no,directories=no,status=no,location=no,resizable=no,scrollbars=no,menubar=no,height="+pheight+",width="+pwidth+",top="+winh+",left="+winw+"");
		
		imageWin.document.open();
		imageWin.document.write("<html><head><title>" + title);
		imageWin.document.write("</title></head><body bgcolor=black scrolling=no marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>");
		imageWin.document.write("<table width=100% height=100% cellpadding=0 border=0 cellspacing=0><tr><td valign=middle align=center><a href='javascript:window.close()' title='Sulge aken'><img src="+imgSrc+" width="+pwidth+" height="+pheight+" border=0></a><br>[<a href='javascript:window.close()' title='Sulge aken'><<-Tagasi </a>]</td></tr></table>");
		imageWin.document.write("</body></html>");
		imageWin.document.close();
	return false;
}	  
function checkForm() {
name = document.getElementById("name").value;
  phone = document.getElementById("phone").value;
  email = document.getElementById("email").value;
  date = document.getElementById("date").value;
  time = document.getElementById("time").value;
  if (name == "") {
  hideAllErrors();
document.getElementById("nameError").style.display = "inline";
document.getElementById("name").select();
document.getElementById("name").focus();
  return false;
  } else if (phone == "") {
hideAllErrors();
document.getElementById("phoneError").style.display = "inline";
document.getElementById("phone").select();
document.getElementById("phone").focus();
  return false;
  } else if (email == "") {
hideAllErrors();
document.getElementById("emailError").style.display = "inline";
document.getElementById("email").select();
document.getElementById("email").focus();
  return false;
  }  else if (date == "") {
hideAllErrors();
document.getElementById("dateError").style.display = "inline";
document.getElementById("date").select();
document.getElementById("date").focus();
    return false;
  } else if (time == "") {
hideAllErrors();
document.getElementById("timeError").style.display = "inline";
document.getElementById("time").select();
document.getElementById("time").focus();
    return false;
  }
  return true;
  }
 
  function hideAllErrors() {
document.getElementById("nameError").style.display = "none"
document.getElementById("phoneError").style.display = "none"
document.getElementById("emailError").style.display = "none"
document.getElementById("dateError").style.display = "none"
document.getElementById("timeError").style.display = "none"
  }	
function newWindow(mypage,myname,w,h,features) {
  if(screen.width){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  }else{winl = 0;wint =0;}
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}

//**********************************************************
