var lng = get_query_variable("l");
if (lng == null || lng == '') {
	lng = 'nl';
}
var subcounter = get_query_variable("subcounter");
if (lng == null || lng == '') {
	subcounter = '0';
}
function get_query_variable(in_var) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0; i<vars.length; i++) {
		var pair = vars[i].split("=");
		if (pair[0] == in_var) {
			return pair[1];
		}
	}
	return false;
}
function setStyle(obj,style,value){
	getRef(obj).style[style]= value;
}

function getRef(obj){
	return (typeof obj == "string") ?
		document.getElementById(obj) : obj;
}
function check_number(in_value) {
	pattern = /^[0-9]*$/;	
	if (!pattern.test(in_value))	{
		return false;
	}
	return true;
}
function check_letter(in_value) {
	pattern = /^[a-z]*$/;	
	if (!pattern.test(in_value))	{
		return false;
	}
	return true;
}
function translate(sLng, sNl, sFr, sDe) { // return text in the user's language
	var sOutput;
	switch (sLng.toLowerCase()) {
		case 'n': 
		case 'nl': 
			sOutput = sNl;
			break;
		case 'f': 
		case 'fr': 
			sOutput = sFr;
			break;
		case 'd': 
		case 'de':
		case 'du':
			sOutput = sDe;
			break;
		default:
			sOutput = sNl;
			break;
	}
	return sOutput;
}
function t(sLng, sNl, sFr, sDe) {
	translate(sLng, sNl, sFr, sDe);
}
function text_nlfr(sLng, sNl, sFr, sDe) {
	translate(sLng, sNl, sFr, sDe);
}
function valid_email(in_email) { 
	in_email = trim(in_email);
	var checkTLD = 0; 
	var knownDomsPat = / ^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/; 
	var emailPat = /^(.+)@(.+)$/; 
	var specialChars = "\\(\\)><@,;:\\\\\\\"\\.\\[\\]"; 
	var validChars = "\[^\\s" + specialChars + "\]"; 
	var quotedUser = "(\"[^\"]*\")"; 
	var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/; 
	var atom = validChars + '+'; 
	var word = "(" + atom + "|" + quotedUser + ")"; 
	var userPat = new RegExp("^" + word + "(\\." + word + ")*$"); 
	var domainPat = new RegExp("^" + atom + "(\\." + atom +")*$"); 
	var matchArray = in_email.match(emailPat); 
	if (matchArray == null) { 
		//alert("The Email Address Is Invalid"); 
		return false; 
	} 
	var user = matchArray[1]; 
	var domain = matchArray[2]; 
	for (i=0; i < user.length; i++) { 
		if (user.charCodeAt(i) > 127) { 
			//alert("The Username Contains Invalid Characters."); 
			return false; 
		} 
	} 
	for (i=0; i < domain.length; i++) { 
		if (domain.charCodeAt(i) > 127) { 
			//alert("Ths Domain Name Contains Invalid Characters."); 
			return false; 
		} 
	} 
	if (user.match(userPat) == null) { 
		//alert("The Username Is Invalid."); 
		return false; 
	} 
	var IPArray = domain.match(ipDomainPat); 
	if (IPArray != null) { 
		for (var i=1; i<=4; i++) { 
			if (IPArray > 255) { 
				//alert("The Destination IP Address Is Invalid."); 
				return false; 
			} 
		} 
		return true; 
	} 
	var atomPat = new RegExp("^" + atom + "$"); 
	var domArr = domain.split("."); 
	var len = domArr.length; 
	for (i=0; i < len; i++) { 
		if (domArr[i].search(atomPat) == -1) { 
			//alert("The Domain Name Is Invalid."); 
			return false; 
		} 
	} 
	if (checkTLD && domArr[domArr.length-1].length != 2 && domArr[domArr.length-1].search(knownDomsPat) == -1) { 
		// alert("The Domain Name Extension Is Invalid"); 
		return false; 
	} 
	if (len < 2) { 
		//alert("The Address Is Missing A Hostname."); 
		return false; 
	}
	return true;
} 
//
var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;
function showhide_layer(lay) {
	if (ie4) {
		if (window.document.all[lay].style.display == "none" || window.document.all[lay].style.display == "") {
			window.document.all[lay].style.display = "block";
		} else {
			window.document.all[lay].style.display = "none";
		}
	}
	if (ns4) {
		if (window.document.layers[lay].display == "none" || window.document.layers[lay].display == "") {
			window.document.layers[lay].display = "block";
		} else {
			window.document.layers[lay].display = "none";
		}
	}
	if (ns6) {
		if (document.getElementById([lay]).style.display == "none" || document.getElementById([lay]).style.display == "") {
			document.getElementById([lay]).style.display = "block";
		} else {
			document.getElementById([lay]).style.display = "none";
		}
	}
}
//
function show_layer(lay,tf) {
	if (ie4) {
		if (tf == '1') {
			window.document.all[lay].style.display = "block";
		} else {
			window.document.all[lay].style.display = "none";
		}
	}
	if (ns4) {
		if (tf == '1') {
			window.document.layers[lay].display = "block";
		} else {
			window.document.layers[lay].display = "none";
		}
	}
	if (ns6) {
		if (tf == '1') {
			document.getElementById([lay]).style.display = "block";
		} else {
			document.getElementById([lay]).style.display = "none";
		}
	}
}
/*-----------*/
// Removes leading whitespaces
function LTrim(value) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}
// Removes ending whitespaces
function RTrim(value) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}
// Removes leading and ending whitespaces
function trim(value) {
	return LTrim(RTrim(value));
}
function isArray(obj) {
   if (obj.constructor.toString().indexOf("Array") == -1)
      return false;
   else
      return true;
}
/*
function isArray() {
	if (typeof arguments[0] == 'object') {  
		var criterion = arguments[0].constructor.toString().match(/array/i);
		return (criterion != null);  
	}
	return false;
}
*/
function set_txt(key) {
	return translations[key];
}
/*--------------------------------------------------------------------------
--------------------------------------------------------------------------*/	
var popUpWin=0;
function popUpWindow(URLStr, pos_width,pos_height,tf_scrollbars,tf_resizable) {
	switch(tf_scrollbars) {
		case false:
		case 'no':
			tf_scrollbars = 'no';
			break;
		default:
			tf_scrollbars = 'yes';
	}
	switch(tf_resizable) {
		case true:
		case 'yes':
			tf_resizable = 'yes';
			break;
		default:
			tf_resizable = 'no';
	}
	if(popUpWin) {
		if(!popUpWin.closed) {
			popUpWin.close();
		}
	}
	pos_left = (screen.width-pos_width)/2;
	pos_top = (screen.height-(pos_height+110))/2;
	popUpWin = window.open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+tf_scrollbars+',resizable='+tf_resizable+',copyhistory=no,width='+pos_width+',height='+pos_height+',left='+pos_left+', top='+pos_top+',screenX='+pos_left+',screenY='+pos_top+'');
}
function print_page() {
	window.print();
}

// Hide additional questions for Capelo
function capelo_hack() {
	var q40El = document.getElementById('ws_question_40');
	var q41El = document.getElementById('ws_question_41');
	var q42El = document.getElementById('ws_question_42');

	var radios = document.getElementsByName("qgqid_114_workshopsessionid[]")
	var showCapelo = false;
	for (var i=0; i<radios.length; i++) {
		if (radios[i].checked === true) {
			showCapelo = true;
			break;
		} 
	}
	if (showCapelo) {
		q40El.style.display = '';
		q41El.style.display = '';
		q42El.style.display = '';
	} else {
		q40El.style.display = 'none';
		q41El.style.display = 'none';
		q42El.style.display = 'none';
	}
}
/*
window.onload = function() {
	document.getElementById('qg1').onclick = function(e) {
		capelo_hack();
	};	
	capelo_hack();
};
*/
