var current_image = '';
var current_url = '';
var current_thumb_div = '';
var current_index = 0;
var continue_rotation = true;
var image_timer;

var aImages = [];
aImages.push(['wilken', 'shawnwilken']);
aImages.push(['siegle', 'richsiegle']);
aImages.push(['ray', 'sararay']);
aImages.push(['perewitz', 'daveperewitz']);
aImages.push(['pascal', 'pascal']);
aImages.push(['maldonado', 'maldonado']);

onload = init_cs_thumbs;

function init_cs_thumbs()  {
  new PeriodicalExecuter(rotate_next_image, 3);
}

function toggle_rotation()  {
  if(continue_rotation)
    continue_rotation = false;
  else
    continue_rotation = true;
}

function rotate_next_image()  {
  if(continue_rotation)  {
    if(current_index < 5)
      current_index++;
    else
      current_index = 0;
    cs_change_image(current_index);
  }
}

function cs_change_image(id)  {
  reset_all_thumbs();
  current_index = id;
  current_image = aImages[id][0];
  current_url = aImages[id][1];
  current_thumb_div = $('cs_thumb_' + id);
  set_current_objs();
}

function set_current_objs()  {
  current_thumb_div.className = 'custom_shop_thumb_normal';
  $('cs_main_link').href = 'CustomShop.aspx?content=' + current_url;
  $('cs_main_image').src = "images/customshop/polaroid_" + current_image + ".jpg";
}

function reset_all_thumbs()  {
  document.getElementsByClassName('custom_shop_thumb_normal')[0].className = 'custom_shop_thumb_faded';
}