
// The #nav dropdown menus and hover states
// Edited source to clean it up and remove unnessisary code re: dropShadow's
// Source: http://www.optusbusiness.com.au/js/dropshadow.js
$(document).ready(function(){

	closetimer = 0;
	if($("#nav")) {
		
		$("#nav i").mouseover(function() {
		clearTimeout(closetimer);
			if(this.className.indexOf("hover") != -1) {
				$("#nav ul ul ul:visible").hide();
				$("#nav em").removeClass("hover");
			}
			else {
				$("#nav i").removeClass();
				$(this).addClass("hover");
				$("#nav ul ul:visible").hide();
				$(this).parent().next().show();
			}
			return false;
		});

		$("#nav em").mouseover(function() {
		clearTimeout(closetimer);
			if(this.className.indexOf("hover") != -1) {
				
			}
			else {
				$("#nav em").removeClass();
				$(this).addClass("hover");
				$("#nav ul ul ul:visible").hide();
				$(this).parent().next().show();
				
			}
			return false;
		});

		$("#nav").mouseover(function() {
		clearTimeout(closetimer);
		});

		$("#nav").mouseout(function() {
			closetimer = window.setTimeout(function(){
			$("#nav ul ul ul:visible").hide();
			$("#nav em").removeClass("hover");
			$("#nav ul ul:visible").hide();
			$("#nav i").removeClass("hover");
			$("#nav b").removeClass("hover");
			}, 10);
		}); 
	}
	
	// Quicklinks select overlay
	if (!$.browser.msie || ($.browser.msie && $.browser.version !== '6.0')) {
		$('select', '#quicklinks')
			.css('opacity', 0)
			.change(function() {
				$('#quicklinksOverlay').html($('option:selected', this).html());
			});
		
		$('<a />')
			.attr({href : '#', id : 'quicklinksOverlay'})
			.html('Quicklinks:')
			.prependTo('#quicklinks form');
	}
	
	$('form', '#quicklinks').submit(function(e) {
		e.preventDefault();
		
		var href = $('option:selected', this).val();
		
		if (href !== '' && href.match(/http/)) {
			window.location = href;
		}
	});
	
	// IE6 hover fixes
	if ($.browser.msie && $.browser.version === '6.0') {
		$('li', '#nav').hover(function() {
			$(this).addClass('current');
		}, function() {
			$(this).removeClass('current');
		});
		
		$('li.submenu', '#sub-nav').hover(function() {
			$(this).addClass('subcur');
			$('> a', this).addClass('subcur-a');
			$('ul', this).show();
		}, function() {
			$(this).removeClass('subcur');
			$('> a', this).removeClass('subcur-a');
			$('ul', this).hide();
		});
	}
});

// Son of suckerfish dropdown menu 
// IE fix to combat the fact there is no support for the :hover psuedo class
// Source: http://www.optusbusiness.com.au/js/suckerfishie.js
sfHover = function() {
	var sfEls = document.getElementById("topnav").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);
