//USED FOR TWITTER SCROLLER
var tweet_count;
var tweet_interval;
var old_tweet = 0;
var current_tweet=0;
var dur=5000;
var timer=0;

$j(document).ready(function() {
	
	
	//set up the over effect on the menu items.
 	$j("#navigation li a").each(function (i) {
		$j(this).mouseenter(function() {
	 		$j(this).animate({ paddingLeft: '10px', queue:true },250)	
	 	});
	 	
	 	$j(this).mouseleave(function() {
	 		$j(this).animate({ paddingLeft: '4px' },250)
	 	});
	});
	
	//for each element in the main content, fade in one by one increasing the delay by 190ms for each element
	$j("#content *").each(function (i) {
			$j(this).fadeTo(0,0);
			
			//this fixes the cleartype font problem.
			if(this.id!='nofade') {
				if($j(this).css("background-color")=="transparent") {			
					$j(this).css("background-color","#FFFFFF");
				}
			}
			
			//now we've hidden all the sub elements, show the main container again
			$j('.container').show();
			
			//now one by one, load in the elements
			$j(this).delay(timer).fadeTo(dur,1);
			
			timer += 100;
	});
	
	$j("#contentSearch").each(function (i) {
			//now we've hidden all the sub elements, show the main container again
			$j('.container').show();
	});
	
	//set up twitter
	if( $j("div.twitterScroller")) {
		tweet_count = $j("div.twitterScroller").size();
		$j("div.twitterScroller:eq("+current_tweet+")").css('top','0px');
		  
		tweet_interval = setInterval(tweet_rotate,5000); //time in milliseconds
	}
	
	if($j('#sec_header')) {
		$j('#sec_header').innerfade({
			speed: 3000,
			timeout: 5000,
			type: 'sequence',
			containerheight: '601px'
		});
		
	}
	
	
});

if(sIFR) {
		// Do sIFR
		var futuralight = {src: 'flash/FuturaLightBT.swf'};
		sIFR.activate(futuralight);
		
		sIFR.replace(futuralight, {
			selector: 'h2',
			css: [ '.sIFR-root { font-size: 30px; color: #4aabd9; text-transform: lowercase; }' ]
		});

}



function tweet_rotate() {
	current_tweet = (old_tweet + 1) % tweet_count; //remainder will always equal old_tweet until it reaches tweet_count - at which point it becomes zero. clock arithmetic
	$j("div.twitterScroller:eq(" + old_tweet + ")").animate({top: 250},"slow", function() {
		$j(this).css('top','-250px');
	});
	$j("div.twitterScroller:eq(" + current_tweet + ")").show().animate({top: 0},"slow");  
	old_tweet = current_tweet;
}
