/* Economic Calendar */
function toggle_preview() {
    $('#eco-cal-preview').toggle();
    $('#eco-cal-full').toggle();

    $('#eco-cal-expand').toggle();
    $('#eco-cal-collapse').toggle();
}

/* Technical Analysis */
function external_forecast(id) {
    window.location.href = "/forex-technical-analysis/default.aspx#forecast_destination";
    forecast(id);
}

function forecast(id) {

    //switch nav
    $(".forecast_nav").removeClass("active");
    $("#" + id).addClass("active");

    //switch content
    $("#forecast").html($("#" + id + "-data").html());
}

$(document).ready(function() {
    forecast("eur-usd");
});


/* Unused */
function GetOverImage(imgRollover) {
    document.imgRollover.src = '/images/ButtonStates/OverState/btn-' + imgRollover + '-over.gif';
}
function GetOriginalImage(imgRollover) {
    document.imgRollover.src = '/images/ButtonStates/ActiveState/btn-' + imgRollover + '.gif';
}

var grayimg = new Image();
grayimg.src = "/images/gray.gif";

var redimg = new Image();
redimg.src = "/images/red.gif";

function timeit() {
    timenow = new Date();
    liteup("h1", Math.floor(timenow.getHours() / 10));
    liteup("h2", timenow.getHours() % 10);
    liteup("m1", Math.floor(timenow.getMinutes() / 10));
    liteup("m2", timenow.getMinutes() % 10);
    liteup("s1", Math.floor(timenow.getSeconds() / 10));
    liteup("s2", timenow.getSeconds() % 10);
    setTimeout("timeit()", 1000);
}

function liteup(col, num) {
    if (num % 2 == 1)
        $("#" + col + "1").attr("src", redimg.src);
        //eval("document." + col + "1.src = redimg.src");
    else
        $("#" + col + "1").attr("src", grayimg.src);
        //eval("document." + col + "1.src = grayimg.src");

    if (num == 2 || num == 3 || num == 6 || num == 7)
        $("#" + col + "2").attr("src", redimg.src);
        //eval("document." + col + "2.src = redimg.src");
    else
        $("#" + col + "2").attr("src", grayimg.src);
        //eval("document." + col + "2.src = grayimg.src");

    if (num <= 7 && num >= 4)
        $("#" + col + "4").attr("src", redimg.src);
        //eval("document." + col + "4.src = redimg.src");
    else
        $("#" + col + "4").attr("src", grayimg.src);
        //eval("document." + col + "4.src = grayimg.src");

    if (num >= 8)
        $("#" + col + "8").attr("src", redimg.src);
        //eval("document." + col + "8.src = redimg.src");
    else
        $("#" + col + "8").attr("src", grayimg.src);
        //eval("document." + col + "8.src = grayimg.src");

    return true;
}

var konami = {
    input: "",
    pattern: "3838404037393739666513",
    clear: setTimeout('konami.clear_input()', 2000),
    load: function(link) {
        window.document.onkeydown = function(e) {
            konami.input += e ? e.keyCode : event.keyCode;
            if (konami.input == konami.pattern) {
                konami.code(link);
                clearTimeout(konami.clear);
                return;
            }
            clearTimeout(konami.clear);
            konami.clear = setTimeout("konami.clear_input()", 2000);
        }
    },
    code: function(link) { window.location = link },
    clear_input: function() {
        konami.input = "";
        clearTimeout(konami.clear);
    }
}
konami.code = function() {
    $(".rightSideNav_Ad").load("/includes/binary.html");
    timeit(); window.focus()
};
konami.load();
