var newsInit = function()
{
    $("div.toggle, div.title, div.date").click(function () {
        var theDiv = $(this).parent().parent().children("div.content");
        if(theDiv.css("display") == "none")
        {
            theDiv.css("display", "block");
            $(this).parent().children("div.toggle").html("-");
        }
        else
        {
            theDiv.css("display", "none");
            $(this).parent().children("div.toggle").html("+");
        }
    });
    var firstDiv = $("div.newsItem:first div.toggle");
    if(firstDiv.html() != null && firstDiv.html().trim() == "+")
        firstDiv.trigger("click");
}

var loadStats = function()
{
    loader.loadUrl(ROOT_URL + 'wow/stats/stats', "#status");
};

var updateTitle = function()
{
    try
    {
        $("#content h1:first").attr("id", "title");
        document.title = "LecoWoW :: " + $("#content h1:first").html().trim();
    }
    catch(err)
    {
        document.title = "LecoWoW :: " + "Unknown Page";
    }
}

function selectRealm()
{
    var realm = $("#select_realm").val();
    var url = $("#select_realm").parents("form").attr("action") + "/" + realm;
    if(ajax)
    {
        location.hash = "#" + url.replace(ROOT_URL, "");
        loader.loadPage();
    }
    else
        window.location = url;
}