// ------------------------------------------------------------
// 
// ------------------------------------------------------------
$(document).ready(
	function() 
	{
		$("a").click(handleLinkClick);
	
		/* school nav */
		$("ul#nav-school-content li a.tab, ul#nav-group-content li a.tab").click(
			function ()
			{
				$("#content").removeClass();
				$("#content").addClass($(this).parent().attr("class"));
				
				return false;
			}
		);

		$("ul#nav-school-content li a.tab, ul#nav-group-content li a.tab").focus(
			function ()
			{
				this.blur();
				
				return false;
			}
		);
		
		/* group resources */
		$("dl#group-resources dt a").click(
			function ()
			{
				// console.log($(this).parent().parent()[0].tagName);
				
				$("#group-resources").removeClass();
				$("#group-resources").addClass($(this).parent().attr("class"));
				
				return false;
			}
		);

		$("dl#group-resources dt a").focus(
			function ()
			{
				this.blur();
				
				return false;
			}
		);
	}
);

// ------------------------------------------------------------
// 
// ------------------------------------------------------------
function handleLinkClick ()
{
	var href = $(this).attr("href");

	// console.log($(this).parent()[0].className);
	// console.log(self.location);
	
	if (
		(href.charAt(0) == "/" || href.substring(0, ("http://" + self.location.host).length).toLowerCase() == ("http://" + self.location.host)) &&
		(!$(this).parent().is(".link") && !$(this).parent().is(".attachment"))
	)
	{

	}
	else
	{
		// linking to a new site or attachment, spawn new window
		$(this).attr("target", "_blank");
	};
};

