// JavaScript Document
//====================================================================================================
//	Function Name	:	IsEmpty
//----------------------------------------------------------------------------------------------------
function IsEmpty(fld, msg)
{
	if((fld.value == "" || fld.value.length == 0) && (msg == ''))
	{
		return false;
	}
	
	if(fld.value == "" || fld.value.length == 0)
	{
		alert(msg);
		fld.focus();
		return false;
	}
	
	return true;
}
//====================================================================================================
//	Function Name	:	IsEmail
//----------------------------------------------------------------------------------------------------
function IsEmail(fld, msg)
{
	var regex = /^[\w]+(\.[\w]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/ ;
	
	if(!regex.test(fld.value))
	{
		alert(msg);
		fld.focus();
		return false;
	}
	
	return true;
}
//====================================================================================================
//	Function Name	:	IsLen
//----------------------------------------------------------------------------------------------------
function IsLen(fld, minlen, maxlen, msg)
{
	if(fld.value.length < minlen || fld.value.length > maxlen)
	{
		alert(msg);
		fld.focus();
		return false;
	}
	
	return true;
}
//====================================================================================================
//	Function Name	:	IsInt
//----------------------------------------------------------------------------------------------------
function IsInt(fld, msg)
{
	var regex = /^[0-9]*$/;
	
	if(!regex.test(fld.value))
	{
		alert(msg);
		fld.focus();
		return false;
	}
	
	return true;
}

//====================================================================================================
//	Function Name	:	Validate_Form()
//====================================================================================================
function Validate_Form(frm)
{
	with(frm)
	{
		//{* Check for empty field *}
				if(!IsEmpty(org, 'Please enter Organization Name.'))
				{			
						return false;
				}
				
				if(!IsEmpty(name, 'Please enter Contact name'))
				{			
						return false;
				}
				if(!IsEmpty(designation, 'Please enter your designation'))
				{			
						return false;
				}
				if(!IsEmpty(country, 'Please enter Country'))
				{			
						return false;
				}
						if(!IsEmpty(phone, 'Please enter phone number'))
				{			
						return false;
				}
				if(!IsEmpty(email, 'Please enter email id'))
				{			
						return false;
				}
				
				if(!IsEmpty(tones, 'Please enter data '))
				{			
						return false;
				}
							
		//{* Check  for minimum length *}
				
				if(!IsLen(phone1, 2,4, 'Please Enter Correct Phone No'))
				{			
					return false;
				}
				
				
				if(!IsLen(phone2, 2,5, 'Please Enter Correct Phone No'))
				{			
					return false;
				}
				
				
				if(!IsLen(phone3, 10,10, 'Please Enter Correct Phone No'))
				{			
					return false;
				}
		//{* Check  for numeric *}
				
				if(!IsInt(fax, 'Please Enter Valid fax'))
				{			
					return false;
				}
				
		//{* Check for valid email *}
				if(IsEmpty(email,''))
				{
					if(!IsEmail(email, 'Oppsss!!! Invalid Email Address specified!'))
					{
						return false;
					}
				}
				
			//	if{document.frmContact.phone1.length > 4}{
			//	}
			alert(document.frmContact.phone1.length);
				
		return true;
	}

}
