/**                  
 * functions.js
 *
 * This file profites an general function set! 
 * The functions below are very handy for handling
 * common javascript functionality or Dynamic (X)HTML.
 *
 * @version 	1.0
 * @author	A.J. de Vries	
 * @package	javascript 
 * 
 * Copyright (c) 2005 Malibomba                               
 * IT IS NOT ALLOWED TO USE OR MODIFY ANYTHING OF THIS SITE,  
 * WITHOUT THE PERMISION OF THE AUTHOR.                       
 * Info? Mail to info@malibomba.com                           
 */
//<![CDATA[ 
var xmlhttp = null;
/*@cc_on @*/
/*@if(@_jscript_version >= 5)
	try {
		xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
	} catch(e) {
		try {
			xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
		} catch(e) {
			xmlhttp = false;
		}
	}
@else
	var xmlhttp = false;
@end @*/
if(!xmlhttp && document.createElement) {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch(e) {
		xmlhttp = false;
	}
}


/**
 * Array.prototype.addItem = function(item)
 *
 * Add an item to an excisting Array.
 *
 * @version 1.0
 * @access  public
 * @author  A.J. de Vries
 * @param   [mixed]   item: the new item to add.
 * @return  [integer] the new length of the array.
 */
Array.prototype.addItem = function(item) {
	this[this.length] = item;
	return this.length;
};



/**
 * Array.prototype.indexOf = function(value)
 *
 * Get the index (key) that identifier the given value
 * in an Array.
 *
 * @version 1.0
 * @access  public
 * @author  A.J. de Vries
 * @param   [mixed] value: the value of the array.
 * @return  [mixed] the index that identifier the given value.
 */
Array.prototype.indexOf = function(value) { 
	for(var i = 0; i < this.length; i++) {
		if(this[i] == value) { 
			return i;
		}
	} return-1;
};



/**
 * String.prototype.startsWith = function(value)
 *
 * Check if the current string starts with the given value.
 *
 * @version 1.0
 * @access  public
 * @author  A.J. de Vries
 * @param   [mixed]   value: the value to check for.
 * @return  [boolean] true if the string starts with the given value, false otherwise.
 */
String.prototype.startsWith = function(value) { 
	return (this.substr(0, value.length) == value);
};



/**
 * String.prototype.endsWith = function(value, ignoreCase)
 *
 * Check if the current string end with the given value.
 * It's possible to specfify if the check should be case-sensative
 * or not.
 *
 * @version 1.0
 * @access  public
 * @author  A.J. de Vries
 * @param   [mixed]   value: the value to check for.
 * @param   [boolean] ignoreCare: to specify if the checl should be case-sensative.
 * @return  [boolean] true if the string end with the given value, false otherwise.
 */
String.prototype.endsWith = function(value, ignoreCase) {
	if(value.length > this.length) {
		return false;
	} else {
		if(ignoreCase) {
			var oRegex = new RegExp(value + '$', 'i');
			return oRegex.test(this);
		} else {
			return (value.length == 0 || this.substr(this.length - value.length, value.length) == value);
		}
	}
};



/**
 * String.prototype.remove = function(start, length)
 *
 * Remove a piece from the current string.
 *
 * @version 1.0
 * @access  public
 * @author  A.J. de Vries
 * @param   [integer] start: the starting position.
 * @param   [integer] length: the lenght of the piece to remove.
 * @return  [string]  the new string.
 */
String.prototype.remove = function(start, length) {
	var str = (start > 0) ? this.substring(0, start) : '';
	if(start + length < this.length) {
		str += this.substring(start + length, this.length);
	} 
	return str;
};



/**
 * String.prototype.trim = function()
 *
 * Remove white space from the beginning and end of a string.
 *
 * @version 1.0
 * @access  public
 * @author  A.J. de Vries
 * @return  [string] the trimmed string.
 */
String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)/g, '');
};



/**
 * String.prototype.ltrim = function()
 *
 * Remove white space from the beginning of a string.
 *
 * @version 1.0
 * @access  public
 * @author  A.J. de Vries
 * @return  [string] the trimmed string.
 */
String.prototype.ltrim = function() {
	return this.replace(/^\s*/g, '');
};



/**
 * String.prototype.rtrim = function()
 *
 * Remove white space from the end of a string.
 *
 * @version 1.0
 * @access  public
 * @author  A.J. de Vries
 * @return  [string] the trimmed string.
 */
String.prototype.rtrim = function() {
	return this.replace(/\s*$/g, '');
};



/**
 * String.prototype.replaceNewLineChars = function(replacement)
 *
 * Replace new line breaks with the given replacement
 *
 * @version 1.0
 * @access  public
 * @author  A.J. de Vries
 * @param   [mixed]  replacement: the replacement of the new line break.
 * @return  [string] the new (replaced) string.
 */
String.prototype.replaceNewLineChars = function(replacement) {
	return this.replace(/\n/g, replacement);
};



/**
 * getElement(elem)
 *
 * Get the element with the given name (elem)
 * and return a reference (object) to it.
 *
 * @version 1.0
 * @access  public
 * @author  A.J. de Vries
 * @param   [string] elem: the name of the element
 * @return  [object] the object that references the element with the given name.
 */
function getElement(elem) {
	if(document.getElementById)
		return document.getElementById(elem);
	if(document.all)
		return document.all[elem];
}



/**
 * addEvent(elem, evt, func)
 *
 * Add an event to the given element (elem)
 *
 * @version 1.0
 * @access  public
 * @author  A.J. de Vries
 * @param   [object]   elem: the element(object) on which the event is set to.
 * @param   [string]   evt:  the name of the event, e.g: 'load', 'focus', 'unload', etc.
 * @param   [function] func: the function to execute.
 * @return  [void]
 */
