//jQuery dom ready
$(document).ready(function() {
	// add class "last" to the last li in any list.  Used as a styling hook since :last-child isn't widely supported via css.  thank you jquery.
    $("ul#nav ul li:last-child").addClass("last");
	$("#local-nav h3:last-child").addClass("last");
	
	// apply automatic input clearing to the search input
	$(".searchform input").inputClear();

	// open links outside of domain in a new window by adding target="_blank" to URL	
	var myURL = window.location.host;
  //$('a[href^=http://]').attr('target','_blank');
	$('a[href^=http://]').not('[href*='+myURL+']').attr('target','_blank');

	
	// MAIN MAVIGATION: add class to drop downs for IE <6
	if(document.all){
	    $("#nav li").hover(
			function() { $(this).addClass("over"); },
			function() { $(this).removeClass("over"); }
	    );
	}// if document.all
	
	// show drops on focus
	$("#nav a").focus(function(){ $(this).parents("li").addClass("over"); })
				.blur(function(){ $(this).parents("li").removeClass("over"); });
	$("#nav>li").mouseover(function() { $("#nav>li").not($(this)).removeClass("over"); });

	//LOCAL NAVIGATION: show/hide second level navigation 
	//$('.level2').hide();
	//$('#local-nav h3').addClass("close");
	//$('#local-nav h3').toggle(
	//	function() {
	//	   $(this).next('.level2').fadeIn();
	//		 $(this).addClass('close');
	//	},
	//	function() {
	//		  $(this).next('.level2').fadeOut();
	//			$(this).removeClass('close');
	//	 }
	//); // end toggle
	
	// init email a friend
	if(typeof tb_init != "undefined") {
		tb_init('#links a.email');
	}
	
	// init print
	$("#links a.print").click(function(){ window.print(); return false; });
	
	$(".footer ul.links:first").addClass("noprint");
	
});// goodnight, jQuery

/* fix to support <abbr> in IE */
document.createElement("abbr");

// clear search field on click
jQuery.fn.inputClear = function() {
	return this.focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
};

$(document).ready(function() {
	$(".meridian h5").click( function(){ window.location = "http://www.meridianhealth.com/";});
});
