function inimiRollover()
{  
  misecs = 4;
  mistopRollover();
  miRollover();
}

function miRollover(){
  if (misecs==0){
    misecs = 4;
    changeImg(ti);
    ti++;
    if (ti ==contentImages["image"].length){
      ti = 0;
      }
      mistopRollover();
      miRollover();
    
  }
  else
  {
    misecs = misecs - 1;
    mirolling = true;
    mirolloverID = self.setTimeout("miRollover()", midelay);
  }
}

function mistopRollover()
{
  if(mirolling)
    clearTimeout(mirolloverID);
  mirolling = false;
}

function mediaSwap(i){
  changeImg(i);
  mistopRollover();
}

function pauseRollover(){
  if(miRestart)
    clearTimeout(miRestartID);
  mistopRollover();
  }

function restartRollover(){
  if(miRestart)
    clearTimeout(miRestartID);
  miRestartID = self.setTimeout('miRollover()', 4000);
  miRestart = true;
}

function changeImg(i){
  new Effect.Appear('content_table', {
    from: 0, 
    to: 1,
    duration: 1,
    afterSetup:function(e){
      $("content_image").src = contentImages["image"][i].item.img.src;
      var className = $('content_bg').classNames();
      $('content_bg').removeClassName(className);
      className = $('content_bg_end').classNames();
      $('content_bg_end').removeClassName(className);
      $('content_bg').addClassName(contentImages["image"][i].item.name + "_bg");
      $('content_bg_end').addClassName(contentImages["image"][i].item.name + "_end");
      $('media_map_options').href = contentImages["image"][i].item.url;
      $('media_map_options').target = contentImages["image"][i].item.target;        
      $('media_map_options').coords = contentImages["image"][i].item.coords;
      $('media_map_options').alt = contentImages["image"][i].item.heading;
    }
  });
  var selectFinder = new Selector('.selected');
  selectFinder.findElements().each(function(input){
    input.removeClassName('selected');
  });
  $('ml'+i).addClassName('selected');

}

function scrollToC(){
new Effect.Move('content_item_1', {x: -800});
new Effect.Move('content_item_5', {x: -800});
  }

function showObj(_id){
  replaceClassGroup('showDiv','hideDiv');
  replaceClassGroup('showPlan','hidePlan');
  replaceClassSingle(_id,'hideDiv', 'showDiv')    
  replaceClassSingle('subConDiv','hideDiv', 'showDiv');
  replaceClassGroup('hideContent','showContent');
  }

function showObjTeam(_id){
  replaceClassGroup('showDiv','hideDiv');
  replaceClassGroup('showPlan','hidePlan');
  replaceClassSingle(_id,'hideDiv', 'showDiv')
  replaceClassGroup('hideContent','showContent');
  }

function showContent(_id){
  if ($('content_' + _id).hasClassName('hideContent')){
      replaceClassSingle('content_' + _id,'hideContent', 'showContent');
      replaceClassGroup('showPlan','hidePlan');
    }
  }

  function showPlan(_i_id, _id){
    if(_id == "0"){
       showContent(_i_id);
    }
    else{
    if ($('content_' + _i_id).hasClassName('showContent')){
      replaceClassSingle('content_' + _i_id, 'showContent', 'hideContent');
    }
    replaceClassGroup('showPlan','hidePlan');
    replaceClassSingle('sc_' + _id,'hidePlan', 'showPlan');
    }
}

function replaceClassSingle(_obj,remove_class, add_class){
  $(_obj).removeClassName(remove_class);  
  $(_obj).addClassName(add_class);
}

function replaceClassGroup(remove_class, add_class){
      var selectFinder = new Selector("." + remove_class);
    selectFinder.findElements().each(function(input){
      input.removeClassName(remove_class);
      input.addClassName(add_class);
    });  }

//Scrolling methods
function moveLeft(id){
  clearTimeout(leftMover);    
  $(id).scrollLeft+=stepIncrement;
  leftMover=setTimeout("moveLeft('"+id+"')",5);
}

function moveRight(id){
  clearTimeout(rightMover)
  $(id).scrollLeft-=stepIncrement
  rightMover=setTimeout("moveRight('"+id+"')",5)
}

function rightEnd(id){
  $(id).scrollLeft=$(id).scrollWidth
//  replaceClassGroup('goLeftEndDisable','goLeftEnd');
}

//Moves id to left end of scroll space
function leftEnd(id, _button_id){
      $(id).scrollLeft=0;
}

function stopScroll(id){
  clearTimeout(rightMover);
  clearTimeout(leftMover);
}

function openWin(_url){
 var owin = window.open(_url,'ps_win','width=400,height=400,toolbar=no,location=yes,directories=yes,status=yes,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes');
 owin.focus();   
}
