url = document.location.href;
xend = url.lastIndexOf("/") + 1;
var base_url = url.substring(0, xend);

var ajax_get_error = false;

function ajax_do (url) {
	if (url.substring(0, 4) != 'http') {
		url = base_url + url;
	}

	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = url;
	document.getElementById('playlist').style.visibility = 'hidden';
	document.getElementById('Logo').style.visibility = 'hidden';
	document.getElementById('movie').style.visibility = 'hidden';
	document.getElementById('contentclose').style.visibility = 'visible';
	document.getElementById('bg').style.visibility = 'visible';

document.body.appendChild (jsel);
	return true;
}

function ajax_get (url, el) {
	if (typeof(el) == 'string') {
		el = document.getElementById(el);
	}

	if (el == null) { return false; }
	if (url.substring(0, 4) != 'http') {
		url = base_url + url;
	}

	getfile_url = base_url + 'getfile.php?url=' + escape(url) + '&el=' + escape(el.id);
	ajax_do (getfile_url);
	return true;
}

function CloseContent(){
	document.getElementById('Dark').style.visibility = 'hidden';
	document.getElementById('content').style.visibility = 'hidden';
	document.getElementById('contentclose').style.visibility = 'hidden';
	document.getElementById('playlist').style.visibility = 'visible';
	document.getElementById('Logo').style.visibility = 'visible';
	document.getElementById('movie').style.visibility = 'visible';
	document.getElementById('bg').style.visibility = 'hidden';
}




var http_request = false;
function makeRequest(url, parameters) {
  http_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
	 http_request = new XMLHttpRequest();
	 if (http_request.overrideMimeType) {
		http_request.overrideMimeType('text/html');
	 }
  } else if (window.ActiveXObject) { // IE
	 try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
		try {
		   http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	 }
  }
  if (!http_request) {
	 alert('Cannot create XMLHTTP instance');
	 return false;
  }
  http_request.onreadystatechange = alertContents;
  http_request.open('GET', url + parameters, true);
  http_request.send(null);
}

function alertContents() {
  if (http_request.readyState == 4) {
	 if (http_request.status == 200) {
		//alert(http_request.responseText);
		result = http_request.responseText;
		document.getElementById('myspan').innerHTML = result;            
	 } else {
		alert('There was a problem with the request.');
	 }
  }
}

function get(obj) {
  var getstr = "?";
  for (i=0; i<obj.childNodes.length; i++) {
	 if (obj.childNodes[i].tagName == "INPUT") {
		if (obj.childNodes[i].type == "text") {
		   getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
		}
		if (obj.childNodes[i].type == "checkbox") {
		   if (obj.childNodes[i].checked) {
			  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
		   } else {
			  getstr += obj.childNodes[i].name + "=&";
		   }
		}
		if (obj.childNodes[i].type == "radio") {
		   if (obj.childNodes[i].checked) {
			  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
		   }
		}
	 }   
	 if (obj.childNodes[i].tagName == "SELECT") {
		var sel = obj.childNodes[i];
		getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
	 }
	if (obj.childNodes[i].type == "textarea") {
	   getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
	}
	 
  }
  makeRequest('fileincludes/sendcontact.php', getstr);
}


function StartStream(url){
	document.getElementById("Stream").innerHTML = "<iframe id='myIFrame' src='" + url + "'frameborder='0'></iframe>";
	document.getElementById('handje').style.display = 'none';
}

function StopStream(url){
	document.getElementById("Stream").innerHTML = "";
	document.getElementById('handje').style.display = 'block';
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function externalLinks() {
	if (!document.getElementsByTagName) {
	return;
	}
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
		}
}
window.onload = externalLinks;

function submit_prijsvraag() {
	window.open("", "prijsvraag", "height=400, width=400");
	document.prijsvraag_form.submit();
	CloseContent();
}


var http_request = false;
function makePOSTRequest(url, parameters) {
  http_request = false;
  if (window.XMLHttpRequest){
	 http_request = new XMLHttpRequest();
	 if (http_request.overrideMimeType) {
		http_request.overrideMimeType('text/html');
	 }
  } else if (window.ActiveXObject) {
	 try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
		try {
		   http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	 }
  }
  if (!http_request) {
	 alert('Kan XMLHTTP instance niet aanmaken');
	 return false;
  }
  
  http_request.onreadystatechange = alertContents;
  http_request.open('POST', url, true);
  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http_request.setRequestHeader("Content-length", parameters.length);
  http_request.setRequestHeader("Connection", "close");
  http_request.send(parameters);
}

function alertContents() {
  if (http_request.readyState == 4) {
	 if (http_request.status == 200) {
		result = http_request.responseText;
		document.getElementById('myspan').innerHTML = result;            
	 } else {
		alert('Er is een probleem ontstaan.');
	 }
  }
}

function get(obj) {
  ajax_do('content.php?page=playlistverleden&date='+encodeURI( document.getElementById('displaydate').value ));
 // setTimeout("parent.parent.location.reload()", 10);
}

function timeoutpostgb(){
	document.gbform.submit();
	setTimeout("ajax_do(\'content.php?page=Gastenboek\');", 1000);
}


function startplayer(){
	player_window = window.open("player.php","Player","width=327,height=170");
}
function closeplayer(){
	if(false == player_window.closed){
	player_window.close ();
	}
}