// JavaScript Document
// email validation script 


function form_validators(theForm)
{
	//Validate Function 
	function validate(value,checkOk)
	{
	var checkStr = value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOk.length;  j++)
		if (ch == checkOk.charAt(j))
			break;
			if (j == checkOk.length) {
			 allValid = false;
			 break;
			}
	}
	  if (!allValid) {
		return (false);
	  }
	else { return (true); }
  }
		//Trim script
		function Trim(STRING){
		STRING = LTrim(STRING);
		return RTrim(STRING);
		}

		function RTrim(STRING){
		while(STRING.charAt((STRING.length -1))==" "){
		STRING = STRING.substring(0,STRING.length-1);
		}
		return STRING;
		}

		function LTrim(STRING){
		while(STRING.charAt(0)==" "){
		STRING = STRING.replace(STRING.charAt(0),"");
		}
		return STRING;
		}
	 // emptycheck
	 var flag=true;
	 function emptystring(value)
	 {
	   if (value=="") return (false);
	   else return(true);
	 }
	 
	
// Name
	theForm.name.value = LTrim(theForm.name.value);
	theForm.name.value = RTrim(theForm.name.value);
	if (!emptystring(theForm.name.value))
		 {
			alert("Please enter the Name ");
			theForm.name.focus();
			flag=false;
			return (false);
		}else {
           var checkOk = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ  .";
			if (!(validate(theForm.name.value,checkOk)))
				{
				alert("Please Enter Valid Name");
				theForm.name.value= "";
				theForm.name.focus();
				flag=false;
				return (false);
				}
		}
	// Address
	theForm.addr.value = LTrim(theForm.addr.value);
	theForm.addr.value = RTrim(theForm.addr.value);
	if (!emptystring(theForm.addr.value))
		 {
			alert("Please enter the Address ");
			theForm.addr.focus();
			flag=false;
			return (false);
		}	
		
		//Phone Number

	theForm.phno.value = LTrim(theForm.phno.value);
	theForm.phno.value = RTrim(theForm.phno.value);
	if (!emptystring(theForm.phno.value))
		 {
			alert("Please enter your Phone Number");
			theForm.phno.focus();
			flag=false;
			return (false);
		}else {
           var checkOk = "0123456789";
			if (!(validate(theForm.phno.value,checkOk)))
				{
				alert("Please Enter Valid phone number");
				theForm.phno.value= "";
				theForm.phno.focus();
				flag=false;
				return (false);
				}
		}
		//Mail id	
	theForm.mail.value = LTrim(theForm.mail.value);
	theForm.mail.value = RTrim(theForm.mail.value);
	if (!emptystring(theForm.mail.value))
		 {
			alert("Please enter your Email");
			theForm.mail.focus();
			flag=false;
			return (false);
		}else {
	var flag  = true
	var Temp     = theForm.mail
	var AtSym    = Temp.value.indexOf('@')
	var Period   = Temp.value.lastIndexOf('.')
	var Space    = Temp.value.indexOf(' ')
	var Length   = Temp.value.length - 1   // Array is from 0 to length-1

	if(theForm.mail.value !=""){
		if ((AtSym < 1) ||                     // '@' cannot be in first position
		    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
		    (Period == Length ) ||             // Must be atleast one valid char after '.'
		    (Space  != -1))                    // No empty spaces permitted
			   {  
		      flag = false
		      alert("Please enter a valid e-mail address!");
			      Temp.value="";
			      Temp.focus();
		      return flag;
   			}
		}
		}
		
	//Message

	theForm.comments.value = LTrim(theForm.comments.value);
	theForm.comments.value = RTrim(theForm.comments.value);
	if (!emptystring(theForm.comments.value))
		 {
			alert("Please enter your Description");
			theForm.comments.focus();
			flag=false;
			return (false);
		}
		
