function validation_of_site_search_form(form)
{
  if ((form.query.value == null)  ||
      (form.query.value == "Search") ||
      (form.query.value == "")    || 
       isBlank(form.query.value))  {
     alert("Please enter keyword(s) to Search");
     form.query.focus();
     return false;
  }
  else
  { 
     return true;
  }
}	  

function validation_of_signup(form)
{
  if ((form.login_email.value == null)  ||
      (form.login_email.value == "Enter e-mail") ||
      (form.login_email.value == "")    || 
       isBlank(form.login_email.value))  {
     alert("Please enter your e-mail");
     form.login_email.focus();
     return false;
  }
  else
  { 
     return true;
  }
}	

function isBlank(str)
{
   for(var i = 0; i < str.length; i++)
   {
      var chr = str.charAt(i);
      if ((chr != ' ') && (chr != '\n') && (chr != '\t')) return false;
   }
   return true;
}		

function validation_of_plan_finder_form(form)
{
  if ((form.zipcode.value == null)  ||
      (form.zipcode.value == "Enter Your Zip Code") || 
      (form.zipcode.value == "")    ||  
       isBlank(form.zipcode.value))  {
     alert("Please enter a zipcode");
     form.zipcode.focus();
     return false;
  }
  else
  { 
     
    if (confirm("You are now leaving bcbs.com and going to the website of the local Blue company you selected.  Information for Blue company members can be found on the website of the Blue company providing the health coverage.\n\nEach Blue company is responsible for the content and experience on its website, including the policies and terms that apply to use of the site."))
window.open("http://apps.bcbs.com/cgi-bin/bcbs_com_finder.cgi?zipcode=" + document.zipcode.zipcode.value);
    else
         return false;
	 
  }
}


function validation_of_plan_finder_form_Main(form)
{
  if ((form.zipcode1.value == null)  ||
      (form.zipcode1.value == "Enter Zip Code") || 
      (form.zipcode1.value == "")    ||  
       isBlank(form.zipcode1.value))  {
     alert("Please enter a zipcode");
     form.zipcode1.focus();
     return false;
  }
  else
  { 
     
    if (confirm("You are now leaving bcbs.com and going to the website of the local Blue company you selected.  Information for Blue company members can be found on the website of the Blue company providing the health coverage.\n\nEach Blue company is responsible for the content and experience on its website, including the policies and terms that apply to use of the site."))
window.open("http://apps.bcbs.com/cgi-bin/bcbs_com_finder.cgi?zipcode=" + document.zipcode1.zipcode1.value);
    else
         return false;
	 
  }
}


function validation_of_plan_finder_form_Main2(form)
{
  if ((form.zipcode2.value == null)  ||
      (form.zipcode2.value == "Enter Zip Code") || 
      (form.zipcode2.value == "")    ||  
       isBlank(form.zipcode2.value))  {
     alert("Please enter a zipcode");
     form.zipcode2.focus();
     return false;
  }
  else
  { 
     
    if (confirm("You are now leaving bcbs.com and going to the website of the local Blue company you selected.  Information for Blue company members can be found on the website of the Blue company providing the health coverage.\n\nEach Blue company is responsible for the content and experience on its website, including the policies and terms that apply to use of the site."))
window.open("http://apps.bcbs.com/cgi-bin/bcbs_com_finder.cgi?zipcode=" + document.zipcode2.zipcode2.value);
    else
         return false;
	 
  }
}


//

function planLinks(url) {
  if (confirm("You are now leaving bcbs.com and going to the website of the local Blue company you selected.  Information for Blue company members can be found on the website of the Blue company providing the health coverage.\n\nEach Blue company is responsible for the content and experience on its website, including the policies and terms that apply to use of the site.")) {
    document.location = url;
  }
}

//

	 
function validation_of_agency_finder_form(form)
{
  if ((form.agency_zip.value == null)  ||
      (form.agency_zip.value == "Enter zip code") ||
	  (form.agency_zip.value == "Zip Code") ||
      (form.agency_zip.value == "")    || 
       isBlank(form.agency_zip.value))  {
     alert("Please enter a zipcode");
     form.agency_zip.focus();
     return false;
  }
  else
  { 
     return true;
  }
}


