﻿$(document).ready(function () {
    $(".HomeBlock").hover(function () {
        var idstr = $(this).attr("id");
        ShowHomeBlockHover(idstr);
    }, function () {
        var idstr = $(this).attr("id");
        HideHomeBlockHover(idstr);
    });

    FixNewsHeight();
    FixContentWidthHeight();
});

function FixContentWidthHeight() {
    if ($("#right").length > 0) {
        //$("#right").css("height", $("#content").css("height"));
        //alert($("#content").css("height"));
        //alert($("#right").css("height"));
    } else {
        $("#middle").css("width", "667px");
    }
}

function FixNewsHeight() {
    var maxNewsheight = 0;
    var temp = 0;
    if ($("#news1").length > 0) {
        temp = parseInt($("#news1").css("height").replace("px", ""));
        if (temp > maxNewsheight)
            maxNewsheight = temp;
        temp = 0;
    }
    if ($("#news2").length > 0) {
        temp = parseInt($("#news2").css("height").replace("px", ""));
        if (temp > maxNewsheight)
            maxNewsheight = temp;
        temp = 0;
    }
    $("#news1").css("height", maxNewsheight + "px");
    $("#news2").css("height", maxNewsheight + "px");

    //alert("news 1: " + $("#news1").css("height"));
    //alert("news 1: " + $("#news2").css("height"));
}

function ShowHomeBlockHover(idstr) {
    //alert("show: " + idstr);
    $("#" + idstr + " h2").addClass("Active");
    $("#" + idstr + " .Slider").slideToggle(400, function () {

    });
    
}

function HideHomeBlockHover(idstr) {
    //alert("hide: " + idstr);
    $("#" + idstr + " .Slider").slideToggle(400, function () {
        $("#" + idstr + " h2").removeClass("Active");
        //$("#" + idstr + " h2").animate({ "background": "white" }, "slow");
    });
}
