I have checkbox set with Category Subcategorywise...
Company
    Microsoft
    Apple
 Country
     USA
     UK
and checkbox attached to e
First of all you should wrap your checkboxes with  so that when the label is clicked the checkbox is also toggled (user friendly).
Then i recommend using lists to group your checkboxes. (you can style them with css in any you want).
Something like this:
    - 
        
        
            
            
         
- 
        
        
            
            
         
Now you can use this very simply jquery to fullfill your task:
$("li :checkbox").change(function(){
    $(this).closest("li").find("ul :checkbox").prop("checked", $(this).is(":checked"));
});
 http://jsfiddle.net/eKTAk/3/
Note that I have changed the names of the fields so that you can read them like this in php a script (post form):
$companies = $_POST['companies']; //Gets the array of values for the checked companies
$countries = $_POST['countries']; //Gets the array of values for the checked companies