function HandleKeyDown(obj, param) {
	if(window.event) {
	//	Get ASCII value of key that user pressed
		var key = window.event.keyCode;
   		var tabKeyCode = 9;

		if(param == 'tab' && key == tabKeyCode) {
			obj.selection = document.selection.createRange();
			obj.selection.text = String.fromCharCode(tabKeyCode);
		//  properly permit the key being entered
			window.event.returnValue = null;
		}
	} else {
	//	Get ASCII value of key that user pressed
		var key = e.which
   		var tabKeyCode = 9;

		if(param == 'tab' && key == tabKeyCode) {
			obj.selection = document.selection.createRange();
			obj.selection.text = String.fromCharCode(tabKeyCode);
		//  properly permit the key being entered
			e.preventDefault();
		}
	}
}



//  some functions to check correct user input in forms
function limitText(limitField, limitNum)
{
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	}
}

function CheckNumeric(e)
{
	if(window.event) // IE coding
	{
	//	Get ASCII value of key that user pressed
		var key = window.event.keyCode;

	//	Was key that was pressed an allowed character?
		if	( key == 44 )				return; // ,
		if	( key == 46 )   			return; // . AND del .... yeah right ...
		if	( key > 47 && key < 58 )	return; // numeric character (0-9)

	//  properly permit the key being entered
		window.event.returnValue = null;
	}
	else
	{
	//	Get ASCII value of key that user pressed
		var key = e.which

	//	Was key that was pressed an allowed character?
		if	( key == 0)					return; // function keys (F1 - F12, arrows, etc.)
		if  ( key == 8 )                return; // backspace
		if	( key == 44 )				return; // ,
		if	( key == 46 )   			return; // . AND del .... yeah right ...
		if	( key > 47 && key < 58 )	return; // numeric character (0-9)

	//  properly permit the key being entered
		e.preventDefault();
 	}
}

function CheckPhone(e)
{
	if(window.event) // IE coding
	{
	//	Get ASCII value of key that user pressed
		var key = window.event.keyCode;
	//	Was key that was pressed an allowed character?
		if	( key == 32 )				return; // space
		if	( key == 35 )				return; // #
		if	( key == 40 )				return; // ,
		if	( key == 41 )				return; // (
		if	( key == 42 )				return; // )
		if	( key == 43 )				return; // +
		//if	( key == 44 )				return; // ,
		if	( key == 45 )				return; // -
		//if	( key == 46 )   			return; // . AND del .... yeah right ...
		if	( key > 47 && key < 58 )	return; // numeric character (0-9)

	//  properly permit the key being entered
		window.event.returnValue = null;
	}
	else
	{
	//	Get ASCII value of key that user pressed
		var key = e.which

	//	Was key that was pressed an allowed character?
		if	( key == 0)					return; // function keys (F1 - F12, arrows, etc.)
		if  ( key == 8 )                return; // backspace
		if	( key == 32 )				return; // space
		if	( key == 35 )				return; // #
		if	( key == 40 )				return; // ,
		if	( key == 41 )				return; // (
		if	( key == 42 )				return; // )
		if	( key == 43 )				return; // +
		//if	( key == 44 )				return; // ,
		if	( key == 45 )				return; // -
		//if	( key == 46 )   			return; // . AND del .... yeah right ...
		if	( key > 47 && key < 58 )	return; // numeric character (0-9)

	//  properly permit the key being entered
		e.preventDefault();
 	}
}

function textbox_activate(id, value)
{
 	if(document.getElementById(id).value.toLowerCase() == value.toLowerCase())
	{
		document.getElementById(id).value='';
		document.getElementById(id).className = document.getElementById(id).className.replace('inactive','');
	}
}
function textbox_inactivate(id, value)
{
 	if(document.getElementById(id).value == '' || document.getElementById(id).value.toLowerCase() == value.toLowerCase())
	{
		document.getElementById(id).value=value;
		document.getElementById(id).className = document.getElementById(id).className + ' inactive';
	}
}

