
// Widget Margin
jQuery(document).ready(function() {
	jQuery('.Widget:nth-child(3n)').addClass("Last");
});


// Navigation LinkNudge
jQuery(document).ready(function() {
	jQuery("footer ul li").hover(function() {
		jQuery(this).find("a").stop().animate({ 
			marginLeft: "5"
		}, 200);
	} , function() {
		jQuery(this).find("a").stop().animate({
			marginLeft: "0"
		}, 200);
	});
});


// Button Animation
jQuery(document).ready(function() {
	jQuery('.Button, .gform_button').css({backgroundPosition: "right 0"})
	.mouseover(function(){
		jQuery(this).stop().animate({backgroundPosition:"(right -36px)"}, {duration:200})
	})
	.mouseout(function(){
		jQuery(this).stop().animate({backgroundPosition:"(right 0)"}, {duration:200})
	})
});
jQuery(document).ready(function() {
	jQuery('.Button.Share, .Button.Favo').css({backgroundPosition: "left 0"})
	.mouseover(function(){
		jQuery(this).stop().animate({backgroundPosition:"(left -36px)"}, {duration:200})
	})
	.mouseout(function(){
		jQuery(this).stop().animate({backgroundPosition:"(left 0)"}, {duration:200})
	})
});

// Toolbar Tooltips
jQuery(document).ready(function(){
	jQuery(".Trigger.Fav").click(function(){
		jQuery(".Panel.Fav").toggle("fast");
		jQuery(this).toggleClass("Active");
		jQuery(".Trigger.Share, .Trigger.Social").removeClass("Active");
		jQuery(".Panel.Share, .Panel.Social").fadeOut();
		return false;
	});
	jQuery(".Trigger.Share").click(function(){
		jQuery(".Panel.Share").toggle("fast");
		jQuery(this).toggleClass("Active");
		jQuery(".Trigger.Fav, .Trigger.Social").removeClass("Active");
		jQuery(".Panel.Fav, .Panel.Social").fadeOut();
		return false;
	});
	jQuery(".Trigger.Social").click(function(){
		jQuery(".Panel.Social").toggle("fast");
		jQuery(this).toggleClass("Active");
		jQuery(".Trigger.Fav, .Trigger.Share").removeClass("Active");
		jQuery(".Panel.Fav, .Panel.Share").fadeOut();
		return false;
	});
});


// Toevoegingen - Jurre

jQuery(document).ready(function() {
	// Products lightbox
	
	jQuery("div.Product a.Fancy, div.Product a.Zoom").each(function() {
		$me = jQuery(this);
		
		var href = $me.attr("href");
		
		$me.attr("href", href + "?lightbox=true");
	});

	jQuery("html.page_in_lightbox .BackBtn").click(function() {
		parent.jQuery.fancybox.close();
	});
	
	
	// Share button
	
	jQuery(".Button.Share").click(function() {
		jQuery("#send_to_friend").fadeIn(200);
		
		jQuery(this).unbind("click");
	});
	
	
	// Load Isotope

	var $container = jQuery('#container');
	var filters = {};
	
	if($container.length)
	{	
		$container.isotope({
			ProductSelector: '.Product',
			masonry: {
				columnWidth: 35
			}
		});
		
		// Isotope Dropdown Filter
			
		jQuery(".DropFilter dt a").click(function() {
			jQuery(".DropFilter dd ul").toggle();
			
			return false;
		});
		
		jQuery(".DropFilter ul.filter li a").click(function() {
			var text = jQuery(this).text();
				
			jQuery(".DropFilter dt a span").html(text);
			jQuery(".DropFilter dd ul").hide();
		});
		
		// Initialize product filter hashtags
		
		jQuery("ul.filter li a").each(function() {
			var $me = jQuery(this);
	
			var params = [{name: $me.parents("ul").attr("data-filter-group"), value: $me.attr("data-filter-value")}];
	
			$me.attr("href", "#" + jQuery.param(params));
			
			$me.removeAttr("data-filter-value");
		});
	
		jQuery("ul.filter li a").click(function() {
			if(jQuery(this).hasClass("selected"))
				return;
						
			var href = jQuery(this).attr('href').replace(/^#/, "");
			var option = jQuery.deparam(href, true);
			var state = jQuery.bbq.getState();
	
			if((option.cat || option.cat === "") && state.cat != option.cat)
			{
				option.combo = "";
			}
			
			jQuery.bbq.pushState(option);
			
			return false;
		});
			
		jQuery(window).bind("hashchange", function(event) {
			// Do filter
			
			var hashOptions = jQuery.deparam.fragment();
			var filter = {filter: ".Product"};
			var filterstring = "";
			
			if(hashOptions.cat)
				filterstring += hashOptions.cat;
			
			if(hashOptions.combo)
				filterstring += hashOptions.combo;
			
			if(filterstring)
				filter.filter = filterstring;
				
			jQuery("#container").isotope(filter);
			
			// Change button classes
			
			jQuery("ul.filter a").removeClass("selected");
			
			if(hashOptions.cat)
			{
				var cat_url = jQuery.param({cat: hashOptions.cat});
				
				jQuery("ul.filter a[href='#" + cat_url + "']").addClass("selected");
			}
			
	
			var anchor;
			
			if(hashOptions.combo)
			{
				var combo_url = jQuery.param({combo: hashOptions.combo});
				anchor = jQuery("ul.filter a[href='#" + combo_url + "']");
			} else
			{
				anchor = jQuery("ul.filter a[href='#combo=']");
			}
			
			if(anchor.length)
			{
				anchor.addClass("selected");
				
				jQuery(".DropFilter dt a span").html(anchor.text());
				jQuery(".DropFilter dd ul").hide();
			}
		}).trigger("hashchange");
	}
});


// New button nudge

/**
 * @author Alexander Farkas
 * v. 1.22
 */

(function($) {
	if(!document.defaultView || !document.defaultView.getComputedStyle){ // IE6-IE8
		var oldCurCSS = $.curCSS;
		$.curCSS = function(elem, name, force){
			if(name === 'background-position'){
				name = 'backgroundPosition';
			}
			if(name !== 'backgroundPosition' || !elem.currentStyle || elem.currentStyle[ name ]){
				return oldCurCSS.apply(this, arguments);
			}
			var style = elem.style;
			if ( !force && style && style[ name ] ){
				return style[ name ];
			}
			return oldCurCSS(elem, 'backgroundPositionX', force) +' '+ oldCurCSS(elem, 'backgroundPositionY', force);
		};
	}
	
	var oldAnim = $.fn.animate;
	$.fn.animate = function(prop){
		if('background-position' in prop){
			prop.backgroundPosition = prop['background-position'];
			delete prop['background-position'];
		}
		if('backgroundPosition' in prop){
			prop.backgroundPosition = '('+ prop.backgroundPosition;
		}
		return oldAnim.apply(this, arguments);
	};
	
	function toArray(strg){
		strg = strg.replace(/left|top/g,'0px');
		strg = strg.replace(/right|bottom/g,'100%');
		strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
		var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
		return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
	}
	
	$.fx.step. backgroundPosition = function(fx) {
		if (!fx.bgPosReady) {
			var start = $.curCSS(fx.elem,'backgroundPosition');
			if(!start){//FF2 no inline-style fallback
				start = '0px 0px';
			}
			
			start = toArray(start);
			fx.start = [start[0],start[2]];
			var end = toArray(fx.end);
			fx.end = [end[0],end[2]];
			
			fx.unit = [end[1],end[3]];
			fx.bgPosReady = true;
		}
		//return;
		var nowPosX = [];
		nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
		nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];           
		fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

	};
})(jQuery);
