function change_page(url) {
	frames["main_iframe"].location.href=url;
}
function test_frames() {
	if (typeof (parent.frames[0]) == "undefined") document.getElementById("links").innerHTML="<br><a href='index.html' target='_self'>home page</a>";
}
function write_timeofday() {
	var currentTime = new Date();
	var hours = currentTime.getHours();
	if (hours < 12) document.getElementById("timeofday").innerHTML="morning";
	else if ((hours > 11) && (hours < 18)) document.getElementById("timeofday").innerHTML="afternoon";
	else if (hours > 17) document.getElementById("timeofday").innerHTML="evening";
}
function validate() {
	error="";
	name=document.getElementById('name').value;
	email=document.getElementById('email').value;
	phone=document.getElementById('phone').value;
	message=document.getElementById('message').value;
	
	if (name=="") error+="Name is required.\n";
	
	if (email=="") error+="Email address is required.\n";
	else {
		emailFilter=/^.+@.+\..{2,3}$/;
	    if (!(emailFilter.test(email))) { 
	       error+= "The email address you have entered does not appear to be a valid one.\n";
	    }
	    else {
		//test email for illegal characters
	       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
	         if (email.match(illegalChars)) {
	          error+= "The email address contains illegal characters.\n";
	       }
	    }
    }
	/*
	if (phone!="") {
		stripped = phone.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
	    if (isNaN(parseInt(stripped))) {
	       error+= "The phone number contains illegal characters.\n";
	    }
	    if (!(stripped.length > 10)) {
		error+= "The phone number should be at least 11 numbers. Please make sure you included an area code.\n";
	    }
    }
    */
	if (message=="") error+="The message field is empty.\n";

    if (error!="") {
    	alert(error);
    	return false;
    }
    
    return true;
}