/* Merged Plone Javascript file
 * This file is dynamically assembled from separate parts.
 * Some of these parts have 3rd party licenses or copyright information attached
 * Such information is valid for that section,
 * not for the entire composite file
 * originating files are separated by - filename.js -
 */

/* - ++resource++coolregionskin.javascripts/jquery.fourdigitsSchedule.js - */
// http://www.coolregion.nl/portal_javascripts/++resource++coolregionskin.javascripts/jquery.fourdigitsSchedule.js?original=1
;(function($){$.fn.fourdigitsSchedule=function(options){var optionsDefaults={interval:1000,times:0,increment:0,label:'main',fn: function(){}};options=$.extend(optionsDefaults,options);if(typeof(options.interval)!='number'){options.interval=optionsDefaults.interval}
if(typeof(options.times)!='number'){options.times=optionsDefaults.times}
if(typeof(options.increment)!='number'){options.increment=optionsDefaults.increment}
if(typeof(options.label)!='string'){options.label=optionsDefaults.label}
if(typeof(options.fn)!='function'){options.fn=optionsDefaults.fn}
return this.each(function(){var obj=this;var tasks=$(obj).data('tasks');if(!tasks){tasks=new Array();$(obj).data('tasks',tasks)}
if(tasks[options.label]){window.clearTimeout(tasks['label'].id);delete tasks[options.label]}
var fn=function(){var tasks=$(obj).data('tasks');if(!tasks||!tasks[options.label]||tasks[options.label].running){return}
tasks[options.label].running=true;tasks[options.label].fn.call(obj);tasks[options.label].interval+=tasks[options.label].increment;tasks[options.label].interval=tasks[options.label].interval<=0?1:tasks[options.label].interval;if((tasks[options.label].increment!=0&&tasks[options.label].times!=1)||(tasks[options.label].times>1)){tasks[options.label].id=window.setTimeout(fn,tasks[options.label].interval)}
if(tasks[options.label].times>1){tasks[options.label].times--}
tasks[options.label].running=false}
tasks[options.label]={running:false,times:options.times,increment:options.increment,interval:options.interval,fn:options.fn}
if(options.times==0&&options.increment==0){tasks[options.label].id=window.setInterval(fn,options.interval)} else{tasks[options.label].id=window.setTimeout(fn,options.interval)}
$(obj).data('tasks',tasks)})};$.fn.fourdigitsScheduleRemove=function(label){return this.each(function(){var tasks=$(this).data('tasks');if(!tasks){tasks=new Array()}
if(tasks[options.label]){window.clearTimeout(tasks['label'].id);delete tasks[options.label];$(this).data('tasks',tasks)}})}})(jQuery);

/* - ++resource++coolregionskin.javascripts/jquery.fourdigitsRotateCoolHeader.js - */
// http://www.coolregion.nl/portal_javascripts/++resource++coolregionskin.javascripts/jquery.fourdigitsRotateCoolHeader.js?original=1
;(function($){$.fn.fourdigitsRotateCoolHeader=function(options){var optionsDefaults={interval:2000,rightitemselector:"div",centerselector:"#centerselector",centeritemselector:"img",pauseonmouseover:true,start:0};for(key in options){if(typeof(options[key])!=typeof(optionsDefaults[key])){options[key]=optionsDefaults[key]}}
options=$.extend(optionsDefaults,options);return this.each(function(){var obj=this;var centerobj=$(options.centerselector);options.totalitems=$(options.rightitemselector,obj).length;options.mouseover=false;options.curitem=options.start>=options.totalitems?0:options.start;$(obj).data('options',options);$(options.rightitemselector,obj).each(function(i){if(i!=options.curitem){$(this).hide()}});$(options.centeritemselector,centerobj).each(function(i){if(i!=options.curitem){$(this).hide()}});$(obj).fourdigitsSchedule({interval:options.interval,fn: function(){var obj=this;var options=$(obj).data('options');var centerobj=$(options.centerselector);if(options.mouseover&&options.pauseonmouseover){return}
var nextitem=options.curitem==options.totalitems-1?0:options.curitem+1;$($(options.rightitemselector,obj).get(nextitem)).show();$($(options.centeritemselector,centerobj).get(nextitem)).show();$($(options.rightitemselector,obj).get(options.curitem)).hide();$($(options.centeritemselector,centerobj).get(options.curitem)).hide();options.curitem=nextitem}});$(obj).mouseover(function(){var options=$(this).data('options');options.mouseover=true});$(obj).mouseout(function(){var options=$(this).data('options');options.mouseover=false})})};$.fn.fourdigitsRotateCoolHeaderImageLoader=function(){$.getJSON(portal_url+"/@@getCoolHeaders", function(data){toload=data.length;loaded=0;var loadedevent=function(){loaded++;if(loaded==toload){$.each(data, function(i,item){if(i>0){$('<img class="headerimg" alt="'+item.Title+'" src="'+item.centerimage+'"  />').appendTo("#portal_header_center_img")}});$("#portal_header_right_img").fourdigitsRotateCoolHeader({centerselector:'#portal_header_center_img',interval:10000})}}
var errorevent=loadedevent;$.each(data, function(i,item){$('<img src="'+item.centerimage+'" />').load(loadedevent).error(errorevent)})})}})(jQuery);

