$( document ).ready( function() {
	$( ".random" ).each( function() {
		var left = Math.floor( Math.random() * $( window ).width() - ( $( this ).width() / 2 ) );
		var top = Math.floor( Math.random() * $( window ).height() - ( $( this ).height() / 2 ) );
		var angle = Math.floor( Math.random() * 360 );

		$( this ).css( "left", left+"px" );
		$( this ).css( "top", top+"px" );
		$( this ).css( "transform", "rotate( " + angle + "deg )" );
		$( this ).css( "-moz-transform", "rotate( " + angle + "deg )" );
		$( this ).css( "-webkit-transform", "rotate( " + angle + "deg )" );
		$( this ).css( "-o-transform", "rotate( " + angle + "deg )" );
		$( this ).css( "-ms-transform", "rotate( " + angle + "deg )" );
	
		 //$( this ).draggable( { containment: "parent", stack: ".photo", cursor: "pointer" } );
		 //$( this ).css( "opacity", 0 );

		var imgWidth = $( this ).width();
		var imgHeight = $( this ).height();
		//var newImageZIndex = 2;

		/*$( this ).load( function() {
			$( this ).css( "width", imgWidth * 1.5 );
			$( this ).css( "height", imgHeight * 1.5 );
			$( this ).css( "opacity", 0 );
			//$( this ).css( "z-index", newImageZIndex++ );
			$( this ).animate( { width: imgWidth, height: imgHeight, opacity: 1 }, 1200 );
		} );*/
	} );
	
	$( "a.gallery" ).fancybox();
	
	$( "article" ).each( function() {
		var angle = ( Math.random() * 6 ) - 3;
		var left =  ( Math.random() * 6 ) - 3;
		$( this ).css( "transform", "rotate( " + angle + "deg )" );
		$( this ).css( "-moz-transform", "rotate( " + angle + "deg )" );
		$( this ).css( "-webkit-transform", "rotate( " + angle + "deg )" );
		$( this ).css( "-o-transform", "rotate( " + angle + "deg )" );
		$( this ).css( "-ms-transform", "rotate( " + angle + "deg )" );
		$( this ).css( "left", left + "em" );
	} );

	$( ".thumbnail" ).each( function() {
		var angle = ( Math.random() * 10 ) - 5;
		$( this ).css( "transform", "rotate( " + angle + "deg )" );
		$( this ).css( "-moz-transform", "rotate( " + angle + "deg )" );
		$( this ).css( "-webkit-transform", "rotate( " + angle + "deg )" );
		$( this ).css( "-o-transform", "rotate( " + angle + "deg )" );
		$( this ).css( "-ms-transform", "rotate( " + angle + "deg )" );
	} );

	/*$( ".paperclip" ).each( function() {
		var pos = $( this ).position();
	} );*/
	$( "#buttons" ).find( "img.clickable" ).bind( "click", function() {
		var id = $( this ).attr( "id" );
		$( ".screen:visible" ).fadeOut( "fast", function() {
			$( "div#" + id ).fadeIn( "slow" );
		} );
	} );
} );

