(function( $ ){
	$.fn.subMenu = function() {
		var subcont = $(this);
		var browserMsie = jQuery.browser.msie;
		
		$(".selected span:eq(0)", subcont).css({"background" : "url(images/submenu_left.png) 0 0 no-repeat"});
		$(".selected span:eq(1)", subcont).css({"background" : "url(images/submenu_center.png) 0 0 repeat-x"});
		$(".selected span:eq(2)", subcont).css({"background" : "url(images/submenu_right.png) 0 0 no-repeat"});
		
		$(".subminitabs", subcont).each(
			function(z) {
				var listE = $(this);
				$("span:eq(0)", listE).css({"width" : "6px"});
				$("span:eq(2)", listE).css({"width" : "6px"});
				if ($(this).hasClass("selected") == false) {
					if (browserMsie == true) {
						$("a", listE).css({"filter" : "progid:DXImageTransform.Microsoft.Glow(Color=#3b5181, Strength=3, enabled=1)", "paddingTop" : "4px"});
					}
					
					// alert($("a", listE).text().length);
					// alert($("a", listE).css("fontSize"));
					// var spanWidth = ($("a", listE).text().length) * (0.7 * Number(($("a", listE).css("fontSize")).substring(0,2)));
					// var liWidth = spanWidth + 14;
					
					// THIS WORKS OKEY ---->
					// var spanWidth = $("span:eq(1)", listE).outerWidth(true);
					// var liWidth = spanWidth + 14;
					
					// $("span:eq(1)", listE).css({"width" : spanWidth+"px"});
					// listE.css({"width" : liWidth+"px"});
					
					$(this).mouseover(function() {
						// $(this).animate({"backgroundPosition" : "0px -48px", "marginTop" : "0px"}, 300);
						if (browserMsie == true) {
							$("a", listE).css({"filter" : "progid:DXImageTransform.Microsoft.Glow(Color=#3b5181, Strength=3, enabled=0)", "paddingTop" : "7px"});
						}
						$("span:eq(0)", listE).css({"background" : "url(images/submenu_left.png) 0 0 no-repeat"});
						$("span:eq(1)", listE).css({"background" : "url(images/submenu_center.png) 0 0 repeat-x"});
						$("span:eq(2)", listE).css({"background" : "url(images/submenu_right.png) 0 0 no-repeat"});
					}).mouseout(function() {
						// $(this).animate({"backgroundPosition" : "0px 0px", "marginTop" : "-10px"}, 300);
						if (browserMsie == true) {
							$("a", listE).css({"filter" : "progid:DXImageTransform.Microsoft.Glow(Color=#3b5181, Strength=3, enabled=1)", "paddingTop" : "4px"});
						}
						$("span:eq(0)", listE).css({"background" : "transparent"});
						$("span:eq(1)", listE).css({"background" : "transparent"});
						$("span:eq(2)", listE).css({"background" : "transparent"});
					});
				}
			}
		);
	}
})( jQuery );
