this.mainNav = function(e){
	if ($(e).length){
		
		$(e + ' li:not(.on) a').hover(
			function(){
				$(this).find('span').css({'display': 'block', 'opacity': 0}).stop(false, true).fadeTo(200,1)
			},
			function(){
				$(this).find('span').stop(false, true).fadeOut(300)
			}
		)
	}else{
		return false;
	}
}

this.initShortNews = function($newsContainer){
	if($newsContainer.length){
		var $childs = $newsContainer.find("> li"),
			maxHeight = 440,
			childsHeight = 0,
			speed = 2400
			
		$newsContainer.css({height: maxHeight + "px", overflow: "hidden"})
		
		$childs.each(function(){
			childsHeight += $(this).height()
		})
		
		if (childsHeight > maxHeight){
			this.slideChilds = function($child){
				var $next = $child.next()
				setTimeout(function(){
					$child.fadeTo((speed / 8),0.01).slideToggle((speed / 4))
					setTimeout(function(){ $child.appendTo($newsContainer).slideToggle((speed / 4)).fadeTo((speed / 4),1); slideChilds($next) }, (speed / 2))
				}, speed)
				
				
			}
			
			this.slideChilds($childs.eq(0))
		}
		
	}else{
		return false;
	}
}

$(function(){
	
	initShortNews($("ul#shortNews"))
	mainNav('ul#mainNav')
})
