﻿document.write('<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>');
document.write('<script type="text/javascript" src="/global/v2.0/library/js/jquery.mask.js"></script>');
document.write('<script type="text/javascript" src="/global/v2.0/library/js/jquery.menuish.js"></script>');

var $rs365 = {
    defaults: {
        jQueryUIVersion: "1.8.16",
        jQueryUITemplate: "/template/styles/jquery-ui/"
    },
    launch: function (link, newWindow) {
        if (newWindow) { window.open(link, "_blank"); }
        else { window.location = link; }

        return false;
    },
    confirmDelete: function (title, pronoun) {
        return confirm('Warning! You are about to delete ' + (pronoun || 'this') + ' ' + title + '.\nClick OK to continue or Cancel to abort.');
    },
    postTo: function (link, newWindow) {
        var form = document.forms[0];

        if (newWindow) { form.target = '_blank'; }
        form.action = link;

        form.submit();
    },
    loadjQueryUI: function (v, t) {
        v = v || $rs365.defaults.jQueryUIVersion;
        t = t || $rs365.defaults.jQueryUITemplate;

        document.write('<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/' + v + '/jquery-ui.min.js"></script>' +
                       '<link type="text/css" rel="stylesheet" href="' + t + 'jquery-ui-' + v + '.custom.css" />');
    },
    openCloseHelper: function (link, element) {
        $(link).click(function (e) {
            var handler = function (e) {
                if ($(element).has(e.target).length <= 0) {
                    $(element).hide();

                    $('body').unbind('click', handler);
                }
            };

            $('body').click(handler);
            $(element).show();

            return false;
        });
    }
};

// Keep for legacy support
function launch(link, newWindow) { $rs365.launch(link, newWindow); }
