//#
//EMAIL CHECK
		function check_email(e) 
		{
		ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
		
		for(i=0; i < e.length ;i++)
			{
		if(ok.indexOf(e.charAt(i))<0)
				{ 
		return (false);
				}	
			} 
		
		if (document.images) 
			{
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (!e.match(re) && e.match(re_two)) 
				{
		return (-1);		
				} 
			}
		}
//NUMBER ONLY
 function phonenumbersonly(e, decimal)
{
var key;
var keychar;

if (window.event) 
    {
      key = window.event.keyCode;
    }
else if (e) 
    {
     key = e.which;
    }
else 
    {
     return true;
    }
keychar = String.fromCharCode(key);

if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) )
   {
     return true;
   }
else if ((("0123456789-. ").indexOf(keychar) > -1))
   {
    return true;
   }
else if (decimal && (keychar == ".")) 
   { 
    return true;
   }
else
   return false;
}
//Name Charector only

function nameonly(e, decimal)
{
var key;
var keychar;

if (window.event) 
    {
      key = window.event.keyCode;
    }  
else if (e)
    {
     key = e.which;
    }
else
    {
      return true;
    }
keychar = String.fromCharCode(key);

if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) )
    {
      return true;
    }
else if ((("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ").indexOf(keychar) > -1))
    {
      return true;
    }
else if (decimal && (keychar == "."))
    { 
     return true;
    }
else
   return false;

}
//#Emai only

function emailonly(e, decimal)
{
var key;
var keychar;

if (window.event) 
    {
      key = window.event.keyCode;
    }  
else if (e)
    {
     key = e.which;
    }
else
    {
      return true;
    }
keychar = String.fromCharCode(key);

if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) )
    {
      return true;
    }
else if ((("1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM").indexOf(keychar) > -1))
    {
      return true;
    }
else if (decimal && (keychar == "."))
    { 
     return true;
    }
else
   return false;

}
//#Address
function addressonly(e, decimal)
{
var key;
var keychar;

if (window.event) 
    {
      key = window.event.keyCode;
    }
else if (e) 
    {
     key = e.which;
    }
else 
    {
     return true;
    }
keychar = String.fromCharCode(key);

if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) )
   {
     return true;
   }
else if ((("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-()/. ").indexOf(keychar) > -1))
   {
    return true;
   }
else if (decimal && (keychar == ".")) 
   { 
    return true;
   }
else
   return false;
}
	
//#subject
function subjectonly(e, decimal)
{
var key;
var keychar;

if (window.event) 
    {
      key = window.event.keyCode;
    }
else if (e) 
    {
     key = e.which;
    }
else 
    {
     return true;
    }
keychar = String.fromCharCode(key);

if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) )
   {
     return true;
   }
else if ((("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890- ").indexOf(keychar) > -1))
   {
    return true;
   }
else if (decimal && (keychar == ".")) 
   { 
    return true;
   }
else
   return false;
}

//#message

function messageonly(e, decimal)
{
var key;
var keychar;

if (window.event) 
    {
      key = window.event.keyCode;
    }
else if (e) 
    {
     key = e.which;
    }
else 
    {
     return true;
    }
keychar = String.fromCharCode(key);

if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) )
   {
     return true;
   }
else if ((("1234567890qwertyuiop[]{}asdfghjklzxcvbnm.,/-_QWERTYUIOPASDFGHJKLZXCVBNM").indexOf(keychar) > -1))
   {
    return true;
   }
else if (decimal && (keychar == ".")) 
   { 
    return true;
   }
else
   return false;
}

//# ON BLUR FUNCTIONS

//#name 

