var IE = (navigator.appName == "Microsoft Internet Explorer");

var resized			= false;
var topmargin		= 170;  // space used for banner, menu etc
var innermargin		= 20;		// left and right margin when frame is resized
var const_mainurl	= "";

var categories = new Array();
var othercategories = new Array();
var theircategories = new Array();
var note_id = '';
var note_content = '';

function bookmarksite(title, url) {
	if (window.sidebar) {
		window.sidebar.addPanel(title, url, "");
	} else if(window.opera && window.print) {
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} else if(document.all) {
		window.external.AddFavorite(url, title);
	}
}

function newPassword(error,ok) {
	var html = '' +
		'<center>' +
		'<form action="index.php" method="post" onkeypress="var e = e || event; if (e.keyCode == 27) hideMsg(\'popup\'); if (e.keyCode == 13) { if(!emailCheck(document.getElementById(\'emailAddress\').value)){alert(\'Vul een geldig e-mailadres in\');}else{document.getElementById(\'submitbutton\').disabled=true;thissubmit();} }">' +
		'<table align="center" border="0" cellpadding="15" cellspacing="0" style="background-color:#ffffff;border:4px #9e9ecc solid;width:400px;height:300px;">' +
		'<tr>' +
		'  <td style="width:25px"><img src="img/logo_small.png" alt=""/></td>' +
		'  <td style="width:375px" class="title" valign="middle"> Nieuw wachtwoord</td>' +
	  	'</tr>' +
		'<tr>' +
		'  <td colspan="2">';
	if (ok != null) {
		html += '<p>' + ok;
	}
	else {
		html += '<p>' +
		'<input type="hidden" name="action" value="newpassword">' +
		'Wachtwoord vergeten?<br>Vul je e-mailadres in en wij sturen een nieuwe.' +
		'<p>' +
		'e-mailadres: <input type="text" name="emailAddress" id="emailAddress" value="" style="width:200px">' +
		'<p>' +
		'<input type="button" id="submitbutton" value="verstuur" onClick="if(!emailCheck(document.getElementById(\'emailAddress\').value)){alert(\'Vul een geldig e-mailadres in\');}else{this.disabled=true;this.form.submit();}">';
		if (error != null) {
			html += '<p><span style="color:red;">' + error + '</span>';
		}
	}
	html += '' +
		'	<p>' +
		'	<center>' +
		'	<a href="javascript:void(0)" onClick="hideMsg(\'popup\')"><span style="font-size:10pt;">Annuleren</span></a>' +
		'	</center>' +
		'  </td>' +
		'</tr>' +
		'</table>' +
		'</form>' +
		'</center>';
	
	document.getElementById('popup').innerHTML = html;
	
	showMsg('popup');
	if (document.getElementById('emailAddress'))
		document.getElementById('emailAddress').focus();
	javascript:scroll(0,0);
}

function incorrectPassword() {
	var html = '' +
		'<center>' +
		'<form action="index.php" method="post" onkeypress="var e = e || event; if (e.keyCode == 27) hideMsg(\'popup\'); if (e.keyCode == 13) { if(!emailCheck(document.getElementById(\'emailAddress\').value)){alert(\'Vul een geldig e-mailadres in\');}else{document.getElementById(\'submitbutton\').disabled=true;thissubmit();} }">' +
		'<table align="center" border="0" cellpadding="15" cellspacing="0" style="background-color:#ffffff;border:4px #9e9ecc solid;width:400px;height:300px;">' +
		'<tr>' +
		'  <td style="width:25px"><img src="img/logo_small.png" alt=""/></td>' +
		'  <td style="width:375px" class="title" valign="middle"> Inloggen mislukt</td>' +
	  	'</tr>' +
		'<tr>' +
		'  <td colspan="2">' +
		'	<p>' +
		'	Jouw ingevulde gebruikersnaam en/of wachtwoord zijn niet correct.<p>' +
		'	<center>' +
		'	<a href="javascript:void(0)" onClick="hideMsg(\'popup\')"><span style="font-size:10pt;">Sluit venster</span></a>' +
		'	</center>' +
		'  </td>' +
		'</tr>' +
		'</table>' +
		'</form>' +
		'</center>';
	
	document.getElementById('popup').innerHTML = html;
	
	showMsg('popup');
	if (document.getElementById('emailAddress'))
		document.getElementById('emailAddress').focus();
	javascript:scroll(0,0);
}

