   function get_value(elem) {
   	var Box = document.getElementById(elem);
   	if(Box.selectedIndex >= 0)
	   	return Box.options[Box.selectedIndex].value;
   }
   function get_name(elem) {
   	var Box = document.getElementById(elem);
   	if(Box.selectedIndex >= 0)
	   	return Box.options[Box.selectedIndex].text;
   }
   function get_value_i(elem) {
	return document.getElementById(elem).value;
   }
	function gebi(id) {
		return document.getElementById(id);
	}


///////////////////////////
// string replacer       //
///////////////////////////	
// by http://developer.irt.org/script/771.htm	
function wmReplace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += wmReplace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}
/*var mytext = 'wm-xXyY';
window.alert(mytext);
var myresult = wmReplace(mytext,'wm','');
window.alert(myresult);
*/

///////////////////////////
// MultiCategory Select  //
///////////////////////////	
	/*
	 *
	 *  ( c) 1993-2005 by United Association of Miloushs | Department of InformatiX :: sQuirrel.NET
	 *   Modified by wm  | 2005
 	 *
	 */
function AddCategory(list) {
     var listname = list;
     list = document.getElementById(list);
      if (list.options[list.selectedIndex].value=="invalid") return;

      category = list.options[list.selectedIndex].text;
      category = category.substring(category.lastIndexOf("- ")+4); // bud lastIndexOf(" ")+1);
var odstavce = document.getElementById('divCategory-' + listname);
var prvni_odstavec_text;
if(odstavce.firstChild) {
prvni_odstavec_text = odstavce.firstChild.nodeValue;
} else {
prvni_odstavec_text = 'nic';
}

  if (document.getElementById('divCategory-' + listname).innerHTML.indexOf(category)>-1) return;

 if(prvni_odstavec_text=='(žádná sekce)' || prvni_odstavec_text=='(no section)' || prvni_odstavec_text=='(---------)') {
document.getElementById('divCategory-' + listname).innerHTML='';
}
 	  document.getElementById('divCategory-' + listname).innerHTML += category.fontcolor("blue") + " <a href=\"javascript:RemoveCategory('" + list.selectedIndex + "', '" + listname + "');\"><font color=red>(odebrat)</font></a><br>";
 	  document.getElementById('hidCategory-' + listname).value += list.options[list.selectedIndex].value + ";";
 	   } 

     function RemoveCategory(id,list) {
     var	 listname = list;

      category = document.getElementById(listname).options[parseInt(id)].text;
      category = category.substring(category.lastIndexOf("- ")+4);
      divHTML =	document.getElementById('divCategory-' + listname).innerHTML;
      found = divHTML.indexOf(category);
      DelStart = divHTML.substring(0,found).toUpperCase().lastIndexOf("<BR>")+4;
      if (DelStart<4) DelStart=0;
      DelEnd = divHTML.substring(found).toUpperCase().indexOf("<BR>")+4+found;
	  document.getElementById('divCategory-' + listname).innerHTML = divHTML.replace(divHTML.substring(DelStart,DelEnd),"");
	  document.getElementById('hidCategory-' + listname).value = document.getElementById('hidCategory-' + listname).value.replace(document.getElementById(listname).options[parseInt(id)].value + ";","");


var odstavce = document.getElementById('divCategory-' + listname);
var prvni_odstavec_text;
if(odstavce.firstChild) {
prvni_odstavec_text = odstavce.firstChild.nodeValue;
} else {
//document.getElementById('divCategory-' + listname).innerHTML = '(žádná sekce)';
document.getElementById('divCategory-' + listname).innerHTML = '(---------)';

}



}

     function wmRemoveCategory(id,list, name) {
     var	 listname = list;
    // window.alert(listname);
      divHTML =	document.getElementById('divCategory-' + listname).innerHTML;
    //  window.alert(divHTML);
     //a = divHTML.indexOf(name);
  //   b = divHTML.indexOf('<br>')+4; //.indexOf(category));
      found = divHTML.indexOf(name);
       DelStart = divHTML.substring(0,found).toUpperCase().lastIndexOf("<BR>")+4;
      if (DelStart<4) DelStart=0;
      DelEnd = divHTML.substring(found).toUpperCase().indexOf("<BR>")+4+found;
	  document.getElementById('divCategory-' + listname).innerHTML = divHTML.replace(divHTML.substring(DelStart,DelEnd),"");
//document.getElementById('divCategory-' + listname).innerHTML = divHTML.replace(divHTML.substring(a,b),"");
//	 document.getElementById('hidCategory-' + listname).value = document.getElementById('hidCategory-' + listname).value.replace(document.getElementById(listname).options[parseInt(id)].value + ";","");
	  document.getElementById('hidCategory-' + listname).value = wmReplace(document.getElementById('hidCategory-' + listname).value,id + ";",'');

var odstavce = document.getElementById('divCategory-' + listname);

var prvni_odstavec_text;
if(odstavce.firstChild) {
prvni_odstavec_text = odstavce.firstChild.nodeValue;
//window.alert('"'+odstavce.innerHTML+'"');
//if(odstavce.innerHTML=='') document.getElementById('divCategory-' + listname).innerHTML = '(---------)';
} else {
//document.getElementById('divCategory-' + listname).innerHTML = '(žádná sekce)';
document.getElementById('divCategory-' + listname).innerHTML = '(---------)';
}

}
///////////////////////////
//      Tabbed menu      //
///////////////////////////	

