$(document).ready(function() {
	
	
	// check brower type
	
	jQuery.each(jQuery.browser, function(i, val) {
		$("body").addClass(i + " " + val);
	});
	
	$("nav.fixed").animate({
		opacity: '0',
		top: '-60'
	}, 5 ).delay( 5 ).animate({
		opacity: '1',
		top: '+20'
	}, 800 )
	

	// floating menu on page scroll
	
	if($("nav").size()) {
		
		$(function(){
			var menu = $("nav"),
			pos = menu.offset();
		
			$(window).scroll(function(){
				if($(this).scrollTop() > pos.top+menu.height() && menu.hasClass('default')){
					menu.fadeOut('fast', function(){
						$(this).removeClass('default').addClass('fixed').fadeIn('fast');
					});
				} else if($(this).scrollTop() <= pos.top && menu.hasClass('fixed')){
					menu.fadeOut('fast', function(){
						$(this).removeClass('fixed').addClass('default').fadeIn('fast');
					});
				};
			});
		});
		
	};
		
	
});

	//height of the news ticker widget
	ticker_height = $('.news_scroller').height() + 0.5;
	
	//height of all the news elements combined
	news_height=$('.newsitems').height();
	
	//scroll top offset
	scroll_top = 0;
	
	//scroll status
	scroll_running = true;
	
	function do_scroll_resume() {
		//set scrolling state to resumed
		scroll_running = true;
	}
	function do_scroll_pause() {
		//set scrolling state to paused
		scroll_running = false;
	}
	function do_scroll() {
		//if scroller is running, then move a little up
		scroll_top += scroll_running ? -2 : 0;
		//set the positions
		$('.newsitems').css( 'top', ''+scroll_top+"px" );
		//if the top position is way beyond the total height of ticker
		//then start over again from bottom
		if( scroll_top<-1*news_height ) scroll_top = ticker_height;
		//set the timer to invoke scroll again
		setTimeout( 'do_scroll()', 100 );
	}
	$(document).ready(function(){
		//when mouse is over the scroller, pause
		$('.news_scroller').mouseover( do_scroll_pause );
		//when mouse is out of the scroller, resume
		$('.news_scroller').mouseout( do_scroll_resume );
		//start the scrolling
		do_scroll();
	});
