﻿(function ($) {
    if (window.Blssi == null) { window.Blssi = {} }
    if (window.Blssi.StudioSystem == null) { window.Blssi.StudioSystem = {} }

    Blssi.StudioSystem.Utilities = {
        ajax: function (url, dataType, onComplete, onError) {
            $.ajax({
                type: 'POST',
                url: url,
                contentType: "application/x-www-form-urlencoded",
                dataType: dataType,
                context: null,
                success: onComplete,
                error: onError
            });
        },

        getUrlVars: function () {
            var vars = [], hash;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for (var i = 0; i < hashes.length; i++) {
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
        },

        getUrlVar: function (name) {
            return this.getUrlVars()[name];
        },

        getInternetExplorerVersion: function () {
            var rv = -1; // Return value assumes failure.
            if (navigator.appName == 'Microsoft Internet Explorer') {
                var ua = navigator.userAgent;
                var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
                if (re.exec(ua) != null)
                    rv = parseFloat(RegExp.$1);
            }
            return rv;
        },

        isEmailAddressValid: function (emailAddress) {
            var pattern = new RegExp(/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i);
            return pattern.test(emailAddress);
        }
    }

})(jQuery);

