/**                        
 * Cloud plugin
 *              
 * @author Patrick Beser<p@hopeglory.com>
 * @author Steve Sinnwell<s@hopeglory.com>
 */
(function($) {

	$.fn.cloud = function(settings) {
		var config = {};

		if (settings) {
			$.extend(config, settings);
		}

		function up(element) {
			var arc_params = {
				center: [$(element).data('left'),$(element).data('top')],
				radius: 8,
				start: 190,
				end: -190,
				dir: 1
			}
			$(element).animate({
				path : new $.path.arc(arc_params)
			}, {
				duration: 3000 + Math.floor(Math.random() * 2400),
				easing: 'linear',
				complete: function() {
					up(this);
				}
			});
		}

		this.each(function(index, element) {
			var speed = 4000 + Math.floor(Math.random() * 2400);
			$(element).data('speed', speed);
			$(element).find('a').hover(function() {
				$(this).css('padding', '9px 11px');
				$(this).css('margin', '-1px 0 0 -1px');
				$(this).parent().stop();
			}, function() {
				$(this).css('padding', '7px 9px');
				$(this).css('margin', '0');
				up($(this).parent());
			});                                  
			var yPos = $(element).position().top;
			var xPos = $(element).position().left;
			$(element).data('top', yPos);
			$(element).data('left', xPos);
			//if(Math.random() > .5) {
				up(element);
			/*
			}else {
				down(element);
			}
			*/
		});

		return this;
	};

})(jQuery);
