$(document).ready(function(){
	
	//sIFR
	if(typeof sIFR == "function"){
		sIFR.replaceElement(named({sSelector:"#content div h1", sFlashSrc:"/resources/vag.swf", sColor:"#ffffff", sCase:"upper", sWmode:"transparent"}));
		sIFR.replaceElement(named({sSelector:"#content div h2", sFlashSrc:"/resources/vag.swf", sColor:"#ffffff", sCase:"upper", sWmode:"transparent"}));
		sIFR.replaceElement(named({sSelector:"#content div h3", sFlashSrc:"/resources/vag.swf", sColor:"#ffffff", sCase:"upper", sWmode:"transparent"}));
		sIFR.replaceElement(named({sSelector:"#content div h4", sFlashSrc:"/resources/vag.swf", sColor:"#ffffff", sCase:"upper", sWmode:"transparent"}));
	};
	
	// Build the navigation UI
	$("#navigation > ul > li").each(
		function(i) {
			//Check to see if the found element has a submenu
			if($(this).children('ul').length != 0) {
				//Hide the submenus by default
				$(this).children('ul').hide();
				$("> a", this).click(
					function() {
						return false;
					}
				);
				//Menu logic
				$(this).mouseover(
					function(){
						$(this).children('ul').show();
					}
				)
				$(this).mouseout(
					function(){
						$(this).children('ul').hide();
				})
			}
		}
	)
	
	//Convert rel="external" links to open in new window
	$('a[rel=external]').attr("title", function(){
		var oldtitle = $(this).attr("title");
		$(this).attr("title", oldtitle + " (opens in a new browser window)");
	})
	.click(function(){
		pageTracker._trackPageview("external/" + $(this).attr('title'));		
		window.open(this.href);
		return false;
	});
	
	//Track specific links...
	$('a[rel=contact]').click(function(){
		pageTracker._trackPageview("contact/" + $(this).attr('title'));
	});
	
});