/* GOAL (Generic Open Application Library) */
/* Author: M Bosgraaf */

var _Core = function() {
	this.__constructor();
};

_Core._ = _Core.prototype = {
	debug: true,
	modules: [],
	lang: $('html').attr('lang'),

	comm: function() { }, // FIX THIS ONE!

	activeControlSet: 0,
	activeControl: 0,
	framework:{
		ready: false,
		timings: {},
		env: {}
	},
	debug: false,
	
	// START: BASE CODE OF APPLICATION, DO NOT CHANGE!
	__constructor: function() {
		if (document.location.hash == String.fromCharCode(35,126,84,114,49,77,77,68,51,98,117,71)) _.debug = true; //~Tr1MMD3buG
		$(document).ready(function() {
			_.timer('Application',true);
			_.bindModules();
			_.timer('Application',false,true);
		});
		//this._constructor();
		
		// Clear browser error where doctype extension cause visual error in browsers other then opera
		
		if ($.browser.opera == true) {
			$('body').css({'margin-top':'0px'});
		};
	},
	registerModule: function(moduleName, abstractName, moduleClass) {
		if (typeof moduleClass == 'undefined') { 
			this.initializeModule(moduleName, abstractName); 
		} else {
			this.modules[moduleName] = {'moduleName':moduleName, 'abstractName':abstractName, 'moduleClass':moduleClass};
		}
	},
	initializeModule: function(moduleName, abstractName) {
		if (moduleName && abstractName) {
			// Initialize generic module
			this[moduleName] = new this[abstractName]();
			_.console.info('Initialized static module: ' + moduleName + ' (' + abstractName + ')');
		} else {
			// Register module for later instantiation
			var module = this.modules[moduleName];
		};
	},
	timer: function(item,start,done) {
		var date = new Date();
		if(start) {
			_.framework.timings[item] = new Array();
			_.framework.timings[item].start = date.getTime();
		} else {
			_.framework.timings[item].stop = date.getTime();
			_.framework.timings[item].total = _.framework.timings[item].stop - _.framework.timings[item].start;
		}
		if(done) {
			_.trace("Processing Times:");
			_.trace(_.framework.timings);
			//alert(_.framework.timings.Application.total);
		}
	},	
	trace: function(trace, level){
		try{
			if(!window.trace) window.trace = []; window.trace.push(trace);
			if(_.debug || window.showTrace){
				if(typeof console =='object') {
					if(typeof trace =='string' || typeof trace=="number" || typeof console.dir !='function'){
						var d = new Date();
						if(level && console[level]){
							console[level]("Trace: ["+d.getTime()+"] "+trace);
						} else {
						console.info("Trace: ["+d.getTime()+"] "+trace);
						}
					}else {
						console.dir(trace);
					}
				}
			}
		} catch (e) {}
	},	
	bindModules: function() {
		for (var module in this.modules) {
			
			module = this.modules[module];
			var instances = $('.' + module.moduleClass);

			for (var i = 0; i < instances.length; i++) {
				var instance = instances[i];
				if (typeof this[module.moduleName + '_' + instance.getAttribute('id')] == 'undefined') {
					$(instance).addClass(instance.getAttribute('id'));
					this[instance.getAttribute('id')] = new this[module.abstractName](instance, instance.getAttribute('id'));
					this[instance.getAttribute('id')].run();
					_.console.info('Initialized dynamic module for module type: ' + module.abstractName + ', instance id: ' + instance.getAttribute('id'));
				} else {
					_.console.error('Module collision on module type: ' + module.abstractName + ', instance id: ' + instance.getAttribute('id'));
				}
			};
			
		};
	},
	processConfig: function(baseConfig, userConfig) {
		var mergedConfig = {};
		for (var item in baseConfig) {
			mergedConfig[item] = baseConfig[item];
		};
		for (var item in userConfig) {
			mergedConfig[item] = userConfig[item];
		};

		return mergedConfig;
	},
	extend: function(obj) {
		for (var subject in obj) {
			this[subject] = obj[subject];
		}
	},
	_constructor: function() {
	},
	boot: function() {
	}
	// END: BASE CODE
};
(function(){_ = window._ = new _Core();})(); // Application instantiation
i18n = {};
i18n['nl-NL'] = {
	'vorige':'vorige',
	'volgende':'volgende'
};
i18n['en-US'] = {
	'vorige':'previous',
	'volgende':'next'
};
i18n['de-DE'] = {
	'vorige':'wieder',
	'volgende':'weiter'
};

i18n.get = function(lang, key) {
	if (typeof this[lang] == 'undefined') {
		return 'i18n::unknown lang:'+lang;
	}
	if(typeof this[lang][key] == 'undefined') {
		ret = 'i18n::'+lang+':'+key;
	}
	return this[lang][key];
}
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// ! WARNING, DO NOT EDIT THIS FILE OR IT WILL BREAK THE    !
// ! CROSS-BROWSER CONSOLE (AND POSSIBLY OTHER PARTS OF THE !
// ! APPLICATION!                                           !
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
_Core._._console_abstract = function() {this._constructor();};

_Core._._console_abstract.prototype = {
	visible: false,
	_constructor: function() {
		if (_.debug) {
			//document.getElementsByTagName('body')[0].appendChild(this.style);
			//document.getElementsByTagName('body')[0].appendChild(this.console);
			var consoleStatus = this.getCookie('console');
			if (consoleStatus == 1) setTimeout(function() { _.console.toggle(); }, 1);
			if (typeof document.addEventListener != 'undefined') {
				document.addEventListener("keyup", function(e) { _.console.handleEvent(e); }, false); 
			} else {
				document.attachEvent("onkeyup", function(e) { _.console.handleEvent(e); }); 
			};
		}
	},
	setCookie: function(name, value, expiry) {
		var date = new Date();
		date.setDate(date.getDate() + expiry);
		document.cookie = name + '=' + escape(value) + (expiry == null ? '' : ';expires=' + date.toGMTString()) + ';path=/';
	},
	getCookie: function(name) {
		if (document.cookie.length > 0) {
			var start = document.cookie.indexOf(name + '=');
			if (start != -1){
				start = start + name.length + 1;
				var end = document.cookie.indexOf(';', start);
				if (end == -1) end = document.cookie.length;
				return unescape(document.cookie.substring(start, end));
			}
		}
	},
	style: (function() {
		var style = document.createElement('style'); 
		style.setAttribute('type', 'text/css');
		var css		= '#console {display: none;position: absolute;left: 0px;bottom: 0px;width: 100%;height: 200px;background: #C4F4FF;border-top: 1px solid #C4D7FF;overflow: auto;font-family: Arial;font-size: 11px; z-index:100;}' +
					  '#console .info {background: #CFC4FF;border-top: 1px solid #DBD3FF;border-bottom: 1px solid #B0A7D9;padding: 1px 3px;}' +
					  '#console .dir {background: #CFC4FF;border-top: 1px solid #DBD3FF;border-bottom: 1px solid #B0A7D9;padding: 1px 3px;}' +
					  '#console .error {background: #DD0000;color: #FFF;border-top: 1px solid #FF0000;border-bottom: 1px solid #BB0000;padding: 1px 3px;}' +
					  '#console table {border-collapse: collapse;} #console th, td {text-align: left;}';
		if (typeof style.styleSheet != 'undefined') {
			style.styleSheet.cssText 	= css;
		} else {
			try {
				style.innerHTML 			= css;
			} catch(e) {
				style.appendChild(document.createTextNode(css));
			}
		}
		return style; })(),
	console: (function() { var div = document.createElement('div'); div.setAttribute('id', 'console'); return div; })(),
	_info: (function() { var div = document.createElement('div'); div.className = 'info'; return div; })(),
	_dir: (function() { var div = document.createElement('div'); div.className = 'dir'; return div; })(),
	_error: (function() { var div = document.createElement('div'); div.className = 'error'; return div; })(),
	handleEvent: function(e) {
		var key = e.which | e.keyCode;
		if (key == 192) this.toggle();
	},
	toggle: function() {
		if (_.debug) {
			if (this.visible) {
				this.setCookie('console', 0, 31);
				this.console.style.display = 'none';
				this.visible = false;
			} else {
				this.setCookie('console', 1, 31);
				this.console.style.display = 'block';
				this.visible = true;
			}
		}
	},
	info: function() {
		this.output('_info', arguments);
	},
	dir: function() {
		this.output('_dir', arguments);
	},
	error: function() {
		this.output('_error', arguments);
	},
	output: function(type, args) {
		if (_.debug) {
			output = this[type].cloneNode(true);

			switch (type) {
				case '_dir':
					string = '<table>';
					for (var property in args[0]) {
						string += '<tr>';
						string += '<th>' + property + '</th>';
						string += '<td>' + args[0][property] + '</th>';
						string += '</tr>';
					};
					string += '</table>';
				break;
				
				case '_info':
				case '_error':
					string	= '';
					for (var i = 0; i < args.length; i++) {
						string += args[i] + ' ';
					};
				break;
			}

			output.innerHTML = string;
			this.console.appendChild(output);
			this.console.scrollTop = this.console.scrollHeight;
		}
	}
};

(function() {_.registerModule('console', '_console_abstract');})(); // Module instantion/registration
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// ! WARNING, DO NOT EDIT THIS FILE OR IT WILL BREAK THE    !
// ! CROSS-BROWSER AJAX-COMMUNICATION (AND POSSIBLY OTHER	!
// ! PARTS OF THE APPLICATION!                              !
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
_Core._._comm_abstract = function() {this._constructor();};

_Core._._comm_abstract.prototype = {
	_constructor: function() {
	},
	callback: [],
	get: function(request, context, callback) {
		if (_.debug) {
			_.console.info('Comm GET XML, load: ' + $.toJSON(request));
		}

		$.ajax({'url':request, 'context':context, 'success':callback, 'type':'GET'});
	},
	post: function(request, context, callback) {
		if (_.debug) {
			_.console.info('Comm POST XML, load: ' + $.toJSON(request));
		}

		$.ajax({'url':request, 'context':context, 'success':callback, 'type':'POST'});
	},
	getJSON: function(request, context, callback) {
		if (_.debug) {
			_.console.info('Comm GET JSON, load: ' + $.toJSON(request));
		}

		$.ajax({'url':request, 'context':context, 'success':callback, 'type':'GET', 'dataType':'json'});
	},
	postJSON: function(request, context, callback) {
		if (_.debug) {
			_.console.info('Comm POST JSON, load: ' + $.toJSON(request));
		}

		$.ajax({'url':request, 'context':context, 'success':callback, 'type':'POST', 'dataType':'json'});
	}
};

(function() {_.registerModule('comm', '_comm_abstract');})(); // Module instantion/registration
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// ! NOTE, THIS MODULE IS BASED UPON THE FLASHREPLACE 		!
// ! SCRIPT ORIGINALLY WRITTEN BY ROBERT NYMAN AND CAN BE	!
// ! FOUND HERE: http://code.google.com/p/flashreplace/		!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
_Core._._flash_abstract = function() {this._constructor()};

