﻿var uCurrentMenuItemId = 0;

function onMenuLoad (Id)
{
    document.getElementById(Id).className = "menu_item";
//    document.getElementById(Id).innerHTML = "<img src=images/bkmenu.jpg>";
}

function onMenuHover(Id, State)
{
    var e = document.getElementById(Id);

    if (Id == uCurrentMenuItemId)
    {
        e.className = "menu_item2";
//        e.innerHTML = "<img src=images/bkmenu2.jpg>";
    }
    else
    {
        if (State == 0)
        {
            e.className = "menu_item";
//            e.innerHTML = "<img src=images/bkmenu.jpg>";
        }
        else
        {
            e.className = "menu_item_hover";
//            e.innerHTML = "<img src=images/bkmenuh.jpg>";
        }
    }
}

function GetPageName(Id)
{
    switch (Id)
    {
        case 1:
            return "index";
        case 2:
            return "screens";
        case 3:
            return "download";
        case 4:
            return "buy";
        case 5:
            return "faq";
        case 6:
            return "support";
    }

    return null;
}

function UpdateMenuItem(Id)
{
    if (uCurrentMenuItemId == Id)
    {
        return;
    }

    if (uCurrentMenuItemId != 0)
    {
        document.getElementById(uCurrentMenuItemId).className = "menu_item";
//        document.getElementById(uCurrentMenuItemId).innerHTML = "<img src=images/bkmenu.jpg>";
    }

    document.getElementById(Id).className = "menu_item2";
//    document.getElementById(Id).innerHTML = "<img src=images/bkmenu2.jpg>";

    uCurrentMenuItemId = Id;
}

function onMenuItem(Id)
{
    window.location.assign(GetPageName(Id) + ".html");
}

function GetArgs()
{
    if (document.location.href.indexOf("?") == -1)
    {
        return null;
    }

    return document.location.search.substr(1).split("&");
}

function GetArg(ArgName)
{
    var args = GetArgs();
    if (args == null) return null;

    for (var i in args)
    {
        var a = args[i].split("=");
        if (a.length != 2) continue;

        if (a[0] == ArgName)
        {
            return a[1];
        }
    }

    return null;
}

function onLoad (Id)
{
    for (var i = 1; i <= 6; i++)
    {
        if (Id != i)
        {
            onMenuLoad(i);
        }
    }

    UpdateMenuItem(Id);
}