function mark_column( container_id , column_number , status )
{
	/**
	* marks all rows and selects its first checkbox inside the given element
	* the given element is usaly a table or a div containing the table or tables
	*
	* @param    container    DOM element
	*/
    var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;
    var radio;
    var selectbox;
	var inputs;
	var cnt;
	var x;
	var column_number;

    for ( var i = 0; i < rows.length; i++ )
	{
        inputs = rows[i].getElementsByTagName( 'input' );
	//  process the checkbox values
		element = inputs[column_number+1];

		if(element && element.type == 'checkbox')
		{
			if((status == 'on' || status === true) && element.disabled == false)		element.checked = true;
			if((status == 'off' || status === false) && element.disabled == false)	element.checked = false;
		}
	//  process the radio buttons
		if(element && element.type == 'radio')
		{
			checkbox = inputs[column_number+1];
			if((status == 'on' || status == true) && element.disabled == false)		element.checked = true;
		}
	//  process the select boxes
        inputs = rows[i].getElementsByTagName( 'select' );
		element = inputs[column_number+1];
		if(element && element.type == 'select' && element.enabled == true)
        {
            cnt = selectbox.options.length;
            for(x=0;x<cnt;x++)
            {
	            if(selectbox.options[x].value == status)
					selectbox.options[x].selected = true;
				else
					selectbox.options[x].selected = false;
			}
		}
	}
    return true;
}
document.getElementsByClassName = function(cl) {
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName('*');
	for (var i = 0; i < elem.length; i++)
	{
		var classes = elem[i].className;
		if (myclass.test(classes)) retnode.push(elem[i]);
	}
	return retnode;
};

function textbox_activate(ele, value)
{
 	if(ele.value.toLowerCase() == value.toLowerCase())
	{
		ele.value = '';
		ele.className = ele.className.replace('inactive','active');
	}
}

function textbox_inactivate(ele, value)
{
 	if(ele.value == '' || ele.value.toLowerCase() == value.toLowerCase())
	{
		ele.value=value;
		ele.className = ele.className.replace('active','inactive');
	}
}

function limitText(limitField, limitNum)
{
	if (limitField.value.length > limitNum)
	{
		limitField.value = limitField.value.substring(0, limitNum);
	}
}

function CheckNumeric(e)
{
	if(window.event) // IE coding
	{
	//	Get ASCII value of key that user pressed
		var key = window.event.keyCode;

	//	Was key that was pressed an allowed character?
		if	( key == 44 )				return; // ,
		if	( key == 46 )   			return; // . AND del .... yeah right ...
		if	( key > 47 && key < 58 )	return; // numeric character (0-9)

	//  properly permit the key being entered
		window.event.returnValue = null;
	}
	else
	{
	//	Get ASCII value of key that user pressed
		var key = e.which

	//	Was key that was pressed an allowed character?
		if	( key == 0)					return; // function keys (F1 - F12, arrows, etc.)
		if  ( key == 8 )                return; // backspace
		if	( key == 44 )				return; // ,
		if	( key == 46 )   			return; // . AND del .... yeah right ...
		if	( key > 47 && key < 58 )	return; // numeric character (0-9)

	//  properly permit the key being entered
		e.preventDefault();
 	}
}

