$(function(){
	//#hide county unless country is ireland
	$('#field-county').hide();
	if($('#Country').val() == 'Ireland')
	{
		$('#field-county').show();
	}
	$('#Country').change(function () {
		if($('#Country').val() == 'Ireland')
		{
			$('#field-county').show();
		}
		else
		{
			$('#field-county').hide();
		}
	});
	
	//#when select all option ticked, select all interests and when unticked, deselect all
	$('#cm101038').click(function () {
		$('input[name^="cm-fo-"]').attr('checked', this.checked);
	});   
	
	//#form validation
	$('#subForm').validate({
		errorElement: "strong",
		rules: {
    		'cm-f-tujys': { required: "#County:visible" }
  		}
		/*
		,errorPlacement: function(error, element) {
     		error.appendTo( element.prevAll("label") );
   		}
		*/
	});
}); 
