﻿// Name: SettingsDialog.js
// Version: 1.0.0.0
// FileVersion: 1.0.0.0
// -----------------------------------------------------------------------
//  Copyright (C) Peter Bredenberg System. All rights reserved.
// -----------------------------------------------------------------------

// Key press handler
function settingsOkButtonKeyPress(e) {
    var kC = (window.event != null) ? event.keyCode : e.charCode;
    if (kC == 13) {
        stopEventBubbling(e);
        settingsOkButton.click();
    }
}

// Key press handler
function settingsCancelButtonKeyPress(e) {
    var kC = (window.event != null) ? event.keyCode : e.charCode;
    if (kC == 13) {
        stopEventBubbling(e);
        settingsCancelButton.click();
    }
}

// Show the dialog window
function showSettingsDialog() {
    closeAllDialogs();

    positionModalBackground(true);
    var width = 350;
    var dlg = $get('SettingsDialog');
    if (dlg != null) {
        enableCtrls($get('SettingsTable').childNodes);
        dlg.style.left = ((getWindowWidth() - width) / 2) + 'px';
        dlg.style.display = 'block';
        settingsItemsPerPageDropDownList.focus();
    }
}

// Close the dialog window
function closeSettingsDialog() {
    var dlg = $get('SettingsDialog');
    if (dlg != null)
        dlg.style.display = 'none';
    hideModalBackground();
}

// Save the settings
function saveSettings() {
    var value = settingsItemsPerPageDropDownList.options[settingsItemsPerPageDropDownList.selectedIndex].value;
    setCookie('PageSize', value, 365);
    history.go(0);
}

// Close all dialogs
function closeAllDialogs() {
    closeTipDialog();
    closeLoginDialog();
    closeArticleInfoDialog();
    closeCheckoutDialog();
    closeAccountApplicationDialog();
    closeMyAccountDialog();
    closeSettingsDialog();
}

// Notify ScriptManager that this is the end of the script
if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();

