//external links

function externalLinks() {

if (!document.getElementsByTagName) return;

var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
var relvalue = anchor.getAttribute("rel");

if (anchor.getAttribute("href")) {
var external = /external/;
var relvalue = anchor.getAttribute("rel");
if (external.test(relvalue)) { anchor.target = "_blank"; }
}
}
}

//spamcheck

function spamCheck() 
{
	if(document.getElementById('spamcontroleveld')) 
	{
		document.getElementById('spamcontrole').value = 'nee';
		document.getElementById('spamcontroleveld').style.display = 'none';
	}
}

function clearText(thefield){
	if (thefield.defaultValue==thefield.value) {
		thefield.value = "";
	}
}


/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuart',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */
 
 
 /* masonry */
 
 /**
 * jQuery Masonry v2.0.110927
 * A dynamic layout plugin for jQuery
 * The flip-side of CSS Floats
 * http://masonry.desandro.com
 *
 * Licensed under the MIT license.
 * Copyright 2011 David DeSandro
 */
(function(a,b,c){var d=b.event,e;d.special.smartresize={setup:function(){b(this).bind("resize",d.special.smartresize.handler)},teardown:function(){b(this).unbind("resize",d.special.smartresize.handler)},handler:function(a,b){var c=this,d=arguments;a.type="smartresize",e&&clearTimeout(e),e=setTimeout(function(){jQuery.event.handle.apply(c,d)},b==="execAsap"?0:100)}},b.fn.smartresize=function(a){return a?this.bind("smartresize",a):this.trigger("smartresize",["execAsap"])},b.Mason=function(a,c){this.element=b(c),this._create(a),this._init()};var f=["position","height"];b.Mason.settings={isResizable:!0,isAnimated:!1,animationOptions:{queue:!1,duration:500},gutterWidth:0,isRTL:!1,isFitWidth:!1},b.Mason.prototype={_filterFindBricks:function(a){var b=this.options.itemSelector;return b?a.filter(b).add(a.find(b)):a},_getBricks:function(a){var b=this._filterFindBricks(a).css({position:"absolute"}).addClass("masonry-brick");return b},_create:function(c){this.options=b.extend(!0,{},b.Mason.settings,c),this.styleQueue=[],this.reloadItems();var d=this.element[0].style;this.originalStyle={};for(var e=0,g=f.length;e<g;e++){var h=f[e];this.originalStyle[h]=d[h]||""}this.element.css({position:"relative"}),this.horizontalDirection=this.options.isRTL?"right":"left",this.offset={};var i=b(document.createElement("div"));this.element.prepend(i),this.offset.y=Math.round(i.position().top),this.options.isRTL?(i.css({"float":"right",display:"inline-block"}),this.offset.x=Math.round(this.element.outerWidth()-i.position().left)):this.offset.x=Math.round(i.position().left),i.remove();var j=this;setTimeout(function(){j.element.addClass("masonry")},0),this.options.isResizable&&b(a).bind("smartresize.masonry",function(){j.resize()})},_init:function(a){this._getColumns("masonry"),this._reLayout(a)},option:function(a,c){b.isPlainObject(a)&&(this.options=b.extend(!0,this.options,a))},layout:function(a,c){var d,e,f,g,h,i;for(var j=0,k=a.length;j<k;j++){d=b(a[j]),e=Math.ceil(d.outerWidth(!0)/this.columnWidth),e=Math.min(e,this.cols);if(e===1)this._placeBrick(d,this.colYs);else{f=this.cols+1-e,g=[];for(i=0;i<f;i++)h=this.colYs.slice(i,i+e),g[i]=Math.max.apply(Math,h);this._placeBrick(d,g)}}var l={};l.height=Math.max.apply(Math,this.colYs)-this.offset.y;if(this.options.isFitWidth){var m=0,j=this.cols;while(--j){if(this.colYs[j]!==this.offset.y)break;m++}l.width=(this.cols-m)*this.columnWidth-this.options.gutterWidth}this.styleQueue.push({$el:this.element,style:l});var n=this.isLaidOut?this.options.isAnimated?"animate":"css":"css",o=this.options.animationOptions,p;for(j=0,k=this.styleQueue.length;j<k;j++)p=this.styleQueue[j],p.$el[n](p.style,o);this.styleQueue=[],c&&c.call(a),this.isLaidOut=!0},_getColumns:function(){var a=this.options.isFitWidth?this.element.parent():this.element,b=a.width();this.columnWidth=this.options.columnWidth||this.$bricks.outerWidth(!0)||b,this.columnWidth+=this.options.gutterWidth,this.cols=Math.floor((b+this.options.gutterWidth)/this.columnWidth),this.cols=Math.max(this.cols,1)},_placeBrick:function(a,b){var c=Math.min.apply(Math,b),d=0;for(var e=0,f=b.length;e<f;e++)if(b[e]===c){d=e;break}var g={top:c};g[this.horizontalDirection]=this.columnWidth*d+this.offset.x,this.styleQueue.push({$el:a,style:g});var h=c+a.outerHeight(!0),i=this.cols+1-f;for(e=0;e<i;e++)this.colYs[d+e]=h},resize:function(){var a=this.cols;this._getColumns("masonry"),this.cols!==a&&this._reLayout()},_reLayout:function(a){var b=this.cols;this.colYs=[];while(b--)this.colYs.push(this.offset.y);this.layout(this.$bricks,a)},reloadItems:function(){this.$bricks=this._getBricks(this.element.children())},reload:function(a){this.reloadItems(),this._init(a)},appended:function(a,b,c){if(b){this._filterFindBricks(a).css({top:this.element.height()});var d=this;setTimeout(function(){d._appended(a,c)},1)}else this._appended(a,c)},_appended:function(a,b){var c=this._getBricks(a);this.$bricks=this.$bricks.add(c),this.layout(c,b)},remove:function(a){this.$bricks=this.$bricks.not(a),a.remove()},destroy:function(){this.$bricks.removeClass("masonry-brick").each(function(){this.style.position="",this.style.top="",this.style.left=""});var c=this.element[0].style;for(var d=0,e=f.length;d<e;d++){var g=f[d];c[g]=this.originalStyle[g]}this.element.unbind(".masonry").removeClass("masonry").removeData("masonry"),b(a).unbind(".masonry")}},b.fn.imagesLoaded=function(a){function h(){--e<=0&&this.src!==f&&(setTimeout(g),d.unbind("load error",h))}function g(){a.call(b,d)}var b=this,d=b.find("img").add(b.filter("img")),e=d.length,f="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";e||g(),d.bind("load error",h).each(function(){if(this.complete||this.complete===c){var a=this.src;this.src=f,this.src=a}});return b};var g=function(a){this.console&&console.error(a)};b.fn.masonry=function(a){if(typeof a=="string"){var c=Array.prototype.slice.call(arguments,1);this.each(function(){var d=b.data(this,"masonry");if(!d)g("cannot call methods on masonry prior to initialization; attempted to call method '"+a+"'");else{if(!b.isFunction(d[a])||a.charAt(0)==="_"){g("no such method '"+a+"' for masonry instance");return}d[a].apply(d,c)}})}else this.each(function(){var c=b.data(this,"masonry");c?(c.option(a||{}),c._init()):b.data(this,"masonry",new b.Mason(a,this))});return this}})(window,jQuery);

 
 /* end of masonry */
 
 
 /* scrollTo */
 
 
 /**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
 
 
 
 /* end of scrollTo */
 


