// Clear Search Fields
jQuery(document).ready(function($) {
    $("#site_search").focus(function(){$(this).val("");});
	$("#search_by_name").focus(function(){$(this).val("");});
	$("#browse_by_name").focus(function(){$(this).val("");});
});

// Navigation
$(document).ready(function() {
$("#top ul#navigation li:first-child").addClass("first-nav");
$("#top ul#navigation li:last-child").addClass("last-nav");
$("#content h1+h2").addClass("sub-heading");
});

// Adds class "last" on a table
$(document).ready(function() {
$("#content table tr:last-child").addClass("last");
$("#content table tr th:first-child").addClass("th-first");
$("#content table tr th:last-child").addClass("th-last");
$("#content table tr:even").addClass("even");
});

// Adds class "last" on a list item
$(document).ready(function() {
$("#footer #foot_right ul li:last-child").addClass("last");
});

// Adds class "first" on a list item
$(document).ready(function() {
$("#footer #foot_right ul li:first-child").addClass("first");
});

// Adds a class focus to input text when focused
function focusfix(selector, className) {
$(selector).focus(function() {
$(this).addClass(className);
});

// Removes class when focus is lost
$(selector).blur(function() {
$(this).removeClass(className);
});
}

jQuery(document).ready(function($) {
focusfix('input', 'focus');
});

jQuery(document).ready(function($) {
focusfix('textarea', 'focus');
});

jQuery(document).ready(function($) {
focusfix('select', 'focus');
});

// Filetype icons and external links
$(document).ready(function() {			
	// Add pdf icons to pdf links
	$("a[href$='.pdf']").addClass("pdf").attr("target", "_blank");	
	// Add email icons to email links
	$("a[href$='.doc']").addClass("doc").attr("target", "_blank");	
	// Add email icons to email links
	$("a[href^='mailto:']").addClass("email");
	//Add external link icon to external links - 
	$('a').filter(function() {
		//Compare the anchor tag's host name with location's host name
	    return this.hostname && this.hostname !== location.hostname;
	  }).addClass("external");	
	//}).addClass("external").attr("target", "_blank");	
	 
});

// Clear Search
function clearDefault(el) {
if (el.defaultValue==el.value) el.value = ""
}

//Bookmark
function bookmark()
{
bookmarkurl="http://www.nrh.ie"
bookmarktitle="Nation Rehabilitation Hospital"
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
else if (window.sidebar) // firefox
window.sidebar.addPanel(bookmarktitle, bookmarkurl, "");
}

//Print
function printpage() {
  window.print();
  }

