$(function(){
	//drop-down navigation
	$('ul#lamp_nav li ul').hide();
	
	$("#lamps_form input[type='submit']").attr("disabled","true");

	$('ul#lamp_nav li').hover(
		function () {
			$(this).children('ul').slideDown('fast');
		},
		function () {
			$(this).children('ul').slideUp('fast');
		}
	);

	//event handler for brand/manufacturer
	$("select#manufacturer").change(function(){
		$("#lamps_form input[type='submit']").attr("disabled","true");
		$("input#midw_pn").val('');
		$("input#manu_pn").val('');
		$.getJSON("/lamps/fetch_models/" + $(this).val(), function(j){
			var options = '';
			for (var i = 0; i < j.length; i++) {
				options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
			}
			$("#model").html(options);
			$('#model option:first').attr('selected', 'selected');
		})
	});

	//event handler for model
	$("select#model").change(function(){
		var sel_manu = $("select#manufacturer").val();
		var sel_model = $(this).val();
		$("#lamps_form").attr({action: "/lamps/view_lamps/" + sel_manu + "/" + sel_model }).submit();
	});

	$("input#manu_pn").focus(function(){
		$("#lamps_form input[type='submit']").removeAttr("disabled");
		$("input#midw_pn").val('');
	});

	$("input#midw_pn").focus(function(){
		$("#lamps_form input[type='submit']").removeAttr("disabled");
		$("input#manu_pn").val('');
	});

	//equalize heights of columns
	$('#colcontainer').equalHeights();
	
	//fade out any notices/warnings
	//$('.notice').fadeIn('slow').fadeTo(2000, 1).fadeOut('slow');
	$('.notice').fadeIn('slow').fadeTo(2000, 1).animate({
					top: '-=' + 25 + 'px',
					opacity: 0
				},500);
	
	


})