function CheckPhone(e)
{
	if(window.event) // IE coding
	{
	//	Get ASCII value of key that user pressed
		var key = window.event.keyCode;
	//	Was key that was pressed an allowed character?
		if	( key == 32 )				return; // space
		if	( key == 35 )				return; // #
		if	( key == 40 )				return; // ,
		if	( key == 41 )				return; // (
		if	( key == 42 )				return; // )
		if	( key == 43 )				return; // +
		//if	( key == 44 )				return; // ,
		if	( key == 45 )				return; // -
		//if	( key == 46 )   			return; // . AND del .... yeah right ...
		if	( key > 47 && key < 58 )	return; // numeric character (0-9)

	//  properly permit the key being entered
		window.event.returnValue = null;
	}
	else
	{
	//	Get ASCII value of key that user pressed
		var key = e.which

	//	Was key that was pressed an allowed character?
		if	( key == 0)					return; // function keys (F1 - F12, arrows, etc.)
		if  ( key == 8 )                return; // backspace
		if	( key == 32 )				return; // space
		if	( key == 35 )				return; // #
		if	( key == 40 )				return; // ,
		if	( key == 41 )				return; // (
		if	( key == 42 )				return; // )
		if	( key == 43 )				return; // +
		//if	( key == 44 )				return; // ,
		if	( key == 45 )				return; // -
		//if	( key == 46 )   			return; // . AND del .... yeah right ...
		if	( key > 47 && key < 58 )	return; // numeric character (0-9)

	//  properly permit the key being entered
		e.preventDefault();
 	}
}

function toggleNext(el)
{
	var next=el.nextSibling;
	while(next.nodeType != 1) next = next.nextSibling;
	next.style.display = ((next.style.display == "none") ? "block" : "none");
}

function toggleNextByClassName(cname)
{
	var clickers = document.getElementsByClassName(cname);
 	for (i=0; i<clickers.length; i++)
	{
		clickers[i].onclick=function() {toggleNext(this)}
		toggleNext(clickers[i]);
	}
}

function toggleDisplay(id)
{
	if(document.getElementById(id).style.display == "block" )
	{
		document.getElementById(id).style.display = "none";
		document.getElementById(id).style.visibility = "hidden";
	}
	else
	{
		document.getElementById(id).style.display = "block";
		document.getElementById(id).style.visibility = "visible";
	}
}

