// Navigation
function showHideMenu(id) {
	$('#navLft ul ul:visible').slideUp(500);
	$(id).next('ul:hidden').slideDown(500);
}

$(function(){	
	$('#navLft ul ul').hide();
	$('.sectionHdr').click(function(e){ e.preventDefault(); showHideMenu(this); });

	// Highlight nav items when tabbed through. Just for fun. `BKS
	$('#siteLft .sectionHdr, #siteLft ul a').bind('focus mouseover',function(){$(this).addClass('hover');});
	$('#siteLft .sectionHdr, #siteLft ul a').bind('blur mouseout',function(){$(this).removeClass('hover');});
	
	// Show everything for testing purposes
	$('body').append('<div id="showAll" style="position:fixed; bottom:0px; width:10px; height:10px;></div>"');
	$('#showAll').bind('dblclick',function(){$('body *:hidden').show();});


	// Hide From IE6
		if(($.browser.msie && $.browser.version > 6) || $.support.opacity) { 
			// Add drop shadow
			$('.shadow').each(function(){
				if($(this).css('position') != 'relative' || $(this).css('position') != 'absolute'){ $(this).css({position:'relative'}); }
				$width = $(this).outerWidth();
				$width = $width + 8;
				$(this).append('<div class="drop_shadow" style="width:'+$width+'px;"><img src="/community/images/spacer.gif" class="drop_shadow" /></div>');
			});
		}
	
	// Show Thumbs on Hover for Cart
		$().mousemove(function(e){
			$x = e.pageX;
			$y = e.pageY;
			
			// Offset Image from Cursor
			$x += 5;
			$y += 5;
			
			$off = $('#site_content').offset();
			$x = $x - $off.left;
			$y = $y - $off.top;
			
			// Adjust to Viewport
			$v_top = $(window).scrollTop();
			$v_height = $(window).height();
			
			// Below keeps image within viewport, needs work
			//if( $y - $v_top + $('.peek').height() >= $v_height ){ $y = $v_height + $v_top - $('.peek').height(); }
			
			$('.peek').css({left:''+$x+'px', top:''+$y+'px'});
		});

		$('.quick_peek').hover(
			function(){ $('.peek',$(this).parent()).stop(true,true).fadeIn(200); },
			function(){ $('.peek',$(this).parent()).fadeOut(100); }
		);
	
	
});

// Catalog Tables & General Scripts
$(function(){
	// Duplicate alt to title
	$('img:not([title])').each(function(){
		$(this).attr('title',$(this).attr('alt'));
	});
	
	// Button Hovers
	$('input[class="button"]').hover(
		function() { $(this).addClass('hover'); },
		function() { $(this).removeClass('hover'); }
	);
	
	// eButton
	// CSS  .eButton, .eButton img { background-image:url(button.png); height:#px; width:#px; }
	$('.eButton').each(function(){
		$(this).wrap('<div class="eButton_wrap"></div>');
		$(this).parent().append('<img src="/commerce/images/spacer.gif" alt="Button Cap" style="position:absolute; top:0px; left:0px; background-position:top left;" /><img src="/commerce/images/spacer.gif" alt="Button Cap" style="position:absolute; top:0px; right:0px; background-position:top right;" />');
	});
 
	// Catalog Tables
	
	$('.listTbl tr:nth-child(even)').not('.norow').addClass('screen');//.css({backgroundColor:'#f7f4ea'});
	$('.listTbl tr:nth-child(even)').not('.norow').children('td').css({borderTop:'1px solid #325a2d',borderBottom:'1px solid #325a2d'});
	$('.listTbl tr:last').children('td').css({borderBottom:'0px'});
	
	
});

function closeMe(){
	$('.detailDiv').fadeOut(500);
}

var timeout;	
function timeOut() {
	timeout = setTimeout('closeMe()',2000);
}

$(function(){
	$('.detailDiv').bind('mouseleave',function(){ timeOut(); }).bind('mouseenter',function(){ clearTimeout(timeout); });
});

