﻿gallery = function() {

  /* show first image and information */
  showTime = 5000;
  timer = 0;
  absLeft = 0;
  picCount = 0;
  total = $('.thumb img').length;

  $('#innerContainer img').css({ display: 'inline' });

  firstStr = $('.thumb');
  showStr = firstStr.html();
  showDiv(showStr)

  /* show image and information */
  function showDiv(htmlStr) {
    $('#fullSize').html(htmlStr).fadeIn(600);
    currentLarge = $('#fullSize img').attr('class');
    currentLarge = currentLarge.substr(1, 3);
  }
}

function autoPlay() {
  currentLarge = $('#fullSize img').attr('class').split(' ').slice(-1);
//  currentLarge = $('#fullSize img').attr('class');
  if ("p" + total != currentLarge) {
    htmlStr = $('#innerContainer li.' + currentLarge).next('li').html();
    $('#fullSize').fadeOut(600, function() { playDiv(htmlStr) });
  }
  if ("p" + (total) == currentLarge) {
    htmlStr = $('#innerContainer li.p1').html();
    $('#fullSize').fadeOut(600, function() { playDiv(htmlStr) });
  }
  timer = setTimeout("autoPlay()", showTime);
}

function playDiv(htmlStr) {
  $('#fullSize').html(htmlStr).fadeIn(600);
  currentLarge = $('#fullSize img').attr('class');
  currentLarge = currentLarge.substr(1, 3);
}

