// JavaScript Document

function checkNum(aNum) {
	var isOK=0;
	var aNum=aNum+"";
	//if the number has one or none decimal points, lastIndexOf and indexOf
	//will give the same answer
	if (aNum.lastIndexOf(".")!=aNum.indexOf("."))
		isOK=1;
	else
	//here a regular expression is used to check for numbers and decimals
	if (aNum.match(/[^0-9.]/))
		isOK=2;
	return isOK;
}//end of checkNum(aNum)


function toggleFlash() {
  if (document.getElementById("flashHeader").style.display == "block") {
	document.getElementById("flashHeader").style.display = "none"; }
  else {
	document.getElementById("flashHeader").style.display = "block";
  }
}



function ajaxFunction()
  {
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
		if (checkNum(fixedNum) != 0 || fixedNum == '' || fixedNum < 10000)
			{
			alert('Please enter a debt amount of $10,000.00 or more. ');
			}
		else
			{
			document.getElementById("calcResults").innerHTML=xmlHttp.responseText;
			//document.getElementById("calcResults").innerHTML="testing";
			toggleFlash();
			Lightbox.showBoxByID('calcResults', 700, 650);
			return false;
			}
        }
      }
	var data = '?principal=' + fixedNum;
    xmlHttp.open("GET","calculator.php" + data,true);
	// alert(document.debtCalc.principal.value);
	xmlHttp.send(data);
	
    // xmlHttp.send(null);
  }
  
