var hs_seconds_between_switch = 3;
var hs_current_img = 'ad_namebadges.jpg';
var hs_path = '/images/homeslides/';
var hs_timeout = ''; // memory saver
var imgcol = ''; // memory saver
<!-- jjohnston 20100314 -->
window.addEvent('domready',function() {
//  alert($('hs_biggun2').getStyle('margin-top'));
  if (Browser.Engine.trident) {
    //$('hs_biggun1').setStyle('margin-top','1px');
    //$('hs_biggun2').setStyle('margin-top','-314px');
  }
});
window.addEvent('domready',function() {
  imgcol = $$('.hs_row img');
  imgcol.addEvent('click',function() {
    hs_resetTimeout();
    $('hs_biggun1').set('src',$('hs_biggun2').get('src'));
    $('hs_biggun2').set('opacity',0);

    imgcol.setStyle('border','4px solid #888'); 
    this.setStyle('border','4px solid #1CB3F2');
    var newsrc = this.get('id');
    var newhref = this.get('longdesc');
    hs_current_img = newsrc; 
    $('hs_biggun2').set('src',hs_path+newsrc);
    $('hs_href2').set('href',newhref);
    $('hs_biggun2').fade('in');
    hs_makeTimeout();
  });
  $$('.hs_nav').fade('out');
  $('hs_main_img').addEvent('mouseover',function() {
    $$('.hs_nav').fade(.7);
    hs_resetTimeout();
  });
  $('hs_main_img').addEvent('mouseout',function() {
    $$('.hs_nav').fade('out');
    hs_makeTimeout();
  });
  $$('.hs_nav').addEvent('mouseover',function() {
    $$('.hs_nav').fade('in');
  });
  $$('.hs_nav').addEvent('mouseout',function() {
    $$('.hs_nav').fade('out');
  });
  $$('.hs_nav').addEvent('click',function() {
    var direction = (this.get('id')=='forward') ? -1 : 1;
    next_img(direction);
  });
  hs_makeTimeout();
});
function next_img(by) {
  //console.log('nextimg: '+by);
  //console.log('img: '+hs_current_img);
  hs_resetTimeout();
  var findimg = 0;
  imgcol.each(function(item,i) {
    var imgid = 'ad_'+item.get('alt')+'.jpg'; 
    if (imgid==hs_current_img) findimg = i;
  }); 
  var newid = findimg+by;
  if (newid<0) newid = imgcol.length-1;
  if (newid>imgcol.length-1) newid = 0;
  var newimgid = imgcol[newid].get('id');
  $(newimgid).fireEvent('click'); 
  hs_makeTimeout();
}
function hs_makeTimeout() {
  window.clearTimeout(hs_timeout);
  hs_timeout = window.setTimeout('next_img(1)',hs_seconds_between_switch*1000);
}
function hs_resetTimeout() {
  window.clearTimeout(hs_timeout);
}