//Set this return value to true when you want to submit the form
	
	return (flag);
}
function form_validator(theForm)
{
	//Validate Function 
	function validate(value,checkOk)
	{
	var checkStr = value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOk.length;  j++)
		if (ch == checkOk.charAt(j))
			break;
			if (j == checkOk.length) {
			 allValid = false;
			 break;
			}
	}
	  if (!allValid) {
		return (false);
	  }
	else { return (true); }
  }

		//Trim script
		function Trim(STRING){
		STRING = LTrim(STRING);
		return RTrim(STRING);
		}

		function RTrim(STRING){
		while(STRING.charAt((STRING.length -1))==" "){
		STRING = STRING.substring(0,STRING.length-1);
		}
		return STRING;
		}

		function LTrim(STRING){
		while(STRING.charAt(0)==" "){
		STRING = STRING.replace(STRING.charAt(0),"");
		}
		return STRING;
		}
	 // emptycheck
	 var flag=true;
	 function emptystring(value)
	 {
	   if (value=="") return (false);
	   else return(true);
	 }
	 
	
// Name
	theForm.name.value = LTrim(theForm.name.value);
	theForm.name.value = RTrim(theForm.name.value);
	if (!emptystring(theForm.name.value))
		 {
			alert("Please enter the Name ");
			theForm.name.focus();
			flag=false;
			return (false);
		}else {
           var checkOk = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ  .";
			if (!(validate(theForm.name.value,checkOk)))
				{
				alert("Please Enter Valid Name");
				theForm.name.value= "";
				theForm.name.focus();
				flag=false;
				return (false);
				}
		}
			
		//Mail id	
	theForm.mailid.value = LTrim(theForm.mailid.value);
	theForm.mailid.value = RTrim(theForm.mailid.value);
	if (!emptystring(theForm.mailid.value))
		 {
			alert("Please enter your Email");
			theForm.mailid.focus();
			flag=false;
			return (false);
		}else {
	var flag  = true
	var Temp     = theForm.mailid
	var AtSym    = Temp.value.indexOf('@')
	var Period   = Temp.value.lastIndexOf('.')
	var Space    = Temp.value.indexOf(' ')
	var Length   = Temp.value.length - 1   // Array is from 0 to length-1

	if(theForm.mailid.value !=""){
		if ((AtSym < 1) ||                     // '@' cannot be in first position
		    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
		    (Period == Length ) ||             // Must be atleast one valid char after '.'
		    (Space  != -1))                    // No empty spaces permitted
			   {  
		      flag = false
		      alert("Please enter a valid e-mail address!");
			      Temp.value="";
			      Temp.focus();
		      return flag;
   			}
		}
		}
			// Friend Name
	theForm.frndname.value = LTrim(theForm.frndname.value);
	theForm.frndname.value = RTrim(theForm.frndname.value);
	if (!emptystring(theForm.frndname.value))
		 {
			alert("Please enter the Friend Name ");
			theForm.frndname.focus();
			flag=false;
			return (false);
		}else {
           var checkOk = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ  .";
			if (!(validate(theForm.frndname.value,checkOk)))
				{
				alert("Please Enter Valid Friend Name");
				theForm.frndname.value= "";
				theForm.frndname.focus();
				flag=false;
				return (false);
				}
		}
	
// Friend Mail id	
	theForm.frndmail.value = LTrim(theForm.frndmail.value);
	theForm.frndmail.value = RTrim(theForm.frndmail.value);
	if (!emptystring(theForm.frndmail.value))
		 {
			alert("Please enter your Email");
			theForm.frndmail.focus();
			flag=false;
			return (false);
		}else {
	var flag  = true
	var Temp     = theForm.frndmail
	var AtSym    = Temp.value.indexOf('@')
	var Period   = Temp.value.lastIndexOf('.')
	var Space    = Temp.value.indexOf(' ')
	var Length   = Temp.value.length - 1   // Array is from 0 to length-1

	if(theForm.frndmail.value !=""){
		if ((AtSym < 1) ||                     // '@' cannot be in first position
		    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
		    (Period == Length ) ||             // Must be atleast one valid char after '.'
		    (Space  != -1))                    // No empty spaces permitted
			   {  
		      flag = false
		      alert("Please enter a valid e-mail address!");
			      Temp.value="";
			      Temp.focus();
		      return flag;
   			}
		}
		}
	//Message

	theForm.message.value = LTrim(theForm.message.value);
	theForm.message.value = RTrim(theForm.message.value);
	if (!emptystring(theForm.message.value))
		 {
			alert("Please enter your Message");
			theForm.message.focus();
			flag=false;
			return (false);
		}
		
