function WriteNavigation()
{
  var x = ReadXml();
  var path, title, thumb;

  for (var i=0; i<x.length; i++) {
	  try
	  {
	    path = x[i].getElementsByTagName("PATH")[0].childNodes[0].nodeValue;
	  }
	  catch(e)
	  {
	    path = "#";
	  }
	  try
	  {
	    title = x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue;
	  }
	  catch(e)
	  {
	    title = "No Title found";
	  }
	  try
	  {
	    thumb = x[i].getElementsByTagName("THUMB")[0].childNodes[0].nodeValue;
	  }
	  catch(e)
	  {
	    thumb = "video_thumbnail.gif";
	  }
		
	  document.writeln('<p id="video_' + i +'"><a href="' + path + '" onclick="UpdateNowPlaying(' + i + ');" title="' + title + '" target="main_frame"> ' + title + ' <br><img id="video_thumb_' + i +'" src="../images/' + thumb + '" /></a></p>');
  }
}
function WriteIframe()
{
  var x = ReadXml();
  var path;

	  try
	  {
	    path = x[0].getElementsByTagName("PATH")[0].childNodes[0].nodeValue;
	  }
	  catch(e)
	  {
	    path = "#";
	  }

	document.write('<iframe style="border: 1px solid #888; border-left:0; overflow:hidden;" name="main_frame" src="' + path + '" width="1036" height="607" frameborder="0" scrolling=NO></iframe>');
}

function UpdateNowPlaying(id)
{
  var x = ReadXml();
  document.getElementById( 'descr_title' ).innerHTML = x[id].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue;
  //document.getElementById( 'descr_text' ).innerHTML = x[id].getElementsByTagName("BODYTEXT")[0].childNodes[0].nodeValue;

  for (var i=0; i<x.length; i++) {
    document.getElementById( 'video_' + i).style.fontWeight = 'normal';
    document.getElementById( 'video_' + i).style.backgroundImage = 'none';
    document.getElementById( 'video_thumb_' + i).style.marginTop = '0';
    document.getElementById( 'video_thumb_' + i).style.opacity = 1.0;
    document.getElementById( 'video_thumb_' + i).style.filter = 'alpha(opacity=100)';
}
  document.getElementById( 'video_' + id).style.fontWeight = 'bold';
  document.getElementById( 'video_' + id).style.background = 'url(../images/video_bg.jpg) bottom left no-repeat';
  document.getElementById( 'video_thumb_' + id).style.marginTop = '7px';
  document.getElementById( 'video_thumb_' + id).style.opacity = 0.5;
  document.getElementById( 'video_thumb_' + id).style.filter = 'alpha(opacity=50)';
}

function ReadXml()
{
  try //Internet Explorer
  {
    xmlDoc=new ActiveXObject("Microsoft.XMLDOM");

    xmlDoc.async=false;
    xmlDoc.load("video_descriptions.xml");
  }
  catch(e)
  {
    try //Firefox, Mozilla, Opera, etc.
    {
      //xmlDoc=document.implementation.createDocument("","",null);        //Doesn't work for Chrome & Safari
      var xmlhttp = new window.XMLHttpRequest();
      xmlhttp.open("GET","video_descriptions.xml",false);
      xmlhttp.send(null);
      xmlDoc = xmlhttp.responseXML.documentElement;
    }
    catch(e)
    {
      alert(e.message);
      return;
    }
  }

  return xmlDoc.getElementsByTagName("DESCR");
}
