// JavaScript Document
function simpleAjaxRequest(target, param){
	//alert("simpleAjaxRequest called");
	var method = (!method) ? "GET" : method;
	(!param) ? alert("param are missing") : true;
	var http = false;

	if(navigator.appName == "Microsoft Internet Explorer") {
		http = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		http = new XMLHttpRequest();
	}

	if (param.noCache){
		target = (target.indexOf("?")>-1) ?  target+"&ajaxRand="+Math.random(999999) : target+"?ajaxRand="+Math.random(999999);
	}

	http.open(method, target);
	http.onreadystatechange=function() {
		if(http.readyState == 4 && http.status == 200) {
			//var obj = ([param.obj+"."+param.callBackFunction]);
			eval(param.callBackFunction)({text:http.responseText,targetObj:param.targetObj});
		}
	}
	http.send(null);
}
function getResponse(response){
	if (response.text.indexOf("error")<0)
	{
		document.getElementById('random_video').innerHTML = response.text;
	}else{
		document.getElementById('random_video').innerHTML = response.text;
	}
}
function displayRandomVideo(){
	var div = document.getElementById('random_video');
	if (typeof(div)=="object"){
		div = div.innerHTML = "loading..";
		simpleAjaxRequest("_includes/getRandomMovie.php?", {callBackFunction:'getResponse',noCache:true});
	}
}


