var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ns6=document.getElementById&&!document.all
var ns4=document.layers

var loc = "";


menuimg = new Image;
menuimg.src="img/p.gif";

menuimgov = new Image;
menuimgov.src="img/wiecej.gif";


function Mover(loc)
{
	loc.src = menuimgov.src;
}

function Mout(loc)
{
	loc.src = menuimg.src;
}




function showopis(which)
{
	opisobj=ie4? document.all.popopis : ns6? document.getElementById("popopis") : ns4? document.popopis : ""
	opisobj.thestyle=(ie4||ns6)? opisobj.style : opisobj

	if (ie4||ns6)
	{
		opisobj.innerHTML=which
	}
	else
	{
		opisobj.document.write('<layer name=gui>'+which+'</layer>')
		opisobj.document.close()
	}
	opisobj.thestyle.visibility="visible"
}

function showmenu(e,which, tmp)
{
	if (!document.all&&!document.getElementById&&!document.layers)
	return

	Mout(loc);
	loc = tmp;

	clearhidemenu()
	Mover(loc);

	menuobj=ie4? document.all.popmenu : ns6? document.getElementById("popmenu") : ns4? document.popmenu : ""
	menuobj.thestyle=(ie4||ns6)? menuobj.style : menuobj

	if (ie4||ns6)
	{
		menuobj.innerHTML=which
	}
	else
	{
		menuobj.document.write('<layer name=gui bgColor=#E6E6E6 width=165 onmouseover="clearhidemenu()" onmouseout="hidemenu()">'+which+'</layer>')
		menuobj.document.close()
	}
/*
	menuobj.contentwidth=(ie4||ns6)? menuobj.offsetWidth : menuobj.document.gui.document.width
	menuobj.contentheight=(ie4||ns6)? menuobj.offsetHeight : menuobj.document.gui.document.height
	eventX=ie4? event.clientX : ns6? e.clientX : e.x
	eventY=ie4? event.clientY : ns6? e.clientY : e.y

	var rightedge=ie4? document.body.clientWidth-eventX : window.innerWidth-eventX
	var bottomedge=ie4? document.body.clientHeight-eventY : window.innerHeight-eventY

	if (rightedge<menuobj.contentwidth)
	{
			menuobj.thestyle.left=ie4? document.body.scrollLeft+eventX-menuobj.contentwidth : ns6? window.pageXOffset+eventX-menuobj.contentwidth : eventX-menuobj.contentwidth
	}
	else
	{
		menuobj.thestyle.left=ie4? document.body.scrollLeft+eventX : ns6? window.pageXOffset+eventX : eventX
	}

	if (bottomedge<menuobj.contentheight)
	{
		menuobj.thestyle.top=ie4? document.body.scrollTop+eventY-menuobj.contentheight : ns6? window.pageYOffset+eventY-menuobj.contentheight : eventY-menuobj.contentheight
	}
	else
	{
		menuobj.thestyle.top=ie4? document.body.scrollTop+event.clientY : ns6? window.pageYOffset+eventY : eventY
	}
	*/
	menuobj.thestyle.visibility="visible"
	return false
}

function hidemenu()
{
	if (window.menuobj)
		menuobj.thestyle.visibility=(ie4||ns6)? "hidden" : "hide"
		Mout(loc);
		loc = "";
}

function dynamichide(e)
{
	if (ie4&&!menuobj.contains(e.toElement))
		hidemenu()
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
		hidemenu()
}


function delayhidemenu()
{
	if (ie4||ns6||ns4)
		delayhide=setTimeout("hidemenu()",500)
}

function clearhidemenu()
{
	if (window.delayhide)
		clearTimeout(delayhide)
}


