<!--
var i;
var SenderNameCount; 
var FromEmailCount; 
var ToEmailCount; 

var ESubjectCount;

var intToEmailAddressIndex;

var elementname;
var strElementName;

function validate()
{
  with (document.emailproductform)
  { 
	 SenderNameCount = 0;    
	
	 FromEmailCount = 0;
	 ToEmailCount = 0;
    
	 var apostrapheindex;
	 var spaceindex;
	 var periodindex;
	 var tempdesc;
	 var tempword;	
	 var midinitialerror;
	 var sendernamecounterror;

     var SenderNameArray;
	
     var spacecount;
	 var wordcount;
	 var apostraphecount;	 
	 var wordcounter;
	
	 firsttime = "true";
	 midinitialerror = "false";
	 sendernamecounterror = "false";
	
	 spacecount = 0;
	 wordcount = 0;	
	 apostraphecount = 0;
	 wordcounter = 0;
	 i = 0;
	    
	
		
		apostrapheindex = SenderName.value.indexOf("'");
		spaceindex = SenderName.value.indexOf(" ");
		tempdesc = SenderName.value;

        if (apostrapheindex > -1)
		{
		   while (spaceindex > -1)
		   {
			   spacecount = spacecount + 1;
			   tempdesc = tempdesc.substr(spaceindex + 1, tempdesc.length);	
			   spaceindex = tempdesc.indexOf(" ");			   
		   }

		    wordcount = spacecount + 1;
			SenderNameArray = new Array(wordcount);

			tempdesc = SenderName.value;
			
			if (spacecount == 0)
			{
			  SenderNameArray[0] = tempdesc;
			  tempword = tempdesc;
			  apostrapheindex = tempword.indexOf("'"); 

			  while (apostrapheindex > -1 )
		         {				   
		           apostraphecount = apostraphecount + 1;
		           tempword = tempword.substr(apostrapheindex + 1, tempword.length);				 
				   apostrapheindex = tempword.indexOf("'"); 
		         }
			   
			  if (apostraphecount > 1)
			      {		
				     sendernamecounterror = "true";				     		   
			      }


			}
			else
			{
			    spaceindex = tempdesc.indexOf(" ");
				tempword = tempdesc.substr(0, spaceindex);	
				tempdesc = tempdesc.substr(spaceindex + 1, tempdesc.length);
				wordcounter = wordcounter + 1;				
				SenderNameArray[0] = tempword;
               
				while (wordcounter < wordcount)
			    {

				   spaceindex = tempdesc.indexOf(" ");
				  
				   if (spaceindex > - 1)
				    {  
					 tempword = tempdesc.substr(0, spaceindex);
					 wordcounter = wordcounter + 1;
					 i = i + 1;
				     SenderNameArray[i] = tempword;
				   
					 tempdesc = tempdesc.substr(spaceindex + 1, tempdesc.length);					
					
				    }	
				   else
				    {
					  tempword = tempdesc.substr(0, tempdesc.length);
					  wordcounter = wordcounter + 1;
					  i = i + 1;
				      SenderNameArray[i] = tempword;
                     
					  tempdesc = tempdesc.substr(0, tempdesc.length); 
					 
				    }                
				}

               wordcounter = 0;

			   while (wordcounter < wordcount)
			   {
				  apostraphecount = 0;
				  SenderNameCount = 0;

				  tempword = SenderNameArray[wordcounter];				 
				  periodindex = tempword.indexOf("."); 
			      apostrapheindex = tempword.indexOf("'"); 
			   
                  if (apostrapheindex > -1)
                  {              
                    if (periodindex > -1)
                     {
				       midinitialerror = "true";					   
                     }
                    else if (tempword.length < 3)
					 {
					  midinitialerror = "true";
					 }
					else
					  {                      
                        
			            while (apostrapheindex > -1 )
		                {
						 
						 SenderNameCount = SenderNameCount + 1;			

		                 apostraphecount = apostraphecount + 1;
		                 tempword = tempword.substr(apostrapheindex + 1, tempword.length);	
				 
				         apostrapheindex = tempword.indexOf("'"); 
		                 }
			          
			         
					     if (apostraphecount > 1)
			             {						   
				           SenderNameCount = SenderNameCount + 1;				   
			             }

						if (SenderNameCount > 1 )
						{
						  sendernamecounterror = "true";
						}
					  }
			      }

                  wordcounter = wordcounter + 1;
			   }				

			
			}			  	
			
		}			
			    
        
		apostrapheindex = ESubject.value.indexOf("'"); 
        if (apostrapheindex > -1) 
	    {
		  ESubjectCount = ESubjectCount + 1;
		  tempdesc = ESubject.value.substr(apostrapheindex + 1);
		 
		  apostrapheindex = tempdesc.indexOf("'"); 
		 
		  if (apostrapheindex > -1)
		  {
			ESubjectCount = ESubjectCount + 1;
		  }
	    }

		apostrapheindex = FromEmailAddress.value.indexOf("'"); 
        if (apostrapheindex > -1) 
	    {
		  FromEmailCount = FromEmailCount + 1;
		}

		apostrapheindex = ToEmailAddress.value.indexOf("'"); 
        if (apostrapheindex > -1) 
	    {
		  ToEmailCount = ToEmailCount + 1;
		}	 
	  
        if (SenderName.value.length == 0)
	    {
         alert("Please enter your name!");
		 SenderName.focus();
		 return false;
	    }

       if (SenderName.value.length > 50)
       {
	     alert("Your first name may not be more than 50 characters.");
		 SenderName.focus();
		 return false;
	   }

       if (SenderName.value.indexOf(";") > -1)
       {
	    alert("Please do not include a semicolon in name.");
	    SenderName.focus();
		return false;	     
       } 

       if (SenderName.value.indexOf("|") > -1)
       {
	    alert("Please do not include a break bar in name.");
	    SenderName.focus();
		return false;	     
       }
  
       if (SenderName.value.indexOf('"') > -1)
      {
	    alert("Please do not include a quote in name.");
	    SenderName.focus();
		return false;	     
      } 


      if (SenderName.value.indexOf("\\") > -1)
      {
	    alert("Please do not include a backslash in name.");
	    SenderName.focus();
		return false;	     
      }  
  

     if (midinitialerror == "true")
     {
	   alert("Please do not include an apostraphe in the middle initial.");
	   SenderName.focus();
	   return false;	     
     }

    if (sendernamecounterror == "true")
    {
	 alert("Please do not include more than one apostraphe in first, middle or last name.");
	 SenderName.focus();
	 return false;	     
    }		

    if (FromEmailAddress.value.length == 0)
	 {
         alert("Please enter your Email address!");
		 FromEmailAddress.focus();
		 return false;
	 }

    if (FromEmailAddress.value.length > 50)
     {
	     alert("From Email address may not be more than 50 characters.");
		 FromEmailAddress.focus();
		 return false;
	 }


    if (FromEmailCount > 0)
    {
	     alert("Please do not include an apostraphe in email!");
		 FromEmailAddress.focus();
		 return false;	     
    }

     if (FromEmailAddress.value.indexOf(",") > -1)
     {
	    alert("Please do not include a comma in email.");
	    FromEmailAddress.focus();
		return false;
	     
     } 
 
     if (FromEmailAddress.value.indexOf(";") > -1)
     {
	    alert("Please do not include a semicolon in email.");
	    FromEmailAddress.focus();
		return false;
	     
     } 

     if (FromEmailAddress.value.indexOf("|") > -1)
     {
	    alert("Please do not include a break bar in email.");
	    FromEmailAddress.focus();
		return false;
	     
     } 


     if (FromEmailAddress.value.indexOf('"') > -1)
     {
	    alert("Please do not include a quote in email.");
	    FromEmailAddress.focus();
		return false;
	     
     } 

 
     if (FromEmailAddress.value.indexOf("\\") > -1)
     {
  	    alert("Please do not include a backslash in email.");
	    FromEmailAddress.focus();
		return false;
	     
     } 

      if (FromEmailAddress.value.indexOf(" ") > -1)
     {
	    alert("Please do not include a space in email.");
	    FromEmailAddress.focus();
		return false;
	     
     } 

    
     var ind = FromEmailAddress.value.indexOf("@");
     if (ind == -1)
	 {
      alert("Please type in a valid E-mail address!");
      FromEmailAddress.focus()
      FromEmailAddress.select();
      return false;
     }

     if (FromEmailAddress.value.indexOf(".",ind) == -1)
     {
      alert("Please type in a valid E-mail address!");
      FromEmailAddress.focus()
      FromEmailAddress.select();
      return false;
     }
    
	

     if (ToEmailAddress.value.length == 0)
	 {
         alert("Please enter send to Email address!");
		 ToEmailAddress.focus();
		 return false;
	 }

     if (ToEmailAddress.value.length > 50)
     {
	     alert("Email address may not be more than 50 characters.");
		 ToEmailAddress.focus();
		 return false;
	 }


     if (ToEmailCount > 0)
     {
	     alert("Please do not include an apostraphe in email!");
		 ToEmailAddress.focus();
		 return false;
	     
     }

	 if (ToEmailAddress.value.indexOf(",") > -1)
     {
	    alert("Please do not include a comma in email.");
	    ToEmailAddress.focus();
		return false;
	     
     } 

     if (ToEmailAddress.value.indexOf(";") > -1)
     {
	    alert("Please do not include a semicolon in email.");
	    ToEmailAddress.focus();
		return false;
	     
     } 

      if (ToEmailAddress.value.indexOf("|") > -1)
     {
	    alert("Please do not include a break bar in email.");
	    ToEmailAddress.focus();
		return false;
	     
     } 


     if (ToEmailAddress.value.indexOf('"') > -1)
     {
	    alert("Please do not include a quote in email.");
	    ToEmailAddress.focus();
		return false;
	     
     } 

 
      if (ToEmailAddress.value.indexOf("\\") > -1)
     {
	    alert("Please do not include a backslash in email.");
	    ToEmailAddress.focus();
		return false;
	     
     } 

       if (ToEmailAddress.value.indexOf(" ") > -1)
     {
	    alert("Please do not include a space in email.");
	    ToEmailAddress.focus();
		return false;
	     
     } 

   

     var ind = ToEmailAddress.value.indexOf("@");
     if (ind == -1)
	 {
      alert("Please type in a valid E-mail address!");
      ToEmailAddress.focus()
      ToEmailAddress.select();
      return false;
     }

     if (ToEmailAddress.value.indexOf(".",ind) == -1)
     {
      alert("Please type in a valid E-mail address!");
      ToEmailAddress.focus()
      ToEmailAddress.select();
      return false;
     }
     
    
      for (i = 0; i < emailproductform.length ; i++)
	  {
          
		   elementname = emailproductform.elements[i];
		  
		   if (elementname.type == "text")
		   { 	
			
			 strElementName = elementname.name;

			
			 intToEmailAddressIndex = strElementName.indexOf("ToEmailAddress0");
			 
		
			 if (intToEmailAddressIndex == -1)
			 {
			    intToEmailAddressIndex = strElementName.indexOf("ToEmailAddress10");	
			 }
			
			   if (intToEmailAddressIndex > -1)
			    {                 
		        
                   if (elementname.value.length > 50)
                    {
	                  alert("Email address may not be more than 50 characters.");
		              elementname.focus();
		              return false;
	                }


				    if (elementname.value.indexOf("'") > -1)
                    {
	                  alert("Please do not include an apostraphe in email.");
	                  elementname.focus();
		              return false;
	     
                    } 

                    if (elementname.value.indexOf(",") > -1)
                      {
	                     alert("Please do not include a comma in email.");
	                     elementname.focus();
		                 return false;	     
                      } 

                     if (elementname.value.indexOf(";") > -1)
                    {
	                  alert("Please do not include a semicolon in email.");
	                  elementname.focus();
		              return false;
	     
                    } 

                   
                    if (elementname.value.indexOf("|") > -1)
                    {
	                  alert("Please do not include a break bar in email.");
	                  elementname.focus();
		              return false;	     
                    } 


                    if (elementname.value.indexOf('"') > -1)
                    {
	                 alert("Please do not include a quote in email.");
	                 elementname.focus();
		             return false;	     
                    } 

 
                    if (elementname.value.indexOf("\\") > -1)
                    {
	                 alert("Please do not include a backslash in email.");
	                 elementname.focus();
		            return false;
	     
                  } 

                   if (elementname.value.indexOf(" ") > -1)
                      {
	                     alert("Please do not include a space in email.");
	                     elementname.focus();
		                 return false;	     
                      }
					  
				
                  var ind = elementname.value.indexOf("@");

				  if (elementname.value.length > 0)
				  {				  
                      if (ind == -1)
	                  {
                        alert("Please type in a valid E-mail address!");
                        elementname.focus()
                        elementname.select();
                        return false;
                      }

                     if (elementname.value.indexOf(".",ind) == -1)
                      {
                        alert("Please type in a valid E-mail address!");
                        elementname.focus()
                        elementname.select();
                       return false;
                      }

					

				  }

                }      
           }             
        
	  } 

  
     if (ESubject.value.length == 0)
	 {
         alert("Please enter subject of Email.");
		 ESubject.focus();
		 return false;
	 }

     if (ESubject.value.length > 100)
     {
	     alert("Email subject may not be more than 100 characters.");
		 ESubject.focus();
		 return false;
	 }


     if (ESubjectCount > 1)
     {
	     alert("Please include only one apostraphe in email subject.");
		 ESubject.focus();
		 return false;
	     
     }

	  if (ESubject.value.indexOf('"') > -1)
     {
	    alert("Please do not include a quote in email subject.");
	    ESubject.focus();
		return false;
	     
     } 

 
      if (ESubject.value.indexOf("\\") > -1)
     {
	    alert("Please do not include a backslash in email subject.");
	    ESubject.focus();
		return false;
	     
     } 


	 if (EMessage.value.length == 0)
	 {
         alert("Please enter message!");
		 EMessage.focus();
		 return false;
	 }

  }  
 }
 //-->



