var pcglib = {
	rotator : function (y_pre, y_next, y_container, y_item, n_duration, n_vertical, n_cicle, n_auto ) {
		var myStep;
		var myVertical = n_vertical;
		var myCicle;
		var animate = false;
		var end = false;
		var iterator = 0;
		var cloneItemNum;
		if (n_auto) {
			myStep = calculateCicleSteps(y_item);
			setInterval(function () {callCicleRotatorProcess(n_auto.to)}, n_auto.time)
		};
		function calculateCicleSteps (item) {
			var length = item.length;
			if (myVertical) {
				var itemSize = item.height();
				var windowSize = y_container.parent().height();
			} else {
				var itemSize = item.width();
				var windowSize = y_container.parent().width();				
			};
			var itemInStep = windowSize / itemSize;
			cloneItemNum = itemInStep;
			return cloneItemNum;
		};
		function callCicleRotatorProcess (to) {
			if (myVertical) {
				var nextStep = cloneItemNum * y_item.height();
				if (to == '+=') {
					for (var i = 0; i < cloneItemNum; i++) {
						var myclass = y_item.attr('class');
						$( '.'+myclass+':last-child', y_container ).prependTo(y_container);
						$(y_container, $(this).parent()).css({top : -nextStep});
					};
				};
				if (!animate) {
					animate = true;
					$(y_container, $(this).parent()).animate({ top : to+nextStep }, n_duration,
					function () {
						for (var i = 0; i < cloneItemNum; i++) {
							var myclass = y_item.attr('class');
							if (to == '-=') {
								$( '.'+myclass+':first-child', y_container ).appendTo(y_container);
								$(y_container, $(this).parent()).css({top : 0});	
							}
						};
						animate = false;
					});
				};
			} else {
				var nextStep = cloneItemNum * y_item.width();
				if (to == '+=') {
					for (var i = 0; i < cloneItemNum; i++) {
						var myclass = y_item.attr('class');
						$( '.'+myclass+':last-child', y_container ).prependTo(y_container);
						$(y_container, $(this).parent()).css({left : -nextStep});
					};						
				};
				if (!animate) {
				animate = true;
				$(y_container, $(this).parent()).animate({ left : to+nextStep }, n_duration,
					function () {
						for (var i = 0; i < cloneItemNum; i++) {
							var myclass = y_item.attr('class');
							if (to == '-=') {
								$( '.'+myclass+':first-child', y_container ).appendTo(y_container);
								$(y_container, $(this).parent()).css({left : 0});	
							}
						};
						animate = false;
					});
				};
			};
		};
	}
};
