function sbmt(tf, mtd) {
	f = document.forms[0];
	f.action = tf;
	f.method = mtd;
	f.submit();
}

function selectItem(itm, val) {
	oneField = document.getElementById(itm);
	for (a = oneField.options.length-1; a >= 0 ; a--) {
		if (oneField.options[a].value == val) oneField.options[a].selected = true;
	}
}

function checkItem(itm) {
	oneField = document.getElementById(itm);
	if (oneField != null) oneField.checked = true;
}

function fillItem(itm, val) {
	oneField = document.getElementById(itm);
	if (oneField != null) oneField.value = val;
}
function newWindow(mypage,myname,w,h,scroll){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=1';

	return window.open(mypage, myname, settings)
}

function isChecked(itm) {
	radioGrp = eval('document.forms[0].'+itm);
	if (radioGrp.checked) return true;
	for (var i = 0; i < radioGrp.length; i++) {
	    if (radioGrp[i].checked) return true;
	}
}

function getChecked(itm) {
	radioGrp = eval('document.forms[0].'+itm);
	if (radioGrp.checked) return radioGrp.value;
	for (var i = 0; i < radioGrp.length; i++) {
	    if (radioGrp[i].checked) return radioGrp[i].value;
	}
}

function toggle_menu(id) {
	pnl   = document.getElementById('mn'+id);

	pnl.style.display = (pnl.style.display == 'block') ? 'none' : 'block';

	return false;
}

function open_map(firma) {
	mapWindow = window.open("http://www.supernavigator.sk/clients/mapa.php?firmID="+firma+"&ref=http://www.roden.sk","mapa","toolbar=0,location=0,scrollbars=0,width=494,height=418,resizable=no");
}

function NewWindow(mypage,myname,w,h,scroll){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=1';
	return window.open(mypage, myname, settings)
}

function NahladTel(id) {
	MyWinPic = NewWindow('telefon_nahlad.php?pic='+id,'TelefonNahlad',500,500,0);
}

function NahladPri(id) {
	MyWinPic = NewWindow('prislusenstvo_nahlad.php?pic='+id,'PrislusenstvoNahlad',500,500,0);
}

function openDetail(itm, kat) {
	if (kat > 3) {
		MyDetail = NewWindow('obchod_detail_pri.php?id='+itm,'ObchodDetail'+itm,600,200,1);
	} else if (kat == 3) {
	    MyDetail = NewWindow('obchod_detail_gigaset.php?id='+itm,'ObchodDetail'+itm,600,400,1);
	} else {
		MyDetail = NewWindow('obchod_detail_tel.php?id='+itm,'ObchodDetail'+itm,600,400,1);
	}
}

function doKosa(itm) {
	var imn = document.getElementById('itemno');
	var ivl = document.getElementById('itempcs');
	var ipc = document.getElementById(itm);

	imn.value = itm;
	ivl.value = ipc.value;

	document.forms[0].submit();
}

function zKosa(itm) {
	var imn = document.getElementById('itemno');
	var ivl = document.getElementById('itempcs');

	imn.value = itm;
	ivl.value = -1;

	document.forms[0].submit();
}

function _openSignOn(price,orderid) {
	window.open('https://www.vub.sk/ibank/e-platby.asp?'+price+'='+orderid+'=0145roden',null,"scrollbars=1,resizable=1,location=0,menubar=0,status=1,toolbar=0",true);
}

function makeOrder() {
	var oti = 0;

	radioGrp = document.getElementsByName('Platba');
	for (var i = 0; i < radioGrp.length; i++) {
	    if (radioGrp[i].checked) oti = radioGrp[i].value;
	}

	if (oti == 0) {
		alert('Vyberte spôsob platby!');
	} else {
		document.forms[1].submit();
	}
}