$(document).ready(function() {

	$("body").css({overflowX: "hidden"});

	
	

	// show work 
	
	$("#werk-items").fadeIn();
	
	// show contact flipper
	
	$(".cbxflipboard").delay(2000).fadeIn();
	
	// show tweets
	
	$("#twitter .tweet div").delay(1000).fadeIn();
	
	// Logo hover
	
	$(".logo").hover(function() {
		$(".logo-tag").show();
	} , function() { 
		$(".logo-tag").hide();
	})	
	
	
	// webhostingdomeincheckfocus
	$("input[name=domein]").focus(function() {
		$(this).css("color", "#333");
		if ($(this).val() == "uwnaam.nl") {
			$(this).val("");
		}
	});
	$("input[name=domein]").blur(function() {
		$(this).css("color", "#000000");
		if ($(this).val() == "") {
			$(this).val("uwnaam.nl");
		}
	});
	
	// Home slider 
	
	$("#home-news #home-cycle").cycle({
	
		fx: "fade",
		timeout: 7000,
		speed: 500,
		easing: "easeOutQuart",
		before: function(idx, slide) {
				// show/hide img art
				//$(slide).find("img.news-art").css({ opacity: "0" });
				//$(slide).find("img.news-art").delay(500).animate({ opacity: "1" }, 250, "easeOutQuart");
				
				$(slide).find(".title img").css({ opacity: "0" });
				$(slide).find(".title img").delay(2000).animate({ opacity: "1" }, 1000, "easeInOutQuart");
				
				//sbSweetSpeak
				$(slide).find(".title span.holder").css({ marginTop: "220px" });
				
				$(slide).find("span.holder:eq(0)").delay(750).animate({ marginTop: "0px" }, 300, "easeOutQuart", function () {
					$(this).parent().next().find(".holder").animate({ marginTop: "0px" }, 300, "easeOutQuart", arguments.callee);
					
				});					
			},
		pager:  '#home-slider-nav',
			pagerAnchorBuilder: function(idx, slide) { 
			return '<a href="#" title="Bekijk item" class= ' + idx + '></a>'; 
			}
	});
	var navWidth = $("#home-slider-nav").width(); 
	$("#home-slider-nav").css({ marginLeft: "-" + (navWidth * 0.5) + "px" });
	
	// Home slide hover
	
	$("#home-cycle").hover(function() {
		$(this).stop().animate({ opacity: "0.8" });
	} , function() { 
		$(this).stop().animate({ opacity: "1" });
	})		
	
	// Home column links hover
	
	$(".homecol a img").hover(function() {
		$(this).parent().parent().stop().css({ color: "#ccc" });
	} , function() { 
		$(this).parent().parent().stop().css({ color: "#fff" });
	})	
	
	
	// Werk hover
	
	$(".album").hover(function() {
		$(this).find(".descr").css({ opacity: "1" });
		$(this).find(".cover").css({ opacity: "0.3" });

	} , function() { 
		$(this).find(".descr").css({ opacity: "0" });
		$(this).find(".cover").css({ opacity: "1" });
	})
	
	
	
	// Werk filter
	
	$("#filter").hover(function() {
		$("#filter .list").show();
	} , function() { 
		$("#filter .list").hide();
	})	
	
	$("#filter span").click(function() {
		var myClass = $(this).attr("class");
		$("#werk-items .album").css({ height: "0", marginBottom: "0" });
		$("#werk-items ." + myClass).css({ height: "auto", marginBottom: "20px" });	
		metselWerk();
	});
	
	$("#filter span.all").click(function() {
		$("#werk-items .album").css({ height: "auto", marginBottom: "20px" });
		metselWerk();
	});
	
	
	
	// Titles subpages
	
	/*
	
		$(".page-subtitle").find("span.holder:eq(0)").delay(750).animate({ marginTop: "0px" }, 250, "easeOutQuart", function () {
			$(this).parent().next().find(".holder").animate({ marginTop: "0px" }, 250, "easeOutQuart", arguments.callee);	
		});
		
	*/
		
	// Twitter cycle.
	
	$("#twitter").cycle({
		fx: "fade",
		timeout: 6000,
		random: 1,
		speed: 200
	});
	
	
	// People cycle.
	
	$(".row1, .row2, .row3").delay(500).slideDown();
	
	$(".row1, .row3").delay(1000).cycle({
		fx: "scrollRight",
		timeout: 3000,
		speed: 1000,
		next: ".illu-webdesign"
	});	
	$(".row2").delay(1000).cycle({
		fx: "scrollLeft",
		timeout: 3000,
		speed: 1000,
		next: ".illu-webdesign"
	});	
	$(".names").delay(500).fadeIn();
	$(".names").delay(1000).cycle({
		fx: "fade",
		timeout: 3000,
		speed: 0,
		next: ".illu-webdesign"
	});	

	// Contact cycle.
	
	$(".cbxflipboard").cycle({
		fx: "fade",
		timeout: 10000,
		//next: '.cbxflipboard',
		speed: 200,
		before: function(idx, slide) {
				
				$(slide).find(".product").css({ opacity: "0" });				
				
				//$(slide).find(".stat, h2, .tag").delay(500).animate({ opacity: "1"}, 1500, "easeInOutElastic");

				
				$(slide).find("div:eq(0)").animate({ opacity: "1" }, 250, "easeOutQuart", function () {
					$(this).next().animate({ opacity: "1" }, 250, "easeOutQuart", arguments.callee);	
				});
				
			},
		after: function(idx, slide) {
				
				//$(slide).find(".product").css({ opacity: "1" });				
				
				//$(slide).find(".stat, h2, .tag").delay(500).animate({ opacity: "1"}, 1500, "easeInOutElastic");

				
				$(slide).find("div:eq(0)").delay(8000).animate({ opacity: "0" }, 250, "easeOutQuart", function () {
					$(this).next().animate({ opacity: "0" }, 250, "easeOutQuart", arguments.callee);	
				});
				
			}			
	});
	
	// BTT
	
	 $(".backtotop").click(function() {  
		$(window).scrollTo( 0, 700);
	 });		

	// Home slow-gan cycle.
	
	$(".slogans .slogantainer").cycle({
		fx: "fade",
		timeout: 0,
		random: 1,
		next: ".slogans .slogantainer"
	});
	
	// Contact stuff
		
	$(".showform").click(function() {
		$(".formulier").toggle();
	});		

	// Werk filter
	
	$(".product a").hover(function() {
		$(this).parent().find('h2').css({ color: "#669900" });
		$(this).parent().find('.dash').css({ borderTop: "1px solid #ccc" });
		$(this).parent().find('.leesmeer').css({ color: "#000" });
	} , function() { 
		$(this).parent().find('h2').css({ color: "#000" });
		$(this).parent().find('.dash').css({ borderTop: "1px solid #e9e9e9" });
		$(this).parent().find('.leesmeer').css({ color: "#888" });
	})		
	
	// prod pags count up
	// moved to pages
	
	



	
});



