$(document).ready(function(){
	$('.back').css({
		cursor:'pointer'
	});
	$('.back').click(function(){
		history.back();
	});
	$('.slideshow').each(function(){
		var data = eval('('+$(this).attr('ssData')+')');
		$('.ssImage').css({visibility:'visible'});
		$(this).cycle(data);
		$(this).height(data.height);
		$(this).width(data.width);
	});

	$('.googleMap').each(function(){
		var opts = eval('('+$(this).attr('mapOptions')+')');
		var center = eval('('+opts.center+')');
		opts.center = new google.maps.LatLng(center.b,center.c);
		opts.zoom = parseFloat(opts.zoom);
		var el = document.getElementById($(this).attr('id'));
		// Markers ophalen
		var markers = [];
		$(this).find('.marker').each(function(){
			markers[markers.length] = {
				data:eval('('+$(this).attr('markerOptions')+')'),
				description:$(this).html()
			}
		});
		var map = null;
		if(el){
			map = new google.maps.Map(el,opts);
		}
		if(map != null && markers.length > 0){
			for(var i = 0; i < markers.length; i++){
				var opts = markers[i].data;
				if(opts.cmsDraggable != undefined){
					opts.draggable = opts.cmsDraggable;
				}
				if(opts.cmsClickable != undefined){
					opts.clickable = opts.cmsClickable;
				}
				var position = eval('('+opts.position+')');
				opts.position = new google.maps.LatLng(position.b,position.c);
				opts.map = map;
				var m = new google.maps.Marker(opts);
				if(markers[i].description != ''){
					var w = new google.maps.InfoWindow({
						content:markers[i].description,
						position:opts.position
					});
					w.open(map);
					google.maps.event.addListener(m, 'click', function(e){
						w.open(map);
					});
				}
			}
		}
	});

	$('#cirkels').first().each(function(){
		var loc = document.location.href.split('/').slice(2,3).join('/');
		if(loc == 'www.lucasict.nl'){
			loc = document.location.href.split('/').slice(3,4).join('/');
		} else {
			loc = '';
		}
		var w = $(this).width();
		var bubbles = [
			'center',
			'center',
			'center'
		];
		for(var i = 0; i < bubbles.length; i++){
			var b = $().BubbleEngine({
				particleSourceX:Math.round(w/4)*(i+1),
				particleSourceY:174,
				particleSizeMin:32,
				particleSizeMax:128,
				particleAnimationDuration:5000,
				particleScatteringX:500,
				particleScatteringY:150,
				particleDirection:bubbles[i],
				gravity:-100,
				imgSource:'/images/cirkel1.png',
				element:$(this)
			});
			b.addBubbles(5);
		}
	});
	/*
	function move(el){
		var dir = el.data('dir');
		var pos = el.position();
		el.animate({
			left:pos.left+(50*(dir=='L'?-1:1)),
			top:pos.top-50
		},1000,'linear', function(){
			el.data('dir', (dir=='L'?'R':'L'));
			move(el);
		});
	}

	$('#cirkels').first().each(function(){
		var w = $(this).width();
		var cirkels = 1;
		var amount = 1;
		for(var i = 1; i <= cirkels; i++){
			for(var j = 1; j <= amount; j++){
				var x = Math.round(Math.random()*w);
				var y = Math.round(Math.random()*174);
				var c = $('<div></div>');
				c.data('dir', Math.round(Math.random())==1?'L':'R');
				c.attr('id', 'test');
				c.addClass('cirkel'+i);
				c.addClass('cirkel');
				c.css({
					left:x,
					top:y
				});
				$(this).append(c);
				move(c);
			}
		}
	});
	*/
});
