<!-- // Hide JS code from non-JavaScript browsers
function  checkreg_form() {

	return checkinput(document.reg_form) ;

    return true;
}
function  checkvisit_form() {

	return checkinput2(document.visit_form) ;

    return true;
}

//----------
// checkEmail - syntax check an email address
//
//  This email validation function will only return true if the following
//  conditions are true of the email address:
//  *       Contains only one "@" symbol.
//  *       Contains the domain name in the address.
//  *       Does not contain two periods next to eachother.
//  *       Does not contain any special characters in the address.
//  *       Does not contain any spaces.
//  Since the email address is converted to lower case, the function
//  is not case sensitive.
//
// INPUT: arg0 = text string - email address
//
// OUTPUT: return true if all ok, else popup error and return false
//
// NOTE: if either is blank ignore checks and return success
//----------


function checkEmail (emailStr) {

/* convert the email strain to lower case */
var emailStr = emailStr.toLowerCase();

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Detects multiple "@" symbols.. */

alert("The email address format is incorrect.  Please check @ and .'s ");
return false;
}

var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("The username doesn't seem to be valid. Please re-enter your full email address - i.e your.user.name@lmco.com");
return false;
}


// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.  Please re-enter your full email address - i.e your.user.name@lmco.com");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end with a well-known domain or at least two letter " + "country. - i.e. @xxxx.com");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("This address is missing a hostname! ( i.e. @lmco.xxx )  Please re-enter your full email address - i.e your.user.name@lmco.com");
return false;
}

return true;
}

//----------
// trim_me - Remove lead/trail whitespace from a text object
//
// INPUT:    t=input box
// OUTPUT:   actual input box's value changed
// USAGE:    (input type="text" name="xx" onBlur="trim_me(this)" size="10" ...etc....)
//----------
function trim_me(t)
  {
  t.value = remove_lead_and_trial_spaces(t.value);
  return true;
  }
  
//----------
// trim_and_upper - Remove lead/trail whitespace from a text object and make uppercase
//
// INPUT:    t=input box
// OUTPUT:   actual input box's value changed
// USAGE:    (input type="text" name="xx" onBlur="trim_and_upper(this)" size="10" ...etc....)
//----------
function trim_and_upper(t)
  {
  t.value = remove_lead_and_trial_spaces(t.value);
  t.value = t.value.toUpperCase();
  return true;
  }
 
//----------
// remove_lead_and_trial_spaces() - just what it says
// INPUT:  s = string to fix
// OUTPUT: fixed string
//----------
function remove_lead_and_trial_spaces (s) {
	if (!(typeof (s) == "string")) {  return (null);  }
	if (s.length == 0) {  return ("");  }

	var done = false;			// remove lead spaces
	for (i=0; (done != true) ; i++)
		{
		if ((i >= s.length) || (s.charAt(i) != " "))
			{done = true;}
		else
			{
			s = s.substring(1,s.length);
			i = i-1;
			}
		} 

	done = false;			// remove trailing spaces
	if (s.length > 0)
		{
		for (i=0; (done != true) ; i++)
			{
			test_col = (s.length - i) - 1;
			if ((test_col <= 0) || (s.charAt(test_col, test_col+1) != " "))
				{done = true;}
			else
				{
				s=s.substring(0,s.length-1);
				i = i-1;
				}
			} 
		}
	return (s);
	}
	
function LeapYear(yr) {
/* Is it a leap year?
   1.Years divisible by 4 are leap years, but 
   2.Years divisible by 100 are not leap years, but 
   3.Years divisible by 400 are leap years. */

if (((yr % 4 == 0) && yr % 100 != 0) || yr % 400 == 0)
   return true;
else
   return false;
}

function IsDate(InString) {
/* Note: Date must be in the format MM/DD/YYYY */
/* Allow empty fields as dates. */
	if (InString.value.length >0)
	{    
		Slashes   = 0;
		Month     = 0;
		Day       = 0;
		Year      = 0;
		RefString = "01234567890/";
		for (i=0; i<InString.value.length; i++)
		{  
			TempChar = InString.value.substring(i, i +1);
			/* Invalid character? */
			if (RefString.indexOf(TempChar,0) == -1) 
			{ 
					alert ( "Invalid character in date string.  Format must be: MM/DD/YYYY." ); 
					return (false); 
			}
			/* Must have two slashes */
			if ( TempChar == "/" ) 
			{ 
				Slashes++; 
			}
		} /* end for */
		if ( Slashes != 2 )
		{ 
			alert ( "Date string must have two slashes in it.  Format must be: MM/DD/YYYY." );
			return (false);
		}
		/* Parse out the date pieces */
		i =  0;
		x = "";
		/* Month */
		while ((InString.value.charAt(i) != "/") && (i <= InString.value.length))
		{
			x = x +  InString.value.charAt(i);
			i++;
		}
		Month = Month + x;  // Rely on implicit conversion of char string x to a number  
		if (( Month < 1 ) || ( Month > 12 )) 
		{ 
			alert ( "Month must be between 1 and 12." ); 
			return (false); 
		}
		/* Day */
		i++; // Skip the slash
		x = "";
		while ((InString.value.charAt(i) != "/") && (i <= InString.value.length))
		{
			x = x +  InString.value.charAt(i);
			i++;
		}
		Day = Day + x; 
		if (( Day < 1 ) || ( Day > 31 )) 
		{ 
			alert ( "Day must be between 1 and 31." );
			return (false);
		}
		/* Year */
		i++; 
		x = "";
		while ((InString.value.charAt(i) != "/") && (i <= InString.value.length))
		{
			x = x +  InString.value.charAt(i);
			i++;
		}
		Year = Year + x; 
		if (( Year < 1000 ) || ( Year > 9999 )) 
		{ 
			alert ( "Year must be between 1000 and 9999." );
			return (false);
		}
		/* Check Day a bit more closely */
		if (( Month == 4 || Month == 6 || Month == 9 || Month == 11 ) && ( Day > 30 ))
		{ 
			alert( "Month " + Month + " can not have more than 30 days." );
			return ( false );
		}
		if ( Month == 2)
		/* Check leap year */
		/* Is it a leap year?
            1.Years divisible by 4 are leap years, but 
            2.Years divisible by 100 are not leap years, but 
            3.Years divisible by 400 are leap years. */
		{
			if ( LeapYear(Year) )
			{
				if ( Day > 29 ) 
				{ 
					alert( "February can not have more than 29 days in " + Year + "." );
					return ( false );
				}
			}
			else
			{ 
				if ( Day > 28 )
				{ 
					alert( "February can not have more than 28 days in " + Year + "." );
					return ( false );
				}
			}
		}
	}
	return ( true );
}

// generates warning before clearing form.
function clear_form(f) {
	var agree=confirm("WARNING: Any entries you may have made on this page will be lost.  \n\nIf you still want to clear the values, press 'OK'.  Otherwise, press 'Cancel'.");
	if (agree) {
		f.reset();
		document.getElementById("fxid").innerText = "" ; }
}

//----------
// Check if parameter is numeric	
//
// input: arg0 = paramenter to be examined
// output: return true if parameter is numeric, else return false
//----------
function isNumeric(n) {
  var length = n.length;
  var valid = true;
  var c,i;
  if (length == 0)  return false;
  for (i=0; (i<length) && valid; i++)
  {
    c = n.charAt(i);
    if (c < "0" || c > "9") valid = false;
  }
  return valid;
}