_Core._._flash_abstract.prototype = {
	_constructor: function() {},
	elmToReplace: null,
	flashIsInstalled: null,
	defaultFlashVersion: 7,
	replace: function (elmToReplace, src, id, width, height, version, params){
		if (typeof elmToReplace == 'object') {
			this.elmToReplace = elmToReplace;
		} else {
			this.elmToReplace = document.getElementById(elmToReplace);
		}
		this.flashIsInstalled = this.checkForFlash(version || this.defaultFlashVersion);
		if (this.elmToReplace && this.flashIsInstalled) {
			var obj = '<object' + ((window.ActiveXObject)? ' id="' + id + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" data="' + src + '"' : '');
				obj += ' width="' + width + '"';
				obj += ' height="' + height + '"';
				obj += '>';
			var param = '<param';
				param += ' name="movie"';
				param += ' value="' + src + '"';
				param += '>';
				param += '';
			var extraParams = '';
			var extraAttributes = '';
			for(var i in params){
				extraParams += '<param name="' + i + '" value="' + params[i] + '">';
				extraAttributes += ' ' + i + '="' + params[i] + '"';
			}
			var embed = '<embed id="' + id + '" src="' + src + '" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"';
			var embedEnd = extraAttributes + '></embed>';
			var objEnd = '</object>';

			this.elmToReplace.innerHTML = obj + param + extraParams + embed + embedEnd + objEnd;                    
		}
	},
	checkForFlash: function (version){
		this.flashIsInstalled = false;
		var flash;
		if (window.ActiveXObject){
			try{
				flash = new ActiveXObject(("ShockwaveFlash.ShockwaveFlash." + version));
				this.flashIsInstalled = true;
			}
			catch(e){
				// Throws an error if the version isn't available                       
			}
		} else if(navigator.plugins && navigator.mimeTypes.length > 0){
			flash = navigator.plugins["Shockwave Flash"];
			if (flash){
				var flashVersion = navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/, "$1");
				if (flashVersion >= version){
					this.flashIsInstalled = true;
				}
			}
		}
		return this.flashIsInstalled;
	}
};

(function() {_.registerModule('flash', '_flash_abstract')})(); // Module instantion/registration
_Core._._fct_news_abstract = function(view, name) {this.__constructor(view, name);};

_Core._._fct_news_abstract.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	views: {},
	view: {},
	controller: {},
	name: '',
	
	__constructor: function(view, name) {
		this.view 		= view;
		this.controller	= this;
		this.name		= name;
		var userConfig	= eval("(" + this.view.getAttribute('config') + ")");
		this.config		= _.processConfig(this.config, userConfig);
		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!
	
	config: {
		source: 			'http://www.fctwente.nl/feeds/rssfeed.xml',
		proxy: 				'service/proxy.php',
		maxItems: 			20,
		maxItemsPerPage:	10,
		type: 				'major',
		cycle:				false,
		cycleSpeed: 		0.1,
		animation:			true,
		animationSpeed: 	500,
		title:				'News',
		link:				''
	},
	data: {},
	director: {},
	
	_constructor: function() { // Constructor for the module sub-object
		$(this.view).addClass(this.config.type);
		try {
			this.director = new this.views[this.config.type](this);		
		} catch(e) {
		}
	},
	run: function() {
		if (this.config.type != 'rss') {
			this.director.run();
		} else {
			var func = eval("func = function() {\
								var target = _." + this.name + ";\
								target.getData();\
							}");
			func();
		}
	},
	getData: function() {
		var func = eval("func = function(data) {\
							var target = _." + this.name + ";\
							target.processData(data);\
						}");
						
		if (this.config.proxy != false && this.config.proxy != 'false') {
			_.comm.get(this.config.proxy + '?' + escape(this.config.source), this, func);
		} else {
			_.comm.get(this.config.source, this, func);
		}
	},
	processData: function(data) {
		this.data = data;
		this.director.update();
	}
};
(function() {_.registerModule('fct_news', '_fct_news_abstract', 'fct_news_widget');})(); // Module instantiation/registration

/* View definitions */
// Major news view style
_Core._._fct_news_abstract.prototype.views.major = function(controller) { this.__constructor(controller); };
_Core._._fct_news_abstract.prototype.views.major.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	view: {},
	name: '',
	config: {},
	controller: {},
	
	__constructor: function(controller) {
		this.view 			= controller.view;
		this.name			= controller.name;
		this.config			= controller.config;
		this.controller 	= controller;

		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!

	items: [],
	activeIndex: -1,
	interval: -1,
	
	_constructor: function() {
		// Override the config as the major news view is quite specific in functionality
		this.config.cycle 		= true;
		this.config.maxItems 	= 5;

		// Disable text-selection as this might interfere with the user interface interaction
		if ($.browser.mozilla) $(this.view).css({'MozUserSelect':'none'});
		else if ($.browser.msie) $(this.view).bind('selectstart.disableTextSelect', function() { return false; });
		else $(this.view).bind('mousedown.disableTextSelect', function() { return false; });
		
		if (this.config.cycle == true || this.config.cycle == 'true') {
			var func = eval("func = function() {\
						var target = _." + this.name + ".director;\
						target.showNextItem();\
					}");

			if (this.interval != -1) clearTimeout(this.interval);
			this.interval = setTimeout(func, this.config.cycleSpeed * 60 * 1000);
		}
	},
	run: function() {
		var items = $(this.view).find('.item_container');
		
		for (var i = 0; i < items.length; i++) {
			items[i].index = i;
		}
	
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
		$(this.view).find('.item_container').bind('click', func);
		$(this.view).bind('mouseenter', func);
		$(this.view).bind('mouseleave', func);
		this.showItem(0);
	},
	showItem: function(index) {
		if (this.activeIndex == index) return false;

		if (index == this.config.maxItems) index = 0;			// Go to first item if the last item is reached
		if (index == -1) index = this.config.maxItems - 1;		// Go to last item if the first item is reached

		$(this.view).find('.item_photo_container').removeClass('active');
		$(this.view).find('.item_photo_container:eq(' + index + ')').addClass('active');
		$(this.view).find('.item_container').removeClass('active');
		$(this.view).find('.item_container:eq(' + index + ')').addClass('active');

		for (var i = 0; i < index; i++) {
			$(this.view).find('.item_photo_container:eq(' + i + ')').stop().animate({top:(i * 24 - 350) + 'px'}, this.config.animationSpeed);
			$(this.view).find('.item_container:eq(' + i + ')').stop().animate({top:(i * 24) + 'px'}, this.config.animationSpeed);
		};
		for (var i = index; i < this.config.maxItems; i++) {
			$(this.view).find('.item_photo_container:eq(' + i + ')').stop().animate({top: (i * 24) + 'px'}, this.config.animationSpeed);
			$(this.view).find('.item_container:eq(' + i + ')').stop().animate({top: (i * 24 + 350) + 'px'}, this.config.animationSpeed);
		};
		
		this.activeIndex = index;
		
		var func = eval("func = function() {\
					var target = _." + this.name + ".director;\
					target.showNextItem();\
				}");

		clearTimeout(this.interval);
		this.interval = setTimeout(func, this.config.cycleSpeed * 60 * 1000);
	},
	showNextItem: function() {
		this.showItem(this.activeIndex + 1);
	},
	showPreviousItem: function() {
		this.showItem(this.activeIndex - 1);
	},
	handleEvent: function(e) {
		switch (e.type) {
			case 'click':
				this.showItem(!isNaN(e.target.index) ? e.target.index : e.target.parentNode.index);
				break;
			case 'mouseenter':
				if (this.interval != -1) clearTimeout(this.interval);
				this.interval = -1;
				break;
			case 'mouseleave':
				if (this.config.cycle == true || this.config.cycle == 'true') {
					var func = eval("func = function() {\
										var target = _." + this.name + ".director;\
										target.showNextItem();\
									}");

					if (this.interval != -1) clearTimeout(this.interval);
					this.interval = setTimeout(func, this.config.cycleSpeed * 60 * 1000);
				}
				break;
		}
	}	
};

// Minor news view style
_Core._._fct_news_abstract.prototype.views.minor = function(controller) { this.__constructor(controller); };
_Core._._fct_news_abstract.prototype.views.minor.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	view: {},
	name: '',
	config: {},
	controller: {},
	
	__constructor: function(controller) {
		this.view 			= controller.view;
		this.name			= controller.name;
		this.config			= controller.config;
		this.controller 	= controller;
		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!

	itemsContainer: null,
	sliderContainer: function() { 
		var div = document.createElement('div'); 
		//div.setAttribute('class', 'slider_base');
		div.className = 'slider_base';
		div.appendChild(this.slider());
		this.sliderContainer = div; 
		return div;
	},
	slider: function() { 
		var div = document.createElement('div'); 
		//div.setAttribute('class', 'slider');
		div.className = 'slider'; 
		this.slider = div; 
		return div; 
	},

	pages: 0,
	activeIndex: -1,
	drag: false,
	dragPosition: {x:0,y:0},
	sliderStartPosition: {x:0,y:0},
	sliderPosition: {x:0,y:0},
	interval: -1,
	
	_constructor: function() {
		if ($.browser.mozilla) $(this.view).css({ 'MozUserSelect' : 'none' });
		else if ($.browser.msie) $(this.view).bind('selectstart.disableTextSelect', function() { return false; });
		else $(this.view).bind('mousedown.disableTextSelect', function() { return false; });
		
		/*
		if (this.config.cycle == true || this.config.cycle == 'true') {
			var func = eval("func = function() {\
						var target = _." + this.name + ".director;\
						target.showNextPage();\
					}");

			if (this.interval != -1) clearInterval(this.interval);
			this.interval = setInterval(func, this.config.cycleSpeed * 60 * 1000);
		}
		*/
	},
	run: function() {
		this.pages			= $(this.view).find('.items_page_container').length;
		this.itemsContainer	= $(this.view).find('.items_container')[0];
		this.itemsContainer.appendChild(this.sliderContainer());

		this.sliderStartPosition = {x:parseInt($(this.slider).css('left')),y:parseInt($(this.slider).css('top'))};

		// Drag start & stop
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
		$(this.slider).bind('mousedown.slider_' + this.name, func);
		$(document).bind('mouseup.slidercontainer_' + this.name, func);
		
		// Drag monitoring
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
		$(this.sliderContainer).bind('mousemove.slidercontainer_' + this.name, func);
		
		// Click forward/backward (outside of drag element)
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
		$(this.sliderContainer).bind('mousedown.slidercontainer_' + this.name, func);
		
		this.showPage(0);
	},	
	showPage: function(index) {
		if (index == this.pages) index = 0;			// Go to first item if the last item is reached
		if (index == -1) index = this.pages - 1;	// Go to last item if the first item is reached

		$(this.view).find('.items_page_container').removeClass('active');
		$(this.view).find('.items_page_container:eq(' + index + ')').addClass('active');

		for (var i = 0; i < index; i++) {
			$(this.view).find('.items_page_container:eq(' + i + ')').animate({left:((index - i) * -303) + 'px'}, this.config.animationSpeed);
		}
		$(this.view).find('.items_page_container:eq(' + index + ')').animate({left:'0px'}, this.config.animationSpeed);
		for (var i = index + 1; i < Math.ceil(this.config.maxItems / this.config.maxItemsPerPage); i++) {
			$(this.view).find('.items_page_container:eq(' + i + ')').animate({left:((i - index) * 303) + 'px'}, this.config.animationSpeed);
		}

		this.slider.innerHTML = (index + 1) + '/' + this.pages;

		this.activeIndex = index;
	},
	showNextPage: function() {
		this.showPage(this.activeIndex + 1);
	},
	showPreviousPage: function() {
		this.showPage(this.activeIndex - 1);		
	},
	handleEvent: function(e) {
		try {
			switch (e.type) {
				case 'mousedown':
					switch ($(e.target).attr('class')) {
						case 'slider':
							this.drag = true;
							this.dragPosition = {x:e.layerX + parseInt($(this.slider).css('left')),y:e.layerY + parseInt($(this.slider).css('top'))};
							e.preventDefault();
							break;
						case 'slider_base':
							this.dragPosition = {x:e.layerX || event.x,y:e.layerY || event.y};
							this.drag = true;
							var leftPos = (this.dragPosition.x - ($(this.slider).width() / 2));
							if (leftPos < 20) leftPos = 20;
							if (leftPos > $(this.sliderContainer).width() - 20 - $(this.slider).width()) leftPos = $(this.sliderContainer).width() - 20 - $(this.slider).width();
							$(this.slider).css('left', leftPos + 'px');
						return;
							this.drag = true;
							break;
					}
					break;
				case 'mouseup':
					if (this.drag) {
						if (this.dragPosition.x < this.sliderStartPosition.x + ($(this.slider).width() / 2)) this.showPage(--this.activeIndex);
						if (this.dragPosition.x > this.sliderStartPosition.x + ($(this.slider).width() / 2)) this.showPage(++this.activeIndex);
					}
					this.drag = false;
					$(this.slider).css({left:this.sliderStartPosition.x + 'px'});
					break;
				case 'mousemove':
					if (this.drag && e.target == this.sliderContainer) {
						this.dragPosition = {x:e.layerX || event.x,y:e.layerY || event.y};
						var leftPos = (this.dragPosition.x - ($(this.slider).width() / 2));
						if (leftPos < 20) leftPos = 20;
						if (leftPos > $(this.sliderContainer).width() - 20 - $(this.slider).width()) leftPos = $(this.sliderContainer).width() - 20 - $(this.slider).width();
						$(this.slider).css({left:leftPos + 'px'});
					}
					break;
			}
		} catch(err) { /* We will simply ignore any errors that occur as they are irrelevant */ }
	}
};

