$(function(){
	checkIsRoundSolo();

	$("input[name='grid-filter_fk_shapeID']").bind("click", function(e) {
		checkIsRoundSolo();
	});
});

function checkIsRoundSolo() {
	//if only the round field is selected, show the 'cut' field.	
	var showCutField = true;
	var roundField = $(".diamondShapeRound").get(0);
	var isRoundFieldChecked = roundField.checked;
	var allFields = $("input[name='grid-filter_fk_shapeID']");
	var currField;
	if(isRoundFieldChecked) {
		//see if any other fields are checked, along with the round field
		//if you find any others checked, do NOT show the cut field.
		for(var i=0; i<allFields.length; i++) {
			currField = allFields[i];
			if( currField != roundField && (currField.id != "") ) {
				if(currField.checked) {
					showCutField = false;
					break;
				}
			}
		}
	} else {
		//else, if the round field isn't checked, then just don't show the cut field.
		showCutField = false;
	}
	hideShowCutField(showCutField);
}

function hideShowCutField(isVisible) {
	if(isVisible) {
		$("#Cut_tr_wrapper").show();
	} else {
		$("#Cut_tr_wrapper").hide();
		$("#grid-filter_fk_cutID_from").attr('selectedIndex',0);
		$("#grid-filter_fk_cutID_to").attr('selectedIndex',0);
	}
}