function validation_of_pedometer_finder_form(form)
{
  if ((form.zipcode.value == null)  ||
      (form.zipcode.value == "")    || 
       isBlank(form.zipcode.value))  {
     alert("Please enter a zipcode");
     form.zipcode.focus();
     return false;
  }
  else
  {      
     window.open("http://apps.bcbs.com/cgi-bin/pedometer_finder.cgi?zipcode=" + document.pedometer.zipcode.value);      
     
     //******
     //document.zipcode.action="http://apps.bcbs.com/cgi-bin/pedometer_finder.cgi";     
     //document.zipcode.method="post";
     //document.zipcode.submit();
     return true;
     //******
  }
}



function validate_news_signup(form) { 
var news_email= form.email.value;

  if ((news_email == null)  ||
      (news_email == "Enter e-mail") ||
      (news_email == "")    || 
       isBlank(news_email))  {
     alert("Please enter an email");
     form.email.focus();
     return false;
  }	
  
  // Assemble the TLD array. Warn on invalid email TLD.
  var tlds = ['AC','AD','AE','AERO','AF','AG','AI','AL','AM','AN','AO','AQ','AR','ARPA','AS','AT','AU','AW','AZ','BA','BB','BD','BE','BF','BG','BH','BI','BIZ','BJ','BM','BN','BO','BR','BS','BT','BV','BW','BY','BZ','CA','CC','CD','CF','CG','CH','CI','CK','CL','CM','CN','CO','COM','COOP','CR','CU','CV','CX','CY','CZ','DE','DJ','DK','DM','DO','DZ','EC','EDU','EE','EG','ER','ES','ET','EU','FI','FJ','FK','FM','FO','FR','GA','GB','GD','GE','GF','GG','GH','GI','GL','GM','GN','GOV','GP','GQ','GR','GS','GT','GU','GW','GY','HK','HM','HN','HR','HT','HU','ID','IE','IL','IM','IN','INFO','INT','IO','IQ','IR','IS','IT','JE','JM','JO','JP','KE','KG','KH','KI','KM','KN','KR','KW','KY','KZ','LA','LB','LC','LI','LK','LR','LS','LT','LU','LV','LY','MA','MC','MD','MG','MH','MIL','MK','ML','MM','MN','MO','MP','MQ','MR','MS','MT','MU','MUSEUM','MV','MW','MX','MY','MZ','NA','NAME','NC','NE','NET','NF','NG','NI','NL','NO','NP','NR','NU','NZ','OM','ORG','PA','PE','PF','PG','PH','PK','PL','PM','PN','PR','PRO','PS','PT','PW','PY','QA','RE','RO','RU','RW','SA','SB','SC','SD','SE','SG','SH','SI','SJ','SK','SL','SM','SN','SO','SR','ST','SU','SV','SY','SZ','TC','TD','TF','TG','TH','TJ','TK','TL','TM','TN','TO','TP','TR','TT','TV','TW','TZ','UA','UG','UK','UM','US','UY','UZ','VA','VC','VE','VG','VI','VN','VU','WF','WS','YE','YT','YU','ZA','ZM','ZW'];

  
	if ( news_email != null && news_email != "" ) {
		var emailPattern = /^\w.*@\w.+\.[a-z]+$/i;
		if ( ! emailPattern.test(news_email) ) {
		alert("The email address supplied is not valid. Please check that the email address matches the format user@example.com.");
		return false;
		}
		var examplePattern = /[.@]example\.[^.]+$/i;
		if ( examplePattern.test(news_email) ) {
		alert("The email address supplied is not valid. Please check that the email address matches the format user@example.com.");
		return false;
		}
	}  
	
	var isValidTLD = false;
    var tldIndex = news_email.lastIndexOf(".")+1;
  	if ( 0 < tldIndex && tldIndex < news_email.length ) {
      var tld = news_email.substr(tldIndex).toUpperCase();
      for (i=0; i<tlds.length; i++) {
        if ( tld == tlds[i] ) {
          isValidTLD = true;
          break;
        }
      }      
    }
  
  	if ( !isValidTLD ) {
      alert("WARNING: The email address supplied does not contain a valid top level domain such as .com or .org.")
        return false;
    }	
	
	
	  else{
	  	return true;
	  }
	

}
