﻿/// <reference path="jquery-1.3.2-vsdoc.js" />
/// 自定义JQuery函数
jQuery.fn.outerHTML = function()
{
    return $('<div>').append(this.eq(0).clone()).html();
};
jQuery.fn.dragDrop = function()
{
    var s = this.get().reverse()[0];
    s.dragDrop();
}
jQuery.fn.dom = function()
{
    return this.get().reverse()[0];
}
jQuery.fn.AddOption = function(text, value, selected, index)
{
    option = new Option(text, value);
    this[0].options.add(option, index);
    this[0].options[index].selected = selected;
}
jQuery.fn.checked = function(bool)
{
    if (bool == null)
        return this.attr("checked");
    else
        this.attr("checked", bool);
}
jQuery.extend({
    postJSON: function(url, data, callback)
    {
        return this.post(url, data, callback, "json");
    },
    postJSONWS: function(url, data, callback)
    {
        var _data = "{}";
        if (typeof data == "function" && callback == null)
        {
            callback = data;
        }
        if (data != null && typeof data != "function")
        {
            _data = data;
        }
        return this.ajax({ contentType: "application/json", type: "POST", url: url, data: _data, dataType: "json", success: callback });
    },
    getXML: function(url, data, callback)
    {
        this.ajax({ type: "GET", url: url, dataType: "xml", data: data, success: callback });
    },
    postXML: function(url, data, callback)
    {
        this.ajax({ type: "POST", url: url, dataType: "xml", data: data, success: callback });
    }
});