window.toggleTMP = function(b,sobj){
  if(obj.currentlyOpen){ obj.className = 'hide'; obj.currentlyOpen = 0; }

  if(b){
    obj.className = 'show'
    if(sobj){
      tobj = sobj.innerHTML.replace(/ /,'').toLowerCase()
      tobj = tobj.match(/[a-zA-Z0-9]+/g)
      tobj = document.getElementById(tobj)
      obj.innerHTML = tobj.innerHTML
    }
    obj.currentlyOpen = 1
  }
}
window.hclickTMP = function(e){
  YAHOO.util.Event.stopEvent()
  if(window.mTimer){ clearTimeout('window.mTimer'); window.mTimer = 0; }
  obj.openNext = this; window.mTimer = setTimeout('toggleTMP(1,obj.openNext)',500); 
}
window.hcloseTMP = function(e){
  YAHOO.util.Event.stopEvent()
  if(window.mTimer){ clearTimeout('window.mTimer'); window.mTimer = 0; }
  window.mTimer = setTimeout('toggleTMP(0,obj)',1000); 
}


window.hmouseover = function(e){ this.className = 'over' }
window.hmouseout = function(e){ this.className = '' }


window.shuffle = function(){
  /* collect h2s and position randomly */

  var y = 100; var x = 0

  var a = document.getElementsByTagName('h2')
  for(var i=0; i<a.length; i++){
    y+=parseInt(Math.random()*40)+40; if(y>350) y=100
    x+=parseInt(Math.random()*40)+60;

    a[i].style.position = 'absolute'
    a[i].style.top = y+'px'
    a[i].style.left = x+'px'
    //a[i].style.zIndex = parseInt(Math.random()*2)

    YAHOO.util.Event.addListener(a[i], "mouseover", hmouseover);
    YAHOO.util.Event.addListener(a[i], "mouseout", hmouseout);
    YAHOO.util.Event.addListener(a[i], "click", hclickTMP);
  }


  /* now that the UI has been assembled, display it */
  var obj = document.getElementById('rendered_surface');
  if(obj){
    obj.style.left = '0px';
    obj.style.width = '900px';
  }
}


window.main = function(){
  var obj = document.getElementById('tmp')
  YAHOO.util.Event.addListener(obj, "mouseout", hcloseTMP);

  window.shuffle()
}

YAHOO.util.Event.addListener(window, "load", main);
//document.onload = main()
