// return today's date in human-readable format.
	function today(){
		var d = new Date(); 
		var day = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); 
		var month = new Array("January","February","March","April","May","June","July","August","September","October","November","December"); 
		var time = "";
		var hours = d.getHours();
		var ampm = " am";
		var mins = d.getMinutes();
		if(hours > 12) {
			hours = hours-12;
			ampm = " pm";
		} else if (hours == 12) {
			ampm = " pm";
		} else if(hours == 0) {
			hours = 12;
		}
		if(mins < 10) {
			mins = "0" + mins;
		}
		return day[d.getDay()]+", "+month[d.getMonth()]+" "+d.getDate()+", "+d.getFullYear();
	};
// trim whitespace from beginning and end of strings.
	function trim(str) {
		str = this != window? this : str;
		return str.replace(/^\s+/g,'').replace(/\s+$/g,'');
	};
// remove empty ad units from the page flow
	function stripUnusedAds(){
		if(!document.getElementsByTagName) return false;
		var images = document.getElementsByTagName('img');
		for(var i=0; i<images.length; i++){
			if((images[i].getAttribute('width')=='2')&&(images[i].getAttribute('height')=='2')){
				var wrapper = images[i].parentNode.parentNode;
				wrapper.setAttribute('style','display:none');
			}
		}
	};
// functions that need to be called on page load go here
	// jquery functions need to be called here rather than using $(document).ready() to avoid the document.write clash
	// see http://jquery.com/discuss/2006-April/000578/
	window.onload=function(){
		/* ----- cygnus standard stuff ----- */
			P7_autoHide('cygnus_menu');
		/* ----- DOM stuff ----- */
			// remove empty ad units from the page, collapses the space as a whole.
//			stripUnusedAds();
			
			sfHover = function() {
	var sfEls = document.getElementById("navigation").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
		/* ----- jQuery code ----- */
/*			// manage second level navigation drop-downs
			$('ul.subnav').hide();
			$('ul.subnav2').hide();
			
			$('ul#navigation li').hover(
				function(){ $('ul.subnav',this).css('left','auto').css('z-index','4').fadeIn('normal'); },
				function(){ $('ul.subnav',this).fadeOut('normal',function(){ $(this).hide().css('z-index','1').css('left','-999em'); });  }
		     );
			
			$('ul#navigation li ul.subnav li').hover(
				function(){ $('ul.subnav2',this).css('left','126px').css('position','absolute').css('top','-10px').css('z-index','4').fadeIn('normal'); },
				function(){ $('ul.subnav2',this).fadeOut('normal',function(){ $(this).hide().css('z-index','1').css('left','-999em'); }); }
			);
			
			

			// the menus were being a little wonky, this makes sure they go away when you're in the content area
			$('div#content').mouseover(function(){ $('ul.subnav').hide();$('ul.subnav2').hide(); });
			$('div#searchbar').mouseover(function(){ $('ul.subnav').hide();$('ul.subnav2').hide(); });
			$('div#branding').mouseover(function(){ $('ul.subnav').hide(); $('ul.subnav2').hide();});
*/			// auto clear search form field on focus, reset on blur, set the default value on pageload
			var defaultsearchtext='Search by keyword...';
			//$('#q').set('value',defaultsearchtext);
			$('#q').focus(function(){
				if($(this).get(0).value==defaultsearchtext){ this.value=''; }
			});
			$('#q').blur(function(){
				if(trim($(this).get(0).value)==''){ this.value=defaultsearchtext; }
			});
			// do not submit the search form if it is blank or contains only the default text
			$('#searchform').submit(function(){
				if(($('#searchform #q').get(0).value==defaultsearchtext)||(trim($('#searchform #q').get(0).value)=='')){ return false; }
			});
			// if there is no text in the datestamp div, write in today's date.
			var datediv = $('div.datestamp');
			if (datediv.size() > 0) {
				var isdate = trim($('div.datestamp').get(0).innerHTML);
				if(!isdate){
					$('div.datestamp').append(today());
				}
			}
			// manage cygnus dropdown menu
			$('div#cygnusmenu a').mouseover(function(){
				P7_autoLayers(0,'cygnus_menu');
				P7_Snap('cygnuslink','cygnus_menu',0,15);
			});
			$('div#xref ul').mouseover(function(){ P7_autoLayers(0); });
			$('div#branding').mouseover(function(){ P7_autoLayers(0); });
	};
			
