/*
 * JQUERY EXTENSIONS
 */

google.load("jquery", "1.2");

google.setOnLoadCallback(function() {

    // Return maximum value of attribute
    jQuery.fn.max = function(attrib) {
        var maxVal = this.get(0) ? this.get(0)[attrib] : 0;
        this.slice(1).each(function() {
            if (maxVal < this[attrib]) maxVal = this[attrib];
        });
        return maxVal;
    };

    // Fix external links
    $("a[rel=xtrn]").attr("target", "_blank");

    // Extend content & left menu border
    var docY = $(document).height();
    $("div.container").height(docY);
    $("#menu").height(docY - $("#header").height() - 18);

    // Equalize box sizes
    var boxList = $("div.equal");
    boxList.height(boxList.max("offsetHeight"));

    // Handle news box close
    $("#alertClose").click(function() {
        $("#alertPanel").animate({ height: 0 }, "slow")
    });

    // Start music
    /*
    var params = {
        autoplay: true,
        repeat: true,
        song_title: "Cooper's Theme",
        song_url: "/music/cooper.mp3"
    };
    swfobject.embedSWF("/music/musicplayer.swf", "musicPlayer",
        "17", "17", "9.0.0", false, params);
    */

    // Pop up news box
    var newsH = $("#alertPanel>div").height() + 20;
    if (newsH === 20) newsH = 250;
    $("#alertPanel").animate({ height: newsH + "px" }, "slow");

});

