obr1=new Image(); obr1.src="/img/loading.gif";


var te = 0;
var tee = 0;

  function LogoONint(){
    var img1 = document.getElementById('logo_color').style;
    var opac = (img1.opacity) ? parseFloat(img1.opacity) : '';
    if(img1.visibility!='visible'){
      img1.visibility='visible';
    }
    img1.opacity = opac + 0.1;
    img1.filter = 'alpha(opacity='+img1.opacity*100+')';
    if(parseFloat(img1.opacity) >= 1){
    clearInterval(te);
    }
  }
  function LogoOffint(){
    var img1 = document.getElementById('logo_color').style;
    var opac = (img1.opacity) ? parseFloat(img1.opacity) : '';
    if((Math.floor(img1.opacity*10)) <= 1){
      img1.visibility='hidden';
      clearInterval(tee);
    }
    img1.opacity = opac - 0.1;
    img1.filter = 'Alpha(Opacity='+img1.opacity*100+')';
  }
  
function LogoColor( stav ){

if(stav){
clearInterval(tee);
te = setInterval( "LogoONint()" , 35 );
} else {
clearInterval(te);
tee = setInterval( "LogoOffint()" , 35 );
}

/*
if(stav){
  img.style.visibility='visible';
  for(var i=0;i<=10;i++){
    LogoOn( img , i , i );
  }
} else {
  clearTimeout(te);
  for(var i=0;i<=10;i++){
    LogoOn( img , i , 10-i );
  }
}
*/

}

function ZverejneneDockumenty( id ){
var dokument1 = document.getElementById('dokument');
var td = dokument1.getElementsByTagName('td');
var tdcols = null;
var img = null;
for(var i=0;i<td.length;i++){
  if(td[i].colSpan>1){
    tdcols = document.getElementById(td[i].id);
    img = td[i].id;
    img = img.replace(/([^0-9]+)/ , "");
    img = document.getElementById('plus_' +img);
    if(td[i].id=='cols_'+id && !tdcols.innerHTML){
    AjaxGET1( "/include/detail_dokumenty.php" , td[i].id , '&ajax=true&id=' + id);
    img.src='/img/dok_minus.gif';
    } else {
    img.src='/img/dok_plus.gif';
    tdcols.innerHTML = '';
    }
  }
}

}

function Kontaktmapa( stav ){

  if(stav == 'show'){
    AjaxGET( "/include/kontakt_mapa.php" , 'kontakt' , '&ajax=true');
  } else {
    AjaxGET( "/pages/obec_kontakt.php" , 'kontakt' , '&ajax=true');
  }

}
function NacitajObrah( get ){

AjaxPOST( "/pages/navstevna.php" , "komentare" ,'&ajax=true'+get)
}


function PridatNavstev(){

var form=document.kniha;
var chyba=false;
var meno = form.meno.value;
var text = form.text.value;
var email = form.email.value;

if(!meno || !text){
return false;
}
if(email && !/([a-zA-Z0-9_\.-]+\@[a-zA-Z0-9_\.-]+\.[a-zA-Z0-9_\.-]+)/.test(email)){
alert("Zle zadaný E-mail");
form.email.focus();
return false;
}

  if(!chyba){
  NacitajObrah( '&strana=1&meno='+meno+'&text='+text+'&email='+email );
  form.reset();
  }
return false;
}

function in_array( what, where ){
	var a=false;
	for(var i=0;i<where.length;i++){
	  if(what == where[i]){
	    a=true;
        break;
	  }
	}
	return a;
}

function AktualityScroll( stav ){

var cislozobraz=new Array();

var div=document.getElementsByTagName('div');
var skryt = false;
var skryt2 = false;
var e=0;
var zobrazenych = 0;
for(var i=0;i<div.length;i++){
  if(div[i].className=="news_item"){

    if(div[i].style.display!='none'){
      cislozobraz[zobrazenych] = e;
      zobrazenych++;
    }
    e++;
  }
}
var pokr = true;
var cont = true;
for(var i=0;i<zobrazenych;i++){
  if(stav=='down'){

    if((cislozobraz[i]+zobrazenych) >= e && pokr){
      cont = false;
    }

    if(cont){
      pokr = false;
      cislozobraz[i] = cislozobraz[i]+1;
    }

  } else if(stav=='up'){
    if(cislozobraz[i]>0 && cont){
      cislozobraz[i] = cislozobraz[i]-1;
    } else {
      cont = false;
    }
  }
}

var p=0;
for(var i=0;i<div.length;i++){
  if(div[i].className=="news_item"){

    if(in_array( p , cislozobraz)){
      div[i].style.display = '';
    } else {
      div[i].style.display = 'none';
    }

  p++;
  }
}

var up=document.getElementById('aktuality_up').style;
var down=document.getElementById('aktuality_down').style;
if(cislozobraz[0]>0){
up.visibility='';
} else {
up.visibility='hidden';
}

if(cislozobraz[zobrazenych-1]+1 >= e){
down.visibility='hidden';
} else {
down.visibility='';
}

}

function AjaxGET1( subor , element , url1){

var xmlhttp=GetXmlHttpObject();
if (xmlhttp==null){
  alert ("Browser does not support HTTP Request");
  return;
  }


var url=subor + "?sid=" + Math.random() + url1;

xmlhttp.onreadystatechange=function(){

  if (xmlhttp.readyState==4 && xmlhttp.status==200){
    document.getElementById( element ).innerHTML=xmlhttp.responseText;
  }
}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}
function AjaxGET( subor , element , url1){

var xmlhttp=GetXmlHttpObject();
if (xmlhttp==null){
  alert ("Browser does not support HTTP Request");
  return;
  }


var url=subor + "?sid=" + Math.random() + url1;

xmlhttp.onreadystatechange=function(){

  if (xmlhttp.readyState==4 && xmlhttp.status==200){
    document.getElementById( element ).innerHTML=xmlhttp.responseText;
  } else {
    document.getElementById( element ).innerHTML='<div style="text-align: center;margin: 100px 0px;"><img src="/img/loading.gif"></div>';
  }
}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}

  var http_request = false;
function AjaxPOST( url , element , parameters){

      http_request = false;
      if (window.XMLHttpRequest) {
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {

            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }

      http_request.onreadystatechange = function() {

  if (http_request.readyState==4 && http_request.status==200){
    document.getElementById( element ).innerHTML=http_request.responseText;
  } else {
    document.getElementById( element ).innerHTML='<div style="text-align: center;margin: 100px 0px;"><img src="/img/loading.gif"></div>';
  }

   }

parameters = '?test=1' + parameters;

      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);

}



function GetXmlHttpObject(){
if (window.XMLHttpRequest){
  return new XMLHttpRequest();
  }
if (window.ActiveXObject){
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
