/* ---------- Hide Flash Of Unstyled Content ---------- */
$('html').addClass('js');
$(document).ready(function() {
	$('html').removeClass('js');
});


/* ---------- Display JavaScript Enabled Styles ---------- */
$(document).ready(function() {
	// check to see if TABS <div> exists
	if($('#tabs').length > 0) {
		// add javascript enabled styles
		$('#content h2').hide();
		$('#tab1').addClass('active');
		$('#content2').css('visibility', 'hidden');
		$('#content3').hide();
		$('#content4').hide();	
		$('#content5').hide();		
		$('#tabs').css({ display: "block" });
	}
});


/* ---------- Show Hide Tabs Content ---------- */
$(document).ready(function() {
	// define function variables
	var oldTab     = "#tab1";
	var oldContent = "#content1";
	var newTab     = "";
	var newContent = "";
	// show / hide content function
	$('#tabs a').click(function() {
		// assign selected tab <div> to variable
		newTab = "#"+$(this).attr('id');
		// select content <div> that coresponds with clicked tab <div>
		switch (newTab) {
			case "#tab1":
			newContent = "#content1";
			break;
			case "#tab2":
			newContent = "#content2";
			break;
			case "#tab3":
			newContent = "#content3";
			break;
			case "#tab4":
			newContent = "#content4";
			break;
			case "#tab5":
			newContent = "#content5";
			break;
		}
		// switch highlighted tab
		$(oldTab).removeClass('active');
		$(newTab).addClass('active');
		if($('#tabs.animate').length < 1) {
			// hide old content
			$(oldContent).hide();
			// set timeout to allow animation to complete
			setTimeout(
				function() {
					// show new content
					$(newContent).show();
				},
				100
			);
		}
		else {
			// hide old content
			$(oldContent).fadeOut(500);
			// set timeout to allow animation to complete
			setTimeout(
				function() {
					// show new content
					$(newContent).fadeIn(500);
				},
				600
			);
		}
		// set old content to be equal to new content
		oldContent = newContent;
		oldTab = newTab;
		return false;
	});
});
