function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function show_menu_galeria()
{
  document.getElementById("subm_moda").style.visibility='hidden';
  x=findPosX(document.getElementById("menu_galeria")) + 180;
  y=findPosY(document.getElementById("menu_galeria"));
  document.getElementById("subm_galeria").style.width='120px';
  document.getElementById("subm_galeria").style.height='183px';
  document.getElementById("subm_galeria").style.left=x+'px';
  document.getElementById("subm_galeria").style.top=y+'px';
  document.getElementById("subm_galeria").style.visibility='visible';
  document.getElementById("subm_galeria").style.position='absolute';
}

function show_menu_moda()
{
  document.getElementById("subm_galeria").style.visibility='hidden';
  x=findPosX(document.getElementById("menu_moda")) + 180;
  y=findPosY(document.getElementById("menu_moda"));
  document.getElementById("subm_moda").style.width='120px';
  document.getElementById("subm_moda").style.height='183px';
  document.getElementById("subm_moda").style.left=x+'px';
  document.getElementById("subm_moda").style.top=y+'px';
  document.getElementById("subm_moda").style.visibility='visible';
  document.getElementById("subm_moda").style.position='absolute';
}

function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        cursor.x = e.clientX + 
            (document.documentElement.scrollLeft || 
            document.body.scrollLeft) - 
            document.documentElement.clientLeft;
        cursor.y = e.clientY + 
            (document.documentElement.scrollTop || 
            document.body.scrollTop) - 
            document.documentElement.clientTop;
    }
    return cursor;
}

function hide_menu(e)
{
  obj=document.getElementById("subm_galeria");
  var kursor=getPosition(e);
  if ((kursor.x < (parseInt(obj.style.left) - 200)) || (kursor.x > (parseInt(obj.style.left) + parseInt(obj.style.width) + 20)) || (kursor.y < (parseInt(obj.style.top) - 20)) || (kursor.y > (parseInt(obj.style.top) + parseInt(obj.style.height) + 20)))
    obj.style.visibility='hidden';
  obj=document.getElementById("subm_moda");
  var kursor=getPosition(e);
  if ((kursor.x < (parseInt(obj.style.left) - 200)) || (kursor.x > (parseInt(obj.style.left) + parseInt(obj.style.width) + 20)) || (kursor.y < (parseInt(obj.style.top) - 20)) || (kursor.y > (parseInt(obj.style.top) + parseInt(obj.style.height) + 20)))
    obj.style.visibility='hidden';
}

function menu_init()
{
  document.onmousemove = hide_menu;
}

function check_field(obj,def)
{
var t;
var stoisko_podstawowe_cena = 100;
var dodatkowe_metry_cena = 25;
var przylacza_elektryczne_cena = 15;
var wynajem_sceny_cena = 150;
var prezentacja_pojazdu_cena = 50;
var ValidChars="0123456789";
var checkStr = obj.value;
if(checkStr == "")
  obj.value=def;
  else
    for (i = 0;  i < checkStr.length;  i++)
      {
      ch = checkStr.charAt(i);
      for (j = 0;  j < ValidChars.length;  j++)
        if (ch == ValidChars.charAt(j))
          break;
        if (j == ValidChars.length)
          {
          obj.value=def;
          break;
          }
      }
Form1.stoisko_podstawowe_suma.value=Form1.stoisko_podstawowe_ilosc.value * stoisko_podstawowe_cena;
Form1.dodatkowe_metry_suma.value=Form1.dodatkowe_metry_ilosc.value * dodatkowe_metry_cena;
Form1.przylacza_elektryczne_suma.value=Form1.przylacza_elektryczne_ilosc.value * przylacza_elektryczne_cena;
Form1.wynajem_sceny_suma.value=Form1.wynajem_sceny_ilosc.value * wynajem_sceny_cena;
Form1.prezentacja_pojazdu_suma.value=Form1.prezentacja_pojazdu_ilosc.value * prezentacja_pojazdu_cena;
i = 1*Form1.stoisko_podstawowe_suma.value + 1*Form1.dodatkowe_metry_suma.value + 1*Form1.przylacza_elektryczne_suma.value + 1*Form1.wynajem_sceny_suma.value + 1*Form1.prezentacja_pojazdu_suma.value;
t=i.toFixed(2);
Form1.wartosc_netto_suma.value=t.replace(/\./,",");
i=i*1.22;
t=i.toFixed(2);
Form1.wartosc_brutto_suma.value=t.replace(/\./,",");
}

