// JavaScript Document

function odeslatPrihlaseni() {
  //alert('fce odeslatPrihlaseni');
  if(document.getElementById('email').value == '') {
	  alert('Musí být vyplněn email');
	  return;
	}
	if(document.getElementById('heslo').value == '') {
	  alert('Musí být vyplněno heslo');
	  return;
	}
	//alert('úspěšně vyplněno');
	var formular = document.getElementById('prihlaseni');
	formular.action = 'obec_prihlaseni.php';
	//alert(prihlaseni.action);
	formular.submit();
}

function odeslatZmenaHesla() {
  //alert('fce odeslatZmenaHesla');
  if(document.getElementById('zmena_hesla_email').value == '') {
	  alert('Musí být vyplněn email.');
	  return;
	}
	if(document.getElementById('zmena_hesla_heslo').value == '') {
	  alert('Musí být vyplněno staré heslo.');
	  return;
	}
	if(document.getElementById('zmena_hesla_heslo_nove').value == '') {
	  alert('Musí být vyplněno nové heslo.');
	  return;
	}
	if(document.getElementById('zmena_hesla_heslo_nove2').value == '') {
	  alert('Musí být vyplněno opakování nového hesla.');
	  return;
	}
	if(document.getElementById('zmena_hesla_heslo_nove').value != document.getElementById('zmena_hesla_heslo_nove2').value) {
	  alert('Nové heslo a jeho opakování se neshodují.');
	  return;
	}
	//alert('úspěšně vyplněno');
	var formular = document.getElementById('zmena_hesla');
	formular.action = 'obec_zmena_hesla.php';
	//alert(prihlaseni.action);
	formular.submit();
}

function odeslatNoveHeslo() {
  //alert('fce odeslatNoveHeslo');
  if(document.getElementById('nove_heslo_email').value == '') {
	  alert('Musí být vyplněn email.');
	  return;
	}
	var formular = document.getElementById('nove_heslo');
	formular.action = 'obec_nove_heslo.php';
	//alert(prihlaseni.action);
	formular.submit();
}

function refreshParentWin() {
  //alert(window.opener.location.href);
  window.opener.location.reload(); 
}

function windowOpener(url, typokna) {
  if(typokna = 'registrace') {
    var retValue=true;
    msgWindowregistrace=window.open(url,"displayWindow",'height=80, width=220,top=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0,titlebar=0');
    if (msgWindowregistrace==null || typeof(msgWindowregistrace)=="undefined")
      retValue=false;
    else
    {
      msgWindowregistrace.moveTo(300,300);
      msgWindowregistrace.focus();
    }
    return retValue;
  }
  
  if(typokna = 'prihlaseni') {
    var retValue=true;
    msgWindowprihlaseni=window.open(url,"displayWindow",'height=80, width=220,top=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0,titlebar=0');
    if (msgWindowprihlaseni==null || typeof(msgWindowprihlaseni)=="undefined")
      retValue=false;
    else
    {
      msgWindowprihlaseni.moveTo(300,300);
      msgWindowprihlaseni.focus();
    }
    return retValue;
  }
  
  if(typokna = 'pokroc_hledani') {
    var retValue=true;
    msgWindowpokroc_hledani=window.open(url,"displayWindow",'height=80, width=220,top=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0,titlebar=0');
    if (msgWindowpokroc_hledani==null || typeof(msgWindowpokroc_hledani)=="undefined")
      retValue=false;
    else
    {
      msgWindowpokroc_hledani.moveTo(300,300);
      msgWindowpokroc_hledani.focus();
    }
    return retValue;
  }
  
  if(typokna = 'zmena_hesla') {
    var retValue=true;
    msgWindowzmena_hesla=window.open(url,"displayWindow",'height=80, width=220,top=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0,titlebar=0');
    if (msgWindowzmena_hesla==null || typeof(msgWindowzmena_hesla)=="undefined")
      retValue=false;
    else
    {
      msgWindowzmena_hesla.moveTo(300,300);
      msgWindowzmena_hesla.focus();
    }
    return retValue;
  }
}

function odeslatRegistraciInsert() {
  //alert('fce odeslatRegistraci');
  if(document.getElementById('in_email').value == '') {
	  alert('Musí být vyplněn email.');
	  return;
	}
  if(document.getElementById('in_prijmeni').value == '') {
	  alert('Musí být vyplněno příjmení.');
	  return;
	}
	if(document.getElementById('in_zobrazovane_jmeno').value == '') {
	  alert('Musí být vyplněno zobrazované jméno.');
	  return;
	}
	if(document.getElementById('in_heslo').value == '') {
	  alert('Musí být vyplněno heslo.');
	  return;
	}
	if(document.getElementById('in_heslo2').value == '') {
	  alert('Musí být vyplněno opakování hesla.');
	  return;
	}
	if(document.getElementById('in_heslo').value != document.getElementById('in_heslo2').value) {
	  alert('Heslo a opakování hesla se neshoduje!');
	  return;
	}
	//alert('úspěšně vyplněno');
	var formular = document.getElementById('registrace');
	//alert(formular.action);
	formular.action = 'obec_registrace.php';
	//alert(formular.action);
	formular.submit();
}

function odeslatRegistraciUpdate() {
  //alert('fce odeslatRegistraci');
  if(document.getElementById('in_email').value == '') {
	  alert('Musí být vyplněn email.');
	  return;
	}
  if(document.getElementById('in_prijmeni').value == '') {
	  alert('Musí být vyplněno příjmení.');
	  return;
	}
	if(document.getElementById('in_zobrazovane_jmeno').value == '') {
	  alert('Musí být vyplněno zobrazované jméno.');
	  return;
	}
	//alert('úspěšně vyplněno');
	var formular = document.getElementById('registrace');
	//alert(formular.action);
	formular.action = 'obec_registrace.php';
	//alert(formular.action);
	formular.submit();
}






