
/*
function onKeyPress (e) {
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if (keycode == 13) {
		document.grupa.submit();
		return false
	}
	else if (keycode > 48 && keycode <= 57 ) {
		if (s = prompt("ilosc * kod katalogowy", String.fromCharCode(keycode) )) {
			vals = s.split("*");
			if (vals[1] != undefined) { kod = vals[1]; ilosc = vals[0]; }
			else { ilosc = 1; kod = vals[0]; }
			document.location.href = document.grupa.action + '&' + 'add['+kod.toUpperCase()+']='+ilosc;
		}
	}
	return true
}
document.onkeypress = onKeyPress;
*/

var lastIdent;
var zIndex = 200;
var wxs = -105;
var wys = 100;



function move(e){
	if (dragapproved){
		xs=is_gecko?(temp1+(e.clientX-x)): (temp1+event.clientX-x);
		ys=is_gecko?(temp2+(e.clientY-y)): (temp2+event.clientY-y);
	//	window.status = temp1;
		z.style.left = xs + 'px';
		z.style.top = ys + 'px';
		return false
	}
}

function drags(e){

	if (!is_ie&&!is_gecko) return
	
	var firedobj=is_gecko? e.target : event.srcElement
	var topelement=is_gecko? "HTML" : "BODY"

	if (firedobj.className=="drag" || firedobj.id == "tableOferta" || firedobj.className == "selWindow"){
		++zIndex;
		firedobj.style.zIndex = zIndex;
		dragapproved=true
		z=firedobj
		temp1=(z.style.left)?parseInt(z.style.left+0):wxs;
		temp2=(z.style.top)?parseInt(z.style.top+0):wxy;
		x=is_gecko? e.clientX: event.clientX
		y=is_gecko? e.clientY: event.clientY
		document.onmousemove=move
		return false
	}
}
function ups (e) {
	dragapproved=false;
}


function maxZ ()  {
	z = 0;
	if (document.getElementsByTagName)
		var x = document.getElementsByTagName('div');
	else if (document.all)
		var x = document.all.tags('div');
	for (var i=0;i<x.length;i++) 
		if (x[i].style.zIndex > z) z = x[i].style.zIndex;
	return z;
}

function openSelWindow(oid){
	st = (document.documentElement)?document.documentElement['scrollTop']:document.body.scrollTop;
	document.getElementById(oid).style.display = 'block';
	wys = st + 100;
	document.getElementById(oid).style.top = (st + 100) + 'px';
	++zIndex;
	document.getElementById(oid).style.zIndex = zIndex;
	void(0);
	
}

function lclose(obj){
	document.getElementById(obj).style.display = 'none';
}
function at(kod,name,typ,cena) {
	openSelWindow('uslugiparam');
	el('unazwa').value = name;
	el('utyp').value = typ;
	el('ucena').value = cena;
	document.forms['grupa'].action += '&add['+kod+']=1';
	el('unazwa').focus();
}

document.onmousedown=drags
document.onmouseup=ups