function sendTip(name,sitename,siteurl) {
	var html = '' + 
		'<form action="index.php" method="post" onSubmit="if (checktipform()) this.form.submit();" onkeypress="var e = e || event; if (e.keyCode == 27) hideMsg(\'popup\');">' +
		'<table align="center" border="0" cellpadding="15" cellspacing="0" style="background-color:#ffffff;border:4px #9e9ecc solid;width:400px;height:300px;">' +
		'<tr>' +
		'  <td style="width:25px"><img src="img/logo_small.png" alt=""/></td>' +
		'  <td style="width:375px" class="title" valign="middle"> Verstuur een tip aan een vriend</td>' +
	  	'</tr>' +
		'<tr>' +
		'  <td colspan="2">' +
		'	<input type="hidden" name="action" value="sendtip">' +
		'	<table style="width:100%">' +
		'	<tr><td style="width:120px">naam vriend</td><td><input type="text" name="tip_name" id="tip_name" style="width:100%"></td></tr>' +
		'	<tr><td style="width:120px">e-mailadres vriend</td><td><input type="text" name="tip_email" id="tip_email" style="width:100%"></td></tr>' +
		'	<tr><td style="width:120px" valign="top">bericht</td><td><textarea name="tip_body" id="tip_body" style="width:100%" rows="10">Neem ook een gratis account op '+sitename+': '+siteurl+'</textarea></td></tr>' +
		'	</table>' +
		'	<p>' +
		'	<input type="button" id="submitbutton" value="verstuur" onClick="if (checktipform()) { this.disabled=true; this.form.submit(); }">' +
		'	<p>' +
		'	<center>' +
		'	<a href="javascript:void(0)" onClick="hideMsg(\'popup\')"><span style="font-size:10pt;">Annuleren</span></a>' +
		'	</center>' +
		'  </td>' +
		'</tr>' +
		'</table>' +
		'</form>';
	
	document.getElementById('popup').innerHTML = html; 	
	
	showMsg('popup');
	document.getElementById('tip_name').focus();
	javascript:scroll(0,0);
}

function addFavorite() {
	var html = '' +
		'<center>' +
		'<form action="index.php" method="post" onkeypress="var e = e || event; if (e.keyCode == 27) hideMsg(\'popup\'); if (e.keyCode == 13) { if (checkfavoriteform()) { document.getElementById(\'submitbutton\').disabled=true; this.submit(); } }">' +
		'<table align="center" border="0" cellpadding="15" cellspacing="0" style="background-color:#ffffff;border:4px #9e9ecc solid;width:400px;height:300px;">' +
		'<tr>' +
		'  <td style="width:25px"><img src="img/logo_small.png" alt=""/></td>' +
		'  <td style="width:375px" class="title" valign="middle"> Website toevoegen</td>' +
	  	'</tr>' +
		'<tr>' +
		'  <td colspan="2">' +
		'	<input type="hidden" name="action" value="addfavorite">' +
		'	<input type="hidden" name="fid" id="fid" value="">' +
		'	<input type="hidden" name="old_catid" id="old_catid" value="">' +
		'	<table>' +
		'	<tr><td>titel:</td><td><input type="text" name="fav_title" id="fav_title" size="45"></td></tr>' +
		'	<tr><td>url:</td><td><input type="text" name="fav_url" id="fav_url" size="45"></td></tr>' +
		'	</table>' +
		'	<table>' +
		'	<tr><td><img src="/img/unlock.gif"></td><td><input type="radio" name="fav_private" id="fav_private_no" value="0"> openbaar</td></tr>' +
		'	<tr><td><img src="/img/lock.gif"></td><td><input type="radio" name="fav_private" id="fav_private_yes" value="1"> priv&eacute;</td></tr>' +
		'	</table>' +
		'	<br>' +
		'	<b>In categorie:</b> ' +
		'	<select name="fav_catid" id="fav_catid">';
	for (var i = 0; i < categories.length; i++) {
		html += '' +
			'<option value="' + categories[i][0] + '">' + categories[i][1] + '</option>';
	}
	html += '' +
		'	</select>' +
		'	<p>' +
		'	<input type="button" id="submitbutton" value="voeg toe" onClick="if (checkfavoriteform()) { this.disabled=true; this.form.submit(); }">' +
		'	<p>' +
		'	<center>' +
		'	<a href="javascript:void(0)" onClick="hideMsg(\'popup\')"><span style="font-size:10pt;">Annuleren</span></a>' +
		'	</center>' +
		'  </td>' +
		'</tr>' +
		'</table>' +
		'</form>' +
		'</center>';

	document.getElementById('popup').innerHTML = html; 	
	
	document.getElementById('fav_private_yes').checked = true;
	document.getElementById('fav_private_no').checked = false;
	if (document.getElementById('fav_new')) {
		document.getElementById('fav_url').value = toUrl(document.getElementById('fav_new').value);
	} 
	showMsg('popup');
	document.getElementById('fav_title').focus();
	javascript:scroll(0,0);
}

