Cufon.replace('#hoofdnav li',{hover: true, hoverables: { li: true}})('.header_title')('.header_links_title')('.nieuwsDatum')('.activiteitenDatum')('.header_title_nieuws')('.listheader');

$(document).ready(function()
{
	$("a.nav").click(function() 
	{ 
		$this = $(this);	
		location.href=$this.attr('href');
		return false;
    });
	
	$("a.navActive").addClass('startActive');
	
	// $('#fade').cycle();
	$('#spotlight').cycle({ timeout: 3000, cleartype: 1, speed: 400 });

	jumpBackTimeout = null;
	
	$("#hoofdnav li:not('.subNav')").hover(
		function() 
		{ 
			$this = $(this);
			$this.find('a.nav').addClass('navActive');
			Cufon.refresh();
			
			clearTimeout(jumpBackTimeout);
		}
	, function() 
		{ 
			$("a.nav:not('.startActive')").removeClass('navActive');
			jumpBackTimeout = setTimeout(function(){jumpBack()},100);
		}
	);
	
	function jumpBack()
	{
		$("#menuslider").stop(true).animate(
		{
			left: $('a.startActive').position().left+265,
			width: $('a.startActive').width()+13
		}, 50);
		
		$("#winkelhaakje").stop(true).animate(
		{
			left: $('a.startActive').position().left+255
		}, 50);
		
		$("a.startActive").css("color", "#ffffff");
		Cufon.refresh();
	}
	
	$("a.nav").click(function(e)
	{
		$this = $(this);
		location.href=$this.attr('href');
	});
	
	$("#maps").maps();
});

function fixHeight()
{
  if ($(".contents").height() < $("#rechts").height())
  {
     if(!$.browser.msie){
        $(".contents").css({
           minHeight:  $("#rechts").height(),
           height:     'auto'      
        });
     }else{
        $(".contents").height($("#rechts").height());
     }
  }
  $("#links").height($("#content").height()-5);
}
	
$(window).load(function()
{
	$("#menuslider").css(
	{ 
		left: $("a.navActive").position().left+265,
		width: $("a.navActive").width()+13
	});
	
	$("#winkelhaakje").css(
	{ 
		left: $("a.navActive").position().left+255
	});
	
	$("li a.nav").hover(function() 
	{ 
		$this = $(this);
		
		$("#menuslider").animate(
		{ 
			left: $this.position().left+265,
			width: $this.parent().width()+9
		}
		, 50
		, false
		, function(){
			left: $this.position().left+265;
			width: $this.parent().width()+9;
		}); 
		
		$("#winkelhaakje").animate(
		{ 
			left: $this.position().left+255
		}
		, 50
		, false
		, function(){
			left: $this.position().left+255;
		}); 
		
		if( ! $(this).hasClass('startActive') )
		{
			$("a.startActive").css("color", "#58585a");
		}
		Cufon.refresh();
    });
	
	$("a.activiteitAlbum").fancybox();
	
	fixHeight();
	
});
			
// DE GOOGLE MAPS MODULE VAN TIM, CREDITS, ODE, KUDDOS EN HULDE AAN TIM DE VOSSEMAN. Amen.
(function($) {
  $.fn.maps = function(options) {
    var opts = $.extend({}, $.fn.maps.defaults, options);
    return this.each(function(i) {
      var $this           = $(this);
      $this.opts          = $.extend({}, opts);
      $this.opts.mainposition1  = new google.maps.LatLng(50.79945,5.7203);
      $this.opts.mainposition2  = new google.maps.LatLng(51.56801,3.5690);
      $this.opts.mainposition3  = new google.maps.LatLng(50.85150,5.7063);
      $this.opts.centerposition = new google.maps.LatLng(51.212,4.749);
      $this.opts.zoom       = 7;
      $this.opts.map        = null;
      $this.opts.directionsService        = null;
      
      var myOptions = {
        zoom: $this.opts.zoom,
        center: $this.opts.centerposition,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      
      $this.opts.map = new google.maps.Map(document.getElementById("routemap"), myOptions);
      $this.opts.directionsService = new google.maps.DirectionsService();
      $this.opts.directionsDisplay = new google.maps.DirectionsRenderer();
      $this.opts.directionsDisplay.setMap($this.opts.map);
      $this.opts.directionsDisplay.setPanel(document.getElementById("routebeschrijving"));
      
		var marker1 = new google.maps.Marker({
			position: $this.opts.mainposition1, 
			map: $this.opts.map,
			title: "Locatie Gronsveld"
		});
		var marker2 = new google.maps.Marker({
			position: $this.opts.mainposition2, 
			map: $this.opts.map,
			title: "Locatie Oostkapelle"
		}); 
		var marker3 = new google.maps.Marker({
			position: $this.opts.mainposition3, 
			map: $this.opts.map,
			title: "Locatie Maastricht"
		}); 

      
      $this.find(".submit").click(function(){
        $.fn.maps.route($this); 
		$("#links").height($("#content").height()-5);		
      });
    });
  };
  $.fn.maps.route = function($this){
		var start = $this.find("[name=straatnaam]").val() + ", " + $this.find("[name=nr]").val() + ", " + $this.find("[name=plaats]").val();
		var destid  = parseInt($this.find("[name=office]").val());
		switch(destid) {
			case 1:	var dest = $this.opts.mainposition1; break;
			case 2:	var dest = $this.opts.mainposition2; break;
			case 3:	var dest = $this.opts.mainposition3; break;
		}
		
		var request = {
			origin:start, 
			destination: dest,
			travelMode: google.maps.DirectionsTravelMode.DRIVING
		};
		
		$this.opts.directionsService.route(request, function(response, status) {
			if (status == google.maps.DirectionsStatus.OK) {
				$this.opts.directionsDisplay.setDirections(response);
				setTimeout("fixheight()",100);
			}else{
				alert("Uw adres kan niet worden gevonden, probeer het nogmaals.");
      }
    });
  };
  fixHeight();
})(jQuery);
