jQuery(document).ready(function(){
    /**
     * Funzione che muove le immagini della photo gallery
     * IMPORTANTE!! Funziona solo su classe .image-overlay
     */
    var $fPhoto = jQuery('.image-overlay').parent();
    $fPhoto.css('background-color','#000000');
    jQuery('.zoom-icon, .more-icon').css({'opacity':'0','visibility':'visible'});
    
    $fPhoto.hover(function(){
        jQuery(this).stop(true, true).animate({top: -10}, 500).find('img.f-photo-img').stop(true, true).animate({opacity: 0.7},500);
        var l1=parseInt(jQuery(this).find('.zoom-icon').css('left').replace("px",""));
        var l2=parseInt(jQuery(this).find('.more-icon').css('left').replace("px",""));
        jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 1, left: l1+10},400);
        jQuery(this).find('.more-icon').stop(true, true).animate({opacity: 1, left: l2-10},400);
    }, function(){
        var l1=parseInt(jQuery(this).find('.zoom-icon').css('left').replace("px",""));
        var l2=parseInt(jQuery(this).find('.more-icon').css('left').replace("px",""));
        jQuery(this).find('.zoom-icon').stop(true, true).animate({opacity: 0, left: l1-10},400);
        jQuery(this).find('.more-icon').stop(true, true).animate({opacity: 0, left: l2+10},400);
        jQuery(this).stop(true, true).animate({top: 0}, 500).find('img.f-photo-img').stop(true, true).animate({opacity: 1},500);
    });
    
    /*jQuery('.roster-avatar-wrapper').hover(function(){
        jQuery(this).find('div.roster-player').fadeIn(500);
    }, function(){
        jQuery(this).find('div.roster-player').fadeOut(500);
    });*/
    
    jQuery('.banner').each(function(){
      jQuery(this).click(function(){
        woopraTracker.pushEvent({name:'Click Banner', banner_id:"'"+jQuery(this).attr('id')+"'", banner_name:"'"+jQuery(this).find('a').attr('title')+"'"});
      });
    });

});

function center_img(obj,nh){
    var mt;
    var h=obj.height();
    mt=Math.ceil((h-nh)/2);
    mt=mt*-1;
    var mt1=mt+'px';
    obj.css({'marginTop' : mt1});
}


function center_img_o(obj,nh){
    var ml;
    var w=obj.width();
    ml=Math.ceil((w-nh)/2);
    ml=ml*-1;
    var ml1=ml+'px';
    obj.css({'marginLeft' : ml1});
}

function center_img_v(obj,nh){
    var mt;
    var h=obj.height();
    mt=Math.ceil((h-nh)/2);
    mt=mt*-1;
    var mt1=mt+'px';
    obj.css({'marginTop' : mt1});
}

jQuery.fn.equalHeightsDiv = function() {
	jQuery(this).each(function(){
		var currentTallest = 0;
		jQuery(this).children().each(function(i){
			if (jQuery(this).height() > currentTallest) {currentTallest = jQuery(this).height();}
		});
    currentTallest=currentTallest+"px";
		jQuery(this).children('div').css({'min-height': currentTallest});
	});
	return this;
};

function EqHeightDiv() {
  jQuery('.eqd').equalHeightsDiv();
}

function showRanking(){
  jQuery('#content-rank-home').children().hide();
  var showRank = jQuery('#team-rank').val();
    jQuery(showRank).show();
}

jQuery(document).ready(function(){
  EqHeightDiv();

  jQuery(".fancybox-rank").fancybox({
                  'type': "iframe",
                  'autoDimension': true,
                  'showCloseButton': true,
                  'autoScale': true,
                  'frameWidth': 645,
                  'frameHeight': 485,
                  'hideOnContentClick': false,
                  'overlayColor': '#000',
                  'overlayOpacity': '0.7'
                });
});
