function doInit() {
  top.selectedId = getPageID();
  menuClick(top.selectedId);
  
  if ($("scroller_imageBoxInside")) {
        top.executer = new PeriodicalExecuter(moveToNext, top.transition_duration);
  }
}

function menuClick(id) {
  return; 
  
  id = $(id).id;
  var div = $(id+'_content'); 
  $('copy').setStyle({display: 'none'});
  $('copy').innerHTML = div.innerHTML;
  new Effect.Appear('copy', {duration: 0.75});
  setMenuImage(top.selectedId, top.selectedId+'.png');  
  setMenuImage(id, id+'_hover.png');
  top.selectedId = id;
  window.location.hash = '_'+id;
  pageTracker._trackPageview(id);  
}

function menuMouseOver(id) {
  id = $(id).id;
  setMenuImage(id, id+'_hover.png');
}

function menuMouseOut(id) {
  id = $(id).id;

  if(top.selectedId != id) {
    setMenuImage(id, id+'.png');
  }
}

function setMenuImage(id, imgName) {
  var div = $(id);
  var img = div.down();
  img.src = 'wp-content/themes/live/images/'+imgName;
}

function setImage(id, imgPath) {
  var img = $(id);
  img.src = imgPath;
}

/* Image Scroller */
top.imageWidth = 334;
top.animation_duration = 1.2;
top.transition_duration = 6.0;
top.buttonsEnabled = true;

function disableButtons() {
  top.buttonsEnabled = false;
}

function enableButtons() {
  top.buttonsEnabled = true;
}

function moveToPrevious(sender) {
  if(!top.buttonsEnabled) {
      return;
  }
  if(sender == 'GUI') {
    top.executer.stop();
  }
  var imageBox = $("scroller_imageBoxInside");
  var imageList = imageBox.childElements();
  var lastImage = imageList[imageList.length-1]; 
  imageBox.insert({top: lastImage.remove()});
  imageBox.setStyle({left: '-668px'});
  new Effect.Move('scroller_imageBoxInside', { x: top.imageWidth, y: 0, duration: top.animation_duration, transition: Effect.Transitions.sinoidal });
  
  // Make buttons unresponsive while animation is occuring
  disableButtons();
  new PeriodicalExecuter(function(pe) {
    enableButtons();
    pe.stop();
  }, top.animation_duration);
}

function moveToNext(sender) {
  
  if(!top.buttonsEnabled && (sender != 'CON')) {
      return;
  }  
  if(sender == 'GUI') {
    top.executer.stop();
  }
  if(sender != 'CON') {
    new Effect.Move('scroller_imageBoxInside', { x: -top.imageWidth, y: 0, duration: top.animation_duration, transition: Effect.Transitions.sinoidal });    
  } else {
    new Effect.Move('scroller_imageBoxInside', { x: 0, y: 0, duration: 0 });    
  }
  var imageBox = $("scroller_imageBoxInside");
  var firstImage = imageBox.childElements()[0];  
  imageBox.insert({bottom: firstImage.remove()});
  if(sender != 'CON') {
  	imageBox.setStyle({left: '0px'});
  } else {
  	imageBox.setStyle({left: '-334px'});
  }
  // Make buttons unresponsive while animation is occuring  
  disableButtons();
  new PeriodicalExecuter(function(pe) {
    enableButtons();
    pe.stop();
  }, top.animation_duration);  
}


function getPageID() {
    var pageID = window.location.hash ? window.location.hash.replace('#','') : '_home'; 
    return pageID.substr(1);
}

