$(document).ready(function() {		
			
	$("img[src*=.ashx]").each(function() {  
		//als de verschaalde afbeelding al een link bevat, dan GEEN fancy-box toepassen.
		if ($(this).parent().attr("href")){
			//$(this).addClass('hover');
			return;
		}
		
		var imgTitle	= $(this).attr('title');
		var imgSrc		= $(this).attr('src');
		var maxW		= '800';
		var maxH		= '800';
		
		var vars = imgSrc.split(/[;&]/);
 		for (var i = 0; i < vars.length; i++) {
			var pair = vars[i].split('=');
			if (pair[0] == 'w'){
				pair[1] = maxW;
			}
			if (pair[0] == 'h'){
				pair[1] = maxH;
			}
			vars[i] = pair.join('=');
		}
		var newImgSrc = vars.join('&');
		$(this).wrap('<a class="fancy" title="'+ imgTitle +'" href="'+ newImgSrc +'"></a>');
		//$(this).parent().append('<span class="zoomIcon">zoom</span>');	
	});

	$(".fancy").fancybox({
		'zoomOpacity'			: false,
		'overlayShow'			: true,
		'zoomSpeedIn'			: 500,
		'zoomSpeedOut'			: 500,
		'imageScale'			: true,
		'hideOnContentClick'	: true
	});

	equalHeight('eqH');
	//$('img[src*=.ashx]').fixImageUrl();

	$('#fotoDiv').crossSlide({
		sleep: 7,
		fade: 1
	}, [
		{ src: '/images/foto_vrouw01.jpg' },
		{ src: 'images/foto_vrouw02.jpg' },
		{ src: 'images/foto_vrouw03.jpg' },
		{ src: 'images/foto_vrouw04.jpg' },
		{ src: 'images/foto_vrouw05.jpg' }
	]);

	//ie6:
	if($.browser.msie){
		if($.browser.version == '6.0'){
			alert("Deze website ondersteunt geen Internet Explorer 6, update aub uw browser, of gebruik een alternatieve browser")
		}
	}

	if(ref != ""){
		switch(ref){
			case "Besparingsprincipe":			kubusMo('click', 'kubus_besparend.jpg', 'kubusBesparend');
			break;
			case "Duurzaamheidsprincipe":		kubusMo('click', 'kubus_duurzaam.jpg', 'kubusDuurzaam');
			break;
			case "Flexibiliteitsprincipe":		kubusMo('click', 'kubus_flexibel.jpg', 'kubusFlexibel');
			break;
			case "Energiezuinigheidsprincipe":	kubusMo('click', 'kubus_energiezuinig.jpg', 'kubusEnergiezuinig');
			break;
			case "Comfortprincipe":				kubusMo('click', 'kubus_comfortabel.jpg', 'kubusComfortabel');
			break;
		}
	}
});

$.fn.fixImageUrl = function(){   
	return this.each(function(){   
		var src = $(this).attr("src");
		$(this).wrap('<div style="width:20px;height:20px;" class="loading"></div>');
		$(this).hide();
		$(this).load(function(){
			$(this).fadeIn();
			$(this).unwrap();
		});
		//$(this).fadeIn();
		//$(this).unwrap();
	});   
};  

//kubus:
var activeImg;
var activeNode;
var kubusMo = function(action, img, node){
	if(action == "click"){
		activeImg	= img;
		activeNode	= node;
	}

	if(typeof activeImg != "undefined"){
		$('#kubus').attr('src', '/images/' + activeImg);
		$('.kubusClass').each(
			function(intIndex){
				$('#' + this.id + ' > h1').removeClass('h1active');
				$('#' + this.id + ' > div').hide();
			}
		)
		$('#' + activeNode + ' > div').show();
		$('#' + activeNode + ' > h1').addClass('h1active');
	}

	if(typeof img != "undefined"){
		$('#kubus').attr('src', '/images/' + img);
	}
	
	if(action == "out" && typeof activeImg == "undefined"){
		$('#kubus').attr('src', 'images/kubus_blanco.jpg');
	}
}
