function validateEmail(addr,man,db) {

	if (addr == 'you@email.com') {

		addr='';

	}

	if (addr == '' && man) {

		if (db) alert('email address is mandatory');

		return false;

	}

	

	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';

	for (i=0; i<invalidChars.length; i++) {

		if (addr.indexOf(invalidChars.charAt(i),0) > -1) {

		if (db) alert('email address contains invalid characters');

		return false;

		}

	}

	

	for (i=0; i<addr.length; i++) {

		if (addr.charCodeAt(i)>127) {

		if (db) alert("email address contains non ascii characters.");

		return false;

		}

	}



	var atPos = addr.indexOf('@',0);

	if (atPos == -1) {

		if (db) alert('email address must contain an @');

		return false;

	}



	if (atPos == 0) {

		if (db) alert('email address must not start with @');

		return false;

	}



	if (addr.indexOf('@', atPos + 1) > - 1) {

		if (db) alert('email address must contain only one @');

		return false;

	}



	if (addr.indexOf('.', atPos) == -1) {

		if (db) alert('email address must contain a period in the domain name');

		return false;

	}



	if (addr.indexOf('@.',0) != -1) {

		if (db) alert('period must not immediately follow @ in email address');

		return false;

	}



	if (addr.indexOf('.@',0) != -1){

		if (db) alert('period must not immediately precede @ in email address');

		return false;

	}



	if (addr.indexOf('..',0) != -1) {

		if (db) alert('two periods must not be adjacent in email address');

		return false;

	}



	var suffix = addr.substring(addr.lastIndexOf('.')+1);

	//if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {

	// if (db) alert('invalid primary domain in email address');

	// return false;

	//}

	

	//verify that the TLD contains at least two characters

	if (suffix.length < 2)  {

		if (db) alert('invalid primary domain in email address');

		return false;

	}



	return true;

}



function CheckForm(formid){

	if(formid == "formAssessment"){

		if(document.forms[formid].contact_name.value==''){ alert('Please Provide Us With Your Name'); document.forms[formid].contact_name.focus(); return false; }
		
		if(document.forms[formid].company_name.value==''){ alert('Please Provide Us With Your Company Name'); document.forms[formid].company_name.focus(); return false; }		

		if(document.forms[formid].company_zipcode.value==''){ alert('Please Provide Us With Your Zip Code'); document.forms[formid].company_zipcode.focus(); return false; }

		if(document.forms[formid].company_zipcode.value.length<5){ alert('Please Provide Us With A Valid Zip Code'); document.forms[formid].company_zipcode.focus(); return false; }		

		if(document.forms[formid].contact_phone.value==''){ alert('Please Provide Us With Your Phone Number'); document.forms[formid].contact_phone.focus(); return false; }

		if(document.forms[formid].contact_phone.value.length<10){ alert('Please Provide Us With A Valid 10-Digit Phone Number'); document.forms[formid].contact_phone.focus(); return false; }	

		if(

		   document.forms[formid].contact_phone.value=='000-000-0000' ||

		   document.forms[formid].contact_phone.value=='111-111-1111' ||	   

		   document.forms[formid].contact_phone.value=='222-222-2222' ||	   

		   document.forms[formid].contact_phone.value=='333-333-3333' ||	   

		   document.forms[formid].contact_phone.value=='444-444-4444' ||	   

		   document.forms[formid].contact_phone.value=='555-555-5555' ||	   

		   document.forms[formid].contact_phone.value=='666-666-6666' ||	   

		   document.forms[formid].contact_phone.value=='777-777-7777' ||	   

		   document.forms[formid].contact_phone.value=='888-888-8888' ||

		   document.forms[formid].contact_phone.value=='999-999-9999' ||	   

		   document.forms[formid].contact_phone.value=='123-456-7890' ||	   

		   document.forms[formid].contact_phone.value=='012-345-6789'

		   ){ alert('Please Provide Us With A Valid Phone Number'); document.forms[formid].contact_phone.focus(); return false; }		

		if(validateEmail(document.forms[formid].contact_email.value,true,false)==false){ alert('Please Provide Us With A Valid eMail Address'); document.forms[formid].contact_email.focus(); return false; }	
		
		if(document.forms[formid].systemcount.value==''){ alert('Please Let Us Know Approximately How Many Systems You Have'); document.forms[formid].systemcount.focus(); return false; }		

		if(document.forms[formid].systemage.value==''){ alert('Please Let Us Know Approximately How Old Your Systems Are'); document.forms[formid].systemage.focus(); return false; }

		if(document.forms[formid].multipleoffices.value==''){ alert('Please Let Us Know If You Have Multiple Offices'); document.forms[formid].multipleoffices.focus(); return false; }
		
		if(document.forms[formid].currentitmanager.value==''){ alert('Please Let Us Know If You Currently Have Someone To Manage Your Technology'); document.forms[formid].currentitmanager.focus(); return false; }		
		
		if(document.forms[formid].industry.value==''){ alert('Please Let Us Know What Industry You Serve'); document.forms[formid].industry.focus(); return false; }				
		
		if(document.forms[formid].timeframe.value==''){ alert('Please Let Us Know What Time Frame You Have To Work With'); document.forms[formid].timeframe.focus(); return false; }						

		else { return true;	}

	}

	else {

		if(document.forms[formid].firstname.value==''){ alert('Please Provide Us With Your First Name'); document.forms[formid].firstname.focus(); return false; }

		if(document.forms[formid].lastname.value==''){ alert('Please Provide Us With Your Last Name'); document.forms[formid].lastname.focus(); return false; }

		if(validateEmail(document.forms[formid].email.value,true,false)==false){ alert('Please Provide Us With A Valid eMail Address'); document.forms[formid].email.focus(); return false; }

		if(document.forms[formid].phone.value==''){ alert('Please Provide Us With Your Phone Number'); document.forms[formid].phone.focus(); return false; }

		if(document.forms[formid].phone.value.length<10){ alert('Please Provide Us With A Valid 10-Digit Phone Number'); document.forms[formid].phone.focus(); return false; }	

		if(

		   document.forms[formid].phone.value=='000-000-0000' ||

		   document.forms[formid].phone.value=='111-111-1111' ||	   

		   document.forms[formid].phone.value=='222-222-2222' ||	   

		   document.forms[formid].phone.value=='333-333-3333' ||	   

		   document.forms[formid].phone.value=='444-444-4444' ||	   

		   document.forms[formid].phone.value=='555-555-5555' ||	   

		   document.forms[formid].phone.value=='666-666-6666' ||	   

		   document.forms[formid].phone.value=='777-777-7777' ||	   

		   document.forms[formid].phone.value=='888-888-8888' ||

		   document.forms[formid].phone.value=='999-999-9999' ||	   

		   document.forms[formid].phone.value=='123-456-7890' ||	   

		   document.forms[formid].phone.value=='012-345-6789'

		   ){ alert('Please Provide Us With A Valid Phone Number'); document.forms[formid].phone.focus(); return false; }		

	}

}



