$(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);
					});
				}
			}
		}
	});

	$('#navigatie li').hover(
		function() {
		$(this).find('.dropNav').show();
	}, function() {
		$(this).find('.dropNav').hide();
	});
	
	var pt = null;
	function getTracker(){
		if(typeof _gat == 'object'){
			pt = _gat._createTracker('UA-24647268-1');
			var items = [
				{id:'#contact #name',			action:'blur',	href:'/nl/contact/naam'},
				{id:'#contact #email',			action:'blur',	href:'/nl/contact/email'},
				{id:'#contact #phone',			action:'blur',	href:'/nl/contact/telefoon'},
				{id:'#contact #remarks',		action:'blur',	href:'/nl/contact/bericht'},
				{id:'#contact_sent',			action:'found',	href:'/nl/contact/voltooid'},
				{id:'#belmeterug #naam',		action:'blur',	href:'/nl/belmijterug/naam'},
				{id:'#belmeterug #phone',		action:'blur',	href:'/nl/belmijterug/telefoon'},
				{id:'#belmeterug_sent',			action:'found',	href:'/nl/belmijterug/verzonden'},
				{id:'#nieuwsbrief #name',		action:'blur',	href:'/nl/nieuwsbrief/naam'},
				{id:'#nieuwsbrief #email',		action:'blur',	href:'/nl/nieuwsbrief/email'},
				{id:'#nieuwsbrief_sent',		action:'found',	href:'/nl/nieuwsbrief/verstuurd'}
			];
			for(var i = 0; i < items.length; i++){
				switch(items[i].action){
					case 'blur':
						var el = $(items[i].id);
						el.attr('rel', items[i].href);
						$(items[i].id).blur(function(){
							pt._trackPageview($(this).attr('rel'));
						});
					break;
					case 'found':
						$(items[i].id).each(function(){
							pt._trackPageview(items[i].href);
						});
					break;
				}
			}
		} else {
			setTimeout(function(){
				getTracker();
			},100);
		}
	}
	getTracker();

	$(function(){
		    $("ul#ticker01").liScroll({travelocity: 0.045}); //0.045
	});
});
