function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 } 
}
window.onload = externalLinks;

function test(what) {
		return confirm(what);
	}

function zkontroluj_mail(theForm){
	if (theForm.email.value == "" || theForm.email.value.indexOf('@',1)== -1 || theForm.email.value.indexOf('.',2)==-1){
		alert("Prosím zadejte emailovou adresu.");
		theForm.email.focus();
		return false;
	}
return true;
}

function zkontroluj_prispevek(theForm){
	if (theForm.nazev.value == "" || theForm.nazev.value.length < 2){
		alert("Prosím zadejte název příspěvku.");
		theForm.nazev.focus();
		return false;
	}
	if (theForm.text.value == "" || theForm.text.value.length < 2){
		alert("Prosím zadejte text.");
		theForm.text.focus();
		return false;
	}

return true;
}


function zkontroluj_uzivatele(theForm){
	if (theForm.jmeno.value == "" || theForm.jmeno.value.length < 2){
		alert("Prosím zadejte jméno.");
		theForm.jmeno.focus();
		return false;
	}
	if (theForm.prijmeni.value == "" || theForm.prijmeni.value.length < 2){
		alert("Prosím zadejte příjmení.");
		theForm.prijmeni.focus();
		return false;
	}
	if (theForm.email.value == "" || theForm.email.value.indexOf('@',1)== -1 || theForm.email.value.indexOf('.',2)==-1){
		alert("Prosím zadejte emailovou adresu.");
		theForm.email.focus();
		return false;
	}
  if (theForm.kontrola.value != 2){
		alert("Prosím zadejte kontrolní součet.");
		theForm.kontrola.focus();
		return false;
	}
return true;
}

function zkontroluj_sympozium(theForm){
  if (theForm.prijmeni.value == "" || theForm.prijmeni.value.length < 2){
		alert("Prosím zadejte příjmení.");
		theForm.prijmeni.focus();
		return false;
	}
	if (theForm.jmeno.value == "" || theForm.jmeno.value.length < 2){
		alert("Prosím zadejte jméno.");
		theForm.jmeno.focus();
		return false;
	}
	if (theForm.subjekt.value == "" || theForm.subjekt.value.length < 2){
		alert("Prosím zadejte subjekt.");
		theForm.subjekt.focus();
		return false;
	}
	if (theForm.adresa.value == "" || theForm.adresa.value.length < 2){
		alert("Prosím zadejte adresu.");
		theForm.adresa.focus();
		return false;
	}
	if (theForm.telefon.value == "" || theForm.telefon.value.length < 2){
		alert("Prosím zadejte telefon.");
		theForm.telefon.focus();
		return false;
	}
	
	if (theForm.email.value == "" || theForm.email.value.indexOf('@',1)== -1 || theForm.email.value.indexOf('.',2)==-1){
		alert("Prosím zadejte emailovou adresu.");
		theForm.email.focus();
		return false;
	}
	if (theForm.ucast16.checked == false && theForm.ucast17.checked == false){
		alert("Prosím zašrtněte alespoň jeden den účasti.");
		theForm.ucast16.focus();
		return false;
	}
return true;
}

function zkontroluj_heslo(theForm){
	if (theForm.nove_heslo.value == "" || theForm.nove_heslo.value.length < 5){
		alert("Heslo je příliš krátké (minimum je 5 znaků).");
		theForm.nove_heslo.focus();
		return false;
	}
	if (theForm.potvrzeni_hesla.value == "" || theForm.potvrzeni_hesla.value.length < 5){
		alert("Heslo je příliš krátké (minimum je 5 znaků).");
		theForm.potvrzeni_hesla.focus();
		return false;
	}
return true;
}

function zkontroluj_heslo_index(theForm){
	if (theForm.password.value == "" || theForm.password.value.length < 5){
		alert("Heslo je příliš krátké (minimum je 5 znaků).");
		theForm.password.focus();
		return false;
	}
return true;
}

