﻿jQuery(document).ready(function () {
	jQuery('.otherProducts').parent().siblings().hide();
	jQuery('.otherProducts').siblings().hide();
    jQuery('.subRow').hide();

    jQuery('.stripeRow').mouseover(function () {
        jQuery(this).addClass('rowAlt');
    }).mouseout(function () {
        jQuery(this).removeClass('rowAlt');
    });

    jQuery('.productRow').click(function () {
        jQuery(this).parent().siblings().each(function () {
            if (jQuery(this).css('display') != 'none')
                jQuery(this).hide();
            else
                jQuery(this).show();
        });

        jQuery(this).siblings().each(function () {
            if (jQuery(this).css('display') != 'none')
                jQuery(this).hide();
            else
                jQuery(this).show();
        });

        var collapsedImg = "../images/expand.png";
        var expandedImg = "../images/collapse.png";

        var expandControl = jQuery(this).children('td').children('img');

        if (expandControl.attr('src') == collapsedImg)
            expandControl.attr('src', expandedImg);
        else
            expandControl.attr('src', collapsedImg);
    });

    jQuery('.viewDownloadDetailLink').click(function () {
        var subRow = jQuery(this).parent().parent().next('.subRow');

        if (subRow.is('tr')) {
            if (subRow.css('display') != 'none') {
                subRow.hide();
                jQuery(this).parent().removeClass('selectedRow');
            }
            else {
                subRow.show();
                jQuery(this).parent().removeClass('rowAlt').addClass('selectedRow');
            }
        }
    });
});

function LoadAlertDialog(downloadPath, alertText) {
    jQuery('#dialog').text(alertText);

    jQuery('#dialog').dialog({
        width: 400,
        modal: true,
        resizable: false,
        buttons: {
            "OK": function () {
                jQuery(this).dialog('close'); document.location = downloadPath; 
            },
            "Cancel": function () {
                jQuery(this).dialog('close');
            }
        }
    });
}
