﻿
if (!HasValidSession())
{
	LoginRedirect();
}

ChangeEventStreamPage(1);

window.onresize = CenterPopups;
window.onscroll = CenterPopups;
CenterPopups();
var ScrollTop = 0;
var ScrollLeft = 0;
function CenterPopups(e)
{
    var width = 0, height = 0;

    if (typeof (window.innerWidth) == 'number')
    {
        //Non-IE
        width = window.innerWidth;
        height = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
    {
        //IE 6+ in 'standards compliant mode'
        width = document.documentElement.clientWidth;
        height = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight))
    {
        //IE 4 compatible
        width = document.body.clientWidth;
        height = document.body.clientHeight;
    }

    var top = GetScrollTop() + (height / 2) - 300;
    var left = GetScrollLeft() + (width / 2);

    if (top < 0)
    {
        top = 0;
    }

    document.getElementById("popupCover").style.top = GetScrollTop() - 0 + "px";
    document.getElementById("popupCover").style.left = GetScrollLeft() - 0 + "px";

    document.getElementById("profilePicSelector").style.top = top + "px";
    document.getElementById("playerSearch").style.top = top + "px";
    document.getElementById("friendRequests").style.top = top + "px";
    document.getElementById("allFriends").style.top = top + "px";

    document.getElementById("profilePicSelector").style.left = left + "px";
    document.getElementById("playerSearch").style.left = left + "px";
    document.getElementById("friendRequests").style.left = left + "px";
    document.getElementById("allFriends").style.left = left + "px";
}

function GetScrollLeft()
{
	return FilterScrollResults(
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}

function GetScrollTop()
{
	return FilterScrollResults(
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function FilterScrollResults(n_win, n_docel, n_body)
{
    var n_result = n_win ? n_win : 0;
    if (n_docel && (!n_result || (n_result > n_docel)))
        n_result = n_docel;
    return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
