/**********************************************************************************/
/* Think Big Publications autoslide() implementation.                             */
/* Copyright 2009                                                                 */
/*                                                                                */
/* To use autoslide(), simply put this line in your code after the BODY tag.      */
/* <script type="text/javascript" src="mooautoslide.js"></script>                 */
/*                                                                                */
/* The script generates an onload event for the document:                         */
/* <body onload="autoslide('id',delay,duration);">                                */
/* The id is the id of the object you want to activate.                           */
/* Delay is how long before showing the slider.                                   */
/* Duration is how long to show the slider before automatically removing it.      */
/*                                                                                */
/**********************************************************************************/

function autoslide(id,counter,delay,duration)
{
  setTimeout("autoslide_activate('" + id + "')",delay);
  setTimeout("autoslide_activate('" + id + "')",delay+duration);
  autoslide_counter(counter,delay+duration);
}

function autoslide_counter(counter,ms)
{
  if (ms<0) return;
  if (!document.getElementById(counter)) return;

  document.getElementById(counter).innerHTML = Math.floor(ms/1000);
  setTimeout("autoslide_counter('" + counter + "'," + (ms-1000) + ")", 1000);
}

function autoslide_activate(id)
{
  var fireThis = document.getElementById(id);
  if (!fireThis) return;

  if (document.createEvent)
  {
//    alert('Using Strategy 1 (Firefox & Safari)');
    var eventObj = document.createEvent('MouseEvents');
//    eventObj.initMouseEvent('click', true, true, window, 1, 10, 11, 20, 21, false, false, true, false, 0, null);
    eventObj.initEvent('click', true, true);
    fireThis.dispatchEvent(eventObj);
  }
  else if (document.createEventObject)
  {
//    alert('Using Strategy 2 (IE)');
//    var eventObj = document.createEventObject();
//    eventObj.detail = 0;
//    eventObj.screenX = 10;
//    eventObj.screenY = 11;
//    eventObj.clientX = 20;
//    eventObj.clientY = 21;
//    eventObj.ctrlKey = false;
//    eventObj.altKey = false;
//    eventObj.shiftKey = true;
//    eventObj.metaKey = false;
//    eventObj.button = 0;
//   eventObj.relatedTarget = null;
//    fireThis.fireEvent('onclick',eventObj);

//    fireThis.fireEvent('onclick');
    fireThis.click();
  }
  else
  {
//    alert('No Strategy Selected');
  }
}

function autoslide_attachOnload(func)
{
  var oldonload = window.onload;
  if (typeof window.onload != 'function') window.onload = func;
  else
  {
    window.onload = function()
    {
      if (oldonload) oldonload();
      func();
    }
  }
}

function autoslide_init()
{
  /* Activate the top slider, bottom slider or both with these two calls. */
  /* autoslide('sliderTopToggle','sliderTopCounter',2000,5000); */
  autoslide('sliderBotToggle','sliderBotCounter',3000,15000);
}

autoslide_attachOnload(autoslide_init);
/* To bypass the onload event and call the event directly, you can instead use setTimeout("autoslide_init()", 1000); */

window.addEvent('domready',function()
{
  if (document.getElementById('sliderTopContent'))
    var px1 = new mooSlide2({ slideSpeed: 1000, fadeSpeed: 500, toggler:'sliderTopToggle', content:'sliderTopContent', height:150, removeOnClick: false, opacity:'0.75', effects:Fx.Transitions.Bounce.easeOut, from:'top'});
  if (document.getElementById('sliderBotContent'))
    var px2 = new mooSlide2({ slideSpeed: 1000, fadeSpeed: 500, toggler:'sliderBotToggle', content:'sliderBotContent', height:150, removeOnClick: false, opacity:'0.75', effects:Fx.Transitions.Bounce.easeOut, from:'bottom'});
})

/* The click events will attach to these divs. */
document.write("<div id='sliderTopToggle'></div>");
document.write("<div id='sliderBotToggle'></div>");
