/**
 * Provides some additional eye-candy on the faq pages
 * 
 * @copyright Scribendi Inc.
 * @author Dave Redfern
 * @requires Prototype 1.6
 * @requires Scriptaculous 1.8.1
 */
document.observe('dom:loaded', function(event){
	obj = $('wc_tool_after');
	if ( obj !== null ) {
		new Scribendi.WordCountWidget(obj);
	}
	
	$$('div.faqa').invoke('hide');
	
	$$('.faqq').each(function(object){
		object.addClassName('faqQuestion');
		object.observe('click', function(event){
			oObject = Event.element(event);
			oNext = oObject.next('div.faqa');
			oNext.toggle();
			if ( oNext.visible() ) {
				object.addClassName('faqQuestionDown').removeClassName('faqQuestionUp');
			} else {
				object.addClassName('faqQuestionUp').removeClassName('faqQuestionDown');
			}
		});
	});
	
	/* Expands an FAQ entry if an ident is present in the URI string */
	identPos = location.href.indexOf('#');
	if ( identPos > -1 ) {
		queryIdentPos = location.href.indexOf('?');
		if ( queryIdentPos === -1 ) {
			identLength = location.href.length;
		} else {
			identLength = queryIdentPos;
		}
		qIdent = location.href.substring(identPos+1, identLength);
		oObject = $(qIdent);
		if (  oObject !== null && oObject != 'undefined' ) {
			oObject.next('div.faqa').toggle();
			oObject.addClassName('faqQuestionDown').removeClassName('faqQuestionUp');
		}
	}
});