function wi(obrazek, width, height){
	width += 40; height += 40;
	window.open(obrazek, "Foto", "width="+width+",height="+height+",menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes,left=100,top=100");
	return false;
}

function trim(hodnota) {
	if(hodnota.charAt(0) == " ") {
		hodnota = hodnota.substring(1,hodnota.length);
		hodnota = trim(hodnota);
	}
	if(hodnota.charAt(hodnota.length-1) == " ") {
		hodnota = hodnota.substring(0,hodnota.length-1);
		hodnota=trim(hodnota);
	}
	return hodnota;
}

function is_int(val, string) {
	var intresult = true; var a = 1; var needle = '';
	for(a=1; a<val.length+1; a++) {
		needle = val.substring(a-1,a);
		if((needle < "0" || needle > "9") && (string.indexOf(needle) < 0 || string.length == 0)) intresult = false;
	}
	return intresult;
}


function search_form(form) {
	search = form.search.value; search = trim(search);
	if(search.length < 2) {
		alert('Hledaný výraz musí mít alespoň dva znaky!'); return false;
	}
	else return true;
}

function validate_form(form, inp_length, inp_adds) {
	cntpr = form.cntpr.value; cntpr = trim(cntpr);
	if (inp_length) {
		var ell = trim(document.getElementById('input_length').value);
		ell = ell * 1;
		if (ell <= 0) {
			alert('Požadovaná délka je zadána nesprávně!');
			return false;
		}
	}
	if (inp_adds) {
		var ela = trim(document.getElementById('additional_requirement').value);
		if (ela.length == 0) {
			alert('Nebylo zadáno upřesnění dodávky - přesná délka, atd.!');
			return false;
		}
	}
	if(!is_int(cntpr, '') || cntpr.length == 0) {
		alert('Nesprávně zadaný počet kusů! Formulářové políčko patrně obsahuje neplatný znak!'); return false;
	}
	else return true;
}

function adv(url) {
	window.open(url, "Graweb", "width=800, height=750,menubar=no, status=no, toolbar=yes, scrollbars=yes, resizable=yes, location=yes, left=100,top=100");
	return false;
}

function w(url) {
	window.open(url, "links", "width=800, height=750,menubar=yes, status=yes, toolbar=yes, scrollbars=yes, resizable=yes, location=yes, left=100,top=100");
	return false;
}

function start_from(fr)
{
	var el = document.getElementById('wh' + fr).value;
	if (el.length > 0) {
		var el2 = document.getElementById('from' + fr);
		el2.checked = true;
	}
}

