var d=document;
var lastid=0,last={0:'',1:''};
function vyberClanek(el,kde){//based on http://citron.blueboard.cz/clanek-239-ajax-navod-pro-zacatecniky.html
if (last[0]==el||last[1]==el) return;
last[lastid] = el; lastid = (lastid + 1) % 2;
if(el!=0){
if(window.ActiveXObject){httpRequest=new ActiveXObject("Microsoft.XMLHTTP");}
else if(window.XMLHttpRequest){httpRequest=new XMLHttpRequest();}
httpRequest.open("GET",el,true);
httpRequest.onreadystatechange=function(){//or ? onreadystatechange
processRequest(kde,el);
};
httpRequest.send(null);}
else{kde.innerHTML="";}
}
function processRequest(kde,el){
if(httpRequest.readyState==4){
kde.innerHTML=httpRequest.responseText;
pocasi(el);
setTimeout("last[0]='';last[1]='';",1000);
FastInit.addOnLoad(mesto);
}}
function getId(id){return d.getElementById(id);}
var bT=[],rych=40;
function viz(fEl,idTo){//based on http://verens.com/archives/2005/12/21/dropbox-tracer/
var toEl=getId(idTo);
if(!toEl){return;}
var fW=fEl.parentNode.parentNode.offsetWidth,fH=fEl.parentNode.parentNode.offsetHeight,
fX=fEl.parentNode.parentNode.offsetLeft+(fW/2),
fY=fEl.parentNode.parentNode.offsetTop+(fH/2),toW=toEl.offsetWidth,toH=toEl.offsetHeight,toX=toEl.offsetLeft+(toW/2),toY=toEl.offsetTop+(toH/2);
var dis=Math.sqrt((fX-toX)*(fX-toX)+(fY-toY)*(fY-toY));
if(dis<5)return;
var id=bT.length;
bT[id]={x:fX,y:fY,width:fW,height:fH,opacity:.4,xRych:(toX-fX)/dis,yRych:(toY-fY)/dis,wRS:fW/dis,hRS:fH/dis,oRS:2/dis}
setTimeout("krok("+id+")",25);
}
function krok(id){
var el=getId('viz'+id);
if(!el){
el=d.createElement('div');
el.id='viz'+id;
el.style.zIndex='100000';
el.style.position='absolute';
el.style.marginTop='200px';
el.style.border='1px solid #fff';
var ims=getId('to').getAttribute('rel');
el.style.background='url(kraj/kraj'+ims+'.gif) #fff center center no-repeat';
el.style.height='0';el.style.width='0';
d.getElementsByTagName('body')[0].appendChild(el);
el.onclick=function(){
el.parentNode.removeChild(el);
getId('nazevkraje').removeChild(getId('nazevkraje').childNodes[0]);
getId('nazevkraje').parentNode.removeChild(getId('nazevkraje'));
settit();
getId('kraj').src='obrazky/kraj0.gif';
if (/WebKit/i.test(navigator.userAgent)) {
d.location.replace(d.location); //impossible to remove event in loaded xmlHTTPrequest in webkit, this is not well workaround, but it works, sorry
}
reset();
};
}
bT[id]['x']+=bT[id]['xRych']/rych;
bT[id]['y']+=bT[id]['yRych']/rych;
bT[id]['width']+=bT[id]['wRS']*rych;
bT[id]['height']+=bT[id]['hRS']*rych;
bT[id]['opacity']+=bT[id]['oRS']/2*rych;
if(bT[id]['width']<1&&bT[id]['height']<1){
bT[id]=null;
return;
}
el.style.opacity=bT[id]['opacity'];
el.style.filter='alpha(opacity='+(bT[id]['opacity']*100)+')';
el.style.width=parseInt(bT[id]['width'])/2+'px';
el.style.height=parseInt(bT[id]['height'])/2+'px';
el.style.top=parseInt(353+176-40-bT[id]['height']/2)*0.5+'px';
el.style.left=parseInt(getId('navi').parentNode.parentNode.parentNode.offsetLeft+44+bT[id]['x']-bT[id]['width']/4)+'px';
el.style.zIndex='10';
if(parseInt(el.style.width)<=600)
setTimeout("krok("+id+")",25);
co='xml/'+getId('to').getAttribute('href')+'.php?den='+den;
vyberClanek(co,el);
}
function removetit(){
  var arey = getId('navi').getElementsByTagName('area');
  for (var j = 0; j < arey.length; j++) {
  arey[j].removeAttribute('title');
  }
}
function settit(){
  var arey = getId('navi').getElementsByTagName('area');
  for (var k = 0; k < arey.length; k++) {
  arey[k].title=arey[k].getAttribute('alt');
  }
}
function extract() {
  var arey = getId('navi').getElementsByTagName('area');
  for (var i = 0; i < arey.length; i++) {
  arey[i].setAttribute('alt',arey[i].title);
      arey[i].onmouseover=function(){
              if(getId('kraj').src.indexOf('obrazky')!=-1){
              var popisek=this.getAttribute('title');
              var imgsrc=this.getAttribute('rel');
              x=getId('nazevkraje');
              x.appendChild(d.createTextNode(popisek));
              getId('kraj').src='obrazky/kraj'+imgsrc +'.gif';
              }
              }
      arey[i].onmouseout=function(){
              if(getId('kraj').src.indexOf('obrazky')!=-1){
              x=getId('nazevkraje');
              x.removeChild(x.childNodes[0]);
              getId('kraj').src='obrazky/kraj0.gif';
              }
              }
      arey[i].onclick=function(){
              x=getId('nazevkraje');
              if (x.childNodes.length>0) {
                  x.removeChild(x.childNodes[0]);
                  getId('to').focus();
              }
              if(getId('kraj').src.indexOf('obrazky')!=-1){
              var popisek=this.getAttribute('alt');
              var imgsrc=this.getAttribute('rel');
              var href=this.getAttribute('href').replace('http://pocasi.cr', '').replace('http://www.pocasi.cr', '').substr(1);
              getId('to').setAttribute('rel',imgsrc);
              getId('to').setAttribute('href',href);
              var x = d.createElement('span');
              x.className='popis';
              x.setAttribute('id','nazevkraje');
              this.parentNode.appendChild(x);
              x.appendChild(d.createTextNode(popisek));
              removetit();
              viz(this,'to');
              getId('kraj').src='negative/'+imgsrc +'.gif';
              return false;
              }
              else{
              settit();
              getId('kraj').src='obrazky/kraj0.gif';
              return false;
              }
              }
  }
}
function mesto(){
var mesto=getId('mesto').getElementsByTagName('area');
  for (var n=0;n<mesto.length;n++){
    mesto[n].onmouseover=function(){
      var href=this.getAttribute('href').replace('http://www.pocasi.cr', '').replace('http://pocasi.cr', '').substr(1);
      vyberClanek('xml/'+href+'.php?den='+den,getId('xml').parentNode.parentNode);
    }
  }
}
/*
*
* Copyright (c) 2007 Andrew Tetlaw
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* *
*
*
* FastInit
* http://tetlaw.id.au/view/javascript/fastinit
* Andrew Tetlaw
* Version 1.4.1 (2007-03-15)
* Based on:
* http://dean.edwards.name/weblog/2006/03/faster
* http://dean.edwards.name/weblog/2006/06/again/
* Help from:
* http://www.cherny.com/webdev/26/domloaded-object-literal-updated
*
*/
var FastInit = {
        onload : function() {
                if (FastInit.done) { return; }
                FastInit.done = true;
                for(var x = 0, al = FastInit.f.length; x < al; x++) {
                        FastInit.f[x]();
                }
        },
        addOnLoad : function() {
                var a = arguments;
                for(var x = 0, al = a.length; x < al; x++) {
                        if(typeof a[x] === 'function') {
                                if (FastInit.done ) {
                                        a[x]();
                                } else {
                                        FastInit.f.push(a[x]);
                                }
                        }
                }
        },
        listen : function() {
                if (/WebKit|khtml/i.test(navigator.userAgent)) {
                        FastInit.timer = setInterval(function() {
                                if (/loaded|complete/.test(d.readyState)) {
                                        clearInterval(FastInit.timer);
                                        delete FastInit.timer;
                                        FastInit.onload();
                                }}, 10);
                } else if (d.addEventListener) {
                        d.addEventListener('DOMContentLoaded', FastInit.onload, false);
                } else if(!FastInit.iew32) {
                        if(window.addEventListener) {
                                window.addEventListener('load', FastInit.onload, false);
                        } else if (window.attachEvent) {
                                return window.attachEvent('onload', FastInit.onload);
                        }
                }
        },
        f:[],done:false,timer:null,iew32:false
};
/*@cc_on @*/
/*@if (@_win32)
FastInit.iew32 = true;
document.write('<script id="__ie_onload" defer src="' + ((location.protocol == 'https:') ? '//0' : 'javascript:void(0)') + '"><\/script>');
document.getElementById('__ie_onload').onreadystatechange = function(){if (this.readyState == 'complete') { FastInit.onload(); }};
/*@end @*/
FastInit.listen();
FastInit.addOnLoad(extract)