function editFavorite( id, name, url, isPrivate, catid ) {
	var html = '' +
		'<center>' +
		'<form action="index.php" method="post" onkeypress="var e = e || event; if (e.keyCode == 27) hideMsg(\'popup\'); if (e.keyCode == 13) { if (checkfavoriteform()) { document.getElementById(\'submitbutton\').disabled=true; this.submit(); } }">' +
		'<table align="center" border="0" cellpadding="15" cellspacing="0" style="background-color:#ffffff;border:4px #9e9ecc solid;width:400px;height:300px;">' +
		'<tr>' +
		'  <td style="width:25px"><img src="img/logo_small.png" alt=""/></td>' +
		'  <td style="width:375px" class="title" valign="middle"> Website bewerken</td>' +
	  	'</tr>' +
		'<tr>' +
		'  <td colspan="2">' +
		'	<input type="hidden" name="action" value="editfavorite">' +
		'	<input type="hidden" name="fid" id="fid" value="">' +
		'	<input type="hidden" name="old_catid" id="old_catid" value="">' +
		'	<table>' +
		'	<tr><td>titel:</td><td><input type="text" name="fav_title" id="fav_title" size="45"></td></tr>' +
		'	<tr><td>url:</td><td><input type="text" name="fav_url" id="fav_url" size="45"></td></tr>' +
		'	</table>' +
		'	<table>' +
		'	<tr><td><img src="/img/unlock.gif"></td><td><input type="radio" name="fav_private" id="fav_private_no" value="0"> openbaar</td></tr>' +
		'	<tr><td><img src="/img/lock.gif"></td><td><input type="radio" name="fav_private" id="fav_private_yes" value="1"> priv&eacute;</td></tr>' +
		'	</table>' +
		'	<br>' +
		'	<table>' +
		'	<tr><td><b>Verplaats naar:</b></td><td>' +
		'	<select name="fav_catid" id="fav_catid">';
	for (var i = 0; i < categories.length; i++) {
		html += '' +
			'<option value="' + categories[i][0] + '">' + categories[i][1] + '</option>';
	}
	html += '' +
		'	</select></td></tr>' +
		'<tr><td><b>Kopieer naar:</b></td><td>' +
		'<select name="fav_catid_copy" id="fav_catid_copy">' +
		'<option value=""></option>';
	for (var i = 0; i < categories.length; i++) {
		html += '' +
			'<option value="' + categories[i][0] + '">' + categories[i][1] + '</option>';
	}
	html += '' +
		'	</select></td></tr>' +
		'	</table>' +
		'	<p>' +
		'	<input type="button" id="submitbutton" value="opslaan" onClick="if (checkfavoriteform()) { this.disabled=true; this.form.submit(); }">' +
		'	<p>' +
		'	<center>' +
		'	<a href="javascript:void(0)" onClick="hideMsg(\'popup\')"><span style="font-size:10pt;">Annuleren</span></a>' +
		'	</center>' +
		'  </td>' +
		'</tr>' +
		'</table>' +
		'</form>' +
		'</center>';
	
	document.getElementById('popup').innerHTML = html; 	
	
	document.getElementById('fid').value = id;
	document.getElementById('old_catid').value = catid;
	document.getElementById('fav_url').value = url; 
	document.getElementById('fav_title').value = name; 
	var cat = document.getElementById('fav_catid');
	for (var i = 0; i < cat.options.length; i++) { 
		if (parseInt(cat.options[i].value) == parseInt(catid)) cat.selectedIndex = i;
	}
	document.getElementById('fav_private_yes').checked = (isPrivate);
	document.getElementById('fav_private_no').checked = (!isPrivate);
	showMsg('popup');
	document.getElementById('fav_title').focus();
	javascript:scroll(0,0);
}

