function StatePlan(blankOK)
{
  Index_counter = document.form1.p_location.selectedIndex

  var p_loc_select = new Array(26)

  p_loc_select[0]="Alaska"
  p_loc_select[1]="Arizona"
  p_loc_select[2]="California"
  p_loc_select[3]="Connecticut"
  p_loc_select[4]="Hawaii"
  p_loc_select[5]="Indiana"
  p_loc_select[6]="Iowa"
  p_loc_select[7]="Kentucky"
  p_loc_select[8]="Maryland"
  p_loc_select[9]="Michigan"
  p_loc_select[10]="Minnesota"
  p_loc_select[11]="Nevada"
  p_loc_select[12]="New Jersey"
  p_loc_select[13]="New Mexico"
  p_loc_select[14]="New York"
  p_loc_select[15]="North Carolina"
  p_loc_select[16]="Oregon"
  p_loc_select[17]="Puerto Rico"
  p_loc_select[18]="South Carolina"
  p_loc_select[19]="Tennessee"
  p_loc_select[20]="Utah"
  p_loc_select[21]="Vermont"
  p_loc_select[22]="Virgin Islands"
  p_loc_select[23]="Virginia"
  p_loc_select[24]="Washington"
  p_loc_select[25]="Wyoming"

  for ( i = 0;  i <= 26;  i++ )
  {
   if (document.form1.p_location.options[Index_counter].value ==  p_loc_select[i])
   {
    if (document.form1.p_location.options[Index_counter].value == p_loc_select[0])
    {
     alert (p_loc_select[i]+" is a State Plan state.\nPlease call the following number 1-800-321-OSHA\nTo have an OSHA Officer assist you with your question.\nThank you.");
    }
    else
    {
     newwindow=open("http://beta.osha-slc.gov/pls/edata/owae_data.e_state_plan","popupnav","scrollbars=yes,toolbar=yes,directories=yes,menubar=no,resizable=yes,status=yes,width=770,height=480");
    //alert (p_loc_select[i]+" is a State Plan state.\nPlease call the following number 1-800-321-OSHA\nTo have an OSHA Officer assist you with your question.\nThank you.");
    }
    break
    return false
   }
  }

  return true
}


function validArea_code (blankOK)
{
 var validChars = /^[0-9][0-9][0-9]$/
 var allValid = true
 if (blankOK) if ( document.form1.v_phone1.value.length < 1 ) return true

 if (validChars.exec(document.form1.v_phone1.value)!=null)
   return true
 else
 {
  allValid = false
  alert ("Please enter a 3-digit Area Code")
  document.form1.v_phone1.focus()
  return false
 }

}

function validPrefix (blankOK)
{
 var validChars = /^[0-9][0-9][0-9]$/
 var allValid = true
 if (blankOK) if ( document.form1.v_phone2.value.length < 1 ) return true

 if (validChars.exec(document.form1.v_phone2.value)!=null)
   return true
 else
 {
  allValid = false
  alert ("Please enter a 3-digit Prefix.")
  document.form1.v_phone2.focus()
  return false
 }

}

function validSuffix (blankOK)
{
 var validChars = /^[0-9][0-9][0-9][0-9]$/
 var allValid = true
 if (blankOK) if ( document.form1.v_phone3.value.length < 1 ) return true

 if (validChars.exec(document.form1.v_phone3.value)!=null)
   return true
 else
 {
  allValid = false
  alert ("Please enter a 4-digit Suffix.")
  document.form1.v_phone3.focus()
  return false
 }
}

function validZIP (blankOK)
{
 var validChars = "0123456789-"
 var allValid = true
 var numDashes = 0
 if (blankOK) if ( document.form1.v_zip_code.value.length < 1 ) return true
   for ( i = 0;  i < document.form1.v_zip_code.value.length;  i++ )
   {
   	ch = document.form1.v_zip_code.value.charAt(i)
   	for ( j = 0;  j < validChars.length;  j++ )
   	{
   		if ( ch == validChars.charAt(j) ) break
   		if ( j == (validChars.length - 1))
   		{
   			allValid = false
   			break
   		}
   	}
       if ( ch == "-" )
   	{
   		numDashes++
   		if ( i != 5 || document.form1.v_zip_code.value.length != 10 )
   		{
   			allValid = false
   			break
   		}
   	}
   }
   if ( numDashes == 0 && document.form1.v_zip_code.value.length != 5 )
   	allValid = false
   if ( !allValid )
   {
   	alert ("Please enter either a 5-digit ZIP code or a 5+4 ZIP code.")
   	document.form1.v_zip_code.focus()
   	return false
   }
   return true
  }

