var rotatorObject;

function rotateHPBannerImages() {
    var oCurPhoto = $('#rotating-banner div.current');
    var oNxtPhoto = oCurPhoto.next();
    
    if (oNxtPhoto.length == 0)
    {
        oNxtPhoto = $('#rotating-banner div:first');
    }

    oCurPhoto.removeClass('current').addClass('previous');
    
    oNxtPhoto.css({ opacity: 0.0 }).addClass('current').animate({ opacity: 1.0 }, 1000,
        function() {
            oCurPhoto.removeClass('previous');
        });
    
    //get the indicator that is currently "on"
    var curIndicator = $('#slide-indicator li.indicator-on');
    //get the next indicator
    var nextIndicator = curIndicator.next();
    
    //if there is not another indicator after the current
    //start over at the begining of the collection
    if (nextIndicator.length == 0)
    {
        nextIndicator = $('#slide-indicator li:first');
    }
    //remove the "on" class and add the "off" class
    curIndicator.removeClass('indicator-on').addClass('indicator-off');
    
    //add fade effect with animate to fade in the new one and after
    //the fade is complete remove the class
    nextIndicator.css({ opacity: 0.0 }).addClass('indicator-on').animate({ opacity: 1.0 }, 250,
        function() {
            curIndicator.removeClass('indicator-off');
        });   
    
}

function goToBannerImage(imgIndex)
{
	//stops the rotation.
	clearInterval(rotatorObject);
	
	$(".hp-image-container").each(function(index) {
	
		if(index == imgIndex)
		{
			$(this).addClass('current');
			$(this).removeClass('previous');
		}
		else
		{
			$(this).removeClass('current previous');
		}
	
	});
	
	$("#slide-indicator li").each(function(index) {
			
		if(index == imgIndex)
		{
			$(this).addClass('indicator-on');
			$(this).removeClass('indicator-off');
		}
		else
		{
			$(this).removeClass('indicator-on indicator-off');
		}
	
	});
	
}

function setIntervalObject(obj)
{
	rotatorObject = obj;
}
