Cufon.replace('#nav, .sub ul li a',{ignore:{div:true}, hover : {color:'#33A0A6'}, hoverables : {li: true}});
Cufon.replace('h1, h2, .intro',{hover : {color:true}});

function initialize(latCoor, lngCoor) {
	var latlng = new google.maps.LatLng(latCoor, lngCoor);
	var myOptions = {
		zoom: 10,
		center: latlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP,
		scrollwheel : false
	};
	var map = new google.maps.Map(document.getElementById("mapcanvas"),myOptions);
	var image = new google.maps.MarkerImage(
		'http://www.casaspanje.be/img/mapspin.png',
		new google.maps.Size(20, 24),
		new google.maps.Point(0,0)
	);
	var marker = new google.maps.Marker({
		position: new google.maps.LatLng(latCoor, lngCoor),
		icon: image,
		map: map
	});
}//initialize

$(document).ready(function(){
	
	$("#contacteerform,#vragen,#loginform").validate({
		errorLabelContainer: $("#errors")
	});
	
	function megaHoverOver(){
		$(this).find(".sub").stop().fadeTo('fast', 1).show();
			
		//Calculate width of all ul's
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				$(this).find("ul").each(function() {					
					rowWidth += $(this).width(); 
				});	
			};
		})(jQuery); 

		
		if ( $(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			$(this).find(".row").each(function() {							   
				$(this).calcSubWidth();
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			//Set width
			$(this).find(".sub").css({'width' :biggestRow});
			$(this).find(".row:last").css({'margin':'0'});
			
		} else { //If row does not exist...
			
			$(this).calcSubWidth();
			//Set Width
			$(this).find(".sub").css({'width' : rowWidth});
			
		}
	}
	
	function megaHoverOut(){ 
	  $(this).find(".sub").stop().fadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
	}


	var config = {    
		 sensitivity: 10, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 100, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 200, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$("ul#nav li .sub").css({'opacity':'0'});
	$("ul#nav li").hoverIntent(config);	
	
  	$('a#contacteerons').click(function() {
 		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname){
			var $target = $(this.hash);
			$target = $target.length && $target
			|| $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top -50;
				$('html,body,content')
				.animate({scrollTop: targetOffset}, 1000);
				return false;
			}
 		}
	});		
});

		$(document).ready(function(){
			if($("a[rel=group]")){
				$("a[rel=group]").fancybox({
					'transitionIn'		: 'none',
					'transitionOut'		: 'none',
					'titlePosition' 	: 'over',
					'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
						return '<span id="fancybox-title-over">Afbeelding ' + (currentIndex + 1) + ' &bull; ' + currentArray.length + '</span>';
					}
				});	
			}//if
			
			if($("#gmaps")){
				$("#gmaps").fancybox({
					'width'				: '90%',
					'height'			: '90%',
					'autoScale'			: false,
					'transitionIn'		: 'none',
					'transitionOut'		: 'none',
					'type'				: 'iframe'
				});
			}//if


});
