// JavaScript Document

function validateContactForm() {
		trap = 0;
		if (trap == 0) {name()}
		if (trap == 0) {email()}
		if (trap == 0) {address()
		if (trap == 0) {telephone()}
		if (trap == 0) {time()}
		if (trap == 0) {noParty()}
				
		
		if (trap == 0) {
			document.contactFrm.submit()
			//alert('ok!')
		    }
}

function name() {
		if (document.contactFrm.name.value == "") {
			trap = 1
			alert('Please enter your name')
			document.contactFrm.name.focus()
		}
	}
	
function email() {
	trap = 0;
	addr = document.contactFrm.email.value
	bits = addr.split("@")
	if (bits.length < 2)
		{
		trap=1
		}
	else 
		{
		scnd = bits[1].split(".")
		if (scnd.length < 2) 
			{
			trap = 1
			}
		}
		
	if(trap == 1)
			{
			alert("Please check your email address. We need a valid email address to reply.")
			document.contactFrm.email.focus()
			}
	}
	
function address() {
		if (document.contactFrm.address.value == "") {
			trap = 1
			alert('Please enter your address')
			document.contactFrm.address.focus()
		}
	}

function telephone() {
		if (document.contactFrm.telephone.value == "") {
			trap = 1
			alert('Please enter your telephone number')
			document.contactFrm.telephone.focus()
		}
	}}

function time() {
		if (document.contactFrm.time.value == "") {
			trap = 1
			alert('Please enter your time of arrival')
			document.contactFrm.time.focus()
		}
	}

function noParty() {
		if (document.contactFrm.noParty.value == "") {
			trap = 1
			alert('Please enter the number of people in your party')
			document.contactFrm.noParty.focus()
		}
	}


	






// this function creates an email link 
function contact(nano)
	{
	parent.location = 'm'+'ail'+'to'+String.fromCharCode(58)+'enquiries'+String.fromCharCode(nano)+'irvinelodge.biz';
	}



function validate() { //checks that the mailing list form has a valid email address
		trap = 0;
		
		if (trap == 0) {email()}
		
		if (trap == 0) {
			alert('Thank you for joining the Mailing List')
			document.form1.submit()
			
		    }
}

function email() {
	trap = 0;
	addr = document.form1.email.value
	bits = addr.split("@")
	if (bits.length < 2)
		{
		trap=1
		}
	else 
		{
		scnd = bits[1].split(".")
		if (scnd.length < 2) 
			{
			trap = 1
			}
		}
		
	if(trap == 1)
			{
			alert("Please check your email address.")
			document.form1.email.focus()
			}
	}

