$(document).ready(function(){
     var zindex = -1000000000;
	 var selector = "#polaroid-gallery img, #polaroid-gallery2 img";
	 $(selector).draggable({
			start: function(event, ui) {
				var cssObj = { 'z-index' : zindex++ };
				$(this).css(cssObj);
			}
	 });
	 $(selector).each(function(){
			 var rot = Math.random()*30-15+'deg';
			 //var left = Math.random()*10+'px';
			 //var top = Math.random()*60+'px';
			 var top = 0+'px';
			 var left = 0+'px';
			 $(this).css('-webkit-transform' , 'rotate('+rot+')');
			 $(this).css('-moz-transform' , 'rotate('+rot+')');
			 $(this).css('top' , top);
			 $(this).css('left' , left);
			 $(this).mouseup(function(){
				 $(this).css('z-index' , zindex++);
			 });
	     });
	$(selector).dblclick(function(){
			$(this).css('-webkit-transform' , 'rotate(0)');
			$(this).css('-moz-transform' , 'rotate(0)');
	});
							   
});