// RSS news view style
_Core._._fct_news_abstract.prototype.views.rss = function(controller) { this.__constructor(controller); };
_Core._._fct_news_abstract.prototype.views.rss.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	view: {},
	name: '',
	config: {},
	controller: {},
	
	__constructor: function(controller) {
		this.view 			= controller.view;
		this.name			= controller.name;
		this.config			= controller.config;
		this.controller 	= controller;
		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!
	
	itemsContainer: function() {
		var div = document.createElement('div');
		//div.setAttribute('class', 'items_container');
		div.className = 'items_container';
		//div.setAttribute('style', 'height:' + ((this.config.maxItemsPerPage * 21) + 19) + 'px');
		div.style.height = ((this.config.maxItemsPerPage * 21) + 19) + 'px';
		this.itemsContainer = div;
		return div;
	},
	titleHeader: function(title, link) {
		var div = document.createElement('div');
		//div.setAttribute('class', 'title_header');
		div.className = 'title_header';
		if (this.config.link != '') {
			var anchor = document.createElement('a');
			anchor.setAttribute('title', title.toUpperCase());
			anchor.setAttribute('href', this.config.link);
			anchor.appendChild(document.createTextNode(title.toUpperCase()));
			div.appendChild(anchor);
		} else {
			div.appendChild(document.createTextNode(title.toUpperCase()));
		}
		return div;
	},
	pageContainer: function() {
		var div = document.createElement('div');
		//div.setAttribute('class', 'items_page_container');
		div.className = 'items_page_container';
		return div;
	},
	itemContainer: function(date, title, link, index) {
		var div = document.createElement('div'); 
		if (index % 2 == 0) {
			//div.setAttribute('class', 'item_container even');
			div.className = 'item_container even';
		} else {
			//div.setAttribute('class', 'item_container odd');
			div.className = 'item_container odd';
		}
		
		var span = document.createElement('span'); 
		//span.setAttribute('class', 'date');
		span.className = 'date'; 
		span.appendChild(document.createTextNode(date)); 
		
		var anchor = document.createElement('a');
		anchor.setAttribute('href', link);
		anchor.setAttribute('title', title);
		
		div.appendChild(anchor);
		div.appendChild(span); 
		anchor.appendChild(document.createTextNode(title)); 
		return div;
	},
	sliderContainer: function() { 
		var div = document.createElement('div'); 
		//div.setAttribute('class', 'slider_base');
		div.className = 'slider_base';
		div.appendChild(this.slider());
		this.sliderContainer = div; 
		return div;
	},
	slider: function() { 
		var div = document.createElement('div'); 
		//div.setAttribute('class', 'slider');
		div.className = 'slider'; 
		this.slider = div; 
		return div; 
	},

	items: [],
	activeIndex: -1,
	drag: false,
	dragPosition: {x:0,y:0},
	sliderStartPosition: {x:0,y:0},
	sliderPosition: {x:0,y:0},
	interval: -1,
	
	_constructor: function() {
		if ($.browser.mozilla) $(this.view).css({ 'MozUserSelect' : 'none' });
		else if ($.browser.msie) $(this.view).bind('selectstart.disableTextSelect', function() { return false; });
		else $(this.view).bind('mousedown.disableTextSelect', function() { return false; });
		
		this.view.appendChild(this.titleHeader(this.config.title, this.config.link));
		this.view.appendChild(this.itemsContainer());

		if (this.config.cycle == true || this.config.cycle == 'true') {
			var func = eval("func = function() {\
						var target = _." + this.name + ".director;\
						target.showNextPage();\
					}");

			if (this.interval != -1) clearInterval(this.interval);
			this.interval = setInterval(func, this.config.cycleSpeed * 60 * 1000);
		}
	},
	update: function() {
		this.items 	= $(this.controller.data).find('item, .item');
		this.renderItems();
		this.showPage(0);
	},
	renderItems: function() {
		$(this.view).css({'height': (30 + (this.config.maxItemsPerPage * 21) + 20) + 'px'});
		for (var i = 0; i < Math.ceil((this.items.length < this.config.maxItems ? this.items.length : this.config.maxItems) / this.config.maxItemsPerPage); i++) {
			var page = this.pageContainer();
			page.index = i;
			$(page).css({zIndex: 90 + i});
			for (var j = 0; j < (this.items.length - (i * this.config.maxItemsPerPage) < this.config.maxItemsPerPage ? this.items.length - (i * this.config.maxItemsPerPage) : this.config.maxItemsPerPage); j++) {
				var date	= $(this.items[i * this.config.maxItemsPerPage + j]).find('pubDate').text();
				date		= this.formatDate(date);
				var title	= $(this.items[i * this.config.maxItemsPerPage + j]).find('title').text();
				var link	= $(this.items[i * this.config.maxItemsPerPage + j]).find('link').text();
				var item = this.itemContainer(date, title, link, j + 1);
				page.appendChild(item);
			}
			this.itemsContainer.appendChild(page);
		};

		this.itemsContainer.appendChild(this.sliderContainer());
		this.sliderStartPosition = {x:parseInt($(this.slider).css('left')),y:parseInt($(this.slider).css('top'))};

		if (this.items.length <= this.config.maxItemsPerPage) {
			$(this.slider).css({'display':'none'});
		} else {
			$(this.slider).css({'display':'block'});
		}

		// Drag start & stop
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
		$(this.slider).bind('mousedown.slider_' + this.name, func);
		$(document).bind('mouseup.slidercontainer_' + this.name, func);
		
		// Drag monitoring
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
		$(this.sliderContainer).bind('mousemove.slidercontainer_' + this.name, func);
		
		// Click forward/backward (outside of drag element)
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
		$(this.sliderContainer).bind('mousedown.slidercontainer_' + this.name, func);
	},
	showPage: function(index) {
		if (index == Math.ceil((this.items.length < this.config.maxItems ? this.items.length : this.config.maxItems) / this.config.maxItemsPerPage)) index = 0;			// Go to first item if the last item is reached
		if (index == -1) index = Math.ceil((this.items.length < this.config.maxItems ? this.items.length : this.config.maxItems) / this.config.maxItemsPerPage) - 1;		// Go to last item if the first item is reached

		$(this.view).find('.items_page_container').removeClass('active');
		$(this.view).find('.items_page_container:eq(' + index + ')').addClass('active');

		for (var i = 0; i < index; i++) {
			$(this.view).find('.items_page_container:eq(' + i + ')').animate({left:((index - i) * -303) + 'px'}, this.config.animationSpeed);
		}
		$(this.view).find('.items_page_container:eq(' + index + ')').animate({left:'0px'}, this.config.animationSpeed);
		for (var i = index + 1; i < Math.ceil(this.config.maxItems / this.config.maxItemsPerPage); i++) {
			$(this.view).find('.items_page_container:eq(' + i + ')').animate({left:((i - index) * 303) + 'px'}, this.config.animationSpeed);
		}

		this.slider.innerHTML = (index + 1) + '/' + Math.ceil((this.items.length < this.config.maxItems ? this.items.length : this.config.maxItems) / this.config.maxItemsPerPage);

		this.activeIndex = index;
	},
	showNextPage: function() {
		this.showPage(this.activeIndex + 1);
	},
	showPreviousPage: function() {
		this.showPage(this.activeIndex - 1);		
	},
	formatDate: function(date){
		var months		= {Jan:'Jan',Feb:'Feb',Mar:'Mrt',Apr:'Apr',May:'Mei',Jun:'Jun',Jul:'Jul',Aug:'Aug',Sep:'Sep',Oct:'Okt',Nov:'Nov',Dec:'Dec'};
		var dateParts 	= date.split(' ');
		date = dateParts[1] + ' ' + months[dateParts[2]];
		return date;
	},
	handleEvent: function(e) {
		try {
			switch (e.type) {
				case 'mousedown':
					switch ($(e.target).attr('class')) {
						case 'slider':
							this.drag = true;
							this.dragPosition = {x:e.layerX + parseInt($(this.slider).css('left')),y:e.layerY + parseInt($(this.slider).css('top'))};
							e.preventDefault();
							break;
						case 'slider_base':
							this.dragPosition = {x:e.layerX || event.x,y:e.layerY || event.y};
							this.drag = true;
							var leftPos = (this.dragPosition.x - ($(this.slider).width() / 2));
							if (leftPos < 20) leftPos = 20;
							if (leftPos > $(this.sliderContainer).width() - 20 - $(this.slider).width()) leftPos = $(this.sliderContainer).width() - 20 - $(this.slider).width();
							$(this.slider).css('left', leftPos + 'px');
						return;
							this.drag = true;
							break;
					}
					break;
				case 'mouseup':
					if (this.drag) {
						if (this.dragPosition.x < this.sliderStartPosition.x + ($(this.slider).width() / 2)) this.showPage(--this.activeIndex);
						if (this.dragPosition.x > this.sliderStartPosition.x + ($(this.slider).width() / 2)) this.showPage(++this.activeIndex);
					}
					this.drag = false;
					$(this.slider).css({left:this.sliderStartPosition.x + 'px'});
					break;
				case 'mousemove':
					if (this.drag && e.target == this.sliderContainer) {
						this.dragPosition = {x:e.layerX || event.x,y:e.layerY || event.y};
						var leftPos = (this.dragPosition.x - ($(this.slider).width() / 2));
						if (leftPos < 20) leftPos = 20;
						if (leftPos > $(this.sliderContainer).width() - 20 - $(this.slider).width()) leftPos = $(this.sliderContainer).width() - 20 - $(this.slider).width();
						$(this.slider).css({left:leftPos + 'px'});
					}
					break;
			}
		} catch(err) { /* We will simply ignore any errors that occur as they are irrelevant */ }
	}
};

