/*
 * jQuery hashchange event - v1.3 - 7/21/2010
 * http://benalman.com/projects/jquery-hashchange-plugin/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('<iframe tabindex="-1" title="empty"/>').hide().one("load",function(){r||l(a());n()}).attr("src",r||"javascript:0").insertAfter("body")[0].contentWindow;h.onpropertychange=function(){try{if(event.propertyName==="title"){q.document.title=h.title}}catch(s){}}}};j.stop=k;o=function(){return a(q.location.href)};l=function(v,s){var u=q.document,t=$.fn[c].domain;if(v!==s){u.title=h.title;u.open();t&&u.write('<script>document.domain="'+t+'"<\/script>');u.close();q.location.hash=v}}})();return j})()})(jQuery,this);;
(function ($) {
  // maakt taxonomie overview views-rows even hoog
  
  Drupal.behaviors.blokheight = {
		attach: function(context, settings) {
			$(window).load(function(){
				var currentTallest = 0,
				currentRowStart = 0,
				rowDivs = new Array(),
				$el,
				topPosition = 0;
				$('.view-taxonomy-term .views-row').each(function() {
					$el = $(this);
					topPostion = $el.position().top;
					
					if (currentRowStart != topPostion) {
						for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
							rowDivs[currentDiv].height(currentTallest);
						}
						rowDivs.length = 0; // empty the array
						currentRowStart = topPostion;
						currentTallest = $el.height();
						rowDivs.push($el);
					} else {
						rowDivs.push($el);
						currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
					}
					for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
						rowDivs[currentDiv].height(currentTallest);
					}
					
				});
				
			});			
    }
  }
  
	// filtert de taxonomieën
  Drupal.behaviors.taxofilter = {
		attach: function(context, settings) {
			$(window).load(function(){
				
				$('.section-projecten .view-taxonomy-term-filtering .views-row a').click(function() {
						$(this).parent().siblings('.active').removeClass('active');
						$(this).parent().addClass('active');				
						
						var type = $(this).attr('class');
						
						$('#content .view-taxonomy-term .views-row a').each(function() {
							if($(this).hasClass(type)) {
									$(this).stop().animate({ opacity: 1 }, 500 );
							} else {							
									$(this).stop().animate({ opacity: 0.3 }, 500 );	
							}																											 
						})
						return false;
				});
				
			});			
    }
  }
  
	// animate anchor links
  Drupal.behaviors.anchorschroll = {
		attach: function(context, settings) {
			$(window).load(function(){
															
				$(".front #block-system-main-menu .content>ul.menu>li>a").click(function(event){
					//prevent the default action for the click event
					event.preventDefault();
			
					//get the full url - like mysitecom/index.htm#home
					var full_url = this.href;
			
					//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
					var parts = full_url.split("#");
					var trgt = parts[1];
			
					//get the top offset of the target anchor
					var target_offset = $("#"+trgt).offset();
					var target_top = target_offset.top;
			
					//goto that anchor by setting the body scroll top to anchor top
					$('html, body').animate({scrollTop:target_top}, 500);
				});
				
			});			
    }
  }
	
})(jQuery);;