function editCategory( id, name ) {
	var html = '' + 
		'<center>' +
		'<form action="index.php" method="post" onkeypress="var e = e || event; if (e.keyCode == 27) hideMsg(\'popup\'); if (e.keyCode == 13) { document.getElementById(\'submitbutton\').disabled=true;this.submit(); }">' +
		'<table align="center" border="0" cellpadding="15" cellspacing="0" style="background-color:#ffffff;border:4px #9e9ecc solid;width:400px;height:300px;">' +
		'<tr>' +
		'  <td style="width:25px"><img src="img/logo_small.png" alt=""/></td>' +
		'  <td style="width:375px" class="title" valign="middle"> Categorie hernoemen</td>' +
	  	'</tr>' +
		'<tr>' +
		'  <td colspan="2">' +
		'	<input type="hidden" name="action" value="editcategory">' +
		'	<input type="hidden" name="catid" id="catid" value="">' +
		'	naam: <input type="text" name="newcatname" id="newcatname" value="">' +
		'	<p>' +
		'	<input type="button" id="submitbutton" value="opslaan" onClick="this.disabled=true;this.form.submit();">' +
		'	<p>' +
		'	<center>' +
		'	<a href="javascript:void(0)" onClick="hideMsg(\'popup\')"><span style="font-size:10pt;">Annuleren</span></a>' +
		'	</center>' +
		'  </td>' +
		'</tr>' +
		'</table>' +
		'</form>' +
		'</center>';
	
	document.getElementById('popup').innerHTML = html; 	
	
	document.getElementById('catid').value = id;
	document.getElementById('newcatname').value = name;
	showMsg('popup');
	document.getElementById('newcatname').focus();
	javascript:scroll(0,0);
}

function deleteCategoryFromTab( tabname ) {
	var html = '' + 
		'<center>' +
		'<form action="index.php" method="post" onkeypress="var e = e || event; if (e.keyCode == 27) hideMsg(\'popup\'); if (e.keyCode == 13) { document.getElementById(\'submitbutton\').disabled=true;this.submit(); }">' +
		'<table align="center" border="0" cellpadding="15" cellspacing="0" style="background-color:#ffffff;border:4px #9e9ecc solid;width:400px;height:300px;">' +
		'<tr>' +
		'  <td style="width:25px"><img src="img/logo_small.png" alt=""/></td>' +
		'  <td style="width:375px" class="title" valign="middle"> Verwijder categorie uit<br>\'' + tabname + '\'</td>' +
	  	'</tr>' +
		'<tr>' +
		'  <td colspan="2">' +
		'	<input type="hidden" name="action" value="deletecat">' +
		'	<select name="fav_catid" id="fav_catid">';
	for (var i = 0; i < categories.length; i++) {
		html += '' +
			'<option value="' + categories[i][0] + '">' + categories[i][1] + '</option>';
	}
	html += '' +
		'	</select>' +
		'	<p>' +
		'	<input type="button" id="submitbutton" value="verwijder" onClick="this.disabled=true;this.form.submit();">' +
		'	<p>' +
		'	<center>' +
		'	<a href="javascript:void(0)" onClick="hideMsg(\'popup\')"><span style="font-size:10pt;">Annuleren</span></a>' +
		'	</center>' +
		'  </td>' +
		'</tr>' +
		'</table>' +
		'</form>' +
		'</center>';
	
	document.getElementById('popup').innerHTML = html; 	
	
	showMsg('popup');
	document.getElementById('fav_catid').focus();
	javascript:scroll(0,0);
}

function addCategoryToTab( tabname ) {
	var html = '' + 
		'<center>' +
		'<form action="index.php" method="post" onkeypress="var e = e || event; if (e.keyCode == 27) hideMsg(\'popup\'); if (e.keyCode == 13) { document.getElementById(\'submitbutton\').disabled=true;this.submit(); }">' +
		'<table align="center" border="0" cellpadding="15" cellspacing="0" style="background-color:#ffffff;border:4px #9e9ecc solid;width:400px;height:300px;">' +
		'<tr>' +
		'  <td style="width:25px"><img src="img/logo_small.png" alt=""/></td>' +
		'  <td style="width:375px" class="title" valign="middle"> Voeg categorie toe aan<br>\'' + tabname + '\'</td>' +
	  	'</tr>' +
		'<tr>' +
		'  <td colspan="2">' +
		'	<input type="hidden" name="action" value="addcat">' +
		'	<select name="fav_catid" id="fav_catid">';
	for (var i = 0; i < othercategories.length; i++) {
		html += '' +
			'<option value="' + othercategories[i][0] + '">' + othercategories[i][1] + '</option>';
	}
	html += '' +
		'	</select>' +
		'	<p>' +
		'	<input type="button" id="submitbutton" value="voeg toe" onClick="this.disabled=true;this.form.submit();">' +
		'	<p>' +
		'	<center>' +
		'	<a href="javascript:void(0)" onClick="hideMsg(\'popup\')"><span style="font-size:10pt;">Annuleren</span></a>' +
		'	</center>' +
		'  </td>' +
		'</tr>' +
		'</table>' +
		'</form>' +
		'</center>';
	
	document.getElementById('popup').innerHTML = html; 	
	
	showMsg('popup');
	document.getElementById('fav_catid').focus();
	javascript:scroll(0,0);
}

