$(document).ready(function(){




// tabs


	$('.tabs a').click(function(event)
		{
		event.preventDefault();
		}
	);



	// highlight the first tab
	$('#tabs1 .tabs a:first').addClass('current');
	$('#tabs2 .tabs a:first').addClass('current');
	$('#tabs3 .tabs a:first').addClass('current');

	// show only the first rows
	$('#tabs1 .work:first').css({ visibility: 'visible'});
	$('#tabs2 .work:first').css({ visibility: 'visible'});
	$('#tabs3 .work:first').css({ visibility: 'visible'});


function tabs(div)
	{
	$(div+' .tabs a').click(function ()
		{
		var index = $(div+' .tabs a').index(this);

		$(div+' .tabs a').removeClass('current');
		$(this).addClass('current');
		
		$(div+' .work').css({ visibility: 'hidden'});
		$(div+' .work').eq(index).css({ visibility: 'visible'});
		}
	);
	}

tabs('#tabs1')
tabs('#tabs2')
tabs('#tabs3')




/*

// set cookies

	$(window).unload(function() 
		{

		var index = '0';
	
		$(".work").each(function ()
			{
			var visibility = $(this).css('visibility');
			$.cookie('.work:eq('+index+')', visibility, { path: '/'});
			index++;
			}
		);
		}

	);



// read cookies

		var index = '0';
	
		$(".work").each(function ()
			{
			var cookie = $.cookie('.work:eq('+index+')');


			$('.work:eq('+index+')').css({ visibility: cookie});

			if (cookie == 'visible')	
				{
				$('.tabs a:eq('+index+')').addClass('current');
				} else if (cookie == null){
				$(this).parent('div').children('.tabs').children('li').children('a:eq(0)').addClass('current');
				$(this).parent().children('.work:eq(0)').css({ visibility: 'visible'});
				}
			index++;
			}
		);

*/





// edit button
	
	$('.flipItem').hover(function()
		{
		$(this).children('a.post-edit-link').css({ display: 'block' });
		},function()
		{
		$(this).children('a.post-edit-link').css({ display: 'none' });
		}
	);






// flips


	$('.flipLeft').click(function(event)
		{
		event.preventDefault();
		}
	);
	$('.flipRight').click(function(event)
		{
		event.preventDefault();
		}
	);



	var itemsVisible = Math.floor(($('.viewer').width()+30) / ($('.flipItem').width() + 30));
	//$('#console').append(itemsVisible + ' zichtbaar <br />');


    $(".viewer").scrollable(
		{
		size: itemsVisible,
		items: '.groupItems',
		clickable: false,
		prevPage: ".flipLeft",
		nextPage: ".flipRight",
		speed: 1000
		}
	).circular(); 



	$(window).resize(function()
		{
		var itemsVisible = Math.floor(($('.viewer').width()+30) / ($('.flipItem').width() + 30));
		//$('#console').append(itemsVisible + ' zichtbaar <br />');


    	$(".viewer").scrollable(
			{
			size: itemsVisible-1,
			items: '.groupItems',
			clickable: false,
			prevPage: ".flipLeft",
			nextPage: ".flipRight"
			}
		).circular(); 
		}
	);






});