$(document).ready(function() {
	
	$(".scroller").scrollable({ circular:false, vertical:true, mousewheel:true });
	$(".scrollable").scrollable();
	
	var n_numTGroup = $(".iContainer").size();
	
	for (i=1;i<=n_numTGroup;i++)
	{
		var lBoxId = '#producten'+i+' div img';
		$(lBoxId).lightBox();
	}

/*
	$('.scrollable .items img').click(function(e){
		var imgurl = $(this).attr('rel');
		var img = new Image();
		
		if($('#fotodetail').is(':visible')){
		}
		else{
			$('#fotodetail').show();
		}
		
		$('#fotodetail div').html('<p><img src="img/foto-loader.gif" width="220" height="19" /></p>');
		$(img).load(function(){
			$(this).hide();
			$('#fotodetail div').removeClass('loading').html(this);
			$(this).slideDown('slow');
		})
		.error(function () {
			var msg = "Sorry but there was an error loading the image.";
			$("#fotodetail div").html(msg);
		})
		.attr('style', 'width:auto; margin:0 auto;')
		.attr('src', imgurl);
	});
*/
	
	$('.soort').click(function(e){
		var toSplit = $(this).attr('rel');
		arr_split = toSplit.split(' | ');
		var imgurl2 = arr_split[0];
		var kleurTxt = arr_split[1];
		
		//var imgurl2 = $(this).attr('rel');
		var img2 = new Image();
		
		if($('.imagePreview').css('visibility') == 'hidden'){
			$('.imagePreview').css('visibility', 'visible');
		}
		else{
			//do nothin
		}
		
		$('.imagePreview').children().remove();
		$('.imagePreview').append('<img src="img/ajax-loader.gif" style="margin-left: 58px; margin-top: 34px;" />');
		
		$(img2).load(function(){
			$(this).hide();
			$('.imagePreview').children().remove();
			$('.imagePreview').append(this);
			$(this).fadeIn();
			$('.imagePreview').append('<div class="imageText"><p>'+kleurTxt+'</p></div>');
		})
		.error(function () {
			var msg = "<p>No image available.</p>";
			$(".imagePreview").html(msg);
		})
		.attr('src', imgurl2);

	});
	
	
	$(".productlist").tabs(".productlist div.product", {tabs: 'h2', effect: 'slide', initialIndex: null});
	
	/*
	$('.productlist h2').click(function(){
		$('#fotodetail div').empty();
		$('#fotodetail').hide();
	});
	
	if($('#fotodetail div:empty')){
		$('#fotodetail').hide();
	}
	*/
});

