/* ---------- Link Outline Fix ---------- */
linkBlur = function() {
	$('a').focus(function() {
		$(this).blur();
	});
};

$(document).mousedown(function() {
	linkBlur();
});

/* ---------- 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').hide();
		$('#content3').hide();
		$('#content4').hide();	
		$('#content5').hide();		
		$('#tabs').css({ display: "block" });
	}
	//$('#leftColumn a').not('.active').css({ opacity: "0.5" });
});


/* ---------- Display JavaScript Enabled Styles ---------- 
$(document).ready(function() {
	$('#leftColumn').hover(function() {
		$('#leftColumn a').not('.active').css({ opacity: "1" });
	},
	function() {
		$('#leftColumn a').not('.active').css({ opacity: "0.5" });
	});

});
*/


/* ---------- RileyBook Hover ---------- */
$(document).ready(function() {
	$('#rileyBook').hover(function() {
		$(this).children('img').attr('src','/images/powered-by-rileybook-hover.png');
	},
	function() {
		$(this).children('img').attr('src','/images/powered-by-rileybook.png');
	});
});


/* ---------- 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).slideUp(500);
			// set timeout to allow animation to complete
			setTimeout(
				function() {
					// show new content
					$(newContent).slideDown(500);
				},
				600
			);
		}
		// set old content to be equal to new content
		oldContent = newContent;
		oldTab = newTab;
		return false;
	});
});