//----------
// Check if parameter is a valid email address	
//
// input: arg0 = paramenter to be examined
// output: return true if parameter is valid, else return false
//----------
function test(email) {
    var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
    var regex = new RegExp(emailReg);
    return regex.test(email);
  }

//generic input value checker
function checkValue(field,desc)	{
        if (remove_lead_and_trail_spaces(field.value) == "")
            {
               alert("Please Enter the " + desc);
               field.focus();
               return (false);
             }
        else 
          return (true); 
		
}

//check text area for input
function checkText(field, initialText) {
		if ( strSearch(field.value, initialText) || (remove_lead_and_trail_spaces(field.value) == "") )
		{
			alert("Please " + initialText);
            field.focus();
            return (false);
		}
		else		
          return (true); 
}
  

//----------
// checkinput2 - do custom checks before processing form
//
// input: arg0 = form object
// output: return true if all ok, else return false
//----------
function checkinput2(in_form) {     
  // Variables
  var idx, ctry, c_ipt;
  
  if (!checkValue(in_form.company_name,"Company Name!"))    return false;

  // Check if profile submitted
  var isProfileSubmitted = "";
  if (in_form.profile_submitted[0].checked) isProfileSubmitted = "Y";
  if (in_form.profile_submitted[1].checked) isProfileSubmitted = "N";
  if (isProfileSubmitted == "")
  {
    alert("Please enter if Potential Supplier Profile Has Already Been Submitted.");
    in_form.profile_submitted[0].focus();
    return false;
  } 
  else if (isProfileSubmitted == "N")
  {
    alert("Please Submit The Potential Supplier Profile Form First.");
    location.href="../ebiz/fcs_profiles.jsp" ;
    return false;
  } 

  if (!checkValue(in_form.contact_name, "Contact name!"))   return false;
  if (!checkValue(in_form.contact_title, "Contact title!")) return false;
  if (!checkValue(in_form.contact_email, "Contact Email!")) return false;
  
  //now do some other email checks
  var email = in_form.contact_email.value;
  if (!checkEmail(email))
  {
    in_form.contact_email.focus();
    return false;
  }
  
  // Check if Contact Email is valid (2)
  if (!test(email))
  { 
    alert("Please enter a valid Contact Email (i.e. aaa@bbb.com).");
    in_form.contact_email.focus();
    return false;
  }
  
  if (!checkValue(in_form.contact_phone, "Contact Phone!"))    return false;
  
    idx = in_form.product_teams.selectedIndex;
    //c_ipt = in_form.product_teams.options[idx].value;
    if (idx == -1) {
      alert("Please select at least one IPT from the list.");
      in_form.product_teams.focus();
      return false;
    }
	
  if (!checkText(in_form.presentation, "Enter brief description of presentation.")) return false;
  
  if (!checkValue(in_form.desired_date1, "Desired Date for First Choice!")) return false;
  if (!checkValue(in_form.desired_date2, "Desired Date for Second Choice!")) return false;
  
  if (!checkText(in_form.us_attendees, "Enter attendees that are US citizens.")) return false;
  if (!checkText(in_form.foreign_natls, "Enter any foreign nationals.")) return false;
  
   // ***************
   //alert("made it this far!") ;
	
  return true;

}

