$(document).ready (function() {
	$("textarea").autogrow();
	$("input:text,textarea").focus(function(){
		$(this).css("border","1px solid #ed2a3b"); 
	});
	$("input:text,textarea").blur(function(){
		$(this).css("border","1px solid #808080");
	});
	$("#other_field1,#other_field2").hide();
	$("#classify_other,#entity_other").focus(function() {
		$(this).attr("value","");
	});
	$("#classify_reader").change(function(){
		if (this.options[this.options.selectedIndex].value=="other"){$("#other_field1").show();
		} else {
		$("#other_field1").hide(); }
	});
	$("#entity").change(function(){
		if (this.options[this.options.selectedIndex].value=="other"){$("#other_field2").show();
		} else {
		$("#other_field2").hide(); }
	});
	$("#survey_form").validate({
		rules: {
			phone_1: { required: { depends: function(e) { 	return $("#enter_drawing")[0].checked; } } },
			phone_2: { required: { depends: function(e) { 	return $("#enter_drawing")[0].checked; } } },
			phone_3: { required: { depends: function(e) { 	return $("#enter_drawing")[0].checked; } } },
			name: { required: { depends: function(e) { 	return $("#enter_drawing")[0].checked; } } }
		}
	});
});


function req_fields() {
	var obj=$("#enter_drawing")[0];
	if(obj.checked) {
		$("#name_req_span")[0].style.display="";
		$("#phone_req_span")[0].style.display="";		
	} else {
		$("#name_req_span")[0].style.display="none";
		$("#phone_req_span")[0].style.display="none";		
		$("#survey_form").valid();
	}
}