function onBlurName()
{
var contname=document.f.text_name

if ((contname.value==null)||(contname.value==""))
	{
	   document.getElementById("divtxtname").innerHTML = "Enter Your Name";
	}
           var nameChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
if(contname.value.length>0)
	{
 document.getElementById("divtxtname").innerHTML="";
for (var i = 0; i < contname.value.length; i++) 
	{
  	  if (nameChars.indexOf(contname.value.charAt(i)) == -1) 
  	      {
		 document.getElementById("divtxtname").innerHTML = "Only A-Z & a-z allowed";
  			
  	      }
	}

	  var nameChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
           if (nameChars.indexOf(contname.value.charAt(0)) == -1) 
  	      {
		 document.getElementById("divtxtname").innerHTML = "Invalid Name";
  			
  	      }
	}

}
//#Email
function onbluremail()
{
        var contemailb=document.f.text_email
        
	if ((contemailb.value==null)||(contemailb.value==""))
	{
		document.getElementById("divtxtemail").innerHTML = "Enter your EmailID";
	}
	
	if(contemailb.value.length>0)
	{
		document.getElementById("divtxtemail").innerHTML="";		
		if(!check_email(contemailb.value))
		{
		document.getElementById("divtxtemail").innerHTML = "Invalid EmailID";
		}
		
	}

}

//#Subject

function onblursubject()
{
var contsubject=document.f.text_suject



if ((contsubject.value==null)||(contsubject.value==""))
	{
	 document.getElementById("divtxtsubject").innerHTML = "Enter Your Subject";

	}
if(contsubject.value.length>0)
	{
	  document.getElementById("divtxtsubject").innerHTML="";	
          for (var i = 0; i < contsubject.value.length; i++) 
	      {
                var subChars = "asdfghjklqwertyuiopzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM_1234567890 -";

  	       if (subChars.indexOf(contsubject.value.charAt(i)) == -1) 
  		  {
		   document.getElementById("divtxtsubject").innerHTML = "Special Charectors not Allowed";	
                  }
	      }
          var subChars = "1234567890qwertyuiop[]{}asdfghjklzxcvbnm.,/-_QWERTYUIOPASDFGHJKLZXCVBNM";
          if (subChars.indexOf(contsubject.value.charAt(0)) == -1) 
  		{
		  document.getElementById("divtxtsubject").innerHTML = "Invalid Subject";	
                }
          
	}
         

}
//#Phone number
function onblurphone()
{
var contphone=document.f.text_phonenumber
if(contphone.value.length >0)
        {
          document.getElementById("divtxtphone").innerHTML="";
          if (contphone.value.length < 7)
			{
				document.getElementById("divtxtphone").innerHTML = "Invalid Phone Number";
			} 	

 		  var phoneChars="0123456789-. ";
          for (var i = 0; i < contphone.value.length; i++) 
		     {
	
	  	       if (phoneChars.indexOf(contphone.value.charAt(i)) == -1) 
	  	         {
			   document.getElementById("divtxtphone").innerHTML = "Invalid Phone Number";
	  			 }
	
             }
 
          var phoneChars="0123456789-.";
          if (phoneChars.indexOf(contphone.value.charAt(0)) == -1) 
  	        {
			  document.getElementById("divtxtphone").innerHTML = "Invalid Phone Number";
  			}

        } 
if ((contphone.value==null)||(contphone.value==""))
	{
	  document.getElementById("divtxtphone").innerHTML = "Enter your Phone Number";
	}

}
//#Address
function onbluraddress()
{
var contadd1=document.f.text_addressline1



if(contadd1.value.length>0)
	{
          document.getElementById("divtxtaddress1").innerHTML="";
          var AddChars1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-()/. ";
          for (var i = 0; i < contadd1.value.length; i++) 
	       {
  	         if (AddChars1.indexOf(contadd1.value.charAt(i)) == -1) 
  		    {
		       document.getElementById("divtxtaddress1").innerHTML = "Invalid Address";	
                    }
	       }

               var AddChars2 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-()/.";
              if (AddChars2.indexOf(contadd1.value.charAt(0)) == -1) 
  		{
		  document.getElementById("divtxtaddress1").innerHTML = "Invalid Address";	
                }
        }

if ((contadd1.value==null)||(contadd1.value==""))
	{
	  document.getElementById("divtxtaddress1").innerHTML = "Enter your Address";
	}

}
//#Address 2
function onbluraddress2()
{
var contadd2=document.f.text_addressline2
if(contadd2.value.length>0)
	{
          document.getElementById("divtxtaddress2").innerHTML="";
          var AddChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-()/.";
              if (AddChars.indexOf(contadd2.value.charAt(0)) == -1) 
  		{
		  document.getElementById("divtxtaddress2").innerHTML = "Invalid Address";	
                }

	}
else
        {
        document.getElementById("divtxtaddress2").innerHTML="";
        }
}
//#Address 3
function onbluraddress3()
{
var contadd3=document.f.text_addressline3
 
if(contadd3.value.length>0)
	{
         document.getElementById("divtxtaddress3").innerHTML="";
          var AddChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-()/.";
              if (AddChars.indexOf(contadd3.value.charAt(0)) == -1) 
  		{
		  document.getElementById("divtxtaddress3").innerHTML = "Invalid Address";	
                }

	}
else
        {
          document.getElementById("divtxtaddress3").innerHTML="";
        }
}
//#Message
function onblurmessage()
{
var contmessage=document.f.textarea_message

if(contmessage.value.length>0)
	{
           document.getElementById("divtxtmessage").innerHTML="";
           var msgChars = "1234567890qwertyuiop[]{}asdfghjklzxcvbnm.,/-_QWERTYUIOPASDFGHJKLZXCVBNM"; 
           if (msgChars.indexOf(contmessage.value.charAt(0)) == -1) 
  		{
		  document.getElementById("divtxtmessage").innerHTML = "Invalid Message";	
                }
	
          var msgChars = "1234567890qwertyuiop[]{}asdfghjklzxcvbnm.,/-_QWERTYUIOPASDFGHJKLZXCVBNM "; 
          for (var i = 0; i < contmessage.value.length; i++) 
	        {
  	           if (msgChars.indexOf(contmessage.value.charAt(i)) == -1) 
  		      {
		         document.getElementById("divtxtmessage").innerHTML = "Invalid Message";	
                      }
	         } 

        }
if ((contmessage.value==null)||(contmessage.value==""))
	{
	 document.getElementById("divtxtmessage").innerHTML = "Enter Your Message";
	}


}


