/**
 * Opens link in new window.
**/
$(document).ready(function() {
   onLoadFunctionality();
});

/**
 * Clears text from an input field.
**/
function clearText(thefield) {
  if (thefield.defaultValue==thefield.value) { thefield.value = "" }
} 

/**
 * Replaces text in an input field.
**/
function replaceText(thefield) {
  if (thefield.value=="") { thefield.value = thefield.defaultValue }
}


// Only put functionality in here that should be updated when a page is refreshed.
// Also updated during ajax calls.
function onLoadFunctionality() {
   // Script to make the first item in the breadcrumb grab more attention.
   $('#breadcrumb a:eq(0)').wrap('<h2>');

	// If there's no link, then there's only one item so we have to account for that.
   if(!$('#breadcrumb a:eq(0)').attr('href')) { 
	   $('#breadcrumb span:eq(0)').wrap('<h2>');
    } else {
	   $('#breadcrumb a:eq(0)').wrap('<h2>');
    }
   
   $('a.new-window').click(function() {
      window.open(this.href);
      return false;
   });
}