function local_photo() {
	document.getElementById('output').innerHTML="<img src='"+photoarr[photoindex]+"' width='342' height='226'>";
	photoindex++;
	if (photoindex > photocount) {photoindex=1};
	var jah_timeout= setTimeout('local_photo();', 5000); 
	}


function submitForm(formname) { 
		var sbmtform='document.'+formname+'.submit()';
		eval(sbmtform); 
	}
function ajaxFunction()
{
	return  window.XMLHttpRequest  ?
	new window.XMLHttpRequest : 
	new ActiveXObject("Microsoft.XMLHTTP");
}
function sendmsmt()
{
var good2go=1;
var httpObj = ajaxFunction();
if (!testname()) {good2go=0};
if (!testphone()){good2go=0};
if (!testemail()) {good2go=0};
if (!testnotes()) {good2go=0};
if (!testmsmt('lhspan')) {good2go=0};
if (!testmsmt('rhspan')) {good2go=0};
if (!testpitch('lhpitch')) {good2go=0};
if (!testpitch('rhpitch')) {good2go=0};
if (!testmsmt('height')) {good2go=0};
if (!testmsmt('heel')) {good2go=0};
if (!testmsmt('drop')) {good2go=0};
if (!testmsmt('span')) {good2go=0};
if (!testmsmt('overhang')) {good2go=0};
if (!testmsmt('cantilever')) {good2go=0};
if (!good2go)
	{
	alert("A red input area indicates missing or incorrectly formatted information. Place your the cursor over any input area to see tips for correct entry.");
	}
else
	{
	var url = 'sendmsmt.php'+"?contact=";
	var indexarg=document.getElementById('contact').value;
	indexarg+="&phone="+document.getElementById('phone').value;
	indexarg+="&email="+document.getElementById('email').value;
	indexarg+="&lhspan="+document.getElementById('lhspan').value;
	indexarg+="&rhspan="+document.getElementById('rhspan').value;
	indexarg+="&lhpitch="+document.getElementById('lhpitch').value;
	indexarg+="&rhpitch="+document.getElementById('rhpitch').value;
	indexarg+="&height="+document.getElementById('height').value;
	indexarg+="&heel="+document.getElementById('heel').value;
	indexarg+="&drop="+document.getElementById('drop').value;
	indexarg+="&span="+document.getElementById('span').value;
	indexarg+="&overhang="+document.getElementById('overhang').value;
	indexarg+="&notes="+document.getElementById('notes').value;
	indexarg+="&cantilever="+document.getElementById('cantilever').value;
	httpObj.open("GET", url + indexarg + "&ms=" + new Date().getTime(), true);
	httpObj.send(null);
	httpObj.onreadystatechange = function()
		{
			if(httpObj.readyState == 4)
			{
			var response = httpObj.responseText;
			alert(response);
			document.getElementById('contact').value="";
			document.getElementById('phone').value="";
			document.getElementById('email').value="";
			document.getElementById('lhspan').value="";
			document.getElementById('rhspan').value="";
			document.getElementById('lhpitch').value="";
			document.getElementById('rhpitch').value="";
			document.getElementById('height').value="";
			document.getElementById('heel').value="";
			document.getElementById('drop').value="";
			document.getElementById('span').value="";
			document.getElementById('overhang').value="";
			document.getElementById('notes').value="Enter more notes here";
			document.getElementById('cantilever').value="";
			}
		}
	}	
}

function sendemail()
{
var good2go=1;
var httpObj = ajaxFunction();
if (!testname()) {good2go=0};
if (!testphone()){good2go=0};
if (!testemail()) {good2go=0};
if (!testmsg()) {good2go=0};
if (!good2go)
	{
	alert("A red input area indicates missing or incorrectly formatted information. Place your the cursor over any input area to see tips for correct entry.");
	}
else
	{
	var url = 'sendemail.php'+"?contact=";
	var indexarg=document.getElementById('contact').value;
	indexarg+="&phone="+document.getElementById('phone').value;
	indexarg+="&email="+document.getElementById('email').value;
	indexarg+="&notes="+document.getElementById('msg').value;
	httpObj.open("GET", url + indexarg + "&ms=" + new Date().getTime(), true);
	httpObj.send(null);
	httpObj.onreadystatechange = function()
		{
			if(httpObj.readyState == 4)
			{
			var response = httpObj.responseText;
			alert(response);
			document.getElementById('contact').value="";
			document.getElementById('phone').value="";
			document.getElementById('email').value="";
			document.getElementById('msg').value="";
			}
		}
	}	
}

