
var display_timeout = 0;

$(document).ready(function() {
	
	var isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
	var isIE7 = /msie|MSIE 7/.test(navigator.userAgent);
	
	// using jQuery to make up for ie's shortcomings
	if(isIE6 == true || isIE7 == true) {
		$('#navigation li ul li.brands ul li:last-child, #navigation li ul li.brands ul li:last-child a').css('marginBottom', '0px');
	}
	
	// navigation
	if(isIE6 == false && isIE7 == false) { $('#navigation li.prods ul').css('opacity', 0.9); }
	$('#navigation li.prods').hover(function() {
	
		var this_el = $(this);
	
		if(display_timeout != 0) {
			clearTimeout(display_timeout);
		}
		
		display_timeout = setTimeout(function() {
			display_timeout = 0;
			this_el.addClass('active').find('ul').fadeIn(200);
		}, 200);
		
	}, function() {
	
		if (display_timeout != 0) {
			clearTimeout(display_timeout);
		}
	
		$(this).removeClass('active').find('ul').fadeOut(50);
		
	});
	
	// trade login
	$('#trade_login_holder').hover(function() { // hover on holder not link so mouseout hides panel
		$('#trade_login_holder #trade_login_panel').css('opacity', 0.9).fadeIn(200); // add css opacity here for ie6
	}, function() {
		$('#trade_login_holder #trade_login_panel').fadeOut(200);
	});
	
	$('#trade_login_holder #trade_link').click(function() {
		return false;
	});
	
	// news link
	$('#news_panel').css('cursor', 'pointer').click(function() {
		var href = $(this).find('.white_arrow').attr('href');
		window.location = href;
		
		return false;
	});
	
	// checkout - character count for custom note
	$('form#checkout textarea.field').html("").keydown(function(){
		text = $('form#checkout textarea.field').val();
		if(text.length > 250){
			$('form#checkout span.error').html('Only 256 characters allowed.');
		} else {
			$('form#checkout span.error').html('');
		}
	});
});

