// JavaScript Document
function createXMLHttpRequest_r() {
   try { return new XMLHttpRequest(); } catch(e) {}
   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
   alert("XMLHttpRequest not supported");
   return null;
}
var old_id;
function switchVideo($id,$name){	
	if (old_id != $id){
	   document.location.href = 'http://hulahoops.previewbox.co.uk/video/'+escape($name);
	   xhReq_r.open("post", "include_player.php");
	   xhReq_r.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	   xhReq_r.onreadystatechange = switchVideoReturn;
	   xhReq_r.send("vid_id="+$id);
	   var ele = document.getElementById('cell_'+$id);
	   if (ele){
			ele.style.backgroundImage="url('images/bg_white_30.png')";
			document.getElementById('thumb_'+$id).style.borderColor = "#E1A40D";
	   }else{
			alert('Could not find cell_'+$id+' DIV');
	   }
	   ele = document.getElementById('cell_'+ old_id);
	   if (ele){
			ele.style.backgroundImage="url('images/bg_white_10.png')";
			document.getElementById('thumb_'+old_id).style.borderColor = "#999999";
	   }else{
			alert('Could not find cell_'+ old_id+' DIV');
	   }
	   old_id = $id;
	}
}
function currentVidId($id){
	old_id = $id;
}
function removeDiv($id){
	var ele = document.getElementById($id);
	if (ele){
		ele.innerHTML = "";
	}
}
var xhReq_r = createXMLHttpRequest_r();//exsists in interface.js;

function switchVideoReturn(){
	if (xhReq_r.readyState == 4) {
		if (xhReq_r.status == 200) {
			var ele = document.getElementById('VideoPlayer');
			if (ele){
				ele.innerHTML = xhReq_r.responseText;
			}else{
				alert('Could not find VideoPlayer DIV');
			}
		} else {
			//alert('There was a problem with the request.');
			//Prob that the user has been clicking before the last request was done;
		}
	}
}

