function DynamicField( globalName ) {
	this.globalName = globalName;
	this.inputElementId = null;
	this.inputElement = null;
	
	if( arguments.length > 2 ) {
		var temp = new Array();
		for( var index = 1; index < arguments.length; index++ )
			temp.push( arguments[ index ] );
		this.inputElementId = temp.join( ":" );
	} else if( arguments.length == 2 ) {
		this.inputElementId = arguments[ 1 ];
	}
	
	this.Initialize = function() {
		if( this.inputElementId === null ) return;
		
		var inputElements = this.inputElementId.split( ":" );
		
		if( inputElements.length > 1 ) {
			this.inputElement = new Array();
			for( var index in inputElements ) {
				var currentElement = document.getElementById( inputElements[ index ] );
				this.inputElement.push( currentElement );
				this.CaptureEvents( currentElement );
			}
		} else {
			this.inputElement = document.getElementById( inputElements[ 0 ] );
			this.CaptureEvents( this.inputElement );
		}
	}
	
	this.CaptureEvents = function( elementReference ) {
		elementReference.onfocus = new Function( "if(" + this.globalName + ".onfocus !== null) " + this.globalName + ".onfocus( this );" );
		elementReference.onblur = new Function( "if(" + this.globalName + ".onblur !== null) " + this.globalName + ".onblur( this );" );
		elementReference.onkeydown = new Function( "if(" + this.globalName + ".onkeydown !== null) " + this.globalName + ".onkeydown( this );" );
		elementReference.onchange = new Function( "if(" + this.globalName + ".onchange !== null) " + this.globalName + ".onchange( this );" );
		elementReference.onclick = new Function( "if(" + this.globalName + ".onclick !== null) " + this.globalName + ".onclick( this );" );
	}
	
	
	this.onfocus = null;
	this.onblur = null;
	this.onkeydown = null;
	this.onchange = null;
	this.onclick = null;
}




function ConditionalBlock( elementId, initialState ) {
	this.elementId = elementId;
	this.element = null;
	this.insertParent = null;
	this.insertPoint = null;
	this.initialState = ( initialState == undefined ? false : initialState );
	
	this.Initialize = function() {
		this.element = document.getElementById( this.elementId );
		this.insertParent = this.element.parentNode;
		this.insertPoint = this.element.nextSibling;
		
		// Detach the block from the form, if specified.
		if( ! initialState ) this.insertParent.removeChild( this.element );
	}
	
	this.Show = function() { if( this.element.parentNode == this.insertParent ) return; if( this.insertPoint === null ) this.insertParent.insertBefore( this.element, this.insertPoint ); else this.insertParent.appendChild( this.element ); }
	this.Hide = function() { if( this.element.parentNode != this.insertParent ) return; this.insertParent.removeChild( this.element ); }
}
