﻿// JavaScript Document


	//Following script provided by: 1. http://www.w3schools.com/js/js_form_validation.asp 2. http://www.dynamicdrive.com/dynamicindex16/requiredcheck.htm; 3. http://www.dynamicdrive.com/emailriddler/ First script 1. is to check for email @, etc. and second 2. that the fields are not empty The third 3. is the email encripter used with the envelope.
	
	// 1. Email validator for contact page

function validate_form(thisform)
{
with (thisform)
  {
  if (validate_required(email,"Email must be filled out!")==false)
  {email.focus();return false;}
  }
}
function validate_email(mailfrom,alerttxt)
{
with (mailfrom)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}
function validate_form(thisform)
{
with (thisform)
  {
  if (validate_email(email,"Not a valid e-mail address!")==false)
    {email.focus();return false;}
  }
}


	// 2. contact form validator for Name, Email, Message 

/***********************************************
* Required field(s) validation v1.10- By NavSurf
* Visit Nav Surf at http://navsurf.com
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function formCheck(formobj){
	// Enter name of mandatory fields
	var fieldRequired = Array("Name", "mailfrom", "Message");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Name missing", "Email address missing", "Message Missing");
	// dialog message
	var alertMsg = "Please complete the following fields:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}


	// 3. The email encripter is: http://www.dynamicdrive.com/emailriddler/
	// Email envelope js for contact page and others pages with it
	// Script following is for email encryption. The envelope is from PhotoS, using the Custom shape tool (or U), then pick from the drop down list in the Options tool bar; first pick style and then the custom shape is dragged into place as a + to establish corners.
	// Following js must be placed in the location of the envelope and then it locates that and takes care of the following form.
	// <script type="text/javascript" src="../js/contactform.js" >
	// </script>

/*<![CDATA[*/
/***********************************************
* Encrypt Email script- Please keep notice intact
* Tool URL: http://www.dynamicdrive.com/emailriddler/
* **********************************************/
<!-- Encrypted version of: info [at] *********.** //-->
var emailriddlerarray=[105,110,102,111,64,100,114,115,104,101,110,116,111,110,46,99,97]
var encryptedemail_id75='' //variable to contain encrypted email 
for (var i=0; i<emailriddlerarray.length; i++)
 encryptedemail_id75+=String.fromCharCode(emailriddlerarray[i])
document.write('<a href="mailto:'+encryptedemail_id75+'?subject=Please provide information"> <h3>Please email us:<br /><br /><img src="../images/drsdi-env-logo300x120.gif" width="300" height="118" border="1px" title="Click here to email for more information on Web Design, Drafting and Engineering by D.R.S. Design Inc." alt="Email DRShenton for Web Design, Drafting, Engineering by D.R.S. Design Inc." /></a></h3>')
/*]]>*/

