$(document).ready( function() {
	if($("body").hasClass("hp")) {
		/* uncomment to turn on HP splash image cycling
		$("#hp-splash").cycle({ 
			fx:     'none', 
			timeout: 5000
		});
		*/
		$("#events").hide();							
		$("#hp-bottom-recent-items").children().each( function() {
			var thisheight = $(this).height();
			var height = $("#hp-bottom-recent-items").height();
			if(thisheight > height) {
				$("#hp-bottom-recent-items").css("height",thisheight+"px");				
			}
			else {
				$("#hp-bottom-recent-items").css("height",height+"px");
			}
			if($("#hp-bottom-recent-items").height() < 80) {
				$("#hp-bottom-recent-items").css("height","80px");	
			}
		});
		$(".news,.events").click( function() {
			var active = $(this).hasClass("active");
			if(!active) {
				$(this).parent().children().each( function() {
					$(this).removeClass("active");										   
				});
				var id = $(this).attr("class");
				$(this).addClass("active");
				$("#hp-bottom-recent-items div:visible").fadeOut( function() { 
					$("#"+id).fadeIn();
			   });
			}
			return false;
		});
	}
	$("#searchtext").val("Search");
	$("#searchtext").focus( function() {
		if($(this).val() == "Search") {
			$(this).val("");	
		}
	});
	$("#searchtext").blur( function() {
		if($(this).val() == "") {
			$(this).val("Search");	
		}
	});	
	$("ul.sf-menu").supersubs({ 
            minWidth:    12,   // minimum width of sub-menus in em units 
            maxWidth:    27,   // maximum width of sub-menus in em units 
            extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
                               // due to slight rounding differences and font-family 
        }).superfish({autoArrows: false, speed: 'fast', delay: 250}).find('ul').bgIframe({opacity:false}); // call supersubs first, then superfish, so that subs are 
                         // not display:none when measuring. Call before initialising 
                         // containing tabs for same reason.
						 
	if( $("#tabs").length > 0) {
		$("#tabs").tabs();	
		$(".ui-tabs .ui-tabs-nav li:last").css("border-right-width","1px");
	}
	
});