/*!
 * Almega µ WordPress Theme
 * Main Behavious JavaScript
 * © 2010 Daytona Communication AB
 */

(function($){ // Sandbox our code

  /**
   * On DOM Ready:
   */

  $(function() {
    $('#almega_blog-intro .blog-intro-panel').hoverLink();
  });


  /**
   * Set .hover class on mouseover, follow first link on click
   */

  $.fn.hoverLink = function(options) {
    options = $.extend({
      hoverClass: 'hover',
			minHeight: 0
    }, options);
		
		
		
    var setUnsetHover = function(e) {
      var panel = $(this);

      if (e.type == 'mouseenter')
        panel.addClass(options.hoverClass);
      else
        panel.removeClass(options.hoverClass);
    };

    var followLink = function(e) {
      var link  = $('a:first', this);

      e.preventDefault();
      window.location = link.attr('href');
    };

		var fixHeight = function(){
			if (options.minHeight < $(this).height()){
				options.minHeight = $(this).height();
			}
		};

    this.bind('mouseenter mouseleave', setUnsetHover);
    this.bind('click', followLink);
		this.each(fixHeight);
		this.height(options.minHeight);
  };

}(jQuery));