//----------
// checkinput - do custom checks before processing form
//
// input: arg0 = form object
// output: return true if all ok, else return false
//----------
function checkinput(in_form) {     
  // Variables
  var idx, ctry;
  
  if (!checkValue(in_form.company_name,"Company Name!")) return false;
  if (!checkStreetPOBOX(in_form.contact_address_1))    return false;
  if (!checkValue(in_form.contact_city, "City!"))    return false;
  if (!checkValue(in_form.contact_state, "State/Province!"))    return false;
  if (!checkCountry(in_form.contact_country,in_form.contact_state))    return false;
  if (!checkValue(in_form.contact_zip,"Postal Code!"))    return false;
  if (!checkValue(in_form.contact_name, "Contact name!"))    return false;
  if (!checkValue(in_form.contact_email, "Contact Email!"))    return false;
  
  //now do some other email checks
  var email = in_form.contact_email.value;
  if (!checkEmail(email))
  {
    in_form.contact_email.focus();
    return false;
  }
  
  // Check if Contact Email is valid (2)
  if (!test(email))
  { 
    alert("Please enter a valid Contact Email (i.e. aaa@bbb.com).");
    in_form.contact_email.focus();
    return false;
  }
  
  if (!checkValue(in_form.contact_phone, "Contact Phone!"))    return false;
  
  if (remove_lead_and_trail_spaces(in_form.alt_name.value) != "") {
  	if (!checkValue(in_form.alt_email, "Alternate Email!"))    return false;
  	var alt_email = in_form.alt_email.value;
  	// Check if AlternateEmail is valid (1)
  	if (!checkEmail(alt_email))	{
    	in_form.alt_email.focus();
    	return false;
  	}
  
	  // Check if Alternate Email is valid (2)
	  if (!test(alt_email))
	  { 
	    alert("Please enter a valid Email (i.e. aaa@bbb.com).");
	    in_form.alt_email.focus();
	    return false;
	  }
	  
	  if (!checkValue(in_form.alt_phone, "Alternate Phone!"))    return false;

	  
	  // Check if Alternateaddress is the same as Main contact
	  var isAltSame = "";
	  if (in_form.alt_address[0].checked) isAltSame = "Y";
	  if (in_form.alt_address[1].checked) isAltSame = "N";
	  if (isAltSame == "")
	  {
	    alert("Please enter if Alternateaddress is the same as Main contact.");
	    in_form.alt_address[0].focus();
	    return false;
	  }
	    
	  // If Alternateaddress is not the same as Main Contact, then other fields are required
	  if (isAltSame == "N" )
	  {
		  if (!checkValue(in_form.alt_address_1, "Alternate Street Address 1!"))    return false;
		  if (!checkValue(in_form.alt_city, "Alternate City!"))    return false;
		  if (!checkValue(in_form.alt_state, "Alternate State/Province!"))    return false;
		  if (!checkCountry(in_form.alt_country,in_form.alt_state))    return false;
		  if (!checkValue(in_form.alt_zip,"Alternate Postal Code!"))    return false;
	  }
  }
  
  // BEGIN 327194
  // Check if duns_number is numeric
  //var d_no = in_form.duns_number.value;
  //if (d_no != "" && isNumeric(d_no) == false)
  //{
  //  alert("DUNS Number must be numeric.");
  //  in_form.duns_number.focus();
  //  return false;
  //}
  // END 327194
  
   if (!checkValue(in_form.main_business_phone, "Main Business Phone!"))    return false;

  // Check if Company changed name
  var isNameChanged = "";
  if (in_form.name_change[0].checked) isNameChanged = "Y";
  if (in_form.name_change[1].checked) isNameChanged = "N";
  if (isNameChanged == "")
  {
    alert("Please enter if Company changed name.");
    in_form.name_change[0].focus();
    return false;
  }
  
  // If Company changed name, then prev_company_name is required
  if (isNameChanged == "Y")
  {
    if (!checkValue(in_form.prev_company_name, "Previous Company Name!"))    return false;
  }
   
  // Check if business_type is empty
  idx = in_form.business_type.selectedIndex;
  var bus_type = in_form.business_type.options[idx].value;
  if (bus_type == "")
  {
    alert("Please enter Business Type.");
    in_form.business_type.focus();
    return false;
  }
  
  // Check if Organization Type is empty
  idx = in_form.org_type.selectedIndex;
  if (in_form.org_type.options[idx].value == "")
  {
    alert("Please enter Organization Type.");
    in_form.org_type.focus();
    return false;
  }
  
  // Check if org type is Corporation
  var isCorporation = "N";
  if (in_form.org_type.options[idx].value == "1")
    isCorporation = "Y";

  // Check if org_type is Non-Profit
  var isNonProfit = "N";
  if (in_form.org_type.options[idx].value == "2")
    isNonProfit = "Y";
	
  // If foreign_owned = N, and org_type = Corporation, and isNonProfit = N, then state_incorporated is required
  idx = in_form.state_incorporated.selectedIndex;
  if (isNonProfit == "N" && isCorporation == "Y" && in_form.state_incorporated.options[idx].value == "")
  {
    alert("Please enter State Incorporated.");
    in_form.state_incorporated.focus();
    return false;
  }
  
  // If org_type = non-profit then non_profit_type is required
  idx = in_form.non_profit_type.selectedIndex;
  if (isNonProfit == "Y" && in_form.non_profit_type.options[idx].value == "")
  {
    alert("Please enter Non-Profit Type.");
    in_form.non_profit_type.focus();
    return false;
  }
  
  if (isNonProfit == "N" && in_form.non_profit_type.options[idx].value != "")
  {
    alert("Non-Profit Type is not valid when Organization Type is not Non-Profit.");
    in_form.non_profit_type.focus();
    return false;
  }
  
  // If org_type = non-profit then socioeconomic_factors is required
  idx = in_form.socioeconomic_factors.selectedIndex;
  if (isNonProfit == "Y" && in_form.socioeconomic_factors.options[idx].value == "")
  {
    alert("Please enter Non-Profit Factor.");
    in_form.socioeconomic_factors.focus();
    return false;
  }
  if (isNonProfit == "N" && in_form.socioeconomic_factors.options[idx].value != "")
  {
    alert("Non-Profit Factor is not valid when Organization Type is not Non-Profit.");
    in_form.socioeconomic_factors.focus();
    return false;
  }
  
 
  // Check if owned by foreign company
  var isForeignOwned = "";
  if (in_form.foreign_owned[0].checked) isForeignOwned = "N";
  if (in_form.foreign_owned[1].checked) isForeignOwned = "Y";
  
  if (isNonProfit == "N" && isForeignOwned == "")
  {
    alert("Please enter if Foreign Owned.");
    in_form.foreign_owned[0].focus();
    return false;
  }  
  
  // If foreign_owned = N then congressional_district is required
  if (isForeignOwned == "N")
  {
    idx = in_form.congr_state.selectedIndex;
    var c_state = in_form.congr_state.options[idx].value;
    idx = in_form.congr_distr.selectedIndex;
    var c_distr = in_form.congr_distr.options[idx].value;
    if (c_state == "") 
    {
      alert("Please select a State for Congressional District.");
      in_form.congr_state.focus();
      return false;
    }
    if (c_distr == "")
    {
      alert("Please select a District Number for Congressional District.");
      in_form.congr_distr.focus();
      return false;
    }
    in_form.congressional_district.value = c_state + c_distr;
  }
  
  // If foreign_owned = Y then foreign_government is required
  idx = in_form.foreign_government.selectedIndex;
  var gov = in_form.foreign_government.options[idx].value;
  if (isNonProfit == "N" && isForeignOwned == "Y" && gov  == "")
  {
    alert("Please select a Government.");
    in_form.foreign_government.focus();
    return false;
  }
  
  // If foreign_owned = N and org_type != non-profit, then either federal_tax_id or 
  // the combination of company_rep_ssn and company_rep_name is required
  var tax_id = in_form.federal_tax_id.value;
  var rep_ssn = in_form.company_rep_ssn.value;
  if (isForeignOwned == "N" && isNonProfit == "N" && tax_id == "" && rep_ssn == "")
  {
    alert("Please enter Federal Tax ID or Company Representative SSN.");
    in_form.federal_tax_id.focus();
    return false;
  }
  
  // Check if federal_tax_id is numeric
  if (isForeignOwned == "N" && isNonProfit == "N" && tax_id != "" && isNumeric(tax_id) == false)
  {
    alert("Federal Tax ID must be numeric with no dashes or spaces.");
    in_form.federal_tax_id.focus();
    return false;
  }
  
  // Check if federal_tax_id is 9 digits
  if (isForeignOwned == "N" && isNonProfit == "N" && tax_id != "" && tax_id.length < 9)
  {
    alert("Federal Tax ID must be 9 digits with no dashes or spaces.");
    in_form.federal_tax_id.focus();
    return false;
  }
  
 // Check if both federal tax id and SSN entered. if yes, tell them only one
  if (isForeignOwned == "N" && isNonProfit == "N" && tax_id != "" && rep_ssn != "")
  {
    alert("Please enter Federal Tax ID or Company Representative SSN, not both.");
    in_form.federal_tax_id.focus();
    return false;
  }
 
  // If foreign_owned != Y and org_type != non-profit and federal_tax_id = blank then company_rep_ssn is required  
  if (isForeignOwned == "N" && isNonProfit == "N" && tax_id == "" && rep_ssn == "")
  {
    alert("Please enter Company Representative SSN with no dashes or spaces.");
    in_form.company_rep_ssn.focus();
    return false;
  }
  
  // Check if company_rep_ssn is numeric
  if (isForeignOwned == "N" && isNonProfit == "N" && tax_id == "" && rep_ssn != "" && isNumeric(rep_ssn) == false)
  {
    alert("Company Representative SSN must be numeric, with no dashes or spaces.");
    in_form.company_rep_ssn.focus();
    return false;
  }
  
  // Check if company_rep_ssn is 9 digits
  if (isForeignOwned == "N" && isNonProfit == "N" && tax_id == "" && rep_ssn != "" && rep_ssn.length < 9)
  {
    alert("Company Representative SSN must be 9 digits, with no dashes or spaces.");
    in_form.company_rep_ssn.focus();
    return false;
  }
  
  // If company_rep_ssn != blank and federal_tax_id == blank, then company_rep_name is required
  var rep_name = in_form.company_rep_name.value;
  if(isForeignOwned == "N" && isNonProfit == "N" && tax_id == "" && rep_ssn != "" & rep_name == "")
  {
    alert("Please enter Company Representative Name.");
    in_form.company_rep_name.focus();
    return false;
  }
  
  // Check if company is owned by parent company
  var isParent = "" ;
  if (in_form.parent_company[0].checked) isParent = "Y" ;
  if (in_form.parent_company[1].checked) isParent = "N" ;

  if (isParent == "")
  {
    alert("Please enter if owned by Parent Company.");
    in_form.parent_company[0].focus();
    return false;
  }  
	
  if (isParent == "Y")
  {
    if (!checkParent(in_form))
		return false;
  }
   
   // ***************
  	//alert("made it this far!") ;
	
   //if (!checkForeignYes()) return(false);
   //if (!checkSize()) return(false);
	
  // Check if small business 
  var isSdb   = "";
  var isSmall = "";
  var isOther = "";
  if (in_form.small_business[0].checked)
  {
    isSmall = "Y";
	isOther = "N";
  }
  if (in_form.small_business[1].checked)
  {
    isSmall = "N";
	isOther = "Y";
  }
  
 // Check if small_business is empty
  if (isForeignOwned == "N" && isNonProfit == "N" && isSmall == "" && isOther =="")
  {
    alert("Please enter Company Size.");
    in_form.small_business[0].focus();
    return false;
  }
  
 // if not foreign owned and not non-profit and company size is small, check small responses
   if (isForeignOwned == "N" && isNonProfit == "N" && isSmall == "Y")
     if (!checkSmall(in_form))
	 	return false;

  // Check if Federal Exclusion is empty
  idx = in_form.federal_exclusion.selectedIndex;
  if (in_form.federal_exclusion.options[idx].value == "")
  {
    alert("Please enter Federal Exclusion Status.");
    in_form.federal_exclusion.focus();
    return false;
  }

	// Check if no product team is selected
    idx = in_form.product_teams.selectedIndex;
    if (idx == -1) {
      alert("Please select at least one IPT from the list.");
      in_form.product_teams.focus();
      return false;
    }
	
	// Check if products have been entered
  	if (!checkText(in_form.products, "Enter specific products.")) return false;
   
  // checkNAICS responses
  if (!checkNAICS(in_form))
  	return false;
  
  // If business_type = Distributor, then oem1 is required
  idx = in_form.business_type.selectedIndex;
  var bus_type = in_form.business_type.options[idx].value;
  if (bus_type == "2" && in_form.oem1.value == "")
  {
    alert("Please enter OEM1.");
    in_form.oem1.focus();
    return false;
  }

  // If foreign_owned = N then user cannot select foreign government
  if (isForeignOwned == "N" && gov != "")
  {
    alert("Cannot select foreign government if company is not foreign owned.");
    in_form.foreign_government.focus(); 
	return false;
  }
  
  // if non-profit, can not be foreign owned
  if (isNonProfit == "Y"  && isForeignOwned == "Y")
  {
    alert("Non-Profit Organizations cannot be Foreign Owned.");
    in_form.foreign_government.options[0].selected = true;
	in_form.foreign_owned[0].focus();
	return false;
  }
  
  // Reset values if isSmall != Y
  if (isSmall != "Y")
  {
    in_form.sba_registered[0].checked = false;
    in_form.sba_registered[1].checked = false;
	in_form.sba_registered.value="";
    in_form.women_owned[0].checked = false;
    in_form.women_owned[1].checked = false;
	in_form.women_owned.value="";
    in_form.veteran_owned[0].checked = false;
    in_form.veteran_owned[1].checked = false;
	in_form.veteran_owned.value="";
    in_form.disabled_veteran_owned[0].checked = false;
    in_form.disabled_veteran_owned[1].checked = false;
	in_form.disabled_veteran_owned.value="";
	in_form.small_socioeconomic_factor[0].selected = true;
	in_form.small_socioeconomic_factor.value="";
    in_form.sdb[0].checked = false;
    in_form.sdb[1].checked = false;
	in_form.sdb.value="";
    in_form.sdb_type.options[0].selected = true;
	in_form.sdb_type.value="";
    in_form.sba_certified[0].checked = false;
    in_form.sba_certified[1].checked = false;
	in_form.sba_certified.value="";
    in_form.sba_cert_expire_date.value = "";
    in_form.hub_zone[0].checked = false;
    in_form.hub_zone[1].checked = false;
	in_form.hub_zone.value="";
  }
  
  // If isNonProfit == "Y", blank out the appropriate fields
  if (isNonProfit == "Y")
  {
    in_form.state_incorporated.options[0].selected = true;
	in_form.state_incorporated.value="";
    in_form.foreign_owned[0].checked = false;
    in_form.foreign_owned[1].checked = false;
	in_form.foreign_owned.value="";
    in_form.foreign_government.options[0].selected = true;
	in_form.foreign_government.value="";
    in_form.federal_tax_id.value = "";
    in_form.company_rep_ssn.value = "";
    in_form.company_rep_name.value = "";
    in_form.small_business[0].checked = false;
	in_form.small_business[1].checked = false;
	in_form.small_business.value="";
    in_form.sba_registered[0].checked = false;
    in_form.sba_registered[1].checked = false;
	in_form.sba_registered.value="";
    in_form.women_owned[0].checked = false;
    in_form.women_owned[1].checked = false;  
	in_form.women_owned.value="";  
    in_form.veteran_owned[0].checked = false;
    in_form.veteran_owned[1].checked = false;
	in_form.veteran_owned.value="";
    in_form.disabled_veteran_owned[0].checked = false;
    in_form.disabled_veteran_owned[1].checked = false;
	in_form.disabled_veteran_owned.value="";
	in_form.small_socioeconomic_factor[0].selected = true;
	in_form.small_socioeconomic_factor.value="";
    in_form.sdb[0].checked = false;
    in_form.sdb[1].checked = false;
	in_form.sdb.value="";
    in_form.sdb_type.options[0].selected = true;
	in_form.sdb_type.value="";
    in_form.sba_certified[0].checked = false;
    in_form.sba_certified[1].checked = false;
	in_form.sba_certified.value="";
    in_form.sba_cert_expire_date.value = "";
    in_form.hub_zone[0].checked = false;
    in_form.hub_zone[1].checked = false;
	in_form.hub_zone.value="";
  }
  else
  {
    in_form.non_profit_type.options[0].selected = true;
	in_form.non_profit_type.value="";
    in_form.socioeconomic_factors.options[0].selected = true;
	in_form.socioeconomic_factors.value="";
  }
  
  // If isForeignOwned == "Y", blank out the appropriate fields  
  if (isForeignOwned == "Y")
  {
    in_form.congr_state.options[0].selected = true;
    in_form.congr_distr.options[0].selected = true;
	in_form.congr_state.value="";
	in_form.congr_distr.value="";
    in_form.federal_tax_id.value = "";
    in_form.company_rep_ssn.value = "";
    in_form.company_rep_name.value = "";
	in_form.small_business[0].checked = false;
	in_form.small_business[1].checked = false;
	in_form.small_business.value="";
    in_form.sba_registered[0].checked = false;
    in_form.sba_registered[1].checked = false;
	in_form.sba_registered.value="";
    in_form.women_owned[0].checked = false;
    in_form.women_owned[1].checked = false;  
	in_form.women_owned.value="";  
    in_form.veteran_owned[0].checked = false;
    in_form.veteran_owned[1].checked = false;
	in_form.veteran_owned.value="";
    in_form.disabled_veteran_owned[0].checked = false;
    in_form.disabled_veteran_owned[1].checked = false;
	in_form.disabled_veteran_owned.value="";
	in_form.small_socioeconomic_factor[0].selected = true;
	in_form.small_socioeconomic_factor.value="";
    in_form.sdb[0].checked = false;
    in_form.sdb[1].checked = false;
	in_form.sdb.value="";
    in_form.sdb_type.options[0].selected = true;
	in_form.sdb_type.value="";
    in_form.sba_certified[0].checked = false;
    in_form.sba_certified[1].checked = false;
	in_form.sba_certified.value="";
    in_form.sba_cert_expire_date.value = "";
    in_form.hub_zone[0].checked = false;
    in_form.hub_zone[1].checked = false;
	in_form.hub_zone.value="";
  }
  
  // If isCorporation == "N", blank out the State Incorporated field
  if (isCorporation == "N")
  {
    in_form.state_incorporated.options[0].selected = true;
	in_form.state_incorporated.value="";
  }
    
  // If isNameChanged == "N", blank out the previous company name field
  if (isNameChanged == "N")
  { 
    in_form.prev_company_name.value = "";
  }
  
  // If isParent == "N", blank out all fields related to parent company
  if (isParent == "N")
  {
    in_form.parent_company_name.value = "";
    in_form.parent_company_tax_id.value = "";
	// BEGIN 327194
    //in_form.parent_company_duns_number.value = "";
	// END 327194
    in_form.parent_company_address[0].checked = false;
    in_form.parent_company_address[1].checked = false;
	in_form.parent_company_address.value="";
    in_form.parent_company_address_1.value = "";
    in_form.parent_company_address_2.value = "";
    in_form.parent_company_city.value = "";
    in_form.parent_company_state.value = ""; 
    in_form.parent_company_country.options[0].selected = true;
    in_form.parent_company_zip.value = "";
  }
  
  // If federal_tax_id is not empty, then blank out company_rep_ssn and company_rep_name
  if (in_form.federal_tax_id.value != "")
  {
    in_form.company_rep_ssn.value = "";
    in_form.company_rep_name.value = "";
  }
  
  // If sdb != "Y", then blank out sba_certified and sba_cert_expire_date
  if (isSdb != "Y")
  {
     in_form.sba_certified[0].checked = false;
     in_form.sba_certified[1].checked = false;
	 in_form.sba_certified.value="";
     in_form.sba_cert_expire_date.value = "";
  }  

  // SR 352999 set the hidden value to prove that Javascript was enabled.
  in_form.javascript_status.value = "JavaScript is currently Enabled";
  
  return true;  // got to here - all checks OK
}

