// JavaScript Document

function validateContactForm() { //checks the user's input for contact form
		trap = 0;
		if (trap == 0) {name()}
		if (trap == 0) {emailFrm()}
		if (trap == 0) {message()}
		
		
		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 emailFrm() {
	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 message() {
		if (document.contactFrm.message.value == "") {
			trap = 1
			alert('Please enter a message')
			document.contactFrm.message.focus()
		}
	}







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



function validate() { //checks that the mailing list form has a valid email address
		trap = 0;
		
		if (trap == 0) {email()}
		
		if (trap == 0) {
			alert('Thak you for joining the Phoenix Motor Group 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()
			}
	}

