//
// CUSTOM MOOTOOLS IMAGE SLIDER - (C)2010 WPstudios
//
var tPun;
var curr_img   = 1;
var prev_img   = 1;
var max_img    = 1;
var show_delay = 10 * 1000; // slider secs.
var page_img   = 1;
var page_width = 1;

var dot_on  = '';
var dot_off = '';

function doSetSlideNum(x,k,w,d_on,d_off)
{
  dot_on  = d_on;
  dot_off = d_off;
  
  page_img = k;
  page_width = w;
  max_img = x/k;
  $('slider_main').setStyle('width', ((max_img) * page_width)+'px');
  $('dots').empty();

  var dot_o = new Element('img', {'src': dot_off,     'alt': 'o', 'border': '0' });

  for(i = 0; i < x; i++)
  {
    var dot_o = new Element('img', {'id': 'dot_'+i,'src': dot_off,     'alt': 'o', 'border': '0' });
    dot_o.inject($('dots'));
  }

  $('dots').setStyle('padding-left', ((page_width - ((20 * x)))/2)+50+'px');

  doShow();
}

function doShow()
{
  $('slider_main').tween('left', (curr_img - 1)*(-1*page_width)+'px');

  k = (prev_img - 1) * page_img;
  for(y = 0; y < page_img; y++)
    $('dot_'+(k+y)).set('src', dot_off);

  k = (curr_img - 1) * page_img;
  for(y = 0; y < page_img; y++)
    $('dot_'+(k+y)).set('src', dot_on);

  prev_img = curr_img;
  curr_img++;
  if(curr_img > max_img) curr_img = 1;

  tPun = setTimeout("doShow()",show_delay);
}

function doShowNext()
{
  clearInterval(tPun);
  doShow();
}


function doShowPrev()
{
  clearInterval(tPun);
  curr_img = prev_img - 1;
  if(curr_img < 1) curr_img = max_img;
  doShow();
}

window.addEvent('domready',function()
{
   
});

