function validateAWSContactUSForm()
{
	if (!validateNotEmpty(document.frmInquiry.name.value))
	{
		alert('Please fill \'Name\' field to proceed!');
		document.frmInquiry.name.focus();
		return false;
	}
	
	if (!validateNotEmpty(document.frmInquiry.pcell.value))
	{
		alert('Please fill \'Personal cell no\' field to proceed!');
		document.frmInquiry.pcell.focus();
		return false;
	}
	if (!validateUSPhone(document.frmInquiry.pcell.value))
	{
		alert('Please use proper format (xxx) xxx-xxxx to enter phone number!');
		document.frmInquiry.pcell.focus();
		return false;
	}
	
	if (!validateNotEmpty(document.frmInquiry.name.value))
	{
		alert('Please fill Name field to proceed!');
		document.frmInquiry.name.focus();
		return false;
	}
	
	if (!validateNotEmpty(document.frmInquiry.company_name.value))
	{
		alert('Please fill \'Company Name\' field to proceed!');
		document.frmInquiry.company_name.focus();
		return false;
	}
	
	if (!validateNotEmpty(document.frmInquiry.company_email.value))
	{
		alert('Please fill \'Company Email\' field to proceed!');
		document.frmInquiry.company_email.focus();
		return false;
	}
	if (!validateEmail(document.frmInquiry.company_email.value))
	{
		alert('Please enter valid email in \'Company Email\' field!');
		document.frmInquiry.company_email.focus();
		return false;
	}
	
	if (!validateNotEmpty(document.frmInquiry.city.value))
	{
		alert('Please fill \'City\' field to proceed!');
		document.frmInquiry.city.focus();
		return false;
	}
	
	if (!validateNotEmpty(document.frmInquiry.subject.value))
	{
		alert('Please fill \'Subject\' field to proceed!');
		document.frmInquiry.subject.focus();
		return false;
	}
	
	if (!validateNotEmpty(document.frmInquiry.comment.value))
	{
		alert('Please fill \'Comment\' field to proceed!');
		document.frmInquiry.comment.focus();
		return false;
	}
return true;
}// end function

function validateQuickContact()
{
	
	if (!validateNotEmpty(document.quick.name.value))
	{
		alert('Please fill \'Name\' field to proceed!');
		document.quick.name.focus();
		return false;
	}
	if (!validateNotEmpty(document.quick.company.value))
	{
		alert('Please fill \'Company\' field to proceed!');
		document.quick.company.focus();
		return false;
	}
	if (!validateNotEmpty(document.quick.email.value))
	{
		alert('Please fill \'Email\' field to proceed!');
		document.quick.email.focus();
		return false;
	}
	if (!validateEmail(document.quick.email.value))
	{
		alert('Please enter valid email in \'Email\' field!');
		document.quick.email.focus();
		return false;
	}
	if (!validateNotEmpty(document.quick.comment.value))
	{
		alert('Please fill \'Comment\' field to proceed!');
		document.quick.comment.focus();
		return false;
	}
return true;
}

function validateAlphaNumericOnly(obj)
{ 
	var criteria = /^[a-zA-Z_0-9]$/;
	alert(criteria.test(obj.value));
	if (! criteria.test(obj.value))
	{ 
		alert("Please enter alphanumeric only");
		return false;
	}
	return true;
}// end function
//////////////////////////////////////////////////////////////////

function validateAlphaOnly(obj)
{ 
	var criteria = /^[a-zA-Z_]$/;
	alert(criteria.test(obj.value));
	if (! criteria.test(obj.value))
	{ 
		alert("Please enter text only");
		return false;
	}
	return true;
}// end function
//////////////////////////////////////////////////////////////////

function validateEmail( strValue) 
{
	var objRegExp  = /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;
	
	//check for valid email
	return objRegExp.test(strValue);
}// end function
//////////////////////////////////////////////////////////////////

function  validateNumeric( strValue )
{
	var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
	
	//check for numeric characters
	return objRegExp.test(strValue);
}// end function
//////////////////////////////////////////////////////////////////

function validateInteger( strValue ) 
{
	var objRegExp  = /(^-?\d\d*$)/;
	
	//check for integer characters
	return objRegExp.test(strValue);
}// end function
//////////////////////////////////////////////////////////////////

function validateNotEmpty( strValue ) 
{
	var strTemp = strValue;
	strTemp = trimAll(strTemp);
	if(strTemp.length > 0)
	{
		return true;
	}
	return false;
}// end function

//////////////////////////////////////////////////////////////////

function validateValue( strValue, strMatchPattern ) 
{
	var objRegExp = new RegExp( strMatchPattern);

	//check if string matches pattern
	return objRegExp.test(strValue);
}// end function
//////////////////////////////////////////////////////////////////


