/*
KD Leach Ltd. - Consutling Structural Engineers
Written by Ian Collier, of lidd Consulting
This work copyright lidd Consulting
Please do not copy or modified this work without seeking the express permission of
the copyright holder beforehand.
Thank you
*/

/* menu and other supporting scripts */

// function to find the bottom of the window and store in winb
function getbottom() {
	// get document height
	return document.body.clientHeight;
}

// function to do create the page top
function dopagetop(title,subtitle) {
	// write the title and subtitle
	document.write('<h1><a href="index.html"><img class="logo" src="./images/logo.png" alt="" title="Click to go to the home page" style="float : right;" /></a>'+title+'</h1>');
	document.write('<h2>'+subtitle+'</h2>');
	// navigation menu
	document.write('<div>');
		// home
		document.write('<a class="menuitem"a href="index.html">Home</a>');
		// role		
		document.write('<a class="menuitem"a href="role.html">Role</a>');
		// projects
		document.write('<a class="menuitem"a href="projects.html">Projects</a>');		
		// about
	   document.write('<a class="menuitem" href="aboutus.html">About</a>');
	   // links
	   document.write('<a class="menuitem" href="links.html">Links</a>');
		// contact
	   document.write('<a class="menuitem" href="contactus.html">Contact</a>');	    
	document.write('</div>');
	// invisible line
	document.write('<hr class="separator" />');
}

// function to do the page footer
function dofooter() {
	// invisible line
	document.write('<hr class="separator" />');
	// write the footer
	document.write('<a href="http://lidd.net" target="_blank"><img src="./images/liddlogosmall.png" alt="" title="Site designed by lidd Consulting (http://lidd.net)" style="float : right;margin-right : 10px;" /></a>');
	document.write('<p style="text-align : center;">');
	document.write('K.D.Leach Limited<br />40 Somerset Road, Linford, Stanford le Hope, Essex, SS17 0QA, UK');
	document.write('</p>');
}

// function to check the form values
function validateform() {
	// reference the document's contact form
	var pageform=document.frmcontact;
	// make regular expressions for testing input
	// name
	var regexpname=/^[a-z][a-z -']*[a-z]$/i
	// email
	var regexpemail=/^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/i;
	// check the name	
	if(regexpname.test(pageform.txtname.value)==false) {
		// post warning message
		document.getElementById("msg").innerHTML="<br /><span class=\"warning\">Please enter your name</span>";
		// reset name to blank
		pageform.txtname.value="";
	}
	else {
		// check the email address
		if(regexpemail.test(pageform.txtemail.value)==false) {
			// post warning message
			document.getElementById("msg").innerHTML="<br /><span class=\"warning\">Please enter a valid email address</span>";
			// reset name to blank
			pageform.txtemail.value="";
		}
		else {	
			// we have what we need, process the form
			pageform.submit();
		}
	}
}		
