var CommunityBuzz = {

	lstCommunityBuzz: null,
	Interval: null,
	SpeedInSeconds: 2,
	FadeInSeconds: 0.5,

	SetBorderToLastElement: function() {

		$("#CommuniyBuzzMessagesArea").find("UL").each(function() {
			$(this).children("LI").removeClass("last").filter(":not(.hiddenticker)").filter(":last").addClass("last");
		});
	},

	Init: function() {

		CommunityBuzz.SetBorderToLastElement();
		

	},
	LoadTickerAnimation: function() {

		$("#CommuniyBuzzMessagesArea").find("UL LI").each(function() {
			if (!$(this).hasClass("hiddenticker")) {
				$(this).children(".border").css("display","block");
				$(this).children(".tickertext").css("display","block");
			}
		});


		CommunityBuzz.Interval = setInterval(function() {

			var bThereIsNoElementsToShow = true;

			$("#CommuniyBuzzMessagesArea").children("UL").each(function() {

				var aItems = $(this).children();

				var oHiddenTicker = aItems.filter(".hiddenticker:first");
				if (oHiddenTicker.length) {
					bThereIsNoElementsToShow = false;
					oHiddenTicker.insertBefore(aItems.filter(":first"));
					
					var oAddedItem = $(this).children(":first");
					oAddedItem.css("height","0px").removeClass("hiddenticker").css("display","block").animate
					(
						{
							height: '52px'
						},
						{
							duration: 500, 
							specialEasing:
							{
								width: 'linear',
								height: 'easeOutBounce'
							}, 
							complete: function() {
								var oEl = this;
								setTimeout(function() {
									$(oEl).children(".border").fadeIn(300);
									$(oEl).children(".tickertext").fadeIn(300);
								},50);
							}
						}
					);



				}

			});

			if (bThereIsNoElementsToShow)
				clearInterval(CommunityBuzz.Interval);

		},6000);
			
		
	},

	ShowMoreItems: function(iItems) {
		
		$("#CommunityBuzz_ShowMoreItems").html("<img src=\"/images/icons/status/ajax-loader.gif\" style=\"padding-top:4px;\" alt=\"\" />");

		setTimeout(function() {
			$("#CommuniyBuzzMessagesArea").children("UL").each(function() {
				
				$(this).find("LI.hiddenticker:lt("+iItems+")").removeClass("hiddenticker");
				
			});
			$("#CommunityBuzz_ShowMoreItems").html("more");
			CommunityBuzz.SetBorderToLastElement();

		},1000);
	},

	SwitchTo: function(oEl,sId) {
		$("#CommunityBuzz_Tabs").children().removeClass("TabSelected");
		$(oEl).addClass("TabSelected");
		$("#CommuniyBuzzMessagesArea").children("UL").css("display","none");
		$("#CommunityBuzzTicker_"+sId).css("display","block");
	}

}