	var wantedTotal = 0;
	var wantedCurrent = 0;

	$(document).ready(function() {
		wantedTimer = setTimeout(toggleWantedItem, 500);
		function megaHoverOver(){
			var fade = 'fast';
			if (browser == 'ie8') { fade = 1; }
			$(this).find(".sub").stop().fadeTo(fade, 1).show();
				
			//Calculate width of all ul's
			(function($) { 
				jQuery.fn.calcSubWidth = function() {
					rowWidth = 0;
					//Calculate row
					$(this).find("ul").each(function() {					
						rowWidth += $(this).outerWidth();
					});	
				};
			})(jQuery); 
			
			if ( $(this).find(".row").length > 0 ) { //If row exists...
				var biggestRow = 0;	
				//Calculate each row
				$(this).find(".row").each(function() {							   
					$(this).calcSubWidth();
					//Find biggest row
					if(rowWidth > biggestRow) {
						biggestRow = rowWidth;
					}
				});
				//Set width
				$(this).find(".sub").css({'width' :biggestRow});
				$(this).find(".row:last").css({'margin':'0'});
				if (browser == 'ie8') { ie8rounded(biggestRow); }
				
				
			} else { //If row does not exist...
				
				$(this).calcSubWidth();
				//Set Width
				$(this).find(".sub").css({'width' : rowWidth});
				if (browser == 'ie8') { ie8rounded(rowWidth); }
				
			}
		}
		
		function megaHoverOut(){ 
			var fade = 'fast';
			if (browser == 'ie8') { ie8rounded('remove'); fade = 1; }
			$(this).find(".sub").stop().fadeTo(fade, 0, function() {
				$(this).hide();
				$('#featuredNews').css({'z-index':'0'});
			});
			
		}
	
		var config = {    
			 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
			 interval: 100, // number = milliseconds for onMouseOver polling interval    
			 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
			 timeout: 500, // number = milliseconds delay before onMouseOut    
			 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
		};
	
		/* Set up Mega-Dropdown */
		if (!ie6) {
			$("#mainNavigation ul li .sub").css({'opacity':'0'});
			$("#mainNavigation ul li .sub").parent().hoverIntent(config);
		}
		/* Process automatic styling of H2 tags and wanted poster text */

		$('h2').each(function() {
			var me = $(this);
			me.html( me.text().replace(/(^\w+)/,'<strong>$1</strong>') );
			});
		
		$('#wantedPeople p').each(function(index) {
			var newHTML = '<span>' + $(this).text().split(':').join('</span>:'); $(this).html(newHTML);
			});
	});

function showNextWantedPerson(){
	$('#wantedItem'+wantedCurrent.toString()).css({'display':'none'});
	wantedCurrent++;
	if(wantedCurrent > wantedTotal){ wantedCurrent = 0; }
	$('#wantedItem'+wantedCurrent.toString()).css({'display':'block'});
}	

function showLastWantedPerson(){
	$('#wantedItem'+wantedCurrent.toString()).css({'display':'none'});
	wantedCurrent--;
	if(wantedCurrent < 0){ wantedCurrent = wantedTotal; }
	$('#wantedItem'+wantedCurrent.toString()).css({'display':'block'});
}

function toggleWantedItem() {
	var nextItem = $('.wantedItem.selected').next('.wantedItem');
	if (nextItem.length < 1) {
		nextItem = $('#wantedItem0');
	}
	if (nextItem.length > 1) {
		$('.wantedItem.selected').removeClass('selected');
		nextItem = $('.wantedItem:visible').next('.wantedItem');
		if (nextItem.length > 1) {
			$('wantedItem:visible').hide();
			$('#wantedItem0').show().addClass('selected');
			nextItem = $('#wantedItem0').next('.wantedItem');
		} else if (nextItem.length < 1 ) {
			$('#wantedItem0').show().addClass('selected');
			nextItem = $('#wantedItem0').next('.wantedItem');
		} else {
			$('.wantedItem:visible').addClass('selected');
		}
	}
	$('.wantedItem.selected').fadeOut('slow', function(){
		$('.wantedItem').removeClass('selected');
		nextItem.fadeIn('fast', function () {
			if (jQuery.browser.msie) {
				this.style.removeAttribute('filter');
			}	
		}).addClass('selected');
		wantedTimer = setTimeout(toggleWantedItem, 5000);
	});
}
function ie6script() {
	DD_roundies.addRule('.sub','7px 7px 7px 7px');
}

function ie7script() {
	$('#mainNavigation ul li').bind('mouseenter', function() {
		$('.sub').css({'z-index':'999'});
	});

	DD_roundies.addRule('.sub','7px 7px 7px 7px');
}

function ie8script() {
	$('#mainNavigation ul li').bind('mouseenter', function() {
		$('.sub').css({'z-index':'999'});
	});
}

var height = 0; //declared here to allow a global variable
var borderColor = 0; //declared here to allow a global that only runs once per page
function ie8rounded(command) {
	if (command == 'remove') {
		$('.sub ~ img').remove();
		$('.sub ~ div').remove();
	} else {
		var position = $('.sub').position();
		var top = position.top + 1;
		var width = $('.sub').width();
		if (height == 0) {
			height = $('.sub').outerHeight(true);
			height = height + top + 4;
		}
		if (borderColor == 0) {
			borderColor = $('.sub').css('border-color');
		}
		var left = position.left;
		var left7 = left + 7;
		width = width + 7;
		
		var right = width + left + 7;
		$('.sub').after(function(){
			var newHTML = '<div style="position:absolute; top:'+top+'px; left:'+left7+'px; width: '+width+'px; height: 6px; background-color: #952837; border-top: 1px solid '+borderColor+'; z-index:99999;"></div>';
			newHTML = newHTML + '<img src="/templates/default/images/subNavTopLeft.png" alt="" style="position:absolute; top:'+top+'px; left:'+left+'px; z-index:99999;" />';
			newHTML = newHTML + '<img src="/templates/default/images/subNavTopRight.png" alt="" style="position:absolute; top:'+top+'px; left:'+right+'px; z-index:99999;" />';
			newHTML = newHTML + '<img src="/templates/default/images/subNavBottomRight.png" alt="" style="position:absolute; top:'+height+'px; left:'+right+'px; z-index:99999;" />';
			newHTML = newHTML + '<img src="/templates/default/images/subNavBottomLeft.png" alt="" style="position:absolute; top:'+height+'px; left:'+left+'px; z-index:99999;" />';
			newHTML = newHTML + '<div style="position:absolute; top:'+height+'px; left:'+left7+'px; width: '+width+'px; height: 6px; background-color: #8F0D1C; border-bottom: 1px solid '+borderColor+'; z-index:99999;"></div>';
			return newHTML;
		});
		$('.sub').css({
				'margin-top':'7px',
				'border-top':'none',
				'border-bottom':'none'});
	}
}