//this function is called when the parent owned value = Y and returns true
//or false depending on whether all the parent questions have been answered
function checkParent(in_form) {
	// parent_company_name is required    
    if (!checkValue(in_form.parent_company_name, "Parent Company Name!"))    return false;
	
	// BEGIN 327194
	var isForeignOwned = "N";
    if (in_form.foreign_owned[1].checked) 
	   isForeignOwned = "Y";
	   
	// parent_company_tax_id is required if not foreign owned  
	if ((document.reg_form.parent_company_tax_id.value == "") && (isForeignOwned == "N"))
	{
	    alert("Please enter Parent Company Tax ID.");
	    in_form.parent_company_tax_id.focus();
	    return false;
	}
	
	if (document.reg_form.parent_company_tax_id.value != "")  
	{
		// Check if parent_company_tax_id is numeric
		var p_tax_id = in_form.parent_company_tax_id.value;
		if (p_tax_id != "" && isNumeric(p_tax_id) == false)
		{
		    alert("Parent Company Tax ID must be numeric.");
	 	   in_form.parent_company_tax_id.focus();
		    return false;
		}
	  
		// Check if parent_company_tax_id is 9 digits
		if (p_tax_id.length < 9)
		{
		    alert("Parent Company Tax ID must be 9 digits.");
	  	  in_form.parent_company_tax_id.focus();
	 	   return false;
		}
	}

	// parent_company_duns_number is required 
	
	//if (in_form.parent_company_duns_number.value == "")
	//{
	//    alert("Please enter Parent Company Tax ID.");
	//    in_form.parent_company_duns_number.focus();
	//    return false;
	//}
	 
	// Check if parent_company_duns_number is numeric
	//var p_duns = in_form.parent_company_duns_number.value;
	//if (p_duns != "" && isNumeric(p_duns) == false)
	//{
	//    alert("Parent Company DUNS Number must be numeric.");
	//    in_form.parent_company_duns_number.focus();
	//    return false;
	//}
	// END 327194
	  
	// Check if Parent Company Address is the same as Main address
	var isParentAddrSame = "";
	if (in_form.parent_company_address[0].checked) isParentAddrSame = "Y";
	if (in_form.parent_company_address[1].checked) isParentAddrSame = "N";
	if (isParentAddrSame == "")
	{
	    alert("Please enter if Parent Company address is the same as Main Address.");
	    in_form.parent_company_address[0].focus();
	    return false;
	}  
	    
	// If Parent Company is not the same as Main address, then parent_company_address_1 is required
	if (isParentAddrSame == "N" )
	  {
		  if (!checkValue(in_form.parent_company_address_1, "Parent Company Street Address 1!"))    return false;
		  if (!checkValue(in_form.parent_company_city, "Parent Company City!"))    return false;
		  if (!checkValue(in_form.parent_company_state, "Parent Company State/Province!"))    return false;
		  if (!checkCountry(in_form.parent_company_country,in_form.parent_company_state))    return false;
		  if (!checkValue(in_form.parent_company_zip,"Parent Company Postal Code!"))    return false;
	  }

	return true;
}

