var tweetNum = 0;
var tweetCount = 4;

function nextTweet() {
	var prevTweetNum = tweetNum;

	tweetNum++;
	if (tweetNum == tweetCount) {
		tweetNum = 0;
	}

	//alert('test');

	jQuery('.tweet:nth-child(' + (prevTweetNum + 1) + ')').fadeOut();
	jQuery('.tweet:nth-child(' + (tweetNum + 1) + ')').fadeIn();

	setTimeout('nextTweet()', 10000);
}

jQuery(document).ready(function() {
	jQuery('.archive-page-button, .archive-page-button-active').click(function() {
		var pageNum = parseInt(jQuery(this).html());
		jQuery('.archive-page-button-active').attr('class', 'archive-page-button');
		jQuery(this).attr('class', 'archive-page-button-active');
		jQuery('.archive-container-inner').animate({ left: 0 - ((pageNum - 1) * 372) }, 500);
		return false;
	});
	
	setTimeout('nextTweet()', 10000);
});;
/*
 Color animation jQuery-plugin
 http://www.bitstorm.org/jquery/color-animation/
 Copyright 2011 Edwin Martin <edwin@bitstorm.org>
 Released under the MIT and GPL licenses.
*/
(function(d){function i(){var b=d("script:first"),a=b.css("color"),c=false;if(/^rgba/.test(a))c=true;else try{c=a!=b.css("color","rgba(0, 0, 0, 0.5)").css("color");b.css("color",a)}catch(e){}return c}function g(b,a,c){var e="rgb"+(d.support.rgba?"a":"")+"("+parseInt(b[0]+c*(a[0]-b[0]),10)+","+parseInt(b[1]+c*(a[1]-b[1]),10)+","+parseInt(b[2]+c*(a[2]-b[2]),10);if(d.support.rgba)e+=","+(b&&a?parseFloat(b[3]+c*(a[3]-b[3])):1);e+=")";return e}function f(b){var a,c;if(a=/#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(b))c=
[parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],16),1];else if(a=/#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(b))c=[parseInt(a[1],16)*17,parseInt(a[2],16)*17,parseInt(a[3],16)*17,1];else if(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(b))c=[parseInt(a[1]),parseInt(a[2]),parseInt(a[3]),1];else if(a=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]*)\s*\)/.exec(b))c=[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10),parseFloat(a[4])];return c}
d.extend(true,d,{support:{rgba:i()}});var h=["color","backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","outlineColor"];d.each(h,function(b,a){d.fx.step[a]=function(c){if(!c.init){c.a=f(d(c.elem).css(a));c.end=f(c.end);c.init=true}c.elem.style[a]=g(c.a,c.end,c.pos)}});d.fx.step.borderColor=function(b){if(!b.init)b.end=f(b.end);var a=h.slice(2,6);d.each(a,function(c,e){b.init||(b[e]={a:f(d(b.elem).css(e))});b.elem.style[e]=g(b[e].a,b.end,b.pos)});b.init=true}})(jQuery);
;
/*jslint browser: true */ /*global jQuery: true */

/**
 * jQuery Cookie plugin
 *
 * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

// TODO JsDoc

/**
 * Create a cookie with the given key and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String key The key of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given key.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String key The key of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function (key, value, options) {
    
    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }
        
        value = String(value);
        
        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};
;
var colors = [
	'#FF003C',
	'#cc00ff',
	'#4800ff',
	'#0078ff',
	'#1ab700',
	'#ff9600',
];

var colorNum = 1;
var colorStartTime = 0;
var colorDelay = 60000;

function rotateColors(delay) {
	//alert('rotateColors: ' + colorNum);
 	colorStartTime = new Date().getTime();;

	if (delay > 0 && delay < colorDelay) {
		colorStartTime -= (colorDelay - delay);
		//alert(delay);
	} else {
		var delay = colorDelay;
	}
		
	color = colors[colorNum];

	//alert(delay);
	
	jQuery('.colored').animate({
		backgroundColor: colors[colorNum]
	}, delay);
	jQuery('h2, #content a').animate({
		color: colors[colorNum]
	}, delay);

	setTimeout(function() {
		colorNum++;
		if (colorNum >= colors.length) {
			colorNum = 0;
		}
		rotateColors();
	}, delay);
}

jQuery(document).ready(function() {
	storedColor = jQuery.cookie('color');
	if (typeof(storedColor) != 'undefined') {
		jQuery('.colored').css('background-color', storedColor);
		jQuery('h2, #content a').css('color', storedColor);
 	}

	storedColorNum = parseInt(jQuery.cookie('colorNum'));
	if (storedColorNum > 0 && storedColorNum < colors.length) {
		colorNum = storedColorNum;
	}

	storedColorTime = parseInt(jQuery.cookie('colorTime'));
	//alert(storedColorTime);
	if (storedColorTime > 0 && storedColorTime < colorDelay) {
		rotateColors(colorDelay - storedColorTime);
	} else {
		rotateColors();
	}

	jQuery(window).unload(function() {
		var color = jQuery('.colored').css('background-color');
		jQuery.cookie('color', color);
		jQuery.cookie('colorNum', colorNum);
		//alert(colorStartTime);
		//alert(new Date().getTime() - colorStartTime);
		jQuery.cookie('colorTime', (new Date().getTime() - colorStartTime));
	  //alert('Color is: ' + color);
	});
});;
cloudHotspots = [
	{
		x: 0,
		y: 0,
		h: 112,
		w: 112,
		link: '/iphone'
	},
	{
		x: 113,
		y: 0,
		h: 112,
		w: 112,
		link: '/ipad'
	},
	{
		x: 226,
		y: 0,
		h: 112,
		w: 112,
		link: '/google-android-apps'
	},
	{
		x: 339,
		y: 0,
		h: 112,
		w: 112,
		link: '/tablet-apps'
	},
	{
		x: 0,
		y: 113,
		h: 112,
		w: 112,
		link: '/websites'
	},
	{
		x: 113,
		y: 112,
		h: 112,
		w: 112,
		link: '/seo'
	},
	{
		x: 226,
		y: 113,
		h: 112,
		w: 112,
		link: '/social-media'
	},
	{
		x: 339,
		y: 113,
		h: 112,
		w: 112,
		link: '/e-marketing'
	},
	{
		x: 0,
		y: 226,
		h: 112,
		w: 112,
		link: '/e-learning'
	},
	{
		x: 113,
		y: 226,
		h: 112,
		w: 112,
		link: '/content-creatie-tools'
	},
	{
		x: 226,
		y: 226,
		h: 112,
		w: 112,
		link: '/app-learning'
	},
	{
		x: 339,
		y: 226,
		h: 112,
		w: 112,
		link: '/learning-management'
	},
	{
		x: 0,
		y: 112,
		h: 339,
		w: 112,
		link: '/over-mdl-solutions'
	},
	{
		x: 113,
		y: 339,
		h: 112,
		w: 112,
		link: '/partners'
	},
	{
		x: 226,
		y: 339,
		h: 112,
		w: 112,
		link: '/onze-werkwijze'
	},
	{
		x: 339,
		y: 339,
		h: 112,
		w: 112,
		link: '/portfolio'
	}
];

jQuery(document).ready(function () {
//(function($) {
	//alert('ffdg');

	//jQuery('.mousetrap').css('left', '100px');
	
	/*jQuery('.mousetrap').mousemove(function(e) {
		var x = e.pageX - this.offsetLeft;
    var y = e.pageY - this.offsetTop;

		if (x > 200) {
			jQuery(this).css('cursor', 'hand');
		} else {
			jQuery(this).css('cursor', 'pointer');
		}
	});*/

	jQuery('a.cloud-zoom, .mousetrap').live('mousemove', function(e) {
		var offset = jQuery(this).offset();

		var x = e.pageX - offset.left;
    var y = e.pageY - offset.top;

		for (var i = 0; i < cloudHotspots.length; i++) {
			var hotspot = cloudHotspots[i];
			if (x >= hotspot.x && x <= (hotspot.x + hotspot.w) && y >= hotspot.y && y <= (hotspot.y + hotspot.h)) {
				jQuery(this).css('cursor', 'pointer');
				return;
			}
		}

		jQuery(this).css('cursor', 'default');
	});

	jQuery('a.cloud-zoom, .mousetrap').live('click', function(e) {
		e.preventDefault();

		var offset = jQuery(this).offset();

		var x = e.pageX - offset.left;
    var y = e.pageY - offset.top;

		for (var i = 0; i < cloudHotspots.length; i++) {
			var hotspot = cloudHotspots[i];
			if (x >= hotspot.x && x <= (hotspot.x + hotspot.w) && y >= hotspot.y && y <= (hotspot.y + hotspot.h)) {
				window.location = hotspot.link;
				return;
			}
		}

		//alert('Geklikt: (' + x + ', ' + y + ', ' + link + ')');
	});
});
//})(jQuery);



