/***********************************************************************Author:     Sander Tiekstra / Ilse van GemertCompany:    TiekstramediaURL:        http://www.tiekstramedia.nl***********************************************************************//* check if a hash value is present in the url and redirect------------------------------------------------------------------*/if (parent.location.hash != "" && parent.location.hash != undefined) {	var hash_value = parent.location.hash.substring(1);	var current_url = window.location.href.split("/");	var new_url = '/' + hash_value;	window.location.href = new_url;}/* Top up------------------------------------------------------------------*/TopUp.host = "http://www.re-z.nl/";TopUp.images_path = "assets/layout/top_up/";TopUp.players_path = "assets/players/";TopUp.addPresets({    'a.top_up': {      	width: 720,      	height: 405,		shaded: 1    }});$(document).ready(function() {		/* Global variabels	------------------------------------------------------------------*/	var currentId = $('body').attr('id');			var targetPosHome = new Array(0, 788, 808, 828, 848);	var targetPosVisie = new Array(0, 20, 808, 828, 848);	var targetPosProjecten = new Array(0, 20, 40, 828, 848);	var targetPosBeheer = new Array(0, 20, 40, 60, 848);	var targetPosContact = new Array(0, 20, 40, 60, 80);		/* Initiate	------------------------------------------------------------------*/	initiateAnimation();	setHeight();	setLinks();	slideShow();	rewriteMail();				/* Initiate after scrolling and resizing	------------------------------------------------------------------*/		$(window).resize( function () {		setHeight();	});		/* Rewrite mail addresses	------------------------------------------------------------------*/	function rewriteMail () {		// mail rewrite (href)		$('a[href*="mailto:"]').each(function() {			var mailto = $(this).attr('href').split('[at]');			if (mailto.length > 1) {				$(this).attr("href", mailto[0] + "@" + mailto[1]);			};		});			// mail rewrite (text node)		$('a:contains("[at]")').each(function() {			var mailto = $(this).text().split('[at]');			$(this).text(mailto[0] + "@" + mailto[1]);		});	}			/* = Set the height of the columns to 'fullwindow'	------------------------------------------------------------------*/	function setHeight()	{		var maxTextHeight = 0;		var textDivs = $('div[class='+ currentId + ']').find('.one, .two, .three, .four');		for (var i=0; i < textDivs.length; i++) {			if ( maxTextHeight < ( $(textDivs[i]).height() + 27 ) ) {				maxTextHeight = $(textDivs[i]).height() + 27;			}		};		var siteHeight = maxTextHeight > $(window).height() ? maxTextHeight : $(window).height();		siteHeight = siteHeight > 640 ? siteHeight : 640;		$('#content, .image-one, .image-two, .image-three, .image-four').height(siteHeight);	}				/* = Animation	------------------------------------------------------------------*/	function initiateAnimation()	{		var positions = getpositions(currentId);						$('div.home').css({ left: positions[0] });		$('div.visie').css({ left: positions[1] });		$('div.projecten').css({ left: positions[2] });		$('div.beheer').css({ left: positions[3] });		$('div.contact').css({ left: positions[4] });				$('.tab').live('click', function(event) {			var target = $(event.target);			var targetId = $(this).parent().attr("class");			if ( !$(this).parent().hasClass(currentId) ) {;				data(targetId, target);			}			return false;			});						$('.navigation a').live('click', function(event) {			var targetId = $(this).parent().parent().parent().parent().attr("class");			var target = $(event.target).is("small") ? $(event.target).parent() : $(event.target);			data(targetId, target);			return false;		});				function getpositions(id)		{			if (id == "home") {				var positions = targetPosHome;			} else if (id == "visie") {				var positions = targetPosVisie;			} else if (id == "projecten") {				var positions = targetPosProjecten;			} else if (id == "beheer") {				var positions = targetPosBeheer;			} else if (id == "contact") {				var positions = targetPosContact;			}						return positions;		}			function data(id, target)		{			if (currentId != id) {				$("div." + id).addClass("animate");			}						var timeout = window.setTimeout(function() { setLoading(); }, 100);			function setLoading () {				$("body").addClass("loading");				window.clearTimeout(timeout);			}									$('body').attr({ id: id	});						var url = target.attr("href");						$.ajax(				{					url: url,					dataType: "html",					async: false,					success: function(data)					{						window.clearTimeout(timeout);												var content = $(data).find('.' + id).children();						$("." + id).html( content );						setLinks();						slideShow();						//make Google Analytics count the pageview						pageTracker._trackPageview(url);												//change the title						var regexp_title = new RegExp("<title>[\n\r\s]*(.*)[\n\r\s]*</title>", "gmi");						var title = regexp_title.exec(data);						document.title = title[1];												//change the url						var url_parts = url.split("/");						var hash = "";						for (var i = 1; i < url_parts.length; i++) {							if (url_parts[i] != "") {								hash = hash + url_parts[i] + '/';							}						}						if (hash != "") {							parent.location.hash = hash;						} else {							parent.location.hash = "#";						}												//decode email addresses in new content						rewriteMail();												$(".loading").removeClass("loading");						if (currentId != id) {							$("div." + id).addClass("animate");							animate(id);						}						currentId = id;											},					error: function()					{						window.location.href = url;					}				}			);					}				function animate(id)		{			var speed = 1000;			var positions = getpositions(id);					$('div.home').stop();			$('div.home').animate({ left: positions[0] }, speed, "", function() { reset(id); } );			$('div.visie').stop();			$('div.visie').animate({ left: positions[1] }, speed, "", function() { reset(id); } );			$('div.projecten').stop();			$('div.projecten').animate({ left: positions[2] }, speed, "", function() { reset(id); } );			$('div.beheer').stop();			$('div.beheer').animate({ left: positions[3] }, speed, "", function() { reset(id); } );			$('div.contact').stop();			$('div.contact').animate({left: positions[4] }, speed, "", function() { reset(id); } );				}				function reset(id)		{			setHeight();			$("div." + id).removeClass("animate");		}			}				/* slideShow	------------------------------------------------------------------*/	var slideInt;	function slideShow() {		var i = 0;		var colCount;				$('.multiple').removeClass('multiple');		clearInterval(slideInt);		$('.' + currentId + ' .filled' ).each(function() {			if ( $('img', this).length > 1 ) {				$(this).addClass('multiple');			}		});		colCount = $('.multiple').length;		$cols = shuffle( $('.multiple') );		if (colCount > 0) {			setTimeout(slideIn, 1000);			setTimeout(function() {				slideInt = setInterval(slideIn, 4000);			}, 1000);			i = 0;		};				function slideIn() {			var $currentCol = $cols[i];			var $nextSlide = $('.active', $currentCol).next().length > 0 ? $('.active', $currentCol).next() : $('img:first', $currentCol);						if ($nextSlide.hasClass("blank-frame")) {				$('.active', $currentCol).removeClass('active').addClass('post-active');				$nextSlide.addClass('active');			} else {				if (Math.round(Math.random()) == 0) {					var pos = "192px";				} else {					var pos = "-192px";				}				$nextSlide					.css({zIndex: "11", left: pos})					.animate({						left: 0					}, 1500 , function() {						$('.active', $currentCol).removeClass('active');						$('.post-active', $currentCol).removeClass('post-active');						$(this).css("zIndex", "").addClass('active');					});			}									if (i+1 == colCount) {				i=0;				$cols = shuffle( $('.multiple') );			} else {				i++;			};						if ($nextSlide.hasClass("blank-frame")) {				slideIn();			}		}			}				/* Toolbox	------------------------------------------------------------------*/	function setLinks()	{		$('a[rel=external]').each(function() {			$(this).attr({target: "_blank"});		});	}		/*  IE PNG fix	------------------------------------------------------------------*/	if($.browser.msie && $.browser.version < 7){		$('.overlay-one, .overlay-two, .overlay-three, .overlay-four').pngFix();	}	});function shuffle(a){    for(var j, x, i = a.length; i; j = parseInt(Math.random() * i), x = a[--i], a[i] = a[j], a[j] = x);    return a;};
