function isEmpty(mytext) {
	var re = /^\s{1,}$/g; //match any white space including space, tab, form-feed, etc.
	/* 	REGEXP DOCUMENTATION
		/^ 	 :  Forward slash escapes the "^" character which represents beginning of input line (here matches whitespace)
		\s	 :	A whitespace character (same as [ \t\v\n\r\f])
		{1,} :	Must occur at least 1 time.
		$ 	 : 	Matches at the end of the string.
		\g 	 :	Match all instances of a pattern in a string (any whitespace)
	*/
	if ((mytext.value.length==0) || (mytext.value==null) || ((mytext.value.search(re)) > -1)) {
		return true;
	} else {
		return false;
	}
}

function checkform (form) {

  var v = new VerifyForm();

   if ( ! v.hasValue(form.howmany) || isEmpty(form.howmany) ) {
 v.addError(form.howmany,     "The number of copies you plan to distribute is required in a numeric format and should not be 0");
   } else {
  if ( ! v.validNumeric(v.getValue(form.howmany)) || parseInt(v.getValue(form.howmany)) < 1 ) 
     v.addError(form.howmany,     "The number of copies you plan to distribute is required in a numeric format and should not be 0");
   }
		
  if ( ! v.hasValue(form.proposeduse) )
    v.addError(form.proposeduse,  "Proposed use is required");
	
   if (v.hasValue(form.proposeduse) && v.getValue(form.proposeduse) == 'Internal_Web_site_ or_server') {
	   
	   if ( ! v.hasValue(form.web_distrib) )
	   v.addError(form.web_distrib,  "Since you've selected Internal Web site or server for the Proposed use, an answer for the update manager question is required");
   }
   
  if ( ! v.hasValue(form.distrb_platform))
    v.addError(form.distrb_platform,      "Distributing platform is required");
 
  if ( ! v.hasValue(form.betauser))
    v.addError(form.betauser,      "An answer for the next Adobe Reader beta program question is required");
 
 if ( ! v.hasValue(form.new_version_mail))
    v.addError(form.new_version_mail,      "An answer for new versions/updates notice mail question is required");
		
  if ( ! v.hasValue(form.FirstName) || isEmpty(form.FirstName) )
    v.addError(form.FirstName,      "First Name is required");
		
  if ( ! v.hasValue(form.LastName) || isEmpty(form.LastName) )
    v.addError(form.LastName,      "Last Name is required");
		
  if ( ! v.hasValue(form.Title) || isEmpty(form.Title) )
    v.addError(form.Title,   "Title is required");
		
  if ( ! v.hasValue(form.JobFunction) )
    v.addError(form.JobFunction,   "Job Function is required");
		
//  if ( ! v.hasValue(form.Phone) || isEmpty(form.Phone) )
//    v.addError(form.Phone,   "Phone number is required");	
		
//  if ( ! v.hasValue(form.Email) || isEmpty(form.Email) )
//    v.addError(form.Email,   "Company e-mail address is required");	
		
   if ( v.hasValue(form.Email) && ! v.validEmail(v.getValue(form.Email)) )
    v.addError(form.Email,     "Invalid E-mail Address");	
		
  if ( ! v.hasValue(form.Address1) || isEmpty(form.Address1) )
    v.addError(form.Address1,  "Address is required"); 
		
   if ( ! v.hasValue(form.City) || isEmpty(form.City) )
    v.addError(form.City,   "City is required"); 
		
  if ( ! v.hasValue(form.Country) || isEmpty(form.Country) )
    v.addError(form.Country,   "Country is required");  
		
 if ( ! v.hasValue(form.State) && v.hasValue(form.Country) && v.isNA(v.getValue(form.Country)) )
    v.addError(form.State, "State/province is required if you reside in the North America");
		
  if ( v.hasValue(form.State) && ! v.validState(v.getValue(form.State), v.getValue(form.Country)) )
    v.addError(form.State,     "Invalid State/province for " + v.getValue(form.Country));  
		
if ( v.hasValue(form.Country) && v.isNA(v.getValue(form.Country)) ) {
 if (! v.hasValue(form.Zip) || isEmpty(form.Zip)) {
   v.addError(form.Zip, "Zip/postal is required if you reside in North America");
  } else {
   if ( ! v.validZip(v.getValue(form.Zip), v.getValue(form.Country)) )
   v.addError(form.Zip,       "Invalid Zip/postal code for " + v.getValue(form.Country)); 
  }
 }		 

  //if ( v.hasValue(form.Zip) && ! v.validZip(v.getValue(form.Zip), v.getValue(form.Country)) || isEmpty(form.Zip) )
    //v.addError(form.Zip,       "Invalid Zip/postal code for " + v.getValue(form.Country)); 
		

  return v.showErrors('Oops! Your form input has some problems:\n',
    '\nPlease fill out the form properly and try again!');
}

function display(obj,id1) {
	txt = obj.options[obj.selectedIndex].value;
	document.getElementById(id1).style.display = 'none';
	if ( txt.match(id1) ) {
	document.getElementById(id1).style.display = '';
	}
}

function setOther(sel) {
	var selectionValue = sel.value;
		if (selectionValue == "United States") {
			document.distrib_form.AdobeInfoByMail.checked = true;
			document.distrib_form.AdobeInfoByEmail.checked = true;
			document.distrib_form.AdobeInfoByPhone.checked = true;
		} else {
			document.distrib_form.AdobeInfoByMail.checked = false;
			document.distrib_form.AdobeInfoByEmail.checked = false;
			document.distrib_form.AdobeInfoByPhone.checked = false;
		}			
}
