/**
 * @author Justin Johnson <justin@fryewiles.com>, justin@booleangate.org
 * @version 0.0.2a 20070910 JJ
 */

toggle = function(expand_id) {
	var expand_content = $(expand_id);
	var next_class = 'hide-scrollers';
	
	if ( expand_content ) {
		var expand_link = $(expand_id + '-link');
		
		// Class modification HAIL ME!
		next_class = expand_link.innerHTML.toLowerCase().indexOf('close') != -1
						? 'hide-scrollers'
						: '';
		
		//Scriptaculous expand
		new Effect.toggle(
			expand_content, 
			'slide', 
			{
				duration: 0.5,
				afterFinish: function() {
					expand_content.className = next_class;
				}
			}
		);
		
		// Link title modification
		if ( expand_link.innerHTML.toLowerCase().indexOf('close') != -1 ) {
			if ( expand_link.rel != '' ) {
				expand_link.innerHTML = expand_link.rel;
			}
			else {
				expand_link.innerHTML = 'Click For More Info';
			}
			
			expand_content.className = 'hide-scrollers';
		}
		else {
			expand_link.innerHTML = 'click to close';
		}
	}
}