jQuery(document).ready(function() {


/*-----------------------------------------------------------------------------------*/
/*  Overlay Animation
/*-----------------------------------------------------------------------------------*/

  function thumb_overlay() {
    jQuery('.post-thumb a').hover( function() {
      jQuery(this).find('.overlay').fadeIn(150);
    }, function() {
      jQuery(this).find('.overlay').fadeOut(150);
    });
    
    $('a.tool_tip').animate({'opacity' : .9}).hover(function() {
    $(this).animate({'opacity' : 1});
    }, function() {
      $(this).animate({'opacity' : .9});
    });
    
  }
  
  thumb_overlay();

/*-----------------------------------------------------------------------------------*/
/*  Tipsy Tool Tip
/*-----------------------------------------------------------------------------------*/

  function tipsy_tooltip() {
    $('a.tool_tip').tipsy({fade: true});
  
  }
  
  tipsy_tooltip();
  

/*-----------------------------------------------------------------------------------*/
/*  Calling the Method
/*-----------------------------------------------------------------------------------*/

  /*slider*/
  $('#slider').nivoSlider({
    effect:'fade' // Specify sets like: 'fold,fade,sliceDown'
  });
  
  
  /* portfolio switch*/
  $("a.switch_thumb").toggle(function(){
        $(this).addClass("swap");
        $("ul.display").fadeOut("fast", function() {
            $(this).fadeIn("fast").addClass("thumb_view");
        });
    }, function () {
        $(this).removeClass("swap");
        $("ul.display").fadeOut("fast", function() {
            $(this).fadeIn("fast").removeClass("thumb_view");
        });
    }); 
  
  
  /* image fade when hover*/
  $('#portfolio a img').animate({'opacity' : 1}).hover(function() {
    $(this).animate({'opacity' : .3});
  }, function() {
    jQuery(this).animate({'opacity' : 1});
  });
  
  /*inFieldLabels*/
  /*$("label").inFieldLabels();*/

  /* PrettyPhoto */
  $("#image-grid:first a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'slow',theme:'light_square',slideshow:2000, autoplay_slideshow: false});

//});



(function($){  
  
  // -------------------------------------------------------------------------------------------------------
  // Form Validation script - used by the Contact Form script
  // -------------------------------------------------------------------------------------------------------
  
  function validateMyAjaxInputs() {

    $.validity.start();
    // Validator methods go here:
    $("#name").require();
    $("#telefon").require();
    $("#email").require().match("email");
    $("#betreff").require();  

    // End the validation session:
    var result = $.validity.end();
    return result.valid;
  }
  
  // -------------------------------------------------------------------------------------------------------
  // Form Clear
  // -------------------------------------------------------------------------------------------------------
  
  $.fn.clearForm = function() {
    return this.each(function() {
   var type = this.type, tag = this.tagName.toLowerCase();
   if (tag == 'form')
     return $(':input',this).clearForm();
   if (type == 'text' || type == 'password' || tag == 'textarea')
     this.value = '';
   else if (type == 'checkbox' || type == 'radio')
     this.checked = false;
   else if (tag == 'select')
     this.selectedIndex = -1;
    });
  };

  $(document).ready(function(){
  //////////////////////////////////////////////////////////////////////////////////////////////////////////////              
    // 
    //-------------------------------------------------------------------------------------------------------
    // Contact Form
    // -------------------------------------------------------------------------------------------------------
    
$("#contact-form").submit(function () {
                      
      if (validateMyAjaxInputs()) { //  procced only if form has been validated ok with validity
        var str = $(this).serialize();
        $.ajax({
          type: "POST",
          url: "http://apm-personal.localhost/DEV/_layout/send.php",
          data: str,
          success: function (msg) {
            $("#formstatus").ajaxComplete(function (event, request, settings) {
              if (msg == 'OK') { // Message Sent? Show the 'Thank You' message
                result = '<div class="successmsg">Ihre Nachricht wurde versendet. Vielen Dank!</div>';
                $('#contact-form').clearForm();
              } else {
                result = msg;
              }
              $(this).html(result);
            });
          }
    
        });
        return false;
      }
    });

  //////////////////////////////////////////////////////////////////////////////////////////////////////////////  
  });

})(window.jQuery);