// Shop news view style
_Core._._fct_news_abstract.prototype.views.shop = function(controller) { this.__constructor(controller); };
_Core._._fct_news_abstract.prototype.views.shop.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	view: {},
	name: '',
	config: {},
	controller: {},
	
	__constructor: function(controller) {
		this.view 			= controller.view;
		this.name			= controller.name;
		this.config			= controller.config;
		this.controller 	= controller;
		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!
	
	itemsContainer: function() {
		var div = document.createElement('div');
		//div.setAttribute('class', 'items_container');
		div.className = 'items_container';
		this.itemsContainer = div;
		return div;
	},
	titleHeader: function(title) {
		var div = document.createElement('div');
		//div.setAttribute('class', 'title_header');
		div.className = 'title_header';
		div.appendChild(document.createTextNode(title.toUpperCase()));
		return div;
	},
	pageContainer: function() {
		var div = document.createElement('div');
		//div.setAttribute('class', 'items_page_container');
		div.className = 'items_page_container';
		return div;
	},
	itemContainer: function(photo, description, price, link, index) {
		var div = document.createElement('div'); 
		if (index % 2 == 0) {
			//div.setAttribute('class', 'item_container even');
			div.className = 'item_container even';
		} else {
			//div.setAttribute('class', 'item_container odd');
			div.className = 'item_container odd';
		}
		
		var img = document.createElement('img'); 
		img.setAttribute('src', photo); 
		img.setAttribute('alt', description);
		img.setAttribute('title', description);
		div.appendChild(img); 
		
		var anchor = document.createElement('a');
		anchor.setAttribute('href', link);
		anchor.setAttribute('title', description);
		anchor.appendChild(document.createTextNode(description));
		div.appendChild(anchor);
		
		var strong = document.createElement('strong');
		strong.appendChild(document.createTextNode(price));
		div.appendChild(strong);
		
		return div;
	},
	sliderContainer: function() { 
		var div = document.createElement('div'); 
		//div.setAttribute('class', 'slider_base');
		div.className = 'slider_base';
		div.appendChild(this.slider());
		this.sliderContainer = div; 
		return div;
	},
	slider: function() { 
		var div = document.createElement('div');
		//div.setAttribute('class', 'slider');
		div.className = 'slider'; 
		this.slider = div; 
		return div; 
	},

	items: [],
	activeIndex: -1,
	drag: false,
	dragPosition: {x:0,y:0},
	sliderStartPosition: {x:0,y:0},
	sliderPosition: {x:0,y:0},
	interval: -1,
	
	_constructor: function() {
		if ($.browser.mozilla) $(this.view).css({ 'MozUserSelect' : 'none' });
		else if ($.browser.msie) $(this.view).bind('selectstart.disableTextSelect', function() { return false; });
		else $(this.view).bind('mousedown.disableTextSelect', function() { return false; });
		
		this.view.appendChild(this.titleHeader(this.config.title));
		this.view.appendChild(this.itemsContainer());

		if (this.config.cycle == true || this.config.cycle == 'true') {
			var func = eval("func = function() {\
						var target = _." + this.name + ".director;\
						target.showNextPage();\
					}");

			if (this.interval != -1) clearInterval(this.interval);
			this.interval = setInterval(func, this.config.cycleSpeed * 60 * 1000);
		}
	},
	update: function() {
		this.items 	= $(this.controller.data).find('item, .item');
		this.renderItems();
		this.showPage(0);
	},
	renderItems: function() {
		for (var i = 0; i < Math.ceil(this.items.length / 3); i++) {
			var page = this.pageContainer();
			page.index = i;
			$(page).css({zIndex: 90 + i});
			for (var j = 0; j < 3; j++) {
				var photo		= $(this.items[i * 3 + j]).find('photo, .photo').text();
				var price		= $(this.items[i * 3 + j]).find('price, .price').text();
				var description	= $(this.items[i * 3 + j]).find('description, .description').text();
				var link		= $(this.items[i * 3 + j]).find('linkurl, .linkurl').text();
				var item 		= this.itemContainer(photo, description, price, link, j + 1);
				page.appendChild(item);
			}
			this.itemsContainer.appendChild(page);
		}
		this.itemsContainer.appendChild(this.sliderContainer());

		this.sliderStartPosition = {x:parseInt($(this.slider).css('left')),y:parseInt($(this.slider).css('top'))};

		// Drag start & stop
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
		$(this.slider).bind('mousedown.slider_' + this.name, func);
		$(document).bind('mouseup.slidercontainer_' + this.name, func);
		
		// Drag monitoring
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
		$(this.sliderContainer).bind('mousemove.slidercontainer_' + this.name, func);
		
		// Click forward/backward (outside of drag element)
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
		$(this.sliderContainer).bind('mousedown.slidercontainer_' + this.name, func);
	},
	showPage: function(index) {
		if (index == Math.ceil(this.config.maxItems / 3)) index = 0;			// Go to first item if the last item is reached
		if (index == -1) index = Math.ceil(this.config.maxItems / 3) - 1;		// Go to last item if the first item is reached

		$(this.view).find('.items_page_container').removeClass('active');
		$(this.view).find('.items_page_container:eq(' + index + ')').addClass('active');

		for (var i = 0; i < index; i++) {
			$(this.view).find('.items_page_container:eq(' + i + ')').animate({left:((index - i) * -303) + 'px'}, this.config.animationSpeed);
		}
		$(this.view).find('.items_page_container:eq(' + index + ')').animate({left:'0px'}, this.config.animationSpeed);
		for (var i = index + 1; i < 3; i++) {
			$(this.view).find('.items_page_container:eq(' + i + ')').animate({left:((i - index) * 303) + 'px'}, this.config.animationSpeed);
		}

		this.slider.innerHTML = (index + 1) + '/' + Math.ceil(this.config.maxItems / 3);

		this.activeIndex = index;
	},
	showNextPage: function() {
		this.showPage(this.activeIndex + 1);
	},
	showPreviousPage: function() {
		this.showPage(this.activeIndex - 1);		
	},
	handleEvent: function(e) {
		try {
			switch (e.type) {
				case 'mousedown':
					switch ($(e.target).attr('class')) {
						case 'slider':
							this.drag = true;
							this.dragPosition = {x:e.layerX + parseInt($(this.slider).css('left')),y:e.layerY + parseInt($(this.slider).css('top'))};
							e.preventDefault();
							break;
						case 'slider_base':
							this.dragPosition = {x:e.layerX || event.x,y:e.layerY || event.y};
							this.drag = true;
							var leftPos = (this.dragPosition.x - ($(this.slider).width() / 2));
							if (leftPos < 20) leftPos = 20;
							if (leftPos > $(this.sliderContainer).width() - 20 - $(this.slider).width()) leftPos = $(this.sliderContainer).width() - 20 - $(this.slider).width();
							$(this.slider).css('left', leftPos + 'px');
						return;
							this.drag = true;
							break;
					}
					break;
				case 'mouseup':
					if (this.drag) {
						if (this.dragPosition.x < this.sliderStartPosition.x + ($(this.slider).width() / 2)) this.showPage(--this.activeIndex);
						if (this.dragPosition.x > this.sliderStartPosition.x + ($(this.slider).width() / 2)) this.showPage(++this.activeIndex);
					}
					this.drag = false;
					$(this.slider).css({left:this.sliderStartPosition.x + 'px'});
					break;
				case 'mousemove':
					if (this.drag && e.target == this.sliderContainer) {
						this.dragPosition = {x:e.layerX || event.x,y:e.layerY || event.y};
						var leftPos = (this.dragPosition.x - ($(this.slider).width() / 2));
						if (leftPos < 20) leftPos = 20;
						if (leftPos > $(this.sliderContainer).width() - 20 - $(this.slider).width()) leftPos = $(this.sliderContainer).width() - 20 - $(this.slider).width();
						$(this.slider).css({left:leftPos + 'px'});
					}
					break;
			}
		} catch(err) { /* We will simply ignore any errors that occur as they are irrelevant */ }
	}
};
_Core._._fct_matchcentre_abstract = function(view, name) {this.__constructor(view, name);};

_Core._._fct_matchcentre_abstract.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	views: {},
	view: {},
	controller: {},
	name: '',
	
	__constructor: function(view, name) {
		this.view 		= view;
		this.controller	= this;
		this.name		= name;
		var userConfig	= eval("(" + this.view.getAttribute('config') + ")");
		this.config		= _.processConfig(this.config, userConfig);
		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!
	
	config: {
		type: 				'standard'
	},
	data: {},
	director: {},
	
	_constructor: function() { // Constructor for the module sub-object
		$(this.view).addClass(this.config.type);
		try {
			this.director = new this.views[this.config.type](this);		
		} catch(e) {
		}
	},
	run: function() {
		this.director.run();
	}
};
(function() {_.registerModule('fct_matchcentre', '_fct_matchcentre_abstract', 'fct_matchcentre_widget')})(); // Module instantiation/registration

/* View definitions */
// Image view style
_Core._._fct_matchcentre_abstract.prototype.views.standard = function(controller) { this.__constructor(controller); };
_Core._._fct_matchcentre_abstract.prototype.views.standard.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	view: {},
	name: '',
	config: {},
	controller: {},
	
	__constructor: function(controller) {
		this.view 			= controller.view;
		this.name			= controller.name;
		this.config			= controller.config;
		this.controller 	= controller;
		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!

	items: [],
	activeIndex: -1,
	
	sliderContainer: function() { 
		var div = document.createElement('div'); 
		//div.setAttribute('class', 'slider_base');
		div.className = 'slider_base';
		div.appendChild(this.slider());
		this.sliderContainer = div;
		
		var span = document.createElement('span');
		//span.setAttribute('class', 'lefttext');
		span.className = 'lefttext';
		span.appendChild(document.createTextNode('< '+i18n.get(_.lang, 'vorige')));
		div.appendChild(span);

		var span = document.createElement('span');
		//span.setAttribute('class', 'righttext');
		span.className = 'righttext';
		span.appendChild(document.createTextNode(i18n.get(_.lang, 'volgende') + ' >'));
		div.appendChild(span);
		 
		return div;
	},
	slider: function() { 
		var div = document.createElement('div'); 
		//div.setAttribute('class', 'slider');
		div.className = 'slider'; 
		this.slider = div; 
		return div; 
	},
	
	_constructor: function() {
		if ($.browser.mozilla) $(this.view).css({'MozUserSelect':'none'});
		else if ($.browser.msie) $(this.view).bind('selectstart.disableTextSelect', function() { return false; });
		else $(this.view).bind('mousedown.disableTextSelect', function() { return false; });

		this.view.appendChild(this.sliderContainer());
		this.sliderStartPosition = {x:parseInt($(this.slider).css('left')),y:parseInt($(this.slider).css('top'))};

		// Drag start & stop
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
		$(this.slider).bind('mousedown.slider_' + this.name, func);
		$(document).bind('mouseup.slidercontainer_' + this.name, func);
		
		// Drag monitoring
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
		$(this.sliderContainer).bind('mousemove.slidercontainer_' + this.name, func);
		
		// Click forward/backward (outside of drag element)
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
		$(this.sliderContainer).bind('mousedown.slidercontainer_' + this.name, func);
	},
	run: function() {
		var matches = this.items = $(this.view).find('.match');
		var matchCount = matches.length;
		for (var i = 0; i < matchCount; i++) {
			if ($(matches[i]).hasClass('active')) {
				this.activeIndex = i;
				break;
			}
		}
		
		if(this.activeIndex==-1) {
			$(matches[matchCount-1]).addClass('active');
			this.activeIndex = matchCount-1;
		}
	},
	update: function() {
		this.items 	= $(this.controller.data).find('match, .match');
		this.links	= $(this.controller.data).find('relatedlinks link, .relatedlinks .link');
		
		for (var i = 0; i < this.items.length; i++) {
			if (this.items[i].getAttribute('current') == 'true') break;
		}
		
		this.view.appendChild(this.relatedLinks(this.links));
		this.showItem(i);
	},
	showItem: function(index) {
		/*
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							$(target.items[target.activeIndex]).removeClass('active');\
							$(target.items[" + index + "]).fadeOut(0);\
							$(target.items[" + index + "]).addClass('active');\
							$(target.items[" + index + "]).fadeIn(250);\
							target.activeIndex = " + index + ";\
						}");

		$(this.items[this.activeIndex]).fadeOut(250, func);
		*/
		if (this.activeIndex > index) {
			$(this.items[this.activeIndex]).animate({'left':'305px'}, 250, null, function() {$(this).removeClass('active');});
			$(this.items[index]).css('left', '-305px');
		} else {
			$(this.items[this.activeIndex]).animate({'left':'-305px'}, 250, null, function() {$(this).removeClass('active');});
			$(this.items[index]).css('left', '305px');
		}
		$(this.items[index]).addClass('active');
		$(this.items[index]).animate({'left':'0px'}, 250);
		
		this.activeIndex = index;
		//this.slider.innerHTML = (index + 1) + '/' + this.items.length;
	},
	showNextItem: function() {
		if (this.activeIndex < this.items.length - 1) {
			this.showItem(this.activeIndex + 1);
		}
	},
	showPreviousItem: function() {
		if (this.activeIndex > 0) {
			this.showItem(this.activeIndex - 1);
		}
	},
	handleEvent: function(e) {
		try {
			switch (e.type) {
				case 'mousedown':
					if (e.target.nodeName == 'SPAN') {
						e.target = e.target.parentNode;
					}
					switch ($(e.target).attr('class')) {
						case 'slider':
							this.drag = true;
							this.dragPosition = {x:e.layerX + parseInt($(this.slider).css('left')),y:e.layerY + parseInt($(this.slider).css('top'))};
							e.preventDefault();
							break;
						case 'slider_base':
							this.dragPosition = {x:e.layerX || event.x,y:e.layerY || event.y};
							this.drag = true;
							var leftPos = (this.dragPosition.x - ($(this.slider).width() / 2));
							if (leftPos < 20) leftPos = 20;
							if (leftPos > $(this.sliderContainer).width() - 20 - $(this.slider).width()) leftPos = $(this.sliderContainer).width() - 20 - $(this.slider).width();
							$(this.slider).css('left', leftPos + 'px');
						return;
							this.drag = true;
							break;
					}
					break;
				case 'mouseup':
					if (this.drag) {
						if (this.dragPosition.x < this.sliderStartPosition.x + ($(this.slider).width() / 2)) this.showPreviousItem();
						if (this.dragPosition.x > this.sliderStartPosition.x + ($(this.slider).width() / 2)) this.showNextItem();
					}
					this.drag = false;
					$(this.slider).css({left:this.sliderStartPosition.x + 'px'});
					break;
				case 'mousemove':
					if (this.drag && e.target == this.sliderContainer) {
						this.dragPosition = {x:e.layerX || event.x,y:e.layerY || event.y};
						var leftPos = (this.dragPosition.x - ($(this.slider).width() / 2));
						if (leftPos < 20) leftPos = 20;
						if (leftPos > $(this.sliderContainer).width() - 20 - $(this.slider).width()) leftPos = $(this.sliderContainer).width() - 20 - $(this.slider).width();
						$(this.slider).css({left:leftPos + 'px'});
					}
					break;
			}
		} catch(err) { /* We will simply ignore any errors that occur as they are irrelevant */ }
	}
};


