var xmlhttp

function showRandom(iteration)
{

xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }

var url="selection.php?setmodels="+iteration;
xmlhttp.onreadystatechange=setselection;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}

function newRandom(iteration)
{
  document.getElementById("selection").innerHTML="";

xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }

var url="selection.php?setmodels="+iteration;
xmlhttp.onreadystatechange=setselection;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}

function setselection()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("selection").innerHTML=xmlhttp.responseText;
  }
}

function playOpening(episode)
{
xmlhttp2=GetXmlHttpObject();
if (xmlhttp2==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }

var url="selection.php?playopening="+episode;
xmlhttp2.onreadystatechange=otherstateChanged;
xmlhttp2.open("GET",url,true);
xmlhttp2.send(null);
}


function otherstateChanged()
{
if (xmlhttp2.readyState==4)
  {
  document.getElementById("opening").innerHTML=xmlhttp2.responseText;
  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
