var polnumber = 10;

$(function() {
        $(".polaroid").draggable({
                revert: false
        });
});

$(document).ready(function(){

	$(".lightbox").lightbox();

});

function hideIE() {
	changeElement("warningmessage", "display", "none");
	changeElement("iemessage", "display", "none");
}

function align() {
	
	var columns = Math.floor(window.innerWidth / 350);
	var hspacer = (window.innerWidth-50)/columns;
	
	
	for (i=1;i<=polnumber;i++) {
		var width = (((i-1)%columns)*hspacer)+50;
		var height = ((Math.floor((i-1)/columns))*350)+50;
		
		//changeElement("pol"+i, "top", height+"px");
		//changeElement("pol"+i, "left", width+"px");
		changeElement("pol"+i, "-webkit-transform", "rotate("+0+"deg)");
		changeElement("pol"+i, "-moz-transform", "rotate("+0+"deg)");
		changeElement("pol"+i, "display", "block");
		changeElement("pol"+i, "zIndex", randomNumber(200));
		
		
		$('#pol'+i).animate({
		top: height,
		left: width
		}, 1000, function() {
		// Animation complete.
		});
		
	}
	

}

function polaroid() {
	for (i=1;i<=polnumber;i++) {
		var height = randomNumber((window.innerHeight)-300);
		if ((height > (window.innerHeight/2)+300) || (height < (window.innerHeight/2)-300)) {
			var width = randomNumber((window.innerWidth)-350);
		} else {
			var side = randomNumber(2)+1;
			if (side == 1) { var width = randomNumber((window.innerWidth/2)-500);}
			else {var width = (window.innerWidth-(randomNumber((window.innerWidth/2)+360)))-350;}
			
		}
		//changeElement("pol"+i, "top", height+"px");
		//changeElement("pol"+i, "left", width+"px");
		changeElement("pol"+i, "-webkit-transform", "rotate("+(randomNumber(20)-10)+"deg)");
		changeElement("pol"+i, "-moz-transform", "rotate("+(randomNumber(20)-10)+"deg)");
		changeElement("pol"+i, "display", "block");
		changeElement("pol"+i, "zIndex", randomNumber(200));
		
		$('#pol'+i).animate({
		top: height,
		left: width
		}, 1000, function() {
		// Animation complete.
		});
		
	}
}

function changeElement(id, property, value) {
	element = document.getElementById(id);
	element.style[property] = value;
}

function randomWidth() {
	window.innerWidth-720;
}

function randomNumber(maximum) {
	var randomNum = (Math.floor(Math.random()*maximum));
	return randomNum;
}

// Drag div