//Set this return value to true when you want to submit the form
	
	return (flag);
}
function news_validator(theForm)
{
	//Validate Function 
	function validate(value,checkOk)
	{
	var checkStr = value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOk.length;  j++)
		if (ch == checkOk.charAt(j))
			break;
			if (j == checkOk.length) {
			 allValid = false;
			 break;
			}
	}
	  if (!allValid) {
		return (false);
	  }
	else { return (true); }
  }

		//Trim script
		function Trim(STRING){
		STRING = LTrim(STRING);
		return RTrim(STRING);
		}

		function RTrim(STRING){
		while(STRING.charAt((STRING.length -1))==" "){
		STRING = STRING.substring(0,STRING.length-1);
		}
		return STRING;
		}

		function LTrim(STRING){
		while(STRING.charAt(0)==" "){
		STRING = STRING.replace(STRING.charAt(0),"");
		}
		return STRING;
		}
	 // emptycheck
	 var flag=true;
	 function emptystring(value)
	 {
	   if (value=="") return (false);
	   else return(true);
	 }
	 // Email
	theForm.email.value = LTrim(theForm.email.value);
	theForm.email.value = RTrim(theForm.email.value);
	if (!emptystring(theForm.email.value))
		 {
			alert("Please enter your Email");
			theForm.email.focus();
			flag=false;
			return (false);
		}else {
	var flag  = true
	var Temp     = theForm.email
	var AtSym    = Temp.value.indexOf('@')
	var Period   = Temp.value.lastIndexOf('.')
	var Space    = Temp.value.indexOf(' ')
	var Length   = Temp.value.length - 1   // Array is from 0 to length-1

	if(theForm.email.value !=""){
		if ((AtSym < 1) ||                     // '@' cannot be in first position
		    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
		    (Period == Length ) ||             // Must be atleast one valid char after '.'
		    (Space  != -1))                    // No empty spaces permitted
			   {  
		      flag = false
		      alert("Please enter a valid e-mail address!");
			      Temp.value="";
			      Temp.focus();
		      return flag;
   			}
		}
		}
	//Set this return value to true when you want to submit the form
	
	return (flag);
}

function newsletter_validator(theForm)
	{
	//Validate Function 
	function validate(value,checkOk)
	{
	var checkStr = value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOk.length;  j++)
		if (ch == checkOk.charAt(j))
			break;
			if (j == checkOk.length) {
			 allValid = false;
			 break;
			}
		}
	  if (!allValid) {
		return (false);
	  }
	else { return (true); }
  }

		//Trim script
		function Trim(STRING){
		STRING = LTrim(STRING);
		return RTrim(STRING);
		}

		function RTrim(STRING){
		while(STRING.charAt((STRING.length -1))==" "){
		STRING = STRING.substring(0,STRING.length-1);
		}
		return STRING;
		}

		function LTrim(STRING){
		while(STRING.charAt(0)==" "){
		STRING = STRING.replace(STRING.charAt(0),"");
		}
		return STRING;
		}
	 // emptycheck
	 var flag=true;
	 function emptystring(value)
	 {
	   if (value=="") return (false);
	   else return(true);
	 }

	
