function checkGogoForm(frm)
///{{{
{
	if (frm.jmeno.value == '') {window.alert('Vyplňte položku jméno'); frm.jmeno.focus(); return false;}
	if (frm.prijmeni.value == '') {window.alert('Vyplňte položku příjmení'); frm.prijmeni.focus(); return false;}
	if (frm.bydliste.value == '') {window.alert('Vyplňte položku bydliště'); frm.bydliste.focus(); return false;}
	if (frm.miry.value == '') {window.alert('Vyplňte položku míry'); frm.miry.focus(); return false;}
	if (frm.zkusenosti.value == '') {window.alert('Vyplňte položku zkušenosti'); frm.zkusenosti.focus(); return false;}
	if (frm.telefon.value == '') {window.alert('Vyplňte položku telefon'); frm.telefon.focus(); return false;}

	var mam_foto = false;

	if (frm.id.value > 0) {
		mam_foto = true;
	} else {
		for (i = 1; i <= 3; ++i) {
			fname = document.getElementById("foto"+i).value;

			if (fname != '') {
				mam_foto = true;
				if (!is_jpg(fname)) {
					window.alert('Přidávejte pouze obrázky formátu JPG prosím.');
					return false;
				}
			}
		}
	}

	if (!mam_foto) {
		window.alert('Přidejte alespoň 1 fotografii');
		frm.foto1.focus();
		return false;
	}

	return true;
}
///}}}

function is_email(s) {
	r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (s == "" || !(r1.test(s) || !r2.test(s)));
}

function is_jpg(s) {
	r2 = new RegExp("\.(jpg|JPG|jpeg|JPEG)$");
	return r2.test(s);
}


function setImg(direction)
///{{{
{
	elem = document.getElementById("gho-img");

	document.getElementById('gho-prev').style.display = 'block';
	document.getElementById('gho-next').style.display = 'block';

	if (elem) {
		if (direction == 'prev') {
			document.getElementById('gho-prev').style.display = 'none';
			if (index > 0) {
				document.getElementById('gho-prev').style.display = 'block';
				index--;
				elem.src = fotos[index];
			}
		} else if (direction == 'next') {
			document.getElementById('gho-next').style.display = 'none';
			if (index < (fotos.length-1)) {
				document.getElementById('gho-next').style.display = 'block';
				index++;
				elem.src = fotos[index];
			}
		} else {
			for (i = 0; i < fotos.length; i++) {
				if (fotos[i] == direction) {
					index = i;
					elem.src = fotos[i];
					break;
				}
			}
		}
	}

	if (index == 0) {
		document.getElementById('gho-prev').style.display = 'none';
		document.getElementById('gho-next').style.display = 'block';
	}

	if (index == (fotos.length-1)) {
		document.getElementById('gho-prev').style.display = 'block';
		document.getElementById('gho-next').style.display = 'none';
	}


	return false;
}
///}}}



///////////AJAXove hratky
function doAJAX(url) {
	var xmlHttpReq = false;
	var self = this;

	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}

	self.xmlHttpReq.open('POST', url, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			var response = self.xmlHttpReq.responseText;
			var text;
			if (response == 1) {
				text = 'Test OK';
			} else if (response == -1) {
				text = 'CHYBA: Adresa je už používána!';
			} else if (response == -2) {
				text = 'CHYBA: Špatný formát adresy nebo adresa z neexistující domény!';
			}

			window.alert(text);

			//..alebo callback funkcia
			//updatepage(self.xmlHttpReq.responseText);
		}
	}

    	self.xmlHttpReq.send(getEmail());
	return false;
}

function getEmail() {
	field = document.getElementById('email-field');

	if (field) {
		val = field.value;
		qstr = 'email=' + escape(val);
		return qstr;
	}

	return false;
}

function updatepage(str){
	document.getElementById("result").innerHTML = str;
}
