var totalNewsItems = 4;
	
$(document).ready(function() {
	
	$('#main #featuredNews').css({'overflow':'hidden'});
	$('#main #featuredNewsWrapper').css({'overflow':'hidden'});
	$('#main #featuredNews #moreNews').show();
	
	$('.newsItem').attr("id", function (arr) {
  	return "newsItem" + arr;
  	});
	
	$('.newsItem').each(function(index){
		$(this).css({'display':'none'});
		});
	
	$('#newsItem0').css({'display':'block'});

	$('.newsItem .mainImage img').each(function(index) {
		var currentImage = $(this).attr("src");
		$('#newsItem' + index + ' .mainImage').css({'background':'url(/' + currentImage + ') left top no-repeat'});
		$(this).addClass('hidden');
		});

	$('#featuredNewsWrapper').append(function(){
		var newHTML = '<div id="newsLinks"><ul>';
		$('.newsItem .newsCopy h3').each(function(index){
			if(index == 0){
				newHTML = newHTML + '<li class="first selected"><a href="javascript:" onClick="showNews(' + index + ');">' + $(this).text() + '</a></li>';
			}
			else if(index == totalNewsItems-1){
				newHTML = newHTML + '<li class="last"><a href="javascript:" onClick="showNews(' + index + ');">' + $(this).text() + '</a></li>';
			}
			else {
				newHTML = newHTML + '<li><a href="javascript:" onClick="showNews(' + index + ');">' + $(this).text() + '</a></li>';
			}
			});
		newHTML = newHTML + '</ul></div>';
		return newHTML;
		});
	
	if (browser == 'ie6') {
		ie6scripthome();
	} else if (browser == 'ie7') {
		ie7scripthome();
	} else if (browser == 'ie8') {
		ie8scripthome();
	}
	
});

function showNews(newsIndex){
	$('.newsItem').each(function(index){
		$(this).css({'display':'none'});
		});
	
	$('#newsItem'+newsIndex).css({'display':'block'});
	
	$('#newsLinks li').each(function(index){
		
		$(this).removeAttr("class");

		if(index == 0){
			$(this).addClass("first");
			}
		if(index == totalNewsItems-1){
			$(this).addClass("last");
			}
		if(index == newsIndex){
			$(this).addClass("selected");
			}
		
		});
	}
	
function ie6scripthome() {

}

function ie7scripthome() {
	$('#mainNavigation').bind('mouseenter', function() {
		$('#featuredNews').css({'z-index':'-1'});
	});

	$('.sub').css({'z-index':'999'});
	$('#featuredNews').css({'position':'relative'});
	$('#featuredNews').css({'z-index':'-1'});

	$('#main').bind('mouseenter', function() {
		if ($('.sub').css('opacity') == 0) {
			$('#featuredNews').css({'z-index':'0'});
		}
	});

	$('#main').bind('mouseleave', function() {
		$('#featuredNews').css({'z-index':'-1'});
	});

	$('#featuredNewsWrapper').append(function(){
		var newHTML = '<img src="/templates/default/images/featuredNews_top_left_corner.png" alt="" style="position:absolute; top:0; left:0;" />';
		newHTML = newHTML + '<img src="/templates/default/images/featuredNews_top_right_corner.png" alt="" style="position:absolute; top:0; right:20px;" />';
		newHTML = newHTML + '<img src="/templates/default/images/featuredNews_bot_right_corner.png" alt="" style="position:absolute; bottom:0; right:19px;" />';
		newHTML = newHTML + '<img src="/templates/default/images/featuredNews_bot_left_corner.png" alt="" style="position:absolute; bottom:0; left:0;" />';
		return newHTML;
	});
}

function ie8scripthome() {
	$('#mainNavigation').bind('mouseenter', function() {
		$('#featuredNews').css({'z-index':'-1'});
	});

	$('.sub').css({'z-index':'999'});
	$('#featuredNews').css({'position':'relative'});
	$('#featuredNews').css({'z-index':'-1'});

	$('#main').bind('mouseenter', function() {
		if ($('.sub').css('opacity') == 0) {
			$('#featuredNews').css({'z-index':'0'});
		}
	});

	$('#main').bind('mouseleave', function() {
		$('#featuredNews').css({'z-index':'-1'});
	});

	$('#featuredNewsWrapper').append(function(){
		var newHTML = '<img src="/templates/default/images/featuredNews_top_left_corner.png" alt="" style="position:absolute; top:0; left:0;" />';
		newHTML = newHTML + '<img src="/templates/default/images/featuredNews_top_right_corner.png" alt="" style="position:absolute; top:0; right:20px;" />';
		newHTML = newHTML + '<img src="/templates/default/images/featuredNews_bot_right_corner.png" alt="" style="position:absolute; bottom:0; right:20px;" />';
		newHTML = newHTML + '<img src="/templates/default/images/featuredNews_bot_left_corner.png" alt="" style="position:absolute; bottom:0; left:0;" />';
		return newHTML;
	});
}
