// survey addons

$(document).ready(function(){
	$('#survey-1 #question-2 .user-answer, #survey-1 #question-6 .user-answer').val('http://');
	
	// validate survey
	$('#survey-1').submit(function(){
		
		// reset text color
		$('.survey-question').attr('style', 'color: #645D57');
		
		var err = false;
		$('#survey-1 input:text, #survey-1 textarea').each(function(){
			if(!$(this).is('#question-1 input') && !$(this).is('#question-3 input') && !$(this).is('#question-5 input')){
				if($(this).val() == '') { 
					err = true;
					$(this).parent().attr('style','color: #ff0000');
				}
			}
		})
		
		var c = 0;
		$('#survey-1 input:radio').each(function(){
			if($(this).attr('checked')) c++;
		})

		if(c==0){
			err = true;
			$('#question-4').attr('style','color: #ff0000');
		}


		if(!err) { 
			return true;
		} else {
			alert('Please fill in all required fields.');
			return false;
		} 
	})
})
