function leir_kibe(melyik) {
	var leiras = document.getElementById('leir_'+melyik);
	if (leiras.style.display=='block') {
		leiras.style.display='none';
	} else {
		leiras.style.display='block';
	}
}

function findcheckbox(e, tdclass) {
	cells = e.parentNode.parentNode.cells;
	for (i=0; i < cells.length; i++) {
		if (cells[i].className==tdclass) {
			return cells[i].getElementsByTagName('input')[0];
		}
	}	
}

/* items list select element onchange handler */
function isc(e) { 
	checkbox = findcheckbox(e, 'kosarhoz');
	if (checkbox)
		checkbox.checked = true;
}

/* items list quantity edit element onchange handler */
function iec(e) { 
	checkbox = findcheckbox(e, 'kosarhoz');
	if (checkbox) {
		q = parseInt(e.value);
		if (isNaN(q) || q < 0) {
			e.focus();
		} else {
			e.value = q;
			checkbox.checked = q > 0;
		}
	}
}

/* items list quantity edit element onchange handler */
function cec(e) { 
	checkbox = findcheckbox(e, 'torles');
	if (checkbox) {
		q = parseInt(e.value);
		if (isNaN(q) || q < 0) {
			e.focus();
		} else {
			e.value = q;
			checkbox.checked = q == 0;
		}
	}
}

function item_pop(a,w,h) {
	url = a.getAttribute('href');
	w = w?w:'400';
	h = h?h:'300';
	var wnd = window.open('', 'item', 'location=0,statusbar=1,menubar=1,width=' + w + ',height=' + h);
	wnd.resizeTo(w,h);
	if (window.innerWidth) {
		dw = w-wnd.innerWidth;
		dh = h-wnd.innerHeight;
	} else if (wnd.document.documentElement && (wnd.document.documentElement.clientWidth || wnd.document.documentElement.clientHeight)) {
		dw = w-wnd.document.documentElement.clientWidth;
		dh = h-wnd.document.documentElement.clientHeight;
	} else if (wnd.document.body && (wnd.document.body.clientWidth || wnd.document.body.clientHeight)) {
		dw = w-wnd.document.body.clientWidth;
		dh = h-wnd.document.body.clientHeight;
	}
	if (dw&&dh) wnd.resizeTo(w+dw,h+dh);
	wnd.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" \n"http://www.w3.org/TR/html4/loose.dtd">\n<html><head><title></title><style type="text/css">html, body, img {margin:0;padding:0}\nimg {border: 0px;}</style></head><body><img style="cursor:pointer" onclick="window.close();" alt="'+url+'" src="'+url+'" />');
	wnd.document.close();
	wnd.focus();
	return false;
}

function imgpop(a) {
	var url = a.getAttribute('href');
	var i = a.getElementsByTagName( "img" )[0];
	var alt = i.getAttribute('alt')?i.getAttribute('alt'):url;
	var wnd = window.open('', 'item', 'location=0,statusbar=1,menubar=1');
	wnd.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" \n"http://www.w3.org/TR/html4/loose.dtd">\n<html><head><title>Vésnök Kft. – '+alt+'</title><script type="text/javascript" src="/res/main.js"></script><style type="text/css">html, body, img {margin:0;padding:0}\nimg {border: 0px;cursor:pointer}</style></head><body onload="return imgpopinner();"><img id="i" alt="'+alt+'" src="'+url+'" onclick="window.close();">');
	wnd.document.close();
	wnd.focus();
	return false;
}

function imgpopinner() {
	var i = document.getElementById('i');
	var w = i.width;
	var h = i.height;
	window.resizeTo(w, h);
	if (window.innerWidth) {
		dw = w-window.innerWidth;
		dh = h-window.innerHeight;
	} else if (window.document.documentElement && (window.document.documentElement.clientWidth || window.document.documentElement.clientHeight)) {
		dw = w-window.document.documentElement.clientWidth;
		dh = h-window.document.documentElement.clientHeight;
	} else if (window.document.body && (window.document.body.clientWidth || window.document.body.clientHeight)) {
		dw = w-window.document.body.clientWidth;
		dh = h-window.document.body.clientHeight;
	}
	if (dw&&dh) window.resizeTo(w+dw,h+dh);
	return false;
}


function shop_pop(a) {
	url = a.getAttribute('href');
	var wnd = window.open(url, 'shop', 'location=1,resizable=1,menubar=1,toolbar=1,scrollbars=1,width=960');
	wnd.focus();
	return false;
}