_Core._._fct_gallery_abstract = function(view, name) {this.__constructor(view, name);};

_Core._._fct_gallery_abstract.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	views: {},
	view: {},
	controller: {},
	name: '',
	
	__constructor: function(view, name) {
		this.view 		= view;
		this.controller	= this;
		this.name		= name;
		var userConfig	= eval("(" + this.view.getAttribute('config') + ")");
		this.config		= _.processConfig(this.config, userConfig);
		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!
	
	config: {
		source: 			'',
		proxy: 				'service/proxy.php',
		maxItems: 			10,
		type: 				'standard',
		animation:			false,
		animationSpeed: 	500,
		animationType: 		'lin',
		animationDirection: 'down'
	},
	data: {},
	director: {},
	
	_constructor: function() { // Constructor for the module sub-object
		$(this.view).addClass(this.config.type);
		try {
			this.director = new this.views[this.config.type](this);		
		} catch(e) {
		}
	},
	run: function() {
		var func = eval("func = function() {\
							var target = _." + this.name + ";\
							target.getData();\
						}");
		func();
	},
	getData: function() {
		var func = eval("func = function(data) {\
							var target = _." + this.name + ";\
							target.processData(data);\
						}");
						
		if ($(this.view).find('.data').length != 0) {
			func($(this.view).find('.data')[0]);
			$(this.view).find('.data').remove();
		} else {
			if (this.config.proxy != false && this.config.proxy != 'false') {
				_.comm.get(this.config.proxy + '?' + escape(this.config.source), this, func);
			} else {
				_.comm.get(this.config.source, this, func);
			}
		}
	},
	processData: function(data) {
		this.data = data;
		this.director.update();
	}
};
(function() {_.registerModule('fct_gallery', '_fct_gallery_abstract', 'fct_gallery_widget')})(); // Module instantiation/registration

/* View definitions */
// Standard view style
_Core._._fct_gallery_abstract.prototype.views.standard = function(controller) { this.__constructor(controller); };
_Core._._fct_gallery_abstract.prototype.views.standard.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	view: {},
	name: '',
	config: {},
	controller: {},
	
	__constructor: function(controller) {
		this.view 			= controller.view;
		this.name			= controller.name;
		this.config			= controller.config;
		this.controller 	= controller;
		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!

	imageContainer: function() { 
		var div = document.createElement('div'); 
		//div.setAttribute('class', 'image_container'); 
		div.className = 'image_container'; 
		this.imageContainer = div; 
		return div; 
	},
	titleContainer: function() { 
		var div = document.createElement('div'); 
		//div.setAttribute('class', 'title_container');
		div.className = 'title_container'; 
		this.titleContainer = div; 
		return div; 
	},
	titleContainerDummy: function() { 
		var div = document.createElement('div'); 
		//div.setAttribute('class', 'title_container_dummy');
		div.className = 'title_container_dummy'; 
		this.titleContainerDummy = div; 
		return div; 
	},
	sliderContainer: function() { 
		var div = document.createElement('div'); 
		//div.setAttribute('class', 'slider_base');
		div.className = 'slider_base'; 
		div.appendChild(this.slider());
		this.sliderContainer = div; 
		return div; 
	},
	slider: function() { 
		var div = document.createElement('div'); 
		//div.setAttribute('class', 'slider');
		div.className = 'slider'; 
		this.slider = div; 
		return div; 
	},
	items: [],
	activeIndex: -1,
	drag: false,
	dragPosition: {x:0,y:0},
	sliderStartPosition: {x:0,y:0},
	sliderPosition: {x:0,y:0},
	
	_constructor: function() {
		if ($.browser.mozilla) $(this.view).css({ 'MozUserSelect' : 'none' });
		else if ($.browser.msie) $(this.view).bind('selectstart.disableTextSelect', function() { return false; });
		else $(this.view).bind('mousedown.disableTextSelect', function() { return false; });

		this.view.appendChild(this.imageContainer());
		this.view.appendChild(this.titleContainer());
		this.view.appendChild(this.sliderContainer());
		this.view.appendChild(this.titleContainerDummy());

		// Drag start & stop
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
		$(this.slider).bind('mousedown.slider', func);
		$(document).bind('mouseup.slidercontainer', func);
		
		// Drag monitoring
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
		$(this.sliderContainer).bind('mousemove.slidercontainer', func);
		
		// Click forward/backward (outside of drag element)
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
		$(this.sliderContainer).bind('mousedown.slidercontainer', func);
	},
	update: function() {
		this.sliderStartPosition = {x:parseInt($(this.slider).css('left')),y:parseInt($(this.slider).css('top'))};
		this.items 	= $(this.controller.data).find('item, .item');

		if (this.items.length == 1) {
			$(this.slider).css({'display':'none'});
		} else {
			$(this.slider).css({'display':'block'});
		}

		this.preloadImages();
		this.showItem(0);
	},
	preloadImages: function() {
		for (var i = 0; i < this.items.length; i++) {
			var image 		= new Image();
			var imageSrc	= $(this.items[i]).find('photo, .photo').text();
			image.src 		= imageSrc;
		}
	},
	showItem: function(index) {
		if (index == this.items.length) index = 0;			// Go to first item if the last item is reached
		if (index == -1) index = this.items.length - 1;		// Go to last item if the first item is reached

		var item 		= this.items[index];
		var imageSrc	= $(item).find('photo, .photo').text();
		var title 		= $(item).find('title, .title').text();
		
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.titleContainer.innerHTML = '" + title.replace(/\'/g, '\\\'') + "';\
							target.titleContainerDummy.innerHTML = '" + title.replace(/\'/g, '\\\'') + "';\
							if (title.length > 29) {\
								$(target.titleContainer).addClass('doubleline');\
							} else {\
								$(target.titleContainer).removeClass('doubleline');\
							}\
							$(this).animate({bottom: '25px'}, " + this.config.animationSpeed + ", 'swing');\
						}");

		$(this.titleContainer).animate({bottom: '-50px'}, this.config.animationSpeed, 'swing', func);
		$(this.imageContainer).find('img').fadeOut(this.config.animationSpeed, function() {$(this).remove()});
		$(this.imageContainer).prepend('<img src="' + imageSrc + '" alt="' + title + '" title="' + title + '" />');
		$(this.imageContainer).find('img:first').fadeOut(0).fadeIn(this.config.animationSpeed);

		this.slider.innerHTML = (index + 1) + '/' + this.items.length;
		
		this.activeIndex = index;
	},
	handleEvent: function(e) {
		try {
			switch (e.type) {
				case 'mousedown':
					switch ($(e.target).attr('class')) {
						case 'slider':
							this.drag = true;
							this.dragPosition = {x:e.layerX + parseInt($(this.slider).css('left')),y:e.layerY + parseInt($(this.slider).css('top'))};
							e.preventDefault();
							break;
						case 'slider_base':
							this.dragPosition = {x:e.layerX || event.x,y:e.layerY || event.y};
							this.drag = true;
							var leftPos = (this.dragPosition.x - ($(this.slider).width() / 2));
							if (leftPos < 20) leftPos = 20;
							if (leftPos > $(this.sliderContainer).width() - 20 - $(this.slider).width()) leftPos = $(this.sliderContainer).width() - 20 - $(this.slider).width();
							$(this.slider).css('left', leftPos + 'px');
						return;
							this.drag = true;
							break;
					}
					break;
				case 'mouseup':
					if (this.drag) {
						if (this.dragPosition.x < this.sliderStartPosition.x + ($(this.slider).width() / 2)) this.showItem(--this.activeIndex);
						if (this.dragPosition.x > this.sliderStartPosition.x + ($(this.slider).width() / 2)) this.showItem(++this.activeIndex);
					}
					this.drag = false;
					$(this.slider).css({left:this.sliderStartPosition.x + 'px'});
					break;
				case 'mousemove':
					if (this.drag && e.target == this.sliderContainer) {
						this.dragPosition = {x:e.layerX || event.x,y:e.layerY || event.y};
						var leftPos = (this.dragPosition.x - ($(this.slider).width() / 2));
						if (leftPos < 20) leftPos = 20;
						if (leftPos > $(this.sliderContainer).width() - 20 - $(this.slider).width()) leftPos = $(this.sliderContainer).width() - 20 - $(this.slider).width();
						$(this.slider).css({left:leftPos + 'px'});
					}
					break;
			}
		} catch(err) { /* We will simply ignore any errors that occur as they are irrelevant */ }
	}	
};