//Name
	theForm.mail.value = LTrim(theForm.mail.value);
	theForm.mail.value = RTrim(theForm.mail.value);
	if (!emptystring(theForm.mail.value))
		 {
			alert("Please enter Email Id");
			theForm.mail.focus();
			flag=false;
			return (false);
		} else {
	var flag  = true
	var Temp     = theForm.mail
	var AtSym    = Temp.value.indexOf('@')
	var Period   = Temp.value.lastIndexOf('.')
	var Space    = Temp.value.indexOf(' ')
	var Length   = Temp.value.length - 1   // Array is from 0 to length-1

	if(theForm.mail.value !=""){
		if ((AtSym < 1) ||                     // '@' cannot be in first position
		    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
		    (Period == Length ) ||             // Must be atleast one valid char after '.'
		    (Space  != -1))                    // No empty spaces permitted
			   {  
		      flag = false
		      alert("Please enter a valid e-mail address!");
			      Temp.value="";
			      Temp.focus();
		      return flag;
   			}
		}
		}
 
	//Set this return value to true when you want to submit the form
	return (flag);
}
//Admin
// email validation script 

function validMail(obj)	{				
	var EmailOk  = true
	var Temp     = obj
	var AtSym    = Temp.value.indexOf('@')
	var Period   = Temp.value.lastIndexOf('.')
	var Space    = Temp.value.indexOf(' ')
	var Length   = Temp.value.length - 1   // Array is from 0 to length-1

	if(obj.value !=""){
		if ((AtSym < 1) ||                     // '@' cannot be in first position
		    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
		    (Period == Length ) ||             // Must be atleast one valid char after '.'
		    (Space  != -1))                    // No empty spaces permitted
			   {  
		      EmailOk = false
		      alert("Please enter a valid e-mail address!");
			      Temp.value="";
			      Temp.focus();
		      return EmailOk;
   			}
		}
	}

// admin/index

function adminLogin_Validator(theForm)
	{
	//Validate Function 
	function validate(value,checkOk)
	{
	var checkStr = value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOk.length;  j++)
		if (ch == checkOk.charAt(j))
			break;
			if (j == checkOk.length) {
			 allValid = false;
			 break;
			}
		}
	  if (!allValid) {
		return (false);
	  }
	else { return (true); }
  }

		//Trim script
		function Trim(STRING){
		STRING = LTrim(STRING);
		return RTrim(STRING);
		}

		function RTrim(STRING){
		while(STRING.charAt((STRING.length -1))==" "){
		STRING = STRING.substring(0,STRING.length-1);
		}
		return STRING;
		}

		function LTrim(STRING){
		while(STRING.charAt(0)==" "){
		STRING = STRING.replace(STRING.charAt(0),"");
		}
		return STRING;
		}
	 // emptycheck
	 var flag=true;
	 function emptystring(value)
	 {
	   if (value=="") return (false);
	   else return(true);
	 }

	
//Name
	theForm.username.value = LTrim(theForm.username.value);
	theForm.username.value = RTrim(theForm.username.value);
	if (!emptystring(theForm.username.value))
		 {
			alert("Please enter Username");
			theForm.username.focus();
			flag=false;
			return (false);
		}
	//password
	theForm.password.value = LTrim(theForm.password.value);
	theForm.password.value = RTrim(theForm.password.value);
	if (!emptystring(theForm.password.value))
		 {
			alert("Please enter Password");
			theForm.password.focus();
			flag=false;
			return (false);
		}
  
	//Set this return value to true when you want to submit the form
	return (flag);
}

function pagename_Validator(theForm)
	{
	//Validate Function 
	function validate(value,checkOk)
	{
	var checkStr = value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOk.length;  j++)
		if (ch == checkOk.charAt(j))
			break;
			if (j == checkOk.length) {
			 allValid = false;
			 break;
			}
		}
	  if (!allValid) {
		return (false);
	  }
	else { return (true); }
  }

		//Trim script
		function Trim(STRING){
		STRING = LTrim(STRING);
		return RTrim(STRING);
		}

		function RTrim(STRING){
		while(STRING.charAt((STRING.length -1))==" "){
		STRING = STRING.substring(0,STRING.length-1);
		}
		return STRING;
		}

		function LTrim(STRING){
		while(STRING.charAt(0)==" "){
		STRING = STRING.replace(STRING.charAt(0),"");
		}
		return STRING;
		}
	 // emptycheck
	 var flag=true;
	 function emptystring(value)
	 {
	   if (value=="") return (false);
	   else return(true);
	 }

	
