/* Behavior for www.davidsfurniture.com */
/* Last updated on 11 Dec 07 */

window.onload = function() {
	contactSend();
}

/* -- checker function - checks to see if variables in each function exist -- */
/*
function checkVars(e) {
	var x = e.split(",");
	var pass = true;
	checkerInvalid = new Array;

	for(i=0; i<x.length; i++) {
		
		if(!eval(x[i])) {
		pass = false; 
		checkerInvalid[checkerInvalid.length] = x[i];
		}
		
	}
	
	return pass;

}
*/



/* -- on contact page, places cursor focus on name field on page load -- */

function contactFocus() {
	
	if(!document.getElementById("name")) {
		return;
	}
	
	var contact_name = document.getElementById("name");
	
	contact_name.focus();
}


function valContactForm() {
	
	var name_value = document.contactform.name.value;
	var email_value = document.contactform.email.value;
	var message_value = document.contactform.message.value;
	var errormsg = '';


	if (name_value == '') {
		errormsg = errormsg + '-You must enter your Name\n';
	}
	
	if (email_value == '') {
		errormsg = errormsg + '-You must enter your Email\n';
	}
	
	if (message_value == '') {
		errormsg = errormsg + '-You must enter a Message\n';
	}
	
	if (errormsg != '') {
		alert('The following errors were found:\n'+errormsg);
		return false;
	}
	
	else { 
		return true; 
	}

}

function contactSend() {
	
	
	var form_name = document.getElementById("contactform");
	
	form_name.onsubmit = function() {
		return valContactForm();
	}
}
	