/***********************************************
* DD Tab Menu script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function expandcontent(cid, aobject){
if (document.getElementById){
highlighttab(aobject)
if (previoustab!="")
document.getElementById(previoustab).style.display="none"
document.getElementById(cid).style.display="block"
previoustab=cid
}
}
function highlighttab(aobject){
if (typeof tabobjlinks=="undefined")
collecttablinks()
for (i=0; i<tabobjlinks.length; i++)
tabobjlinks[i].className=""
aobject.className="current"
}

function collecttablinks(){
var tabobj=document.getElementById("tablist")
tabobjlinks=tabobj.getElementsByTagName("A")
}

function do_onload(){
collecttablinks()
expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1])
}
	
///////////////////////////
//      confirm link     //
///////////////////////////		
	
	function confirmSubmit(id,name,type,url)
{
var agree=confirm("Opravdu smazat " +  name + "?");
if (agree)
 if(type=='SCH') {
 	location.href='?p=deleteschool&id=' + id + '&url=' + url
 } else {
	location.href='?p=deleteitem&type=' + type + '&id=' + id + '&url=' + url
 }
else
	return false ;
}

	function confirmSubmitOwn(url,hlaska)
{
var agree=confirm(hlaska);
if (agree)
 	location.href=url;
else
	return false ;
}

function CheckSection(form,field,souhlas)
{
	if (document.getElementById(field).value == "") { 
		window.alert("Prosím zařaďte alespoň do jedné sekce"); 
		return false;
	}
	
	if(souhlas==1) {
		if(form.Licence.checked) { }  else {
			licc = window.confirm("Pro vložení položky je třeba odsouhlasit licenční podmínky. Souhlasíte s nimi?"); 
			if(licc) {
				form.Licence.checked=true;
				return true;
			} else {
				return false;
			}
		}
	}
}

 function toogle(sName)
 {
  divName = document.getElementById("div_"+sName);
  imgName = document.getElementById("img_"+sName);
  if (divName.style.display=="block")
  {
    divName.style.display="none";
    imgName.src="images/catDown.png";
  }
  else
  {
    divName	.style.display="block";
    imgName.src="images/catUp.png";
  }
 }
 
 
var dstY = 173, srcY = 0;
function scrollFlips()
{

 if (document.body.scrollTop < 153) 
   dstY = 173;
 else
   dstY = document.body.scrollTop + 20;
 if (div_Flips.style.posTop != dstY) AdjFlips(1);
}
function AdjFlips(x)
{
 if (x==1) {if (srcY!=0) return; else srcY = div_Flips.style.posTop;}
 x = 1000*Math.pow(x/1000,0.8);
 if (x>=999) {div_Flips.style.top = dstY; srcY = 0;}
 else
 {
   div_Flips.style.top = srcY+(dstY-srcY)/1000*x;
   window.setTimeout("AdjFlips("+x+")",15);
 }
}

function CheckSkoleni (form) {
		if(form.NameFirst.value=='' || form.NameLast.value=='' || form.SchoolName.value=='' || form.SchoolCity.value=='' || form.SchoolStreet.value==''  || form.SchoolPSC.value=='' || form.da_nar.value=='') { 
			window.alert("Je třeba vyplnit všechny položky"); 
			return false;
		} else {
			var x = form.Mail.value;
			var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if (filter.test(x)) {
				return validatePasswords(form);
			} else { 
				window.alert("Neplatná e-mailová adresa"); 
				return false;
			}
		}

}

function CheckReg(form)
{
	
//document.form.finish.disabled=false;
		
		if(form.Licence.checked) { 
			if(form.NameFirst.value=='' || form.NameLast.value=='') { 
				window.alert("Je třeba vyplnit všechny položky"); 
				return false;
			}
		}  else {
			//licc = window.confirm("Pro dokončení registrace je třeba souhlasit s licenčními podmínkami"); 
			window.alert("Pro dokončení registrace je třeba souhlasit s licenčními podmínkami"); 
		//	if(licc) {
			//	form.Licence.checked=true;
			//	return true;
		//	} else {
				return false;
		//	}
		}
}

function CheckF(form,lic)
{
	
//document.form.finish.disabled=false;
		
//		if(step==1) {
		
		if(form.SchoolName.value=='' || form.Street.value=='' || form.NameFirst.value=='' || form.NameLast.value=='' || form.City.value=='' || form.HeadMaster.value=='') { 
			window.alert("Je třeba vyplnit všechny položky"); 
			return false;
		} else {
			var x = form.Mail.value;
			var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if (filter.test(x)) {
				if(lic==1) {
					return CheckReg(form);
				}
			} else { 
				window.alert("Neplatná e-mailová adresa"); 
				return false;
			}
		}
}


function checkMail(form,lic)
{
	var x = form.Mail.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) {
		if(lic==1) {
			return CheckReg(form);
		}
	} 	else { 
		window.alert("Neplatná e-mailová adresa"); 
		return false;
	}
}


function denyReg(id)
{
x = prompt("Důvod zamítnutí:");
if(x) {
location.href='?p=overeni&a=N&id=' + id + '&reason=' + x + ''
}
}


function confirmSecSubmit(id,name)
{
var agree=confirm("Smazat sekci " +  name + "?");
if (agree)
	location.href='?p=manage&akce=delsec&id=' + id + ''
else
	return false ;
}

function confirmUserDel(name,id)
{
var agree=confirm("Smazat uživatele " +  name + "?");
if (agree) {
	location.href='?p=deleteuser&id=' + id + ''
} else {
//	return false ;
	}
}


var Fokus;
	function OpenJSWindow(url, jmeno, w, h)
	{
	Fokus = window.open(url, jmeno,'scrollbars=1,resizable=0,top=20,left=20,menubar=0,width=' + w + ',height=' + h);
	Fokus.focus()

  if (!Fokus.opener)
    Fokus.opener = self;
	}
	
	
	function Hide() {
		document.getElementById('SubMenu').style.visibility='hidden';
	}
	
function validatePasswords(form) {
    if (form.P1.value != '' && form.P2.value != '' && form.P1.value == form.P2.value) {
        return true;
    }
    else {
        alert('Hesla se neshodují');
        form.P1.focus();
        return false;
    }
}

function CheckUserReg(form) {
	if(bad_mail) {window.alert("Zkontrolujte, prosím, vyplněný mail.");  return false; }
	if(bad_name) {window.alert("Zkontrolujte zadané přihlašovací jméno.");  return false; }
	
	var x = form.UserMail.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) {
		if(form.Licence.checked) { 
			if(form.UserName.value=='' || form.UserLast.value=='') { 
				window.alert("Je třeba vyplnit všechny položky"); 
				return false;
			} else {
				return validatePasswords(form);
			}
		}  else {
			window.alert("Pro dokončení registrace je třeba souhlasit s licenčními podmínkami"); 
			return false;
		}
	} 	else { 
		window.alert("Neplatná e-mailová adresa"); 
		return false;
	}
}


/*
 * Div popuper
 * ( c ) idea from libimseti.cz
 */
