function SubmitForm( formName, submitName ){
	var newField = document.createElement("INPUT");
	newField.setAttribute("type","hidden");
	newField.setAttribute("name",submitName);
	newField.setAttribute("value",'1');
	document.forms[formName].appendChild(newField);
	document.forms[formName].submit();
}

function BouilleSelect( id, count ){
	this.pos = 0;
	this.id = id;
	this.count = count;
	this.display = 8;
}

BouilleSelect.prototype.pageMove = function( delta ){
	if( delta > 1 ) delta = 1;
	if( delta < -1 ) delta = -1;
	this.move( delta * this.display );
}

BouilleSelect.prototype.move = function( delta ){
	if( this.pos > 0 && delta < 0 ){
		this.pos += delta;
	}else if( this.pos + this.display < this.count && delta > 0 ){
		this.pos += delta;
	}
	for( var i=0; i < this.pos; i++ ){
		document.getElementById( this.id + i ).style.display = 'none';
	}
	for( var i=this.pos; i < Math.min(this.pos + this.display,this.count) ; i++ ){
		document.getElementById( this.id + i ).style.display = 'block';
	}
	for( var i=this.pos + this.display; i < this.count; i++ ){
		document.getElementById( this.id + i ).style.display = 'none';
	}
}

function TemplateSelect( base, varName ){
	this.current = null;
	this.list = new Array();
	this.values = new Array();
	this.base = base;
	this.varName = varName;
}

TemplateSelect.prototype.register = function( n, val ){
	this.list.push( n );
	this.values[ n ] = val;
}

TemplateSelect.prototype.dsp = function( n ){
	if( this.current != null ){
		document.getElementById( this.base + this.current ).style.display = 'none';
	}
	this.current = n;
	document.getElementById( this.base + this.current ).style.display = 'block';
	document.getElementById( this.varName ).value = this.values[ n ];
}

TemplateSelect.prototype.move = function( delta ){	
	for( var n = 0; n < this.list.length; n++ ){
		if( this.list[n] == this.current ){
			if( n + delta < 0 ) return;
			if( n + delta >= this.list.length ) return;
			return this.dsp( this.list[ n + delta ] );
		}
	}
}

