/*!
 * jQuery xoay_vong Plugin
 * Copyright (c) 2010 MR_TUAN
 * Version: 1 (22/09/2010)
 * Email mr.tuan.88@gmail.com
 * Requires: jQuery v1.4.2 or later
 */
 
;(function($) {
		   
	$.fn.xoay_vong = function() {
		
		return this.each(function() {
			$cont = $(this);
			pause = false;
			$cont.hover(function() {
				pause = true;
			}, function() {
				pause = false;
			});
			setTimeout(go, 4000);
			
			function go (){
				if (pause) {
					setTimeout(go, 500);
					return;
				}
				var $el = $cont.children(':first');
				$el.animate({"opacity": 0}, 500, function() {
					var h = $el.outerHeight();
					$el.animate({ marginTop: -h }, 500, function() {
					$el.css({ marginTop: 0,	opacity: 1 });
					$el.css({ padding: '5px 10px', clear: 'left' }).show().appendTo($cont);
					});
				});
				setTimeout(go, 4000);						
			}
			
		});
		
	};

})(jQuery);

