var xmlHttp
function showWBA(str)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }

var url="ben.php"
url=url+"?st="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)

}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("wbahint").innerHTML=xmlHttp.responseText; 

 } 
}


function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

// check date JavaScript function   
// if date is valid then function returns true, otherwise returns false   
function isDate(txtDate){   
  var objDate;  // date object initialized from the txtDate string   
  var mSeconds; // milliseconds from txtDate   
  
  // date length should be 10 characters - no more, no less   
  if (txtDate.length != 10) return false;   
  
  // extract day, month and year from the txtDate string   
  // expected format is mm/dd/yyyy   
  // subtraction will cast variables to integer implicitly   
  var day   = txtDate.substring(3,5)  - 0;   
  var month = txtDate.substring(0,2)  - 1; // because months in JS start with 0   
  var year  = txtDate.substring(6,10) - 0;   
  
  // third and sixth character should be /   
  if (txtDate.substring(2,3) != '/') return false;   
  if (txtDate.substring(5,6) != '/') return false;   
  
  // test year range   
  if (year < 999 || year > 3000) return false;   
  
  // convert txtDate to the milliseconds   
  mSeconds = (new Date(year, month, day)).getTime();   
  
  // set the date object from milliseconds   
  objDate = new Date();   
  objDate.setTime(mSeconds);   
  
  // if there exists difference then date isn't valid   
  if (objDate.getFullYear() != year)  return false;   
  if (objDate.getMonth()    != month) return false;   
  if (objDate.getDate()     != day)   return false;   
  
  // otherwise return true   
  return true;   
}  

function validate()
{
if (document.choice.state.selectedIndex == 0){
	alert("Please select a State.");
	return false;
}
else if (document.choice.wba.value == ""){
 	alert("Please enter Weekly Benefit Amount.");
	return false;
}
//else if (parseInt(document.choice.wba.value) < parseInt(document.choice.minwba.value)){
else if ((document.choice.minwba != null) && (parseInt(document.choice.wba.value) < parseInt(document.choice.minwba.value))){
 	alert("You have entered a WBA less than the minimum WBA for the state. Please re-enter.");
	return false;
}

else if (document.choice.mba.value == ""){
 	alert("Please enter Maximum Benefit Amount.");
	return false;
}
else if (document.choice.ef_date.value == ""){
 	alert("Please enter Effective Date of Claim.");
	return false;
}

else if (!isDate(document.choice.ef_date.value)){
	alert("Please enter valid format of the effective date of claim.");
	return false;
}

else
	alert("These benefits are available for weeks of unemployment that begin before November 30, 2010. Individuals establishing benefit entitlement as of this date can collect the remainder of this entitlement through April 30, 2011. \n\nIf there are any additional Congressional extensions of the EUC08 program beyond the November 30, 2010 date, the Department of Labor will update this calculator to show the specific end dates as they are signed into law.");

	return true;
	
}

function clear() {
	document.getElementById('wbahint').style.visibility='hidden';
    return true;
}	