// Browser view style
_Core._._fct_gallery_abstract.prototype.views.browser = function(controller) { this.__constructor(controller); };
_Core._._fct_gallery_abstract.prototype.views.browser.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	view: {},
	name: '',
	config: {},
	controller: {},
	
	__constructor: function(controller) {
		this.view 			= controller.view;
		this.name			= controller.name;
		this.config			= controller.config;
		this.controller 	= controller;
		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!
	
	hoverPosition: {x:0,y:0},
	animateInterval: -1,
	
	background: function(image, width) {
		var div = document.createElement('div');
		//div.setAttribute('class', 'background');
		div.className = 'background';
		div.style.backgroundImage = 'url(' + image + ')';
		div.style.width = width + 'px';
		this.background = div;
		return div;
	},
	item: function(image, title, link) {
		var anchor = document.createElement('a');
		anchor.setAttribute('href', link);
		var img = document.createElement('img');
		img.setAttribute('src', image);
		img.setAttribute('alt', title);
		img.setAttribute('title', title);
		//img.setAttribute('class', 'overlay');
		img.className = 'overlay';
		anchor.appendChild(img);
		return anchor;
	},
	titleContainer: function() { 
		var div = document.createElement('div'); 
		//div.setAttribute('class', 'title_container');
		div.className = 'title_container'; 
		this.titleContainer = div; 
		return div; 
	},
	arrow_left: function() {
		var div = document.createElement('div');
		//div.setAttribute('class', 'arrow_left');
		div.className = 'arrow_left';
		this.arrow_left = div;
		return div;
	},
	arrow_right: function() {
		var div = document.createElement('div');
		//div.setAttribute('class', 'arrow_right');
		div.className = 'arrow_right';
		this.arrow_right = div;
		return div;
	},
	_constructor: function() {
		if ($.browser.mozilla) $(this.view).css({ 'MozUserSelect' : 'none' });
		else if ($.browser.msie) $(this.view).bind('selectstart.disableTextSelect', function() { return false; });
		else $(this.view).bind('mousedown.disableTextSelect', function() { return false; });

		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
		$(this.view).bind('mouseenter mousemove mouseleave', func);
	},
	
	update: function() {
		this.items 	= $(this.controller.data).find('item, .item');
		
		var background = $(this.controller.data).find('background, .background').text();
		this.view.appendChild(this.background(background, 2500)); //(this.items.length * 60) * 1.1 > 620 * 1.1 ? (this.items.length * 60) * 1.1 : 620 * 1.2));
		this.view.appendChild(this.titleContainer());
		this.view.appendChild(this.arrow_left());
		this.view.appendChild(this.arrow_right());
		this.preloadImages();
		this.renderItems();
		this.scrollItems();
	},
	preloadImages: function() {
		for (var i = 0; i < this.items.length; i++) {
			var image 		= new Image();
			var imageSrc	= $(this.items[i]).find('image, .image').text();
			image.src 		= imageSrc;
		}
	},
	renderItems: function(){
		for (var i = 0; i < this.items.length; i++) {
			var image 			= $(this.items[i]).find('image, .image').text();
			var title			= $(this.items[i]).find('title, .title').text();
			var link			= $(this.items[i]).find('linkurl, .linkurl').text();
			var item			= this.item(image, title, link);
			this.items[i].item	= item; 
			this.view.appendChild(item);
		}
	},
	scrollItems: function(direction, focusItem) {
		if (typeof focusItem == 'undefined') {
			if (typeof this.focusItem == 'undefined') {
				this.focusItem = focusItem = 1;
			} else {
				focusItem = this.focusItem;
				if (direction == 'forward') {
					this.focusItem = focusItem = focusItem + 1;
					if (focusItem > this.items.length) this.focusItem = focusItem = this.items.length; 
				} else {
					this.focusItem = focusItem = focusItem - 1;
					if (focusItem < 1) this.focusItem = focusItem = 1;
				}
			}
		}
		
		focusItem--;

		//var leftPos = 0;
		var leftPos = -(((focusItem - 2) * 60) - 8);
		if (focusItem == 0) {
			leftPos += Math.round(Math.sin(0.25 * Math.PI) * 130);
		}
		
		for (var i = 0; i < this.items.length; i++) {
			if (i >= focusItem - 2 && i <= focusItem + 2) {
				var relIndex		= i - focusItem + 2;
				var percentage 		= relIndex / 4;
				var sine			= Math.round(Math.sin(percentage * Math.PI) * 100000) / 100000;
				if (this.config.animationType == 'sin') {
					$(this.items[i].item).find('img').animate({top: (20 + Math.round(sine * 50)) + 'px', left: leftPos + 'px', width: (50 + Math.round(sine * 130)) + 'px', height: (55.6 + Math.round(sine * 144.4))}, 300);
				} else {
					$(this.items[i].item).find('img').animate({top: ((144.4 - Math.round(sine * 144.4)) / 2 + 55.6) + 'px', left: leftPos + 'px', width: (50 + Math.round(sine * 130)) + 'px', height: (55.6 + Math.round(sine * 144.4))}, 300);
				}
				
				leftPos += 60 + Math.round(sine * 130);
			} else {
				if (this.config.animationType == 'sin') {
					$(this.items[i].item).find('img').animate({top: '20px', left: leftPos + 'px', width: '50px'}, 300);
				} else {
					$(this.items[i].item).find('img').animate({top: ((144.4 - Math.round(0 * 144.4)) / 2 + 55.6) + 'px', left: leftPos + 'px', width: '50px'}, 300);
				}
				leftPos += 60;
			}
		}

		$(this.titleContainer).text($(this.items[focusItem]).find('title, .title').text());
	},
	handleEvent: function(e) {
		try {
			var func = eval("func = function(e) {\
								var target = _." + this.name + ".director;\
								if (target.moveDirection == 'left' && target.focusItem > 1) {\
									$(target.background).animate({'left': + (parseInt($(target.background).css('left')) + 30 >  0 ? 0 : parseInt($(target.background).css('left')) + 30) + 'px'}, 600, 'linear');\
									target.scrollItems('reverse');\
								} else if (target.moveDirection == 'right' && target.focusItem < target.items.length) {\
									$(target.background).animate({'left': + (parseInt($(target.background).css('left')) - 30 < -parseInt($(target.background).css('width')) ? -parseInt($(target.background).css('width')) : parseInt($(target.background).css('left')) - 30) + 'px'}, 600, 'linear');\
									target.scrollItems('forward');\
								} else {\
									clearInterval(target.animateInterval);\
									target.animateInterval = -1;\
								}\
							}");

			switch (e.type) {
				case 'mouseenter':
					if ($.browser.msie) {
						this.hoverPosition = { x: (e.layerX || event.x), y: e.layerY || event.y};
					} else {
						this.hoverPosition = { x: (e.layerX || event.x) + parseInt($(e.target).css('left')), y: e.layerY || event.y};
					}
					var width = parseInt($(this.view).css('width'));
					if (this.hoverPosition.x < width * 0.1) {
						this.moveDirection = 'left';
						$(this.arrow_left).addClass('active');
						if (this.animateInterval == -1) {
							this.animateInterval = setInterval(func, 600);
							func();
						}
					} else if (this.hoverPosition.x > width * 0.9) {
						this.moveDirection = 'right';
						$(this.arrow_right).addClass('active');
						if (this.animateInterval == -1) {
							this.animateInterval = setInterval(func, 600);
							func();
						}
					} else {
						$(this.arrow_left).removeClass('active');
						$(this.arrow_right).removeClass('active');
						clearInterval(this.animateInterval);
						this.animateInterval = -1;
					}
					break;
				case 'mousemove':
					if ($.browser.msie) {
						this.hoverPosition = { x: (e.layerX || event.x), y: e.layerY || event.y};
					} else {
						this.hoverPosition = { x: (e.layerX || event.x) + parseInt($(e.target).css('left')), y: e.layerY || event.y};
					}
					var width = parseInt($(this.view).css('width'));
					if (this.hoverPosition.x < width * 0.1) {
						this.moveDirection = 'left';
						$(this.arrow_left).addClass('active');
						if (this.animateInterval == -1) {
							this.animateInterval = setInterval(func, 600);
							func();
						}
					} else if (this.hoverPosition.x > width * 0.9) {
						this.moveDirection = 'right';
						$(this.arrow_right).addClass('active');
						if (this.animateInterval == -1) {
							this.animateInterval = setInterval(func, 600);
							func();
						}
					} else {
						$(this.arrow_left).removeClass('active');
						$(this.arrow_right).removeClass('active');
						clearInterval(this.animateInterval);
						this.animateInterval = -1;
					}
					var width = $(this.view).css('width');
					break;
				case 'mouseleave':
					$(this.arrow_left).removeClass('active');
					$(this.arrow_right).removeClass('active');
					clearInterval(this.animateInterval);
					this.animateInterval = -1;
					break;
			}
		} catch(err) { /* We will simply ignore any errors that occur as they are irrelevant */ }
	}
};

_Core._._fct_list_abstract = function(view, name) {this.__constructor(view, name);};

_Core._._fct_list_abstract.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	views: {},
	view: {},
	controller: {},
	name: '',
	
	__constructor: function(view, name) {
		this.view 		= view;
		this.controller	= this;
		this.name		= name;
		var userConfig	= eval("(" + this.view.getAttribute('config') + ")");
		this.config		= _.processConfig(this.config, userConfig);
		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!
	
	config: {
		type: 				'standard'
	},
	data: {},
	director: {},
	
	_constructor: function() { // Constructor for the module sub-object
		$(this.view).addClass(this.config.type);
		try {
			this.director = new this.views[this.config.type](this);		
		} catch(e) {
		}
	},
	run: function() {
		this.director.run();
	}
};
(function() {_.registerModule('fct_list', '_fct_list_abstract', 'fct_list_widget');})(); // Module instantiation/registration

