var timer,timer2,el,radek,submenu,vyska,logo,vyskaOkna,vyskaSloupku;

window.onload=function()
{
  el=getElement("submenu");
  if(window.getComputedStyle)
  {
    vyska=parseInt(window.getComputedStyle(el,null).getPropertyValue("height"));
  }
  else
  {
    vyska=parseInt(el.offsetHeight);
  }
  el.style.height="23px";


  //umístění loga
  logo=document.getElementById("logo");
  if(window.getComputedStyle)
  {
    vyskaSloupku=parseInt(window.getComputedStyle(getElement("okno"),null).getPropertyValue("height"));
  }
  else
  {
    vyskaSloupku=parseInt(getElement("okno").offsetHeight);
  }

	//antispam
	if(getElement("protispamu")){
		getElement("protispamu").style.display="none";
		getElement("AS").value="protispamu";
	}

  pozicuj();
  window.onscroll=pozicuj;
}
function pozicuj()
{
  //zjištění verze prohlížeče
  if(navigator.appName=="Microsoft Internet Explorer")
  {
    reg=new RegExp("MSIE [0-9]\.[0-9]");
    navigatorVerze=String(navigator.appVersion.match(reg));
    navigatorVerze=navigatorVerze.substring(5);
    navigatorVerze=parseInt(navigatorVerze);
    if(navigatorVerze<=6){var nav="ie6";}
    else{var nav="ie7";}
  }
  else {var nav="ff";}
  //posunutí loga
  switch(nav)
  {
    //IE 6
    case "ie6":
      var vyskaOkna=document.body.clientHeight;
      var pozice=vyskaSloupku-vyskaOkna-document.body.scrollTop+20+"px";
      break;
    //IE 7
    case "ie7":
      var vyskaOkna=document.documentElement.clientHeight;
      var pozice=vyskaSloupku-vyskaOkna-document.documentElement.scrollTop+20+"px";
      break;
    //ostatní
    default:
      var vyskaOkna=parseInt(window.innerHeight);
      var pozice=vyskaSloupku-vyskaOkna-window.pageYOffset+20+"px";

  }
  if(vyskaOkna<vyskaSloupku){logo.style.bottom=pozice;}
}

//funkce na získání elementu
function getElement(id){return document.getElementById(id);}

function otevri(){zvetsuj();}
function zavri(){zmensuj();}

function zvetsuj()
{
  clearTimeout(timer);
  clearTimeout(timer2);
  h=parseInt(el.style.height)+5;
  if(parseInt(el.style.height)>=vyska)
  {
    el.style.height=vyska+"px";
    return;
  }
  else {el.style.height=h+"px";}
  timer=setTimeout("zvetsuj()",10);
}
function zmensuj()
{
  clearTimeout(timer);
  clearTimeout(timer2);
  h=parseInt(el.style.height)-5;
  if(h<=23)
  {
    el.style.height="23px";
    return;
  }
  else{el.style.height=h+"px";}
  timer2=setTimeout("zmensuj()",10);
}
function stopPosun()
{
  clearTimeout(timer2);
  el.style.height=vyska+"px";
}



function mail(mail)
{
  location.href="mailto:"+mail.replace("(at)","@");
}


function kontroluj(el,event)
{
  if(event && el)
  {
    var text=el.value;
    text=parsuj(text);
    el.value=text;
  }
}

function parsuj(text)
{
  var vysledek="";var desetina=false;
  for(i=0;i<text.length;i++)
  {
    var pismeno=text.slice(i,i+1);
    if(((pismeno>=0 && pismeno<=9) || pismeno=="," || pismeno==".") && pismeno!=" ")
    {
      if(pismeno=="," || pismeno==".")
      {
        if(desetina) continue;
        pismeno=".";
        desetina=true;
      }
      vysledek+=""+pismeno;
    }
  }
  return vysledek;
}

function zmenJazyk(lang)
{
  var href=location.href;
  href=href.split(".");
  if(href.length>2)
  {
    var newHref="";
    for(i=0;i<(href.length-1);i++)
    {
      if(i==(href.length-2))
      {
        casti=href[i].split("_");
        href[i]="";
        for(j=0;j<casti.length;j++)
        {
          if(casti[j]=="en" || casti[j]=="de"){break;}
          href[i]+=casti[j]+"_";
        }
        href[i]=href[i].slice(0,href[i].length-1);
      }
      newHref+=href[i]+".";
    }
  }

  if(lang=="cz"){lang="";}
  else{lang="_"+lang;}
  if(href.length>2) {newHref=newHref.slice(0,newHref.length-1)+lang+"."+href[href.length-1];}
  else {var newHref="http://penzionbbs.eu/index"+lang+".php";}
  location.href=newHref;
  return false;
}
function odkaz(href)
{
  window.open(href);
  return false;
}
function nahoru()
{
  window.scrollTo(0,0);
  return false;
}
