// Care Fertility Javascript
//=============================================================================

// Bookmark this page
//--------------------------------------------------------------------------

function bookmark(bookmarkurl, bookmarkname)
{
if ( navigator.appName != 'Microsoft Internet Explorer' )
  {
		window.sidebar.addPanel(bookmarkname, bookmarkurl, '');
  } else {
  	window.external.AddFavorite(bookmarkurl, bookmarkname);
  }
}
// end bookmark


// No link
//--------------------------------------------------------------------------
// function called by links which are not required to go anywhere. Returned false.
function noLink ()
{
	// do nothing	
}
//--------------------------------------------------------------------------

// Date and time display
//--------------------------------------------------------------------------
function datetime ()
{
	var now = new Date();
	
	var days = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" );
	var months = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
	
	var yy = now.getYear();
	if( yy < 2000 ) yy += 1900;
	var mm = now.getMonth();
	mm = months[mm];
	var dd = now.getDate();
	var dy = now.getDay();
	dy = days[dy];
	var hh = now.getHours();
	var mn = now.getMinutes();
	var ss = now.getSeconds();
	
	if( hh <= 9 ) hh = "0" + hh;
	if( mn <= 9 ) mn = "0" + mn;
	
	document.getElementById("date").innerHTML = dy + " " + dd + " " + mm + " " + yy + "&nbsp;&nbsp;&nbsp;" + hh + ":" + mn;
	
	window.setTimeout( "datetime()", 10000 )
}

// end date and time



//jQuery section
//--------------------------------------------------------------------------

jQuery().ready(function(){
  
  // sifr font replace
	//------------------------------------------------------------------------
  // This handles text color for the headings
  // Triggers configsifr (which is in sifr-config.js) passing in the
  // text colour for the page headings. 
  bodyTag = document.getElementsByTagName('body')[0];
	bodyClass = bodyTag.className;	
	switch (bodyClass)
	{
		case 'treatments': fontColor = '#660066'; break;
		case 'genetics': fontColor = '#0a97e7'; break;
		case 'donation': fontColor = '#bb09d1'; break;
		case 'preservation': fontColor = '#116178'; break;
		case 'bulletin': fontColor = '#660066'; break;
		default: fontColor = '#660066'; 
	}
	configsifr(fontColor);

	
	// Alternating rows for tables
	//------------------------------------------------------------------------
	// Give table class 'alt_rows' to apply the effect
	$(".alt_rows tr:even").css("background-color", "#F4F4F8");
	$(".alt_rows tr:odd").css("background-color", "#EFF1F1");
	
    
	// Map zoom
	//------------------------------------------------------------------------
	$("#map img").hover(function() {
		$(this).attr("src", $(this).attr("src").split("map1").join("map2"));
	}, function() {
		$(this).attr("src", $(this).attr("src").split("map2").join("map1"));
	});
	// end map zoom


	// Accordion menu init
	//------------------------------------------------------------------------
	// The 'if' ststements check whether the element is present
	if ($('#accordion01').length != 0)
	{
		// For use in side content area for list items
		$('#accordion01').accordion({
			header: "h3",
			autoHeight: false,
			alwaysOpen:false
		});
	}
	if ($('#accordion02').length != 0)
	{
		// For use in main content area - first item is open to start
		$('#accordion02').accordion({
			header: "h3",
			autoHeight: false,
			alwaysOpen:false
		});
	}
	if ($('#accordion03').length != 0)
	{
		// For use in main content area and locations side - starts fully closed,
		// unless a heading has class 'current' in which case that item opens.
		$('#accordion03').accordion({
			header: "h3",
			autoHeight: false,
			active: false,
			alwaysOpen: false,
			active: "#targetItem"
		});
	}
	// Anchor type links
	// Scrolls page to correct place when linking into an accordion item
	// which has opened as the page loads as a result of clicking a link
	// on another page
	if (document.getElementById("targetItem"))
	{
  	$('html, body').animate({ 
                 scrollTop: $('#targetItem')
                 .offset().top }, 1200);
  }
  
  // end accordion init
  
  // Open links in a new window
  $('a.new-window').click(function(){
   window.open(this.href);
   return false;
	});
	
	
});


// end jQuery section
//--------------------------------------------------------------------------