//Name
	theForm.pagename.value = LTrim(theForm.pagename.value);
	theForm.pagename.value = RTrim(theForm.pagename.value);
	if (!emptystring(theForm.pagename.value))
		 {
			alert("Please enter Pagename");
			theForm.pagename.focus();
			flag=false;
			return (false);
		}
 
	//Set this return value to true when you want to submit the form
	return (flag);
}

function cms_Validator(theForm)
{
	//Validate Function 
	function validate(value,checkOk)
	{
	var checkStr = value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOk.length;  j++)
		if (ch == checkOk.charAt(j))
			break;
			if (j == checkOk.length) {
			 allValid = false;
			 break;
			}
		}
	  if (!allValid) {
		return (false);
	  }
	else { return (true); }
  }

		//Trim script
		function Trim(STRING){
		STRING = LTrim(STRING);
		return RTrim(STRING);
		}

		function RTrim(STRING){
		while(STRING.charAt((STRING.length -1))==" "){
		STRING = STRING.substring(0,STRING.length-1);
		}
		return STRING;
		}

		function LTrim(STRING){
		while(STRING.charAt(0)==" "){
		STRING = STRING.replace(STRING.charAt(0),"");
		}
		return STRING;
		}
	 // emptycheck
	 var flag=true;
	 function emptystring(value)
	 {
	   if (value=="") return (false);
	   else return(true);
	 }
	//Category Name
	if(theForm.pagename.selectedIndex==0)
		{
			alert("Please select Pagename");
			theForm.pagename.focus();
			return false;
		}
		
	theForm.title.value = LTrim(theForm.title.value);
	theForm.title.value = RTrim(theForm.title.value);
	if (!emptystring(theForm.title.value))
		 {
			alert("Please Enter Title");
			theForm.title.focus();
			flag=false;
			return (false);
		}
		
	theForm.keywords.value = LTrim(theForm.keywords.value);
	theForm.keywords.value = RTrim(theForm.keywords.value);
	if (!emptystring(theForm.keywords.value))
		 {
			alert("Please Enter Keywords");
			theForm.keywords.focus();
			flag=false;
			return (false);
		}
		
	theForm.metadesc.value = LTrim(theForm.metadesc.value);
	theForm.metadesc.value = RTrim(theForm.metadesc.value);
	if (!emptystring(theForm.metadesc.value))
		 {
			alert("Please Enter Meta Description");
			theForm.metadesc.focus();
			flag=false;
			return (false);
		}
	
	//Set this return value to true when you want to submit the form
	return (flag);
}
function adminprofile_validator(theForm)
	{
	//Validate Function 
	function validate(value,checkOk)
	{
	var checkStr = value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOk.length;  j++)
		if (ch == checkOk.charAt(j))
			break;
			if (j == checkOk.length) {
			 allValid = false;
			 break;
			}
		}
	  if (!allValid) {
		return (false);
	  }
	else { return (true); }
  }

		//Trim script
		function Trim(STRING){
		STRING = LTrim(STRING);
		return RTrim(STRING);
		}

		function RTrim(STRING){
		while(STRING.charAt((STRING.length -1))==" "){
		STRING = STRING.substring(0,STRING.length-1);
		}
		return STRING;
		}

		function LTrim(STRING){
		while(STRING.charAt(0)==" "){
		STRING = STRING.replace(STRING.charAt(0),"");
		}
		return STRING;
		}
	 // emptycheck
	 var flag=true;
	 function emptystring(value)
	 {
	   if (value=="") return (false);
	   else return(true);
	 }
	 //Old Password
	theForm.oldPassword.value = LTrim(theForm.oldPassword.value);
	theForm.oldPassword.value = RTrim(theForm.oldPassword.value);
	if (!emptystring(theForm.oldPassword.value))
		 {
			alert("Please enter the Current Password");
			theForm.oldPassword.focus();
			flag=false;
			return (false);
		}
	
	//New Password
	theForm.newPassword.value = LTrim(theForm.newPassword.value);
	theForm.newPassword.value = RTrim(theForm.newPassword.value);
	if (!emptystring(theForm.newPassword.value))
		 {
			alert("Please enter the New Password");
			theForm.newPassword.focus();
			flag=false;
			return (false);
		}
	//Confirm Password
	theForm.confirmPassword.value = LTrim(theForm.confirmPassword.value);
	theForm.confirmPassword.value = RTrim(theForm.confirmPassword.value);
	if (!emptystring(theForm.confirmPassword.value))
		 {
			alert("Please enter the Confirm Password");
			theForm.confirmPassword.focus();
			flag=false;
			return (false);
		}
		
	
	//Compare password
	theForm.newPassword.value = LTrim(theForm.newPassword.value);
	theForm.newPassword.value = RTrim(theForm.newPassword.value);
	theForm.confirmPassword.value = LTrim(theForm.confirmPassword.value);
	theForm.confirmPassword.value = RTrim(theForm.confirmPassword.value);

	if (theForm.newPassword.value != theForm.confirmPassword.value)
		 {
			alert("Password mismatching....");
			theForm.newPassword.value="";
			theForm.confirmPassword.value="";
			theForm.newPassword.focus();
			flag=false;
			return (false);
		}
	
	//Set this return value to true when you want to submit the form
	return (flag);
}
function site_validator(theForm)
	{
	//Validate Function 
	function validate(value,checkOk)
	{
	var checkStr = value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOk.length;  j++)
		if (ch == checkOk.charAt(j))
			break;
			if (j == checkOk.length) {
			 allValid = false;
			 break;
			}
		}
	  if (!allValid) {
		return (false);
	  }
	else { return (true); }
  }

		//Trim script
		function Trim(STRING){
		STRING = LTrim(STRING);
		return RTrim(STRING);
		}

		function RTrim(STRING){
		while(STRING.charAt((STRING.length -1))==" "){
		STRING = STRING.substring(0,STRING.length-1);
		}
		return STRING;
		}

		function LTrim(STRING){
		while(STRING.charAt(0)==" "){
		STRING = STRING.replace(STRING.charAt(0),"");
		}
		return STRING;
		}
	 // emptycheck
	 var flag=true;
	 function emptystring(value)
	 {
	   if (value=="") return (false);
	   else return(true);
	 }
	 //email
	theForm.sitemail.value = LTrim(theForm.sitemail.value);
	theForm.sitemail.value = RTrim(theForm.sitemail.value);
	if (!emptystring(theForm.sitemail.value))
		 {
			alert("Please enter the Email");
			theForm.sitemail.focus();
			flag=false;
			return (false);
		}
	
	//Set this return value to true when you want to submit the form
	return (flag);
}
function quote_validator(theForm)
{
	//Validate Function 
	function validate(value,checkOk)
	{
	var checkStr = value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOk.length;  j++)
		if (ch == checkOk.charAt(j))
			break;
			if (j == checkOk.length) {
			 allValid = false;
			 break;
			}
	}
	  if (!allValid) {
		return (false);
	  }
	else { return (true); }
  }

		//Trim script
		function Trim(STRING){
		STRING = LTrim(STRING);
		return RTrim(STRING);
		}

		function RTrim(STRING){
		while(STRING.charAt((STRING.length -1))==" "){
		STRING = STRING.substring(0,STRING.length-1);
		}
		return STRING;
		}

		function LTrim(STRING){
		while(STRING.charAt(0)==" "){
		STRING = STRING.replace(STRING.charAt(0),"");
		}
		return STRING;
		}
	 // emptycheck
	 var flag=true;
	 function emptystring(value)
	 {
	   if (value=="") return (false);
	   else return(true);
	 }
	 
	
