// MENU

var items = new Array("news","hist","graph","gallery","heap","inter","forum","creds");
var num = 8;

var subs = new Array(
  new Array(),
  new Array("gen","kid","flea","john","chad","exp"),
  new Array("albums","comps","snds","boots"),
  new Array("gen","stage","kid","flea","john","chad"),
  new Array("lyrics","tabs","trans","artics","walls","mp3"),
  new Array("list","art","guest","shop"),
  new Array(),
  new Array()
);
var subnum = new Array(0,6,4,6,6,4,0,0);

var gaps = new Array(0,260,185,265,265,185,0,0);

var expanded = -1;
var moves = 0;

var delay = 0;
var speedM = 16;
var speed = 16;

var timer = null;

function collapse() {
  if (moves > 0) return;
  if (expanded == -1) return;
  moves += 2;
  moveTo(expanded);
  removeSub(expanded);
  expanded = -1;
  }

function expand(n) {
  if (moves > 0) return;
    if (expanded != -1) collapse();
  if (expanded == n) return;
  
  moves += 2;
  moveFrom(n);
  bringSub(n);
  expanded = n;
  }

function moveTo(n) {
  for (i = n+1; i < num; i++) {
    cmd = "document.all."+items[i]+".style.top = parseInt(document.all."+items[i]+".style.top)-"+speedM;
    eval(cmd);
    }
  var offset;
  cmd = "offset = parseInt(document.all."+items[n+1]+".style.top) -"+
    "parseInt(document.all."+items[n]+".style.top)";
  eval(cmd);
  var ht; eval("ht = document.all."+items[n]+".height;");
  if (offset > ht+4) setTimeout("moveTo("+n+")",delay);//moveTo(n);
  else moves--;
  }

function moveFrom(n) {
  for (i = n+1; i < num; i++) {
    cmd = "document.all."+items[i]+
   ".style.top = parseInt(document.all."+items[i]+".style.top)+"+speedM;
   eval(cmd);
    }
  var offset;
  cmd = "offset = parseInt(document.all."+items[n+1]+".style.top) -"+
    "parseInt(document.all."+items[n]+".style.top)"; eval(cmd);
  if (offset < gaps[n]) setTimeout("moveFrom("+n+")",delay);//moveFrom(n);//!!setTimeout("moveFrom("+n+")",delay);
  else moves--;
  }

function bringSub(n) {
  cmd = items[n]+"icon.style.left = parseInt("+items[n]+"icon.style.left)+"+speed;
  eval(cmd);
  eval("pos = parseInt("+items[n]+"icon.style.left)");
  for (i = 0; i < subnum[n]; i++) {
    cmd = items[n]+subs[n][i]+".style.left = parseInt("+items[n]+subs[n][i]+".style.left)+"+speed;
    eval(cmd);
  }
  if (pos < 18) setTimeout("bringSub("+n+")",delay);//bringSub(n);
  else moves--;
  }

function removeSub(n) {
  cmd = items[n]+"icon.style.left = parseInt("+items[n]+"icon.style.left)-"+speed;
  eval(cmd);
  eval("pos = parseInt("+items[n]+"icon.style.left)");
  for (i = 0; i < subnum[n]; i++) {
    cmd = items[n]+subs[n][i]+".style.left = parseInt("+items[n]+subs[n][i]+".style.left)-"+speed;
    eval(cmd);
  }
  if (pos > -172) setTimeout("removeSub("+n+")",delay);//removeSub(n);//!!
  else moves--;
  }

function highlight() {} //NEED TO WORK ON THIS!!!!!!!!!!!!!!!!!

// LINKS

function redir(n) {
  switch (n) {
    case 0: url = "/index.shtml"; break;
   //-------history submenu----------- 
    case 1:  url = "/history/history.shtml"; break;
    case 11: url = "/history/AK.shtml"; break;
    case 12: url = "/history/Flea.shtml"; break;
    case 13: url = "/history/JF.shtml"; break;
    case 14: url = "/history/CS.shtml"; break;
    case 15: url = "/history/Ex.shtml"; break;
   //-------disco submenu------------- 
    case 21: url = "/disco/albums.shtml"; break;
    case 24: url = "/disco/videos.shtml"; break;	
   //-------heap submenu--------------
    case 41: url="/disco/lyrics.shtml";break;
	case 43: url="/translit/translit.shtml";break;
    case 44: url="/articles/articles.shtml";break;
	case 45: url="/wallpapers/wallpapers.shtml";break;
    case 46: url= "/mp3/mp3.shtml"; break;
   //-------interactive submenu-------
   case 52: url="/fanart/fanart.shtml";break;
   
	case 6: url = "/cgi-bin/board/board.cgi"; break;
    case 7: url = "/creds.shtml"; break;
    }
  parent.location=url;
  }

// HYPERBOLA LEVELLING

function level() {
  x = document.body.scrollTop;
  mx = parseInt(main.style.height)+parseInt(main.style.top);
  if (x + 734 > mx) return;
  if (x > 650) cont.style.top = x;
}

// ANIMATION LOADING

var anim;

function checkImg() {
if (anim.readyState == "complete") {
  clip.src = "/images/optimized.gif";
  clip.style.left = 23;
  clip.style.top = 20;
  } else setTimeout("checkImg()",1000);
}

// LOADING PICS

var picgap = 15;

var lastpic = 77;

function loadPics() {

var nums = new Array();

nums[0] = Math.round(Math.random()*(lastpic-1))+1;
for (i = 1; i < 5; i++) {
	if (nums[i-1] != lastpic) nums[i] = nums[i-1]+1;
	else nums[i] = 1;
}

for (i = 0; i < 5; i++) {
  eval("slot"+i+".src = \"/pics/pic"+nums[i]+".gif\";");
  }
}

function checkPics() {
for (i = 0; i < 5; i++) {
  if (eval("slot"+i+".readyState") == "complete") {
    if (i == 0) eval("slot"+i+".style.top = 115");
    else eval("slot"+i+".style.top = parseInt(slot"+(i-1)+".style.top) + slot"+(i-1)+".height + picgap");
    eval("slot"+i+".style.left = 878");
	if (i == 4) {
	  var h = 0;
	  for (j = 0; j < 5; j++) eval("h += slot"+j+".height + picgap");
	  framebottom.style.top = 110 + h - 10 - 343;
	}
  } else { setTimeout("checkPics()",1000); return; }
}
}

// EXECUTION START

function init() {
highlight();
anim = new Image();
anim.src = "/images/optimized.gif";
checkImg();
loadPics();
checkPics();
}