function CheckEmail(formid){

	if(validateEmail(document.forms[formid].email.value,true,false)==false){ alert('Please Provide Us With A Valid eMail Address'); document.forms[formid].email.focus(); return false; }	

}



function FormatNumber(num, format, shortformat)

{

	if(format==null)

	{

			// Choose the default format you prefer for the <b style="color:black;background-color:#a0ffff">number</b>. 

		//format = "#-(###) ###-#### ";		// Telephone w/ LD Prefix and Area Code

		//format = "(###) ###-#### ";			// Telephone w/ Area Code

		format = "###-###-####";			// Telephone w/ Area Code (dash seperated)

		//format = "###-##-####";			//Social Security <b style="color:black;background-color:#a0ffff">Number</b>

	}					



	if(shortformat==null)

	{

		// Choose the short format (without area code) you prefer. 

		//If you do not want multiple formats, leave it as "".



		//var shortformat = "###-#### ";

		var shortformat = "";

	}

	

	var validchars = "0123456789";

	var tempstring = "";

	var returnstring = "";

	var extension = "";

	var tempstringpointer = 0;

	var returnstringpointer = 0;

	count = 0;



	// Get the length so we can go through and remove all non-numeric characters

	var length = num.value.length;

		



	// We are only concerned with the format of the phone <b style="color:black;background-color:#a0ffff">number</b> - extensions can be left alone.

	if (length > format.length)

	{

		length = format.length;

	};

	

	// scroll through what the user has typed

	for (var x=0; x<length; x++)

	{

		if (validchars.indexOf(num.value.charAt(x))!=-1)

		{

		tempstring = tempstring + num.value.charAt(x);

		};

	};

	// We should now have just the #'s - extract the extension if needed

	if (num.value.length > format.length)

	{

		length = format.length;

		extension = num.value.substr(format.length, (num.value.length-format.length));

	};

	

	// if we have fewer characters than our short format, we'll default to the short version.

	for (x=0; x<shortformat.length;x++)

	{

		if (shortformat.substr(x, 1)=="#")

		{

			count++;

		};

	}

	if (tempstring.length <= count)

	{

		format = shortformat;

	};



	

	//Loop through the format string and insert the numbers where we find a # sign

	for (x=0; x<format.length;x++)

	{

		if (tempstringpointer <= tempstring.length)

		{

			if (format.substr(x, 1)=="#")

			{

				returnstring = returnstring + tempstring.substr(tempstringpointer, 1);

				tempstringpointer++;

			}else{

				returnstring = returnstring + format.substr(x, 1);

			}

		}

		

	}



	// We have gone through the entire format, let's add the extension back on.

		returnstring = returnstring + extension;

	

	//we're done - let's return our value to the field.

	num.value = returnstring;

}