//skryje vsechny divy krome aktualniho
function zavriVse(id) {
  for(i=1;i<=10;i++) {
    if(jQuery("#popisMistnosti"+i).is(":visible")) {

      jQuery("#popisMistnosti"+i).slideUp();
    }
  }
}

/*------------ ANKETA -------------------------------------*/
  function hlasuj(id,hlas) {    
    if (window.ActiveXObject) {
      try {
        httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
      }
    }
    else
      {
        httpRequest = new XMLHttpRequest();
    }
    httpRequest.onreadystatechange= function () {zpracovat(id,hlas,httpRequest); } ;
    httpRequest.open("GET", "hlasovat.php?anketa="+id+"&hlas="+hlas, true);
    httpRequest.send(null);
  }
  
  function zpracovat(id,hlas,httpRequest) {
    if(httpRequest.readyState == 1 || httpRequest.readyState == 2 || httpRequest.readyState == 3) {
      document.getElementById("cekacka").innerHTML="<img src='img/loader.gif' alt='' />";
    }
    else if (httpRequest.readyState == 4)
    {
      if(httpRequest.status == 200) {
        document.getElementById("pocet"+hlas).innerHTML++;
        document.getElementById("cekacka").innerHTML="<img src='../img/loader.gif' alt='' />";
        
        //znemoznime hlasovani smazanim odkazu
        for (var key in document.getElementById('t-anketa').getElementsByTagName('td')) {
          var val = document.getElementById("t-anketa").getElementsByTagName('td')[key];
          if(val.className=='popis') {
            val.innerHTML = val.firstChild.innerHTML;
          }
        }
        
        //aktualizuji odpovedi
        var odpovedi = httpRequest.responseXML.getElementsByTagName('odpoved');
        var procenta = httpRequest.responseXML.getElementsByTagName('procenta');
        var delka = httpRequest.responseXML.getElementsByTagName('delka');
        for(var i=0; i < odpovedi.length; i++) {
          document.getElementById(odpovedi[i].getAttribute('id')).innerHTML = odpovedi[i].firstChild.data;
        }
        for(var i=0; i < procenta.length; i++) {
          document.getElementById(procenta[i].getAttribute('id')).innerHTML = procenta[i].firstChild.data+"%";
          document.getElementById(delka[i].getAttribute('id')).width=delka[i].firstChild.data;
        }
        document.getElementById("cekacka").innerHTML="";
      }
      else {
        alert("Chyba pri nacitani stanky "+ httpRequest.status);
      }
    }
  }

