/*==============================================================================
 JavaScript Document // EDVENS MEDIA s.r.o. // revize 0.9

# CONTENT OF JS
-------------------------
01. jQuery: Initialize library
03. jQuery - function: Animated Scrolling for Same-Page Links
==============================================================================*/

/* Initialize jQuery Library
==============================================================================*/
jQuery.noConflict();
jQuery(document).ready(function() {
// jQuery(document).bind('jQuery', function(event, data) {

  // ---------------------------------------------------------------------------
  // Variable name 'data' is RESERVED ARRAY !!! for interact with internal 
  // JavaScripts within XHTML templates
  // for (i in data) { alert ('debug: ' + i + ' = ' + data[i]); }
  // ---------------------------------------------------------------------------

  /* jQuery - function: Animated Scrolling for Same-Page Links
  ============================================================================*/
  function filter(string) {
    return string
      .replace(/^\//,'')
      .replace(/(index|default)\.[a-zA-Z]{3,4}$/,'')
      .replace(/\/$/,'')
  }
  jQuery('a[href*=#]:not([href*=#object])').each(function() {
    if (filter(location.pathname) == filter(this.pathname)
    && location.hostname == this.hostname
  	&& this.hash.replace(/#/,'') ) {
      var $targetId = jQuery(this.hash), $targetAnchor = jQuery('[name=' + this.hash.slice(1) +']');
      var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
      if ($target) {
        var targetOffset = $target.offset().top;
        jQuery(this).click(function() {
          // jQuery('html, body').animate({scrollTop: targetOffset}, 400); // disable
  	      return false;
  	    });
      }
    }
  });


  /* jQuery - function: Nabidky
  ============================================================================*/
  jQuery.ajaxSetup({cache: false});
  function ajaxSend(var_script, var_fn, var_name, var_value) {
    var return_value = jQuery.ajax({ type: "GET", url: var_script + "?fn=" + var_fn + "&" + var_name + "=" + encodeURIComponent(var_value) + "&" + new Date().getMilliseconds(), async: false }).responseText;
    return return_value;
  }

  jQuery('#li-zpravy a:first').click(function() {
    jQuery('#li-zpravy ul').toggle();
    ajaxSend('../kernel/plug_showhide.php', 'menu', 'menu', 'li-zpravy');
    return false;
  });

  jQuery('#li-fotografie a').hover(function () { jQuery(this).css({'cursor':'pointer'}); }, function () { jQuery(this).css({'cursor':''}); });
  jQuery('#li-fotografie a:first').click(function() {
    jQuery('#li-fotografie ul').toggle();
    ajaxSend('../kernel/plug_showhide.php', 'menu', 'menu', 'li-fotografie');
    return false;
  });

  jQuery('#li-mistrovstvi-cr a:first').hover(function () { jQuery(this).css({'cursor':'pointer'}); }, function () { jQuery(this).css({'cursor':''}); });
  jQuery('#li-mistrovstvi-cr a:first').click(function() {
    jQuery('#li-mistrovstvi-cr ul:first').toggle();
    ajaxSend('../kernel/plug_showhide.php', 'menu', 'menu', 'li-mistrovstvi-cr');
    return false;
  });

  // jQuery('#li-muzi a').hover(function () { jQuery(this).css({'cursor':'pointer'}); }, function () { jQuery(this).css({'cursor':''}); });
  jQuery('#li-muzi a:first').click(function() {
    jQuery('#li-muzi ul').toggle();
    ajaxSend('../kernel/plug_showhide.php', 'menu', 'menu', 'li-muzi');
    // return false; // je to aktivni odkaz
  });

  jQuery('#li-ostatni-souteze a').hover(function () { jQuery(this).css({'cursor':'pointer'}); }, function () { jQuery(this).css({'cursor':''}); });
  jQuery('#li-ostatni-souteze a:first').click(function() {
    jQuery('#li-ostatni-souteze ul').toggle();
    ajaxSend('../kernel/plug_showhide.php', 'menu', 'menu', 'li-ostatni-souteze');
    return false;
  });

  jQuery('#li-soutez-mladeze a').hover(function () { jQuery(this).css({'cursor':'pointer'}); }, function () { jQuery(this).css({'cursor':''}); });
  jQuery('#li-soutez-mladeze a:first').click(function() {
    jQuery('#li-soutez-mladeze ul').toggle();
    ajaxSend('../kernel/plug_showhide.php', 'menu', 'menu', 'li-soutez-mladeze');
    return false;
  });

  jQuery('#li-statistika a').hover(function () { jQuery(this).css({'cursor':'pointer'}); }, function () { jQuery(this).css({'cursor':''}); });
  jQuery('#li-statistika a:first').click(function() {
    jQuery('#li-statistika ul').toggle();
    ajaxSend('../kernel/plug_showhide.php', 'menu', 'menu', 'li-statistika');
    return false;
  });

  jQuery('#li-archiv a').hover(function () { jQuery(this).css({'cursor':'pointer'}); }, function () { jQuery(this).css({'cursor':''}); });
  jQuery('#li-archiv a:first').click(function() {
    jQuery('#li-archiv ul').toggle();
    ajaxSend('../kernel/plug_showhide.php', 'menu', 'menu', 'li-archiv');
    return false;
  });

});