var slideshow=new Class({
	initialize:function(a){
		this.items = a.items||a.box.getChildren();	//	source images
		this.mode = a.mode||'horizontal';	//	scroll mode
		this.modes = {horizontal:['left','width'],vertical:['top','height']}; //	scroll mode operators
		this.size = a.size||a.box.getStyle('width').toInt(); // vreemde fouten tussen FF2 en FF3 ... nog uitzoeken, voorlopig size expliciet definieren
		this.thumbsize = a.thumbsize||Math.ceil(this.size/5),	//	size of thumbnails
		this.numthumbs = Math.ceil(this.size / this.thumbsize),	//	number of visible thumbnails
		this.box = a.box.setStyle(this.modes[this.mode][1],(this.size*this.items.length)+'px');
		this.thumbbox = a.thumbbox||null,	//	thumbnail box handler
		this.button_event = a.button_event||'click';
		this.handle_event = a.handle_event||'click';
		this.onWalk = a.onWalk||null;
		this.currentIndex=a.startItem||0;
		this.previousIndex=null;
		this.nextIndex=null;
		this.interval=a.interval||5000;
		this.autoPlay=a.autoPlay||false;
		this.loopItems=a.loopItems||true;
		this._play=null;
		this.handles=a.handles||null;
	//	reconstruct the slideshow elements if items are given as an array
		if(a.items){
		//	clear the contents of the viewport and the thumbnails and create from scratch
			this.box.empty();
			this.thumbbox.empty();
			this.constructSlideshow();
		}
	//	add events to the thumbnails
		if(this.handles){
			this.addHandleButtons(this.handles);
		}
	//	add events to the buttons
		this.buttons={previous:[],next:[],play:[],playback:[],stop:[]};
		if(a.addButtons){
			for(var b in a.addButtons){
				this.addActionButtons(b,$type(a.addButtons[b])=='array'?a.addButtons[b]:[a.addButtons[b]])
			}
		}
	//	create the fx
		this.thumbfx=new Fx.Tween(this.thumbbox,$extend((a.fxOptions||{duration:500,wait:false}),{property:this.modes[this.mode][0]}));
		this.fx=new Fx.Tween(this.box,$extend((a.fxOptions||{duration:500,wait:false}),{property:this.modes[this.mode][0],onComplete:function(){this.constructSlideshow();}.bind(this)}));

	//	walk to the first element
		//this.walk((a.startItem||0),true,true);
	},constructSlideshow:function(a){
	//	construct containers in case they are not available
		if(!this.handles.length)
		{
			for(c=0;c<this.numthumbs;c++)
			{
			//	thumbnails need twice as many containers as visible thumbs
//				this.thumbbox.innerHTML += '<li><img src="'+this.items[(2*c)][1]+'"></li><li><img src="'+this.items[(2*c)+1][1]+'"></li>';
				this.thumbbox.innerHTML += '<li><img src=""></li><li><img src=""></li>';
			//	big images need the same number of containers as visible thumbs
//				this.box.innerHTML += '<li><img src="'+this.items[c][0]+'"></li>';
				this.box.innerHTML += '<li><img src=""></li>';
			}
		//	update the handles and targets arrays
			this.handles = this.thumbbox.getElements('li');
			this.targets = this.box.getElements('li');
		//	set the correct starting position of the list
			//this.box.setStyle(this.modes[this.mode][0],(-this.size*(Math.floor(this.numthumbs/2)-1)));
			this.box.setStyle(this.modes[this.mode][1],(this.size*this.numthumbs));
			this.thumbbox.setStyle(this.modes[this.mode][1],(this.thumbsize*this.numthumbs*2));
			//this.thumbbox.setStyle(this.modes[this.mode][0],(-this.thumbsize*(Math.floor(this.numthumbs/2)-1)));
			//return true;
		}
		
	//	check if the image containers need to be updated
		if(	this.loopItems ||
			(
				this.currentIndex < this.items.length-Math.floor(this.numthumbs/2) &&
				this.currentIndex > Math.floor(this.numthumbs/2)
			)
		)
		{
//alert(this.currentIndex);
		//	update the center image
			this.targets[Math.floor(this.numthumbs/2)-1].getElement('img').set('src',this.items[this.currentIndex][0]);
			this.handles[Math.floor(this.numthumbs/2)-1].getElement('img').set('src',this.items[this.currentIndex][1]);
		//	reposition the list
			this.box.setStyle(this.modes[this.mode][0],(-this.size*(Math.floor(this.numthumbs/2)-1)));
			this.thumbbox.setStyle(this.modes[this.mode][0],(-this.thumbsize*(Math.floor(this.numthumbs/2)-1)));
		//	update the series
			for(c=0;c<this.numthumbs;c++)
			{
			//	pfff reken reken reken ... houdt de snelheid er ook niet echt in :S
				var e = this.currentIndex - (Math.floor(this.numthumbs/2)-1) + c;
				var f = this.currentIndex - (this.numthumbs-2) + 2*c;
				var g = f+1;
				e = (e < 0)?this.items.length+e:((e>=this.items.length)?e-this.items.length:e);
				f = (f < 0)?this.items.length+f:((f>=this.items.length)?f-this.items.length:f);
				g = (g < 0)?this.items.length+g:((g>=this.items.length)?g-this.items.length:g);
				this.targets[c].getElement('img').set('src',this.items[e][0]);
				this.handles[2*c].getElement('img').set('src',this.items[f][1]);
				this.handles[2*c+1].getElement('img').set('src',this.items[g][1]);
			}
		}
	},addHandleButtons:function(a){
		for(var i=0;i<a.length;i++){
//			a[i].addEvent(this.handle_event,this.walk.bind(this,[i,true]))
			a[i].addEvent(this.handle_event,this.walk.bind(this,[(i-this.numthumbs+2),true]))
		}
	},addActionButtons:function(a,b){
		for(var i=0;i<b.length;i++){
			switch(a){
				case 'previous':b[i].addEvent(this.button_event,this.previous.bind(this,[true]));break;
				case 'next':b[i].addEvent(this.button_event,this.next.bind(this,[true]));break;
				case 'play':b[i].addEvent(this.button_event,this.play.bind(this,[this.interval,'next',false]));break;
				case 'playback':b[i].addEvent(this.button_event,this.play.bind(this,[this.interval,'previous',false]));break;
				case 'stop':b[i].addEvent(this.button_event,this.stop.bind(this));break;
			}
			this.buttons[a].push(b[i])
		}
	},previous:function(a){
		//this.walk((this.currentIndex>0?this.currentIndex-1:this.items.length-1),a)
		this.walk(-1,a);
	},next:function(a){
		//alert((this.currentIndex<this.items.length-1?this.currentIndex+1:0));
		//this.walk((this.currentIndex<this.items.length-1?this.currentIndex+1:0),a)
		this.walk(1,a);
	},play:function(a,b,c){
		this.stop();
		if(!c){
			this[b](false)
		}
		this._play=this[b].periodical(a,this,[false])
	},stop:function(){
		$clear(this._play)
	},walk:function(a,b,c){
//alert('a: '+a+' currentIndex: '+this.currentIndex);
	//	goto the new index
		if(a!=0){
		//	update the items indexes required by the buttons and the current position
			//steps = a-this.currentIndex;
			this.currentIndex= this.currentIndex+a;
			this.currentIndex = (this.currentIndex<0?this.items.length+this.currentIndex:(this.currentIndex>=this.items.length?this.currentIndex-this.items.length:this.currentIndex));
			this.previousIndex=this.currentIndex+(this.currentIndex>0?-1:this.items.length-1);
			this.nextIndex=this.currentIndex+(this.currentIndex<this.items.length-1?1:1-this.items.length);
		//	start the fx events
			if(b){
				this.stop();
			}
			if(c){
//				this.fx.cancel().set((this.size*-this.currentIndex)+'px');
				this.fx.cancel().set((this.box.getStyle(this.modes[this.mode][0]).toInt()-(this.size*steps))+'px');
			}else{
			//	convert the item index to the proper style distance
				this.thumbfx.start(this.thumbbox.getStyle(this.modes[this.mode][0]).toInt()-(this.thumbsize*a));
				this.fx.start(this.box.getStyle(this.modes[this.mode][0]).toInt()-(this.size*a));
			}
			if(b&&this.autoPlay){
				this.play(this.interval,'next',true)
			}
			if(this.onWalk){
				//this.onWalk((this.items[this.currentIndex]||null),(this.handles&&this.handles[this.currentIndex]?this.handles[this.currentIndex]:null))
				this.onWalk((this.items[a]||null),(this.handles&&this.handles[a]?this.handles[a]:null));
			}
		}
	}
});
/*
var slideshowOLD=new Class({
//	great slideshow, for source and updates see ... http://www.efectorelativo.net/laboratory/noobSlide/
	initialize:function(a){
		this.items = a.box.getChildren();
		this.mode = a.mode||'horizontal';
		this.modes = {horizontal:['margin-left','width'],vertical:['top','height']};
		this.size = a.size||a.box.getStyle('width').toInt();
		this.box = a.box.setStyle(this.modes[this.mode][1],(this.size*this.items.length)+'px');
		this.button_event = a.button_event||'click';
		this.handle_event = a.handle_event||'click';
		this.onWalk = a.onWalk||null;
		this.currentIndex=null;
		this.previousIndex=null;
		this.nextIndex=null;
		this.interval=a.interval||5000;
		this.autoPlay=a.autoPlay||false;
		this._play=null;
		this.handles=a.handles||null;
		if(this.handles){
			this.addHandleButtons(this.handles)
		}
		this.buttons={previous:[],next:[],play:[],playback:[],stop:[]};
		if(a.addButtons){
			for(var b in a.addButtons){
				this.addActionButtons(b,$type(a.addButtons[b])=='array'?a.addButtons[b]:[a.addButtons[b]])
			}
		}
		this.fx=new Fx.Tween(this.box,$extend((a.fxOptions||{duration:500,wait:false}),{property:this.modes[this.mode][0]}));
		this.walk((a.startItem||0),true,true)
	},addHandleButtons:function(a){
		for(var i=0;i<a.length;i++){
			a[i].addEvent(this.handle_event,this.walk.bind(this,[i,true]))
		}
	},addActionButtons:function(a,b){
		for(var i=0;i<b.length;i++){
			switch(a){
				case 'previous':
					b[i].addEvent(this.button_event,this.previous.bind(this,[true]));
				break;
				case 'next':
					b[i].addEvent(this.button_event,this.next.bind(this,[true]));
				break;
				case 'play':
					b[i].addEvent(this.button_event,this.play.bind(this,[this.interval,'next',false]));
				break;
				case 'playback':
					b[i].addEvent(this.button_event,this.play.bind(this,[this.interval,'previous',false]));
				break;
				case 'stop':
					b[i].addEvent(this.button_event,this.stop.bind(this));
				break
			}
			this.buttons[a].push(b[i])
		}
	},previous:function(a){
		this.walk((this.currentIndex>0?this.currentIndex-1:this.items.length-1),a)
	},next:function(a){
		this.walk((this.currentIndex<this.items.length-1?this.currentIndex+1:0),a)
	},play:function(a,b,c){
		this.stop();
		if(!c){
			this[b](false)
		}
		this._play=this[b].periodical(a,this,[false])
	},stop:function(){
		$clear(this._play)
	},walk:function(a,b,c){
		if(a!=this.currentIndex){
			this.currentIndex=a;
			this.previousIndex=this.currentIndex+(this.currentIndex>0?-1:this.items.length-1);
			this.nextIndex=this.currentIndex+(this.currentIndex<this.items.length-1?1:1-this.items.length);
			if(b){
				this.stop()
			}
			if(c){
				this.fx.cancel().set((this.size*-this.currentIndex)+'px')
			}else{
				this.fx.start(this.size*-this.currentIndex)
			}
			if(b&&this.autoPlay){
				this.play(this.interval,'next',true)
			}
			if(this.onWalk){
				this.onWalk((this.items[this.currentIndex]||null),(this.handles&&this.handles[this.currentIndex]?this.handles[this.currentIndex]:null))
			}
		}
	}
});
*/
var viewer = new Class({
	mode:'rand',
	modes:['top','right','bottom','left','alpha'],
	sizes:{w:480,h:240},
	fxOptions:{duration:500},
	interval:5000,
	initialize: function(a,b){
		if(b) for(var o in b) this[o]=b[o];
		if(this.buttons){
			this.buttons.previous.addEvent('click',this.previous.bind(this,[true]));
			this.buttons.next.addEvent('click',this.next.bind(this,[true]))
		}
		this._current=0;
		this._previous=null;
		this.items=a.setStyle('display','none');
		this.items[this._current].setStyle('display','block');
		this.disabled=false;
		this.attrs={
			left:['left',-this.sizes.w,0,'px'],
			top:['top',-this.sizes.h,0,'px'],
			right:['left',this.sizes.w,0,'px'],
			bottom:['top',this.sizes.h,0,'px'],
			alpha:['opacity',0,1,'']
		};
		this.rand=this.mode=='rand';
		this.sequence=typeof(this.mode)=='object'?this.mode:false;
		this.curseq=0;
		this.timer=null
	},
	walk: function(n,b){
	//alert(n);
		if(this._current!==n&&!this.disabled){
			this.disabled=true;
			if(b){this.stop()}
			if(this.rand){this.mode=this.modes.getRandom()}
			else if(this.sequence){
				this.mode=this.sequence[this.curseq];
				this.curseq+=this.curseq+1<this.sequence.length?1:-this.curseq
			}
			this._previous = this._current;
			this._current = n;
			var a = this.attrs[this.mode].associate(['p','f','t','u']);
			for(var i = 0; i < this.items.length; i++){
				if(this._current === i){
					this.items[i].setStyles($extend({'display':'block','z-index':'2'},JSON.decode('{"'+a.p+'":"'+a.f+a.u+'"}')));
//					this.items[i].setStyles($extend({},JSON.decode('{"'+a.p+'":"'+a.f+a.u+'"}')));
				}
				else if(this._previous === i){
					this.items[i].setStyles({'z-index':'1'})
				}
				else{
					this.items[i].setStyles({'display':'none','z-index':'0'})
//					this.items[i].setStyles({})
				}
			}
			this.items[n].set('tween',$merge(this.fxOptions,{onStart:this.onComplete.bind(this)})).tween(a.p,a.f,a.t)
		}
	},
	play: function(a){
		this.stop();
		if(!a){this.next()}
		this.timer=this.next.periodical(this.interval,this,[false])
	},
	stop: function(){
		$clear(this.timer)
	},
	next: function(a){
		this.walk(this._current+1<this.items.length?this._current+1:0,a)
	},
	previous: function(a){
		this.walk(this._current>0?this._current-1:this.items.length-1,a)
	},
	onComplete: function(){
		this.disabled=false;
		this.items[this._previous].setStyle('display','none');
		if(this.onWalk)this.onWalk(this._current)
	}
});



			
//window.addEvent('domready', function(){
function initializeViewer() {
//	load the viewer
	if($$('.viewer_mask').length > 0) {
		var v = new viewer($$('.viewer_mask'),{
			mode: 'alpha',
			fxOptions: {duration: 1000}
		});
		$$('.viewer_button').each(function(el,i) {
			el.addEvent('click', v.walk.bind(v,[i,true]));
		});
	}
}

