/**
 * Regularni vyrazy pro kontrolu zadanych udaju
 * TODO: vylepsit je :o) 
 */ 
var reg_exp_email = "^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+[\.]{1}[a-zA-Z]{2,4}$";
var reg_exp_tel   = "[\+420]*[ ]*[/]*[ ]*[0-9]{3}[ ]*[/]*[ ]*[0-9]{3}[ ]*[0-9]{3}";

/**
 * Form. pro fulltext. vyhledavani
 */
function focusSearchInput(input)
{
  if (input.value == SEARCH_DEF_STR)
  {
    input.value = "";
  }
}

function checkSerchForm(form)
{
  if (form.search.value.length < SEARCH_MIN_LENGTH)
  {
    window.alert( SEARCH_MSG_SHORT_QUERY );
    form.search.focus();
    return false;
  }
  return true;
}

/**
 * Form. pro objednani Newsletteru
 */
function focusNwlInput(input)
{
  input.value = "";
}

function checkNwlForm(form)
{
  if (!form.email.value.match(reg_exp_email))
  {
    form.email.focus();
    window.alert (texty.regMsgEmail);
		return false;
  }
  return true;
}

/**
 * Registracni formular
 */ 
function checkRegForm(f)
{
  // Kontaktni udaje
	if (f.prijmeni && f.prijmeni.value == "") {
		f.prijmeni.focus();
		alert (texty.regMsgPrijm);
		return false;
	}
	if (f.jmeno && f.jmeno.value == "") {
		f.jmeno.focus();
		alert (texty.regMsgJmeno);
		return false;
	}
	if (f.email && !f.email.value.match(reg_exp_email)) {
    f.email.focus();
    alert (texty.regMsgEmail);
		return false;
	}
	if (f.telefon && !f.telefon.value.match(reg_exp_tel)) {
		f.telefon.focus();
		alert (texty.regMsgTelef);
		return false;
	}
	if (f.spolecnost && f.spolecnost.value == "") {
		f.spolecnost.focus();
		alert (texty.regMsgSpolec);
		return false;
	}
	if (f.medium && f.medium.value == "") {
		f.medium.focus();
		alert (texty.regMsgMedium);
		return false;
	}

  // Login a heslo
	if (f.login && f.login.value == "") {
		f.login.focus();
		alert (texty.regMsgLogin);
		return false;
	}
	if (f.heslo && f.heslo.value == "") {
		f.heslo.focus();
		alert (texty.regMsgHeslo1);
		return false;
	}
	if (f.heslo2 && f.heslo2.value == "") {
		f.heslo2.focus();
		alert (texty.regMsgHeslo2);
		return false;
	}
	if ((f.heslo && f.heslo2) && (f.heslo.value != f.heslo2.value)) {
		f.heslo2.focus();
		alert (texty.regMsgHesloX);
		return false;
	}

	return true;
}

/**
 * Formular pro odeslani zapom. hesla
 */
function checkPassForm(f)
{
	if (f.email && !f.email.value.match(reg_exp_email)) {
    f.email.focus();
    alert (texty.regMsgEmail);
		return false;
	}
	return true;
}