function rightTrim( strValue )
{
	var objRegExp = /^([\w\W]*)(\b\s*)$/;
	
	if(objRegExp.test(strValue))
	{
	   //remove trailing a whitespace characters
	   strValue = strValue.replace(objRegExp, '$1');
	}
	return strValue;
}// end function
//////////////////////////////////////////////////////////////////

function leftTrim( strValue ) 
{
	var objRegExp = /^(\s*)(\b[\w\W]*)$/;
	
	if(objRegExp.test(strValue)) 
	{
		//remove leading a whitespace characters
		strValue = strValue.replace(objRegExp, '$2');
	}
	return strValue;
}// end function
//////////////////////////////////////////////////////////////////

function trimAll( strValue ) 
{
	var objRegExp = /^(\s*)$/;
	
	//check for all spaces
	if(objRegExp.test(strValue))
	{
		strValue = strValue.replace(objRegExp, '');
		if( strValue.length == 0)
			return strValue;
	}
	
	//check for leading & trailing spaces
	objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
	if(objRegExp.test(strValue)) 
	{
	   //remove leading and trailing whitespace characters
	   strValue = strValue.replace(objRegExp, '$2');
	}
	return strValue;
}// end function
//////////////////////////////////////////////////////////////////

function validateUSPhone( strValue ) 
{
	var objRegExp  = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;
	
	//check for valid us phone with or without space between
	//area code
	return objRegExp.test(strValue);
}// end function
//////////////////////////////////////////////////////////////////

function validateUSZip( strValue ) 
{
	var objRegExp  = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
	
	//check for valid US Zipcode
	return objRegExp.test(strValue);
}// end function
//////////////////////////////////////////////////////////////////

function validateUSDate( strValue ) 
{
	var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
	
	//check to see if in correct format
	if(!objRegExp.test(strValue))
		return false; //doesn't match pattern, bad date
	else{
		var strSeparator = strValue.substring(2,3) 
		var arrayDate = strValue.split(strSeparator); 
		//create a lookup for months not equal to Feb.
		var arrayLookup = { '01' : 31,'03' : 31, 
							'04' : 30,'05' : 31,
							'06' : 30,'07' : 31,
							'08' : 31,'09' : 30,
							'10' : 31,'11' : 30,'12' : 31}
		var intDay = parseInt(arrayDate[1],10); 
		
		//check if month value and day value agree
		if(arrayLookup[arrayDate[0]] != null)
		{
			if(intDay <= arrayLookup[arrayDate[0]] && intDay != 0)
				return true; //found in lookup table, good date
		}
				
		var intMonth = parseInt(arrayDate[0],10);
		if (intMonth == 2) 
		{ 
			var intYear = parseInt(arrayDate[2]);
			
			if (intDay > 0 && intDay < 29) 
			{
			   return true;
			}
			else if (intDay == 29) 
			{
				if ((intYear % 4 == 0) && (intYear % 100 != 0) || (intYear % 400 == 0)) 
				{
				  // year div by 4 and ((not div by 100) or div by 400) ->ok
				 	return true;
				}   
			}
		}
	}  
	return false; //any other values, bad date
}// end function

//////////////////////////////////////////////////////////////////

function removeCurrency( strValue ) 
{
	var objRegExp = /\(/;
	var strMinus = '';
	
	//check if negative
	if(objRegExp.test(strValue))
	{
		strMinus = '-';
	}
	
	objRegExp = /\)|\(|[,]/g;
	strValue = strValue.replace(objRegExp,'');
	
	if(strValue.indexOf('$') >= 0)
	{
		strValue = strValue.substring(1, strValue.length);
	}
	return strMinus + strValue;
}// end function
//////////////////////////////////////////////////////////////////

function addCurrency( strValue ) 
{
	var objRegExp = /-?[0-9]+\.[0-9]{2}$/;
	
	if( objRegExp.test(strValue)) 
	{
		objRegExp.compile('^-');
		strValue = addCommas(strValue);
		if (objRegExp.test(strValue))
		{
			strValue = '(' + strValue.replace(objRegExp,'') + ')';
		}
		return '$' + strValue;
	}
	else
		return strValue;
}// end function
//////////////////////////////////////////////////////////////////

function removeCommas( strValue ) 
{
	var objRegExp = /,/g; //search for commas globally  
	return strValue.replace(objRegExp,'');
}// end function
//////////////////////////////////////////////////////////////////

function addCommas( strValue ) 
{
	var objRegExp  = new RegExp('(-?[0-9]+)([0-9]{3})');
	
	//check for match to search criteria
	while(objRegExp.test(strValue)) 
	{
	   //replace original string with first group match,
	   //a comma, then second group match
	   strValue = strValue.replace(objRegExp, '$1,$2');
	}
	return strValue;
}// end function
//////////////////////////////////////////////////////////////////

function removeCharacters( strValue, strMatchPattern ) 
{
	var objRegExp =  new RegExp( strMatchPattern, 'gi' );
	
	//replace passed pattern matches with blanks
	return strValue.replace(objRegExp,'');
}// end function