/* JavaScript Cache File generated by CMX at Fri, 08 May 2009 22:23:38. */

/** File: ../javascripts/00-default.js */

if (window != top) {
	top.location.href = location.href;
}

function Goto(url) {
	if (url != null && url != "" && url != "none")
		window.location.href = url;
	else
		return false;
}

function ConfirmGoto(url) {
	if (confirm("Weet je zeker dat je door wilt gaan?")) {
		if (url != null && url != "" && url != "none")
			window.location.href = url;
		else
			return true;
	}

	return false;
}

/** File: ../javascripts/01-class.jsEffect.js */

function copyPrototype(descendant, parent) {
	var sConstructor	= parent.toString();
	var aMatch	= sConstructor.match( /\s*function (.*)\(/ );
	if ( aMatch != null ) { descendant.prototype[aMatch[1]] = parent; }
	for (var m in parent.prototype) {
		descendant.prototype[m] = parent.prototype[m];
	}
};


var jsEffect = jseffect = {};
/**
 * Core Class with basic effect implementation
 */
jsEffect.Core = function Core(elmid, fps, transition) {
	if (elmid == null) alert('Missing required first parameter "element" or "elementID".');

	this.element	= typeof elmid == "object" ? elmid : document.getElementById(elmid);
	this.fps		= fps != null ? fps : 100;
	this.unit		= "px";
	this.transition	= transition != null ? transition : jsEffect.Transitions.smoothInOut;

	this.wait		= false;
	this.queue		= new Array();

	return this;
};
jsEffect.Core.prototype	= {
	setElm :	function(elmid) {
		var _this	= this;
		if (this._checkWait(function () { _this.setElm(elmid) })) {
			this.element	= typeof elmid == "object" ? elmid : document.getElementById(elmid);
		}
		return this;
	},
	setFps :	function(fps) {
		var _this	= this;
		if (this._checkWait(function () { _this.setFps(fps) }))
			this.fps	= fps;
		return this;
	},
	setUnit :	function(unit) {
		var _this	= this;
		if (this._checkWait(function () { _this.setUnit(unit) }))
			this.unit	= unit;
		return this;
	},
	setTrans :	function(transition) {
		var _this	= this;
		if (this._checkWait(function () { _this.setTrans(transition) }))
			this.transition	= transition;
		return this;
	},

	custom :	function(begin, end, duration) {
		var _this	= this;
		if (!this._checkWait(function () { _this.custom(begin, end, duration) }))
			return this;

		this.wait		= true;

		var change		= end - begin;
		var sTime		= new Date().getTime();

		this.startStyle(begin);

		if (change == 0 || duration == 0) {
			this.finishStyle(Math.round(end));
			return this.resume();
		}

		var func	= function() {
			var cTime	= new Date().getTime() - sTime;
			if (cTime > duration) return;
			_this.setStyle(Math.round(_this.transition(cTime, begin, change, duration)));
			_this.timer	= setTimeout(func, 1000 / this.fps);
		}
		func();

		/*this.timer	= setInterval(function() {
		}, 1000 / this.fps);*/

		setTimeout(function() {
			clearTimeout(_this.timer);
			_this.finishStyle(Math.round(end));
			_this.resume();
		}, duration);

		return this;
	},

	set :		function(value) {
		this.startStyle(value);
		return this;
	},

	pause :		function(duration) {
		this.wait	= true;
		var _this	= this;
		if (duration && duration > 0) {
			setTimeout(function() {	_this.resume() }, duration);
		}
		return this;
	},

	resume :		function() {
		this.wait	= false;
		this._execQueue();
		return this;
	},

	execute :		function(func) {
		if (this._checkWait(func)) func.apply();
		return this;
	},

	_checkWait :	function(func) {
		if (this.wait) {
			this.queue[this.queue.length]	= func;
			return false;
		}
		return true;
	},

	_execQueue :	function() {
		while (this.queue.length > 0) {
			if (this.wait) return false;
			this.queue.shift().apply();
		}

		return true;
	}
};


/**
 * Opacity effect class
 */
jsEffect.Opacity = function (elmid, fps, transition) { this.Core(elmid, fps, transition) }
jsEffect.Opacity.prototype	= {
	startStyle :	function(value) {
		this.setStyle(value);
		this.element.style.visibility	= "visible";
	},

	setStyle :		function(value) {
		this.element.style.opacity		= value / 100;
		this.element.style.filter		= "alpha(opacity=" + value + ")";
	},

	finishStyle :	function(value) {
		if (value == 0)
			this.element.style.visibility	= "hidden";
		this.setStyle(value);
	},

	show :			function(duration) {
		return this.custom(0, 100, duration);
	},

	hide :			function(duration) {
		var current = !this.current ? 100 : this.current;
		return this.custom(current, 0, duration);
	}
};
copyPrototype(jsEffect.Opacity, jsEffect.Core);


/**
 * Height slide effect class
 */
jsEffect.Height = function (elmid, fps, transition) { this.Core(elmid, fps, transition) }
jsEffect.Height.prototype	= {
	startStyle :	function(value) {
		this.overflow	= this.element.style.overflow;
		this.setStyle(value);
		this.element.style.overflow		= "hidden"
		this.element.style.visibility	= "visible";
	},

	setStyle :		function(value) {
		this.element.style.height	= value + this.unit;
	},

	finishStyle :	function(value) {
		this.setStyle(value);
		this.element.style.overflow		= this.overflow;
		if (value == 0)
			this.element.style.visibility	= "hidden";
	},

	show :			function(duration) {
		if (this.unit == "%")
			var height	= 100;
		else
			var height	= this.element.clip ? this.element.clip.height : this.element.offsetHeight;
		return this.custom(0, height, duration);
	},

	hide :			function(duration) {
		if (this.unit == "%")
			var height	= 100;
		else
			var height	= this.element.clip ? this.element.clip.height : this.element.offsetHeight;
		return this.custom(height, 0, duration);
	}
};
copyPrototype(jsEffect.Height, jsEffect.Core);


/**
 * Width slide effect class
 */
jsEffect.Width = function (elmid, fps, transition) { this.Core(elmid, fps, transition) }
jsEffect.Width.prototype	= {
	startStyle :	function(value) {
		this.overflow	= this.element.style.overflow;
		this.setStyle(value);
		this.element.style.overflow	= "hidden"
		this.element.style.visibility	= "visible";
	},

	setStyle :		function(value) {
		this.element.style.width	= value + this.unit;
	},

	finishStyle :	function(value) {
		this.setStyle(value);
		this.element.style.overflow		= this.overflow;
		if (value == 0)
			this.element.style.visibility	= "hidden";
	},

	show :			function(duration) {
		if (this.unit == "%")
			var height	= 100;
		else
			var width	= this.element.clip ? this.element.clip.width : this.element.offsetWidth;
		return this.custom(0, width, duration);
	},

	hide :			function(duration) {
		if (this.unit == "%")
			var height	= 100;
		else
			var width	= this.element.clip ? this.element.clip.width : this.element.offsetWidth;
		alert(height);
		return this.custom(width, 0, duration);
	}
};
copyPrototype(jsEffect.Width, jsEffect.Core);


/**
 * Horizontal slide effect class
 */
jsEffect.Horizontal = function (elmid, fps, transition) { this.Core(elmid, fps, transition) }
jsEffect.Horizontal.prototype	= {
	startStyle :	function(value) {
		this.overflow	= this.element.style.overflow;
		this.setStyle(value);
	},

	setStyle :		function(value) {
		this.element.style.marginLeft	= value + this.unit;
	},

	finishStyle :	function(value) {
		this.setStyle(value);
		this.element.style.overflow		= this.overflow;
	},

	show :			function(duration) {
		if (this.unit == "%")
			return alert('Unsupported unit.');
		else
			var left	= this.element.clip ? this.element.clip.width : this.element.offsetWidth;
		return this.custom(left, 0, duration);
	},

	hide :			function(duration) {
		if (this.unit == "%")
			return alert('Unsupported unit.');
		else
			var left	= this.element.clip ? this.element.clip.width : this.element.offsetWidth;
		return this.custom(0, -left, duration);
	}
};
copyPrototype(jsEffect.Horizontal, jsEffect.Core);


/**
 * Transitions Class with all available transitions
 */
jsEffect.Transitions	= {
	bounceIn :		function(t, b, c, d) {
		return c - jsEffect.Transitions.bounceOut(d - t, 0, c, d) + b;
	},

	bounceOut :		function(t, b, c, d) {
		if ((t /= d) < (1 / 2.75))
			return c * (7.5625 * t * t) + b;
		else if (t < (2 / 2.75))
			return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
		else if (t < (2.5 / 2.75))
			return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
		else
			return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
	},

	bounceInOut :	function(t, b, c, d) {
		if (t < d / 2) return jsEffect.Transitions.bounceIn(t * 2, 0, c, d) * .5 + b;
		return jsEffect.Transitions.bounceOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
	},

	linear :		function linear(t, b, c, d) {
		return c * t / d + b;
	},

	smoothIn :		function(t, b, c, d) {
		return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
	},

	smoothOut :		function(t, b, c, d) {
		return c * Math.sin(t / d * (Math.PI / 2)) + b;
	},

	smoothInOut :	function smoothInOut(t, b, c, d) {
		return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
	}
};

/** File: ../javascripts/02-function.showPhoto.js */

var duration = 1500, interval = 5000;
var sliderbusy = false, newurl;
var photoback, photofront, backElm, frontElm;

function photoback_onload() {
	backElm.setAttribute('src', photoback.src);

	// Element centreren
	centerElement(backElm);

	// Laat de achtergrond zien en verberg voorgrond
	new jsEffect.Opacity(backElm).show(0).setElm(frontElm).hide(0).execute(function() {
		photofront.src	= newurl;
	});
};

function photofront_onload() {
	frontElm.setAttribute('src', photofront.src);

	// Element centreren
	centerElement(frontElm)

	// Laat voorgrond met effect zien en verberg achtergrond met effect
	var fmLeft	= parseInt(frontElm.style.marginLeft);
	var bmLeft	= parseInt(backElm.style.marginLeft);

	new jsEffect.Opacity(backElm).hide(duration);
	new jsEffect.Horizontal(backElm).custom(bmLeft, bmLeft - backElm.clientWidth, duration);

	new jsEffect.Horizontal(frontElm).setTrans(jsEffect.Transitions.bounceOut).pause(500).custom(fmLeft + frontElm.clientWidth, fmLeft, duration);
	new jsEffect.Opacity(frontElm).pause(500).show(duration).execute(function() {
		sliderbusy = false;
	});
};


function showPhoto(url) {
	if (sliderbusy) return;
	sliderbusy = true;

	if (!backElm || !frontElm) {
		backElm		= document.getElementById('photo-back');
		frontElm	= document.getElementById('photo-front');

		if (!backElm || !frontElm) {
			alert('Image containers cannot be found.');
			return;
		}
	}

	photoback	= document.createElement('img');
	photofront	= document.createElement('img');

	photoback.onload	= photoback_onload;
	photofront.onload	= photofront_onload;

	newurl = url;
	photoback.src = frontElm.getAttribute('src');
};

function startSlideShow(photos) {
	if (photos.length == 0) return;

	showPhoto(photos[0]);

	if (photos.length == 1) return;

	var i = 1;

	setInterval(function slideLoop() {
		if (i == photos.length) i = 0;
		showPhoto(photos[i]);
		i++;
	}, interval);
};


function centerElement(elm) {
	elm.style.left	= "50%";
	elm.style.top	= "50%";

	elm.style.marginLeft	= (0 - (elm.clientWidth / 2)) + "px";
	elm.style.marginTop		= (0 - (elm.clientHeight / 2)) + "px";
};
