function validateForm(myForm)
{
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
	var _num = myForm.contact.value.replace(/[^\d]/g,'');		
	var nonums = /^[0-9]*$/;
	var noalpha = /^[a-zA-Z]*$/;
	var error = document.getElementById('Merror');	
	
	if (myForm.firstName.value.length == 0)
	{
		error.innerHTML = 'Please enter your fullname';
		myForm.firstName.focus();
		return false;
	}

	for (var i = 0; i < myForm.firstName.value.length; i++) 
	{
		if (iChars.indexOf(myForm.firstName.value.charAt(i)) != -1) 
		{
			error.innerHTML = "Your name field cannot have special characters";
			myForm.firstName.select();
			return false;
		}
	}

	if (nonums.test(myForm.firstName.value)) {
	     error.innerHTML = "Your name field cannot be numeric";
		 myForm.firstName.select();
	     return false;
	}

	if (myForm.people.value.length == 0)
	{
		error.innerHTML = 'Please enter the number of guests attending';
		myForm.people.focus();
		return false;
	}

	for (var i = 0; i < myForm.people.value.length; i++) 
	{
		if (iChars.indexOf(myForm.people.value.charAt(i)) != -1) 
		{
			error.innerHTML = "Your guest field cannot have special characters";
			myForm.people.select();
			return false;
		}
	}

	if (noalpha.test(myForm.people.value)) {
	     error.innerHTML = "Your guest field cannot be alphnumeric";
		 myForm.people.select();
	     return false;
	}
	
	if(_num.length != 11) 
	{	
		error.innerHTML = 'Please enter a valid phone number';
		myForm.contact.focus();
		return false;
	}	
	
	if (myForm.email.value.length >= 0) 
	{
		var i = myForm.email.value.indexOf("@");
		var j = myForm.email.value.indexOf(".",i);
		var k = myForm.email.value.indexOf(",");
		var kk = myForm.email.value.indexOf(" ");
		var jj = myForm.email.value.lastIndexOf(".")+1;
		var len = myForm.email.value.length;

		if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=3)){}
		else 
		{
			error.innerHTML = "Please enter a valid email address";
			myForm.email.focus();
			return false;
		}
	}
	
	//validated all fields and theer seems to be no problems, so now we continue submiting form
	error.innerHTML = "&nbsp;";
	return true;
}

function load_areas(obj)
{		
	if (obj == 'front_area')
	{
		document.getElementById(obj).style.visibility='visible';
		document.getElementById('high_table_area').style.visibility='hidden';		
		document.getElementById('rear_sofa_area').style.visibility='hidden';		
		document.getElementById('fireplace_sofa_area').style.visibility='hidden';		
	}
	else if (obj == 'high_table_area')
	{
		document.getElementById(obj).style.visibility='visible';
		document.getElementById('front_area').style.visibility='hidden';		
		document.getElementById('rear_sofa_area').style.visibility='hidden';		
		document.getElementById('fireplace_sofa_area').style.visibility='hidden';		
	}
	else if (obj == 'rear_sofa_area')
	{
		document.getElementById(obj).style.visibility='visible';
		document.getElementById('high_table_area').style.visibility='hidden';		
		document.getElementById('front_area').style.visibility='hidden';		
		document.getElementById('fireplace_sofa_area').style.visibility='hidden';		
	}
	else if (obj == 'fireplace_sofa_area')
	{
		document.getElementById(obj).style.visibility='visible';
		document.getElementById('high_table_area').style.visibility='hidden';		
		document.getElementById('rear_sofa_area').style.visibility='hidden';		
		document.getElementById('front_area').style.visibility='hidden';		
	}
	
}

function areaForm(_area)
{
	if (_area == 'front_area')
		var w = window.open('book_photos/front_area.html','Popup_Window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=500,top=20,left=100');
	else if (_area == 'high_table_area')
		var w = window.open('book_photos/high_table_area.html','Popup_Window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=500,top=20,left=100');
	else if (_area == 'rear_sofa_area')
		var w = window.open('book_photos/rear_sofa_area.html','Popup_Window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=500,top=20,left=100');
	else if (_area == 'fireplace_sofa_area')
		var w = window.open('book_photos/fireplace_sofa_area.html','Popup_Window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=500,top=20,left=100');
}

function SentForm(myForm)
{
	if (validateForm(myForm) == false)
		return false;
	
	var w = window.open('email_sent.html','Popup_Window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=500,height=500,top=20,left=100');
	myForm.target = 'Popup_Window';
	return true;
}
