function formGen(a,m,w,p) {
	this.pcol = ['AFAFAF','DCDCDC']
	this.scol = ['FF7D65','FFAA92']
	this.elem = []
	this.buta = []
	this.cont = 1
	this.width = w
	this.percent = p
	this.action = a
	this.method = m ? m : "post"

	// External properties: 
	// this.onsubmit
	
this.render = function () {
		var i
		var s = ''
		var t = ''

		for (i = 0; i < this.buta.length; i++) {
			t += this.buta[i] + " "
		}

		s += '<form action="' + this.action + '" method="' + this.method + (this.onsubmit ? '" onSubmit="' + this.onsubmit : "") + '">'
		s += '<table cellpadding=3 cellspacing=0 border=0 ' + (this.width ? ' width=' + this.width : '') + '>'

		for (i = 0; i < this.elem.length; i++) {
			s += this.elem[i]
		}

		s += (t == '' ? '' : this.TR('',this.TD(' align="right" colspan=2' + this.PC(),t)))
		s += '</table>'
		s += '</form>'
		document.write(s)
	}


this.date = function (sn,n,date) {
		var m
		var d
		var y
		var v = date.split("-")

		var i
		var w = ['xx','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31']

		y = 'year: <select name="y_' + sn + '" size=1><option' + ("undefined" == typeof(v[0]) ? ' selected' : '') + ' value=0></option>'
		for (i = 2004; i <= 2020; i++) {
			y += '<option' + (i == v[0] ? ' selected' : '') + ' value=' + i + '>' + i + '</option>'
		}
		y += '</select>'

		m = 'month: <select name="m_' + sn + '" size=1><option' + ("undefined" == typeof(v[1]) ? ' selected' : '') + ' value=0></option>'
		for (i = 1; i <= 12; i++) m += '<option' + (i == v[1] ? ' selected' : '') + ' value=' + w[i] + '>' + w[i] + '</option>'
		m += '</select>'

		d = 'day: <select name="d_' + sn + '" size=1><option' + ("undefined" == typeof(v[2]) ? ' selected' : '') + ' value=0></option>'
		for (i = 1; i <= 31; i++) d += '<option' + (i == v[2] ? ' selected' : '') + ' value=' + w[i] + '>' + w[i] + '</option>'
		d += '</select>'

		this.elem[this.elem.length] = this.TR('',this.TDPC(n) + this.TDSC(m + "&nbsp;" + d + "&nbsp;" + y))
	}

this.titl = function (n) {
		this.elem[this.elem.length] = this.TR('', this.TD('colspan=2' + this.PC() ,"<strong>" + n + "</strong>"))
	}

this.text = function (sn,n,v,w) {
		var s = ''
		s += '<input type="TEXT" name="' + sn + '" id="' + sn + '" value="' + v + '" size="' + w + '" maxlength="' + w + '">'
		this.elem[this.elem.length] = this.TR('', this.TDPC(n) + this.TDSC(s))
	}

this.memo = function (sn,n,v,r,c) {
		var s = ''
		s += '<textarea wrap="soft" rows=' + r + ' cols=' + c + ' name="' + sn + '">' + v + '</textarea>'
		this.elem[this.elem.length] = this.TR('', this.TDPC(n) + this.TDSC(s))
	}
	
this.sets = function (sn,n,v,a,attribs) {
		var i
		var c
		var vSet = new Object
		var aCode = new Object
		var re1 = / /g
		var re2 = /_/g

		this.elem[this.elem.length] = this.TR('',this.TDPC(n) + this.TDSC(""))
		
		var pcol = this.PC()
		var scol = this.SC()

		for (i = 0; i < a.length; i++) aCode[i] = a[i].replace(re1,"_")
		for (i = 0; i < v.length; i++) vSet[v[i].replace(re1,"_")] = 1

		for (i = 0; i < a.length; i++) {
			c = ""
			if (aCode[i] in vSet) c = " checked"
			this.elem[this.elem.length] = this.TR('',this.TD(' valign="top" align="right"' + pcol,a[i].replace(re2," ")) + this.TD(' align="left"' + scol,'<input type="checkbox"' + c + ' name="' + sn + aCode[i] + '" value="set">' + (attribs ? attribs[i] : "")))
		}
		if (a.length == 0) this.elem[this.elem.length] = this.TR('',this.TD(' align="right"' + pcol,"none") + this.TD(' align="left"' + scol,""))
	}

this.dlst = function (sn,n,v,a) {
		var s = ''
		var i
		s += '<select name="' + sn + '" size=1>'
		for (i = 0; i < a.length; i++) {
			s += '<option' + ((i == v) ? ' selected' : '') + ' value=' + i + '>' + a[i] + '</option>'
		}
		s += '</select>'
		this.elem[this.elem.length] = this.TR('',this.TDPC(n) + this.TDSC(s))
	}

this.radi = function (sn,n,v,a) {
		var s = ''
		var i
		for (i = 0; i < a.length; i++) {
			s += '<input type="radio"' + ((a[i] == v) ? ' checked' : '') + ' name="' + sn + '" value="' + a[i] + '">'
			s += (a[i] == "" ? "" : ':') + a[i] + '&nbsp;'
		}
		this.elem[this.elem.length] = this.TR('',this.TDPC(n) + this.TDSC(s))
	}

this.cbox = function (sn,n,v,a) {
		var s = ''
		var i
		var j
		var c

		for (i = 0; i < a.length; i++) {
			for (c = "", j = 0; j < v.length; j++) {
				if (i == parseInt(v[j])) {
					c = " checked"
					break
				}
			}

			s += '<input type="checkbox"' + c + ' name="' + sn + '" value="' + i + '">'
			s += ':' + a[i] + '&nbsp;'
		}
		this.elem[this.elem.length] = this.TR('',this.TDPC(n) + this.TDSC(s))
	}

this.hidn = function (sn,v) {
		this.elem[this.elem.length] = '<input type="HIDDEN" name="' + sn + '" value="' + v + '">'
	}

this.butn = function (sn) {
		this.buta[this.buta.length] = '<input type="submit" name="action" value="' + sn  + '"' + (sn == 'Save' ? ' accesskey="S"' : '') + '>'
	}

this.ibtn = function (sn,ref) {
		this.elem[this.elem.length] = this.TR('',this.TD('colspan=2 align="right"' + this.PC(),'<a name=' + ref + '><input type="submit" name="action" value="' + sn  + '" >'))
	}

this.pass = function (sn,n,v,w) {
		var s = ''
		s += '<input type="PASSWORD" name="' + sn + '" value="' + v + '" size="' + w + '" maxlength="' + w + '">'
		this.elem[this.elem.length] = this.TR('', this.TDPC(n) + this.TDSC(s))
	}

this.cons = function (n,v) {
		this.elem[this.elem.length] = this.TR('', this.TDPC(n) + this.TDSC(v))
	}

this.PC = function () { /* Primary Color */
		return ' bgcolor="' + this.pcol[(++this.cont % 2)] + '"'
	}

this.SC = function () { /* Secondary Color */
		return ' bgcolor="' + this.scol[(this.cont % 2)] + '"'
	}
	
this.TDPC = function (str) {
		var aux
		aux = '<td class="form" valign="top" align="right"' + this.PC() + (this.percent ? ' width="' + this.percent + '%"' : '') + '>' + str + '</td>'
		return aux
	}

this.TDSC = function (str) {
		var aux
		aux = '<td class="form" align="left"' + this.SC() + '>' + str + '</td>'
		return aux
	}

this.TD = function (strAtr,str) {
		var aux
		aux = '<td class="form"' + strAtr + '>' + str + '</td>'
		return aux
	}
 
this.TR = function (strAtr,str) {
		var aux = ''
		aux += '<tr' + strAtr + '>'
		aux += str
		aux += '</tr>'
		return aux
	}

//////

this.drop = function (sn,n,v,a_disp,a_code) {
		var s = ''
		var i
		s += '<select name="' + sn + '" size=1>'
		if (a_code) {
			for (i = 0; i < a_disp.length; i++) {
				s += '<option' + ((a_code[i] == v) ? ' selected' : '') + ' value="' + a_code[i] + '">' + a_disp[i] + '</option>'
			}
		} else {
			for (i = 0; i < a_disp.length; i++) {
				s += '<option' + ((a_disp[i] == v) ? ' selected' : '') + '>' + a_disp[i] + '</option>'
			}
		}

		s += '</select>'
		this.elem[this.elem.length] = this.TR('',this.TDPC(n) + this.TDSC(s))
	}

this.set2 = function (sn,n,v,a,itemsPerRow) {
		var i
		var c
		var s = ""
		var vSet = new Object
		var aCode = new Object

		for (i = 0; i < a.length; i++) aCode[i] = a[i].replace(/ /g,"_")
		for (i = 0; i < v.length; i++) vSet[v[i].replace(/ /g,"_")] = 1

		for (i = 0; i < a.length; i++) {
			c = ""
			if (aCode[i] in vSet) c = " checked"
			s += a[i].replace(/_/g," ") + '<input type="checkbox"' + c + ' name="' + sn + aCode[i] + '" value="set">' + (i % itemsPerRow == (itemsPerRow - 1) ? "<br />" : " &nbsp; ")
		}
		if (a.length == 0) s = "none"
		
		this.elem[this.elem.length] = this.TR('',this.TDPC(n) + this.TDSC(s))
	}

}

