// JavaScript Document
$(document).ready(function() {
	
	$('#main-content div.content-tabs').each(function(i, tab){
			    var slideshow = ($(this).find('.slideshow'));
			    slideshow.cycle({ 
				    timeout: 0,
				    next:  $(this).find('.next'),
				    prev: $(this).find('.prev'),
				    after: function(){$(this).parent().css({'height':$(this).height()}); $(slideshow).cycle({timeout:4000});}
			    });
			    $(this).find('.pause').click(function() {slideshow.cycle({timeout:0}); return false;});
    			
		    });
    	
	    $(function () {

		    var tabs = $('#main-content div.content-tabs');
		    $('#main-content ul.tabs a').click(function () {
    		
			    var tab = tabs.hide().filter(this.hash).show();
			    $(this).parent().siblings('.active').removeClass('active');
			    $(this).parent().addClass('active');
    			
			    tabs.find('.slideshow').cycle({timeout:0});
			    tab.find('.slideshow').cycle({timeout:4000});
    			
			    return false;
		    }).filter(':first').click();
	    });
	
	$('#slides').after('<ol class="pagination"></ol>').cycle({ 
	    timeout: 5000,
	    pause: true,
		pager:'#slideshow ol.pagination',
		pagerAnchorBuilder: function(id, slide) {return('<li style="z-index:'+Number(100-id)+';"><a>'+Number(id+1)+'</a></li>');},
		before: function(currSlideElement, nextSlideElement, options, forwardFlag){ 
			var link=$(this).attr('href'); 
			$('#slideshow').find('a.more').attr('href', link);
			$('#slideshow').find('h2').hide().empty().append('<a target="_blank" href="' + link + '">' + $(this).attr('title') + '</a>').fadeIn('slow');
			$('#slideshow').find('.slideshowText').hide().empty().append( $(this).attr('rel') ).fadeIn('slow');
		}
	});
	
	$('#in-de-kijker ul.slide-container').before('<ol class="pagination"></ol>').cycle({ 
	    fx: 'scrollUp', 
  		timeout: 6000, 
    	delay:  -2000, 
		pager:'#in-de-kijker ol.pagination',
		pagerAnchorBuilder: function(id, slide) {return('<li><a>'+Number(id+1)+'</a></li>');}
	});
	
	$('#brands-slide-container').cycle({ fx: 'scrollLeft', timeout: 6000, delay:  -2000});
	
	$("a.map").fancybox({
		'width'				: 600,
		'height'			: 400,
        'autoScale'     	: false,
		'type'				: 'iframe'
	});
	
	$("a.tip.more").fancybox({
		//'width'				: 600,
        //'autoScale'     	: true,
		//'autoDimensions'	: false
		'width': '70%', // or whatever you want
		'height': '70%', // or whatever you want
		'type': 'iframe' 
	});
	
	$(".video").click(function() {
			$.fancybox({
					'showNavArrows'	: false,
					'padding'		: 0,
					'autoScale'		: false,
					'transitionIn'	: 'none',
					'transitionOut'	: 'none',
					'title'			: this.title,
					'width'			: 680,
					'height'		: 495,
					'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
					'type'			: 'swf',
					'swf'			: {
						 'wmode'		: 'transparent',
						'allowfullscreen'	: 'true'
					}
				});
		
			return false;
		});
	
	//$('a[href="#tab-laminaat"]').click(function(){
		
	//	$('.eerste.catalogus').fadeToggle("fast", "linear").addClass('show');
	//	return false
	//});
	
	//$('.catalogue.twee').click(function(){	
	//	$('.tweede.catalogus').fadeToggle("fast", "linear").addClass('show');
	//	return false
	//});
	
	//$('.catalogue.drie').click(function(){
		
	//	$('.derde.catalogus').fadeToggle("fast", "linear").addClass('show');
	//	return false
	//});
	
	//$('.catalogue.vier').click(function(){
		
	//	$('.vierde.catalogus').fadeToggle("fast", "linear").addClass('show');
	//	return false
	//});
	
	//$('.tabs a').click(function(){
	//	$('.catalogus').fadeOut();
	//});
	
	$("#catalogue a[rel=product_list]").fancybox({overlayOpacity: 0.8, overlayColor:'#130000', autoDimensions:true, autoScale:true, width:484, titleShow:false});

	//$(".products-nav input").click(function(){ $(this).closest("div.catalogus").removeClass("hide"); });
	
	
});