/* - ++resource++coolregionskin.javascripts/jquery.fourdigitsRotateCoolHeaderInit.js - */
// http://www.coolregion.nl/portal_javascripts/++resource++coolregionskin.javascripts/jquery.fourdigitsRotateCoolHeaderInit.js?original=1
;(function($){$(document).ready(function(){$('#portal_header_center_img').each(function(){var runner=function(){$('#portal_header_right_img').fourdigitsRotateCoolHeaderImageLoader()}
setTimeout(runner,1500)})})})(jQuery);

/* - ++resource++collective.roundabout.javascripts/jquery.timers.js - */
﻿/**
 * jQuery.timers - Timer abstractions for jQuery
 * Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
 * Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
 * Date: 2008/08/26
 *
 * @author Blair Mitchelmore
 * @version 1.0.0
 *
 **/

jQuery.fn.extend({
	everyTime: function(interval, label, fn, times, belay) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, times, belay);
		});
	},
	oneTime: function(interval, label, fn) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, 1);
		});
	},
	stopTime: function(label, fn) {
		return this.each(function() {
			jQuery.timer.remove(this, label, fn);
		});
	}
});

jQuery.extend({
	timer: {
		guid: 1,
		global: {},
		regex: /^([0-9]+)\s*(.*s)?$/,
		powers: {
			// Yeah this is major overkill...
			'ms': 1,
			'cs': 10,
			'ds': 100,
			's': 1000,
			'das': 10000,
			'hs': 100000,
			'ks': 1000000
		},
		timeParse: function(value) {
			if (value == undefined || value == null)
				return null;
			var result = this.regex.exec(jQuery.trim(value.toString()));
			if (result[2]) {
				var num = parseInt(result[1], 10);
				var mult = this.powers[result[2]] || 1;
				return num * mult;
			} else {
				return value;
			}
		},
		add: function(element, interval, label, fn, times, belay) {
			var counter = 0;
			
			if (jQuery.isFunction(label)) {
				if (!times) 
					times = fn;
				fn = label;
				label = interval;
			}
			
			interval = jQuery.timer.timeParse(interval);

			if (typeof interval != 'number' || isNaN(interval) || interval <= 0)
				return;

			if (times && times.constructor != Number) {
				belay = !!times;
				times = 0;
			}
			
			times = times || 0;
			belay = belay || false;
			
			if (!element.$timers) 
				element.$timers = {};
			
			if (!element.$timers[label])
				element.$timers[label] = {};
			
			fn.$timerID = fn.$timerID || this.guid++;
			
			var handler = function() {
				if (belay && this.inProgress) 
					return;
				this.inProgress = true;
				if ((++counter > times && times !== 0) || fn.call(element, counter) === false)
					jQuery.timer.remove(element, label, fn);
				this.inProgress = false;
			};
			
			handler.$timerID = fn.$timerID;
			
			if (!element.$timers[label][fn.$timerID]) 
				element.$timers[label][fn.$timerID] = window.setInterval(handler,interval);
			
			if ( !this.global[label] )
				this.global[label] = [];
			this.global[label].push( element );
			
		},
		remove: function(element, label, fn) {
			var timers = element.$timers, ret;
			
			if ( timers ) {
				
				if (!label) {
					for ( label in timers )
						this.remove(element, label, fn);
				} else if ( timers[label] ) {
					if ( fn ) {
						if ( fn.$timerID ) {
							window.clearInterval(timers[label][fn.$timerID]);
							delete timers[label][fn.$timerID];
						}
					} else {
						for ( var fn in timers[label] ) {
							window.clearInterval(timers[label][fn]);
							delete timers[label][fn];
						}
					}
					
					for ( ret in timers[label] ) break;
					if ( !ret ) {
						ret = null;
						delete timers[label];
					}
				}
				
				for ( ret in timers ) break;
				if ( !ret ) 
					element.$timers = null;
			}
		}
	}
});

if (jQuery.browser.msie)
	jQuery(window).one("unload", function() {
		var global = jQuery.timer.global;
		for ( var label in global ) {
			var els = global[label], i = els.length;
			while ( --i )
				jQuery.timer.remove(els[i], label);
		}
	});


/* - ++resource++collective.roundabout.javascripts/jquery.roundabout.js - */
/**
 * jQuery.roundabout
 * Copyright (c) 2008 Four Digits - rob@fourdigits.nl
 * 
 * @projectDescription	This plugin is used to view a virtual tour with panoramic images.
 * @author				Rob Gietema
 * @version				0.1
 *
 * @id jQuery.roundabout
 * @id jQuery.fn.roundabout
 */
