﻿var Redirect = {

    /*** Redirect to specific page
    ******************************************/
    to: function (redirectTo) {
        document.location.href = redirectTo;
    },

    /*** List of pages
    ******************************************/
    home: function () { Redirect.to('home.aspx'); }
};


var AjaxLib = {

    /*** Call webservice method and callback
    ******************************************/
    call: function (service, method, array, callback) {
        $.ajax({
            type: 'POST',
            url: '/Services/' + service + '.asmx/' + method,
            data: AjaxLib.getJSON(array),
            contentType: "application/json;",
            dataType: 'json',
            success: function (data) {
                callback(data.d)
            }
        });
    },

    /*** Transform array in JSON
    ******************************************/
    getJSON: function (array) {
        if (array == null || array.length == 0)
            return '{}';

        var json = '{';

        for (var i = 0; i < array.length; i = i + 2) {
            json += " '" + array[i] + "' ";
            json += ": '" + array[i + 1] + "', ";
        }

        json = json.substr(0, json.length - 2);
        json += ' }';

        return json;
    }
};

$(document).ready(function () {
    $('.corner').corner('5px');
});

$(window).load(function () {
    $('body').show();
});
