﻿/* If you make changes please increment the version number in the file name. */

$(function () {

    $('.datepicker').datepicker({
        showOn: 'button',
        buttonImage: '../Images/icons/calendar_select_day.png',
        buttonImageOnly: true,
        showButtonPanel: true,
        showAnim: 'blind'
    });

    $('a.dialog-logout').click(
        function (e) {
            var $href = this.href;
            e.preventDefault();
            $('<div title="Logout"></div>')
                .html('Are you sure you want to logout?')
                .dialog({
                    autoOpen: true,
                    resizable: false,
                    height: 140,
                    modal: true,
                    buttons: {
                        'Yes': function () {
                            $(this).dialog('close');
                            window.location.href = $href;
                        },
                        'Cancel': function () {
                            $(this).dialog('close');
                        }
                    }
                });
        });

    $('a.dialog-delete').click(
        function (e) {
            var $href = this.href;
            e.preventDefault();
            $('<div title="Delete"></div>')
                .html('Are you sure you want to delete?')
                .dialog({
                    autoOpen: true,
                    resizable: false,
                    height: 140,
                    modal: true,
                    buttons: {
                        'Yes': function () {
                            $(this).dialog('close');
                            window.location.href = $href;
                        },
                        'Cancel': function () {
                            $(this).dialog('close');
                        }
                    }
                });
        });

    $('.dialog-content').dialog({
        autoOpen: false,
        resizable: false,
        height: 400,
        width: 550,
        modal: true,
        buttons: {
            'Cancel': function () {
                $(this).dialog('close');
            }
        }
    });

});


function dialogOpen(dialogClass) {
    $(dialogClass).dialog('open');
}

function dialogClose(dialogClass) {
    $(dialogClass).dialog('close');
}

function dialogSave(keyField, textField, linkField, keyValue, textValue, dialogClass) {
    $(keyField)[0].value = keyValue;
    $(textField)[0].value = textValue;
    $(linkField)[0].innerHTML = textValue;
    dialogClose(dialogClass);
}


