/* Copyright 2010 HID Digital Solutions. */

// When DOM is loaded.
$(document).ready(function() {


	// "Call me" fancybox.
	$("#belmeterug").fancybox({
		'transitionIn': 'elastic',
		'transitionOut': 'elastic',
		'width': 300,
		'height': 185,
		'speedIn': 600, 
		'speedOut':	200, 
		'overlayShow':	true,
		'type': 'iframe',
		'overlayColor': '#000000',
		'overlayOpacity': 0.7,
		'scrolling': 'no'
	});

	// Image slider.
	$('#imagesWoningen img:first').delay(1000).fadeIn(1500, function() {
		$('#imagesWoningen').cycle({
			fx: 'fade',
			speed: 1500,
			timeout: 4000,
			width: 200,
			before: function() {
				$('#caption span').html(this.alt);
			}
		});
	});

	// Tabs.
	// Woningen.
	$('#tabWoningen').click(function() {
		$('.tabs').removeClass('active');
		$('#tabWoningen').addClass('active');
		$('.projects').css('display', 'none');
		$('#contentWoningen').css('display', 'block');

		// Stop woningen cycle.
		$('#imagesAppartementen').cycle('destroy');
		$('#imagesBedrijfsgebouwen').cycle('destroy');
		$('#imagesOverheidsgebouwen').cycle('destroy');
		$('#imagesRenovaties').cycle('destroy');

		// Hide woningen images.
		$('.projectImages').css('display', 'none');

		// Clear caption.
		$('#caption span').html('');

		// Hide woningen images.
		$('#imagesWoningen').css('display', 'block');
		
		//$('.projectImages').css('display', 'none');
		$('#imagesWoningen img:first').delay(1000).fadeIn(1500, function() {
			$('#imagesWoningen').cycle({
				fx: 'fade',
				speed: 1500,
				timeout: 4000,
				width: 200,
				before: function() {
					$('#caption span').html(this.alt);
				}
			});
		});

	});

	// Appartementen.
	$('#tabAppartementen').click(function() {
		$('.tabs').removeClass('active');
		$('#tabAppartementen').addClass('active');
		$('.projects').css('display', 'none');
		$('#contentAppartementen').css('display', 'block');

		// Stop woningen cycle.
		$('#imagesWoningen').cycle('destroy');
		$('#imagesBedrijfsgebouwen').cycle('destroy');
		$('#imagesOverheidsgebouwen').cycle('destroy');
		$('#imagesRenovaties').cycle('destroy');

		// Hide woningen images.
		$('.projectImages').css('display', 'none');

		// Clear caption.
		$('#caption span').html('');

		// Hide woningen images.
		$('#imagesAppartementen').css('display', 'block');
		
		//$('.projectImages').css('display', 'none');
		$('#imagesAppartementen img:first').delay(1000).fadeIn(1500, function() {
			$('#imagesAppartementen').cycle({
				fx: 'fade',
				speed: 1500,
				timeout: 4000,
				width: 200,
				before: function() {
					$('#caption span').html(this.alt);
				}
			});
		});

	});

	// Bedrijfsgebouwen.
	$('#tabBedrijfsgebouwen').click(function() {
		$('.tabs').removeClass('active');
		$('#tabBedrijfsgebouwen').addClass('active');
		$('.projects').css('display', 'none');
		$('#contentBedrijfsgebouwen').css('display', 'block');

		// Stop woningen cycle.
		$('#imagesWoningen').cycle('destroy');
		$('#imagesAppartementen').cycle('destroy');
		$('#imagesOverheidsgebouwen').cycle('destroy');
		$('#imagesRenovaties').cycle('destroy');

		// Hide woningen images.
		$('.projectImages').css('display', 'none');

		// Clear caption.
		$('#caption span').html('');

		// Hide woningen images.
		$('#imagesBedrijfsgebouwen').css('display', 'block');
		
		//$('.projectImages').css('display', 'none');
		$('#imagesBedrijfsgebouwen img:first').delay(1000).fadeIn(1500, function() {
			$('#imagesBedrijfsgebouwen').cycle({
				fx: 'fade',
				speed: 1500,
				timeout: 4000,
				width: 200,
				before: function() {
					$('#caption span').html(this.alt);
				}
			});
		});

	});

	// Overheidsgebouwen.
	$('#tabOverheidsgebouwen').click(function() {
		$('.tabs').removeClass('active');
		$('#tabOverheidsgebouwen').addClass('active');
		$('.projects').css('display', 'none');
		$('#contentOverheidsgebouwen').css('display', 'block');

		// Stop woningen cycle.
		$('#imagesWoningen').cycle('destroy');
		$('#imagesAppartementen').cycle('destroy');
		$('#imagesBedrijfsgebouwen').cycle('destroy');
		$('#imagesRenovaties').cycle('destroy');

		// Hide woningen images.
		$('.projectImages').css('display', 'none');

		// Clear caption.
		$('#caption span').html('');

		// Hide woningen images.
		$('#imagesOverheidsgebouwen').css('display', 'block');
		
		//$('.projectImages').css('display', 'none');
		$('#imagesOverheidsgebouwen img:first').delay(1000).fadeIn(1500, function() {
			$('#imagesOverheidsgebouwen').cycle({
				fx: 'fade',
				speed: 1500,
				timeout: 4000,
				width: 200,
				before: function() {
					$('#caption span').html(this.alt);
				}
			});
		});

	});

	// Renovatie.
	$('#tabRenovatie').click(function() {
		$('.tabs').removeClass('active');
		$('#tabRenovatie').addClass('active');
		$('.projects').css('display', 'none');
		$('#contentRenovatie').css('display', 'block');

		// Stop woningen cycle.
		$('#imagesWoningen').cycle('destroy');
		$('#imagesAppartementen').cycle('destroy');
		$('#imagesBedrijfsgebouwen').cycle('destroy');
		$('#imagesOverheidsgebouwen').cycle('destroy');

		// Hide woningen images.
		$('.projectImages').css('display', 'none');

		// Clear caption.
		$('#caption span').html('');

		// Hide woningen images.
		$('#imagesRenovaties').css('display', 'block');
		
		//$('.projectImages').css('display', 'none');
		$('#imagesRenovaties img:first').delay(1000).fadeIn(1500, function() {
			$('#imagesRenovaties').cycle({
				fx: 'fade',
				speed: 1500,
				timeout: 4000,
				width: 200,
				before: function() {
					$('#caption span').html(this.alt);
				}
			});
		});

	});

});
