// survey functions
										   
function showHideDependent(field){
    
	fieldID = field.id;
	
	//alert(fieldID);
	
	//Do actions depending on what was clicked
	if(fieldID == 'do_you_have_0'){
		hideThis('wrapper_do_you_plan');		
		showThis('wrapper_created_in_house'); 
		showThis('wrapper_how_long'); 
		showThis('wrapper_who_makes_changes'); 
		showThis('wrapper_update_plans');		
		showThis('wrapper_most_important_website'); 
	}
	
	if(fieldID == 'do_you_have_1'){ 
		showThis('wrapper_do_you_plan');	
		hideThis('wrapper_created_in_house'); 
		hideThis('wrapper_how_long'); 
		hideThis('wrapper_who_makes_changes'); 
		hideThis('wrapper_update_plans');		
		hideThis('wrapper_most_important_website'); 
	}
	
	if(fieldID == 'do_you_plan_0'){showThis('wrapper_set_appointment'); }
	
	if(fieldID == 'do_you_plan_1'){	hideThis('wrapper_set_appointment'); }
	
	if(fieldID == 'set_appointment_0'){
		
		//make sure that contact information is entered
		if(isBlank('your_name') || 
			isBlank('your_company')	||
			isBlank('your_address_1') ||
			isBlank('your_city') ||
			isBlank('your_state') || 
			isBlank('your_zip') ||
			(isBlank('your_email') && isBlank('your_phone')) 
		){
			//assemble the error block
			errorMessage = "For someone to contact you, please supply:";
			errorMessage = errorMessage + "\n           Your name";
			errorMessage = errorMessage + "\n           Your company";
			errorMessage = errorMessage + "\n           Your address with city, state & zip code";
			errorMessage = errorMessage + "\n           Your email address and/or phone number";			
			alert(errorMessage);
			
			//uncheck the contact radio
			field.checked = false;		
			
			//set focus to the correct field
			setAddressFocus();
			
		}else{
			showThis('wrapper_day_and_time'); 
			showThis('wrapper_day'); 
			showThis('wrapper_time'); 			
		}
		
	}
	
	if(fieldID == 'set_appointment_1'){	
		hideThis('wrapper_day_and_time'); 
		hideThis('wrapper_day'); 
		hideThis('wrapper_time'); 
	}

	if(fieldID == 'created_in_house_0'){			
		showThis('wrapper_continue_in_house');			 
		hideThis('wrapper_company_name'); 
		hideThis('wrapper_company_why'); 		
		hideThis('wrapper_most_important_company'); 		
	}
	
	if(fieldID == 'created_in_house_1'){			
		hideThis('wrapper_continue_in_house');		 
		showThis('wrapper_company_name'); 
		showThis('wrapper_company_why');
		showThis('wrapper_most_important_company'); 		 
	}
	
	if(fieldID == 'who_makes_changes_0'){ hideThis('wrapper_learn_about_cms'); }
		
	if(fieldID == 'who_makes_changes_1' || fieldID == 'who_makes_changes_2' ){ showThis('wrapper_learn_about_cms'); }
	
	if(fieldID == 'update_plans_0' || fieldID == 'learn_about_cms_0'){ showThis('wrapper_set_appointment'); }
	
	if(fieldID == 'update_plans_1'){ hideThis('wrapper_set_appointment'); }

}

function setAddressFocus(){
	
	NameField = document.getElementById('your_name');
	CompanyField = document.getElementById('your_company');
	AddressField = document.getElementById('your_address_1');
	CityField = document.getElementById('your_city');
	StateField = document.getElementById('your_state');
	ZipField = document.getElementById('your_zip');
	EmailField = document.getElementById('your_email');
	PhoneField = document.getElementById('your_phone');
	
	if(NameField.value.trim() == ''){ NameField.focus(); return; }
	if(CompanyField.value.trim() == ''){ CompanyField.focus(); return; }
	if(AddressField.value.trim() == ''){ AddressField.focus(); return; }
	if(CityField.value.trim() == ''){ CityField.focus(); return; }
	if(StateField.value.trim() == ''){ StateField.focus(); return; }
	if(ZipField.value.trim() == ''){ ZipField.focus(); return; }
	if(EmailField.value.trim() == ''){ EmailField.focus(); return; }
	if(PhoneField.value.trim() == ''){ PhoneField.focus();  return;}
	
}











String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

function isBlank(fieldID){	
	return document.getElementById(fieldID).value.trim() == '';	
}

function hideThis(fieldID){
	document.getElementById(fieldID).style.display = 'none'; 
}

function showThis(fieldID){
	document.getElementById(fieldID).style.display = 'block'; 
}

function hideAll(){
	hideThis('wrapper_do_you_plan'); 
	hideThis('wrapper_created_in_house'); 
	hideThis('wrapper_continue_in_house'); 
	hideThis('wrapper_company_name'); 
	hideThis('wrapper_company_why'); 
	hideThis('wrapper_how_long'); 
	hideThis('wrapper_who_makes_changes'); 
	hideThis('wrapper_learn_about_cms'); 
	hideThis('wrapper_update_plans'); 
	hideThis('wrapper_set_appointment'); 
	hideThis('wrapper_day_and_time' ); 
	hideThis('wrapper_day'); 
	hideThis('wrapper_time'); 
	hideThis('wrapper_most_important_website'); 
	hideThis('wrapper_most_important_company'); 	
}











