		$(document).ready(function() {
			
				// variables
				animation = false;
				
				// hide elements
				$('.hover').fadeOut(0);
				
				// next image
				function changeImage(id, nr){
					// variables
					width		= 670;
					
					current		= id.parent().find('.state').html().split(' ')[0].split('(')[1];
					amount		= id.parent().find('.state').html().split(' ')[2].split(')')[0];
					
					background	= $(id).parent().parent().parent().find('.image').css("background");
					
					if( !$(id).parent().parent().parent().find('.image').css("backgroundPosition") ){
						$(id).parent().parent().parent().find('.image').css("backgroundPosition", 0);
					}
					
					position	= $(id).parent().parent().parent().find('.image').css("backgroundPosition").split("px")[0];
					
					// set position
					
					if( Number(position)+(width*nr) == 0 || Number(position)+(width*nr) > (amount-1)*width || Number(position)+(width*nr) < -(amount-1)*width ){
						current = 1;
						id.parent().parent().parent().find('.image').css("background-position", 0);
					}else{
						current = Number(current)-nr<1 ? amount : Number(current)-nr;
						id.parent().parent().parent().find('.image').css("background-position", Number(position)+(width*nr));
					}
					
					// set amount text
					state = "("+current+" of "+amount+")";
					id.parent().find('.state').html(state);
					
					// create fade div
					id.parent().parent().parent().find('.image').html("<div class='fade'></div>");
					
					
					// fade
					id.parent().parent().parent().find('.fade').css("background", background);
					id.parent().parent().parent().find('.fade').css("backgroundPosition", position-0);
					
					id.parent().parent().parent().find('.fade').fadeIn(0);
					id.parent().parent().parent().find('.fade').fadeOut('normal', function(){
						animation = false;
						id.parent().parent().parent().find('.fade').remove();
					});
				}
				
				$('.item').find('.next').mousedown(function(){
					if( !animation ){
						animation = true;
						changeImage($(this), -1);
					}
				});
				
				$('.item').find('.previous').mousedown(function(){
					if( !animation ){
						animation = true;
						changeImage($(this), +1);
					}
				});
				
				$('.item').find('.interact a').mousedown(function(){
					if( !animation ){
						animation = true;
						
						id = $(this).parent().parent().parent();
						
						if( id.find('.image').find('.object').length>0 ){
							$(this).html('Open project');
							
							id.find('.controls').fadeIn('fast');
							id.find('.image').find('.object').fadeOut('normal', function(){
								id.find('.image').find('.object').remove();
								animation = false;
							});
						}else{
							$(this).html('Close project');
							
							height = id.find('.image').css('height');
							
							url = $(this).attr('href');
							id.find('.image').html('<div class="object"><embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="'+url+'" wmode="transparent" height="'+height+'px" type="application/x-shockwave-flash"></embed></div>');
							
							id.find('.controls').fadeOut('fast');
							id.find('.image').find('.object').fadeOut(0);
							id.find('.image').find('.object').fadeIn('normal', function(){
								animation = false;
							});
						}
						
					}
				});
				
				var timer;
				
				// show & hide controls
				$('.image').hover(function(){
					$(this).parent().find('.hover').fadeIn('fast');
					clearTimeout(timer);
				},function(event){
					timer = setTimeout( function(){ $(".hover").fadeOut('fast'); }, 5);
				});
				
				$('.hover').hover(function(){
					clearTimeout(timer);
				},function(event){
					timer = setTimeout( function(){ $(".hover").fadeOut('fast'); }, 5);
				});
			
			});