function metselWerk() {

	$('#werk-items').masonry({
		itemSelector : '.album, .folio-text',
		columnWidth : 330,
		isAnimated : true,
		animationOptions: {
			duration: 500,
			easing: 'easeOutQuart',
			queue: false
		  }		
	  });
			   
}



$(window).load(function () {
	
	// Werk load
	$("#werk-items .album img.cover:eq(0)").animate({ opacity: "1" }, 200, "easeOutQuint", function () {
		$(this).parent().next().find("img").animate({ opacity: "1" }, 100, "easeOutQuint", arguments.callee);
	});

	
	// Werk item page load

	$(".work img:eq(0)").animate({ opacity: "1" }, 750, "easeOutQuint", function () {
		$(this).parent().parent().next().find("img").animate({ opacity: "1" }, 750, "easeOutQuint", arguments.callee);
	});	
	
	// Home news load

	$("#home-news .home-news-slide img.news-art:eq(0)").delay(250).animate({ opacity: "1" }, function () {
		$(this).parent().next().find("img").animate({ opacity: "1" }, arguments.callee);
	});
	
	// Home slogan
	
	$(".slogans").delay(2000).fadeIn();
	
});	




$(window).resize(function() {	
	posFix();
});


function posFix() {
	var TotalWidth = $(window).width();
	var navWidth = $("#menu").width(); 
	$("#home-news .home-news-slide .home-news-slide-text").css({ marginLeft: "-485px" });
	$("#home-news, #home-news .home-news-slide").css({ width: TotalWidth + "px" });		   
}



