/**
 * @package WordPress
 * @subpackage Constructor
 * 
 * @author   Anton Shevchuk <AntonShevchuk@gmail.com>
 * @link     http://anton.shevchuk.name
 */

 
(function($){
  function pareggia_altezze(elements){
    $(elements+':even').each(function(index, elem){
      elem2 = $(elements+':odd')[index];
      ($(elem).height() > $(elem2).height()) ? height = $(elem).height() : height = $(elem2).height();
      //console.log(height);
  	  $(elem).css({height: height+"px"});
  	  $(elem2).css({height: height+"px"});
  	});
  }
  
    $(document).ready(function(){

        // Header Drop-Down Menu
        if ($("#menu ul ul").length > 0) {
			
			$("#menu li:has(ul)").addClass('indicator');
			
			$("#menu li:has(ul)").hover(function(){
				$(this)
					.addClass('hover')
					.children('ul')
						.stop(true,true)
						.slideDown()
						//.animate({opacity:1},{queue:false})
					;
			}, function(){
				$(this)
					.removeClass('hover')
					.children('ul')
						.slideUp()
						//.animate({opacity:0.2},{queue:false})
					;
			});
        }
		
		// Header Search Form
		$('#menusearchform .s').mouseenter(function(){
		    var $this = $(this);
		    if (!$this.data('expand')) {
		        $this.data('expand', true);
			    $this.animate({width:'+=32px',left:'-=16px'});
		    }
		}).mouseleave(function(){
		    var $this = $(this);
		    $this.data('expand', false);
            $this.animate({width:'-=32px',left:'+=16px'});
        });

        // Header Slideshow
		if ($('.wp-sl').length > 0) {
			var sl = $('.wp-sl').wpslideshow({
			    url:wpSl.slideshow,
				thumb: wpSl.thumb,
				thumbPath: wpSl.thumbPath,
				limit: 480,
				effectTime: 1000,
				timeout: 10000,
				play: true
			});
		}
		
		// No underline for a with img
		$('a:has(img)').css({border:0});
		
    // pareggia_altezze(".posts_home .hentry h1");
    //    pareggia_altezze(".posts_home .hentry .entry");
		//$('.posts_home .hentry h1:even').css({height: "300px"});
    });


})(jQuery);