/*
	var IE = document.all?true:false
	if (!IE) document.captureEvents(Event.MOUSEMOVE)
	document.onmousemove = getMouseXY;
	var tempX = 0
	var tempY = 0

	function getMouseXY(e) {
	  if (IE) { // grab the x-y pos.s if browser is IE
	      tempX = event.clientX + document.body.scrollLeft;
	      tempY = event.clientY + document.body.scrollTop;
     } else {  // grab the x-y pos.s if browser is NS
          tempX = e.pageX;
	      tempY = e.pageY;
	 }
	 // catch possible negative values in NS4
	 if (tempX < 0){tempX = 0}
	 if (tempY < 0){tempY = 0}  
	 // show the position values in the form named Show
	 // in the text fields named MouseX and MouseY
	 return true
}
*/
//saple use userPopup('boy', this, '050517/8e68367979.jpg','ma1277006');
function userPopup (title,el,imgurl,obj_id) {
	document.getElementById('viz').style.top = (el.offsetTop+25- 10 )+'px';
	mouse_pos = (el.offsetTop+25- 10);
	div_hg = document.body.clientHeight - 20;
	layer_hg = 100;
	if ( (mouse_pos+layer_hg)>(div_hg)) {
		document.getElementById('viz').style.top = (mouse_pos - 70)
	} 
	if ((mouse_pos - 70)<=0)
	{
		document.getElementById('viz').style.top = 5;
	}
	
// Do something with this information	
w = document.body.clientWidth;
		document.getElementById('viz').style.left = (tempX+10) +'px';
		document.getElementById('viz').style.top = (tempY+5) +'px';


	viz_data = document.getElementById('viz')

	data = "<b>" +title+ "<br><img src=" + imgurl + " border=0><br>";

	viz_data.innerHTML = data;

	viz_data.style.display = 'block';

    popup_nick=title;
}
/*
 *  / Div popuper
 */
 
 function isCzech(item) {
 	selectValue = item.options[item.selectedIndex].value;
 	if(selectValue == 65)
 		document.getElementById('AreaRow').style.display="block";
 	else
 		document.getElementById('AreaRow').style.display="none";
 }
 
 	function activateField(item) {
		selectValue = item.options[item.selectedIndex].value;
			switch(selectValue) {
				case '1': //cz
					document.getElementById('ShowCZ').style.display="";
					document.getElementById('ShowEN').style.display="none";
				break;
				case '2': //en
					document.getElementById('ShowCZ').style.display="none";
					document.getElementById('ShowEN').style.display="";
				break;
				case '999': //both
					document.getElementById('ShowCZ').style.display="";
					document.getElementById('ShowEN').style.display="";
				break;
			} //en
	}