/* $(document).ready(function () {
	$('#color-bar').animate( { 
		backgroundColor: '#fff600',
	}, 1000 ).animate( { 
		backgroundColor: '#72ff00',
	}, 1000 ).animate( { 
		backgroundColor: '#00a2ff',
	}, 1000 );
}); */

/*function bla(sel, color) {
	$("#navlist a").css("color", "#FFFFFF"); 
	$(sel).css("color", color); 
	/*$(sel).animate( { 
		color: color,
	}, 1000 );*/
/*	$(".colored").animate( { 
		backgroundColor: color,
	}, 1000 );
	$("#footer a").animate( { 
		color: color,
	}, 1000 );
	//$('#nav ul li.active a').animate( { 
	/*$('#content-inner a').animate( { 
		color: color,
	}, 2000 );*/
//}

/*function hashChanged(href) {
	path = href.slice((href.indexOf('#') + 1), href.length);
	$("#content-inner").hide();
	$("#content-inner").load("/load_node.php?path=" + path, "", function(){
		$("#content-inner").fadeIn("slow");
	});
	$('#sub1').css('right', '0px');
	$('#sub1').css('opacity', '100');
	$('#sub2').css('right', '-1024px');
	$('#sub2').css('opacity', '0');
	$("#sub1").animate( { 
		right: 1024,
		opacity: 0,
	}, 750 );	
	$("#sub2").animate( { 
		right: 0,
		opacity: 100,
	}, 750 );	
}*/

