﻿$.fn.serializeNoViewState = function () {
    return this.find("input,textarea,select,hidden")
               .not("[type=hidden][name^=__]")
               .serialize();
}

$.fn.addItems = function (data) {
    return this.each(function () {
        var list = this;
        $.each(data, function (index, itemData) {
            var option = new Option(itemData.Text, itemData.Value);
            // list.add(option); <- firefox error
            list.options[list.options.length] = option;
        });
    });
};

$.ajaxSetup({
    "error": function (XMLHttpRequest, textStatus, errorThrown) {
        alert('Data error! please reinstall system!')
        if (window.console && window.console.log) {
            console.log(textStatus);
            console.log(errorThrown);
            console.log(XMLHttpRequest.responseText);
            console.log(XMLHttpRequest);
        }
    }
});

var CDAjax = {};
CDAjax.Get = function (a, b, c) {
    var now = new Date().getTime();
    $.getJSON(a + "?now=" + now, b, c);
};

CDAjax.Post = function (a, b, c) {
    var now = new Date().getTime();
    $.ajax({
        type: "POST",
        url: a + '?timer=' + now,
        data: b,
        success: c
    });
};
