// JavaScript Document
var httpRequest = false;
var flvId=location.href.split('flvId=')[1]; // video file name..
if(flvId=='' || flvId=="undefined" || flvId==null) flvId="1";
var contentNode;
var flvPath;
var belowVideoContent;
var thumbString='';
function makeRequest(url) 
{
	try{
      httpRequest = false;
      if (window.XMLHttpRequest) { // For Mozilla, Safari,... Browser's
         httpRequest = new XMLHttpRequest();
         if (httpRequest.overrideMimeType) {
            httpRequest.overrideMimeType('text/xml');
         }
      } else if (window.ActiveXObject) { // For IE Browser
         try {
            httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!httpRequest) {
         alert('Cannot Create XMLHTTP Instance');
         return false;
      }
      httpRequest.onreadystatechange = getData; //Calling a function getData()
      httpRequest.open('GET', url, true);
      httpRequest.send(null);
	}
	catch(e){debug!=-1?alert(e):"";}
}

function getData() 
{
	try{
	  if(httpRequest.readyState == 0) {}
	  if(httpRequest.readyState == 1) {}
	  if(httpRequest.readyState == 2) {}
	  if(httpRequest.readyState == 3) {}
	  if(httpRequest.readyState == 4) 
		{
		 if (httpRequest.status == 200) 
			{
				contentNode= httpRequest.responseXML.getElementsByTagName('content');
				process();

			}else{
				alert('There was a problem with the request.');
			}
		}
	}
	catch(e){
		alert(e)
	}
}
function process(){
	flvPath='';
	belowVideoContent='';
	thumbString='';
	var items=contentNode[0].getElementsByTagName('item');
	function getVal(num, nodeName){
			var v=items[num].getElementsByTagName(nodeName)[0].firstChild.nodeValue;
			//alert(v);
			return v;
	}
	for(k=0; k<items.length; k++){
		if(String(flvId)==String(items[k].getAttribute('id'))){
			flvPath=getVal(k,'videoPath')+"^"+getVal(k,'ccPath')+"^"+getVal(k,'videoImg');
			belowVideoContent=getVal(k,'belowVideoContent');
		}
		//constructing thumb string
		
         	thumbString+='<table border="0" cellpading="0" cellspacing="0" class="thumbContainer"><tr><td width="10%">'
		 		thumbString+='<a href="?flvId='+items[k].getAttribute('id')+'">'
				thumbString+='<img style="padding-bottom:1px;" border="0" id="thumb2" class="home-thumbnail" src="'+getVal(k,'thumbImg')+'" title="'+getVal(k,'thumbTitle')+'"/>'
				//thumbString+='<img border="0" src="/web/UK/about/humannetwork/images/thumb.png"/>'
		 		thumbString+='</a></td>'
			thumbString+='<td class="thumbHeader">'
          	thumbString+='<h3>'+getVal(k,'thumbTitle')+'</h3></td></tr>'
            thumbString+='<tr><td colspan="2" class="thumbDescription"><p>'+getVal(k,'thumbDes')+'</p></td></tr>'			
         thumbString+='</table>'
	}
}
function updatedBelowVideoContent(){
	var div=document.getElementById('home-video-entry');
	div.innerHTML=belowVideoContent;
}
function buildThumbs(){
	var div=document.getElementById('thumbContent');
	div.innerHTML=thumbString;
}