function checkChecks() {
    if ( $("#sa input:checked").length > 0 ) {
        document.getElementById('surroundCheck').checked = true;
        return true;
    } else {
        document.getElementById('surroundCheck').checked = false;
        return false;
    }
    
}

$(document).ready(function(){
    
    // check on page load
    checkChecks();
    
    // disable clicking on the "Surrounding Towns" Check Box
    $('#surroundCheck').click ( function(o) { 
        if ( $("#sa input:checked").length > 0 ) {
            $("#sa input").each ( function(o) {
                this.checked = false;
            });
            return true;
        } else {
            $("#sa").fadeIn();
            return false; 
        }
    });
    
    // Check if we should check "Surrounding Towns" on clicks
    $("#sa input").click( function(o) {
        checkChecks();
    });
    
});

$.fn.check = function() {
	return this.each(function() {
        if ( !this.checked ) {
            this.checked = true;
        } else {
            this.checked = false;
        }
        checkChecks();
	});
};