function addCategory() {
	var html = '' + 
		'<center>' +
		'<form action="index.php" method="post" onkeypress="var e = e || event; if (e.keyCode == 27) hideMsg(\'popup\'); if (e.keyCode == 13) { document.getElementById(\'submitbutton\').disabled=true;this.submit(); }">' +
		'<table align="center" border="0" cellpadding="15" cellspacing="0" style="background-color:#ffffff;border:4px #9e9ecc solid;width:400px;height:300px;">' +
		'<tr>' +
		'  <td style="width:25px"><img src="img/logo_small.png" alt=""/></td>' +
		'  <td style="width:375px" class="title" valign="middle"> Categorie toevoegen</td>' +
	  	'</tr>' +
		'<tr>' +
		'  <td colspan="2">' +
		'	<input type="hidden" name="action" value="add">' +
		'	titel: <input type="text" maxlength="35" name="cat_new" id="cat_new">' +
		'	<p>' +
		'	<input type="button" id="submitbutton" value="voeg toe" onClick="this.disabled=true;this.form.submit();">' +
		'	<p>' +
		'	<center>' +
		'	<a href="javascript:void(0)" onClick="hideMsg(\'popup\')"><span style="font-size:10pt;">Annuleren</span></a>' +
		'	</center>' +
		'  </td>' +
		'</tr>' +
		'</table>' +
		'</form>' +
		'</center>';
	
	document.getElementById('popup').innerHTML = html;
	
	showMsg('popup');
	document.getElementById('cat_new').focus();
	javascript:scroll(0,0);
}

function addTab() {
	var html = '' + 
		'<center>' +
		'<form action="index.php" method="post" onkeypress="var e = e || event; if (e.keyCode == 27) hideMsg(\'popup\'); if (e.keyCode == 13) { document.getElementById(\'submitbutton\').disabled=true;this.submit(); }">' +
		'<table align="center" border="0" cellpadding="15" cellspacing="0" style="background-color:#ffffff;border:4px #9e9ecc solid;width:400px;height:300px;">' +
		'<tr>' +
		'  <td style="width:25px"><img src="img/logo_small.png" alt=""/></td>' +
		'  <td style="width:375px" class="title" valign="middle"> Tabblad toevoegen</td>' +
	  	'</tr>' +
		'<tr>' +
		'  <td colspan="2">' +
		'	<input type="hidden" name="action" value="newtab">' +
		'	titel: <input type="text" maxlength="25" name="newtabname" id="newtabname">' +
		'	<p>' +
		'	<input type="button" id="submitbutton" value="voeg toe" onClick="this.disabled=true;this.form.submit();">' +
		'	<p>' +
		'	<center>' +
		'	<a href="javascript:void(0)" onClick="hideMsg(\'popup\')"><span style="font-size:10pt;">Annuleren</span></a>' +
		'	</center>' +
		'  </td>' +
		'</tr>' +
		'</table>' +
		'</form>' +
		'</center>';
	
	document.getElementById('popup').innerHTML = html; 	
	
	showMsg('popup');
	document.getElementById('newtabname').focus();
	javascript:scroll(0,0);
}

