﻿function OnApplyFilterClientClick(sender) {
    $('#hiddenFilterOptions').append($("#TB_ajaxContent").children());
    tb_remove();
    return true;
}

function SetActiveFeed(shortName, feedName) {
    $.ajax({
        url: "/Handlers/SetSessionOption.ashx?selectedFeedShortName=" + shortName + "&selectedFeedName=" + feedName,
        success: function () { document.location = "/inventory/default.aspx?" + new Date().getTime(); }
    });
}

function OnApplySearchClientClick(sender) {
    $('#hiddenSearchOptions').append($("#TB_ajaxContent").children());
    tb_remove();
    return true;
}

function DataRowShowEditOptions(obj) {
    $(this).addClass('active');
    sourceRow = $(this);
    var productId = $(this).children('TD:first').text();

    if (productId) {

        eleOffset = $(this).children('TD:first').offset();
        $('#toolbox').removeClass('hidden');
        $("#toolbox").css('left', eleOffset.left);
        $("#toolbox").css('top', eleOffset.top);

        $('#toolbox > #Edit').attr("href", "/inventory/edit/default.aspx?ProductId=" + productId + "&TB_iframe=true&height=400&width=610");
        $('#toolbox > #Edit').unbind("click");
        $('#toolbox > #View').attr("href", "/inventory/view/default.aspx?ProductId=" + productId + "&TB_iframe=true&height=400&width=610");
        $('#toolbox > #View').unbind("click");
        $('#toolbox > #Image').attr("href", "/inventory/uploadimage/default.aspx?ProductId=" + productId + "&TB_iframe=true&height=400&width=610");
        $('#toolbox > #Image').unbind("click");
        $('#toolbox > #Audio').attr("href", "/inventory/audio/default.aspx?ProductId=" + productId + "&TB_iframe=true&height=400&width=610");
        $('#toolbox > #Audio').unbind("click");
        $('#toolbox > #Video').attr("href", "/inventory/video/default.aspx?ProductId=" + productId + "&TB_iframe=true&height=400&width=610");
        $('#toolbox > #Video').unbind("click");

        tb_init('#toolbox > #Edit, #toolbox > #View, #toolbox > #Image, #toolbox > #Audio, #toolbox > #Video');
    }

}
function DataRowHideEditOptions(obj) {
    $(this).removeClass('active');
}

$(document).ready(function () {
    $('.DataTable TR').mouseover(DataRowShowEditOptions);
    $('.DataTable TR').mouseout(DataRowHideEditOptions);

    $('.toggleoverlay').toggle(function () {
        $(this).text("Turn on product overlay menu");
        $('.DataTable TR').unbind('mouseover');
        $('.DataTable TR').unbind('mouseout');
        $('#toolbox').addClass('hidden');
        $.get("/Handlers/SetSessionOption.ashx?overlay=false");
    },
    function () {
        $(this).text("Turn off product overlay menu");
        $('.DataTable TR').mouseover(DataRowShowEditOptions);
        $('.DataTable TR').mouseout(DataRowHideEditOptions);
        $.get("/Handlers/SetSessionOption.ashx?overlay=true");
    });


});