function validEmail(blankOK)
{
if (blankOK) if ( document.form1.p_response.value.length < 1 ) return true
var validChars = "'/@0123456789-_.,abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
var allValid = true
var numAts = 0
for ( i = 0;  i < document.form1.p_response.value.length;  i++ )
{
	ch = document.form1.p_response.value.charAt(i)
	for ( j = 0;  j < validChars.length;  j++ )
	{
		if ( ch == validChars.charAt(j) ) break
		if ( j == (validChars.length - 1))
		{
			allValid = false
			break
		}
	}
    if ( ch == "@" )
    	numAts++
}
if ( numAts != 1 )
	allValid = false
if ( !allValid || document.form1.p_response.value.length == 1)
{
	alert ("Please enter a return email address of the form name@domain.")
	document.form1.p_response.focus()
	return false
}
return true
}

function valid_Email(blankOK)
{
var validChars = "'@0123456789-_.,abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
var allValid = true
var numAts = 0
for ( i = 0;  i < document.form1.p_response.value.length;  i++ )
{
	ch = document.form1.p_response.value.charAt(i)
	for ( j = 0;  j < validChars.length;  j++ )
	{
		if ( ch == validChars.charAt(j) ) break
		if ( j == (validChars.length - 1))
		{
			allValid = false
			break
		}
	}
    if ( ch == "@" )
    	numAts++
}
if ( numAts != 1 )
	allValid = false
if ( !allValid || document.form1.p_response.value.length == 1)
{
	alert ("Please enter a return email address of the form name@domain.")
	document.form1.p_response.focus()
	return false
}
return true
}

function valid_e_mail(blankOK)
{
var validChars = "'@0123456789-_.,abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
var allValid = true
var numAts = 0
for ( i = 0;  i < document.form1.p_email.value.length;  i++ )
{
	ch = document.form1.p_email.value.charAt(i)
	for ( j = 0;  j < validChars.length;  j++ )
	{
		if ( ch == validChars.charAt(j) ) break
		if ( j == (validChars.length - 1))
		{
			allValid = false
			break
		}
	}
    if ( ch == "@" )
    	numAts++
}
if ( numAts != 1 )
	allValid = false
if ( !allValid || document.form1.p_email.value.length == 1)
{
	alert ("Please enter a return email address of the form name@domain.")
	document.form1.p_email.focus()
	return false
}
return true
}

function jumpTo(URL_List)
{
 if (document.all)
 {
  if (URL_List.options[URL_List.selectedIndex].value=="ROUTED")
  {
   document.all.test.innerHTML ="Reason for reroute";
  }
  if (URL_List.options[URL_List.selectedIndex].value=="ANSWER_ROUTED")
  {
   document.all.test.innerHTML ="Answer (Before rerouting the question)";
  }
  if (URL_List.options[URL_List.selectedIndex].value=="ANSWERED")
  {
   document.all.test.innerHTML ="Answer";
  }
  if (URL_List.options[URL_List.selectedIndex].value=="RESEARCH")
  {
   document.all.test.innerHTML ="Reason of Research, Hold, or Review";
  }
 }
 else
 {
  if (URL_List.options[URL_List.selectedIndex].value=="ROUTED")
  {
   document.test.innerHTML ="Reason for reroute";
  }
  if (URL_List.options[URL_List.selectedIndex].value=="ANSWER_ROUTED")
  {
   document.test.innerHTML ="Answer (Before rerouting the question)";
  }
  if (URL_List.options[URL_List.selectedIndex].value=="ANSWERED")
  {
   document.test.innerHTML ="Answer";
  }
  if (URL_List.options[URL_List.selectedIndex].value=="RESEARCH")
  {
   document.test.innerHTML ="Reason of Research, Hold, or Review";
  }
 }
}


function validform( frm ) {
// force validation of all fields
var i
validated=true
for (i=0;i<frm.elements.length && validated;i++)
if (frm.elements[i].onchange!=null)
frm.elements[i].onchange()  // force execution of onchange event handler
return validated
}

