$(document).ready(function () {

	$('nav a:first').addClass('current').click();

	function scroll() {			
		$('nav a, a.see_all').click( function() {
			var aHrefName = $(this).attr('href').substring(1);
			var headingPos = $('body').find('#' + aHrefName).offset().top;
			
			$('nav a').removeClass('current');
			
			$(this).addClass('current');
			
			if ($.browser.mozilla || $.browser.opera) {
				$('html:not(:animated)').animate({scrollTop: headingPos - 125}, 1000);
			}
			else if ($.browser.msie) {
				if ($.browser.version == '6.0') {
					$('html:not(:animated)').animate({scrollTop: headingPos}, 1000);
				}
				else {
					$('html:not(:animated)').animate({scrollTop: headingPos - 125}, 1000);
				}
			}
			else {
				$('body:not(:animated)').animate({scrollTop: headingPos - 125}, 1000);
			}
			return false;
		});
	}

	function scroll_on_refresh(){
		if ( $("header").offset().top > 0 ) {
			$('html, body').animate({
				scrollTop: 0
			});
		}
	}
		
	scroll();
	scroll_on_refresh();
	
	$('a.see_all').click( function (){
		if ($('.history').hasClass('maximized')) {
			$('.history').slideUp('slow');
			$(this).css({backgroundPosition : "left top"});
			$('.history').removeClass('maximized');
		}
		else {
			$('.history').addClass('maximized');
			$('.history').slideDown('slow');
			$(this).css({backgroundPosition : "left bottom"});
		}
	});
	
	$('.codecs li:last').css({margin: "0"});

});
