function Module(name)
{
	this.ModInput = ModInput;
	this.ModInput();
	this.nm = name || 'module';
	this.objects = [];
	this.delMsg = 'Are you sure you wish to delete this item?'
	
	this.form = document.forms[this.form_name] || null;
	
	this.popUpReturn = function(location, name, attribs)
	{
		loc = location || '';
		nm = name || 'popUp';
		attr = attribs || 'width=400,height=200,left=200,top=100,resizable=yes,toolbar=no,scrollbars=auto,status=yes';
		obj = window.open(loc, nm, attr);
		return obj;
	}
	this.popUp = function(location, name, attribs)
	{
		this.popUpReturn(location, name, attribs);
	}
	this.closeNoAuth = function()
	{
		win = opener ? opener : window.opener ? window.opener : null;
		loc = window.location.toString();
		if(win && loc.indexOf('login') >= 0)
		{
			win.location = window.location;
			window.close();
		}
	}
	this.delConfirm = function(url)
	{
		if(confirm(this.delMsg) && url)
			window.location = url;
	}
	this.closeNoAuth();
		
	if(this.form)
	{
		with(this.form)
		{
			this.validator = new Validator(this.form);
			this.getObjectsFromFlds = function(arrayName, className)
			{
				arr = arrayName || null;
				classNm = className || null;
				objCounter = 0;
				if(arr && classNm)
				{
					this.objects[arr] = [];
					for(i = 0; i < this.form.elements.length; i++)
					{
						fld = this.form.elements[i];
						if(fld.name.indexOf(classNm) == 0)
						{
							if(fld.name.indexOf('_') != -1 && fld.name.lastIndexOf('_') != -1)
							{
								if(fld.name.indexOf(classNm + '_id') == 0)
								{
									this.objects[arr][objCounter] = eval('new ' + classNm + '(' + fld.value + ')');
									objCounter++;
								}
								else if(objCounter > 0)
								{
									start = fld.name.indexOf('_')+1;
									end = fld.name.lastIndexOf('_') - start;
									propName = fld.name.substr(start, end);
									this.objects[arr][objCounter-1][propName] = fld.value;
								}
							}
						}
					}
					return this.objects[arr];
				}
				else return null;
			}
			this._submit = function()
			{
				
				if(this.validator.validate())
				{
					submit();
					return true;
				}
				else return false;
			}
			this.submit = function()
			{
				if(this.form['wizard']) 
					wizard.value = 'false';
				this._submit();
			}
			this.wizard = function()
			{
				if(this.form['wizard']) 
					wizard.value = 'true';
				this._submit();
			}
		}
	}
}

