document.writeln('<script src="App_Assets/Javascript/jQuery/AcoraCMS/FeatureRotator.js"></script>');

if (document.images) {
    imgRotatorNextOn = new Image();
    imgRotatorNextOn.src = '/App_Themes/Default/images/rotator_next_on.png';
    imgRotatorPreviousOn = new Image();
    imgRotatorPreviousOn.src = '/App_Themes/Default/images/rotator_previous_on.png';
    imgRssFeedOn = new Image();
    imgRssFeedOn.src = '/App_Themes/Default/images/circle_rss_on.gif';
}

$(document).ready(function () {
    varFeatureWidth = $('.rotatorElements .rotatorElement:first').width();
    Rotator.init({
        'navItems': '.rotatorNav .rotatorLink',
        'rotatorElement': '.rotatorElements .rotatorElement',
        'featureAnimStartValue': 0,
        'featureAnimEndValue': varFeatureWidth,
        'featureElementStartCSSValue': '-' + varFeatureWidth + 'px',
        'useNextPrevButtons' : true,
        'featureVisibleDuration': '5000',
        'lazyLoadImages': true
    });
	
	//custom rotator stuff for RMIT
	var sectionHeadings = $('.rotatorNav>li');
	$(sectionHeadings).click(function(){
		var nestedUl = $(this).find('ul');
		var firstAnchor = $(nestedUl).find('a:first');
		$(firstAnchor).trigger('click');
	})
	
	//add selected class to rotator nav h2 
	$('.rotatorLink').click(function(){
		var parentUl = $(this).closest('ul');
		var parentParentLi = $(parentUl).closest('li');
		$('.rotatorNav>li.selected').removeClass('selected');
		$(parentParentLi).addClass('selected');
	})
	//just need to add selected class to first h2 at the start
	$('.rotatorNav>li:first').addClass('selected');
	
});
