$(document).ready(function()
{	
	/*$('.stuff_photo').Draggable(
			{
				revert:		true,
				fx:			100
			}
		);*/
		
		$('.stuff_elements').Draggable(
			{
				revert:		true,				
				ghosting:	true,
				opacity:	0.5,
				fx:			300
			}
		);
		
	
	slide("#sliding-navigation", 90, 100, 150, .8);
	topmenu();

	
	$(".sliding-element a").click(function(){
		$('.sel').removeAttr('class');
		$(this).attr('class','sel');
		
      ////$(this).clone(true).insertAfter(this);
    });
	
	
	$("#right_menu a").attr('click_id',$(this).attr('class'));
	
	//$("#right_menu a").removeAttr('href');
	
	
	
	$("#right_menu a").click(function(){
		$('.sel_right').removeAttr('class');
		$(this).attr('class','sel_right');
		$("#stuff_list").load("stuff_list.php", {min_height: 5, max_height: 250, open_by: 'ajax', category: $(this).attr('click_id')});
		
      ////$(this).clone(true).insertAfter(this);
	  return false;
    });
	
	
	//$(".sliding-element a").attr("onclick","$('.sel').removeAttr('class');$(this).attr('class','sel');");
	
	// images lens on hover
	//$("a.box").fancybox();
	$("a.box>img").attr('class','zoom');
});

function slidefoto(){
	$('#design_foto').fadeTo('fast', 0.13);
	$('#design_foto').animate({background: "url(img/gal/foto"+(new Date).getTime()%10+".jpg) no-repeat;"}, 1 );
	$('#design_foto').fadeTo('slow', 1);
	}

function topmenu(){
	$(".sliding-element a").click(function(){
		num = $(".sliding-element a").index(this)*375;
		$('.main-content').stop();
		$('.main-content').fadeTo('fast', 0.55);
		$(".main-content").animate({left: "-"+num+"px"}, 1500 );
		$('.main-content').fadeTo('slow', 1);
		return false;
    	});
	}

function slide(navigation_id, pad_out, pad_in, time, multiplier)
{
	// creates the target paths
	var list_elements = navigation_id + " li.sliding-element";
	var link_elements = list_elements + " a";
	
	// initiates the timer used for the sliding animation
	var timer = 0;
	
	// creates the slide animation for all list elements 
	$(list_elements).each(function(i)
	{
		// margin left = - ([width of element] + [total vertical padding of element])
		//$(this).css("margin-left","15px");
		// updates timer
		timer = (timer*multiplier + time);
		$(this).animate({ width: "90px" }, timer);
		$(this).animate({ width: "100px" }, timer);
		$(this).animate({ width: "90px" }, timer);
	});

	// creates the hover-slide effect for all link elements 		
	$(link_elements).each(function(i)
	{
		$(this).hover(
		function()
		{
			$(this).animate({ width: pad_in }, 150);
		},function()
		{
			$(this).animate({ width: pad_out }, 150);
		});
	});
}