//this function is called for small business and returns true or false 
//depending on whether all the small business questions have been answered
function checkSmall(in_form) {

// sba_registered is required
  var isSbaRegistered = "";
  if (in_form.sba_registered[0].checked) isSbaRegistered = "Y";
  if (in_form.sba_registered[1].checked) isSbaRegistered = "N";
  if (isSbaRegistered == "")
  {
    alert("Please enter if SBA Registered.");
    in_form.sba_registered[0].focus();
    return false;
  }  
  
  // women_owned is required
  var isWomen = "";
  if (in_form.women_owned[0].checked) isWomen = "Y";
  if (in_form.women_owned[1].checked) isWomen = "N";
  if (isWomen == "")
  {
    alert("Please enter if Women Owned.");
    in_form.women_owned[0].focus();
    return false;
  }
  
  // veteran_owned is required
  var isVet = "";
  if (in_form.veteran_owned[0].checked) isVet = "Y";
  if (in_form.veteran_owned[1].checked) isVet = "N";
  if (isVet == "")
  {
    alert("Please enter if Veteran Owned.");
    in_form.veteran_owned[0].focus();
    return false;
  }
       
  // If veteran_owned = Y then disabled_veteran_owned is required
  var isVetDis = "";
  if (in_form.disabled_veteran_owned[0].checked) isVetDis = "Y";
  if (in_form.disabled_veteran_owned[1].checked) isVetDis = "N";
  if (isVet == "Y" && isVetDis == "")
  {
    alert("Please enter if Service Disabled Veteran Owned.");
    in_form.disabled_veteran_owned[0].focus();
    return false;
  }
  //SR402252 below not true anymore
  //if veteran_owned = Y then socioeconomic_factors is required --->
  /*idx = in_form.small_socioeconomic_factor.selectedIndex;
  if (isVet == "Y" && in_form.small_socioeconomic_factor.options[idx].value == "")
  {
    alert("Please enter Socioeconomic Factors.");
    in_form.small_socioeconomic_factor.focus();
    return false;
  }*/
  
  // sdb is required
  var isSdb = "";
  if (in_form.sdb[0].checked) isSdb = "Y";
  if (in_form.sdb[1].checked) isSdb = "N";
  if (isSdb == "")
  {
    alert("Please enter if Small Disadvantaged Business.");
    in_form.sdb[0].focus();
    return false;
  }
  
  // If SDB = Y then sdb_type is required
  idx = in_form.sdb_type.options.selectedIndex;
  if (isSdb == "Y" && in_form.sdb_type.options[idx].value == "")
  {
    alert("Please enter SDB Type.");
    in_form.sdb_type.focus();
    return false;
  }
  
  // If SDB = Y then sba_certified is required
  var isSbaCert = "";
  if (in_form.sba_certified[0].checked) isSbaCert = "Y";
  if (in_form.sba_certified[1].checked) isSbaCert = "N";
  if (isSdb == "Y" && isSbaCert == "")
  {
    alert("Please enter if SBA Certified.");
    in_form.sba_certified[0].focus();
    return false;
  }
  
  // If sba_certified = Y  then sba_cert_expire_date is required
  var sba_date = in_form.sba_cert_expire_date.value;
  if (isSdb == "Y" && isSbaCert == "Y" && sba_date == "")
  {
    alert("Please enter SBA Certification Expiration Date.");
    in_form.sba_cert_expire_date.focus();
    return false;
  }
  
  // Check if sba_cert_expire_date is a valid date
  if (sba_date != "" && !IsDate(in_form.sba_cert_expire_date))
  {
    in_form.sba_cert_expire_date.focus();
    return false;
  }
  
 
  // Check if hub_zone is "Y"
  var isHub = "";
  if (in_form.hub_zone[0].checked) isHub = "Y";
  if (in_form.hub_zone[1].checked) isHub = "N";
  if (isHub == "")
  {
    alert("Please enter if you are on the SBA list of Qualified HUB Zone Small Business Concerns.");
    in_form.hub_zone[0].focus();
    return false;
  }
    
	
//sr 402252 Hub zone expiration date was removed from the screen	  
  
  return true;
}

