$(document).ready(function(){

// add "All" checkboxes for users who have enabled javascript
$("#artform-div h5").after('<input name="artform" id="artform" value="All" type="checkbox" /><label for="artform"> All</label><br />');
$("#gos-div h5").after('<input name="gos" id="gos" value="All" type="checkbox" /><label for="gos"> All</label><br />');
$("#goaf-div h5").after('<input name="goaf" id="goaf" value="All" type="checkbox" /><label for="goaf"> All</label><br />');
$("#ggl-div h5").after('<input name="ggl" id="ggl" value="All" type="checkbox" /><label for="ggl"> All</label><br />');

// setup behavior for "All" checkboxes
$("#artform-div [name='artform']").click( function() {
	if( $(this).is(":checked") ) {
		$("#artform-div input").not("[name='artform']").attr("checked", "checked").attr("disabled", "disabled");
		$("#artform-div label").not("[for='artform']").addClass("grey");
	} else {
		$("#artform-div input").not("[name='artform']").removeAttr("checked").removeAttr("disabled");
		$("#artform-div label").not("[for='artform']").removeClass("grey");
	}
});

$("#gos-div [name='gos']").click( function() {
	if( $(this).is(":checked") ) {
		$("#gos-div input").not("[name='gos']").attr("checked", "checked").attr("disabled", "disabled");
		$("#gos-div label").not("[for='gos']").addClass("grey");
	} else {
		$("#gos-div input").not("[name='gos']").removeAttr("checked").removeAttr("disabled");
		$("#gos-div label").not("[for='gos']").removeClass("grey");
	}
});

$("#goaf-div [name='goaf']").click( function() {
	if( $(this).is(":checked") ) {
		$("#goaf-div input").not("[name='goaf']").attr("checked", "checked").attr("disabled", "disabled");
		$("#goaf-div label").not("[for='goaf']").addClass("grey");
	} else {
		$("#goaf-div input").not("[name='goaf']").removeAttr("checked").removeAttr("disabled");
		$("#goaf-div label").not("[for='goaf']").removeClass("grey");
	}
});

$("#ggl-div [name='ggl']").click( function() {
	if( $(this).is(":checked") ) {
		$("#ggl-div input").not("[name='ggl']").attr("checked", "checked").attr("disabled", "disabled");
		$("#ggl-div label").not("[for='ggl']").addClass("grey");
	} else {
		$("#ggl-div input").not("[name='ggl']").removeAttr("checked").removeAttr("disabled");
		$("#ggl-div label").not("[for='ggl']").removeClass("grey");
	}
});

// form1 reset
$("#button").after('<input name="reset" id="reset" value="reset" src="images/button_reset.gif" alt="Reset" height="41" width="88" type="image" />');

$("#reset").click( function() {
	document.form1.reset();
	$("input").removeAttr("disabled");
	$("label").removeClass("grey");
	return false;
	});
	
// form 2 reset button
$("#button2").after('<input name="reset" id="reset2" value="reset" src="images/button_reset.gif" alt="Reset" height="41" width="88" type="image" />');

$("#reset2").click( function() {
	document.form2.reset();
	return false;
	});
	
});