function addEvent(elem, evt, func) {
	if(elem.addEventListener)
		elem.addEventListener(evt, func, false);
	else if(elem.attachEvent)
		elem.attachEvent('on'+evt, func);
}



/**
 * removeEvent(elem, evt, func)
 *
 * Remove an event from the given element (elem)
 *
 * @version 1.0
 * @access  public
 * @author  A.J. de Vries
 * @param   [object]   elem: the element(object) on which the event is set to.
 * @param   [string]   evt:  the name of the event, e.g: 'load', 'focus', 'unload', etc.
 * @param   [function] func: the function to execute.
 * @return  [void]
 */
function removeEvent(elem, evt, func) {
	if(elem.addEventListener)
		elem.removeEventListener(evt, func, true);
	else if(elem.attachEvent)
		elem.detachEvent("on" + evt, func);
};



/**
 * random image
 *
 */
 
var theImages = new Array() // do not change this

theImages[0] = '/pics/professionaliseren01.jpg'
theImages[1] = '/pics/professionaliseren02.jpg'
theImages[2] = '/pics/professionaliseren03.jpg'
theImages[3] = '/pics/professionaliseren04.jpg'
theImages[4] = '/pics/professionaliseren05.jpg'

// ======================================
// do not change anything below this line
// ======================================

var j = 0
var p = theImages.length;

var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}

var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'">');
}




/**
 * upload document bij het formulier
 *
 */

window.onload = function() {
	var loc = document.location.href;
	var querystr = loc.match(/erno=1/);
	if(querystr == 'erno=1') {
		alert('Uw bestand is te groot om verstuurd te worden!\nDe maximale bestandsgrootte is 2 MB.');
	}
}

function checkFile(elem) {
	if(elem.value != '') {
		var bCheck = elem.value.match(/\.doc|.csv|.xls|.pdf|.jpg|.jpeg|.gif|.bmp$/i);
		if(bCheck == null) {
			alert('Uw bestand komt niet overeen met de toegenstane extenties, probeer opnieuw!');
			elem.value = '';
			elem.focus();
		}
	}
}



   	/***********************************************************************************************
	
	Copyright (c) 2005 - Alf Magne Kalleland post@dhtmlgoodies.com
	
	Get this and other scripts at www.dhtmlgoodies.com
	
	You can use this script freely as long as this copyright message is kept intact.
	
	***********************************************************************************************/ 	
	var activeImage = false;
	var imageGalleryLeftPos = false;
	var imageGalleryWidth = false;
	var imageGalleryObj = false;
	var maxGalleryXPos = false;
	var slideSpeed = 0;
	function startSlide(e)
	{
		if(document.all)e = event;
		var id = this.id;
		this.getElementsByTagName('IMG')[0].src = 'pics/' + this.id + '_over.gif';	
		if(this.id=='arrow_right'){
			slideSpeedMultiply = Math.floor((e.clientX - this.offsetLeft) / 5);
			slideSpeed = -1*slideSpeedMultiply;
			slideSpeed = Math.max(-10,slideSpeed);
		}else{			
			slideSpeedMultiply = 10 - Math.floor((e.clientX - this.offsetLeft) / 5);
			slideSpeed = 1*slideSpeedMultiply;
			slideSpeed = Math.min(10,slideSpeed);
			if(slideSpeed<0)slideSpeed=10;
		}
	}
	
	function releaseSlide()
	{
		var id = this.id;
		this.getElementsByTagName('IMG')[0].src = 'pics/' + this.id + '.gif';
		slideSpeed=0;
	}
		
	function gallerySlide()
	{
		if(slideSpeed!=0){
			var leftPos = imageGalleryObj.offsetLeft;
			leftPos = leftPos/1 + slideSpeed;
			if(leftPos>maxGalleryXPos){
				leftPos = maxGalleryXPos;
				slideSpeed = 0;
				
			}
			if(leftPos<minGalleryXPos){
				leftPos = minGalleryXPos;
				slideSpeed=0;
			}
			
			imageGalleryObj.style.left = leftPos + 'px';
		}
		setTimeout('gallerySlide()',20);
		
	}
	
	function showImage()
	{
		if(activeImage){
			activeImage.style.filter = 'alpha(opacity=50)';	
			activeImage.style.opacity = 0.5;
		}	
		this.style.filter = 'alpha(opacity=100)';
		this.style.opacity = 1;	
		activeImage = this;	
	}
	
	function initSlideShow()
	{
		document.getElementById('arrow_left').onmousemove = startSlide;
		document.getElementById('arrow_left').onmouseout = releaseSlide;
		document.getElementById('arrow_right').onmousemove = startSlide;
		document.getElementById('arrow_right').onmouseout = releaseSlide;
		
		imageGalleryObj = document.getElementById('theImages');
		imageGalleryLeftPos = imageGalleryObj.offsetLeft;
		imageGalleryWidth = document.getElementById('galleryContainer').offsetWidth - 80;
		maxGalleryXPos = imageGalleryObj.offsetLeft; 
		minGalleryXPos = imageGalleryWidth - document.getElementById('slideEnd').offsetLeft;
		var slideshowImages = imageGalleryObj.getElementsByTagName('IMG');
		for(var no=0;no<slideshowImages.length;no++){
			slideshowImages[no].onmouseover = showImage;
		}
		gallerySlide();
	}
	
	function showPreview(imagePath){
		var subImages = document.getElementById('previewPane').getElementsByTagName('IMG');
		if(subImages.length==0){
			var img = document.createElement('IMG');
			document.getElementById('previewPane').appendChild(img);
		}else img = subImages[0];
		img.src = imagePath;
	}
	
	
//]]>