/**
 * $("form").getFormValues(); will return an key/value object that can be used with the Ajax.
 */
jQuery.fn.getFormValues = function(){
    var formvals = {};
    jQuery.each(jQuery(':input',this).serializeArray(),function(i,obj){
        if (formvals[obj.name] == undefined) {
            formvals[obj.name] = obj.value;
        } else if (typeof formvals[obj.name] != 'string') {
            formvals[obj.name].push(obj.value);
        } else {
            var first = formvals[obj.name];
            delete formvals[obj.name];
            formvals[obj.name] = new Array();
            formvals[obj.name].push(first);
            formvals[obj.name].push(obj.value);
        }
    });
    return formvals;
};
