var cycState = new Array(1, 1, 1, 1, 1, 1);
var cycMax = new Array(4, 7, 4, 4, 6, 4);
var boxTimes = new Object();
boxTimes.b01 = 15000;
boxTimes.b02 = 14000;
boxTimes.b03 = 9000;
boxTimes.b04 = 11000;
boxTimes.b11 = 7000;
boxTimes.b12 = 14000;
boxTimes.b13 = 14000;
boxTimes.b14 = 14000;
boxTimes.b15 = 14000;
boxTimes.b16 = 14000;
boxTimes.b17 = 14000;
boxTimes.b21 = 9000;
boxTimes.b22 = 9000;
boxTimes.b23 = 7000;
boxTimes.b24 = 9000;
boxTimes.b31 = 7000;
boxTimes.b32 = 6000;
boxTimes.b33 = 7000;
boxTimes.b34 = 9000;
boxTimes.b41 = 9000;
boxTimes.b42 = 8000;
boxTimes.b43 = 9000;
boxTimes.b44 = 6000;
boxTimes.b45 = 9000;
boxTimes.b46 = 9000;
boxTimes.b51 = 8000;
boxTimes.b52 = 8000;
boxTimes.b53 = 8000;
boxTimes.b54 = 8000;
var curSet = 0;
var curBox = 1;
var curElmt;
var bopac = 100;
var intID;
var timID;
function initPage() {
 curElmt = document.getElementById('b' + curSet + curBox);
 cycle()
}
function insertBut(butSet, butVis) {
 var butString;
 if (butVis) {
  document.write('<p><button type="button" onclick="more(' + butSet + ')">More...</button></p>')
 } else {
  document.write('<p style="visibility: hidden"><button type="button" onclick="more(' + butSet + ')">More...</button></p>')
 }
}
function fadeout() {
 bopac -= 5;
 curElmt.style.filter = 'alpha(opacity=' + bopac + ')';
 curElmt.style.opacity = bopac/100;
 if (bopac == 0) {
  curElmt.style.visibility = 'hidden';
  clearInterval(intID);
  cycle();
 }
}
function fadein() {
 bopac += 5;
 curElmt.style.filter = 'alpha(opacity=' + bopac + ')';
 curElmt.style.opacity = bopac/100;
 if (bopac == 100) {
  clearInterval(intID);
  cycle();
 }
}
function cycle() {
 if (bopac == 0) {
  curBox++; if (curBox > cycMax[curSet]) {curBox = 1};
  cycState[curSet] = curBox;
  curElmt = document.getElementById('b' + curSet + curBox);
  curElmt.style.filter = 'alpha(opacity=0)';
  curElmt.style.opacity = 0;
  curElmt.style.visibility = 'visible';
  intID = setInterval('fadein()', 50)
 } else {
  timID = setTimeout('startFade()', boxTimes['b' + curSet + curBox])
 }
}
function startFade() {
 intID = setInterval('fadeout()', 50)
}
function getLstElmt(elmt) {
 var lstElmt = elmt.lastChild;
 while (lstElmt.nodeType != 1) {
  lstElmt = lstElmt.previousSibling
 }
 return lstElmt
}
function more(newSet) {
 if (intID != null) {
  clearInterval(intID)
 }
 if (timID != null) {
  clearTimeout(timID)
 }
 curElmt.style.filter = 'alpha(opacity=100)';
 curElmt.style.opacity = 1;
 curElmt.style.visibility = 'visible';
 getLstElmt(curElmt).style.visibility = 'visible';
 curSet = newSet;
 curBox = cycState[curSet];
 curElmt = document.getElementById('b' + curSet + curBox)
 bopac = 100;
 getLstElmt(curElmt).style.visibility = 'hidden';
 startFade();
}
