Ticker = {

	/**
	 * set some properties
	 */
	"moving": false,
	"automove_action": null, 
	"automove_direction": "left", 
	"automove_timeout": 3000,

	/**
	 * function move()
	 */
	"move": function (direction) {

		/**
		 * get step width, get current list left position, get ammount of list items
		 */
		this.step_width = parseInt($("#animation_ticker_content a").css("width")) + parseInt($("#animation_ticker_content a").css("margin-right"));
		this.list_left = parseInt($("#animation_ticker_content").css("left"));
		this.list_items = $("#animation_ticker_content").children().length;

		/**
		 * count minimum left position, exclude ammount of always visible items
		 * from total count of items
		 */
		this.min_left = 0 - (this.step_width * (this.list_items - 1) + parseInt($("#animation_ticker_content a").css("margin-right")));

		/**
		 * switch by direction, count next left position, move if permitted and
		 * not moving right now
		 */
		switch (direction) {
			case "left":
				this.next_left = this.list_left - this.step_width;

				if (this.next_left >= this.min_left && this.moving == false) {
					this.moving = true;
					$("#animation_ticker_content").animate({left: this.next_left}, 450, function() { Ticker.moving = false; })
				}
				break;

			case "right":
				this.next_left = this.list_left + this.step_width;

				if (this.next_left <= 0 && this.moving == false) {
					this.moving = true;
					$("#animation_ticker_content").animate({left: this.next_left}, 450, function() { Ticker.moving = false; })
				}
				break;
		}
	},

	/**
	 * function automove()
	 */
	"automove": function() {

		/**
		 * continue only if there is more than 6 child in list
		 */
		if ($("#animation_ticker_content").children().length > 1) {

			/**
			 * determine next automove direction or keep current
			 */
			switch (this.automove_direction) {
				case "left":
					if ((this.list_left - this.step_width) < this.min_left) {
						this.automove_direction = "right";
						this.move(this.automove_direction);
					}
					break;

				case "right":
					if ((this.list_left + this.step_width) > 0) {
						this.automove_direction = "left";
						this.move(this.automove_direction);
					}
					break;
			}

			/**
			 * move item and set timeout
			 */
			this.automove_action = setTimeout("Ticker.move('" + this.automove_direction + "'); Ticker.automove();", this.automove_timeout);
		}
	}, 

	/**
	 * function stop()
	 */
	"stop": function() {
		clearTimeout(this.automove_action);
		this.automove_action = null;
	}
}
