﻿var NPform = function(fName, pId, eId, autoComplete, submitEvent, action, cl) {
    this.action = "";
    
    this.create = function(child, parent) {
        this.el = document.createElement("FORM");
        this.el.setAttribute("autocomplete", autoComplete || "off");
        this.el.setAttribute("action", this.action);
        this.el.setAttribute("method", "post");

        if (fName) {
            this.el.setAttribute("name", fName);
            this.el.setAttribute("id", fName);
        }
        if (cl)
            this.el.setAttribute("class", cl);

        this.el.appendChild(child);
        parent.appendChild(this.el);

        if (submitEvent) {
            this.el.onsubmit = submitEvent;
        }
    };
    this.init = function() {
        try {
            var el = document.getElementById(eId || "tbleftLogin");
            var parent = document.getElementById(pId || "leftlogin") || Ext.query("." + (pId || "leftlogin"))[0];

            if (!el || !parent)
                return;

            this.action = action || el.getAttribute("data");
            parent.removeChild(el);
            this.create(el, parent);
        }
        catch (e) { }
    }
    this.init();
}

try {
    $(document).ready(function() {
        var np_form = new NPform();
    });
}
catch (ex) {
    var np_form = new NPform();
}


