//  this function checks the email format is correct or not
//  and return true or false accordingly.
	function is_email(email)
	{
		if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
			return false;
		return true;
	}
// End of is_email Function



//  this function checks the given string is empty or not
//  and return true or false accordingly.
	function is_empty(str)
	{
  		 str=trim(str);
		 if ((str.length==0)||(str==null))
			return true;
		 return false;
	}
// End of is_empty Function
	
	function trim(inputString) 
	{
	   inputString=inputString.replace(/^\s+/g,"");
	   inputString=inputString.replace(/\s+$/g,"");
	   return inputString;
	} // Ends the "trim" function

		
	//Form validation

	function ValidateForm(theForm)
	{
		for(i=0;i<theForm.elements.length;i++)
		{
				field = theForm.elements[i];
				if(field.id.match(/^chkemail_/))
				{
						/*fieldname = field.id.replace(/^chkemail_/,'');
						fieldobj = field.getElementById(fieldname);*/
						if(!is_email(field.value))
						{
							alert(field.title)
							field.value==" ";
							field.focus();
							return false;
						}
				}
								else if(field.id.match(/^chknum_/))
				{
						if(!is_number(field.value))
						{
							alert(field.title)
							field.focus();
							return false;
						}
				}				else if(field.id.match(/^chkchkbox_/))
				{
						if(!field.checked)
						{
							alert(field.title)
							field.focus();
							return false;
						}
				}
				else if(field.id.match(/chkchkmbox_/))
				{
					if(theForm.elements[field.name].length >0)
					{
						checked = false;
						for(j=0;j<theForm.elements[field.name].length;j++)
						{
							if(theForm.elements[field.name][j].checked)
							{
								checked = true;
								break
							}
						}
						if(!checked)
						{
							alert(field.title)
							field.focus();
							return false;
						}
		
					}
					else if(!field.checked)
					{
							alert(field.title)
							field.focus();
							return false;
					}
				}
				
			
		}
		return true;
	}

