// Checks if a string is empty
function emptystr(string) {
	var x = 0;
	var chr;
	var empty = true;
	if (string.length) {
		do {
			chr = string.substring(x, x + 1);
			x++;
			empty = (chr == ' ' || chr == '\t' || chr == '\n' || chr == '\r');
		} while (empty && x < string.length);
	}
	return empty;
}

function checkGetal(item, name){
  if (isNaN(document.subform.elements[item].value)){
	  alert(name + ' moet een nummer zijn!');
    document.subform.elements[item].focus();
    return false;
  }
  else{
    return true;
  }
}

function showAlert(item, name){
  if (emptystr(document.subform.elements[item].value)){
    alert('U heeft ' + name + ' vergeten in te voeren!');
    document.subform.elements[item].focus();
    return false;
  }
  else{
    return true;
  }
}

function checkEmail(item){
  var pattern=/(^[\-_\.a-zA-Z0-9]+)@((([0-9]{1,3}\.){3}([0-9]{1,3})((:[0-9])*))|(([a-zA-Z0-9\-]+)(\.[a-zA-Z]{2,})+(\.[a-zA-Z]{2})?((:[0-9])*)))/;
  
  if (document.subform.elements[item].value.search(pattern) == -1){
    alert('Het e-mailadres is onjuist!');
    document.subform.elements[item].focus();
    return false;
  }
  else{
    return true;
  }
}

function addSubject() {
    return (showAlert('subject', 'het onderwerp') && showAlert('user', 'de naam') && checkEmail('email') && showAlert('content', 'het bericht')); 
}

function addPost() {
    return (showAlert('user', 'de naam') && checkEmail('email') && showAlert('content', 'het bericht')); 
}

function addNewsletterMember() {
    return (showAlert('lastname', 'de achternaam') && showAlert('firstname', 'de voornaam') && checkEmail('email'));
}

function removeNewsletterMember() {
    return checkEmail('email');
}

function searchRelation() {
    return (showAlert('search_string', 'de zoekopdracht'));
}

function windowOpen(name,url,Hoogte,Breedte) {
  LeftPosition = (screen.width) ? (screen.width-Breedte)/2 : 0;
  TopPosition = (screen.height) ? (screen.height-Hoogte)/2 : 0;
  settings ='height='+Hoogte+',width='+Breedte+',top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes'
  window_open = window.open(url,name, settings);
  window_open.focus();
}

function selectListboxItem ( theListbox, theItem ) {
	theOptions = theListbox.options;
	for(i=0; i<theOptions.length; i++) {
		theOptions[i].selected = theOptions[i].value == theItem;
	}
}

function printFrame(frame_name){ 
  if(typeof window.print == "undefined"){ 
    alert("Uw browser ondersteund dit niet!"); 
  }else{ 
    parent.frames[frame_name].focus(); 
    parent.frames[frame_name].window.print();  
  } 
} 

function form_setfocus( aForm ) {
	if( aForm.elements[0]!=null) {
		var i;
		var max = aForm.length;
		for( i = 0; i < max; i++ ) {
			if( aForm.elements[ i ].type != "hidden" &&
				!aForm.elements[ i ].disabled &&
				!aForm.elements[ i ].readOnly ) {
				aForm.elements[ i ].focus();
				break;
			}
		}
	}
}

imgFadeObjects = new Object();
imgFadeTimers = new Object();

function imgFade(object, naarDoorzichtigheid, snelheid, aantalStappen) {


	if (!document.all) {
		return;
	}

	if (object != "[object]") {
		setTimeout("imgFade("+object+","+naarDoorzichtigheid+","+snelheid+","+aantalStappen+")",0);
		return;
	}

	clearTimeout(imgFadeTimers[object.sourceIndex]);

	diff = naarDoorzichtigheid-object.filters.alpha.opacity;
	direction = 1;
	if (object.filters.alpha.opacity > naarDoorzichtigheid) {
		direction = -1;
	}

	aantalStappen = Math.min(direction*diff,aantalStappen);
	object.filters.alpha.opacity+=direction*aantalStappen;

	if (object.filters.alpha.opacity != naarDoorzichtigheid) {
		imgFadeObjects[object.sourceIndex] = object;
		imgFadeTimers[object.sourceIndex] = setTimeout("imgFade(imgFadeObjects["+object.sourceIndex+"],"+naarDoorzichtigheid+","+snelheid+","+aantalStappen+")",snelheid);
	}
}

// this is a dummy function. Every module can override this function for initialisation
function init() {
	null;
}



// Set up the image files to be used.
var theImages = new Array() // do not change this
var theTopImages = new Array() // do not change this
var theContentImages = new Array() // do not change this
var theContentThumbImages = new Array() // do not change this
// To add more image files, continue with the
// pattern below, adding to the array.

theTopImages[0] = 'images/site/kop01.jpg'
theTopImages[1] = 'images/site/kop02.jpg'
theTopImages[2] = 'images/site/kop03.jpg'
theTopImages[3] = 'images/site/kop04.jpg'
theTopImages[4] = 'images/site/kop05.jpg'
theTopImages[5] = 'images/site/kop06.jpg'
theTopImages[6] = 'images/site/kop07.jpg'
theTopImages[7] = 'images/site/kop08.jpg'
theTopImages[8] = 'images/site/kop09.jpg'
theTopImages[9] = 'images/site/kop10.jpg'

theImages[0] = '01'
theImages[1] = '02'
theImages[2] = '03'
theImages[3] = '04'
theImages[4] = '05'
theImages[5] = '06'
theImages[6] = '07'
theImages[7] = '08'
theImages[8] = '09'
theImages[9] = '10'


// do not edit anything below this line

var j = 0
var p = theTopImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theTopImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function getTopRow(){
	document.write('<tr align="right" valign="top" height="200"><td align="right" valign="top" width="800px" background="'+theTopImages[whichImage]+'"><div></div></td></tr>');
}
function getContentThumbImage(){
	document.write('<DIV id=contentThumb-'+theImages[whichImage]+'></DIV>');
}
function getContentImage(){
	document.write('<DIV id=contentSpacer></DIV>');
	document.write('<DIV id=extra></DIV>');
	document.write('<DIV id=contentImg-'+theImages[whichImage]+'></DIV>');


}

function checkLogin() {
  return (showAlert('login', "de gebruikersnaam") &&
					showAlert('password', "het wachtwoord"));
}

							