function showNote() {
	var html = '' + 
		'<form action="index.php" method="post" onkeypress="var e = e || event; if (e.keyCode == 27) hideMsg(\'popup\');">' +
  		'<input type="hidden" name="note_id" value="' + note_id + '">' +
		'<table align="center" border="0" cellpadding="15" cellspacing="0" style="background-color:#ffffff;border:4px #9e9ecc solid;width:400px;height:300px;">' +
		'<input type="hidden" name="action" value="updatenote">' +
		'<tr>' +
		'  <td valign="middle" style="width:25px;height:13px;"><img src="img/logo_small.png" alt=""/></td>' +
		'  <td valign="middle" style="width:345px;height:13px;" class="title"> Kladblokje</td>' +
		'  <td valign="middle" align="right" style="width:30px;height:13px;">' +
		'		<a href="javascript:void(0)" onClick="hideMsg(\'popup\');">Sluiten</a>' +
		'  </td>' +
		'</tr>' +
		'<tr>' +
		'  <td valign="top" colspan="4">' +
		'		<textarea id="note_content" name="note_content" style="width:100%;" rows="20">' + note_content + '</textarea>' +
		'		<br>' +
		'		<input type="button" id="submitbutton" value="opslaan" onClick="this.disabled=true;this.form.submit();">';
		'</td>' +
		'</tr>' +
		'</table>' +
		'</form>'
	document.getElementById('popup').innerHTML = html; 	
	showMsg('popup');
	javascript:scroll(0,0);
}

function reloadwindow() {
	window.location.href = window.location.href;
}

function popup( page ) {
	window.open(page,'_blank','width='+(screen.width-200)+',height='+(screen.height-200)+',left=150,top=50,status=no,location=no,menubar=no,directories=no,toolbar=no,resizable=yes,scrollbars=yes');
}

function showMsg(elemname) {
	var w = 400; var h = 300; var d = 800;
	var blur = document.getElementById('semi-transparent');
	var msgtable = document.getElementById(elemname);
	//msgtable.style.top = (window.document.body.clientHeight/2)-(h/2)-150;
	msgtable.style.top = 100;
	var size = getDocumentSize();
	blur.style.width = size[0] + 'px';
	blur.style.height = (size[1]+1000) + 'px';
	blur.style.display = 'block';
	msgtable.style.width = size[0] + 'px';
	msgtable.style.height = '500px';
	msgtable.style.display = 'block';
}

function hideMsg(elemname) {
	var blur = document.getElementById('semi-transparent');
	var msgtable = document.getElementById(elemname);
	blur.style.display = 'none';
	msgtable.style.display = 'none';
}

function checkfavoriteform() {
	var errors = '';
	if (val('fav_title').length == 0) errors += '- Vul de titel in\n';
	if (val('fav_url').length == 0) errors += '- Vul de url in\n';
	if (val('fav_url') != null) {
		if (val('fav_url') == 'http://') errors += '- Vul de url in\n';
	}
	
	if (errors == '') {
		return true;
	} 
	else {
		alert('Je hebt niet alles ingevuld!\n\n'+errors);
		return false;
	}
}

function checkcontactform() {
	var errors = '';
	if (val('s_contact_name').length == 0) errors += '- Vul je naam in\n';
	if (!emailCheck(val('s_contact_email'))) errors += '- Vul een correct e-mailadres in\n';
	if (val('s_contact_subject').length == 0) errors += '- Vul een onderwerp in\n';
	if (val('s_contact_text').length == 0) errors += '- De tekst van het bericht is leeg\n';
	
	if (errors == '') {
		return true;
	} 
	else {
		alert('Je hebt niet alles (goed) ingevuld!\n\n'+errors);
		return false;
	}
}

function checktipform() {
	var errors = '';
	if (val('tip_name').length == 0) errors += '- Vul de naam in van de ontvanger\n';
	if (!emailCheck(val('tip_email'))) errors += '- Vul een correct e-mailadres in\n';
	if (val('tip_body').length == 0) errors += '- De tekst van het bericht is leeg\n';
	
	if (errors == '') {
		return true;
	} 
	else {
		alert('Je hebt niet alles (goed) ingevuld!\n\n'+errors);
		return false;
	}
}