function checkNAICS(in_form)
{
	//primary naics required
	if (in_form.naics_code1.value == "" && in_form.naics_code1_desc.value == "")
	{
	  alert("Please enter Primary NAICS Code and US NAICS Title.");
	  in_form.naics_code1.focus();
	  return false;
	}
	
	for (var i = 1; i <= 5; i++)
	{
		var code_naics=eval("in_form.naics_code"+eval(i)+".value");
		var desc_naics=eval("in_form.naics_code"+eval(i)+"_desc.value");
        if (((remove_lead_and_trail_spaces(code_naics) == "") &&
		    (remove_lead_and_trail_spaces(desc_naics) != "")) ||
			((remove_lead_and_trail_spaces(code_naics) != "") &&
		    (remove_lead_and_trail_spaces(desc_naics) == "")))
            {
               alert("Please Enter both NAICS Code and U.S. NAICS Title!");
               eval("in_form.naics_code"+eval(i)+".focus()");
               return (false);
             }

		var trimmed_naics = remove_lead_and_trail_spaces(code_naics);
        if ((remove_lead_and_trail_spaces(code_naics) != "") &&
		 		(trimmed_naics.length) < 6) 
			{
				alert("NAICS code must be 6 digits!");
		    	eval("in_form.naics_code"+eval(i)+".focus()");
				return(false);
			}
		if ((remove_lead_and_trail_spaces(code_naics) != "") &&
			(isNumeric(remove_lead_and_trail_spaces(code_naics)) == false)) 
			{
				alert("NAICS code must be NUMERIC!");
		    	eval("in_form.naics_code"+eval(i)+".focus()");
		    	//code_naics.focus();
				return(false);
			}
	}
	
	// Make sure that all 5 Naics codes are different
	var n1 = in_form.naics_code1.value;
	var n2 = in_form.naics_code2.value;
	var n3 = in_form.naics_code3.value;
	var n4 = in_form.naics_code4.value;
	var n5 = in_form.naics_code5.value;
	var sameFlag = false;
	if ((n1 != "") && (n1 == n2 || n1 == n3 || n1 == n4 || n1 == n5))
	  sameFlag = true;
	if ((n2 != "") && (n2 == n3 || n2 == n4 || n2 == n5))
	  sameFlag = true;
	if ((n3 != "") && (n3 == n4 || n3 == n5))
	  sameFlag = true;
	if ((n4 != "") && (n4 == n5))
	  sameFlag = true; 
	if (sameFlag == true)
	{
	  alert("Please review your NAICS Coding and do not submit duplicate numbers.  Please make sure each entry is unique or blank.");
	  in_form.naics_code1.focus();
	  return false;
	}
	return true;
}