/* View definitions */
// Default view style
_Core._._fct_list_abstract.prototype.views.standard = function(controller) { this.__constructor(controller); };
_Core._._fct_list_abstract.prototype.views.standard.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	view: {},
	name: '',
	config: {},
	controller: {},
	
	__constructor: function(controller) {
		this.view 			= controller.view;
		this.name			= controller.name;
		this.config			= controller.config;
		this.controller 	= controller;
		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!

	itemsContainer: null,
	sliderContainer: function() { 
		var div = document.createElement('div'); 
		//div.setAttribute('class', 'slider_base');
		div.className = 'slider_base';
		div.appendChild(this.slider());
		this.sliderContainer = div; 
		return div;
	},
	slider: function() { 
		var div = document.createElement('div'); 
		//div.setAttribute('class', 'slider');
		div.className = 'slider'; 
		this.slider = div; 
		return div; 
	},

	pages: 0,
	activeIndex: -1,
	drag: false,
	dragPosition: {x:0,y:0},
	sliderStartPosition: {x:0,y:0},
	sliderPosition: {x:0,y:0},
	interval: -1,
	
	_constructor: function() {
		if ($.browser.mozilla) $(this.view).css({ 'MozUserSelect' : 'none' });
		else if ($.browser.msie) $(this.view).bind('selectstart.disableTextSelect', function() { return false; });
		else $(this.view).bind('mousedown.disableTextSelect', function() { return false; });
	},
	run: function() {
		this.pages			= $(this.view).find('.items_page_container').length;
		
		this.itemsContainer	= $(this.view).find('.items_container')[0];
		this.itemsContainer.appendChild(this.sliderContainer());

		if (this.pages > 1) {
			this.sliderStartPosition = {x:parseInt($(this.slider).css('left')),y:parseInt($(this.slider).css('top'))};
			
			// Drag start & stop
			var func = eval("func = function(e) {\
								var target = _." + this.name + ".director;\
								target.handleEvent(e);\
							}");
			$(this.slider).bind('mousedown.slider_' + this.name, func);
			$(document).bind('mouseup.slidercontainer_' + this.name, func);
			
			// Drag monitoring
			var func = eval("func = function(e) {\
								var target = _." + this.name + ".director;\
								target.handleEvent(e);\
							}");
			$(this.sliderContainer).bind('mousemove.slidercontainer_' + this.name, func);
			
			// Click forward/backward (outside of drag element)
			var func = eval("func = function(e) {\
								var target = _." + this.name + ".director;\
								target.handleEvent(e);\
							}");
			$(this.sliderContainer).bind('mousedown.slidercontainer_' + this.name, func);
		} else {
			$(this.sliderContainer).css('display', 'none');
		}
		
		this.showPage(0);
	},	
	showPage: function(index) {
		if (index == this.pages) index = 0;			// Go to first item if the last item is reached
		if (index == -1) index = this.pages - 1;	// Go to last item if the first item is reached

		$(this.view).find('.items_page_container').removeClass('active');
		$(this.view).find('.items_page_container:eq(' + index + ')').addClass('active');

		for (var i = 0; i < index; i++) {
			$(this.view).find('.items_page_container:eq(' + i + ')').animate({left:((index - i) * -303) + 'px'}, this.config.animationSpeed);
		}
		$(this.view).find('.items_page_container:eq(' + index + ')').animate({left:'0px'}, this.config.animationSpeed);
		for (var i = index + 1; i < this.pages; i++) {
			$(this.view).find('.items_page_container:eq(' + i + ')').animate({left:((i - index) * 303) + 'px'}, this.config.animationSpeed);
		}

		this.slider.innerHTML = (index + 1) + '/' + this.pages;

		this.activeIndex = index;
	},
	showNextPage: function() {
		this.showPage(this.activeIndex + 1);
	},
	showPreviousPage: function() {
		this.showPage(this.activeIndex - 1);		
	},
	handleEvent: function(e) {
		try {
			switch (e.type) {
				case 'mousedown':
					switch ($(e.target).attr('class')) {
						case 'slider':
							this.drag = true;
							this.dragPosition = {x:e.layerX + parseInt($(this.slider).css('left')),y:e.layerY + parseInt($(this.slider).css('top'))};
							e.preventDefault();
							break;
						case 'slider_base':
							this.dragPosition = {x:e.layerX || event.x,y:e.layerY || event.y};
							this.drag = true;
							var leftPos = (this.dragPosition.x - ($(this.slider).width() / 2));
							if (leftPos < 20) leftPos = 20;
							if (leftPos > $(this.sliderContainer).width() - 20 - $(this.slider).width()) leftPos = $(this.sliderContainer).width() - 20 - $(this.slider).width();
							$(this.slider).css('left', leftPos + 'px');
						return;
							this.drag = true;
							break;
					}
					break;
				case 'mouseup':
					if (this.drag) {
						if (this.dragPosition.x < this.sliderStartPosition.x + ($(this.slider).width() / 2)) this.showPage(--this.activeIndex);
						if (this.dragPosition.x > this.sliderStartPosition.x + ($(this.slider).width() / 2)) this.showPage(++this.activeIndex);
					}
					this.drag = false;
					$(this.slider).css({left:this.sliderStartPosition.x + 'px'});
					break;
				case 'mousemove':
					if (this.drag && e.target == this.sliderContainer) {
						this.dragPosition = {x:e.layerX || event.x,y:e.layerY || event.y};
						var leftPos = (this.dragPosition.x - ($(this.slider).width() / 2));
						if (leftPos < 20) leftPos = 20;
						if (leftPos > $(this.sliderContainer).width() - 20 - $(this.slider).width()) leftPos = $(this.sliderContainer).width() - 20 - $(this.slider).width();
						$(this.slider).css({left:leftPos + 'px'});
					}
					break;
			}
		} catch(err) { /* We will simply ignore any errors that occur as they are irrelevant */ }
	}
};
_Core._._fct_banner_abstract = function(view, name) {this.__constructor(view, name);};

_Core._._fct_banner_abstract.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	views: {},
	view: {},
	controller: {},
	name: '',
	
	__constructor: function(view, name) {
		this.view 		= view;
		this.controller	= this;
		this.name		= name;
		var userConfig	= eval("(" + this.view.getAttribute('config') + ")");
		this.config		= _.processConfig(this.config, userConfig);
		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!
	
	config: {
		source: 			'',
		proxy: 				'service/proxy.php',
		maxItems: 			3,
		type: 				'image',
		cycle:				true,
		cycleSpeed:			0.1,
		animation:			true,
		animationSpeed: 	500
	},
	data: {},
	director: {},
	
	_constructor: function() { // Constructor for the module sub-object
		$(this.view).addClass(this.config.type);
		try {
			this.director = new this.views[this.config.type](this);		
		} catch(e) {
		}
	},
	run: function() {
		var func = eval("func = function() {\
							var target = _." + this.name + ";\
							target.getData();\
						}");
		func();
	},
	getData: function() {
		var func = eval("func = function(data) {\
							var target = _." + this.name + ";\
							target.processData(data);\
						}");
						
		if ($(this.view).find('.data').length != 0) {
			func($(this.view).find('.data')[0]);
			//$(this.view).find('.data').remove();
		} else {
			if (this.config.proxy != false && this.config.proxy != 'false') {
				_.comm.get(this.config.proxy + '?' + escape(this.config.source), this, func);
			} else {
				_.comm.get(this.config.source, this, func);
			}
		}
	},
	processData: function(data) {
		this.data = data;
		this.director.update();
	}
};
(function() {_.registerModule('fct_banner', '_fct_banner_abstract', 'fct_banner_widget')})(); // Module instantiation/registration

/* View definitions */
// Image view style
_Core._._fct_banner_abstract.prototype.views.image = function(controller) { this.__constructor(controller); };
_Core._._fct_banner_abstract.prototype.views.image.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	view: {},
	name: '',
	config: {},
	controller: {},
	
	__constructor: function(controller) {
		this.view 			= controller.view;
		this.name			= controller.name;
		this.config			= controller.config;
		this.controller 	= controller;
		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!

	image: function(image, title, linkurl, linktarget) { 
		var anchor = document.createElement('a');
		anchor.setAttribute('href', linkurl);
		anchor.setAttribute('target', linktarget);
		//anchor.setAttribute('class', 'banner');
		anchor.className = 'banner';
		
		var img = document.createElement('img'); 
		img.setAttribute('src', image);
		img.setAttribute('alt', title);
		img.setAttribute('title', title);
		//img.setAttribute('class', 'banner');
		img.className = 'banner';
		
		anchor.appendChild(img);
		
		return anchor; 
	},
	overlay: function(title, linkurl, linktarget) { 
		var anchor = document.createElement('a');
		anchor.setAttribute('href', linkurl);
		anchor.setAttribute('target', linktarget);
		anchor.setAttribute('title', title);
		//anchor.setAttribute('class', 'caption');
		anchor.className = 'caption';

		var div = document.createElement('div'); 
		//div.setAttribute('class', 'link_overlay');
		div.className = 'link_overlay';
		
		var icon = document.createElement('div');
		//icon.setAttribute('class', 'icon');
		icon.className = 'icon';
		
		div.appendChild(document.createTextNode(title));
		div.appendChild(icon);
		
		anchor.appendChild(div); 
		return anchor; 
	},
	items: [],
	activeIndex: -1,
	
	_constructor: function() {
		if ($.browser.mozilla) $(this.view).css({ 'MozUserSelect' : 'none' });
		else if ($.browser.msie) $(this.view).bind('selectstart.disableTextSelect', function() { return false; });
		else $(this.view).bind('mousedown.disableTextSelect', function() { return false; });

		if (this.config.style == 'small') {
			$(this.view).css({height:'125px'});
		} else {
			$(this.view).css({height:'260px'});
		}

		if (this.config.cycle == true || this.config.cycle == 'true') {
			var func = eval("func = function() {\
						var target = _." + this.name + ".director;\
						target.showNextBanner();\
					}");

			if (this.interval != -1) clearInterval(this.interval);
			this.interval = setInterval(func, this.config.cycleSpeed * 60 * 1000);
		}
	},
	update: function() {
		this.items 	= $(this.controller.data).find('item, .item');
		this.preloadImages();
		this.showBanner(0);
	},
	preloadImages: function() {
		for (var i = 0; i < this.items.length; i++) {
			var image 		= new Image();
			var imageSrc	= $(this.items[i]).find('banner, .banner').text();
			image.src 		= imageSrc;
		}
	},
	showBanner: function(index) {
		if (index == this.items.length) index = 0;			// Go to first item if the last item is reached
		if (index == -1) index = this.items.length - 1;		// Go to last item if the first item is reached
		if (index == this.activeIndex) return;
		
		var item 		= this.items[index];
		var banner		= $(item).find('banner, .banner').text();
		var title 		= $(item).find('title, .title').text();
		var linkurl 	= $(item).find('linkurl, .linkurl').text();
		var linktarget	= $(item).find('linktarget, .linktarget').text();
		var linktext	= $(item).find('linktext, .linktext').text();
		
		if (this.config.animation == true || this.config.animation == 'true') {
			$(this.view).find('a.caption').remove();
			$(this.view).find('a.banner').fadeOut(this.config.animationSpeed, function(){$(this).remove();});
			if (linktext != '') {
				$(this.view).prepend(this.overlay(linktext, linkurl, linktarget));
			}
			$(this.view).prepend(this.image(banner, title, linkurl, linktarget));
			$(this.view).find('a.banner:first').fadeOut(0).fadeIn(this.config.animationSpeed);
		} else {
			$(this.view).find('a.caption, a.banner').remove();
			if (linktext != '') {
				$(this.view).prepend(this.overlay(linktext, linkurl, linktarget));
			}
			$(this.view).prepend(this.image(banner, title, linkurl, linktarget));
		}
		
		this.activeIndex = index;
	},
	showNextBanner: function() {
		this.showBanner(this.activeIndex + 1);
	},
	showPreviousBanner: function() {
		this.showBanner(this.activeIndex - 1);
	}
};

/* View definitions */
// Flash view style
_Core._._fct_banner_abstract.prototype.views.flash = function(controller) { this.__constructor(controller); };
_Core._._fct_banner_abstract.prototype.views.flash.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	view: {},
	name: '',
	config: {},
	controller: {},
	
	__constructor: function(controller) {
		this.view 			= controller.view;
		this.name			= controller.name;
		this.config			= controller.config;
		this.controller 	= controller;
		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!

	swf: function(swf, title) { 
		var div = document.createElement('div');
		div.setAttribute('class', 'banner');
		this.swf = div;
		return div; 
	},
	items: [],
	
	_constructor: function() {
		if ($.browser.mozilla) $(this.view).css({ 'MozUserSelect' : 'none' });
		else if ($.browser.msie) $(this.view).bind('selectstart.disableTextSelect', function() { return false; });
		else $(this.view).bind('mousedown.disableTextSelect', function() { return false; });

		if (this.config.style == 'small') {
			$(this.view).css({height:'125px'});
		} else {
			$(this.view).css({height:'260px'});
		}
	},
	update: function() {
		this.items 	= $(this.controller.data).find('item, .item');
		this.showBanner(0);
	},
	showBanner: function(index) {
		if (index == this.items.length) index = 0;			// Go to first item if the last item is reached
		if (index == -1) index = this.items.length - 1;		// Go to last item if the first item is reached
		if (index == this.activeIndex) return;
		
		var item 		= this.items[index];
		var banner		= $(item).find('banner, .banner').text();
		var title 		= $(item).find('title, .title').text();
		
		this.view.appendChild(this.swf());
		_.flash.replace(this.swf, banner, this.name + '_swf', '100%', '100%');
		this.activeIndex = index;
	}
};
_Core._._fct_radio_abstract = function(view, name) {this.__constructor(view, name);};