/**
 * countdown timer with some configuration
 *
 * @version 0.1
 * @url http://jsfiddle.net/KzrwQ/1/
 * @date 2011/09/02
 * @author Conrad 'bartrail' Barthelmes
 * @licence MIT
 *
 * usage:
 *
 * $('selector').countTo({
 *   interval:    1000,                             // miliseconds the interval is repeated (aka speed)
 *   startNumber: 10,                               // start from 10 or any other integer
 *   endNumber:   0,                                // end at 0 or any other integer
 *
 *   onLoop:      function(self, current, loop) {   // fired on every loop
 *     self;      // the fetched element
 *     current;   // current number of interval
 *     loop;      // finished loops
 *
 *     // default behaviour:
 *     $(self).text(current);
 *   },
 *
 *   onStart:     function(self) {                  // fired on the beginning
 *     self;      // the fetched element
 *   },
 *
 *   onFinish:    function(self, current, loop) {   // fired when finished
 *     self;      // the fetched element
 *     current;   // current number of interval
 *     loop;      // finished loops
 *   }
 * });
 *
 */

jQuery.fn.countTo = function(options) {
  if(this.length == 0) {
    return;
  }
  // save reference to self
  var self     = this;
  // merge optoins
  self.options = {};
  jQuery.extend(true, self.options, {
    interval   : 1000,
    startNumber: 10,
    endNumber  : 0,
    onLoop     : function(self, current, loop) {
      $(self).text(current);
    },
    onStart    : function(self) {},
    onFinish   : function(self, current, loop) {}
  }, options);

  // init the start number
  self.current   = self.options.startNumber;
  // get the direction, true is 'down', false is 'up'
  self.direction = self.options.startNumber > self.options.endNumber ? true : false;
  // the current iteration
  self.loop      = 0;
  // whether is finished or not
  self.finished  = false;
  // the timing function
  self.timer     = function(self) {
    self.intervalId = setInterval(self._interval, self.options.interval)
  }

  self._interval  = function() {
    self.options.onLoop(self, self.current, self.loop);
    // going down
    if(self.direction) {
      if(self.current > self.options.endNumber) {
        self.current--;
      }else{
        self.finished = true;
      }
    // going up
    }else{
      if(self.current < self.options.endNumber) {
        self.current++;
      }else{
        self.finished = true;
      }
    }
    // clear interval and fire onFinish when finished
    if(self.finished) {
      clearInterval(self.intervalId);
      self.options.onFinish(self, self.current, self.loop)
    }
    self.loop++;
  }

  self.start = function(self) {
    self.options.onStart(self);
    self.timer(self);
  }

  self.start(self);
}


$(window).scroll(function() {

});