function checkForeignYes() {
	if (document.forms[0].foreign_owned[1].checked)
	{
		if ((getSelectedValue(document.forms[0].org_type)) == "1")
		{
			ret = confirm("You have selected Corporation and Foreign Owned.  If you are indeed a corporation and foreign owned, you must select Foreign Corporation as your organization type.\n\nIf you select OK, your organization type will default to Foreign Corporation and any Congressional, Tax or Company small_business Information previously entered will be lost.");
			if (ret)
			{
				for (i = 0; i < document.forms[0].org_type.length; i++)
				{
					if (document.forms[0].org_type.options[i].value == "3")
						break; 
				}
				document.forms[0].org_type[i].selected = true;
				resetSelectList(document.forms[0].state_incorporated);
				resetSelectList(document.forms[0].congr_state);
				resetSelectList(document.forms[0].congr_distr);
				resetSelectList(document.forms[0].non_profit_type);
				resetSelectList(document.forms[0].socioeconomic_factors);
				resetSelectList(document.forms[0].sdb_type);
				document.forms[0].small_business[0].checked = false;
				document.forms[0].small_business[1].checked = false;
				document.forms[0].sba_registered[0].checked  = false;
				document.forms[0].sba_registered[1].checked  = false;
				document.forms[0].women_owned[0].checked  = false;
				document.forms[0].women_owned[1].checked  = false;
				document.forms[0].veteran_owned[0].checked  = false;
				document.forms[0].veteran_owned[1].checked  = false;
				document.forms[0].disabled_veteran_owned[0].checked  = false;
				document.forms[0].disabled_veteran_owned[1].checked  = false;
				document.forms[0].sdb[0].checked  = false;
				document.forms[0].sdb[1].checked  = false;
				document.forms[0].sba_certified[0].checked  = false;
				document.forms[0].sba_certified[1].checked  = false;
				document.forms[0].hub_zone[0].checked  = false;
				document.forms[0].hub_zone[1].checked  = false;
				document.forms[0].federal_tax_id.value ='';
				document.forms[0].company_rep_ssn.value =''; 
				document.forms[0].company_rep_name.value = '';
				document.forms[0].sba_cert_expire_date.value = '';
				}
			else
				{
				document.forms[0].foreign_owned[0].checked = true;
				document.forms[0].foreign_owned[1].checked = false;
				resetSelectList(document.forms[0].foreign_government);
				document.forms[0].foreign_owned[1].focus();
				return (false);
				}
		}
		if ((getSelectedValue(document.forms[0].org_type)) !== "3")
		{
		  if (pop_up_foreign_definition()) 
		  	{
				document.forms[0].foreign_owned[0].checked = false;
				document.forms[0].foreign_owned[1].checked = true;
				document.forms[0].federal_tax_id.value ='';
				document.forms[0].company_rep_ssn.value =''; 
				document.forms[0].company_rep_name.value = '';
				document.forms[0].org_type[i].selected = true;
				resetSelectList(document.forms[0].state_incorporated);
				resetSelectList(document.forms[0].congr_state);
				resetSelectList(document.forms[0].congr_distr);
				resetSelectList(document.forms[0].non_profit_type);
				resetSelectList(document.forms[0].socioeconomic_factors);
				resetSelectList(document.forms[0].sdb_type);
				document.forms[0].small_business[0].checked = false;
				document.forms[0].small_business[1].checked = false;
				document.forms[0].sba_registered[0].checked  = false;
				document.forms[0].sba_registered[1].checked  = false;
				document.forms[0].women_owned[0].checked  = false;
				document.forms[0].women_owned[1].checked  = false;
				document.forms[0].veteran_owned[0].checked  = false;
				document.forms[0].veteran_owned[1].checked  = false;
				document.forms[0].disabled_veteran_owned[0].checked  = false;
				document.forms[0].disabled_veteran_owned[1].checked  = false;
				document.forms[0].sdb[0].checked  = false;
				document.forms[0].sdb[1].checked  = false;
				document.forms[0].sba_certified[0].checked  = false;
				document.forms[0].sba_certified[1].checked  = false;
				document.forms[0].hub_zone[0].checked  = false;
				document.forms[0].hub_zone[1].checked  = false;
				document.forms[0].federal_tax_id.value ='';
				document.forms[0].company_rep_ssn.value =''; 
				document.forms[0].company_rep_name.value = '';
				document.forms[0].sba_cert_expire_date.value = '';
			}
		  else
		  	{
				document.forms[0].foreign_owned[0].checked = false;
				document.forms[0].foreign_owned[1].checked = false;
				resetSelectList(document.forms[0].foreign_government);
				document.forms[0].foreign_owned[1].focus();
				return (false);
			}
		}
		Selected = 0;
		for (Count = 0; Count < document.forms[0].congr_state.length; Count++)
		{
			if (document.forms[0].congr_state.options[Count].selected)
			{
				Selected = Count;
				break; 
			}
		}		
		Selected2 = 0;
		for (Count2 = 0; Count2 < document.forms[0].congr_distr.length; Count2++)
		{
			if (document.forms[0].congr_distr.options[Count2].selected)
			{
				Selected2 = Count2;
				break; 
			}
		}		
		if( (Selected > 0) || 
			(Selected2 > 0) ||
			(remove_lead_and_trail_spaces(document.forms[0].federal_tax_id.value) !='') ||
			(remove_lead_and_trail_spaces(document.forms[0].company_rep_ssn.value) !='') || 
			(remove_lead_and_trail_spaces(document.forms[0].company_rep_name.value) !='') ) 
		{
			ret = confirm("You have selected Foreign Owned. \n If you continue, any Congressional, Tax or Company small_business Information previously entered will be lost.");
			if (ret)
			{
				resetSelectList(document.forms[0].congr_state);
				resetSelectList(document.forms[0].congr_distr);
				resetSelectList(document.forms[0].non_profit_type);
				resetSelectList(document.forms[0].socioeconomic_factors);
				resetSelectList(document.forms[0].sdb_type);
				document.forms[0].small_business[0].checked = false;
				document.forms[0].small_business[1].checked = false;
				document.forms[0].sba_registered[0].checked  = false;
				document.forms[0].sba_registered[1].checked  = false;
				document.forms[0].women_owned[0].checked  = false;
				document.forms[0].women_owned[1].checked  = false;
				document.forms[0].veteran_owned[0].checked  = false;
				document.forms[0].veteran_owned[1].checked  = false;
				document.forms[0].disabled_veteran_owned[0].checked  = false;
				document.forms[0].disabled_veteran_owned[1].checked  = false;
				document.forms[0].sdb[0].checked  = false;
				document.forms[0].sdb[1].checked  = false;
				document.forms[0].sba_certified[0].checked  = false;
				document.forms[0].sba_certified[1].checked  = false;
				document.forms[0].hub_zone[0].checked  = false;
				document.forms[0].hub_zone[1].checked  = false;
				document.forms[0].federal_tax_id.value ='';
				document.forms[0].company_rep_ssn.value =''; 
				document.forms[0].company_rep_name.value = '';
				document.forms[0].sba_cert_expire_date.value = '';
			}
			else
			{
				document.forms[0].foreign_owned[0].checked = true;
				document.forms[0].foreign_owned[1].checked = false;
				resetSelectList(document.forms[0].foreign_government);
				document.forms[0].foreign_owned[1].focus();
				return (false);
			}
		}
	}
	document.forms[0].foreign_government.focus();
	return (true);
}
// Get selected value from drop down list. Pass in the element. returns the value
function getSelectedValue(list) {   
	for (Count = 0; Count < list.length; Count++)
	{
		if (list.options[Count].selected)
			break; 
	}

    return list.options[Count].value 
}

function orgNextElement() {
	if ((getSelectedValue(document.forms[0].org_type)) == "1")	
	{
		document.forms[0].state_incorporated.focus();
	}	
	else if ((getSelectedValue(document.forms[0].org_type)) == "2")	
	{
		document.forms[0].non_profit_type.focus();
	}
		else if ((getSelectedValue(document.forms[0].org_type)) == "3")
		{
		  if (pop_up_foreign_definition())
		  	{
				document.forms[0].foreign_owned[0].checked = false;
				document.forms[0].foreign_owned[1].checked = true;
				document.forms[0].federal_tax_id.value ='';
				document.forms[0].company_rep_ssn.value =''; 
				document.forms[0].company_rep_name.value = '';
				resetSelectList(document.forms[0].state_incorporated);
				resetSelectList(document.forms[0].congr_state);
				resetSelectList(document.forms[0].congr_distr);
				resetSelectList(document.forms[0].non_profit_type);
				resetSelectList(document.forms[0].socioeconomic_factors);
				document.forms[0].small_business[0].checked = false;
				document.forms[0].small_business[1].checked = false;
			}
		  else
		  	{
				document.forms[0].org_type[0].selected = true;
				return (false);
			}
		}
	return true;
}


function pop_up_foreign_definition() {
	ret=confirm("Per the International Traffic and Arms Regulations, section 120.15, a U.S. person ... also means any corporation, business association, partnership, society, trust, or any other entity, organization or group that is incorporated to do business in the United States.\n\nIf you fall into this definition, Foreign Corporation/Owned is not appropriate (if you have a foreign parent, please be sure to complete the parent information section).\n\nSelect OK to continue as Foreign Corporation/Owned or Cancel to select an alternative organization type or switch to domestic owned.\n\nNote: Selecting OK will result in the loss of any Federal Tax, Corporation, Non-Profit and Congressional District information previously entered.");
	if(ret)
		return (true);
	else
		return (false);
}

