﻿$(window).load(function(){
    var cnt = 0;
    var leftNutPercent = 0.78;
    $(".nut-wrap").each(function(){
        
        if (0==cnt || 3==cnt){
            $(this).animate({top:$(this).outerHeight(true)});
        }else if (1==cnt || 4==cnt){
            $(this).animate({top:$(this).outerHeight(true)/2});
        }
        if (1==cnt){
            $(this).animate({left:$(this).outerWidth(true)*leftNutPercent});
        }
        else if (2==cnt || 3==cnt){
            $(this).animate({left:$(this).outerWidth(true)*2*leftNutPercent});
        }else if (4==cnt){
            $(this).animate({left:$(this).outerWidth(true)*3*leftNutPercent});
        }else if (5==cnt){
            $(this).animate({left:$(this).outerWidth(true)*4*leftNutPercent});
        }
        cnt++;
    });
    $(".nut-wrap").hover(function(){
        $(this).find(".nut-image").attr("src",$(this).find(".nut-image").attr("rel") + "Hov.png");
        $content = $(this).find(".nut-content-wrap")
        $content.css({'top':0,'left':0});//$(this).position().top});
        $content.show();
        var m = "-" + ($content.outerHeight(true)+$(this).find(".nut-image").outerHeight(true)) + "px";
        //$content.css({'margin-top':m});
        $contentInner = $(this).find(".nut-content-inner");
        $(this).find(".nut-content-background").css({
            'width':$contentInner.outerWidth(true)
            ,'height':$contentInner.outerHeight(true)
            ,'top':$contentInner.position().top
            ,'left':$contentInner.position().left
        });
    },function(){
        $(this).find(".nut-image").attr("src",$(this).find(".nut-image").attr("rel") + ".png");
        $(this).find(".nut-content-wrap").hide();
    });
    placeDefaultContentBackground();
    $(".pnlNewsList").css({'height':$("#pnlDefaultContentWrap").outerHeight(true) - parseInt($(".pnlNewsList").css('padding-top'))});
});
$(window).resize(placeDefaultContentBackground);
function placeDefaultContentBackground(){
    $content = $("#pnlDefaultContent");
    $("#pnlDefaultContentBackground").css({
        'width':$content.outerWidth()
        ,'height':$content.outerHeight(true)
        ,'top':$content.position().top
        ,'left':$content.offset().left
        ,'z-index':1
    });
}
