
  // JavaScript Document // EDVENS MEDIA s.r.o. // revize 0.3
  jQuery.noConflict();
  jQuery(document).ready(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*=#]').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);
  	        return false;
  	      });
        }
      }
    });
  
  
    // Sending Contact Form over Ajax
    jQuery('#form form').attr({action: "./"});
    jQuery('#form form').attr({method: "post"});
    jQuery('#form input.button').click(function()
    {
      var jmeno   = jQuery("#form input#jmeno").val();
      var email   = jQuery("#form input#email").val();
      var zprava  = jQuery("#form textarea#zprava").val();
      if ((jmeno=="")||(email=="")||(zprava=="")) { alert('Je potřeba vyplnit všechna políčka.'); }
      else
      {
        jQuery.ajax({
          type: "POST",
          url: "./",
          data: "jmeno=" + jmeno + "&email=" + email + "&zprava=" + zprava + "&phpmailer=",
          success: function(msg){
            if (msg.substr(0,1)=="1") 
            { // uspesne odeslano, proto vymazeme kolonky
              jQuery("input#jmeno").val("");
              jQuery("input#email").val("");
              jQuery("textarea#zprava").val("");
            }
            jQuery("#status").text( msg.substr(1) );
          }
        });
      }
      return false;
    });


    // vymaze e-mail input pro zadani vlastniho e-mailu
    jQuery('input#e-mail').click(function() { jQuery('input#e-mail').attr({value: ""}); });

    // registrace e-mailu pro odber novinek
    jQuery('form#feed').attr({action: "./"});
    jQuery('form#feed').attr({method: "post"});
    jQuery('#feed input#submit').click(function()
    {
      var email   = jQuery("#feed input#e-mail").val();
      if (email=="") { alert('Je potřeba vyplnit adresu e-mailu.'); }
      else
      {
        jQuery.ajax({
          type: "POST",
          url: "./",
          data: "email=" + email,
          success: function(msg){
            if (msg.substr(0,1)=="1")
            { // uspesne odeslano, vratime puvodni text do kolonky
              jQuery('#feed input#e-mail').attr({value: "Novinky na e-mail @"});
            }
            alert( msg.substr(1) );
          }
        });
      }
      return false;
    });



  });
