﻿var features = new Array();var itemCount = 6;  var speed = 6000; var showClass = 'showFeature'; var interval;var dPrefix = '#divFeature_';  var aPrefix = '#aFeature_';
function setRotation() { var i; var id; for (i = 1; i < (itemCount + 1); i++) { id = dPrefix + i; if ($(id).length) { features.push(i); if ($(id).hasClass(showClass)) { $(id).fadeIn(0); } else { $(id).fadeOut(0); } } } }
function rotate() { var i; var cur; var toShow; for (i = 0; i < features.length; i++) { cur = dPrefix + features[i]; if ($(cur).hasClass(showClass)) { if ((i + 1) == features.length) { toShow = features[0]; flipbutton(aPrefix + 1); } else { toShow = features[i + 1]; flipbutton(aPrefix + (i + 2)); } flipbutton(aPrefix + (i + 1)); $(cur).toggleClass(showClass); $(cur).delay(100).fadeOut('slow'); } } if (toShow != '') { cur = dPrefix + toShow; $(cur).toggleClass(showClass); $(cur).fadeIn('slow'); } }
function flipbutton(b) { $(b).toggleClass('featureButtonSelected'); $(b).toggleClass('featureButtonUnselected'); }
function swapContent(id,bid) { clearInterval(interval); if ($(id).length && $(id).attr('id') != $('.' + showClass).attr('id')) { $('.' + showClass).delay(100).fadeOut('slow'); $('.' + showClass).toggleClass(showClass); $(id).fadeIn('slow'); $(id).toggleClass(showClass); flipbutton('#' + $('.featureButtonSelected').attr('id')); flipbutton(bid); } interval = null; interval = setInterval(rotate, speed); }
$(document).ready(function() { setRotation(); if (features.length > 1) { interval = setInterval(rotate, speed); } })
