/*
 @name		JQuery for Residential Survey
 @author	Mike Bailey
 @url		http://creativehappy.com
*/
$(document).ready(function(){
	// hide questions
	$('#q3').hide();
	$('#q4').hide();
	$('#survey-other').hide();
	
	// set vars
	var q3 = $('.q3:checked').val();
	var q4 = $('.q4:checked').val();
	var q5 = $('#survey-hear-about-us').val();
	// checking on page load
	if (q3 == 'yes')
	{
		$('#q3').show();
	}
	
	if (q4 == 'no')
	{
		$('#q4').show();
	}
	
	if (q5 == 'Other')
	{
		$('#survey-other').show();
	}
	// when question 3 was clicked.
	$('.q3').click(function()
	{
		var val = $(this).val();
		if (val == 'yes')
		{
			$('#q3').show();
		}
		else
		{
			$("input[name='was-installed']").val('');
			$('#q3').hide();
		}
	});
	// when question 4 was clicked.
	$('.q4').click(function()
	{
		var val = $(this).val();
		if (val == 'yes')
		{
			$('#q4').hide();
			$("input[name='survey-improve']").val('');
		}
		else
		{
			$('#q4').show();
		}
	});
	// on change for q6
	$('#survey-hear-about-us').change(function()
	{
		var val = $(this).val();
		if (val == 'Other')
		{
			$('#survey-other').show();
		}
		else
		{
			$('#survey-other').hide();
		}
	});
});