/****Jquery****/
jQuery.noConflict(); 
jQuery(document).ready(function() {
		  jQuery('#sipka').click(function(){
          jQuery('html, body').animate({scrollTop:0}, 'slow');
      });
      

		    jQuery("#popisArea1").hide();
		    jQuery("#popisMistnosti1").hide();
		    jQuery("#popisArea2").hide();
		    jQuery("#popisMistnosti2").hide();
		    jQuery("#popisArea3").hide();
		    jQuery("#popisMistnosti3").hide();
		    jQuery("#popisArea4").hide();
		    jQuery("#popisMistnosti4").hide();
		    jQuery("#popisArea5").hide();
		    jQuery("#popisMistnosti5").hide();
		    jQuery("#popisArea6").hide();
		    jQuery("#popisMistnosti6").hide();
		    jQuery("#popisArea7").hide();
		    jQuery("#popisMistnosti7").hide();
		    jQuery("#popisArea8").hide();
		    jQuery("#popisMistnosti8").hide();
		    jQuery("#popisArea9").hide();
		    jQuery("#popisMistnosti9").hide();
		    jQuery("#popisArea10").hide();
		    jQuery("#popisMistnosti10").hide();

      
      jQuery(".navod").hide();
      
      jQuery('.map').maphilight();
		  
		  jQuery("#area1").mouseover(function() {
        jQuery("#popisArea1").show();
      });
      jQuery("#area2").mouseover(function() {
        jQuery("#popisArea2").show();
      });
      jQuery("#area3").mouseover(function() {
        jQuery("#popisArea3").show();
      });
      jQuery("#area4").mouseover(function() {
        jQuery("#popisArea4").show();
      });
      jQuery("#area5").mouseover(function() {
        jQuery("#popisArea5").show();
      });
      jQuery("#area6").mouseover(function() {
        jQuery("#popisArea6").show();
      });
      jQuery("#area7").mouseover(function() {
        jQuery("#popisArea7").show();
      });
      jQuery("#area8").mouseover(function() {
        jQuery("#popisArea8").show();
      });
      jQuery("#area9").mouseover(function() {
        jQuery("#popisArea9").show();
      });
      jQuery("#area10").mouseover(function() {
        jQuery("#popisArea10").show();
      });
      
      
      jQuery("#area1").mouseout(function() {
        jQuery("#popisArea1").hide();
      });
      jQuery("#area2").mouseout(function() {
        jQuery("#popisArea2").hide();
      });
      jQuery("#area3").mouseout(function() {
        jQuery("#popisArea3").hide();
      });
      jQuery("#area4").mouseout(function() {
        jQuery("#popisArea4").hide();
      });
      jQuery("#area5").mouseout(function() {
        jQuery("#popisArea5").hide();
      });
      jQuery("#area6").mouseout(function() {
        jQuery("#popisArea6").hide();
      });
      jQuery("#area7").mouseout(function() {
        jQuery("#popisArea7").hide();
      });
      jQuery("#area8").mouseout(function() {
        jQuery("#popisArea8").hide();
      });
      jQuery("#area9").mouseout(function() {
        jQuery("#popisArea9").hide();
      });
      jQuery("#area10").mouseout(function() {
        jQuery("#popisArea10").hide();
      });
      
      jQuery("#area1").click(function() {
        zavriVse("1");
        jQuery("#popisMistnosti").slideUp( function(){ 
          jQuery("#popisMistnosti1").toggle(function(){
            jQuery('html, body').animate({scrollTop:800}, 'slow');
          });
        });
      });
      jQuery("#area2").click(function() {
        zavriVse("2");
        jQuery("#popisMistnosti").slideUp( function(){ 
          jQuery("#popisMistnosti2").toggle(function(){
            jQuery('html, body').animate({scrollTop:800}, 'slow');
          });
        });
      });
      jQuery("#area3").click(function() {
        zavriVse("3");
        jQuery("#popisMistnosti").slideUp( function(){ 
          jQuery("#popisMistnosti3").toggle(function(){
            jQuery('html, body').animate({scrollTop:800}, 'slow');
          });
        });
      });
      jQuery("#area4").click(function() {
        zavriVse("4");
        jQuery("#popisMistnosti").slideUp( function(){ 
          jQuery("#popisMistnosti4").toggle(function(){
            jQuery('html, body').animate({scrollTop:800}, 'slow');
          });
        });
      });
      jQuery("#area5").click(function() {
        zavriVse("5");
        jQuery("#popisMistnosti").slideUp( function(){ 
          jQuery("#popisMistnosti5").toggle(function(){
            jQuery('html, body').animate({scrollTop:800}, 'slow');
          });
        });
      });
      jQuery("#area6").click(function() {
        zavriVse("6");
        jQuery("#popisMistnosti").slideUp( function(){ 
          jQuery("#popisMistnosti6").toggle(function(){
            jQuery('html, body').animate({scrollTop:800}, 'slow');
          });
        });
      });
      jQuery("#area7").click(function() {
        zavriVse("7");
        jQuery("#popisMistnosti").slideUp( function(){ 
          jQuery("#popisMistnosti7").toggle(function(){
            jQuery('html, body').animate({scrollTop:800}, 'slow');
          });
        });
      });
      jQuery("#area8").click(function() {
        zavriVse("8");
        jQuery("#popisMistnosti").slideUp( function(){ 
          jQuery("#popisMistnosti8").toggle(function(){
            jQuery('html, body').animate({scrollTop:800}, 'slow');
          });
        });
      });
      jQuery("#area9").click(function() {
        zavriVse("9");
        jQuery("#popisMistnosti").slideUp( function(){ 
          jQuery("#popisMistnosti9").toggle(function(){
            jQuery('html, body').animate({scrollTop:800}, 'slow');
          });
        });
      });
      jQuery("#area10").click(function() {
        zavriVse("10");
        jQuery("#popisMistnosti").slideUp( function(){ 
          jQuery("#popisMistnosti10").toggle(function(){
            jQuery('html, body').animate({scrollTop:800}, 'slow');
          });
        });
      });
		  
      jQuery("a.akce").fancybox({ 'zoomSpeedIn': 300, 
                           'padding': 0,
                           'frameWidth' : 640,
	                         'frameHeight' : 480,
                           'zoomSpeedOut': 300, 
                           'overlayOpacity'	:	0.1,
                           'hideOnContentClick': true,
                           'overlayShow': true });
			
      jQuery("a.gal").fancybox({ 'zoomSpeedIn': 300, 
                           'padding': 10,
                           'frameWidth' : 640,
	                         'frameHeight' : 480,
                           'zoomSpeedOut': 300, 
                           'overlayOpacity'	:	0.1,
                           'hideOnContentClick': true,
                           'overlayShow': true });

      jQuery("#autostart").fancybox({ 'zoomSpeedIn': 300, 
                           'padding': 0,
                           'frameWidth' : 640,
	                         'frameHeight' : 480,
                           'zoomSpeedOut': 300, 
                           'overlayOpacity'	:	0.0,
                           'hideOnContentClick': false,
                           'overlayShow': true}).trigger('click');
      
      jQuery("#navod").click(function(){
        jQuery(".navod").slideToggle(500);
      });
      
		});

