// document ready
$(document).ready(function() {
  
  // init nivo slider
  if($('#slider').length) {
    $('#slider').nivoSlider({
      effect: 'fade',
      directionNav: false,
      contolNav: true,
      animSpeed:400, // Slide transition speed
      pauseTime:5000 // How long each slide will show
    });
    
    // mehr button hover behavior
    $('#slider > a').hover(
      function() {
        $(this).children("span").addClass("hover");
      },
      function() {
        $(this).children("span").removeClass("hover");
      }
    );
  }
  
  if($('.handle-focus').length) handleInputFocus();

});

// clear input field onfocus and reset original content onblur
function handleInputFocus() {
  var sel = $(".handle-focus");
  sel.each(function(i) {
    var inputValue = $(this).attr('value');
    $(this).focus(function(){
      $(this).stop(true, true);
      if($(this).attr('value') == inputValue) $(this).attr('value', '');
      $(this).parent().addClass("input-focus").removeClass("error");
    }).blur(function(){
      if($(this).attr('value') == '') {
        $(this).attr('value', inputValue);
        $(this).parent().removeClass("input-focus");
      }
    });
  });
}