//# SUBMIT VALIDATION

function validation()
{
var contname=document.f.text_name
var contemail=document.f.text_email
var contphone=document.f.text_phonenumber
var contadd1=document.f.text_addressline1
var contadd2=document.f.text_addressline2
var contadd3=document.f.text_addressline3
var contsubject=document.f.text_suject
var contmessage=document.f.textarea_message
var s=0;
if ((contname.value==null)||(contname.value==""))
	{
	   document.getElementById("divtxtname").innerHTML = "Invalid Name";
	   s++;
	}
           var nameChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";

for (var i = 0; i < contname.value.length; i++) 
	{
  	  if (nameChars.indexOf(contname.value.charAt(i)) == -1) 
  	      {
		     document.getElementById("divtxtname").innerHTML = "Only A-Z & a-z allowed";
  			 s++;
  	      }
	}
if(contname.value.length>0)
	{
	  var nameChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
           if (nameChars.indexOf(contname.value.charAt(0)) == -1) 
  	      {
		     document.getElementById("divtxtname").innerHTML = "Invalid Name";
  			 s++;
  	      }
	}

	if(!check_email(contemail.value))
	{
	  document.getElementById("divtxtemail").innerHTML = "Invalid EmailID";
	  s++;
	}
 
        var phoneChars="0123456789-. ";
 	
for (var i = 0; i < contphone.value.length; i++) 
	{

  	  if (phoneChars.indexOf(contphone.value.charAt(i)) == -1) 
  	        {
		     document.getElementById("divtxtphone").innerHTML = "Invalid Phone Number";
		     s++;
  		    }
	}
if ((contphone.value==null)||(contphone.value==""))
	{
	  document.getElementById("divtxtphone").innerHTML = "Invalid Phone Number";
	  s++;
	}
if(contphone.value.length >0)
        { 
          var phoneChars="0123456789-.";
          if (phoneChars.indexOf(contphone.value.charAt(0)) == -1) 
  	        {
			  document.getElementById("divtxtphone").innerHTML = "Invalid Phone Number";
			  s++;
  			}
        } 
var AddChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-()/. ";

for (var i = 0; i < contadd1.value.length; i++) 
	{
  	   if (AddChars.indexOf(contadd1.value.charAt(i)) == -1) 
  		{
		  document.getElementById("divtxtaddress1").innerHTML = "Invalid Address";
		  s++;	
        }
	}

if ((contadd1.value==null)||(contadd1.value==""))
	{
	  document.getElementById("divtxtaddress1").innerHTML = "Invalid Address";
	  s++;
	}
if(contadd1.value.length>0)
	{
          var AddChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-()/.";
              if (AddChars.indexOf(contadd1.value.charAt(0)) == -1) 
  		{
		  document.getElementById("divtxtaddress1").innerHTML = "Invalid Address";	
		  s++;
        }

	}
if(contadd2.value.length>0)
	{
          var AddChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-()/.";
              if (AddChars.indexOf(contadd2.value.charAt(0)) == -1) 
  		{
		  document.getElementById("divtxtaddress2").innerHTML = "Invalid Address";
		  s++;
        }

	}
if(contadd3.value.length>0)
	{
          var AddChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-()/.";
              if (AddChars.indexOf(contadd3.value.charAt(0)) == -1) 
  		{
		  document.getElementById("divtxtaddress3").innerHTML = "Invalid Address";	
          s++;
        }

	}

      
        var subChars = "asdfghjklqwertyuiopzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM_1234567890 -";


for (var i = 0; i < contsubject.value.length; i++) 
	{
  	   if (subChars.indexOf(contsubject.value.charAt(i)) == -1) 
  		{
		  document.getElementById("divtxtsubject").innerHTML = "Special Charectors not Allowed";	
          s++;
        }
	}
if ((contsubject.value==null)||(contsubject.value==""))
	{
	 document.getElementById("divtxtsubject").innerHTML = "Invalid Subject";
	 s++;
	}
if(contsubject.value.length>0)
	{
          var subChars = "1234567890qwertyuiop[]{}asdfghjklzxcvbnm.,/-_QWERTYUIOPASDFGHJKLZXCVBNM";
          if (subChars.indexOf(contsubject.value.charAt(0)) == -1) 
  		{
		  document.getElementById("divtxtsubject").innerHTML = "Invalid Subject";	
		  s++;
        }
          
	}
         
 var msgChars = "1234567890qwertyuiop[]{}asdfghjklzxcvbnm.,/-_QWERTYUIOPASDFGHJKLZXCVBNM "; 
for (var i = 0; i < contmessage.value.length; i++) 
	{
  	   if (msgChars.indexOf(contmessage.value.charAt(i)) == -1) 
  		{
		  document.getElementById("divtxtmessage").innerHTML = "Invalid Message";
		  s++;
        }
	} 

if ((contmessage.value==null)||(contmessage.value==""))
	{
	 document.getElementById("divtxtmessage").innerHTML = "Invalid Message";
	 s++;
	}
if(contmessage.value.length>0)
	{
var msgChars = "1234567890qwertyuiop[]{}asdfghjklzxcvbnm.,/-_QWERTYUIOPASDFGHJKLZXCVBNM"; 
           if (msgChars.indexOf(contmessage.value.charAt(0)) == -1) 
  		{
		  document.getElementById("divtxtmessage").innerHTML = "Invalid Message";
		  s++;	
        }
	}
 if(s==0)
 {
 	
 	document.f.submit();
 
 }           
}