function checkaccountform( checkpassword ) {
	if (val('s_password').length > 0) checkpassword = true;
	if (val('s_password_again').length > 0) checkpassword = true;
	var errors = '';
	//if (val('s_name').length == 0) errors += '- Vul je voornaam in\n';
	//if (val('s_surname').length == 0) errors += '- Vul je achternaam in\n';
	if (val('s_username').length == 0) errors += '- Vul je gebruikersnaam in\n';
	if (val('s_password').length < 6 && checkpassword) errors += '- Vul een wachtwoord in van minstens 6 karakters\n';
	if (val('s_password_again').length == 0 && checkpassword) errors += '- Herhaal wachtwoord\n';
	if (val('s_password') != val('s_password_again') && checkpassword) {
		errors += '- Je hebt niet 2x hetzelfde wachtwoord ingevuld\n';
		delval('s_password');
		delval('s_password_again');
	}
	if (!emailCheck(val('s_emailaddress'))) errors += '- Vul een correct e-mailadres in\n';
	//if (val('s_gender').length == 0) errors += '- Selecteer je geslacht (m/v)\n';
	//if (!isDate(val('s_dateofbirth'))) errors += '- Vul je geboortedatum correct in (dd-mm-jjjj)\n';
	//if (val('s_city').length == 0) errors += '- Vul je woonplaats in\n';
	//if (val('s_mobile').length > 0 && val('s_mobile').length < 10) errors += '- Een telefoonnummer moet uit 10 cijfers bestaan\n';
	//if (val('s_terms') != '1') errors += '- Om je aan te melden dien je akkoord te gaan met de algemene voorwaarden\n';
	//if (val('s_newsletter').length == 0) errors += '- Geef aan of je de nieuwsbrief wilt ontvangen\n';
	//if (!document.getElementById('s_terms').checked) errors += '\nJe moet akkoord gaan met de algemene voorwaarden\n';
	
	if (errors == '') {
		return true;
	} 
	else {
		alert('Je hebt niet alles (goed) ingevuld!\n\n'+errors);
		return false;
	}
}

function val(i) {
	return document.getElementById(i).value;
}
function delval(i) {
	document.getElementById(i).value = '';
}

function ShowHide(elem) {
	var x = document.getElementById(elem).style;
	x.display = (x.display == 'block') ? 'none' : 'block';
}

function SetCookie(name, value) {
        var argv = SetCookie.arguments;
        var argc = SetCookie.arguments.length;
        var expires = (argc > 2) ? argv[2] : null;
        var path = (argc > 3) ? argv[3] : null;
        var domain = (argc > 4) ? argv[4] : null;
        var secure = (argc > 5) ? argv[5] : false;
        document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) endstr = document.cookie.length;
	return unescape (document.cookie.substring(offset, endstr));
}
function GetCookie(name) {
	var arg = name+"=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) return getCookieVal(j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function toUrl( url ) {
	if (url.indexOf('://') <= 0)
		url = 'http://' + url;
	return url;
}

/* EMAIL VALIDATION SCRIPT */
		
		function emailCheck (emailStr) {
			/* The following pattern is used to check if the entered e-mail address
			   fits the user@domain format.  It also is used to separate the username
			   from the domain. */
			var emailPat=/^(.+)@(.+)$/
			/* The following string represents the pattern for matching all special
			   characters.  We don't want to allow special characters in the address. 
			   These characters include ( ) < > @ , ; : \ " . [ ]    */
			var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
			/* The following string represents the range of characters allowed in a 
			   username or domainname.  It really states which chars aren't allowed. */
			var validChars="\[^\\s" + specialChars + "\]"
			/* The following pattern applies if the "user" is a quoted string (in
			   which case, there are no rules about which characters are allowed
			   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
			   is a legal e-mail address. */
			var quotedUser="(\"[^\"]*\")"
			/* The following pattern applies for domains that are IP addresses,
			   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
			   e-mail address. NOTE: The square brackets are required. */
			var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
			/* The following string represents an atom (basically a series of
			   non-special characters.) */
			var atom=validChars + '+'
			/* The following string represents one word in the typical username.
			   For example, in john.doe@somewhere.com, john and doe are words.
			   Basically, a word is either an atom or quoted string. */
			var word="(" + atom + "|" + quotedUser + ")"
			// The following pattern describes the structure of the user
			var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
			/* The following pattern describes the structure of a normal symbolic
			   domain, as opposed to ipDomainPat, shown above. */
			var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
			
			
			/* Finally, let's start trying to figure out if the supplied address is
			   valid. */
			
			/* Begin with the coarse pattern to simply break up user@domain into
			   different pieces that are easy to analyze. */
			var matchArray=emailStr.match(emailPat)
			if (matchArray==null) {
			  /* Too many/few @'s or something; basically, this address doesn't
			     even fit the general mould of a valid e-mail address. */
				//alert("Email address seems incorrect (check @ and .'s)")
				return false
			}
			var user=matchArray[1]
			var domain=matchArray[2]
			
			// See if "user" is valid 
			if (user.match(userPat)==null) {
			    // user is not valid
			    //alert("The username doesn't seem to be valid.")
			    return false
			}
			
			/* if the e-mail address is at an IP address (as opposed to a symbolic
			   host name) make sure the IP address is valid. */
			var IPArray=domain.match(ipDomainPat)
			if (IPArray!=null) {
			    // this is an IP address
				  for (var i=1;i<=4;i++) {
				    if (IPArray[i]>255) {
				        //alert("Destination IP address is invalid!")
					return false
				    }
			    }
			    return true
			}
			
			// Domain is symbolic name
			var domainArray=domain.match(domainPat)
			if (domainArray==null) {
				//alert("The domain name doesn't seem to be valid.")
			    return false
			}
			
			/* domain name seems valid, but now make sure that it ends in a
			   three-letter word (like com, edu, gov) or a two-letter word,
			   representing country (uk, nl), and that there's a hostname preceding 
			   the domain or country. */
			
			/* Now we need to break up the domain to get a count of how many atoms
			   it consists of. */
			var atomPat=new RegExp(atom,"g")
			var domArr=domain.match(atomPat)
			var len=domArr.length
			if (domArr[domArr.length-1].length<2 || 
			    domArr[domArr.length-1].length>3) {
			   // the address must end in a two letter or three letter word.
			   //alert("The address must end in a three-letter domain, or two letter country.")
			   return false
			}
			
			// Make sure there's a host name preceding the domain.
			if (len<2) {
			   var errStr="This address is missing a hostname!"
			   //alert(errStr)
			   return false
			}
			
			// If we've gotten this far, everything's valid!
			return true;
		}
		



