$(function(){
	
	$('#survey_holder').sectorChoice();
	$('#survey_holder').disableOption();
});

$.fn.sectorChoice = function(){
	return this.each(function(){
		var trigger = $('#your_sector');
		var options = $('option',trigger);
		var sets = $('.sub_fieldset',this).remove();
		trigger.change(function(){
			var choice = $('option:selected',this)[0].index;
			sets.remove().eq(choice).insertAfter(trigger);
		});
	});
}

//copy the second select, so we can easily reset it
$.fn.disableOption = function(){
	return this.each(function(){
		var selectClone = $('#importance_2').clone();
		$('#importance_1').change(function() {
		    var val = parseInt($(this).val());
				console.log(val);
		    // //reset the second select on each change
		    // $('#theOptions2').html(selectClone.html())
		    // switch(val) {
		    //     //if 2 is selected remove C
		    //     case 2 : $('#theOptions2').find('option:contains(c)').remove();break;
		    //     //if 3 is selected remove A
		    //     case 3 : $('#theOptions2').find('option:contains(a)').remove();break;
		    // }
		});
	});
}