﻿////////////////////////////////////////////////////////////////////////
// Contains the main javascript function used everywhere on the website.
////////////////////////////////////////////////////////////////////////

var sectionID = "";

function openNewWindow(theURL, wW, wH, secondaryURL) {
    var w = wW, h = wH, cw = w / 2, ch = h / 2;
    if (window.screen) {
        cw = Math.floor((screen.availWidth - w) / 2);
        ch = Math.floor((screen.availHeight - h) / 2);
    }
    window.open(theURL, "newPopup", 'width=' + w + ',height=' + h + ',top=' + ch + ',left=' + cw);

    if (secondaryURL != null) {
        window.location.href = secondaryURL;
    }
}

function show_thickbox(title, url, width, height, iframe) {
    //alert(iframe +' :: ' + width + ' :: ' + height);
    if (iframe == true) {
        url = url + '?keepThis=true&TB_iframe=true&width=' + width + '&height=' + height;
    } else {
        url = url + '?width=' + width + '&height=' + height;
    }
    //alert(url);
    imageGroup = '';
    tb_show(title, url, imageGroup);
}

function testPopup(action) {
    //alert("action : " + action);
    if (action == "forgotPwd") {
        window.location.href = "ForgetPassword.aspx";
    } else if (action == "register") {
        window.location.href = "Register.aspx";
    } else {
        window.location.href = "index.aspx";
    }
}

function randomPub(size) {
    var path_pfx = "/Themes/en/swf/";
    if (size == "120x240") {
        var pub_arr = new Array("PUB_GLX120x240_01.swf", "PUB_Widget120x240_01.swf");
    } else if (size == "120x600") {
        var pub_arr = new Array("PUB_GLX120x600_01.swf", "PUB_Widget120x600_01.swf", "PUB_NEO120x600_01.swf");
    }
    var rand_idx = Math.floor(pub_arr.length * Math.random());
    //alert(rand_idx);
    return (path_pfx + pub_arr[rand_idx]);
}

function OpenNeoshifterGame() {
    openNewWindow('Neoshifters/neoClient.aspx', 750, 510);
}