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);
$(document).ready(function(){
	$('#nav li:first').css('border-left', '0');
	$('.section:last').css('background', 'none');
	$('#sidebar ul li:last').css('border-bottom', '0');
	
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
	if (!(jQuery.browser.msie && ie6)) {
		$('#nav li ul').hover(function(){
			$(this).parents('li:eq(0)').addClass('activ');
		},function(){
			$(this).parents('li:eq(0)').removeClass('activ');
		});
	}
	else {
		activ = function() {
			var sfEls = document.getElementById("nav").getElementsByTagName("LI");
			for (var i=0; i<sfEls.length; i++) {
				sfEls[i].onmouseenter=function() {
					this.className +=" activ";
				}
				sfEls[i].onmouseleave=function() {
					this.className=this.className.replace(new RegExp(" activ\\b"), "");
				}
			}
		}
		if (window.attachEvent) window.attachEvent("onload", activ);
	}
	
	$('#nav li a').mouseenter(function(){
		if(!$(this).parents('li:eq(0)').children('ul:eq(0)').children('li:first').hasClass('arrow')) {
			$(this).parents('li:eq(0)').children('ul:eq(0)').children('li:first').before('<li class="arrow"><img src="http://americanofficecenters.com//wp-content/themes/american/images/arrow.png" alt="" width="14" height="10" /></li>');
			var lat = $(this).parents('li:eq(0)').width();
			lat = lat/2 + 1;
			var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
			if (jQuery.browser.msie && ie6) {
				lat = lat/2 + 9;
			}
			lat += 'px';
			$(this).parents('li:eq(0)').children('ul:eq(0)').children('li.arrow').children('img').css('left', lat);
		}
	});
});
