//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//	Copyright (C) 2008 Cro-Cec, Inc. dba Digital Solutions.
//	A complete description of the Digital Solutions (c) copyright notice can be found online at: 
//	http://www.digitalsolutionslc.com/copyright_notice.php 
//		
//	Digital Solutions is a premier marketing and web development company in Las Cruces, New Mexico. 
//	We offer professional web design including flash and database web sites, graphic design, marketing materials, 
//	and video production. 
//
//	If you enjoyed this website and are looking for custom web development, give us a call at (575) 523-7661.
//		
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


/*********************************************************************
				Version 4.0 --> modified Jun 6, 2007
*********************************************************************/

// This is the function you would use to require certain fields to be filled in when submitting a form.
// PLEASE NOTE: If you wish to have another field required, copy/paste the if statement for one of the
// other fields (e.g. first_name) and change the information to match the appropriate field.




function validate(form) {
	var e = form.elements, m = '';
	
	if(!e['first_name'].value) {
		m += '- First name is required.\n\n';
	}
	if(!e['last_name'].value) {
		m += '- Last name is required.\n\n';
	}
	if(!e['email'].value) {
		m += '- Email is required.\n\n';
	} 
	if(e['email'].value) {
		var str = e['email'].value;
		var reg = new RegExp("([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})");
				
		if (!reg.test(str))
		{
			m += '- E-Mail address is not valid.\n\n';
		}
	}
	if(!e['comments'].value) {
		m += '- Comments are required.\n\n';
	}
	if(!e['s_image'].value) {
		m += '- Security Code is required.\n\n';
	}
	if(e['s_image'].value) {
		var str2 = e['s_image'].value;
		var reg2 = new RegExp("([a-z]{4})");
	
		if (!reg2.test(str2)) {
			m += '- Security Code must have 4 characters.\n\n';
		}
	}
	if(m) {
		alert('The following error(s) occurred:\n\n' + m);
		return false;
	}
	return true;
}

// You would also need to make sure you have the onSubmit property declared within the <form> tag.
// For example: <form onSubmit="return validate(this)" method="post" action="process_contact.php">