var important = false;
function setImportant(val){
	important = val;
	jQuery.each(countries, function(key, val) {
		countryToggle(key,val);
	});
}

function showFull(){
	var total = 0;
	var c = 0;
	jQuery.each(countries, function(key, val) {
		total++;
		if(val==false){
			c++;
		}
	});
	if(c==total){
		return true;
	}
	return false;

}

function countryToggle(c){
	var val = $('#'+c).is(':checked');
	countries[c] = val;
	var showfull = showFull();
	$('.caldata tr').each(function (i) {
		var country = $(this).attr('rel');
		if(countries[country]==true || showfull == true){
			if(important == true && $(this).hasClass( 'important' ) ) {
				$(this).show();
			}
			else if(important == false){
				$(this).show();
			}
			else{
				$(this).hide();
			}
		}
		else{
			$(this).hide();
		}
	});
}