/* CHECKDATE SCRIPT */
		
		var dtCh= "/";
		var minYear=1900;
		var maxYear=1997;
		
		function isInteger(s){
			var i;
		    for (i = 0; i < s.length; i++){   
		        // Check that current character is number.
		        var c = s.charAt(i);
		        if (((c < "0") || (c > "9"))) return false;
		    }
		    // All characters are numbers.
		    return true;
		}
		
		function stripCharsInBag(s, bag){
			var i;
		    var returnString = "";
		    // Search through string's characters one by one.
		    // If character is not in bag, append to returnString.
		    for (i = 0; i < s.length; i++){   
		        var c = s.charAt(i);
		        if (bag.indexOf(c) == -1) returnString += c;
		    }
		    return returnString;
		}
		
		function daysInFebruary (year){
			// February has 29 days in any year evenly divisible by four,
		    // EXCEPT for centurial years which are not also divisible by 400.
		    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
		}
		function DaysArray(n) {
			for (var i = 1; i <= n; i++) {
				this[i] = 31
				if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
				if (i==2) {this[i] = 29}
		   } 
		   return this
		}
		
		function isDate(dtStr){
			var daysInMonth = DaysArray(12)
			var pos1=dtStr.indexOf(dtCh)
			var pos2=dtStr.indexOf(dtCh,pos1+1)
			var strMonth=dtStr.substring(pos1+1,pos2)
			var strDay=dtStr.substring(0,pos1)
			var strYear=dtStr.substring(pos2+1)
			strYr=strYear
			if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
			if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
			for (var i = 1; i <= 3; i++) {
				if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
			}
			month=parseInt(strMonth)
			day=parseInt(strDay)
			year=parseInt(strYr)
			if (pos1==-1 || pos2==-1){
				//alert("The date format should be : dd/mm/yyyy")
				return false
			}
			if (strMonth.length<1 || month<1 || month>12){
				//alert("Please enter a valid month")
				return false
			}
			if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
				//alert("Please enter a valid day")
				return false
			}
			if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
				//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
				return false
			}
			if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
				//alert("Please enter a valid date")
				return false
			}
		return true
		}

function getDocumentSize() {
	var ns6 = document.getElementById && !document.all;
	var width  = window.document.body.clientWidth;
	var height = window.document.body.clientHeight;  
	if (!ns6) {
		if( typeof( window.pageYOffset ) == 'number' ) {
		    //Netscape compliant
		    height += window.pageYOffset;
		    width  += window.pageXOffset;
		} 
		else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		    //DOM compliant
		    height += document.body.scrollTop;
		    width  += document.body.scrollLeft;
		} 
		else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		    //IE6 standards compliant mode
		    height += document.documentElement.scrollTop;
		    width  += document.documentElement.scrollLeft;
		}
		if (width < 0) width = 0;
		if (height < 0) height = 0;  
	}
	return new Array( width, height );
}

