$(function() 
{
	function equalHeight(classRef) {
	
		var tallest = '';

		$(classRef).each(function(){
			if ($(this).outerHeight() > tallest)
				tallest = $(this).outerHeight();
			
		});
		
		tallest = tallest - 60;

		if($.browser.msie && $.browser.version.substr(0,1) == "6") {
				$('#tab-nav').height(tallest);
				$('#main').height(tallest);
			}
		else {
			$('#tab-nav').css("min-height", tallest);
			$('#main').css("min-height", tallest);
		}
	}
	
	if ($('.equal').length) equalHeight('.equal');
	
	
	/*** 
    * Twitter feed
 	*/	
 	
	$('.twitter-feed').rssfeed('http://twitter.com/statuses/user_timeline/25982226.rss', {
    	limit: 3,
    	header: false
  	});
  	
  	$('.twitter-selector a').click(function(){
  		
  		$('.twitter-feed').rssfeed($(this).attr('href'), {
	    	limit: 3,
	    	header: false
	  	});
	  	
	  	$('#twitter-icon').attr('href', 'http://twitter.com/'+$(this).html());
	  	
	  	return false;
  	
  	});
  	
  	/*** 
    * Homepage Slider
 	*/	
 	
  	if($('#banner').length) {
  	
	  	function addNav() {
	  		$('#banner').prepend('<ul id="navigation"></ul>');  	
	  		var count = $('#slides li').size();
	  		for(var i = 1; i <= count; i++) {
	  			$('#navigation').append('<li><a href="#">' + i + '</a></li>');	
	  		}
	  		$('#navigation li').eq(0).addClass('active');
	  	}
	  	
	  	if($('#slides li').size() > 1) {
	  	
		  	addNav();
		  	
		  	 $('#banner').serialScroll({
		        target:'#slide-wrapper',
		        items:'li', // Selector to the items ( relative to the matched elements, '#sections' in this case )
		        axis:'x',// The default is 'y' scroll on both ways
		        navigation:'#navigation li a',
		        duration:700,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
		        force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
		        interval:6000, 
		        stop:true,
		        lock:false,
		        onBefore:function( e, elem, $pane, $items, pos ){
		            e.preventDefault();
		            if( this.blur )
		                this.blur();
		         
				  $('#navigation li.active').removeClass('active'); 
		          $('#navigation li').eq(pos).addClass('active'); 
		        },
		        onAfter:function( elem ){

		        }
		    });
    
    	}
    }
    
    /*** 
    * A really really hacky workaround for an IE 6 redraw bug
 	*/	
 	
    if (jQuery.browser.msie && parseInt(jQuery.browser.version) == 6) 
    	$("#newsletter").resize(function(e) { $("#footer-nav").hide().show(); });	
});