/*
function initializeSlideshow() {	
//	load the slideshows
	$$('.slideshow').each(function(show, i) {
	//	set the start item
		var startItem = 0;
					
	//	add the thumbnails section if it doesn't already exist
		var thumbs = show.getElement('.slideshow_thumbs');
		if(!thumbs)
		{
			var thumbs = new Element('div', {'class': 'slideshow_thumbs'});
			var copy = show.getElement('div.slideshow_viewport ul').clone();
			copy.getElements('li').each(function(el) {
				el.grab(el.getElement('img'));
				//el.dispose('a');
			});
			copy.inject(thumbs);
			thumbs.inject(show, 'bottom');
		}
		var thumb_width = thumbs.getElements('img').getLast().getStyle('width').toInt();
		var view_width = show.getElements('div.slideshow_viewport img').getLast().getStyle('width').toInt();
		
	//	set the options that define the grafix
		var fxOptions = {property:'margin-left', duration:2000, transition:Fx.Transitions.Back.easeOut, wait:false}

	//	set the tween fx for the thumbs
		thumbs.getElement('ul').setStyle('margin-left','0px');
		var thumbsFx = new Fx.Tween(thumbs.getElement('ul'), fxOptions);
					
	//	initiate the slideshow class
		var slide = new slideshow({
			box: show.getElement('.slideshow_viewport ul'),
			handles: show.getElements('.slideshow_thumbs ul li'),
			fxOptions: fxOptions,
			onWalk: function(currentItem) {
//alert((view_width / thumb_width / 2).ceil());	
				if(this.currentIndex > (this.items.length - ((view_width / thumb_width / 2).ceil()+0))) {
					thumbsFx.start((this.items.length - (view_width / thumb_width)) * -thumb_width);
				} 
				else if(this.currentIndex < (view_width / thumb_width / 2).floor()) {
					thumbsFx.start(0);
				}
				else {
					thumbsFx.start((this.currentIndex - ((view_width / thumb_width / 2).ceil()-1)) * -thumb_width);
				}
				thumbs.getElements('img').set('opacity', 0.382);
				this.handles[this.currentIndex].getElement('img').set('opacity', 1);
			},
			startItem: startItem
		});
	//	walk to first with fx
		//alert(slide.items.length);
//		alert(Math.min(3,slide.items.length));
		slide.walk(Math.min(3,slide.items.length)-1);
	});
}
*/
function initializeAccordeon()
{
	toggleNextByClassName("toggle_comment");
	var date = new Date();
	var expire = date.setTime(date.getTime()+(24*60*60*1000));
	var position = Cookie.read("accordionpos");
	var accordion = new Accordion($('accordion'),
		'div.toggler', 
		'ol.element',
		{
			alwaysHide: true,
			opacity: false,
			show: (position - 1),
			onActive: function(toggler, element){
				Cookie.write("accordionpos", this.togglers.indexOf(toggler) + 1), {
					path:"/",
					duration: 0
				} 
			}
		}
	);
}
//	google analytics via mootools
	function initializeGoogleAnalytics(google)
	{
		var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
		new Asset.javascript(gaJsHost + "google-analytics.com/ga.js", {
			onload: function() {
				var pageTracker = _gat._getTracker(google); // your id here
				pageTracker._initData();
				pageTracker._trackPageview();
			}
		});
	}
