function switch_lang(lang) {
  var spans = new Array();

  spans = document.getElementsByTagName('div');

  for(i = 0; i < spans.length; i++) {

	if (spans[i].className.substr(0, 4) == 'lang') {
  	  if (spans[i].className == 'lang_'+lang) {
  		spans[i].style.display = 'block';
  	  } else {
  		spans[i].style.display = 'none';
  	  }
	}
  }
}

// depricated, for backwards compatibility
function popUp(url, width, height) {
	popup(url, '', width, height);
}

function popup(url, name, width, height) {
	if (!name) name = Math.floor(Math.random() * 100 +1);
	if (!width) width = 400;
	if (!height) height = 300;

	window.open(url, name ,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+ width +',height='+ height +',screenX=150,screenY=150,top=200,left=350')

}

function popupProduct(url) {
	window.open(url, 'Product' ,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=400,height=600,screenX=150,screenY=150,top=200,left=350');
}

/* JS for popup.php */

function show_opdrachten(id, top) {
	for(t = 1; t <= top; t++) {
		document.getElementById('project_' +t).style.width = '';
		document.getElementById('opdrachten_' +t).style.display = 'none';
	}

	document.getElementById('project_' +id).style.width = '280px';
	document.getElementById('opdrachten_' +id).style.display = 'block';
}

function open_opdracht(o_id, msg) {
	if (msg) {
		alert(msg);
	} else {
		document.getElementById('o_id').value = o_id;
		document.getElementById('nav').submit();
	}
}

function set_p_type(type) {
	document.getElementById('p_type').value = type;
	document.getElementById('nav').submit();
}

function change_navigatie(string) {
	document.getElementById('navigatie').innerHTML = string;
}

function open_les(l_id, msg) {
	if (msg) {
		alert(msg);
	} else {
		document.getElementById('l_id').value = l_id;
		document.getElementById('nav').submit();
	}
}

function home() {
	if (document.getElementById('active').value) {
		alert('Je kunt een les niet onderbreken');
	} else {
		document.getElementById('p_type').value = '';
		document.getElementById('o_id').value = '';
		document.getElementById('l_id').value = '';
		document.getElementById('nav').submit();
	}
}

function start_toets() {
	document.getElementById('active').value = 1;
	document.getElementById('nav').submit();
}
