// JavaScript Document for Contact Form

function seenMode() {
	
	if(document.getElementById('seen_usY').checked == true) {
		document.getElementById('whereField').innerHTML = "<p>Where? <input type='text' name='seen_where' id='seen_where' /></p>";
	} else {
		document.getElementById('whereField').innerHTML = "";
	}
		
}

function howHear() {
	if(document.getElementById('how_hear').value == "other") {
		document.getElementById('hearOtherField').innerHTML = "<p>Other: <input type='text' name='hear_other' id='hear_other' /></p>";
	} else {
		document.getElementById('hearOtherField').innerHTML = "";
	}
}

function validateContact() {
	
	if(document.getElementById('own_recordingsY').checked == false && document.getElementById('own_recordingsN').checked == false) {
		alert("Please check whether or not you own any of our recordings.");
		document.getElementById('own_recordingsY').focus();
		return false;			
	}
	
	if(document.getElementById('seen_usY').checked == false && document.getElementById('seen_usN').checked == false) {
		alert("Please check whether or not you've seen us.");
		document.getElementById('seen_usY').focus();
		return false;			
	}
	
	if(document.getElementById('seen_usY').checked == true) {
		if(document.getElementById('seen_where') && document.getElementById('seen_where').value == "") {
			alert("Please enter where you saw us.");
			document.getElementById('seen_where').select(this);
			return false;			
		}
	}
	
	if(document.getElementById('how_hear').value == "") {
		alert("Please select how you heard about us.");
		document.getElementById('how_hear').focus();
		return false;			
	}
	
	if(document.getElementById('how_hear').value == "other") {
		if(document.getElementById('hear_other') && document.getElementById('hear_other').value == "") {
			alert("Please enter the other way you heard about us.");
			document.getElementById('hear_other').select(this);
			return false;			
		}			
	}
	
	if(document.getElementById('name').value == "") {
		alert("Please enter your name.");
		document.getElementById('name').select(this);
		return false;			
	} 
	
	if(document.getElementById('email').value == "") {
		alert("Please enter your email address.");
		document.getElementById('email').select(this);
		return false;			
	} else {
		if(document.getElementById('email').value.indexOf("@") == -1 || document.getElementById('email').value.indexOf(".") == -1) {
			alert("Please enter a valid email address.");
			document.getElementById('email').select(this);
			return false;			
		}
	}
	
	//return false;
	
}