var searchOpen = 0;
var narrowOpen = 0;


$(document).ready(function(){
					
	/*
	function disableEnterKey(e)
	{
		 var key;     
		 if(window.event)
			  key = window.event.keyCode; //IE
		 else
			  key = e.which; //firefox     
	
		 return (key != 13);
	}	
					
	$('input').bind("keypress", function(e) {
	  disableEnterKey(e);
	});*/
					
	$('.imageToAction').click(function(){		/* this is done because IE7 cannot pass the value of image inputs the way even */
		$('#action').val($(this).val());		/* IE6, the worst browser ever made, is able to do.  so we have to do this stupid */		
        
	    return true;							/* hack, which puts the value of the clicked image input into a generic hidden input */
	});											/* named action.  sorry for the long explanation but this just really sucks.	*/

	$('form').submit(function(){
		var stopit = 0;
		if($(this).find('.product-option').length>0){
			$(this).find('.product-option').each(function(){
				if($(this).children('option:selected').val()=='0' && stopit == 0){
					alert('All options are required.  Please make your selection and proceed with your order.');
					$(this).focus();
					stopit = 1;
				}
			});
			if(stopit==1){
				return false;
			} else {
				return true;
			}
		} else {
			return true;
		}
	});	
		
	$('#searchbox').click(function(){
		$(this).val('');
	});	
	$('.search').click(function(){
		if (searchOpen==0){
		$('.search-wrap').animate({height: "38px"}, 100);
		searchOpen=1;
		} else {
		$('.search-wrap').animate({height: "0px"}, 100);
		searchOpen=0;
		}
	});
	$('.child_categories h4').click(function(){
		if (narrowOpen==0){
		$('.narrowby ul').css('visibility','visible');
		$(this).css('background-image','url(/templates/default/images/droparrow.gif)');
		narrowOpen=1;
		} else {
		$('.narrowby ul').css('visibility','hidden');
		$(this).css('background-image','url(/templates/default/images/rightarrow.gif)');
		narrowOpen=0;
		}
	});
});