
function phone1()
{
var ValidChars = "0123456789/-.";
var IsNumber=true;
var Char;
sText=obj.phone.value;	
for (i = 0; i < sText.length && IsNumber == true; i++) 
{ 
Char = sText.charAt(i); 
if (ValidChars.indexOf(Char) == -1) 
{alert('Please enter only Positive numbers in Telephone field') ;
obj.phone.value='';
obj.phone.focus(); 
IsNumber = false;
}
}
return IsNumber;
}

function name1()
{var IsNumber=true;
var Char;
string=obj.name.value;
var iChars = "*|,\":<>[]{}`\';()@&$#%0123456789";
for (var i = 0; i < string.length; i++) {
if (iChars.indexOf(string.charAt(i)) != -1)
IsNumber=false;
if(IsNumber==false){
alert('Please enter only Alphabets in the Name field');
obj.name.value='';
obj.name.focus(); 
return IsNumber;
}
}
return IsNumber;
}

// This method is used to remove Leading spaces.
// It takes argument of the string which Leading Spaces has to removed.
function removeLeadingSpaces(str)
{
   var whitespace = new String(" \\t\\n\\r");
   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1)
    {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)  j++;
      s = s.substring(j, i);
    }
   return s;
}

//######################################################################################################
// This method is used to remove Trailing spaces.
// It takes argument of the string which Trailing Spaces has to removed.

function removeTrailingSpaces(str)
{
   var whitespace = new String(" \\t\\n\\r");
   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1)
   {
      var i = s.length - 1;       // Get length of string
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) i--;

      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }

   return s;
}
//######################################################################################################
// Removes both Leading and Trailing blanks.
//

function removeAllSpaces(str)
{
   str = removeLeadingSpaces(str); //Remove Leading Spaces
   str = removeTrailingSpaces(str); //Remove Trailing Spaces
   return str;
}

function isValidEmail (emailIn){
	var isEmailOk = false;

	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;


	if(emailIn.search(filter) != -1)
		isEmailOk = true;
	if(emailIn.indexOf("..") != -1)
		isEmailOk = false;
	if(emailIn.indexOf(".@") != -1)
		isEmailOk = false;
	if(emailIn.indexOf("'") != -1 || emailIn.indexOf("''") != -1 || emailIn.indexOf("\"") != -1 ||emailIn.indexOf("\"") != -1 ||  emailIn.indexOf("(") != -1  || emailIn.indexOf(")") != -1 || emailIn.indexOf("[") != -1 || emailIn.indexOf("]") != -1 || emailIn.indexOf("{") != -1  || emailIn.indexOf("}") != -1 || emailIn.indexOf(",") != -1 || emailIn.indexOf(",,") != -1 || emailIn.indexOf(":") != -1 || emailIn.indexOf(";") != -1 || emailIn.indexOf("#") != -1 || emailIn.indexOf("mailto:") != -1)
		isEmailOk = false;

	return isEmailOk;
} // Ends 

var myWind = "";

function validate(){

if(!document.cookie) 
	{
		alert("For security/anti spam reasons, this form requires cookies.");
		return false;
	}	

var msg='';
if(document.form3.name.value=="")
{
	alert("Name can't be left Blank") ;
	document.form3.name.focus() ;
	return false ;
	
}

if(document.form3.email.value=="")
{
	alert("Email can't be left Blank") ;
	document.form3.email.focus() ;
	return false ;
	
}
 var em=document.form3.email.value;
		var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
		var matchArray = em.match(emailPat);
		if (matchArray == null) 
		{
		 alert("Please enter a valid email address");
		 document.form3.email.focus();
	     return false;
    	}	

if(document.form3.comment.value=="")
{
	alert("Comments can't be left Blank") ;
	document.form3.comment.focus() ;
	return false ;
	
}

 var cm=document.form3.comment.value;
 var f = /<a/;
  var c = /<A/;
 var matchPos1 = cm.search(f);
  var matchPos2 = cm.search(c);
 if(matchPos1 != -1 || matchPos2 != -1)
	{
		alert("Please enter only charachters ");
		document.form3.comment.focus();
		return false;
	}

if (myWind == "" || myWind.closed || myWind.name == undefined) 
	{
		//alert(myWind.name+'checktrue');
		//document.form3.windowCheck.value='Open';
	myWind = window.open('validate2.php','_blank','height=210, width=550, left=350, top=300, menubar=no');
 		return false;
	} 
 	else
	{
		//alert(myWind.name+'checkfalse');
		alert("Please enter verification code given in image.");
		myWind.focus();
		//alert(myWind);
		return false;
	}
	
	/*
	if (removeAllSpaces(document.form3.name.value)==""){msg="Following Error occured..\n\nName can't be left Blank\n"; obj.name.value='';
	obj.name.focus();}
	if (removeAllSpaces(document.form3.email.value)==""){msg= msg + "Email can't be left Blank\n"; obj.email.value=''; obj.email.focus();}
	else
	{   var em=document.form3.email.value;
		var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
		var matchArray = em.match(emailPat);
		if (matchArray == null) 
		{
			msg= msg + "Email address seems incorrect. Please check the '@' and '.' in the email address\n";
			obj.email.value='';
			obj.email.focus();
		}
	}
	if (removeAllSpaces(document.form3.comment.value)==""){msg=msg + "Comments can't be left Blank\n"; 
	obj.comment.value='';
	obj.comment.focus();}


		
		if (msg!="" ){
		
		alert (msg);
		
		
		return false;
		
			
	}
	
	
	if(msg =="")
		
		{
			
		var myWind = "";
	 if(myWind == "" || myWind.closed || myWind.name == undefined) 
	    {
			
	    myWind = window.open('validate.php','_blank','height=210, width=550, left=350, top=300, menubar=no');
 	
		}		
		
		
		
		//if((msg =="") &&  state =="test")
		//{
		
//alert("press OK");
document.form3.submit();

	//}
	*/
//document.form3.submit();
return true;
}
 

 
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
 