function popUpCenterNoScroll( url, ww, wh ) {
	var WinWidth = ww;
	var WinHeight = wh;
	var HorPosition;
	var VerPosition;
	//gets top and left positions based on user's resolution so hint window is centered.
	HorPosition = (window.screen.width/2) - ((WinWidth/2) + 10); //half the screen width minus half the new window width (plus 5 pixel borders).
	VerPosition = (window.screen.height/2) - ((WinHeight/2) + 50); //half the screen height minus half the new window height (plus title and status bars).
	var win2 = window.open( url ,"bannerpopup","status=0,menubar=no,toolbar=no,Directory=no,height="+ WinHeight +",width="+ WinWidth +",resizable=no,left=" + HorPosition + ",top=" + VerPosition + ",screenX=" + HorPosition + ",screenY=" + VerPosition + ",scrollbars=no");
	win2.focus();

}

function popUpCenterScroll( url, ww, wh ) {
	var WinWidth = ww;
	var WinHeight = wh;
	var HorPosition;
	var VerPosition;
	//gets top and left positions based on user's resolution so hint window is centered.
	HorPosition = (window.screen.width/2) - ((WinWidth/2) + 10); //half the screen width minus half the new window width (plus 5 pixel borders).
	VerPosition = (window.screen.height/2) - ((WinHeight/2) + 50); //half the screen height minus half the new window height (plus title and status bars).
	var win2 = window.open( url ,"bannerpopup","status=0,menubar=no,toolbar=no,Directory=no,height="+ WinHeight +",width="+ WinWidth +",resizable=no,left=" + HorPosition + ",top=" + VerPosition + ",screenX=" + HorPosition + ",screenY=" + VerPosition + ",scrollbars=yes");
	win2.focus();

}


function doSearch(){
	var error = false;
	if (error) {
		alert(msg);		
	} else {
		document.searchgeneral.submit();
	}
}

function toggle_visibility(id) {
	var e = document.getElementById(id);
    if(e.style.display == 'block')
    	e.style.display = 'none';
    else
    	e.style.display = 'block';
}

	function isValidEmail(str) {

   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 


}



function validateAddAccountForm(){
	document.addaccount.gonext.value = 'next';
	var error = false;
	var msg = 'Account kan nog niet worden aangemaakt: \n\n';
	var minLength = 6; // Minimum length
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.addaccount.email.value;
   
	if(document.addaccount.geslacht.value == ""){
		msg = msg + '- Geslacht \n';
		error = true;
	}
	if(document.addaccount.achternaam.value == ""){
		msg = msg + '- Achternaam \n';
		error = true;
	}
	if(document.addaccount.voorletters.value == ""){
		msg = msg + '- Voorletters \n';
		error = true;
	}
	if(document.addaccount.adres.value == ""){
		msg = msg + '- Adres \n';
		error = true;
	}
	if(document.addaccount.huisnummer.value == ""){
		msg = msg + '- Huisnummer \n';
		error = true;
	}
	if(document.addaccount.postcode.value == ""){
		msg = msg + '- Postcode \n';
		error = true;
	}
	if(document.addaccount.woonplaats.value == ""){
		msg = msg + '- Woonplaats \n';
		error = true;
	}
	
   if (reg.test(address) == false) {
   	msg = msg + '- U dient een juist e-mailadres in te vullen. \n';
   	error = true;
   }
	
	if (document.addaccount.gebruikersnaam.value.length < minLength) {
		msg = msg + '- De gebruikersnaam dient minimaal 6 tekens lang te zijn \n'
		error = true;
	}
	if (document.addaccount.wachtwoord.value.length < minLength) {
		msg = msg + '- Het wachtwoord dient minimaal 6 tekens lang te zijn \n'
		error = true;
	}
	if(document.addaccount.akkoord.checked == false){ 
		msg = msg + '- U dient akkoord te gaan met de Algemene Voorwaarden \n'
		error = true;
	}
	
	if (error) {
		alert(msg);		
	} else {
		document.addaccount.submit();
	}
}

function returnAddAccountForm(){
	var error = false;
	document.addaccount.gonext.value = 'return';
	if (error) {
		alert(msg);		
	} else {
		document.addaccount.submit();
	}

}


