$(document).ready(function(){
	
	/*// Info request map
	jQuery("#map-container AREA").mouseover(function(){
		var regionMap = '.'+$(this).attr('id')+'-map';
		var regionList = '.'+$(this).attr('id')+'-list';
		jQuery(regionMap).css('display', 'inline');
	
		// Check if a click event has occured and only change the Region hover state accodringly
		if (! jQuery('#practice-container ul').hasClass('selected')) {
			jQuery(regionList).css('display', 'inline');
		}
	}).mouseout(function(){
		var regionMap = '.'+$(this).attr('id')+'-map';
		var regionList = '.'+$(this).attr('id')+'-list';
	
		// Check if a click event has occured and only change the Region hover state accodringly
		if (! jQuery(regionMap).hasClass('selected')) {
			jQuery(regionMap).css('display', 'none');
		}
	
		// Check if a click event has occured and only change the Region hover state accodringly
		if (! jQuery('#practice-container ul').hasClass('selected')) {
			jQuery(regionList).css('display', 'none');
		}
	});
	
	jQuery("#map-container AREA").click(function(){
		jQuery('#map-container img.region').removeClass('selected').css('display', 'none');
		jQuery('#practice-container ul').removeClass('selected').css('display', 'none');
		
		var regionMap = '.'+$(this).attr('id')+'-map';
		var regionList = '.'+$(this).attr('id')+'-list';
		jQuery(regionMap).addClass('selected').css('display', 'inline');
		jQuery(regionList).addClass('selected').css('display', 'inline');
	});*/
	
	// Suckerfish for IE
	sfHover = function() {
		var sfEls = document.getElementById("nav").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"), "");
			}
		}
	}
	if (window.attachEvent) window.attachEvent("onload", sfHover);
						   
	// Adds a class of "lastchild" to the last <li> in a list
	$("li:last-child").addClass("last-child");

	// Adds a class to odd rows in <table>
	/*$("#materials table tr:nth-child(odd), #comparison table tr:nth-child(odd)")
		.addClass("oddrow");*/

	// Places the <label> from <form id="searchform"> inside the text input and makes it show/hide on blur/focus
	$("#searchform label").each(function() {
		var label = $(this);
		var input = $('#' + label.attr('for'));
		var initial = label.hide().text().replace(':', '');
		input.focus(function() {
			input.css('color', '#77787b');
			if (input.val() == initial) {
				input.val('');
			}
		}).blur(function() {
			if (input.val() == '') {
				input.val(initial).css('color', '#77787b');
			}
		}).css('color', '#77787b').val(initial);
	});		
	
	// Open in a new window for rel='external' links (non-modal window links, i.e. webchat)
	
	function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors .length; i++) {
	var anchor = anchors[i];
	if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
	anchor.target = "_blank";
	anchor.title = (anchor.title != "") ? anchor.title+"" : "";
	anchor.className = (anchor.className != '') ? anchor.className+' external' : 'external';
	}
	}
	}
	window.onload = externalLinks;
	
	// Accordion
	$('#accordion dd').hide();
	$('#accordion dt a').click(function(){
		if ($(this).hasClass('selected')) {
			$(this).removeClass('selected');
			$(this).parent().next().slideUp();
		} else {
		$('#accordion dt a').removeClass('selected');
		$(this).addClass('selected');
		$('#accordion dd').slideUp();
		$(this).parent().next().slideDown();
		}
		return false;
	});
	
	/* Initialize Shadowbox */
	Shadowbox.init();
		
});
