﻿/***********************************
*Author:     Remco "B-ie-R" Verver
*Year:       2009
*Project:    GameSpy Volunteers Webpages
*Company:    IGN / GameSpy
************************************/

/* profile page */
function SetBGImg(id) {
    var element = document.getElementById(id);
    element.style.backgroundImage = "url('images/bg_70_transparant.png')";
}
function ReleaseBGImg(id) {
    var element = document.getElementById(id);
    element.style.backgroundImage = "none";
}

function SBF(arb) {
    arbb = arb.split("_"); 
    var ran_unrounded = Math.random() * (arbb.length - 1);
    var ran_number = Math.floor(ran_unrounded);
    document.getElementById('d01').style.backgroundImage = "url('bfimg/" + arbb[ran_number] + "_b.png')";
    document.getElementById('d03').style.backgroundImage = "url('bfimg/" + arbb[ran_number] + "_f.png')";
}

/* Banner */
function DLBF() {
    var xmlhttp;
    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();

        xmlhttp.open("GET", "GBF.aspx?bl=true", true);
        xmlhttp.send(null);

        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4) {
                arb = xmlhttp.responseText;
                SBF(arb);
            }
        }
        setTimeout("DLBF()", 6500);
    }
    else if (window.ActiveXObject) {
        // code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

        xmlhttp.open("GET", "GBF.aspx?bl=true", true);
        xmlhttp.send(null);

        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4) {
                arb = xmlhttp.responseText;
                SBF(arb);
            }
        }
        setTimeout("DLBF()", 6500);
    }
    else {
        document.getElementById('d01').style.backgroundImage = "url('bfimg/bf2_b.png')";
        document.getElementById('d03').style.backgroundImage = "url('bfimg/bf2_f.png')";
    }
}

function ViewEvent(id) {
    if (screen.width > 980 && screen.height > 850) {
        window.open('http://www.gamespyvolunteers.com/EventHandler.aspx?event=' + id, 'ViewEvent', 'width=980,height=850,resizable=0,scrollbars=1,toolbar=0,location=1,directories=0,status=0,menubar=0,copyhistory=0');
    }
    else {
        window.open('http://www.gamespyvolunteers.com/EventHandler.aspx?event=' + id, 'ViewEvent', 'width=' + (screen.width - 80) + ',height=' + (screen.height - 90) + ',resizable=0,scrollbars=1,toolbar=0,location=1,directories=0,status=0,menubar=0,copyhistory=0');
    }
}

function RunTime(id, hour, min, sec) {
    hour = parseFloat(hour);
    min = parseFloat(min);
    sec = parseFloat(sec);

    if ((sec + 1) < 60)
        sec = sec + 1;
    else
        if ((sec + 1) == 60 && (min + 1) < 60) {
        sec = 0;
        min = min + 1;
    }
    else
        if ((sec + 1) == 60 && (min + 1) == 60) {
        sec = 0;
        min = 0;
        hour = hour + 1;
    }
    else
        if ((sec + 1) == 60 && (min + 1) == 60 && (hour + 1) == 24) {
        sec = 0;
        min = 0;
        hour = 0;
    }

    if (sec.toString().length == 1)
        sec = "0" + sec;
    if (min.toString().length == 1)
        min = "0" + min;
    if (hour.toString().length == 1)
        hour = "0" + hour;

    if (id == 'TimeS') {
        document.getElementById(id).innerHTML = hour + ":" + min + ":" + sec + " PST";
    }
    else
        if (id == 'TimeE') {
        document.getElementById(id).innerHTML = hour + ":" + min + ":" + sec + " CET";
    }

    setTimeout("RunTime('" + id + "','" + hour + "','" + min + "','" + sec + "')", 999);
}
