function FormKeeper(oForm, bUpdate, iMax) {

	this.oForm = oForm;
	this.aInputs = oForm.getElementsByTagName('input');	
	this.iMax = iMax || 1000;
		
	if(bUpdate) {
		this.setFromCookies();
	}
	
	var oThis = this;
	
	function processSubmit() {
	
		oThis.setFromForm();
	
	}
	
	Common.Event.add(
		oForm,
		'submit',
		processSubmit
		);

}

FormKeeper.prototype = {

	setFromForm : function() {
	
		var sValue = '';
	
		for(var i = 0; i < this.aInputs.length && i < this.iMax; i++) {
			
			sValue += i > 0? '|' : '';
			
			switch(this.aInputs[i].type.toLowerCase()) {							
			
				case 'checkbox':
					sValue += this.aInputs[i].checked? 1 : 0;
				break;
				
				default:
					sValue += this.aInputs[i].value;
				break;
			
			}			
		}
		
		Common.Cookie.set(this.oForm.id, sValue, '/');				
		
	},
	
	setFromCookies : function() {
	
		var
			sValue = Common.Cookie.get(this.oForm.id),
			aValue = []
			;
		
		if(!sValue) {
			return;
		}		
		
		aValue = sValue.split('|');
				
		for(var i = 0; i < this.aInputs.length && i < this.iMax; i++) {
						
			if(aValue[i]) {
						
				switch(this.aInputs[i].type.toLowerCase()) {						
			
					case 'checkbox':
						this.aInputs[i].checked = aValue[i] > 0? true : false;
					break;
				
					default:
						this.aInputs[i].value = aValue[i];
					break;
					
				}
			
			}
			
		}		
	
	}
		

};