$('html').addClass('js');

$(window).load(function(){
	
	$("#content").show("drop", { direction: "up" }, 1000, function(){
		if ($.browser.msie && $.browser.version < 8) 
			$(this).fadeTo(250, 0.9);
	});
	$('.scroll').jScrollPane({ showArrows: true, scrollbarWidth: 22, maintainPosition: false });
	
	var html;
	var timeout;
	var id;
	var url;
	var link;
	
	$("#content")
		.ajaxStart(function(){
			$(this).clone().css('overflow', 'hidden')
				.insertAfter( $(this).hide() )
				.hide("drop", { direction: "down" }, 800, function(){
					$(this).remove();
				});
		})
		.ajaxStop(function(){
			// add div with pageid-background to show main image
			$("<div />").hide().attr('id', id + '-background').addClass('background')
				.appendTo("#wrap").fadeIn(2000, function(){
					$(document.body).attr('id', id); // swap body id
					if (id == 'accounting') $("#nav-accounting").removeClass('over'); // force remove of subnav bg
					$(this).remove(); // remove main image class, let body id take over from here
				});
				
			$(this).show("drop", { direction: "up" }, 1000, function(){
					if ($.browser.msie && $.browser.version < 8) 
						$(this).fadeTo(250, 0.9);
				})
				// re-attach jScrollPane to new content
				.find(".scroll").jScrollPane({ showArrows: true, scrollbarWidth: 22 });
				
			$("#nav a").removeClass('active');
			link.addClass('active');
		});
	
	/*$("#nav a, #logo a, #footer a").click(function(e){
		link = $(this);
		id = link.attr('id'); // get page id
		url = link.attr('href'); // get link url
		
		// make sure not the same page
		if (id != $(document.body).attr('id')) { 
			
			// handle subnav
			if (link.parent().hasClass('primary') || link.parent().attr('id') == 'footer-nav' || link.parent().attr('id') == 'logo' ) {
				if (id == 'accounting') {
					$("#nav-accounting").removeClass("up").addClass('over');
					$("#nav-accounting ul.secondary").slideDown();
				} else {
					$("#nav-accounting").addClass('over');
					$("#nav-accounting ul.secondary").slideUp("normal", function(){
						$("#nav-accounting").removeClass('over').addClass('up');
					});
				}
			}

			// AJAX get content
			$("#content .scroll").load(url + ' .scroll > *');
		}

		return false;
	});*/
});