function testmsmt(myval)
{
var ok=1;
if (document.getElementById(myval).value!="")
	{
	tmsmt=new Array();
	tmsmt=document.getElementById(myval).value.split("-");
	if (tmsmt.length != 3) 
		{
		ok=0;
		}
	else
		{
		if (tmsmt[0] < 0 || tmsmt[0] > 100) {ok=0;}
		if (tmsmt[1] < 0 || tmsmt[1] > 11) {ok=0;}
		if (tmsmt[2] < 0 || tmsmt[2] > 15) {ok=0;}
		}
	}
if (!ok) 
	{document.getElementById(myval).style.backgroundColor='#FF0000'; }
else
	{document.getElementById(myval).style.backgroundColor='#EEEEEE'; }
return ok;
}
function testpitch(myval)
{
var ok=1;
if (document.getElementById(myval).value!="")
	{
	tmsmt=new Array();
	tmsmt=document.getElementById(myval).value.split("-");
	if (tmsmt.length != 2) 
		{
		ok=0;
		}
	else
		{
		if (tmsmt[0] < 0 || tmsmt[0] > 18) {ok=0;}
		if (tmsmt[1] != 12) {ok=0;}
		}
	}
if (!ok) 
	{document.getElementById(myval).style.backgroundColor='#FF0000'; }
else
	{document.getElementById(myval).style.backgroundColor='#EEEEEE'; }
return ok;
}
function testphone() 
	{
  var phoneRegex = /^\(?[2-9]\d{2}[\)\.-]?\s?\d{3}[\s\.-]?\d{4}$/;
  var tphone=document.getElementById('phone').value;
  if( !tphone.match( phoneRegex ) )
	  {
	  document.getElementById('phone').style.backgroundColor='#FF0000'; 
	  return 0;
	 	}
 	else
	 	{
	 	document.getElementById('phone').style.backgroundColor='#EEEEEE'; 	
	 	return 1;
		}
	}
function testemail() 
	{
  var emailRegex = /^(\w+\.)*\w+@(\w+\.)+[A-Za-z]+$/;
  var temail=document.getElementById('email').value;
  if( !temail.match( emailRegex ) )
	  {
	  document.getElementById('email').style.backgroundColor='#FF0000'; 
	  return 0;
	 	}
 	else
	 	{
	 	document.getElementById('email').style.backgroundColor='#EEEEEE'; 	
	 	return 1;
		}
	}
function testname() 
	{
  var nameRegex = /^[A-Za-z0-9. ]{3,20}$/;
  var tname=document.getElementById('contact').value;
  if( !tname.match( nameRegex ) )
	  {
	  document.getElementById('contact').style.backgroundColor='#FF0000'; 
	  return 0;
	 	}
 	else
	 	{
	 	document.getElementById('contact').style.backgroundColor='#EEEEEE'; 	
	 	return 1;
		}
	}
function testnotes() 
	{
  var nameRegex = /^[A-Za-z0-9.'\- ]{0,350}$/;
  var tname=document.getElementById('notes').value;
  if( !tname.match( nameRegex ) )
	  {
	  document.getElementById('notes').style.backgroundColor='#FF0000'; 
	  return 0;
	 	}
 	else
	 	{
	 	document.getElementById('notes').style.backgroundColor='#EEEEEE'; 	
	 	return 1;
		}
	}
function testmsg() 
	{
  var nameRegex = /^[A-Za-z0-9.'\- ]{0,350}$/;
  var tname=document.getElementById('msg').value;
  if( !tname.match( nameRegex ) )
	  {
	  document.getElementById('msg').style.backgroundColor='#FF0000'; 
	  return 0;
	 	}
 	else
	 	{
	 	document.getElementById('msg').style.backgroundColor='#EEEEEE'; 	
	 	return 1;
		}
	}
