 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//	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_login_restricted(form) 
{
	var e = form.elements, m = '';
	
	if(!e['username'].value) 
	{
		m += '- Username is required.\n\n';
	} 

	if(!e['password'].value) 
	{
		m += '- Password is required.\n\n';
	} 
	
	if(m) 
	{
		alert('The following error(s) occurred:\n\n' + m);
		return false;
	}
	
	return true;
}

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;
}

function validateAgent(form) 
{
	var e = form.elements, m = '';
	
	if(!e['phone_1_type'].value && ((e['phone_1_prefix'].value || e['phone_1_prefix'].value != 0) && (e['phone_1_suffix'].value || e['phone_1_suffix'].value != 0))) 
	{
		m += '- You must specify the Phone Type if you enter Phone 1.\n';
	}
	
	if(!e['phone_2_type'].value && ((e['phone_2_prefix'].value || e['phone_2_prefix'].value != 0) && (e['phone_2_suffix'].value || e['phone_2_suffix'].value != 0))) 
	{
		m += '- You must specify the Phone Type if you enter Phone 2.\n';
	}
	
	if(m) 
	{
		alert('The following error(s) occurred:\n\n' + m);
		return false;
	}
	
	return true;
}