/*reset selected values*/
function resetSelectList(list) {
	Selected = 0;
	for (Count = 0; Count < list.length; Count++)
		{
		if (list.options[Count].selected)
			{
			Selected = Count;
			break; 
			}
		}	
	if (Selected > 0)
		{
			list.options[Count].selected = false;
			list.options[0].selected = true;
			return true;		
		}
	else		
			return false;	
}
	
function checkSize() {
  	alert("made it this far! " + document.forms[0].foreign_owned[0].checked ) ;
	if ( document.forms[0].foreign_owned[1].checked )
	{
		if (document.forms[0].small_business[0].checked || document.forms[0].small_business[1].checked)
		{
			document.forms[0].small_business[0].checked = false;
			document.forms[0].small_business[1].checked = false;
			alert("You cannot select a company size if Foreign Owned.");
		}
	}
	else if ( (getSelectedValue(document.forms[0].org_type)) == "2" )	
	{
		if (document.forms[0].small_business[0].checked || document.forms[0].small_business[1].checked)
		{
			document.forms[0].small_business[0].checked = false;
			document.forms[0].small_business[1].checked = false;
			alert("You cannot select a company size if Non-Profit.");
		}
	}
	else
		if (document.forms[0].small_business[0].checked || document.forms[0].small_business[1].checked)
			;
		else
		{
			document.forms[0].small_business[0].focus();
			alert("Select a Company Size.");
			return (false);
		}
	return (true);
}

//----------
// remove_lead_and_trail_spaces() - just what it says
// INPUT:  s = string to fix
// OUTPUT: fixed string
//----------
function remove_lead_and_trail_spaces(s) {
	if (!(typeof (s) == "string")) {  return (null);  }
	if (s.length == 0) {  return ("");  }

	var done = false;			// remove lead spaces
	for (i=0; (done != true) ; i++)
		{
		if ((i >= s.length) || (s.charAt(i) != " "))
			{done = true;}
		else
			{
			s = s.substring(1,s.length);
			i = i-1;
			}
		} 

	done = false;			// remove trailing spaces
	if (s.length > 0)
		{
		for (i=0; (done != true) ; i++)
			{
			test_col = (s.length - i) - 1;
			if ((test_col <= 0) || (s.charAt(test_col, test_col+1) != " "))
				{done = true;}
			else
				{
				s=s.substring(0,s.length-1);
				i = i-1;
				}
			} 
		}
	return (s);
}

//check if street address 1 is blank	
function checkStreet(street) {
        if (remove_lead_and_trail_spaces(street.value) == "")
            {
               alert("Please Enter the Street Address!");
               street.focus();
               return (false);
             }
        else 
          return (true); 
   }

function strSearch( string , searchstring) { 
	return (string.search( searchstring ) != -1); 
} 

//street address 1 cannot be a PO box	
function checkStreetPOBOX(street) {
	    if (!checkStreet(street)) return(false);
		if (
			(strSearch(street.value.toUpperCase(),"POST OFFICE BOX"))
			||
			(strSearch(street.value.toUpperCase(),"P.O.BOX"))
			||
			(strSearch(street.value.toUpperCase(),"PO BOX"))
			||
			(strSearch(street.value.toUpperCase(),"PO BX"))
			||
			(strSearch(street.value.toUpperCase(),"P.O. BOX"))
			||
			(strSearch(street.value.toUpperCase(),"P.O BOX"))
			||
			(strSearch(street.value.toUpperCase(),"PO. BOX"))
			||
			(strSearch(street.value.toUpperCase(),"P. O. BOX"))		
			||
			(strSearch(street.value.toUpperCase(),"0 BOX"))	
			||
			(strSearch(street.value.toUpperCase(),"0. BOX"))		
			||
			(strSearch(street.value.toUpperCase(),"P. O.BOX"))			
			||
			(strSearch(street.value.toUpperCase(),"POB"))
			||
			(strSearch(street.value.toUpperCase(),"POSTAL BOX"))
			)
		{
			alert("Street Address 1 needs physical street address no PO BOX");
              	street.focus();
              	return (false);
		}
		else		
          return (true); 
}

  function checkCountry(country,state) {
	Selected = 0;
	for (Count = 0; Count < country.length; Count++)
		{
		if (country.options[Count].selected)
			{
			Selected = Count;
			break; 
			}
		}			
	if (Selected == 0)
		{
		alert("Please Select a Country");
		country.focus();
		return false;
		}
	else		
		{
		var upperstate = state.value.toUpperCase();
		if (country.options[Count].value == "805")//if USA check for valid state
			{
				if (!isStateCode(upperstate))
				{
			    alert("Please enter a valid 2 character US state or District Code in UPPERCASE!");
			    state.focus();
			   	state.select();
			    return (false);
			   	}
			  	else 
				{
					state.value = upperstate;
					return (true); 
				}	
			}	
		else
			return true;		
		}
	}	
	
function checkCountrySel(country) {
	Selected = 0;
	for (Count = 0; Count < country.length; Count++)
		{
		if (country.options[Count].selected)
			{
			Selected = Count;
			break; 
			}
		}	
	if (Selected > 0)
		{
			return true;		
		}
	else		
		{
			return false;	
		}

	}
// Valid U.S. Postal Codes for states, territories, armed forces, etc.
// See http://www.usps.gov/ncsc/lookups/abbr_state.txt.

function isStateCode(s) {
var USStateCodeDelimiter = "|";
var USStateCodes  = new Array("AA","AE","AK","AL","AP","AR","AS","AZ","CA","CO","CT","DC","DE",
        "FM","FL","GA","GU","HI","ID","IA","IL","IN","KS","KY","LA","ME","MH","MD","MA","MI","MN",
        "MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","MP","OH","OK","OR","PW",
        "PA","PR","RI","SC","SD","TN","TX","UT","VA","VT","VI","WA","WV","WI","WY");

    for (i=0; i<USStateCodes.length; i++)
      if (USStateCodes[i] == s) break;     
    if (i == USStateCodes.length)
    {
      return false;             
    }
return true;	

}

// Check whether string s is empty.

function isEmpty(s) {
   return ((s == null) || (s.length == 0))
}


function isEmailAddress(string) {
  var addressPattern=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
  return addressPattern.test(string);
}

function transOn() {
	document.getElementById("msgblock").style.visibility = 'visible';
} 

function transOff() { 
	document.getElementById("msgblock").style.visibility = 'hidden';
} 

function FXDesc(slct) {
	var FXArray = new Array("", 
							"Not excluded from U.S. Federal Procurement Programs.",
	                		 "On the List of Parties Excluded from Federal Procurement Programs.",
	                		 "Ineligible, debarred, or suspended from receiving Federal Contracts or Subcontracts.",
							 "Convicted or indicted for fraud or a criminal offense in connection with obtaining a Federal or State Contract or Subcontract or had contracts terminated for default.") ;  
	document.getElementById("fxid").innerText = FXArray[slct] ;
	document.getElementById("fxid").style.color = "red" ;
} 

//  End -->
