$(document).ready(function () {
    var zindex = 1;
    $("#polaroid img").draggable({
        start: function (event, ui) {
            zindex++;
            var cssObj = {
                'z-index': zindex
            };
            $(this).css(cssObj);
        }
    });
    $('#polaroid img').each(function () {
        var rot = Math.random() * 30 - 15 + 'deg';
        var left = Math.random() * 50 + 'px';
        var top = Math.random() * 150 + 'px';
        $(this).css('-webkit-transform', 'rotate(' + rot + ')');
        $(this).css('-moz-transform', 'rotate(' + rot + ')');
        $(this).css('top', left);
        $(this).css('left', top);
        $(this).mouseup(function () {
            zindex++;
            $(this).css('z-index', zindex);
        });
    });
    $('#polaroid img').dblclick(function () {
        $(this).css('-webkit-transform', 'rotate(0)');
        $(this).css('-moz-transform', 'rotate(0)');
    });
    $('#polaroid img:first-child').addClass('featured');
    $('#polaroid img:nth-child(2)').addClass('second');
    $('#polaroid img:nth-child(3)').addClass('top');
    $('#polaroid img:nth-child(4)').addClass('fourth');

    $('#polaroid img:nth-child(5)').addClass('left');
    $('#polaroid img:nth-child(6)').addClass('sixth');
    $('#polaroid img:nth-child(7)').addClass('seventh');
    $('#polaroid img:nth-child(8)').addClass('eighth');



});
 
