function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) return true;
    else return false;
}

//otevirani okna
function nastav_select(nazev, hodnota) {
  var prvek;
  eval('prvek=document.forms[0].'+nazev);
  for (i=0; i<prvek.options.length; i++) {
    if ( prvek.options[i].value == hodnota ) {
      prvek.options[i].selected = true
    } else { 
      prvek.options[i].selected = false 
    }
  }
}   


function modul(adresa, jmeno, s,v) {
    var w;
//    skript=<?php echo $_SERVER{'SCRIPT_NAME'};?>;
    w = open(adresa, jmeno, "Scrollbars=1,resizable=1,width="+s+",height="+v);
    if (w) {
      l = 20;
      if (screen.width>s) { l = (screen.width-s)/2; }
      h = 20;
      if (screen.height>(v+20)) { h = (screen.height-(v+20))/2; }
      w.moveTo(l,h);
      if (w.opener == null)
      w.opener = self;
      w.focus();
    }
}

function zavri() {
  if (window.opener != null) { 
		window.opener.location.reload(); 
		window.opener.focus(); 
		window.close(); 
  } else {
//    history.back(); 
//    location.href="$SCRIPT_NAME" + newloc;
    window.location.reload(); 
	}
}

function opener_reload() {
  if (window.opener != null) {
	window.opener.location.reload();
	window.opener.focus();
  }
}
		
function wciselnik(nazev,klic,typ,hodnota) {
  var w; 
  s=350;
  v=400;
  w = open('/sprava/handler.php?akce=ciselnik&nazev='+nazev+'&klic='+klic+'&typ='+typ+'&hodnota='+hodnota, 'cis'+nazev, "Scrollbars=1,resizable=1,width="+s+",height="+v);
  if (w) {
    l = 20;
    if (screen.width>s) { l = (screen.width-s)/2; }
    h = 20;
    if (screen.height>(v+20)) { h = (screen.height-(v+20))/2; }
    w.moveTo(l,h);
    if (w.opener == null) {
      w.opener = self;
      w.focus();
    }
  }
}

//vraceni hodnoty z ciselniku
function vrathodnotu(id, text, klic) {
   if (opener.document.getElementById(klic)) {opener.document.getElementById(klic).value=id;}
   if (opener.document.getElementById(klic+'_text')) {opener.document.getElementById(klic+'_text').value=text;} 
   window.opener.focus();
   window.close();
}


