
/* throw all global functions into this file.
 * we'll be including specific files per page 
 * if they're needed.
 */

// these two variables are specifially for the hotnews rotator.
var news_index=0;
var news_rotator=false;

$(document).ready( function() {
	// this function turns off those annoying dotted lines that show focus.
	$( 'a' ).each( function ( index, elem ) {
			$(elem).focus( function(){ 
					this.blur();
					});
	});
	$('#menubar').mouseenter( function( evt ) {
			$('#menubar li a').each( function( idx, elem ) { $(elem).removeClass('active');});
	});
	$('#menubar').mouseleave( function( evt ) {
			$('#menubar #btn'+page+ ' a' ).addClass('active');
	});

	$('a.inactive').each(
		function(index,element) {
			$(element).click( function(){ return false; });
			var inactivebackground = $(element).css( 'backgroundPosition' );
			$(element).mouseenter( function( evt ){ 
					$( evt.target ).css({backgroundPosition:inactivebackground});});
			});



});


/* this function is pulled out of the document.ready function
 * to make the recursion easier to handle.
 */
function lightHeader( spot ) {
	if ( spot.substr(0,7 ) =='header_' ) {
			spot=spot.substr(7);
	}

	$('#header li a').each( function( index, elem ){
			$(elem).css( { backgroundPosition:'0 -199px' });
	});
	$( '#header_'+spot+' a').css({backgroundPosition:'0 0px'});
}


function addBookmark() {
	url = window.location;
	//
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); 
	}
	else if(window.opera && window.print) { // Opera Hotlist
		return true; 
	}
}



$(document).ready( function() {

	$('#news_0').fadeIn();
	if ( news_timing > 0  ) {
		if ( $('.hotnewsinner').length > 1 ) { 
			news_rotator = setInterval(
				function() {
					changeNews();
				}, news_timing * 1000 );
		}
	}	
});


function changeNews() {
	newindex = news_index+1;
	if ( newindex >= $('.hotnewsinner').length ) {
		newindex=0;
	}

	$('#news_'+newindex).fadeIn();
	$('#news_'+news_index).fadeOut();
	news_index=newindex;
}