function zkontroluj_namet(theForm){
	if (theForm.predkladatel_nazev.value == "" || theForm.predkladatel_nazev.value.length < 2){
		alert("Prosím zadejte název předkladatele.");
		theForm.predkladatel_nazev.focus();
		return false;
	}
	if (theForm.predkladatel_adresa.value == "" || theForm.predkladatel_adresa.value.length < 2){
		alert("Prosím zadejte adresu.");
		theForm.predkladatel_adresa.focus();
		return false;
	}
	if (theForm.predkladatel_typ.value == ""){
		alert("Prosím zadejte typ předkladatele.");
		theForm.predkladatel_typ.focus();
		return false;
	}
	if (theForm.predkladatel_kontaktni_osoba.value == "" || theForm.predkladatel_kontaktni_osoba.value.length < 2){
		alert("Prosím zadejte kontaktní osobu.");
		theForm.predkladatel_kontaktni_osoba.focus();
		return false;
	}
	if (theForm.predkladatel_telefon.value == "" || theForm.predkladatel_telefon.value.length < 2){
		alert("Prosím zadejte telefon.");
		theForm.predkladatel_telefon.focus();
		return false;
	}
/*	if (theForm.predkladatel_zkusenosti_zadatele.value == "" || theForm.predkladatel_zkusenosti_zadatele.value.length < 2){
		alert("Prosím zadejte zkušenosti s realizací projektu.");
		theForm.predkladatel_zkusenosti_zadatele.focus();
		return false;
	}*/
	if (theForm.nazev_projektu_nazev.value == "" || theForm.nazev_projektu_nazev.value.length < 2){
		alert("Prosím zadejte název projektu.");
		theForm.nazev_projektu_nazev.focus();
		return false;
	}
	if (theForm.misto_realizace_projektu_misto.value == "" || theForm.misto_realizace_projektu_misto.value.length < 2){
		alert("Prosím zadejte místo realizace projektu.");
		theForm.misto_realizace_projektu_misto.focus();
		return false;
	}
	if (theForm.predpokladane_celkove_naklady.value == "" || (!parseInt(theForm.predpokladane_celkove_naklady.value))){
		alert("Prosím zadejte předpokládané celkové náklady.");
		theForm.predpokladane_celkove_naklady.focus();
		return false;
	}
	if (theForm.financni_ucast_tis.value == "" || (!parseInt(theForm.financni_ucast_tis.value))){
		alert("Prosím zadejte finanční účast.");
		theForm.financni_ucast_tis.focus();
		return false;
	}
return true;
}

function spocitej_financovani() 
{
	var cista, zaloha = 0;
	cista = parseInt(cista);
	zaloha = parseFloat(zaloha);
			
	//nacteni promennych
	obj_celkove_naklady = document.getElementById("predpokladane_celkove_naklady");
	celkove_naklady = obj_celkove_naklady.value;
	
	obj_financni_ucast_tis = document.getElementById("financni_ucast_tis");
	financni_ucast_tis = obj_financni_ucast_tis.value;
	
	if (celkove_naklady && financni_ucast_tis)
	{
		//procentualni financni ucast
		financni_ucast_procenta = financni_ucast_tis/celkove_naklady;
		financni_ucast_procenta = financni_ucast_procenta*100;
		financni_ucast_procenta = Math.round(financni_ucast_procenta*100);
		financni_ucast_procenta = financni_ucast_procenta/100;
		
		//financovani jinymi zdroji + procenta
		spolufinancovani_jine_zdroje_tis = celkove_naklady - financni_ucast_tis;
		spolufinancovani_jine_zdroje_procenta = 100 - financni_ucast_procenta;
		
		document.formular_nametu.financni_ucast_procenta.value = financni_ucast_procenta;
		document.formular_nametu.spolufinancovani_jine_zdroje_tis.value = spolufinancovani_jine_zdroje_tis;
		document.formular_nametu.spolufinancovani_jine_zdroje_procenta.value = spolufinancovani_jine_zdroje_procenta;
	}
}

function zkontroluj_select() 
{
	var delka = 0;
  var pocet = 0;
  var index = 0;
	delka = parseInt(delka);
	pocet = parseFloat(pocet);
	index = parseFloat(index);
			
	//nacteni promennych
	select = document.getElementById("opatreni[]");
	delka = select.length;
		for (i = 0; i < delka; i++)
	  {
	    if (select.options[i].selected) pocet++;
    }
  //pokud je pocet roven 3, nenecham jej zatrhnout dalsi
  if (pocet > 3)
  {
	   window.alert("Zatrhněte prosím maximálně 3 položky!");
     index = select.selectedIndex;
     select.options[index].selected = false;
     
	}
}


function openwin(url,name,width,height) 
{
	window.open(url,name,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,width="+width+",height="+height);
}

