$(document).ready(function(){
var fadeTime = 300; // 表示切り替え速度(ミリ秒)
var opacity = 0.4; // ボタン、サムネイルなどの透過度(0~1)
var lwrap = $('#slideshow');
var swrap = $('#slideshow_sub');
var cwrap = $('#slideshow_comment');
var twrap = $('.slideshow_thumb li');
var first = $('.slideshow_thumb li:first');
var last = $('.slideshow_thumb li:last');
var active = first;
var listLengh = twrap.length;
twrap.each(function(i){
var src = $(this).find('img').attr('large');
var comment = $(this).find('img').attr('alt');
var id = (i + 1).toString();
$(this).hover(function(){
if (!$(this).hasClass('active')) {
$(this).stop().animate({opacity:'1'},200);
$(this).addClass('hover');
}
},function(){
if (!$(this).hasClass('active')) {
$(this).stop().animate({opacity:opacity},200);
}
$(this).removeClass('hover');
});
var img = $('
');
lwrap.append(img);
img.load(function(){
if (lwrap.css('width') < img.css('width')) {
img.css('width','100%');
img.css('height','auto');
}
if (lwrap.css('height') < img.css('height')) {
img.css('width','auto');
img.css('height','100%');
}
if (lwrap.css('height') > img.css('height')) {
img.css('margin-top', parseInt((parseInt(lwrap.css('height'))-parseInt(img.css('height')))/2));
}
});
if ($('a.baguetteBox').length == listLengh)
{
baguetteBox.run('#slideshow');
}
});
twrap.css({opacity:opacity});
/*
if ($('#img_1').size()) {
var src = $('#img_1').attr('large');
var img = $('
');
swrap.append(img);
img.load(function(){
if (swrap.css('width') < img.css('width')) {
img.css('width','100%');
img.css('height','auto');
}
if (swrap.css('height') < img.css('height')) {
img.css('width','auto');
img.css('height','100%');
}
if (swrap.css('height') > img.css('height')) {
img.css('margin-top', parseInt((parseInt(swrap.css('height'))-parseInt(img.css('height')))/2));
}
});
}
if ($('#img_madori').size()) {
var src2 = $('#img_madori').attr('large');
var img2 = $('
');
swrap.append(img2);
img2.load(function(){
if (swrap.css('height') < img2.css('height')) {
img.css('width','auto');
img.css('height','100%');
}
if (swrap.css('height') > img.css('height')) {
img2.css('margin-top', parseInt((parseInt(swrap.css('height'))-parseInt(img2.css('height')))/2));
}
});
}
*/
twrap.click(function(){
var connectCont = twrap.index(this);
var showCont = connectCont+1;
var comment = $(this).find('img').attr('alt');
var view = lwrap.find('#view_' + (showCont));
var img_id = $(this).find('img').attr('id');
view.siblings().stop().animate({opacity:'0'},fadeTime,function(){$(this).css({zIndex:'98'}).hide();});
view.show().stop().animate({opacity:'1'},fadeTime,function(){$(this).css({zIndex:'99'});});
cwrap.text(comment);
active.stop().animate({opacity:opacity},200);
active.removeClass('active');
$(this).addClass('active');
active = twrap.parent().find('.active');
/*
if (($(this).find('img').attr('id')=="img_madori" || $('#view_sub_madori').size()==0) && $('#view_sub_1').size()) {
$('#view_sub_madori').stop().animate({opacity:'0'},fadeTime,function(){$(this).css({zIndex:'98'})});
$('#view_sub_1').stop().animate({opacity:'1'},fadeTime,function(){$(this).css({zIndex:'99'})});
}
else if ($('#view_sub_madori').size()) {
$('#view_sub_1').stop().animate({opacity:'0'},fadeTime,function(){$(this).css({zIndex:'98'})});
$('#view_sub_madori').stop().animate({opacity:'1'},fadeTime,function(){$(this).css({zIndex:'99'})});
}
*/
if ($('#view_sub_1').attr('img_id') == img_id && $('#view_sub_2').attr('img_id') != '') {
$('#view_sub_1').stop().animate({opacity:'0'},fadeTime,function(){$(this).css({zIndex:'98'})});
$('#view_sub_2').stop().animate({opacity:'1'},fadeTime,function(){$(this).css({zIndex:'99'})});
}
else {
$('#view_sub_2').stop().animate({opacity:'0'},fadeTime,function(){$(this).css({zIndex:'98'})});
$('#view_sub_1').stop().animate({opacity:'1'},fadeTime,function(){$(this).css({zIndex:'99'})});
}
});
first.click();
function nextView() {
var listIndex = twrap.index(active);
if(listLengh == (listIndex+1)){
first.click()
} else {
twrap.eq(listIndex+1).click();
};
}
function prevView() {
var listIndex = twrap.index(active);
if(listIndex == 0){
last.click();
} else {
twrap.eq(listIndex-1).click();
};
}
if (lwrap.find('img').size() <= 1) {
if ($('#slideshow_prev').size()) {
$('#slideshow_prev').remove();
}
if ($('#slideshow_next').size()) {
$('#slideshow_next').remove();
}
} else {
if ($('#slideshow_prev').size()) {
$('#slideshow_prev').click(prevView);
}
if ($('#slideshow_next').size()) {
$('#slideshow_next').click(nextView);
}
}
});
// -->