/* ---- DON'T Put site specific functions in here --- */


var carousel_timeout = 8000;
var timer;
jQuery(document).ready(function () {
    if (jQuery('#carousel').length != 0) {
        jQuery('#carousel li').mouseover(function () {
            clearTimeout(timer);
            var index = jQuery('#carousel li').index(this);
            jQuery('#carousel>div').hide();
            jQuery('#carousel #tabs_'+index).show();
            jQuery('#carousel ul a').removeClass('hover');
        });
        jQuery('#carousel ul').mouseout(function () {
            timer = setTimeout('goNextPic()', carousel_timeout);
            var div = jQuery(jQuery('#carousel>div:visible')[0]);
            index = div.attr('id').split('_')[1];
            jQuery('#carousel ul li:eq('+index+')').find('a').addClass('hover');
        });
    }
    goNextPic();
});

function goNextPic() {
    var vis = jQuery('#carousel>div:visible');
    var index;
    if (vis.length == 1) {
        var div = jQuery(jQuery('#carousel>div:visible')[0]);
        index = div.attr('id').split('_')[1];
    } else {
        index = -1;
    }
    index++;
    if (index >= jQuery('#carousel>div').length) {
        index = 0;
    }
    jQuery('#carousel>div').hide();
    if (vis.length == 1) {
        jQuery('#carousel #tabs_'+index).fadeIn("def");
    } else {
        jQuery('#carousel #tabs_'+index).show();
    }
    jQuery('#carousel ul a').removeClass('hover');
    jQuery('#carousel ul li:eq('+index+')').find('a').addClass('hover');
    timer = setTimeout('goNextPic()', carousel_timeout);
}

