$(document).ready(function(){
	//FEATURED
	/*$('div.features div.wrap').featured({
		interval	: 8000,
		start		: 0
	});*/
	
	//SLIMBOX
	$("a[rel^='slimbox']").slimbox({
		loop: false,
		overlayOpacity: 0.8,
		overlayFadeDuration: 0,
		resizeDuration: 350,
		resizeEasing: "swing",
		initialWidth: 250,
		initialHeight: 250,
		imageFadeDuration: 200,
		captionAnimationDuration: 200,
		counterText: "Afbeelding {x} van {y}"
	});
	
	//FIX CLICKABLE BUTTONS
	$('a button').each(function(){
		var url = $(this).parent('a').attr('href');
		$(this).click(function(){
			window.location = url;
		});
	});
	
	//SEARCH INPUT
	$('div.topMenu form.search input').focus(function(){
		this.value = '';
		$(this).css({'background-color' : '#FFF'}).animate({'width' : '+=50'}, 250);
	}).blur(function(){
		var defval = 'Zoeken'
		var val = this.value;
		if(val && val != defval){
			this.form.submit();
		}else{
			this.value = defval;
			$(this).css({'background-color' : '#e8ebeb'}).animate({'width' : '-=50'}, 250);
		}
	});
	
	//DISABLED BUTTONS
	$('button[disabled]').css({'opacity' : 0.5});
	
	//SELECT ZEBRA
	$('select option:odd').addClass('alt');

	//QUICKSEARCH
	$('div.quicksearch select[name="cat"]').change(function(){
		$('div.quicksearch select[name="type"]').attr({'value' : ''});
		$('div.quicksearch select[name="brand"]').attr({'value' : ''});
		$('div.quicksearch select[name="serie"]').attr({'value' : ''});
	});
	$('div.quicksearch select[name="brand"]').change(function(){
		$('div.quicksearch select[name="serie"]').attr({'value' : ''});
	});
	$('div.quicksearch select').change(function(){
		this.form.submit();
	});
	$('div.quicksearch label.disabled, div.quicksearch div.disabled').each(function(){
		$(this).css({'opacity' : 0.5}).find('select').attr({'disabled' : 'true'});
	});
	
	//FILTER
	$('table.filter select').change(function(){
		this.form.submit();
	});
	
	//DATA TABLE
	$('table.data tr:odd').addClass('alt');
	$('table.data tr').hover(function(){
		$(this).addClass('hover');
	}, function(){
		$(this).removeClass('hover');
	});
	
	//ADD2CART
	$('a.addToCart').click(function(){
		$('form.shop_item').submit();
		return false;
	});
	
	//EXTRA GEGEVENS TOGGLE
	$('input[name="gift"]').change(function(){
		var val = $(this).attr('checked');
		if(val){
			$('div.moar').show(500, function(){
				$.scrollTo($('input[name="gift"]').parent(), 1000, 'easeInOutCubic');							 
			}).fadeTo(500, 1);
		}else{
			$('div.moar').fadeTo(500, 0).hide(500);
		}
	});
});
