    /* Original Functions */
    $.fn.setFocus = function(e)
        {
        if (document.getElementById(e))
            document.getElementById(e).focus();
        return this;
        };


    $.fn.ajaxSubmit = function(e)
        {
        /* Change a form's submission type to ajax */
        this.submit(function()
            {
            var params = {};
            var IncCounter = 0;
            var OldArrayName = "";
            var thisParam = "";
            params['call'] = 'ajax';
            $(this).find("input[@checked], input[@type='text'], input[@type='hidden'], input[@type='password'], input[@type='submit'], option[@selected], textarea").each(function()
                {
                ArrayName = this.name || this.id || this.parentNode.name || this.parentNode.id || this.parentNode.parentNode.name || this.parentNode.parentNode.id;
                thisParam = params[ArrayName];
                if (thisParam == null)
                    {
                    thisParam = new Array(1);
                    thisParam[0] = this.value;
                    OldArrayName = ArrayName;
                    }
                else
                    {
                    thisParam.length = thisParam.length + 1;
                    thisParam[thisParam.length - 1] = this.value;
                    }
                params[ArrayName] = thisParam;
                });
            $("body").addClass("curWait");


            $.post(this.getAttribute("action"), params, function(xmldata, textStatus)
                {
                //alert(textStatus);    
                $("body").removeClass("curWait");
                strError = "Unable to submit form. Please try again later.";
                oFocus = null;

                $("AjaxResponse", xmldata).each(function()
                    {
                    var AjaxResp = this;
                    $(document).find("input[@type='checkbox'], input[@type='image'], input[@type='radio'], input[@type='text'], input[@type='password'], select, textarea").each(function()
                        {

                        if (this.name == null)
                            {
                            if (this.parentNode.name > 0 && AjaxResp.getAttribute(this.parentNode.name) != null)
                                {
                                $(this).addClass("fielderror");
                                $("div.error_" + this.name).html(AjaxResp.getAttribute(this.name));
                                }
                            }
                        else if (this.name.length > 0 && AjaxResp.getAttribute(this.name) != null)
                            {
                            $(this).addClass("fielderror");
                            $("div.error_" + this.name).html(AjaxResp.getAttribute(this.name));
                            }
                        else
                            {
                            $(this).removeClass("fielderror");
                            $("div.error_" + this.name).html("");
                            }
                        });

                    strRedirect = this.getAttribute("redirecturl");
                    strError = this.getAttribute("error");
                    oFocus = this.getAttribute("focus");
                    });
                if (strError.length == 0)
                    {
                    window.location = strRedirect;
                    }
                else
                    {
                    $("div.formErrors").html("<ul>" + strError.replace(/(\t)(.+)/g, "<li>$2<\/li>") + "<\/ul>").filter(":hidden").fadeIn("normal");
                    try
                        {
                        if (oFocus) $("#" + oFocus).get(0).focus();
                        }
                    catch(e)
                        {
                        }
                    ;
                    }
                }, "xml");

            try
                {
                post_form_submit();
                }
            catch(e1)
                {
                }

            return false;
            });

        return this;
        };


    $.fn.ajaxSubmitAll = function(e)
        {
        /* Change a form's submission type to ajax */
        this.submit(function()
            {
            var params = {};
            var IncCounter=0;
            var OldArrayName="";
            var thisParam="";
            params['call'] = 'ajax';

            $(document).find("input[@checked], input[@type='text'], input[@type='hidden'], input[@type='password'], option[@selected], textarea").each(function()
                {
                ArrayName= this.name || this.id || this.parentNode.name || this.parentNode.id || this.parentNode.parentNode.name || this.parentNode.parentNode.id;


                if(ArrayName==OldArrayName)
                    {
                    // Add to the array
                    thisParam.length= thisParam.length+1;
                    thisParam[thisParam.length-1]=this.value;
                    }
                else
                    {
                    thisParam = new Array(1);
                    thisParam[0]=this.value;
                    OldArrayName = ArrayName;
                    }

                params[ArrayName] = thisParam;
                });
            $("body").addClass("curWait");

            //$.post(this.getAttribute("action") + "?call=ajax", params, function(xml)
            $.post(this.getAttribute("action"), params, function(xml, textStatus)
                {
                //alert(textStatus);
                $("body").removeClass("curWait");
                strError = "Unable to submit form. Please try again later.";
                oFocus = null;

                $("AjaxResponse", xml).each(function()
                    {
                    var AjaxResp = this;
                    $(document).find("input[@type='checkbox'], input[@type='image'], input[@type='radio'], input[@type='text'], input[@type='password'], select, textarea").filter(":enabled").each(function()
                        {
                        if (this.name == null)
                            {
                             if (this.parentNode.name > 0 && AjaxResp.getAttribute(this.parentNode.name) != null)
                                 {
                                 $(this).addClass("fielderror");
                                 $("div.error_"+this.name).html(AjaxResp.getAttribute(this.name));
                                 }
                            }
                        else if (this.name.length > 0 && AjaxResp.getAttribute(this.name) != null)
                            {
                            $(this).addClass("fielderror");
                            $("div.error_"+this.name).html(AjaxResp.getAttribute(this.name));
                            }
                        else
                            {
                            $(this).removeClass("fielderror");
                            $("div.error_"+this.name).html("");
                            }
                        });

                    strRedirect = this.getAttribute("redirecturl");
                    strError = this.getAttribute("error");
                    oFocus = this.getAttribute("focus");
                    });
                if (strError.length == 0)
                    {
                    window.location = strRedirect;
                    }
                else
                    {
                    $("div.formErrors").html("<ul>" + strError.replace(/(\t)(.+)/g, "<li>$2<\/li>") + "<\/ul>").filter(":hidden").fadeIn("normal");
                    //if (oFocus) $("#" + oFocus).get(0).focus();
                    }
                }, "xml");
            return false;
            });

        return this;
        };