// Name
	theForm.yourname.value = LTrim(theForm.yourname.value);
	theForm.yourname.value = RTrim(theForm.yourname.value);
	if (!emptystring(theForm.yourname.value))
		 {
			alert("Please enter the Name ");
			theForm.yourname.focus();
			flag=false;
			return (false);
		} else {
           var checkOk = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ  .";
			if (!(validate(theForm.yourname.value,checkOk)))
				{
				alert("Please Enter Valid Name");
				theForm.yourname.value= "";
				theForm.yourname.focus();
				flag=false;
				return (false);
				}
		}
			
	theForm.company.value = LTrim(theForm.company.value);
	theForm.company.value = RTrim(theForm.company.value);
	if (!emptystring(theForm.company.value))
		 {
			alert("Please enter the Company Name");
			theForm.company.focus();
			flag=false;
			return (false);
		}
		
	theForm.city.value = LTrim(theForm.city.value);
	theForm.city.value = RTrim(theForm.city.value);
	if (!emptystring(theForm.city.value))
		 {
			alert("Please enter the City ");
			theForm.city.focus();
			flag=false;
			return (false);
		}
		
	theForm.state.value = LTrim(theForm.state.value);
	theForm.state.value = RTrim(theForm.state.value);
	if (!emptystring(theForm.state.value))
		 {
			alert("Please enter state");
			theForm.state.focus();
			flag=false;
			return (false);
		}
		
	//zipcode
	theForm.zip.value = LTrim(theForm.zip.value);
	theForm.zip.value = RTrim(theForm.zip.value);
	if (!emptystring(theForm.zip.value))
		 {
			alert("Please enter zipcode");
			theForm.zip.focus();
			flag=false;
			return (false);
		}else {
           var checkOk = "1234567890 ";
			if (!(validate(theForm.zip.value,checkOk)))
				{
				alert("Please Enter Valid Zipcode");
				theForm.zip.value= "";
				theForm.zip.focus();
				flag=false;
				return (false);
				}
		}
		
		//phone
	theForm.phone.value = LTrim(theForm.phone.value);
	theForm.phone.value = RTrim(theForm.phone.value);
	if (!emptystring(theForm.phone.value))
		 {
			alert("Please enter Phone number");
			theForm.phone.focus();
			flag=false;
			return (false);
		}else {
           var checkOk = "1234567890 -()";
			if (!(validate(theForm.phone.value,checkOk)))
				{
				alert("Please Enter Valid Phone number");
				theForm.phone.value= "";
				theForm.phone.focus();
				flag=false;
				return (false);
				}
		}
	
	
	//Mail id	
	theForm.email.value = LTrim(theForm.email.value);
	theForm.email.value = RTrim(theForm.email.value);
	if (!emptystring(theForm.email.value))
		 {
			alert("Please enter your Email");
			theForm.email.focus();
			flag=false;
			return (false);
		}else {
	var flag  = true
	var Temp     = theForm.email
	var AtSym    = Temp.value.indexOf('@')
	var Period   = Temp.value.lastIndexOf('.')
	var Space    = Temp.value.indexOf(' ')
	var Length   = Temp.value.length - 1   // Array is from 0 to length-1

	if(theForm.email.value !=""){
		if ((AtSym < 1) ||                     // '@' cannot be in first position
		    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
		    (Period == Length ) ||             // Must be atleast one valid char after '.'
		    (Space  != -1))                    // No empty spaces permitted
			   {  
		      flag = false
		      alert("Please enter a valid e-mail address!");
			      Temp.value="";
			      Temp.focus();
		      return flag;
   			}
		}
		}
//Set this return value to true when you want to submit the form
	
	return (flag);
}