;(function($) {

	/**
	* Create a new instance of roundabout.
	*
	* @classDescription			This class creates a new roundabout object.
	* @param {Object} options	This object contains the options used for the roundabout object.
	* @return {Object}			Returns a new roundabout object.
	* @type {Object}
	* @constructor
	*/
	$.fn.roundabout = function(options) {

		// Option default values
		var optionsDefaults = {
			screenWidth: 320,			// Viewer width
			screenHeight: 240,			// Viewer height
			scale: 1,					// Image scale
			hotspotSize: 28,			// Width / height of the hotspots
			mapPanoramaSize: 8,			// Width / height of panorama points on the map
			compassSize: 40,			// Width / height of the compass
			arrowRotateSpeed: 60,		// Rotate speed when hovering over arrows around the viewer
			angle: 0.0,					// Current image x-angle
			height: 0.5,				// Current image y-angle
			deadZone: 25,				// Deadzone in the center of the image
			orgSpeed: 10,				// Original speed with original scale
			mouseDown: false,			// Mouse down state
			mouseX: 0,					// Mouse x-coordinate relative to viewer window
			mouseY: 0,					// Mouse y-coordinate relative to viewer window
			drawScale: false,			// True if tiles need to be scaled
			nrOfTiles: 12,				// Number of tiles
			orgTileWidth: 0,			// Original tile width
			orgPanHeight: 0,			// Original panoramic image height
			orgPanWidth: 0,				// Original panoramic image width
			drawInit: true,				// True if init needs to be run
			currentTile: "a",			// Current tile set
			otherTile: "b",				// Other (not active) tile set
			animFrame: -1,				// Current animation frame (-1 if not in an animation)
			nrOfAnimFrames: 10,			// Number of animation frames between image transitions
			animAngle: 0,				// X-angle of animation between image transitions
			currentId: "single",		// Current image id
			panoramas: [],				// Array of panorama data
			maps: [],					// Array of map data
			drawMap: false,				// True if map is available
			nrOfPanoramas: 0,			// Number of panoramas
			stopOnMouseOut: false		// True if rotating must stop when leaving the viewer window
		};

		// Extend default settings
		options = $.extend(optionsDefaults, options);

		// Loop through matched elements
		return this.each(function() {

			// Get current object
			obj = $(this);

			// Check if object is an image
			if (this.tagName.toLowerCase() == "img") {

				// Replace img with a viewer div
				obj = obj
					.removeClass()
					.addClass("roundaboutimage")
					.wrap(document.createElement("div"))
					.parent();
			}

			// Get viewer width / height and start image / angle
			if (obj.attr("title") != "") {

				// Get json data
				var data = eval("(" + obj.attr("title") + ")");

				// Set viewer width / height
				options.screenWidth = parseInt(data.viewer_width);
				options.screenHeight = parseInt(data.viewer_height);

				// Set start image / angle
				if (data.start_image != "None")
					options.currentId = data.start_image;
				options.angle = parseFloat(data.start_angle);

				options.nrOfAnimFrames = parseInt(data.animation_frames);
				if (options.nrOfAnimFrames < 1)
					options.nrOfAnimFrames = 1;
			}

			// Reset title
			obj.attr("title","");

			// Get image width / height
			options.orgPanHeight = $(obj.children("img")[0]).height();
			options.orgPanWidth = $(obj.children("img")[0]).width();

			// Get maps
			obj.children("img.roundaboutmap").each (function() {

				// Get map data and add to maps attribute
				var map = {
					src: $(this).attr("src"),
					panoramas: []
				};
				map = $.extend(map, eval("(" + $(this).attr("title") + ")"));
				options.maps[map.id] = map;

				// Draw map
				options.drawMap = true;
			});

			// Get images
			options.nrOfPanoramas = 0;
			obj.children("img.roundaboutimage").each (function() {

				// Default panoramic image data
				var panorama = {
					src: $(this).attr("src"),		// Src of image
					id: "single"					// Id of image
				};

				// Add json data if available
				if ($(this).attr("title").indexOf("{") != -1)
					panorama = $.extend(panorama, eval("(" + $(this).attr("title") + ")"));

				// Set current id if not set
				if (options.currentId == "single")
					options.currentId = panorama.id;

				// Add panorama to panorama list
				options.panoramas[panorama.id] = panorama;

				// If map is available
				if (options.drawMap) {

					// Add panorama location to map array
					options.maps[panorama.map].panoramas.push({
						id: panorama.id,
						x: panorama.mapx,
						y: panorama.mapy
					});
				}

				// Inc number of panoramas
				options.nrOfPanoramas++;
			});

			// If no panorama images available exit
			if (options.nrOfPanoramas == 0)
				return;

			// Remove images and add class
			obj.children().remove();
			obj
				.removeClass("roundabout")
				.addClass("roundabout-viewer-window");

			// Calc other values
			options.orgTileWidth = Math.ceil(options.orgPanWidth / options.nrOfTiles);
			options.lastTileWidth = options.orgTileWidth - ((options.orgTileWidth * options.nrOfTiles) - options.orgPanWidth);
			options.tileWidth = parseInt(parseFloat(options.orgTileWidth) * options.scale);
			options.panWidth = options.nrOfTiles * options.tileWidth;
			options.panHeight = parseInt(parseFloat(options.orgPanHeight) * options.scale);
			options.screenCenterX = options.screenWidth / 2;
			options.screenCenterY = options.screenHeight / 2;
			options.maxAngleX = (parseFloat(options.screenCenterX + options.hotspotSize/2) / parseFloat(options.panWidth)) * 360;
			options.speed = parseFloat(options.orgSpeed) / parseFloat(options.scale);

			// Add tiles
			for (var i = 0; i < options.nrOfTiles; i++) {
				obj
					.append(
						$(document.createElement("div"))
							.addClass("roundabout-tile-a")
							.append(
								$(document.createElement("img"))
									.attr("src", options.panoramas[options.currentId].src)
							)
					)
					.append(
						$(document.createElement("div"))
							.addClass("roundabout-tile-b")
							.append(
								$(document.createElement("img"))
							)
					)
			}

			// Add overlay
			obj.append(
				$(document.createElement("div"))
					.addClass("roundabout-overlay")
					.html("&nbsp;")
			);

			// Set screen size
			obj
				.width(options.screenWidth)
				.height(options.screenHeight);
			obj.children(".roundabout-overlay")
				.width(options.screenWidth)
				.height(options.screenHeight);

			// Setup viewer
			obj = obj
				.wrap(document.createElement("div"))
				.parent()
				.addClass("roundabout-viewer");

			// Add arrows
			$(["nw","ne","se","sw","n","e","s","w"]).each(function() {
				obj.append(
					$(document.createElement("div"))
						.addClass("roundabout-arrow")
						.addClass("roundabout-arrow-" + this)
						.html("&nbsp;")
				);
			});

			// Setup wrapper
			obj = obj
				.wrap(document.createElement("div"))
				.parent()
				.addClass("roundabout-wrapper")
				.data("options", options);

			// Setup map
			if (options.drawMap) {
				obj.append('<div class="roundabout-map"></div>');
				var map = $(obj.children(".roundabout-map")[0]);
				map.append('<div class="roundabout-map-window"></div>');
				map = $(map.children()[0]);
				map.append('<div class="roundabout-map-container"></div>');
				map.append('<div class="roundabout-map-overlay"></div>');
				$(map.children(".roundabout-map-overlay")[0]).append('<div class="roundabout-map-compass">&nbsp;</div>');
				map = $(map.children(".roundabout-map-container")[0]);
				for (x in options.maps) {
					if (typeof(options.maps[x]) == 'object') {
						map.append('<div id="roundabout-map-' + x + '"></div>');
						var curmap = $(map.children("#roundabout-map-" + x)[0]);
						curmap.append('<img id="roundabout-map-image" src="' + options.maps[x].src + '" />');

						// Add map panoramas
						var panoramas = options.maps[x].panoramas;
						for (var i = 0; i < panoramas.length; i++) {
							// Add panoramas
							curmap.append ('<div class="roundabout-map-panorama">&nbsp;</div>');
						}
						curmap.children(".roundabout-map-panorama").each(function(i) {
							$(this).css({
								top: panoramas[i].y - parseInt(options.mapPanoramaSize/2),
								left: panoramas[i].x - parseInt(options.mapPanoramaSize/2)
							});

							$(this).data("panorama", panoramas[i].id);

							/**
							* Event handler for mousedown on map panorama, navigates to the next panorama.
							*
							* @param {Object} e			This object points to the event object.
							*/
							$(this).mousedown(function(e) {
								var obj = $($(this).parents(".roundabout-wrapper").get(0));
								var options = $(obj).data("options");

								// Hide all hotspots during anim
								$(".roundabout-hotspot", obj).hide();
								options.currentId = $(this).data("panorama");
								obj.roundaboutGetPanorama();
								obj.find(".roundabout-tile-" + options.otherTile).roundaboutSetImage();
								options.animFrame = 0;
								options.animAngle = 0;
							});
						});

						// Add map hotspots
						var hotspots = options.maps[x].hotspots;
						for (var i = 0; i < hotspots.length; i++) {
							// Add panoramas
							curmap.append ('<div class="roundabout-map-hotspot">&nbsp;</div>');
						}
						curmap.children(".roundabout-map-hotspot").each(function(i) {
							$(this).css({
								top: hotspots[i].y,
								left: hotspots[i].x,
								width: hotspots[i].width,
								height: hotspots[i].height
							});

							$(this).data("map", hotspots[i].target_map);

							/**
							* Event handler for mousedown on map hotspot, navigates to the next map.
							*
							* @param {Object} e			This object points to the event object.
							*/
							$(this).mousedown(function(e) {
								var obj = $($(this).parents(".roundabout-wrapper").get(0));
								var options = $(obj).data("options");

								// Show the right map
								obj.find(".roundabout-map-container").children().hide();
								obj.find(".roundabout-map-container").children("#roundabout-map-" + $(this).data("map")).show();

								// Check if compass should be visible
								if (options.panoramas[options.currentId].map == $(this).data("map")) {
									obj.find(".roundabout-map-compass").show();
								} else {
									obj.find(".roundabout-map-compass").hide();
								}
							});
						});
					}
				}
			}

			// Draw viewer
			obj
				.roundaboutScaleTiles(options.scale, "a")
				.roundaboutScaleTiles(options.scale, "b")
				.roundaboutGetPanorama();

			/**
			* Event handler for mousedown on overlay, stores x and y coords in options object.
			*
			* @param {Object} e			This object points to the event object.
			*/
			$(obj.find(".roundabout-overlay")).mousedown(function(e) {

				// Check classname of event object
				if (e.target.className == "roundabout-overlay") {

					// Set mousedown state
					options.mouseDown = true;

					// Set event object
					if (!e) {
						e = window.event;
					}

					// Check get x and y coords
					if (e.pageX || e.pageY) {
						options.mouseX = e.pageX;
						options.mouseY = e.pageY;
					} else if (e.clientX || e.clientY) {
						options.mouseX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
						options.mouseY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
					}
					options.mouseX -= obj.find(".roundabout-viewer-window").offset().left;
					options.mouseY -= obj.find(".roundabout-viewer-window").offset().top;
				}
				
				// Prevent selection
				return false;
			});

			/**
			* Event handler for mouseup on overlay, sets mousestate in options object.
			*
			* @param {Object} e			This object points to the event object.
			*/
			$(obj.find(".roundabout-overlay")).mouseup(function(e) {

				// Set mousedown state
				options.mouseDown = false;
			});

			/**
			* Event handler for mouseout on overlay, sets mousestate in options object.
			*
			* @param {Object} e			This object points to the event object.
			*/
			$(obj.find(".roundabout-overlay")).mouseout(function(e) {

				// Set mousedown state
				if (options.stopOnMouseOut)
					options.mouseDown = false;
			});

			/**
			* Event handler for mouseout on arrow, sets mousestate in options object.
			*
			* @param {Object} e			This object points to the event object.
			*/
			$(obj.find(".roundabout-arrow")).mouseout(function(e) {

				// Set mousedown state
				options.mouseDown = false;
			});

			/**
			* Event handler for mouseover on arrow, sets mousestate in options object.
			*
			* @param {Object} e			This object points to the event object.
			*/
			$(obj.find(".roundabout-arrow")).mouseover(function(e) {

				// Set mousedown state
				options.mouseDown = true;
				options.mouseX = options.screenCenterX;
				options.mouseY = options.screenCenterY;

				// Get arrow and add rotate speed
				var arrow =$(this).attr("class").split("roundabout-arrow-")[1];
				if (arrow.indexOf("n") != -1)
					options.mouseY -= options.arrowRotateSpeed;
				if (arrow.indexOf("e") != -1)
					options.mouseX += options.arrowRotateSpeed;
				if (arrow.indexOf("s") != -1)
					options.mouseY += options.arrowRotateSpeed;
				if (arrow.indexOf("w") != -1)
					options.mouseX -= options.arrowRotateSpeed;
			});

			/**
			* Event handler for mousemove on overlay, stores x and y coords in options object.
			*
			* @param {Object} e			This object points to the event object.
			*/
			$(obj.find(".roundabout-overlay")).mousemove(function(e) {

				// Set mousedown state
				if (!e) {
					e = window.event;
				}
				if (e.pageX || e.pageY) {
					options.mouseX = e.pageX;
					options.mouseY = e.pageY;
				} else if (e.clientX || e.clientY) {
					options.mouseX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
					options.mouseY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
				}
				options.mouseX -= obj.find(".roundabout-viewer-window").offset().left;
				options.mouseY -= obj.find(".roundabout-viewer-window").offset().top;
			});

			/**
			* Main draw loop which is executed every 50ms.
			*/
			obj.everyTime(50,function() {

				// If scale tiles
				if (options.drawScale == true) {
					options.tileWidth = parseInt(parseFloat(options.orgTileWidth) * options.scale);
					options.panWidth = options.nrOfTiles * options.tileWidth;
					options.panHeight = parseInt(parseFloat(options.orgPanHeight) * options.scale);
					options.maxAngleX = (parseFloat(options.screenCenterX + options.hotspotSize/2) / parseFloat(options.panWidth)) * 360;
					options.speed = parseFloat(options.orgSpeed) / parseFloat(options.scale);

					obj
						.roundaboutScaleTiles(options.scale, "a")
						.roundaboutScaleTiles(options.scale, "b");
					options.drawScale = false;
				}

				var prevAngle = options.angle;
				var prevHeight = options.height;

				// Update angle / height
				if (options.mouseDown) {
					
					// Recalc behavior
					if (options.mouseX > options.screenCenterX+options.deadZone) {
						options.angle += (options.mouseX-options.screenCenterX-options.deadZone)/(options.screenCenterX-options.deadZone)*options.speed;
					}

					if (options.mouseX < options.screenCenterX-options.deadZone) {
						options.angle -= (options.screenCenterX-options.mouseX-options.deadZone)/(options.screenCenterX-options.deadZone)*options.speed;
					}

					if (options.angle > 360) { options.angle -= 360; }
					if (options.angle < 0) { options.angle += 360; }

					if (options.mouseY > options.screenCenterY+options.deadZone) {
						options.height += (options.mouseY-options.screenCenterY-options.deadZone)/(options.screenCenterY-options.deadZone)*options.speed/50;
					}

					if (options.mouseY < options.screenCenterY-options.deadZone) {
						options.height -= (options.screenCenterY-options.mouseY-options.deadZone)/(options.screenCenterY-options.deadZone)*options.speed/50;
					}

					if (options.height < 0) { options.height = 0; }
					if (options.height > 1) { options.height = 1; }
				}

				var drawObjects = false;
				if (options.drawInit == true) {
					drawObjects = true;
					options.drawInit = false;
				} else if ((options.angle != prevAngle) || (options.height != prevHeight)) {
					drawObjects = true;
				}

				if (options.animFrame != -1) {
					var animScale = options.scale + parseFloat(options.animFrame)/options.nrOfAnimFrames*options.scale;
					var animFactor = parseFloat(options.animFrame)/parseFloat(options.nrOfAnimFrames);
					if (options.animFrame < options.nrOfAnimFrames/4) {
						options.angle -= options.animAngle*animFactor/parseFloat(options.nrOfAnimFrames)*8;
					}

					obj
						.roundaboutScaleTiles(animScale, options.currentTile)
						.roundaboutDrawTiles(options.currentTile, animScale)
						.roundaboutDrawTiles(options.otherTile, options.scale);
				} else {
					if (drawObjects == true) {
						obj.roundaboutDrawTiles (options.currentTile, options.scale);

						// Set compass
						if (options.drawMap) {
							obj
								.find(".roundabout-map-compass")
									.removeClass()
									.addClass("roundabout-map-compass")
									.addClass("roundabout-map-compass-" + ["n","ne","e","se","s","sw","w","nw"][parseInt((options.angle+22.5)%360/45)]);
						}
					}
				}

				// Check if map available
				if (options.drawMap) {

					// Draw hotspots
					var oHotspot;
					if (typeof(options.panoramas[options.currentId]) != "undefined") {
						if (((options.animFrame == -1) && (drawObjects == true)) || (options.animFrame == options.nrOfAnimFrames)) {

							for (var iCount = 0; iCount < options.panoramas[options.currentId].hotspots.length; iCount++) {
								oHotspot = options.panoramas[options.currentId].hotspots[iCount];

								// Check if left from center
								var fDifangle = (options.angle - oHotspot.x_angle + 360) % 360;
								var hotspotobj = $($(obj).find(".roundabout-overlay")).children(".roundabout-hotspot")[iCount];

								var fCalcAngle;
								if (options.angle < options.maxAngleX) {
									fCalcAngle = options.angle + 360;
								} else {
									fCalcAngle = options.angle;
								}
								if ((fDifangle >= 0) && (fDifangle < options.maxAngleX)) {
									var fFactor = fDifangle / options.maxAngleX;

									$(hotspotobj).css ("left", options.screenCenterX - parseInt (fFactor * (options.screenCenterX+options.hotspotSize/2)) - options.hotspotSize / 2);
									$(hotspotobj).css ("top", parseInt(oHotspot.y_angle * parseFloat(options.panHeight)) - parseInt(options.height * (options.panHeight - options.screenHeight)) - options.hotspotSize / 2);
									$(hotspotobj).show();

								// Check if right from center
								} else if ((fDifangle <= 360) && (fDifangle > 360 - options.maxAngleX)) {

									var fFactor = (360 - fDifangle) / options.maxAngleX;
									$(hotspotobj).css ("left", options.screenCenterX + parseInt (fFactor * (options.screenCenterX + options.hotspotSize/2)) - options.hotspotSize / 2);
									$(hotspotobj).css ("top", parseInt(oHotspot.y_angle * parseFloat(options.panHeight)) - parseInt(options.height * (options.panHeight - options.screenHeight)) - options.hotspotSize / 2);
									$(hotspotobj).show();

								} else {

									// Hide hotspot
									$(hotspotobj).hide();
								}
							}
						}
					}
				}

				// Check if animation running
				if (options.animFrame != -1) {

					// If end of animation
					if (options.animFrame == options.nrOfAnimFrames) {

						// Hide current frame
						obj.find(".roundabout-tile-" + options.currentTile)
							.hide()
							.css({
								"opacity": 1,
								"z-index": 3
							});
						obj.find(".roundabout-tile-" + options.otherTile).css("z-index", 4);

						// Reset scale
						obj.roundaboutScaleTiles(options.scale, options.currentTile);

						var sTemp = options.currentTile;
						options.currentTile = options.otherTile;
						options.otherTile = sTemp;

						// End anim
						options.animFrame = -1;

					// Not the end of the animation
					} else
						options.animFrame++;
				}
			});
		});
	};

	/**
	* Scale the specified tiles.
	*
	* @param {Float} newScale	New scale factor.
 	* @param {String} tile		Specifies which tiles must be draw, can be either "a" or "b"
	* @return {Object}			Returns a pointer to the current object.
	*/
	$.fn.roundaboutScaleTiles = function(newScale, tile) {
		var obj = $(this);
		var options = $(this).data("options");

		// Calc values
		var newHeight = parseInt(parseFloat(options.orgPanHeight) * newScale);

		// Cycle through matched elements
		return this.each(function() {

			// Get tiles
			$(".roundabout-tile-" + tile, obj).each(function(i) {

				// Set new scales
				$(this)
					.width(i == options.nrOfTiles - 1?parseInt(parseFloat(options.lastTileWidth) * newScale):parseInt(parseFloat(options.orgTileWidth) * newScale))
					.height(newHeight)
					.children("img")
						.width(parseInt((parseFloat(options.orgTileWidth) * newScale * 11) + (parseFloat(options.lastTileWidth) * newScale)))
						.height(newHeight)
						.css("left", parseInt(-1 * parseFloat(options.orgTileWidth * i) * newScale));
			});
		});
	};

	/**
	* Set the image of the specified tile.
	*
	* @return {Object}			Returns a pointer to the current object.
	*/
	$.fn.roundaboutSetImage = function() {
		var options = $($(this).parents(".roundabout-wrapper").get(0)).data("options");

		// Loop through matched elements
		return this.each(function() {

			// Set image
			$(this).children("img").attr("src", options.panoramas[options.currentId].src);
		});
	};

	/**
	* Draw the specified tiles with the specified scale.
	*
 	* @param {String} tile		Specifies which tiles must be draw, can be either "a" or "b"
	* @param {Float} localScale	The scale of the tiles to be drawn.
	* @return {Object}			Returns a pointer to the current object.
	*/
	$.fn.roundaboutDrawTiles = function(tile, localScale) {
		var obj = $(this);
		var options = obj.data("options");
		var tiles = obj.find(".roundabout-tile-" + tile);

		// Loop through matched elements
		return this.each(function() {

			// Calc width / height
			iLocalTileWidth = parseInt(parseFloat(options.orgTileWidth) * localScale);
			iLocalTileWidthLast = parseInt(parseFloat(options.lastTileWidth) * localScale);
			iLocalPanWidth = options.nrOfTiles * options.tileWidth;
			iLocalPanHeight = parseInt(parseFloat(options.orgPanHeight) * localScale);
			fLocalMaxAngleX = (parseFloat(options.screenCenterX + options.hotspotSize/2) / parseFloat(options.panWidth)) * 360;

			// Check if animation
			var bAnim = ((options.animFrame != -1) && (tile == options.currentTile))?true:false;
			var fAnimFactor = parseFloat(options.nrOfAnimFrames-options.animFrame)/options.nrOfAnimFrames;

			// Set local angle
			var fLocalAngle = options.angle;
			if (bAnim) {
				fLocalAngle -= (options.animAngle*(1-fAnimFactor));
			}

			// Draw center tile
			var iTile = parseInt(fLocalAngle/360*options.nrOfTiles);
			if (iTile > 11)
				iTile = 11;
			var fLocalAngle = fLocalAngle/360*options.nrOfTiles-iTile;
			var iX = options.screenCenterX - parseInt(fLocalAngle*iLocalTileWidth);
			var iY = parseInt((iLocalPanHeight-options.screenHeight)*-options.height);
			$(tiles[iTile])
				.css({
					"left": iX,
					"top": iY,
					"opacity": bAnim?fAnimFactor:1
				})
				.show();

			// Draw tiles right from current
			var iCurX = iX;
			var iCurTile = iTile;
			while (iCurX + iLocalTileWidth < options.screenWidth) {
				if (iCurTile == options.nrOfTiles-1) {
					iCurTile = 0;
					iCurX += iLocalTileWidthLast;
				} else {
					iCurTile++;
					iCurX += iLocalTileWidth;
				}

				$(tiles[iCurTile])
					.css({
						"left": iCurX,
						"top": iY,
						"opacity": bAnim?fAnimFactor:1
					})
					.show();
			}
			var iRightTile = iCurTile;

			// Draw tiles left from current
			iCurX = iX;
			iCurTile = iTile;
			while (iCurX > iLocalTileWidth * -1) {
				if (iCurTile == 0) {
					iCurTile = options.nrOfTiles-1;
					iCurX -= iLocalTileWidthLast;
				} else {
					iCurTile--;
					iCurX -= iLocalTileWidth;
				}

				$(tiles[iCurTile])
					.css({
						"left": iCurX,
						"top": iY,
						"opacity": bAnim?fAnimFactor:1
					})
					.show();
			}

			// Hide the rest of the tiles
			while (iCurTile != iRightTile) {
				$(tiles[iCurTile]).hide();
				iCurTile += options.nrOfTiles - 1;
				iCurTile %= options.nrOfTiles;
			}
		});
	};

	/**
	* Get the current panorama data from the backend.
	*
	* @return {Object}			Returns a pointer to the current object.
	*/
	$.fn.roundaboutGetPanorama = function() {
		var obj = $(this);
		var options = obj.data("options");

		// Loop through matched elements
		return this.each(function() {

			// Check if maps available
			if (options.drawMap) {

				// Clear hotspots
				var overlay = obj
					.find(".roundabout-overlay")
					.empty();

				// Add hotspots
				$(options.panoramas[options.currentId].hotspots).each(function () {

					// Create div
					overlay.append(

						// Create hotspot div
						$(document.createElement("div"))
							.addClass("roundabout-hotspot")
							.data("target_image", this.target_image)
							.data("x_angle", this.x_angle)

							/**
							* Event handler for mousedown on hotspot, navigates to the next panorama.
							*
							* @param {Object} e			This object points to the event object.
							*/
							.mousedown(function(e) {

								// Hide all hotspots during anim
								$(".roundabout-hotspot", obj).hide();
								options.currentId = $(this).data("target_image");
								options.animFrame = 0;
								options.animAngle = (options.angle - parseFloat($(this).data("x_angle")) + 360) % 360;
								if (options.animAngle > 180)
									options.animAngle -= 360;
								obj
									.roundaboutGetPanorama()
									.find(".roundabout-tile-" + options.otherTile)
									.roundaboutSetImage();
							})
					);
				});

				// Show current map
				obj.find(".roundabout-map-container").children()
					.hide()
					.parent()
					.children("#roundabout-map-" + options.panoramas[options.currentId].map)
					.show();

				// Set compass
				obj.find(".roundabout-map-compass")
					.show()
					.css({
						left: options.panoramas[options.currentId].mapx - parseInt(options.compassSize/2),
						top: options.panoramas[options.currentId].mapy - parseInt(options.compassSize/2)
					});
			}
		});
	};
})(jQuery);


