﻿loadOptions = function () {
    var dlg = $('body').find('#sd-options');

    if (dlg.length > 0) {

        dlg.dialog('open');
    }
    else {
        dlg = createOptionsContent();
        $('body').append(dlg);
        dlg.dialog(
        {
            modal: true,
            title: 'Smartdiary Options',
            bgiframe: true,
            height: 550,
            width: 645,
            buttons: {
                "Save": function () {
                    var theme = $('#sd-theme').val();
                    $('head').append('<link rel="stylesheet" type="text/css" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/' + theme + '/jquery-ui.css" />');
                },
                'Close': function () {
                    dlg.dialog('close');
                }
            }
        });
    }
}

createOptionsContent = function () {
    $o = $('<div id=\'sd-options\'></div>');
    $theme = $('<select id=\'sd-theme\'></select>');
    $theme.append('<option value=\'ui-lightness\'>ui-lightness</option>');
    $theme.append('<option value=\'ui-darkness\'>ui-darkness</option>');
    $theme.append('<option value=\'smoothness\'>smoothness</option>');
    $theme.append('<option value=\'start\'>start</option>');
    $theme.append('<option value=\'redmond\'>redmond</option>');
    $theme.append('<option value=\'sunny\'>sunny</option>');
    $theme.append('<option value=\'overcast\'>overcast</option>');
    $theme.append('<option value=\'le-frog\'>le-frog</option>');
    $theme.append('<option value=\'flick\'>flick</option>');
    $theme.append('<option value=\'pepper-grinder\'>pepper-grinder</option>');
    $theme.append('<option value=\'dark-hive\'>dark-hive</option>');
    $theme.append('<option value=\'cupertino\'>cupertino</option>');
    $theme.append('<option value=\'south-street\'>south-street</option>');
    $theme.append('<option value=\'blitzer\'>blitzer</option>');
    $theme.append('<option value=\'humanity\'>humanity</option>');
    $theme.append('<option value=\'hot-sneaks\'>hot-sneaks</option>');
    $theme.append('<option value=\'dot-luv\'>dot-luv</option>');
    $theme.append('<option value=\'mint-choc\'>mint-choc</option>');
    $theme.append('<option value=\'black-tie\'>black-tie</option>');
    $theme.append('<option value=\'trontastic\'>trontastic</option>');
    $theme.append('<option value=\'swanky-purse\'>swanky-purse</option>');
    $p = $('<p>Select a Theme</p>');
    $p.append($theme);
    $o.append($p);
    return $o;
}

saveOptions = function () {
    var t = $('#sd-theme').val();

}
