﻿/* ================================================================ 
This copyright notice must be untouched at all times.
Copyright (c) 2008 Stu Nicholls - stunicholls.com - all rights reserved.
=================================================================== */

gallery = function() {
  current = 'img1a';
  var total = $('.thumbs').length;
  thumbWidth = 0;
  for (var x = 0; x < total; x++) {
    thumbWidth = thumbWidth + $('#img' + (x + 1)).innerWidth() + 12;
  }
  //$('#innerContainer').css({ width: thumbWidth + 'px' });

  currentWidth = $('#' + current).outerWidth();
  currentHeight = $('#' + current).outerHeight();
  $('#gallery').animate({ width: currentWidth + 'px' }, 500);
  $('#' + current).animate({ marginLeft: '-' + (currentWidth - 851) / 2 + 'px' }, 500);
  $('#' + current).fadeIn('slow');
  $('#fullSize').animate({ height: currentHeight + 0 + 'px' }, 500);

  $('#innerContainer img').css({ display: 'inline' });

      //090928追加
	$('#innerContainer .thumbs').hover(function(){
		$(this).css("cursor","pointer"); 
	},function(){
		$(this).css("cursor","default"); 
		});

  $('#innerContainer img').click(function() {
    $('#' + current).fadeOut('slow');
    current = this.id + "a";
    currentWidth = $('#' + current).outerWidth();
    currentHeight = $('#' + current).outerHeight();
    if (currentWidth < 851) {
      $('#' + current).animate({ marginLeft: (851 - currentWidth) / 2 + 'px' }, 500);
      $('#gallery').animate({ width: '851px' }, 500);
    }
    else {
      $('#gallery').animate({ width: currentWidth + 'px' }, 500);
      $('#' + current).animate({ marginLeft: '-' + (currentWidth - 851) / 2 + 'px' }, 500);
    }
    $('#' + current).fadeIn('slow');
    $('#fullSize').animate({ height: currentHeight + 0 + 'px' }, 500);
  });

  return false;
}