$(document).ready(function() {
	if ($('#thegraphwrap').length == 0){
		$('#carousel').carouselslide();
	}
	navtabs();
	
	$.each($('a.scrl'), function() {
		$(this).bind('click', gotohash);
	});
});

function gotohash(){
	$(window).scrollTo('#' + $(this).attr('href'), 1100);
	return false;
}
	


function navtabs(){
	// adds functionality to the tabs
	var locarray = (location.pathname).split("/");
	var loc = locarray[locarray.length - 1];
		
	$.each($('#navr a'), function(){
		
		if (loc == $(this).attr('href')){
			$(this).parent().addClass('current');
			$(this).parent().next().addClass('pnext');
			$(this).parent().prev().addClass('pprev');
		}
		
		var tabtitle = $(this).find('.title');
		var tabl = $(this).find('.hi .l');
		var tabr = $(this).find('.hi .r');
		
		if ($.browser.msie && $.browser.version < 8){
			$(this).find('.title').width(100);
		}
		
		$(this).find('.c').width($(this).find('.title').outerWidth() - tabl.outerWidth() - tabr.outerWidth());
		//$(tabtitle).css({'paddingRight' : $(this).find('.title').css('padding-right') - 5});
		//$(this).find('.hi .c').width($(this).outerWidth() - tabl.outerWidth() - tabr.outerWidth());
		
		if (!$(this).parent().hasClass('current')){
			$(this).bind('mouseenter', function(){
				if ($.support.opacity){
					$(this).find('.hi').stop().animate({'top' : 0, 'opacity' : 1}, 100, 'swing');
					$(this).find('.med').stop().animate({'top' : 0}, 100, 'swing');
				} else {
					$(this).find('.hi, .med').stop().animate({'top' : 0}, 100, 'swing');
					$(this).find('.hi').show();
				}
				$(this).find('.title').stop().animate({'paddingTop' : 8}, 100, 'swing');
			}).bind('mouseleave', function(){
				if ($.support.opacity){
					$(this).find('.hi').stop().animate({'top' : 8, 'opacity' : 0}, 100, 'swing');
					$(this).find('.med').stop().animate({'top' : 8}, 100, 'swing');
				} else {
					$(this).find('.hi, .med').stop().animate({'top' : 8}, 100, 'swing');
					$(this).find('.hi').hide();
				}
				$(this).find('.title').stop().animate({'paddingTop' : 11}, 100, 'swing');
			});
			
			$(this).find('.hi, .med').css({'top' : 8});
			$(this).find('.hi').css({'opacity' : 0});
			
			$(this).find('.title').css({'paddingTop' : 11});
		} else {
			$(this).find('.hi').hide();
		}
	});
	
	$('#navr li').first().addClass('first');
}
