/* -- Homepage Tabs/Slideshow -- */
YAHOO.example = function() {
		var $D = YAHOO.util.Dom;
		var $E = YAHOO.util.Event;
		var $A = YAHOO.util.Anim;
		var $ = $D.get;
		var fStart = 1;
		var tempID;
		var tID;
		var anim = {};
		var tabs;
		var controlButton;
		anim.isAnimated = function() { return false; };
		return {
			init : function() {
				tabs = $('tab_nav').getElementsByTagName('li');
				controlButton = $('controller');
				YAHOO.util.Event.on(controlButton.id, 'click', this.pause);
				YAHOO.util.Event.on(tabs, 'click', function(){ clearTimeout(tID); controlButton.className="playit";} );
				YAHOO.util.Event.on(tabs, 'click', this.fade);
			},
			auto : function(e) {
				tID = window.setTimeout("YAHOO.example.auto()",4000);
				this.play();
			},
			play : function(e) {
				var feat = $('feature' + fStart);

				if( fStart <= tabs.length )
					YAHOO.example.fadeIn(feat);

				if( tempID && tempID != fStart ) {
					var prev = $('feature' + tempID);
					this.fadeOut(prev);
				}
				tempID = fStart;
				
				fStart == tabs.length ? fStart = 1 : fStart++;
			},
			pause : function(e) {
				if( controlButton.className == "pause" ) {
					clearTimeout(tID);
					controlButton.className="playit";
				} else {
					YAHOO.example.auto();
					controlButton.className="pause";
				}
			},
			fadeIn : function(e) {
				var attributes = {
					opacity : { from: 0, to: 100 }
				}
				
				anim = new $A(e, attributes, 4.5, YAHOO.util.Easing.easeIn);
				anim.onStart.subscribe(
					function(){ 
						e.style.display = 'block';
						addClassName( $('tab' + e.id.substring(7)), 'active');
					}
				)
				anim.animate();
			},
			fadeOut : function(e) {
				var attributes = {
					opacity : { to: 0 }
				}
				anim = new $A(e, attributes, 0.5, YAHOO.util.Easing.easeOut);
				anim.onComplete.subscribe(
					function(){ 
						e.style.display = 'none'; 
						removeClassName( $('tab' + e.id.substring(7)), 'active');
					}
				)
				anim.animate();
			},
			fade : function(e) {
				$E.stopEvent(e);

				if( this.id )
					e = this;

				var fID = e.id.substring(3);
				var feature = 'feature' + fID;
				var prev = 'feature' + tempID;
				tempID = fID;

				YAHOO.example.fadeOut( $(prev) );
				YAHOO.example.fadeIn( $(feature) );
			}
		};
	}();
YAHOO.util.Event.onAvailable('controller', YAHOO.example.init, YAHOO.example, true);
YAHOO.util.Event.onAvailable('controller', YAHOO.example.auto, YAHOO.example, true);


/* -- Seminar Tour Dates -- */
function seminar_links() {
	var table = $('seminar_dates');
	var rows = table.getElementsByTagName('tr');
	for( var i = 0, row; row = rows[i]; i++ ) {
		var to_go = row.getElementsByTagName('a');
		if( to_go[0] && to_go[0].href  && row.className != 'header' ) {
			addEvent(row,'mouseover', function(){ addClassName(this,'highlight'); this.title = this.getElementsByTagName('a')[0].title;} );
			addEvent(row,'mouseout', function(){ removeClassName(this,'highlight');} );
			addEvent(row,'click', function(){ window.location.href = this.getElementsByTagName('a')[0].href;} );
		}
	}
}