var ActiveMenu='';
var HiliteMenu='';
var	MenuTimer = null;
var	TimerStart = null;
var	TimerFlag = false;

function unescapeHTML(html) {
  var htmlNode = document.createElement("DIV");
  htmlNode.innerHTML = html;
  if(htmlNode.innerText)
    return htmlNode.innerText;// IE
  return htmlNode.textContent;// FF
}


function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function Kontrola(f) {
var vysledek = true;
var strerr = "";
if (f.jmeno.value=="") strerr += "Jméno\n";
if (f.text.value=="") strerr += "Text\n";
if (f.preposlat.checked && f.email.value=="") strerr += "E-mail\n";

if ("" != strerr) {
    alert("Vyplňte prosím:\n\n" + strerr);
	return false;
        }
var test = "^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$";
if(f.email.value && f.email.value!="" && f.email.value!="@") {
if (!(f.email.value.match(test))) {alert('Není vyplněna správná emailová adresa!!!');
 return false;
};}
}

function trim(string)
{
var re= /^\s*|\s*$/g;
return string.replace(re,"");
}

function check_email(f) {
var vysledek = true;
var strerr = "";
var email = trim(f.login.value);
var test = "^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$";
if (!(email.match(test)) && email.length!=6) {
	alert('Login je celá emailová adresa ve formátu jmeno@neco.cz .');
 return false;
}
return vysledek;
}

function zobrazSkryj_pos(idecko,action){
el=document.getElementById(idecko).style; 
if (action=='hide') el.display='none';
if (action=='show') {el.display='block';}
}

function zobrazSkryj_zmena(idecko){
	el=document.getElementById(idecko).style; 
	
	if (el.display=='none') { el.display='block'; return true}
	if (el.display=='block') {el.display='none'; return true}
}

function zobrazSkryj_pos_inline(idecko,action){
	el=document.getElementById(idecko).style; 
	if (action=='hide') el.display='none';
	if (action=='show') {el.display='inline';}
}

function select_kraj(id) {
if (id==349) {
MM_changeProp('country['+id+']','','checked','checked','INPUT/CHECKBOX');
} else {
MM_changeProp('kraj['+id+']','','checked','checked','INPUT/CHECKBOX');
}
}

function typ_upresnit_fce(id) 
 { 
 if (id.value==5)   zobrazSkryj_pos_inline('upresnit','show');
 else zobrazSkryj_pos_inline('upresnit','hide');
 
 }
 
 function potvrzeni(message){
if (!confirm(message)) return false;
}


function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function clearMyTimeout()
{
	if (MenuTimer) clearTimeout(MenuTimer);
	MenuTimer = null;
	TimerFlag = false;
}

function startMyTimeout(menuitem)
{
	TimerStart = new Date();
	TimerFlag = true;
	ActiveMenu = menuitem;
	MenuTimer = setTimeout("HideMenu()", 100);
}

function HideMenu()
{
	if (!TimerFlag) return;
	var elapsed = new Date() - TimerStart;
	if (elapsed < 1000) {
		HideMenuTimer = setTimeout("HideMenu()", 100-elapsed);
		return;
	}
	TimerFlag = false;
	MM_showHideLayers(ActiveMenu,'','hide', HiliteMenu,'','show');
	
}


function show_map_registrace(){
var ulice=document.getElementById('ulice').value; 
var mesto=document.getElementById('mesto').value; 
if (ulice) {
	if (mesto) {
		 MM_openBrWindow('http://mapy.seznam.cz/?query='+ulice+','+mesto,'mapa','');
		 } else {
		alert ('Vyplňte prosím město.');	
	return false;
		
	}
} else {
	alert ('Vyplňte prosím adresu zařízení.');	
	return false;
}
}

function change(id, toto) {
	x=document.getElementById(id);
	if (toto.className == 'li_plus'){
	       x.style.display="block";
        toto.className = 'li_minus';
        }
    else
    {
    x.style.display="none";
    toto.className = 'li_plus';
    }}
	
