$(document).ready(function() {
	initMenus();

function initMenus() {
	$('#l2menu ul.menu ul').hide();
	$.each($('#l2menu ul.menu'), function(){
		$('#' + this.id + '.expandfirst ul:first').show();
	});
	$('#l2menu ul.menu li a').mouseover(
		function() {
			var checkElement = $(this).next();
			var parent = this.parentNode.parentNode.id;

			if($('#' + parent).hasClass('noaccordion')) {
				$(this).next().slideToggle('normal');
				return false;
			}
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				if($('#' + parent).hasClass('collapsible')) {
					$('#' + parent + ' ul:visible').slideUp('normal');
				}
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#' + parent + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal');
				return false;
			}
		}
	);
}

$('div.goal').mouseover(function() {
		oImg = $(this).find("img");
		strImg = oImg.attr("src");
		strImg = strImg.replace("grey", "colour");
		oImg.attr("src", strImg); 
	});
	
	$('div.goal').mouseout(function() {
		oImg = $(this).find("img");
		strImg = oImg.attr("src");
		strImg = strImg.replace("colour", "grey");
		oImg.attr("src", strImg); 
	});
});

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			if (this.className != 'home') {
				if (window.attachEvent) {
					this.className+=" sfhover";
				}
			}
		}  
		
		sfEls[i].onmouseout=function() {
			if (this.className != 'home') {
				if (window.attachEvent) {
					this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
				}
			}
		}
	}  
}
window.onload = sfHover;

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
