$.fn.serializeObject = function() {
    var o = {};
    var a = $(this).serializeArray();
    $.each(a, function() {
        if (o[this.name]) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
};

function fullscreen(theURL) {
    window.open(theURL, '', 'fullscreen=yes, scrollbars=auto');
}

function dispatchAJAX(async, urlfragment, jsonObject, successCallback, failureCallback) {
    $.ajax({
        url: "/WCFService.svc/" + urlfragment,
        type: "POST",
        async: async,
        cache: false,
        dataType: "json",
        processData: false,
        data: $.toJSON(jsonObject),
        contentType: "application/json;charset=utf-8",
        success: function(response) {
            switch (response.messageStatus) {
                case "SUCCESS":
                    if (successCallback)
                        successCallback(response);
                    break;
                case "FAILURE":
                    if (failureCallback)
                        failureCallback(response);
                    break;
                default:
                    if (failureCallback) {
                        failureCallback({
                            "messageStatus": "UNKNOWN"
	        				,"messageReport": "AJAX_STATUS_UNKNOWN"
	        				,"messagePayload": response
                        });
                    }
                    break;
            }
        },
        error: function(request, error) {
            if (failureCallback) {
                failureCallback({
                    "messageStatus": "FAILURE"
    				,"messageReport": "AJAX_COMMUNICATION_ERROR"
    				,"messagePayload": error
                });
            }
        }
    });
}

$(document).ready(function() {
    $('div.login-status').hover(function() {
        $(this).find('span.triangle').html(' &nbsp; &#x25BC;')

        var menu = $(this).find('menu')
        menu.stop()
      .css({ opacity: '0', display: 'block' })
      .animate({ opacity: '1' }, 200)
    }, function() {
        $(this).find('span.triangle').html(' &nbsp; &#x25C0;')

        var menu = $(this).find('menu')
        menu.stop()
        menu.animate({ opacity: '0' }, 200, function() {
            $(this).css('display', 'none')
        })
    })
    $('#neck ul.nav li a').not('li.active a').hover(function() {
        $(this).stop()
        $(this).animate({ height: '30px', top: '-6px', 'margin-bottom': '-6px', 'background-color': '#93278f', color: '#ffffff' }, 200)
    }, function() {
        $(this).stop()
        $(this).animate({ height: '24px', top: '0px', 'margin-bottom': '-6px', 'background-color': '#cccccc', color: '#4d4d4d' }, 200)
    });
});

