jQuery(document).ready(function() {
    if(jQuery("#section-menu li").hasClass("more")) {
        sectionLength = jQuery("#section-menu li.section").length;
        sectionLengthMore = jQuery("#section-menu .more li.section").length;
        sectionLength=sectionLength-(sectionLengthMore+2);
        jQuery("#section-menu li.section:eq("+sectionLength+")").css("border","0px");
       //alert(sectionLength);
    }
});

if (location.href.indexOf('HomePage') >= 0 || location.href=='http://www.broncosports.com/' || location.href=='http://broncosports.com/') 
	var rotate = true;	 
else
	var rotate = false;
var rotate_current = 1;
var rotate_end = 5;
var rotate_past = rotate_end;
var r;

function changeArticle() {
	//rotate_past = rotate_current - 1;
	////console.log("old: "+rotate_past+" new: "+rotate_current);
		
		jQuery("#main-image-"+rotate_past).fadeOut(500);
		//jQuery("#Rotator .main-content").hide();
		//jQuery("#Rotator .main-content").css("display","none");
		
		jQuery("#rotatorHeadlines-"+rotate_past).animate({
			top: 365
		}, 500);
		
		jQuery("#rotatorHeadlineText-"+rotate_past).animate({
			top: 365
		}, 500);
		
		jQuery("#rotatorSub-"+rotate_past).css("background", "transparent url(/fls/9900/site_graphics/rotatorsub.png) no-repeat scroll 0 0");
		jQuery("#rotatorSub-"+rotate_current).css("background", "transparent url(/fls/9900/site_graphics/rotatorsubon.png) no-repeat scroll 0 0");
		
		jQuery("#rotatorSub-"+rotate_past).css("width", "150px");
		jQuery("#rotatorSub-"+rotate_current).css("width", "184px");
		
		setTimeout('jQuery("#main-content-'+rotate_past+'").hide()',500);
		setTimeout('jQuery("#main-content-'+rotate_current+'").show()',500);
		
		setTimeout('jQuery("#main-image-'+rotate_current+'").fadeIn(500)',505);
		setTimeout('jQuery("#rotatorHeadlines-'+rotate_current+'").animate({ top: 288 }, 500)', 505);
		setTimeout('jQuery("#rotatorHeadlineText-'+rotate_current+'").animate({ top: 288 }, 500)', 505);
	//setTimeout('jQuery("#sub-arrow-'+rotate_current+'").animate({ opacity: 100 }, 500)', 505);
	//jQuery("#sub-arrow-"+rotate_current).css("visibility", "visible");
	
	/*jQuery("#sub-rotator-"+rotate_current).animate({
	  width: 0
	}, 500);

	jQuery("#sub-rotator-"+rotate_current).css("border", "0px");
	jQuery("#sub-rotator-"+rotate_current).css("margin", "0px");

	jQuery("#sub-rotator-"+rotate_past).animate({
	  width: 80
	}, 500);
	
	jQuery("#sub-rotator-"+rotate_past).css("border", "1px solid #ccc");
	jQuery("#sub-rotator-"+rotate_past).css("margin", "0px 3px");*/
	
	// fixes IE's problem displaying a space for the div that's hidden
	//setTimeout('jQuery("#sub-rotator-'+rotate_current+'").css("display", "none")',500);
	
	//jQuery('#sub-rotator-count').html((rotate_current+1)+"/5&nbsp;&nbsp;");
}

function article(num) {
	rotate_past = rotate_current;
	rotate_current = num;
	//jQuery("#Rotator .main-content").fadeOut(500);
	//setTimeout('jQuery("#Rotator .main-content:eq('+rotate_current+')").fadeIn(500)',510);
	////console.log(rotate_current+' - '+rotate_past);
	//jQuery("#Rotator .main-content:eq('+rotate_current+')").css("display","block");
	if (playerRunning)
		hideNeuLionVid();
	changeArticle();
	
	rotate = false;
}

/*function subStoryOn(num) {
	////console.log('subStoryOn:'+num);
	jQuery("img.sub-image").css("borderStyle","solid")
	////console.log(jQuery("img.sub-image").css("borderColor"));
	
	jQuery("img.sub-image:eq("+num+")").css("border", "2px solid #fff");
	jQuery("img.sub-image:eq("+num+")").css("marginBottom", "2px");
	
	jQuery("img.sub-image:eq("+num+")").animate({
		borderWidth:"2px",
		marginBottom:"2px"
	},500);
	//jQuery("img.arrow:eq("+num+")").slideDown(500);
	
	jQuery("img.arrow:eq("+num+")").css("display", "block");
}*/

function rotateForward() {
	////console.log('Forward');
	rotate_past = rotate_current;
	if(rotate_current!=rotate_end)
		rotate_current ++;
	else
		rotate_current = 1;	
	changeArticle();
}

function rotateBack() {
	////console.log('Back');
	rotate_past = rotate_current;
	if(rotate_current!=1)
		rotate_current --;
	else
		rotate_current = rotate_end;	
	changeArticle();
}

function Rotate() {
	////console.log("Rotate()");
	if(rotate) {
		////console.log("go");
		rotateForward(false);
	}
	else {
		////console.log('stop');
	}
}

function toggle() {
	////console.log('toggle');
	if(rotate) {
		rotate = false;
		clearInterval(r);
	}
	else {
		rotate = true;
		var r = setInterval('Rotate()',7000);	
	}
}

jQuery(document).ready(function () {
	
	jQuery("#rotatorHeadlines-1").animate({
		top: 288
	}, 500);
	
	jQuery("#rotatorHeadlineText-1").animate({
		top: 288
	}, 500);
	
	if(document.getElementById("rotatorContent")) 
		var r = setInterval('Rotate()',7000);	//call rotate every 5 seconds
	else {
		////console.log('no rotator');
	}
});