﻿
$(document).ready(function() {

    //sliding summaries      
    $('.featurecontainer.captionfull').hover(function() {
        $(".cover", this).stop().animate({ top: '0px' }
        , { queue: false, duration: 360 });

        doRotate = false;
        clearTimeout(timer);
    }
    , function() {
        $(".cover", this).stop().animate({ top: '157px' }, { queue: false, duration: 360 });

        //pause 

        doRotate = true;
        clearTimeout(timer);
        timer = setTimeout(function() {
            contentRotate(nextDiv);
        }, 4000);
    }
    );

    //rotating news
    var timer;
    var doRotate = true;
    var featureCount = $("#news_content").children().length;
    var nextDiv = "2";
    timer = setTimeout(function() {
    contentRotate(nextDiv, true);
    }, 4000);
    

    function contentRotate(divName) {
        if (doRotate) {
            //alert(featureCount);
            var feature = $("#news_" + divName);
            feature.fadeOut("fast", function(feature) {
                return function() {
                    $(".news_content div.newsitem").hide();

                    /* fade in next item or go back to first */
                    feature.fadeIn("fast", function() {

                        if (nextDiv == featureCount) {
                            nextDiv = 1;
                        }
                        else {
                            nextDiv++;
                        }
                        timer = setTimeout(function() {
                            contentRotate(nextDiv);
                        }, 4000);

                    });
                };
            } (feature));
        }
    }
});     
    
