jQuery(document).ready(function($){
	// nav_categories
	$('#nav_categories ul ul').hide();
	$('#nav_categories li.category').hover(function() {
		var $this = $(this);
		$this.addClass('on');
		$this.find('ul').each(function() {
			var $this = $(this);
			if (!$this.is(':visible') && !$this.is(':animated'))
				$this.slideDown(200);
		});
	}, function() {
		var $this = $(this);
		$this.removeClass('on');
		$this.find('ul').each(function() {
			var $this = $(this);
			if ($this.is(':visible'))
				$this.slideUp(200);
		});
	});

var menuAccordion = function(){
	//active class = generated by cms to indicate current page is active or part of active menu node
	//open/close classes = used by the script
	
	var $rootMenu = $(".accordion .menu"),
		$levelOne = $rootMenu.children("li"),
		$activeLi = $rootMenu.find(".active"),
		$activeParentLi = $activeLi.closest(".parent"),
		$triggers = $levelOne.children("span.separator"),
		bottomClear = "<div class='clear'></div>",
		open = function(object){
				var $this = $(object),
					$childUl = $this.find("ul");
					$this.addClass("open").append(bottomClear);
					$childUl.slideDown("fast");
			},
		close = function(object){
				var $this = $(object),
					$childUl = $this.find("ul");
					$childUl.slideUp("fast",function(){
					$this.removeClass("open").find("div.clear").remove();
				});
			};
			
	//Hide menu <ul>s
	$levelOne.find("ul").not('active').hide();
		
	//onload open appropriate menu if a certain item is active.
	if($activeParentLi.length){
		open($activeParentLi);
	}

	$triggers.click(function(){
		var $parentLi = $(this).parent();
		if($parentLi.hasClass('open')){
			close($parentLi);
		} else {
			open($parentLi);
		}
	});

};
menuAccordion();
	
// rotator
	
function cycle(){
		$('.rotator div:last').fadeOut(500, function(){
			 $(this).remove().prependTo('.rotator').show(); 
			 } );
	};
	setInterval(function(){ cycle(); },7000);
	
	
});
function openNewWindow(URLtoOpen, windowName, windowFeatures) {
	newWindow=window.open(URLtoOpen, windowName, windowFeatures); 
}

function openWin(urlToOpen, windowName, width, height){
	var useTop = 0;
	var useLeft = 0;
	var screenHeight = screen.height;
	var screenWidth = screen.width;		
	var useWidth = width || 1000;
	var useHeight = height || 800;
	
	if(screenHeight > useHeight && screenWidth > useWidth){
		useTop = (screenHeight - useHeight)/2;
		useLeft = (screenWidth - useWidth)/2;
	}
	if(!windowName) windowName = '_blank';
	var varFeatures = 'scrollbars=yes,menubar=no,left=' + useLeft + ',top=' + useTop + ',height='+useHeight+',width='+useWidth+',resizable=yes,toolbar=no,location=no,status=no';
	openNewWindow(urlToOpen,windowName,varFeatures);
}

jQuery(document).ready(function(){
	jQuery("a[href=''], a[href='#'], a[href$='.html'").each(function(){
		if(!(jQuery(this).hasClass("otcSuppliesLink") || jQuery(this).hasClass("visionLink") || jQuery(this).hasClass("hearingLink"))){
			//jQuery(this).css("text-decoration", "line-through");
		}
	});
});