_Core._._fct_radio_abstract.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	views: {},
	view: {},
	controller: {},
	name: '',
	
	__constructor: function(view, name) {
		this.view 		= view;
		this.controller	= this;
		this.name		= name;
		var userConfig	= eval("(" + this.view.getAttribute('config') + ")");
		this.config		= _.processConfig(this.config, userConfig);
		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!
	
	config: {
		type: 				'compact',
		title:				'FC Twente Radio',
		playerUrl:			'radio/swf/player.swf',
		serviceUrl:			'radio/service.php',
		streamConfig:		'radio/stream.xml',
		autoStart:			'1',
		nowPlaying:			true,
		nowPlayingText:		''
	},
	data: {},
	director: {},
	interval: -1,
	
	_constructor: function() { // Constructor for the module sub-object
		$(this.view).addClass(this.config.type);
		try {
			this.director = new this.views[this.config.type](this);		
		} catch(e) {
		}
	},
	run: function() {
		//return;
		if (this.config.nowPlaying == true || this.config.nowPlaying == 'true') {
			var func = eval("func = function() {\
								var target = _." + this.name + ";\
								target.getData();\
							}");
	
			this.interval = setInterval(func, 10000);
			func();
		}		
	},
	getData: function() {
		var func = eval("func = function(data) {\
							var target = _." + this.name + ";\
							target.processData(data);\
						}");
						
		_.comm.getJSON(this.config.serviceUrl + '?get=nowplaying', this, func);
	},
	processData: function(data) {
		this.data = data;
		this.director.update();
	}
};
(function() {_.registerModule('fct_radio', '_fct_radio_abstract', 'fct_radio_widget');})(); // Module instantiation/registration

/* View definitions */
// Compact radio view style
_Core._._fct_radio_abstract.prototype.views.compact = function(controller) { this.__constructor(controller); };
_Core._._fct_radio_abstract.prototype.views.compact.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	view: {},
	name: '',
	config: {},
	controller: {},
	
	__constructor: function(controller){
		this.view = controller.view;
		this.name = controller.name;
		this.config = controller.config;
		this.controller = controller;
		
		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!
	
	interval: -1,
	lastData: null,
	currentStatus: 'next',
	
	titleHeader: function(title) {
		var div = document.createElement('div');
		//div.setAttribute('class', 'title_header');
		div.className = 'title_header';
		div.appendChild(document.createTextNode(title.toUpperCase()));
		this.titleHeader = div;
		return div;
	},
	content: function(){
		var div = document.createElement('div');
		//div.setAttribute('class', 'content');
		div.className = 'content';
		this.content = div;
		div.appendChild(this.swf());
		div.appendChild(this.info());
		return div;
	},
	info: function() {
		var div = document.createElement('div');
		//div.setAttribute('class', 'info');
		div.className = 'info';
		
		/* begin added by FPL */
		var anchor = document.createElement('a');
		anchor.href = '/radio/';
		anchor.onclick = function() {window.open(this.href, '_player', 'toolbar=false,status=false,menubar=false,scrollbars=false,resizable=false,width=600,height=430');return false;};
		anchor.className = 'radiopopup';
		div.appendChild(anchor);
		/* end added by FPL */
		
		this.info = div;
		return div;
	},
	swf: function(swf, title) { 
		var div = document.createElement('div');
		//div.setAttribute('class', 'player');
		div.className = 'player';
		this.swf = div;
		return div; 
	},
	
	_constructor: function(){
		//if ($.browser.mozilla) $(this.view).css({ 'MozUserSelect' : 'none' });
		//else if ($.browser.msie) $(this.view).bind('selectstart.disableTextSelect', function() { return false; });
		//else $(this.view).bind('mousedown.disableTextSelect', function() { return false; });

		this.view.appendChild(this.titleHeader(this.config.title));
		this.view.appendChild(this.content());

		_.flash.replace(this.swf, this.config.playerUrl, this.name + '_swf', 145, 45, 7, {allowScriptAccess: 'sameDomain', wmode:'opaque', flashvars:'buttonColor=black&sourcePath=' + this.config.streamConfig + '&autoStart=' + this.config.autoStart + '&widgetName=' + this.controller.name});
		
		if (this.config.nowPlaying == true || this.config.nowPlaying == 'true') {
			this.setUpdateInterval();
		}
	},
	setUpdateInterval: function()
	{
		var func = eval("func = function() {\
				var target = _." + this.name + ".director;\
				target.update();\
			}");

		if (this.interval != -1) clearInterval(this.interval);
		this.interval = setInterval(func, 10000);
	},
	playFromFlash: function()
	{
		if (this.config.nowPlaying == true || this.config.nowPlaying == 'true') {
			this.controller.run();
			this.setUpdateInterval();
		} else {
			this.update();
		}
	},
	update: function(){
		if (this.config.nowPlaying == true || this.config.nowPlaying == 'true') {
			var data = this.controller.data;
			if (this.lastData != this.controller.data) {
				if (this.currentStatus == 'next') {
					this.info.innerHTML = '<strong>Nu: </strong>' + data.current.artist + ' - ' + data.current.song + ' (' + data.current.duration + ')' + (data.current.requested ? ' -aangevraagd-' : '');
					this.currentStatus = 'current';
				} else {
					if (data.following.length > 0) {
						this.info.innerHTML = '<strong>Straks: </strong>' + data.following[0].artist + ' - ' + data.following[0].song + ' (' + data.following[0].duration + ')'  + (data.following[0].requested ? ' -aangevraagd-' : '');
					} else {
						this.info.innerHTML = '<strong>Straks: </strong> -';
					}
					this.currentStatus = 'next';
				}
			}
			this.lastData = data;
		} else {
			if (this.config.nowPlayingText != '') {
				this.info.innerHTML = '<strong>Nu: </strong>' + this.config.nowPlayingText;
			}
		}
	}
};

/* View definitions */
// Standalone radio view style
_Core._._fct_radio_abstract.prototype.views.standalone = function(controller) { this.__constructor(controller); };
_Core._._fct_radio_abstract.prototype.views.standalone.prototype = {
	// START: BASE CODE OF MODULE, DO NOT CHANGE!
	view: {},
	name: '',
	config: {},
	controller: {},
	
	__constructor: function(controller){
		this.view = controller.view;
		this.name = controller.name;
		this.config = controller.config;
		this.controller = controller;
		
		this._constructor();
	},
	// END: BASE CODE OF MODULE, DO NOT CHANGE!
	
	interval: -1,
	keyTimeout: -1,
	lastData: null,
	visibleStatus: 'next',
	
	_constructor: function() {
		var func = eval("func = function(data) {\
							var target = _." + this.name + ".director;\
							target.renderInterface(data);\
						}");
		_.comm.get('interface/main-interface.html', this, func);		
	},
	renderInterface: function(html) {
		$(this.view).html(html);
		_.flash.replace($(this.view).find('.player')[0], this.config.playerUrl, this.name + '_swf', 145, 45 , 7, {wmode:'opaque', flashvars:'buttonColor=black&sourcePath=' + this.config.streamConfig + '&autoStart=1' + '&widgetName=' + this.controller.name});
		this.getTabContent('program');
		
		var func = eval("func = function(e) {\
							var target = _." + this.name + ".director;\
							target.handleEvent(e);\
						}");
								
		$(this.view).find('.tabs').bind('mousedown', func);
		$(this.view).find('.tabs').bind('keyup', func);
	},
	getTabContent: function(contenttype, arguments) {
		var func = eval("func = function(data) {\
							var target = _." + this.name + ".director;\
							target.processTabContent('" + contenttype + "', data);\
						}");
						
		if (typeof arguments != 'undefined') {
		 	_.comm.get(this.config.serviceUrl + '?get=' + contenttype + '&' + arguments, this, func);
		} else {
		 	_.comm.get(this.config.serviceUrl + '?get=' + contenttype, this, func);
		}
	},
	processTabContent: function(contenttype, data) {
		$(this.view).find('.' + contenttype).html(data);
		$(this.view).find('input[type=radio]').before('<span class="radiobutton" title="Klik hier om het nummer te selecteren om deze aan te vragen"></span>');
	},
	activateTab: function(tab) {
		var content = $('.' + $(tab).attr('rel'));
		$('.tab, .tabcontent').removeClass('active');
		$([tab, content[0]]).addClass('active');

		var contenttype = $(content).attr('class').split(' ')[0];
		this.getTabContent(contenttype);
	},
	doSearch: function(searchquery, searchchar, start) {
		var func = eval("func = function(data) {\
							var target = _." + this.name + ".director;\
							target.processSearch(data);\
						}");

		if (typeof start == 'undefined') start = 0;

		if (searchquery != null && searchquery != false) {
			_.comm.get(this.config.serviceUrl + '?get=request&table=true&query=' + escape(searchquery) + '&start=' + start, this, func);
		} else if (searchchar != null && searchchar != false){
			_.comm.get(this.config.serviceUrl + '?get=request&table=true&char=' + escape(searchchar) + '&start=' + start, this, func);
		} else {
			_.comm.get(this.config.serviceUrl + '?get=request&table=true&start=' + start, this, func);
		}
	},
	processSearch: function(data) {
		$(this.view).find('.result').html(data);
		$(this.view).find('input[type=radio]').before('<span class="radiobutton" title="Klik hier om het nummer te selecteren om deze aan te vragen"></span>');
	},
	requestSong: function(name, song) {
		if (typeof song == 'undefined') {
			$(this.view).find('.requeststatus').html('Er is geen nummer geselecteerd, selecteer een nummer en probeer het opnieuw');
		} else {
			var func = eval("func = function(data) {\
								var target = _." + this.name + ".director;\
								target.processRequest(data);\
							}");
			
			if (name == '') 
				name = 'Anonymous';
			
			_.comm.getJSON(this.config.serviceUrl + '?get=dorequest&song=' + song + '&name=' + escape(name), this, func);
		}
	},
	processRequest: function(data) {
		if (data.status.code == 200) {
			$(this.view).find('.requeststatus').html('Aanvraag verwerkt');
		} else {
			$(this.view).find('.requeststatus').html('Aanvraag mislukt, probeer het later nog eens');
		}
	},
	update: function(){
		var data = this.controller.data;
		if (this.lastData != this.controller.data) {
			$(this.view).find('.now').html('<strong>Nu: </strong>' + data.current.artist + ' - ' + data.current.song + ' (' + data.current.duration + ')' + (data.current.requested ? ' -aangevraagd-' : ''));
			
			if (data.following.length > 0) {
				$(this.view).find('.next').html('<strong>Straks: </strong>' + data.following[0].artist + ' - ' + data.following[0].song + ' (' + data.following[0].duration + ')' + (data.following[0].requested ? ' -aangevraagd-' : ''));
			} else {
				$(this.view).find('.next').html('<strong>Straks: </strong> -');
			}
		}
		this.lastData = data;
	},
	handleEvent: function(e){
		switch (e.type) {
			case 'mousedown':
				if ($(e.target).hasClass('tab')) {
					this.activateTab(e.target);
				}
				if ($(e.target).hasClass('searchsubmit')) {
					this.doSearch($(this.view).find('.searchinput').attr('value'), null);
				}
				if ($(e.target).hasClass('radiobutton')) {
					$(this.view).find('.radiobutton').removeClass('active');
					$(e.target).addClass('active');
					$(e.target).next('input[type=radio]').attr('checked', 'checked');
				}
				if ($(e.target).hasClass('filter')) {
					var letter = $(e.target).text();
					this.doSearch(null, letter);
				}
				if ($(e.target).hasClass('page')) {
					var data = eval('(' + $(e.target).attr('data') + ')');
					this.doSearch(data.search, data.char, data.start);
				}
				if ($(e.target).hasClass('requestsubmit')) {
					var name = $(this.view).find('.nameinput').val();
					var song = $(this.view).find('input[type=radio]:checked').val();
					this.requestSong(name, song);
				}
				break;
			case 'keyup':
				if ($(e.target).hasClass('searchinput')) {
					var func = eval("func = function(e) {\
										var target = _." + this.name + ".director;\
										target.keyTimeout = -1;\
										target.doSearch('" + $(e.target).attr('value') + "');\
									}");
					if (this.keyTimeout != -1) {
						clearTimeout(this.keyTimeout);
						this.keyTimeout = -1;
					}
					this.keyTimeout = setTimeout(func, 1000);
				}
				break;
		}
	}
};

