var xmlhttp;
var xmlhttp2;
var numberOfSame = 5;

function loadWebcamsRow(page)
{
  var url = './webcams_row.php?page=' + page + '&rand=' + Math.floor(Math.random() * 1000000);
  loadXMLDoc2(url);
}

function loadSameMovie(id,type)
{
  var url = './same.php?set=' + id + '&type=' + type + '&number=' + numberOfSame + '&rand=' + Math.floor(Math.random() * 1000000);
  loadXMLDoc(url);
}

function loadSameOtherMovie(id, type)
{
  var url = './same_other.php?set=' + id + '&type=' + type + '&rand=' + Math.floor(Math.random() * 1000000);
  loadXMLDoc3(url);
}
function loadSameOtherTmfMovie(id, type)
{
  var url = './same_other_tmf.php?set=' + id + '&type=' + type + '&rand=' + Math.floor(Math.random() * 1000000);
  loadXMLDoc4(url);
}
function loadSameTrailer(id,type)
{
  var url = './samet.php?set=' + id + '&type=' + type + '&number=' + numberOfSame + '&rand=' + Math.floor(Math.random() * 1000000);
  loadXMLDoc(url);
}

function loadXMLDoc(url)
{
  // code for Mozilla, etc.
  if(window.XMLHttpRequest){
	  xmlhttp=new XMLHttpRequest()
	  xmlhttp.onreadystatechange=state_Change
	  xmlhttp.open("GET",url,true)
	  xmlhttp.send(null)
  }
  // code for IE
  else if (window.ActiveXObject)
  {
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    if (xmlhttp)
    {
		xmlhttp.onreadystatechange=state_Change
	    xmlhttp.open("GET",url,true)
		xmlhttp.send()
    }
  }
}

function state_Change()
{
  // if xmlhttp shows "loaded"
  if (xmlhttp.readyState==4){
	// if "OK"
    if (xmlhttp.status==200){
	  document.getElementById('SameTrailers').innerHTML = xmlhttp.responseText;
    }
  }
}

function loadXMLDoc2(url)
{
  // code for Mozilla, etc.
  if(window.XMLHttpRequest){
	  xmlhttp2=new XMLHttpRequest()
	  xmlhttp2.onreadystatechange = state_Change2
	  xmlhttp2.open("GET",url,true)
	  xmlhttp2.send(null)
  }
  // code for IE
  else if (window.ActiveXObject)
  {
	xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP")
    if (xmlhttp2)
    {
		xmlhttp2.onreadystatechange = state_Change2
	    xmlhttp2.open("GET",url,true)
		xmlhttp2.send()
    }
  }
}

function state_Change2()
{
  // if xmlhttp shows "loaded"
  if (xmlhttp2.readyState==4){
	// if "OK"
    if (xmlhttp2.status==200){
	  document.getElementById('WebcamsRow').innerHTML = xmlhttp2.responseText;
    }
  }
}

function loadXMLDoc3(url)
{
  // code for Mozilla, etc.
  if(window.XMLHttpRequest){
	  xmlhttp3=new XMLHttpRequest()
	  xmlhttp3.onreadystatechange = state_Change3
	  xmlhttp3.open("GET",url,true)
	  xmlhttp3.send(null)
  }
  // code for IE
  else if (window.ActiveXObject)
  {
	xmlhttp3=new ActiveXObject("Microsoft.XMLHTTP")
    if (xmlhttp3)
    {
		xmlhttp3.onreadystatechange = state_Change3
	    xmlhttp3.open("GET",url,true)
		xmlhttp3.send()
    }
  }
}

function state_Change3()
{
  // if xmlhttp shows "loaded"
  if (xmlhttp3.readyState==4){
	// if "OK"
    if (xmlhttp3.status==200){
	  document.getElementById('SameOther').innerHTML = xmlhttp3.responseText;
    }
  }
}
function loadXMLDoc4(url)
{
  // code for Mozilla, etc.
  if(window.XMLHttpRequest){
	  xmlhttp4=new XMLHttpRequest()
	  xmlhttp4.onreadystatechange = state_Change4
	  xmlhttp4.open("GET",url,true)
	  xmlhttp4.send(null)
  }
  // code for IE
  else if (window.ActiveXObject)
  {
	xmlhttp4=new ActiveXObject("Microsoft.XMLHTTP")
    if (xmlhttp4)
    {
		xmlhttp4.onreadystatechange = state_Change4
	    xmlhttp4.open("GET",url,true)
		  xmlhttp4.send()
    }
  }
}

function state_Change4()
{
  // if xmlhttp shows "loaded"
  if (xmlhttp4.readyState==4){
	// if "OK"
    if (xmlhttp4.status==200){
	  document.getElementById('SameOtherTmf').innerHTML = xmlhttp4.responseText;
    }
  }
}
window.status = " ";
