// JavaScript Document
function changepage(whichpage)
{
  clearTimeout(timecop);
  if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp = new XMLHttpRequest();
  }
  else
  {// code for IE6, IE5
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function()
  {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
    {
    document.getElementById("staticdiv").innerHTML=xmlhttp.responseText;
    document.getElementById("staticdiv").style.display = "block";
    }
  }
  xmlhttp.open("get", "./pages/getpage.php?q="+whichpage, true);
  xmlhttp.send("");
  whatamidoing = "static";
  document.getElementById("sidebar").style.display = "block";
  document.getElementById("detail").style.display = "none";
  for (r=0; r<howmanypreviews; r++) {
    document.getElementById(r).style.display = "none";
    document.getElementById("spt"+r).style.color = maincolour;
    document.getElementById("spd"+r).style.color = maincolour;
  }
}

function archdetail(goowls) {
	previewarray[-1] = goowls;
	detail(-1);
}

function detail(horton)
{
  clearTimeout(timecop);
  if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp = new XMLHttpRequest();
  }
  else
  {// code for IE6, IE5
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function()
  {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
    {
      document.getElementById("detail").innerHTML=xmlhttp.responseText;
      document.getElementById("detail").style.display = "block";
    }
  }
  xmlhttp.open("get", "./pages/detail.php?s="+previewarray[horton], true);
  xmlhttp.send("");
  whatamidoing = "detail";
  document.getElementById("sidebar").style.display = "none";
  document.getElementById("staticdiv").style.display = "none";
  for (r=0; r<howmanypreviews; r++) {
	document.getElementById(r).style.display = "none";
    document.getElementById("spt"+r).style.color = maincolour;
    document.getElementById("spd"+r).style.color = maincolour;
  }
}

function archive(c, d)
{
  clearTimeout(timecop);
  if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp = new XMLHttpRequest();
  }
  else
  {// code for IE6, IE5
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function()
  {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
    {
    document.getElementById("staticdiv").innerHTML=xmlhttp.responseText;
    document.getElementById("staticdiv").style.display = "block";
    }
  }
  if (d == "track") {
	  suck = archtracker.split("|");
	  c = suck[0];
	  d = suck[1];
  }
  archtracker = c + "|" + d;
  xmlhttp.open("get", "./pages/archive.php?c="+c+"&d="+d, true);
  xmlhttp.send("");
  whatamidoing = "static";
  document.getElementById("sidebar").style.display = "block";
  document.getElementById("detail").style.display = "none";
  for (r=0; r<howmanypreviews; r++) {
    document.getElementById(r).style.display = "none";
    document.getElementById("spt"+r).style.color = maincolour;
    document.getElementById("spd"+r).style.color = maincolour;
  }
}