function powieksz(str, s, w)
{
	wys = w + 15;
	szer = s + 30;

	  if(window.screen){
		aw=screen.availWidth;
		ah=screen.availHeight;
	  }else{
		aw=640;
		ah=450;
	  }

	  if (szer>800) szer = 800;
	  if (wys>600) wys = 600;

	var win = window.open(str,"zoom","width="+szer+", height="+wys+", left="+(aw-szer)/2+", top="+ (ah-wys)/2+", titlebar=no, status=no, toolbar=no, menubar=no, location=no, resizable=yes, scrollbars=yes, fullscreen=no");
	win.focus();

}


	var Zamowienie = new Array();
	Zamowienie[0] = new Array('','','','','','');

	function CheckZamowienie()
	{
		var tabela = '<table cellspacing="1" cellpadding="1" border="0" width="690"><tr><td width="30" class="nagl"><b>Lp.</b></td><td width="54" class="nagl"><b>Seria</b> <br>(3 litery)</td><td width="175" class="nagl"><b>Nazwa towaru</b></td>    <td width="79" class="nagl"><b>Lp. cennika</b></td><td width="39" class="nagl"><b>Szt.</b></td>    <td width="39" class="nagl"><b>L/P</b></td>    <td width="266" class="nagl"><b>Uwagi</b> <br>(kolor korpusu, kolor frontu, dodatki)</td></tr>';
		var nr = 0;
		for(i=0;i<Zamowienie.length;i++)
		{
			tabela+='<tr>';
			tabela+='<td class="tdl" valign="top"><span style="color:#000000">'+(i+1)+'.&nbsp;</span></td>';
			tabela+='<td class="tdl" valign="top"><input type="text" id="seria_'+i+'" name="seria_'+i+'" class="box3" value="'+Zamowienie[i][0]+'"></td>';
			tabela+='<td class="tdl" valign="top"><input type="text" id="nazwa_'+i+'" name="nazwa_'+i+'" class="box4" value="'+Zamowienie[i][1]+'"></td>';
			tabela+='<td class="tdl" valign="top"><input type="text" id="lpcennik_'+i+'" name="lpcennik_'+i+'" class="box5" value="'+Zamowienie[i][2]+'"></td>';
			tabela+='<td class="tdl" valign="top"><input type="text" id="szt_'+i+'" name="szt_'+i+'" class="box6" value="'+Zamowienie[i][3]+'"></td>';
			tabela+='<td class="tdl" valign="top"><input type="text" id="lp_'+i+'" name="lp_'+i+'" class="box6" value="'+Zamowienie[i][4]+'"></td>';
			tabela+='<td class="tdl" valign="top"><textarea id="uwagi_'+i+'" name="uwagi_'+i+'" style="width: 230px; height: 30px;" class="box">'+Zamowienie[i][5]+'</textarea></td>';
			tabela+='</tr>';
		}
		tabela+= '</table>';
		zam.innerHTML = tabela;
		MF.all["seria_"+(i-1)].focus();
	}

	function add()
	{
		for(i=0;i<Zamowienie.length;i++)
		{
			Zamowienie[i][0] = MF.all["seria_"+i].value;
			Zamowienie[i][1] = MF.all["nazwa_"+i].value;
			Zamowienie[i][2] = MF.all["lpcennik_"+i].value;
			Zamowienie[i][3] = MF.all["szt_"+i].value;
			Zamowienie[i][4] = MF.all["lp_"+i].value;
			Zamowienie[i][5] = MF.all["uwagi_"+i].value;
		}

		Zamowienie[Zamowienie.length] = new Array('','','','','','');
		CheckZamowienie();
	}

	function MFreset()
	{
		Zamowienie = new Array();
		Zamowienie[0] = new Array('','','','','','');
		CheckZamowienie();
	}
	
	function MFsubmit()
	{
		okno = wnd1('', 'zamowienie', 800, 400);
		okno.focus();
		MF.ilosc_zamowien.value = Zamowienie.length;
		MF.mailem.value = 0;
		MF.submit();
	}

	function MFsubmitm()
	{
		okno = wnd1('', 'zamowienie', 800, 400);
		okno.focus();
		MF.ilosc_zamowien.value = Zamowienie.length;
		MF.mailem.value = 1;
		MF.submit();
	}

	function MFreset2()
	{
		MF.reset();
	}
	
	function MFsubmit2()
	{
		MF.submit();
	}

function wnd(src, nazwa, w, h)
{
  if(window.screen){
    aw=screen.availWidth;
    ah=screen.availHeight;
  }else{
    aw=640;
    ah=450;
  }
  //if(noweOkienko==null || noweOkienko.closed){
    ustawienia=
     "left=" + (aw-w)/2 + ", "
    +"top=" + (ah-h)/2 + ", "
    +"screenX=" + (aw-w)/2 + ", "
    +"screenY=" + (ah-h)/2 + ", "
    +"width=" + w + ", "
    +"height=" + h + ", "
    +"innerWidth=" + w + ", "
    +"innerHeight=" + h + ", "
    +"toolbar=no, "
    +"location=no, "
    +"directories=no, "
    +"status=no, "
    +"menubar=no, "
    +"scrollbars=yes, "
    +"resizable=yes, "
	+"status=no";
	noweOkienko = window.open(src,nazwa,ustawienia);

  //}
  return noweOkienko;
}

