﻿$(document).ready(function() {
    $("a[rel='example2']").colorbox({ transition: "fade" });

    $('.encodedAddress').each(function() {
        var emailAddress = $(this).text();
        emailAddress = emailAddress.replace("[at]", "@");
        $(this).replaceWith('<a href="mailto:' + emailAddress + '">' + emailAddress + '</a>');
    });
})


/* mapa pobocky*/
function mapaPobocky(PobockaId, PobockaMeno, PobockaAdresa, PobockaInfo) {
        $('#gmap_' + PobockaId).goMap({
          zoom: 16,
          markers: [{
              title: "'" + PobockaMeno + "'",
              address: "'" + PobockaAdresa + "'",

              html: {
                  content: PobockaInfo,
                  popup: true
              }

          }
            ],
          icon: '/img/ico_maps_logo.png'
      });
  }


//menu
function coolMenu(elemID, newClass) {
    elemH[1] = $('ul.coolMenu_off ul')
    var elem = document.getElementById(elemID);
    elem.className = newClass;
}




//zobrazovanie
function f_slideBox(c_okna)
{
  for(i=1;i < 4;i++)
    { 
    var okno = document.getElementById("okno_" + i);
    var menu = document.getElementById("select_" + i);
    if ( c_okna == i ) 
    {
    okno.style.display = "block";
    menu.style.color = "#C33801"   
    initImage("okno_" + i);
    }
    else 
    {
    okno.style.display = "none";
    menu.style.color = "#FF7F4B";
    }
    }
}



//efekt zobrazovania
 function initImage(okno_id) 
    {
      imageId = okno_id;
      image = document.getElementById(imageId);
      setOpacity(image, 0);
      image.style.visibility = 'visible';
      fadeIn(imageId,0);
    }
    
    function setOpacity(obj, opacity) 
    {
      opacity = (opacity == 100)?99.999:opacity;
      

      // IE/Win
      obj.style.filter = "alpha(opacity="+opacity+")";
      
      // Safari<1.2, Konqueror
      obj.style.KHTMLOpacity = opacity/100;
      
      // Older Mozilla and Firefox
      obj.style.MozOpacity = opacity/100;
      
      // Safari 1.2, newer Firefox and Mozilla, CSS3
      obj.style.opacity = opacity/100;
    }
    
    function fadeIn(objId,opacity) 
    {
      if (document.getElementById) {
        obj = document.getElementById(objId);
        if (opacity <= 100) {
          setOpacity(obj, opacity);
          opacity += 10;
          window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 60);
        }
      }
  }



/* ticker ----------------------------------------------------------------------------------------*/



  jQuery.fn.liScroll = function(settings) {
      settings = jQuery.extend({
          travelocity: 0.07
      }, settings);
      return this.each(function() {
          var $strip = jQuery(this);
          $strip.addClass("newsticker")
          var stripWidth = 0;
          var $mask = $strip.wrap("<div class='mask'></div>");
          var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");
          var containerWidth = $strip.parent().parent().width(); //a.k.a. 'mask' width 	
          $strip.find("li").each(function(i) {
              stripWidth += jQuery(this, i).outerWidth(true); // thanks to Michael Haszprunar
          });
          $strip.width(stripWidth);
          var totalTravel = stripWidth + containerWidth;
          var defTiming = totalTravel / settings.travelocity; // thanks to Scott Waye		
          function scrollnews(spazio, tempo) {
              $strip.animate({ left: '-=' + spazio }, tempo, "linear", function() { $strip.css("left", containerWidth); scrollnews(totalTravel, defTiming); });
          }
          scrollnews(totalTravel, defTiming);
          $strip.hover(function() {
              jQuery(this).stop();
          },
				function() {
				    var offset = jQuery(this).offset();
				    var residualSpace = offset.left + stripWidth;
				    var residualTime = residualSpace / settings.travelocity;
				    scrollnews(residualSpace, residualTime);
				});
          $(".ticker").css("visibility", "visible");
      });

  };