function validateImgForm(){
	var error = false;
	var msg = 'Bestand kan nog niet worden toegevoegd: \n\n';
	
	if(document.addimg.file.value == ""){
		msg = msg + 'Kies een bestand \n';
		error = true;
	}
	
	if (error) {
		alert(msg);		
	} else {
		
		toggle_visibility('commupload');		
		toggle_visibility('upload');
		document.addimg.submit();
	}
}


function validateFilesForm(){
	var error = false;
	var msg = 'Bestand kan nog niet worden toegevoegd: \n\n';
	
	if(document.addfile.onderwerp.value == "null"){
		msg = msg + 'Kies type document \n';
		error = true;
	}
	
	if (error) {
		alert(msg);		
	} else {
			
		toggle_visibility('commupload');		
		toggle_visibility('upload');
		document.addfile.submit();
	}

}



function validateAccountForm(){
	var error = false;
	var msg = 'Accountgegevens kunnen nog niet worden gewijzigd: \n\n';
	
	if(document.updateaccount.achternaam.value == ""){
		msg = msg + 'Vul achternaam in \n';
		error = true;
	}
	
	if(document.updateaccount.voorletters.value == ""){
		msg = msg + 'Vul voorletters in \n';
		error = true;
	}
	
	if(document.updateaccount.email.value == ""){
		msg = msg + 'Vul email in \n';
		error = true;
	}
	
	if(document.updateaccount.gebruikersnaam.value == ""){
		msg = msg + 'Kies een gebruikersnaam in \n';
		error = true;
	}
	
	if(document.updateaccount.wachtwoord.value == ""){
		msg = msg + 'Kies een wachtwoord in \n';
		error = true;
	}
	
	if (error) {
		alert(msg);		
	} else {
		document.updateaccount.submit();
	}

}


function setMainImage(imgid){
	window.location = 'lib.prog.php?REQ=set_main_image&imgid=' + imgid;
}

function setMainImageInit(imgid){
	window.location = 'lib.prog.php?REQ=set_main_image_init&imgid=' + imgid;
}

function savePatentForm(goto){
	var error = false;
	var msg = 'Uitvinding kan nog niet worden opgeslagen: \n\n';
	
	if(document.addpatent.titel.value == ""){
		msg = msg + '- Vul titel in. \n';
		error = true;
	}
	
	if(document.addpatent.omschrijving_kort.value == ""){
		msg = msg + '- Omschrijf de uitvinding in een zin. \n';
		error = true;
	}
	
	if(document.addpatent.omschrijving_lang.value == ""){
		msg = msg + '- Omschrijf de uitvinding. \n';
		error = true;
	}
	
	if(document.addpatent.probleemomschrijving.value == ""){
		msg = msg + '- Omschrijf de probleemstelling. \n';
		error = true;
	}
	
	if(document.addpatent.doelgroepen.value == ""){
		msg = msg + '- Geef een beschrijving van de de doelgroep. \n';
		error = true;
	}
	
	if(document.addpatent.hulpvraag_primair.value == ""){
		msg = msg + 'Vraag 10: Waarnaar bent u opzoek? (primaire hulpvraag). \n';
		error = true;
	}


		
	if(goto == 'current'){
		document.addpatent.gonext.value = 'current_form';
	} else {
		document.addpatent.gonext.value = 'next';
	}
	
	if (error) {
		alert(msg);		
	} else {
		document.addpatent.submit();
	}
}

function confirmDeletePatent(pid){
		var msg = "Uitvinding echt verwijderen?\n";
		var result = confirm (msg);
		if (result){
			window.location = 'account.php?REQ=deletepatent&pid=' + pid;
		}  
	}

function validateLoginForm(){
	var error = false;
	
	if (error) {
		alert(msg);		
	} else {
		document.loginform.submit();
	}
}


/*
Later toegevoegd
*/

function cijfers(evt) {
	var charCode = (evt.which) ? evt.which : evt.keyCode;
	if ((charCode >= 48 && charCode <=57) || charCode == 8){ 
		return true; } // Alleen maar cijfers en backspace toegestaan
	return false;
}