//Drupal.behaviors.mdl = {
//	attach: function(context) {
		//(function($) {
		//alert('document ready');
		/*if (location.href.indexOf('#') != -1) {
			hashChanged(location.href);
		}*/
/*		$('a').click(function () { 
			if (this.href.indexOf('#') != -1) {
				hashChanged(this.href);
			}
		});
		$('li.menu-357 a').click(function () { bla("li.menu-357 a", '#ff003c'); });
		$('li.menu-356 a').click(function () { bla("li.menu-356 a", '#ff6c00'); });
		$('li.menu-336 a').click(function () { bla("li.menu-336 a", '#fff600'); });
		$('li.menu-337 a').click(function () { bla("li.menu-337 a", '#0be000'); });
		$('li.menu-355 a').click(function () { bla("li.menu-355 a", '#00a2ff'); });*/

//	}
//};
//})(jQuery);
;
var portfolioOverviewAnimationInterval = 7000;
var portfolioOverviewItemWidth = 319;
var portfolioOverviewItemNum = 0;
var portfolioOverviewItemCount;

function animatePortfolioOverview(reverse) {
	portfolioOverviewItemCount = jQuery('.portfolio-overview-item').length;

	if (!reverse) {
		portfolioOverviewItemNum++;
	} else {
		portfolioOverviewItemNum--;
	}

	if (portfolioOverviewItemNum < 0) {
		portfolioOverviewItemNum += portfolioOverviewItemCount;
	}
	if (portfolioOverviewItemNum >= portfolioOverviewItemCount) {
		portfolioOverviewItemNum -= portfolioOverviewItemCount;
	}

	jQuery('.portfolio-overview-item').css('display', 'none');

	for (var pos = 0; pos < 4; pos++) {
		var num = portfolioOverviewItemNum + pos;
		if (!reverse) {
			num--;
		}

		if (num < 0) {
			num += portfolioOverviewItemCount;
		} 
		if (num >= portfolioOverviewItemCount) {
			num -= portfolioOverviewItemCount;
		}
		
		var el = jQuery('.portfolio-overview-item:eq(' + num + ')');
		el.css('display', 'inline');
		el.css('position', 'absolute');
		el.css('left', (pos * portfolioOverviewItemWidth) + 'px');
	}

	if (!reverse) {
		jQuery('.portfolio-overview-container-inner').css('left', '0px');
		jQuery('.portfolio-overview-container-inner').animate({ left: -portfolioOverviewItemWidth }, 500);
	} else {
		jQuery('.portfolio-overview-container-inner').css('left', '-300px');
		jQuery('.portfolio-overview-container-inner').animate({ left: 0 }, 500);
	}

	setTimeout('animatePortfolioOverview(false)', portfolioOverviewAnimationInterval);
}

jQuery(document).ready(function() {
	setTimeout('animatePortfolioOverview(false)', portfolioOverviewAnimationInterval);
});;