/* - ++resource++collective.roundabout.javascripts/roundabout.js - */
;(function($) {
	$(window).load(function() {
		$(".roundabout").roundabout();
	});
})(jQuery);

/* - ++resource++coolregionskin.javascripts/jquery.cookie.js - */
// http://www.coolregion.nl/portal_javascripts/++resource++coolregionskin.javascripts/jquery.cookie.js?original=1
jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires * 24 * 60 * 60 * 1000))} else{date=options.expires}
expires='; expires='+date.toUTCString()}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('')} else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break}}}
return cookieValue}};

/* - ++resource++coolregionskin.javascripts/jquery.fourdigitsBrowseHistory.js - */
// http://www.coolregion.nl/portal_javascripts/++resource++coolregionskin.javascripts/jquery.fourdigitsBrowseHistory.js?original=1
;(function($){$.fn.fourdigitsBrowseHistory=function(options){var optionsDefaults={itemcount:5,titleselector:"h1",title:"Title"};for(key in options){if(typeof(options[key])!=typeof(optionsDefaults[key])){options[key]=optionsDefaults[key]}}
options=$.extend(optionsDefaults,options);return this.each(function(){var items=new Array();for(var i=0;i<options.itemcount;i++){var itemtitle=$.cookie('browse_history_title_'+i);var itemurl=$.cookie('browse_history_url_'+i);if(itemtitle!=null&&itemurl!=null){items.push({title:itemtitle,url:itemurl})}}
var newitems=new Array();for(var i=0;i<items.length;i++){newitems[i]={title:items[i].title,url:items[i].url}}
if(newitems.length>=options.itemcount){newitems.pop()}
newitems.unshift({title:$(options.titleselector).text(),url:document.location.href});for(var i=0;i<options.itemcount;i++){if(i<newitems.length){$.cookie('browse_history_title_'+i,newitems[i].title,{path:'/'});$.cookie('browse_history_url_'+i,newitems[i].url,{path:'/'})} else{$.cookie('browse_history_title_'+i,null);$.cookie('browse_history_url_'+i,null)}}
var html='';html+='<dl class="portlet">';html+='<dt class="portletHeader">'+options.title+'</dt>';for(var i=0;i<items.length;i++){html+='<dd class="portletitem"><a href="'+items[i].url+'" class="tile">'+items[i].title+'</a></dd>'}
html+='</dl>';$(this).html(html)})}})(jQuery);

