var xmlHttp;

function update_total() {
var total;
  if (document.mainform.student_discount[0].checked) {
    total=200;
  }
  if (document.mainform.student_discount[1].checked) {
    total=300;
  }
  if (document.mainform.student_discount[2].checked) {
    total=0;
  }
  total+=document.mainform.guests.selectedIndex*70;
  document.getElementById("total").innerHTML="$"+total;
  return total;
}

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;
}

function create_link(total) {
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  var url="total.php";
  url=url+"?total="+total;
  url=url+"&sid="+Math.random();
  xmlHttp.onreadystatechange=stateChanged;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("secure_link").innerHTML="<a href="+xmlHttp.responseText+">Go to the secure payment server</a>";
}
}


function update() {
var total;
  total=update_total();
  create_link(total);
}