/* Walls Bakery javascript - determines browser window size in order to correctly display footer */


		function getWindowHeight() {
			var windowHeight = 0;
			if (typeof(window.innerHeight) == 'number') {
				windowHeight = window.innerHeight;
			}
			else {
				if (document.documentElement && document.documentElement.clientHeight) {
					windowHeight = document.documentElement.clientHeight;
				}
				else {
					if (document.body && document.body.clientHeight) {
						windowHeight = document.body.clientHeight;
					}
				}
			}
			return windowHeight;
		}
		function setFooter() {
			if (document.getElementById) {
				var windowHeight = getWindowHeight();
				if (windowHeight > 0) {
					var mainHeight = document.getElementById('main').offsetHeight;
					var footerElement = document.getElementById('footer');
					var footerHeight  = footerElement.offsetHeight;
					if (windowHeight - (mainHeight + footerHeight) >= 0) {
						footerElement.style.position = 'relative';
						footerElement.style.top = (windowHeight - (mainHeight + footerHeight)) + 'px';
					}
					else {
						footerElement.style.position = 'static';
					}
				}
			}
		}
		window.onload = function() {
			setFooter();
		}
		window.onresize = function() {
			setFooter();
		}




function Form1_Validator(theForm)
{

var alertsay = ""; // define for long lines
// alertsay is not necessary for your code,
// but I need to break my lines in multiple lines
// so the code won't extend off the edge of the page

// check to see if the field is blank
if (theForm.first_name.value == "")
{
alert("Please enter your first name.");
theForm.first_name.focus();
return (false);
}

// require at least 2 characters be entered
if (theForm.first_name.value.length < 2)
{
alert("Please enter your full first name.");
theForm.first_name.focus();
return (false);
}








// check to see if the field is blank
if (theForm.last_name.value == "")
{
alert("Please enter your last name.");
theForm.last_name.focus();
return (false);
}

// require at least 2 characters be entered
if (theForm.last_name.value.length < 2)
{
alert("Please enter your full last name.");
theForm.last_name.focus();
return (false);
}






// check to see if the field is blank
if (theForm.address_1.value == "")
{
alert("Please enter your address.");
theForm.address_1.focus();
return (false);
}

// require at least 2 characters be entered
if (theForm.address_1.value.length < 2)
{
alert("Please enter your full address.");
theForm.address_1.focus();
return (false);
}






// check to see if the field is blank
if (theForm.city.value == "")
{
alert("Please enter your city.");
theForm.city.focus();
return (false);
}

// require at least 2 characters be entered
if (theForm.city.value.length < 2)
{
alert("Please enter your city.");
theForm.city.focus();
return (false);
}






// check if email field is blank
if (theForm.email.value == "")
{
alert("Please enter your email address.");
theForm.email.focus();
return (false);
}


// test if valid email address, must have @ and .
var checkEmail = "@.";
var checkStr = theForm.email.value;
var EmailValid = false;
var EmailAt = false;
var EmailPeriod = false;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkEmail.length;  j++)
{
if (ch == checkEmail.charAt(j) && ch == "@")
EmailAt = true;
if (ch == checkEmail.charAt(j) && ch == ".")
EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
if (EmailAt && EmailPeriod)
{
		EmailValid = true
		break;
	}
}
if (!EmailValid)
{
alert("Please enter a valid email address.");
theForm.email.focus();
return (false);
}

return (true);
// replace the above with return(true); if you have a valid form to submit to
}

