sfHover = function() {
	var sfEls = document.getElementById("mi-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);


$(document).ready(function(){
	//fixes li hover in IE6
	$("#mi-nav li").hover(
		function(){$(this).css({backgroundColor:"#e04100"});},
		function(){$(this).css({backgroundColor:"transparent"});}
	);
	$("#mi-nav li.active").hover(
		function(){$(this).css({backgroundColor:"#e04100"});},
		function(){$(this).css({backgroundColor:"#e04100"});}
	);
	
	//makes logo clickable to home
	$("#mi-logo").click(
		function(){
			location.href = "/";
		}
	);
	
	
	$("#mi-address a").hover(
		function(){
			var miaddress = $(this).next(".mi-address-box").html();
			$("body").append('<div class="mi-address-pop"></div>');
			$(".mi-address-pop").html(miaddress);
			
			var position = $(this).position();
			var acenter = $(this).outerWidth() / 2;
			var divcenter = $('.mi-address-pop').outerWidth() / 2;
			var divheight = $('.mi-address-pop').height();
			
			$(".mi-address-pop").css({top: position.top - 40 - divheight + 'px', left: position.left + acenter - divcenter + 'px' })
			.fadeIn("fast");
		},
		function(){
			$(".mi-address-pop").fadeOut('fast', function() {
				$(this).remove();
			});
		}
	);

});
