﻿//LeftMenu.js

$(function()
{
    SetLeftPanelsBehavior();
});

function SetLeftPanelsBehavior()
{
    //set categories-table behavior
    $('#LeftMenu_AllCategoriesTable tr td').each(function()
    {
        $(this).addClass('LeftPanelRow');

        $(this).mouseenter(function()
        {
            $(this).removeClass('LeftPanelRow');
            $(this).addClass('LeftPanelRowHighlight');
        });

        $(this).mouseleave(function()
        {
            $(this).removeClass('LeftPanelRowHighlight');
            $(this).addClass('LeftPanelRow');
        });

        $(this).click(function()
        {
            var categoryUid = this.id.split('_')[2];
            ChangeCategory(categoryUid);
        });
    });

    //set languages-table behavior
    $('#LeftMenu_AllLanguagesTable tr td').each(function()
    {
        $(this).addClass('LeftPanelRow');

        $(this).mouseenter(function()
        {
            $(this).removeClass('LeftPanelRow');
            $(this).addClass('LeftPanelRowHighlight');
        });

        $(this).mouseleave(function()
        {
            $(this).removeClass('LeftPanelRowHighlight');
            $(this).addClass('LeftPanelRow');
        });

        $(this).click(function()
        {
            var languageUid = this.id.split('_')[2];
            ChangeLanguage(languageUid);
        });
    });

    //set projects-table behavior
    $('#LeftMenu_AllProjectsTable tr td').each(function()
    {
        $(this).addClass('LeftPanelRow');

        $(this).mouseenter(function()
        {
            $(this).removeClass('LeftPanelRow');
            $(this).addClass('LeftPanelRowHighlight');
        });

        $(this).mouseleave(function()
        {
            $(this).removeClass('LeftPanelRowHighlight');
            $(this).addClass('LeftPanelRow');
        });

        $(this).click(function()
        {
            var projectUid = this.id.split('_')[2];
            ChangeProject(projectUid);
        });
    });
}

////////////////////////////////////////////////
//event methods (methods directly from controls)

function ChangeCategory(categoryUid)
{
    window.top.location = '/?category=' + categoryUid;
}

function ChangeLanguage(languageUid)
{
    window.top.location = '/?language=' + languageUid;
}

function ChangeProject(projectUid)
{
    window.top.location = '/?project=' + projectUid;
}