// Scrolling = 0;
  function ScrollWin(position) {
   // while(Scrolling != position) {
   // this.scroll(1,Scrolling)
   // Scrolling++;
   // }
  // window.location.hash="zalozky";


  }
  

function getElementsByClassName(oElm, strTagName, strClassName){
var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
	    var arrReturnElements = new Array();
	    strClassName = strClassName.replace(/\-/g, "\\-");
	    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	    var oElement;
	    for(var i=0; i<arrElements.length; i++){
	        oElement = arrElements[i];
	        if(oRegExp.test(oElement.className)){
	            arrReturnElements.push(oElement);
	        }
	    }
	    return (arrReturnElements)
	}


function hide_all_class(class_id) {
	var elements=getElementsByClassName(document,'div', class_id);
	
	if(elements.length) {
		for(i=0;i<elements.length;i++) 
		{
			elements[i].style.visibility='hidden';
		}
		
	}
}

function show_all_edit(class_id, action) {
	var elements=getElementsByClassName(document,'a', class_id);
	
	if(elements.length) {
		for(i=0;i<elements.length;i++) 
		{
			elements[i].style.display=action;
		}
		
	}
}

function ajaxAlert(originalRequest){
	window.alert(originalRequest);
}

function popUp(test) {
return;	
}

function change_popis (id, popis1, popis2) {
	var el =document.getElementById(id);
	var content = el.innerHTML;
	
	if (content==popis1) {
		el.innerHTML =popis2;
	}
	if (content==popis2) {
		el.innerHTML =popis1;
	}
	
}

function change_image (id, image1, image2, host) {
	var img = MM_findObj(id);
	
	image1 = 'http://'+host+image1;
	image2 = 'http://'+host+image2;
	//alert(img.src+' '+image1+' '+image2);
	if (img.src==image1) {img.src=image2; return true };
	if (img.src==image2) {img.src=image1; return true };
}



function setCookie (value, show_window) {
	var myCookie = Cookie.write('gmap1', value);
	if (show_window) {
		
	} else {
		var myCookie = Cookie.write('gmap2', value);
	}
}
function loadCookie (name) {
	var myCookie = Cookie.read(name);
	//alert(myCookie);
	return myCookie;
}
var my_all = 0;


function poslat_zpravu (id) {
	Shadowbox.open({
		content: 	'/index.php?page=zprava&only=yes&id='+id,
        player:     'iframe',
        height:     450,
        width:      380		
    });
    

	/*/index.php?page=zprava&amp;include=yes&amp;id={$detail.result.id}{if $post.session.logged_user_id}&amp;login=yes{/if}*/
}

function openNavi (odkaz) {

    Shadowbox.open({
        content:    unescapeHTML(odkaz),
        player:     "iframe",
        width:      885

    });
 }
 
function openMap (odkaz) {
    Shadowbox.open({
        content:    unescapeHTML(odkaz),
        title:      "",
        player:     "iframe",
        width:      800,
        height:     600
    });
     
}
 
function aktivuj_jazyk_char(active,char_id, allangs) {
 
  
  document.getElementById('text_'+char_id+'_'+active).style.visibility="visible";
  document.getElementById('click_'+char_id+'_'+active).style.backgroundColor="green";
  
  
  for (var i = 0; i < allangs.length; i++) {
    if (allangs[i] != active) {
      document.getElementById('text_'+char_id+'_'+allangs[i]).style.visibility="hidden";
      document.getElementById('click_'+char_id+'_'+allangs[i]).style.backgroundColor="white";
  
    }
  }
  
  
  
}

function newClassIE (id, newclass) {
document.getElementById(id).className=newclass;
}

function changeClass (change ,clear, class_name) {    
    var clear_array=$$(clear);
    
    //console.debug(change);
    
    clear_array.each(function (item, index) {
      item.removeClass('current');          
    });

    change.addClass('current');
}


/*Element.implement ({
  changeClass:function (clear, class_name) {    
    var clear_array=$$(clear);
    
    clear_array.each(function (item, index) {
      item.removeClass('current');          
    });

    this.addClass('current');
 
  }
})*/
 
  