//	google search
	function intializeGoogleSearch(myForm,myResult,myOptions)
	{
	//	Create a search control
		var searchControl = new google.search.SearchControl();
	//	Add in a WebSearch, with alternate root
		var google_options = new google.search.SearcherOptions();
		google_options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
		google_options.setRoot(document.getElementById(myResult));
		var websearch = new google.search.WebSearch()
		websearch.setSiteRestriction(myOptions.SiteRestriction);
		searchControl.addSearcher(websearch, google_options);

	//	tell the searcher to draw itself
		searchControl.draw(document.getElementById(myForm));
	}
//	progress bar for file uploads
	function initialize_progress_bar(progress_key)
	{
		$$('form').each(function(el,i){
			if(el.hasChild('APC_UPLOAD_PROGRESS')) {
				el.addEvent('submit', function() {
				//	create a progress bar if it doesn`t already exist
					if(!$('progress_bar'))
					{
					//	create new elements
						var p = document.getElementById('page');
						var d = document.createElement('div');
						var pc = document.createElement('div');
						//var pb = document.createElement('div');
						//var pt = document.createElement('div');
					//	insert the new elements into the DOM
						document.body.appendChild(d);
						d.appendChild(pc);
						
						var im = document.createElement('img');
						pc.appendChild(im);
						im.setAttribute('src','css/img/upload.gif');
						//pc.appendChild(pb);
						//pc.appendChild(pt);
					//	define some attributes
						d.setAttribute('id', 'dimmer');
						pc.setAttribute('id', 'progress_container');
						//pb.setAttribute('id', 'progress_bar');
						//pt.setAttribute('id', 'progress_text');
						//pb.set('text',' ');
					}
					/*
				//	create the request instance
					var r = new Request.JSON({
						method: 'get',
						url: '/upload_status.php?progress_key='+progress_key,
						onSuccess: function(status,responseText){
							if(status.percent == 100) {
								$clear(periodical);
								$('progress_text').innerHTML = 'verwerken en analyseren ...';
							}
							else
							{
								$('progress_text').innerHTML = status.current+' - '+status.total+' @ '+status.rate;
							}
							$('progress_bar').tween('width', Math.round(status.percent)*($('progress_container').getStyle('width').toInt()/100)+'px');
						}
					});
					perform = function () {r.send();}
					periodical = perform.periodical(250);
					*/
				});
			}
		});
	}


