function MakeLoading(id)

{

	var code ="<br /><center><div class='barloading'> </div></center>";

	document.getElementById(id).innerHTML = code;

}



function getXMLHttp()

{

  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;

      }

    }

  }

  return xmlHttp;

}



function encodeMyHtml(val) {

	 encodedHtml = escape(val);

	 encodedHtml = encodedHtml.replace(/\//g,"%2F");

	 encodedHtml = encodedHtml.replace(/\?/g,"%3F");

	 encodedHtml = encodedHtml.replace(/=/g,"%3D");

	 encodedHtml = encodedHtml.replace(/&/g,"%26");

	 encodedHtml = encodedHtml.replace(/@/g,"%40");

	 encodedHtml = encodedHtml.replace(/<br>/g,"%0A");

	 encodedHtml = encodedHtml.replace(/\n/g,"%0D");

	 return  encodedHtml;

} 



function getMyResult(unsecureddebt, interestrate, payoffmonthsgoal)

{

  var xmlHttp = getXMLHttp();

 

  xmlHttp.onreadystatechange = function()

  {

    if(xmlHttp.readyState == 4)

    {

      HandleResponse(xmlHttp.responseText);

    }

  }



  xmlHttp.open("GET", "result.php?unsecureddebt="+unsecureddebt+"&interestrate="+interestrate+"&payoffmonthsgoal="+payoffmonthsgoal, true);

  xmlHttp.send(null);

}



function getMyGraph(unsecureddebt, interestrate, payoffmonthsgoal)

{

  var xmlHttp = getXMLHttp();

 

  xmlHttp.onreadystatechange = function()

  {

    if(xmlHttp.readyState == 4)

    {

      HandleResponseGraph(xmlHttp.responseText);

    }

  }



var multiplier = (interestrate!="") ? interestrate/100 : 1;



	t1 = ((unsecureddebt*.50) + (unsecureddebt*.15));

	t2 = (unsecureddebt*(.05) / 12 * 60 );

		t2sum = parseInt(unsecureddebt) + parseInt(t2);

	t3 = (((unsecureddebt * (multiplier)) / 12) * (payoffmonthsgoal * 10)) + parseInt(unsecureddebt);



  xmlHttp.open("GET", "bargraph.php?t1="+t1+"&t2="+t2sum+"&t3="+t3, true);

  xmlHttp.send(null);

}





function HandleResponse(response)

{

  document.getElementById('resultcontent').innerHTML = response;

}



function HandleResponseGraph(response)

{

  document.getElementById('resultgraph').innerHTML = response;

  document.getElementById('homepage_content').style.display = "none";

}
