$ (function () {

	var flySetPosition = function (which) {
		var newPosition = {
		 'left': $ ('#' + which + '-original').position ().left + 'px',
		 'top':  $ ('#' + which + '-original').position ().top + 'px'
		}

		if ($ ('#' + which + '-original').css ('display') == 'none') return

		if (
		 (Math.abs (
			 parseInt ($ ('#' + which).css ('left')) - $ ('#' + which + '-original').position ().left) > 200
		 ) ||
		 (Math.abs (
			 parseInt ($ ('#' + which).css ('top')) -	 $ ('#' + which + '-original').position ().top) > 320
		 )
		) {
		  $ ('#' + which).animate (newPosition, 333)
		} else {
		  $ ('#' + which).css (newPosition)
		}
		
	}
	
	var flySetPositions = function () {
	
	 $ ('*').stop ()
	 $ ('#fly-box-wrapper').animate ({ 'height': $ ('#fly-box-bottom').position ().top }, 333)
	 $.each ($ ('.fly-box'), function (k, v) { flySetPosition (v.id) })
	
	}

  $ (window).resize (flySetPositions)
  $ ('.fly-box').css ({ 'position': 'absolute' })
  $ ('#fly-box-wrapper').css ({ 'position': 'relative', 'overflow': 'hidden' })

  flySetPositions ()
	 
})
