
if(window.location.hash != "" && window.location.hash.substr(0, 2) == "#!")
{
    var loc = "http://leagueofreplays.com" + window.location.hash.replace("#!", "");
    window.location = loc;
}

function loginOpen()
{
    $("#login").show("explode", {}, 800, function() {
        $("#usernameinput").focus();
    });
    $("#loginclose").hide("explode", {}, 800, function() {});
}

function loginClose()
{
    $("#loginclose").show("explode", {}, 800, function() {});
    $("#login").hide("explode", {}, 800, function() {});
}

function checkactive()
{
    alert("active = " + active + "\ntimeoutID = " + timeoutID);
}
var active;
var timeoutID;
var current;

$(function (){
    active = true;
    timeoutID = setTimeout("active = false", 300000);

    $("#loginOpen").click(function (){
        loginOpen();
    });

    $("#loginClose").click(function (){
        loginClose();
    });

    $("#usernameinput, #passwordinput").focus( function() {// only select if the text has not changed
      if(this.value == this.defaultValue)
      {
       this.select();
      }
    });

    $('div.outlinks a').click(function(){
        window.open(this.href);
        return false;
    });

    $(document).live("click keyup scroll", function(event) {
        clearTimeout(timeoutID);
        if(active == false)
        {
            active = true;
            redpost();
            streams();
        }
        timeoutID = setTimeout("active = false", 300000);
    });

    if($("#newsContent").length > 0)
        current = "newsContent";
    else
        current = "forumContent";

    add();
    
});

function add()
{
    var add2 = $(".add2 iframe");
    if(add2.html() == null)
    {
        $(".add2").css("display", "none");
        $(".noadd2").css("display", "block");
        $(".noadd2").css("width", "510px");
        $(".noadd2").css("padding", "10px");
    }

    var add1 = $(".add1 iframe");
    if(add1.html() == null)
    {
        $(".add1").css("display", "none");
        $(".noadd1").css("display", "block");
        $(".noadd1").css("padding", "10px");
        $(".noadd1").css("width", "226px");
        $(".noadd1").css("height", "226px");
    }
}

function toggle()
{
    toggleHeader();
    toggleSide();
    togglemaincontent();
}

function toggleHeader()
{
    $("#header").slideToggle(1000);
}

function toggleSide()
{
    $("#content").toggleClass("contentW");
    $("#maincontentfoot").toggleClass("basic");
    $("#eastcontent").toggle("drop", {direction: "left"}, 1000);
    $("#eastcontent2").toggle("drop", {direction: "right"}, 1000);
}

function togglemaincontent()
{
    if($("#newsContent").length > 0)
    {
        $("#newsContent").attr("id", "forumContent");
        //$(document).scrollTo($(document).scrollTop() - 325, 800, {});
    }
    else
    {
        $("#forumContent").attr("id", "newsContent");
        //$(document).scrollTo($(document).scrollTop() + 325, 800, {});
    }
}

