/**
reuse this if you want
*/

	var margin = 10; 
	var maxHeight = 500;
	var windowPad = 200;
	var homeX= 10;
	var COL = 0;
	var MOVED = false;
	var MOVED2 = false;
	var homeY =10;
	var lastY =0;
	var lastX = 0;
	var tmpY =0;
	maxy = new Array();
	

	function setupSite(){
		arrange();
		setupZoom();
	}

	$(document).ready( function() {
		arrange();
		setup();
	});

	// on window resize, call again
	$(window).resize( function() { arrange(); } );
	
	arrange();
	
	function setup(){
		$('.eachpost').each(function(i) {
			
		
		
			
			$(this).mouseover(function(){
				//$(".caption",this).fadeIn();
				$(".caption",this).css('display','block');
				$(".ball",this).css('display','block');
			});
			
			$(this).mouseout(function(){
				$(".caption",this).css('display','none');
				$(".ball",this).css('display','none');
				//$(".caption",this).fadeOut();
			});
			
		});
	}
	function arrange() {
		lastY=homeY;
		lastX=homeX;
		MOVED=false;
		MOVED2=false;
		maxHeight = $(window).height() - windowPad;
		$('.eachpost').each(function(i) {

			//set the current height;
			var h = $(this).css('height');
			var currHeight = h.split('px');
		
	
			
			$(this).css('top',lastY+'px');
			$(this).css('left',lastX+'px');
			//var divPOS = $(this).offset();
			//alert(divPOS.top);
			if(lastY > maxHeight){
				COL++;
				lastY =homeY;
				lastX = Number(lastX) + 250 + Number(margin);
				//alert(lastX);
				//alert('maxHeight');
				$(this).css('top',lastY);
				$(this).css('left',lastX);	
			}
			
			lastY = Number(lastY) + Number(currHeight[0]) + Number(margin);
		});

	}
