function wi(url, width, height)
{
	width += 50; height += 50;
	window.open(url, 'foto', 'width='+width+', height='+height+', toolbar=no, location=no, resizable=yes, scrollbars=yes, top=100, left=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 zkontroluj_email(adresa)
{
    var pozice_zavinace = adresa.indexOf("@");
    if (pozice_zavinace < 0)
        return false;
    var cast_pred_zavinacem = adresa.substring(0,pozice_zavinace);
    var cast_po_zavinaci = adresa.substring(pozice_zavinace+1,adresa.length);
    if (cast_po_zavinaci.indexOf("@") >= 0)
        return false;
    if (cast_pred_zavinacem.length <= 0)
        return false;
    if (cast_po_zavinaci.length <= 0)
        return false;
    return true;
}

function check_form()
{
	var error = false;
	var report = '';
	var jmeno_prijmeni = document.getElementById('jmeno_prijmeni').value;
	jmeno_prijmeni = trim(jmeno_prijmeni);
	if (jmeno_prijmeni.length == 0) {
		error = true;
		report += 'Jméno a příjmení není zadáno!\n';
	}
	var telefon = document.getElementById('telefon').value;
	telefon = trim(telefon);
	if (telefon.length == 0) {
		error = true;
		report += 'Telefon není zadán!\n';
	}
	var email = document.getElementById('email').value;
	email = trim(email);
	if (email.length == 0) {
		error = true;
		report += 'E-mail není zadán!';
	} else {
		if (!zkontroluj_email(email)) {
			error = true;
			report += 'E-mail má nesprávnou adresu!';
		}
	}
	if (error) {
		alert(report);
		return false;
	}
	var check_value = document.getElementById('check_value');
	check_value.value = 1;
	return true;
}
