$(document).ready(function () {
	$("#coc_league").attr({disabled: true});
	$("#loadAssociations").remove();
	$("#state").change(function(){
    $.get("ajax.svc/LoadAssociationByState", {s : $(this).val()}, function(data){
      var s = $("#association").attr({disabled: false});
      var oldValue = s.val();
      s[0].length = 1;
      $("Association", data).each(function(){
        s[0].options[s[0].length] = new Option($("AssociationName", this).text(), $("AssociationId", this).text());
      })
			s.val(oldValue);
    })
  }).change();
	$("#association").change(function(){
		$("#coc_league").toggleClass("disabled", this.value == "").attr({disabled: this.value == ""});
  });
	
	//assign clear event handler to clear search criteria.
	$("#clear").click(function(){
    $(this.form).clearForm();
    return false;
  });
	$("#search").attr({disabled: false});//counter a bug in Firefox which disables the search button
})

