﻿ var headline_count;
 var headline_interval;
 var old_headline = 0;
 var current_headline = 0;

$(function () {
    // create the image rotator
    setInterval("rotateImages()", 5000);
    setInterval("rotateText()", 5000);  
    setInterval("rotateMem()", 8000);


   headline_count = $("div.headline").size();
   $("div.headline:eq("+current_headline+")").css('top','2px');
 
   headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
   });


function headline_rotate() {
   current_headline = (old_headline + 1) % headline_count; 
   $("div.headline:eq(" + old_headline + ")").animate({top: -205},"slow", function() {
     $(this).css('top','210px');
   });
   $("div.headline:eq(" + current_headline + ")").show().animate({top: 2},"slow");  
   old_headline = current_headline;
 }

function rotateMem() {
    var oCurPhoto = $('#memberShow div.current');
    var oNxtPhoto = oCurPhoto.next();

    if (oNxtPhoto.length == 0)
        oNxtPhoto = $('#memberShow div:first');

    oCurPhoto.removeClass('current').addClass('previous');
    oNxtPhoto.css({ opacity: 0.0 }).addClass('current').animate({ opacity: 1.0 }, 5000,
                function () {
                    oCurPhoto.removeClass('previous');
                });
}


function rotateImages() {
    var oCurPhoto = $('#photoShow div.current');
    var oNxtPhoto = oCurPhoto.next();

    if (oNxtPhoto.length == 0)
        oNxtPhoto = $('#photoShow div:first');

    oCurPhoto.removeClass('current').addClass('previous');
    oNxtPhoto.css({ opacity: 0.0 }).addClass('current').animate({ opacity: 1.0 }, 1000,
                function () {
                    oCurPhoto.removeClass('previous');
                });
}


function rotateText() {
    var oCurPhoto = $('#mViewInnerRight div.currentText');
    var oNxtPhoto = oCurPhoto.next();

    if (oNxtPhoto.length == 0)
        oNxtPhoto = $('#mViewInnerRight div:first');

    oCurPhoto.removeClass('currentText');
    oNxtPhoto.addClass('currentText');
}


