$(document).ready(function () {
	setTimeout(EventList.Initialize,1000);
});

var _itemList = null;
var _itemIndex = 0;
var _startUp = 0;
var _rotateIndex = 0;
var _itemCount = 0;

EventList = {
	Initialize: function () {
		itemList = $('.eventSmallItem');
		_itemCount = itemList.length;

		//		$(itemList[0]).animate({ 'top': '130px' }, 200, 'swing');
		//		$(itemList[1]).animate({ 'top': '175px' }, 200, 'swing');
		//		$(itemList[2]).animate({ 'top': '215px' }, 400, 'swing');
		//		$(itemList[3]).animate({ 'top': '255px' }, 600, 'swing');

		EventList.Spot_One(itemList[0]);
		EventList.Spot_Two(itemList[1]);
		EventList.Spot_Three(itemList[2]);
		EventList.Spot_Four(itemList[3]);
		EventList.Spot_Five(itemList[4]);

		setTimeout(EventList.Rotate, 5000);
	},

	Spot_Zero: function (item) {
		$(".content", item).slideUp('fast', function () {
			$(".bar > .title", item).find('a').css("color", "black");
			$(".bar > .bg", item).animate({ 'width': '5px' }, 200, 'swing');
			$(item).animate({ 'top': '-130px' }, 700, 'swing', function () {
				$(item).css("top", "400px");
			});

		});
	},

	Spot_One: function (item) {
		$(item).animate({ 'top': '0px' }, 700, 'swing', function () { $(".content", item).slideDown('slow'); $(".bar > .bg", item).animate({ 'width': '379px' }, 200, 'swing'); $(".bar > .title", item).find('a').css("color", "white"); });
	},

	Spot_Two: function (item) {
		$(item).animate({ 'top': '125px' }, 700, 'swing');
	},

	Spot_Three: function (item) {
		$(item).animate({ 'top': '165px' }, 700, 'swing');
	},

	Spot_Four: function (item) {
		$(item).animate({ 'top': '205px' }, 700, 'swing');
	},

	Spot_Five: function (item) {
		$(item).animate({ 'top': '245px' }, 700, 'swing');
	},

	Rotate: function () {
		//alert("_startUp=" + _startUp + "\n_rotateIndex=" + _rotateIndex + "\n_itemIndex=" + _itemIndex)

		switch (_rotateIndex + _startUp) {
			case 0:
				EventList.Spot_Zero($(itemList[EventList.GetIndex(_itemIndex)]));
				break;
			case 1:
				EventList.Spot_One($(itemList[EventList.GetIndex(_itemIndex + 1)]));
				break;
			case 2:
				EventList.Spot_Two($(itemList[EventList.GetIndex(_itemIndex + 2)]));
				break;
			case 3:
				EventList.Spot_Three($(itemList[EventList.GetIndex(_itemIndex + 3)]));
				break;
			case 4:
				EventList.Spot_Four($(itemList[EventList.GetIndex(_itemIndex + 4)]));
				break;
			case 5:
				EventList.Spot_Five($(itemList[EventList.GetIndex(_itemIndex + 5)]));
				break;
		}

		if (_rotateIndex < 6) {
			_rotateIndex++;
			setTimeout(EventList.Rotate, 100);
		}
		else {
//			if (_startUp > 0) {
//				_startUp--;
//			}
			_rotateIndex = 0;
			_itemIndex++;
			if (_itemIndex >= _itemCount)
				_itemIndex = 0;

			setTimeout(EventList.Rotate, 5000);
		}
	},

	GetIndex: function (index) {
		if (index < 0) {
			return _itemCount + index;
		}
		else if (index >= _itemCount) {
			return index - _itemCount;
		}
		else {
			return index;
		}
	}
}

