var faqObject = function ( itemClass, switchClass, options ) {

	// Fields

	this.itemClass = itemClass;
	this.switchClass = switchClass;
	this.options = options;

	this.container = ( options.container )? ( ( options.container.nodeName )? options.container : document.getElementById( options.container ) ) : document.getElementsByTagName( "BODY" ).item( 0 );

	this.activeClass = ( options.activeClass )? options.activeClass : "active";
	this.inactiveClass = ( options.inactiveClass )? options.inactiveClass : "inactive";

	
	// Methods

	this.init = FAQO_init;
	this.switchFunc = FAQO_switchFunc;

	// Init object

	this.init();

}

var FAQO_init = function () {
	try {

		var faqItemList = getElementsByClassName ( this.container, this.itemClass );

		for ( var i = faqItemList.length; i-- > 0; ) {
			applyClassName ( faqItemList[ i ], this.inactiveClass, true );

			var switchList = getElementsByClassName ( faqItemList[ i ], this.switchClass );

			for ( var j = switchList.length; j-- > 0; ) {
				switchList[ j ].faqItem = faqItemList[ i ];
				switchList[ j ].faqObj = this;
				$addEventListener ( switchList[ j ], "click", FAQF_switch );
			}
			
		}

	} catch ( e ) {};
}

var FAQO_switchFunc = function ( switchNode ) {
	try {
		var isInactive = matchClassName ( switchNode.faqItem,  this.inactiveClass );

		applyClassName( switchNode.faqItem, this.activeClass, isInactive );
		applyClassName( switchNode.faqItem, this.inactiveClass, !isInactive );
	
	} catch ( e ) {};
}

var FAQF_switch = function () {
	try {
		var switchNode = this;
   		if ( !switchNode.nodeName ) switchNode = window.event.srcElement;
		
		switchNode.faqObj.switchFunc( switchNode );
	} catch ( e ) {};
}
