function checkFields2()
      {
      var dispVal="";
      var show=0;
      reEmail = new RegExp(/^([a-zA-Z0-9])+([.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-]+)+/);
      var email=document.forms.pdfsub.pdfemail.value;
   
		if((!validateNotEmpty(email)||!reEmail.test(email)))
		{
            if(dispVal!="")
               dispVal = dispVal + ",";
            else
               document.forms.pdfsub.pdfemail.focus();
          
            dispVal = dispVal+"Please enter a valid address.";
            show=1;
         }
      //alert(dispVal);
         if(show==1)
            dispVal="<table><tr><td><b><font color=\"red\" style=\"font-size:10px;\">" + dispVal + "</font></b><br></td></tr></table>";
         else
         {
            dispVal="";
            document.pdfsub.submit();  
         }   
         pdfsubErrors.innerHTML = dispVal;            
      }


function checkFields()
      {
      var dispVal="";
      var show=0;
      //reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
      reEmail = new RegExp(/^([a-zA-Z0-9])+([.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-]+)+/);
     // var zip=document.forms.decorHelp.zip.value;
      var fname=document.forms.decorHelp.fullname.value;  
	  var phone=document.forms.decorHelp.phone.value; 
     // var lname=document.forms.decorHelp.lastname.value;
     // var address1=document.forms.decorHelp.add1.value;
     // var city=document.forms.decorHelp.city.value;
    //  var state=document.forms.decorHelp.state.value;
    //  var zip=document.forms.decorHelp.zip.value;
      var email=document.forms.decorHelp.email.value;
      var jpcValue=document.forms.decorHelp.listed.checked;

         if(!validateNotEmpty(fname))
         {
            dispVal="Full Name";  
            document.forms.decorHelp.fullname.focus();    
            show=1;
         }   
	     if(!validateNotEmpty(phone))
         {
            if(dispVal!="")
               dispVal = dispVal + ",";
            else   
               document.forms.decorHelp.phone.focus();      
            dispVal = dispVal+" Telephone";
            show=1;
         }
		 else if (checkInternationalPhone(phone)==false)
		 {
			if(dispVal!="")
               dispVal = dispVal + ",";
        	else   
               document.forms.decorHelp.phone.focus();      
            dispVal = dispVal+" Please Enter a Valid Phone Number";
            show=1;
		}
         if((!validateNotEmpty(email)||!reEmail.test(email))&& jpcValue==true)
         {
            if(dispVal!="")
               dispVal = dispVal + ",";
            else
               document.forms.decorHelp.email.focus();
          
            dispVal = dispVal+" Email Address";
            show=1;
         }
      //alert(dispVal);
         if(show==1)
            dispVal="<table><tr><td colspan=\"2\"><b><u><font color=\"red\" style=\"font-size:11px;\">Please Enter the following...</u><br>"+dispVal+"</font></b><br></td></tr></table>";
         else
         {
            dispVal="";
            document.decorHelp.submit();  
         }   
         decorHelpErrors.innerHTML = dispVal;   
            
      }


      function validateNotEmpty(strValue) {
         var strTemp = strValue;
         strTemp = trimAll(strTemp);
         if(strTemp.length > 0)
         {
           return true;
         }
         return false;
      }
      function trimAll( strValue ) {
       var objRegExp = /^(\s*)$/;

          //check for all spaces
          if(objRegExp.test(strValue)) {
             strValue = strValue.replace(objRegExp, '');
             if( strValue.length == 0)
                return strValue;
          }

         //check for leading & trailing spaces
         objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
         if(objRegExp.test(strValue)) {
             //remove leading and trailing whitespace characters
             strValue = strValue.replace(objRegExp, '$2');
          }
        return strValue;
      }


      function checkEmail()
      {
         var jpcValue=document.forms.decorHelp.listed.checked;
         if(jpcValue==true)
         {
            emailAst.style.display = "inline";
         }
         else
         {
            emailAst.style.display = "none";
         }   
      }
	  
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

