var slider_index = 0;
window.addEvent('domready', function()
{
  var status = {
                 'true': 'open',
                 'false': 'close'
               };


  /*
    Buttons have the follwing construct:
    <div id="button1"><input type="hidden" id="button1_target" value="signup" /></div>

    Each button on the page should be in sequence starting with 1: <div id="button1"> <div id="button2"> <div id="button3"> etc.
    Each button must have a corresponding name and target hidden field: <input type="hidden" id="button1_name" value="signup" /> <input type="hidden" id="button1_target" value="signup.php" /> etc.
    The value of the hidden name field will be used to reference the class name for the mouse over images.  So if the value is 'signup', the classes 'signup' and 'signup_o' will be used to render
    the button and the mouse over version of the button.
    The value of the hidden name target will be used as the destination after a click.  If the target value is preceeded by 'http://' it will be treated as an external link, otherwise it will be
    treated as an internal link.
  */
  var counter=1;
  while(jQuery('#button'+counter).length != 0)
  {
/*
      var n = document.getElementById('button'+counter+'_name').value;
      var t = document.getElementById('button'+counter+'_target').value;
*/
      var n = jQuery('#button'+counter+'_name').val();
      var t = jQuery('#button'+counter+'_target').val();

      /*document.getElementById('button'+counter).id = n;*/
      jQuery('#button'+counter).mouseover(function()
      {
        this.className = n+'_o';
      });

      jQuery('#button'+counter).mouseout(function()
      {
        this.className = n;
      });

      var i = (t.substr(0,7)=='http://');
      if(i)
      {
        jQuery('#button'+counter).click(function()
        {
          var nm = this.id;
          var t = document.getElementById(nm+'_target').value;
          window.location = t;
        });
      }
      else
      {
        jQuery('#button'+counter).click(function()
        {
          var nm = this.id;
          var t = document.getElementById(nm+'_target').value;
          window.location = '/'+t;
        });
      }
      counter++;
  }

  if(jQuery('#cpanel_login_area').length != 0)
  {
/*    var cpanelLoginVerticalSlide = new Fx.Slide('cpanel_login_area').hide();
    cpanelLoginVerticalSlide.hide();
    //jQuery('#cpanel_login_area').style.display = 'block';
    jQuery('#cpanel_login_area').css({"display":"block"});
    if(jQuery('#cpanel_toggle').length != 0)
      jQuery('#cpanel_toggle').click(function()
      {
       e.stop();
        cpanelLoginVerticalSlide.toggle();
      });
*/  }


  if(jQuery('#sliderContainer').length != 0)
  {
    var num_elements = 3;
    var mySlider = new ImageSlider({
                   objToSlide: 'sliderContainer',
                   sliderElements: 'div',
                   numOfElementsToSlide: 1,
                   numOfElementsShown: 1,
                   leftBtn: 'leftBtn',
                   rightBtn: 'rightBtn'
                 });

          jQuery('#leftBtn').click(function(e)
          {
            if(slider_index == 0)
            {
              slider_index = (num_elements-1);
              mySlider.slideTo(slider_index);
            }
            else
              slider_index = slider_index - 1;
          });

          jQuery('#rightBtn').click(function()
          {
            if(slider_index == (num_elements-1))
            {
              slider_index = 0;
              mySlider.slideTo(slider_index);
            }
            else
              slider_index = slider_index + 1;
          });
  }

});


