/**
* AbstractWidget
*
* An interface for widget classes.  Defines the basic functionality of all Widgets.  Specialized widgets may have more functions or may 
* override functions as necessary
*
* Note.  Calling any of the member functions of the AbstractWidget will cause errors since the abstract widget has no members
**/
function AbstractWidget() { }

new AbstractWidget();

/**
* AbstractWidget.addContentNode
*
* Adds a content node to the content_array and the content_container of the Widget
*
* @param c The DOM object to add
**/
AbstractWidget.prototype.addContentNode = function( c ) { 

	this.content_array.push( c );
	this.content_container.appendChild( c );

}

/**
* AbstractWidget.removeContentNode
*
* Removes a specific content node from the content_array and the content_container of the Widget
*
* @param c The DOM object to remove
**/
AbstractWidget.prototype.removeContentNode = function( c ) { 

	this.content_container.removeChild( c );

	for ( var i=0; i<this.content_array.length; i++ ) { 
		if ( this.content_array[i] == c ) this.content_array.splice( i, 1 );
	}

}

/**
* AbstractWidget.removeLastContentNode
*
* Removes the last content node added which will be the last element of the content_array
*
* @returns The element removed, false if no elements left
**/
AbstractWidget.prototype.removeLastContentNode = function() { 

	if ( this.content_array.length > 0 ) { 

		var node_to_remove = this.content_array.pop();
		this.content_container.removeChild( node_to_remove );
		return node_to_remove;

	}
	return false;

}

/**
* AbstractWidget.removeFirstContentNode
*
* Remove the first content node added which will be the element on top of the content_array
*
* @returns The element removed, false if no elements left
**/
AbstractWidget.prototype.removeFirstContentNode = function() { 

	if ( this.content_array.length > 0 ) { 

		var node_to_remove = this.content_array[0];
		this.content_array.splice( 0, 1 );
		this.content_container.removeChild( node_to_remove );
		return node_to_remove;

	}
	return false;

}

/**
* AbstractWidget.clearContents
*
* Clears out the content container and the content array
**/
AbstractWidget.prototype.clearContents = function() { 

	//this.content_container.childNodes.length = 0;
	//this.content_array = new Array();
	while( this.content_container.childNodes[0] ) 
		this.content_container.removeChild( this.content_container.childNodes[0] );
	this.content_array = new Array();

}

/**
* AbstractWidget.getWidgetDOM
*
* @returns the container
**/
AbstractWidget.prototype.getWidgetDOM = function() { 

	return this.container_dom;

}

/**
* AbstractWidget.setWidgetWidth
*
* @param w The width to force the widget to
**/
AbstractWidget.prototype.setWidgetWidth = function( w ) { 

	this.container_dom.style.width = w;

}

/**
* AbstractWidget.setWidgetHeight
*
* @param h The height to force the widget to
**/
AbstractWidget.prototype.setWidgetHeight = function( h ) { 

	//alert( h );
	this.container_dom.style.height = h;

}

/**
* AbstractWidget.setWidgetStyle
*
* Dangerous! Use sparingly! Allows direct modification of any style element of the widget.  Uncontrolled modifications may cause unexpected results
*
* @param style_element The style element you are modifying
* @param style_value The value you are setting the style element to
**/
AbstractWidget.prototype.setWidgetStyle = function( style_element, style_value ) { 

	this.container_dom.style[style_element] = style_value;

}


