//クローズアップ用
function slideSwitch() {
	var $active = $('#slideshow a.active');
	if ( $active.length == 0 ) $active = $('#slideshow a:last');
	var $next =  $active.next().length ? $active.next() : $('#slideshow a:first');
	$active.addClass('last-active');
	$next.css({opacity: 0.0})
	.addClass('active')
	.animate({opacity: 1.0}, 1000, function() {
		$active.removeClass('active last-active');
	});
}
$(function() {
	setInterval( "slideSwitch()", 4000 );
});
//boxをリンクに
jQuery(function($){
	$("div#top_rank td").click(function(){
	  window.location=$(this).find("a").attr("href");
	  return false;
	});
	$("div#top_newentry2 li").click(function(){
	  window.location=$(this).find("a").attr("href");
	  return false;
	});
	$("div#top_diary .link").click(function(){
	  window.location=$(this).find("a").attr("href");
	  return false;
	});
	$("div#top_random .base").click(function(){
	  window.location=$(this).find("a").attr("href");
	  return false;
	});
	$("div#top_rss .rss_td").click(function(){
	  window.location=$(this).find("a").attr("href");
	  return false;
	});
	$("div#birthday .link").click(function(){
	  window.location=$(this).find("a").attr("href");
	  return false;
	});
	$("div#history2 #history_part").click(function(){
	  window.location=$(this).find("a").attr("href");
	  return false;
	});
	$("div#event_s td").click(function(){
	  window.location=$(this).find("a").attr("href");
	  return false;
	});
});
//プリロード
jQuery.preloadImages = function(){
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
};
$.preloadImages(
"/img/menu01a.gif", "/img/menu01b.gif", "/img/menu02a.gif", "/img/menu02b.gif", "/img/menu03a.gif", "/img/menu03b.gif", "/img/menu04a.gif", "/img/menu04b.gif", "/img/menu05a.gif", "/img/menu05b.gif", "/img/menu06a.gif", "/img/menu06b.gif", "/img/menu07a.gif", "/img/menu07b.gif", "/img/menu08a.gif", "/img/menu08b.gif", "/img/menu08-2a.gif", "/img/menu08-2b.gif", "/img/menu09a.gif", "/img/menu09b.gif", "/img/menu10a.gif", "/img/menu10b.gif", "/img/menu11a.gif", "/img/menu11b.gif", "/img/shop_menu01a.gif", "/img/shop_menu01b.gif", "/img/shop_menu02a.gif", "/img/shop_menu02b.gif", "/img/shop_menu03a.gif", "/img/shop_menu03b.gif", "/img/shop_menu04a.gif", "/img/shop_menu04b.gif", "/img/cast_menu01a.gif", "/img/cast_menu01b.gif", "/img/cast_menu02a.gif", "/img/cast_menu02b.gif","/img/menu_s01_b.gif", "/img/menu_s02_b.gif", "/img/menu_s03_b.gif", "/img/menu_s04_b.gif", "/img/search01a.jpg", "/img/search02a.jpg", "/img/search03a.jpg" , "/img/cast_back.gif"
);
//タブ
document.write('<style type="text/css">');
document.write('div.domtab div{display:none;}<');
document.write('/s'+'tyle>');
//横スライド用 (/pray.html参照)
(function () {
    $.fn.infiniteCarousel = function () {
        function repeat(str, n) {
            return new Array( n + 1 ).join(str);
        }
        
        return this.each(function () {
            // magic!
            var $wrapper = $('> div', this).css('overflow', 'hidden'),
                $slider = $wrapper.find('> ul').width(9999),
                $items = $slider.find('> li'),
                $single = $items.filter(':first')
                
                singleWidth = $single.outerWidth(),
                visible = Math.ceil($wrapper.innerWidth() / singleWidth),
                currentPage = 1,
                pages = Math.ceil($items.length / visible);
                
            /* TASKS */
            
            // 1. pad the pages with empty element if required
            if ($items.length % visible != 0) {
                // pad
                $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
                $items = $slider.find('> li');
            }
            
            // 2. create the carousel padding on left and right (cloned)
            $items.filter(':first').before($items.slice(-visible).clone().addClass('cloned'));
            $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
            $items = $slider.find('> li');
            
            // 3. reset scroll
            $wrapper.scrollLeft(singleWidth * visible);
            
            // 4. paging function
            function gotoPage(page) {
                var dir = page < currentPage ? -1 : 1,
                    n = Math.abs(currentPage - page),
                    left = singleWidth * dir * visible * n;
                
                $wrapper.filter(':not(:animated)').animate({
                    scrollLeft : '+=' + left
                }, 500, function () {
                    // if page == last page - then reset position
                    if (page > pages) {
                        $wrapper.scrollLeft(singleWidth * visible);
                        page = 1;
                    } else if (page == 0) {
                        page = pages;
                        $wrapper.scrollLeft(singleWidth * visible * pages);
                    }
                    
                    currentPage = page;
                });
            }
            
            // 5. insert the back and forward link
            $wrapper.after('<a href="#" class="arrow back">&lt;</a><a href="#" class="arrow forward">&gt;</a>');
            
            // 6. bind the back and forward links
            $('a.back', this).click(function () {
                gotoPage(currentPage - 1);
                return false;
            });
            
            $('a.forward', this).click(function () {
                gotoPage(currentPage + 1);
                return false;
            });
            
            $(this).bind('goto', function (event, page) {
                gotoPage(page);
            });
            
            // THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL
            $(this).bind('next', function () {
                gotoPage(currentPage + 1);
            });
        });
    };
})(jQuery);

$(document).ready(function () {
    // THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL
    var autoscrolling = true;
    
    $('.infiniteCarousel').infiniteCarousel().mouseover(function () {
        autoscrolling = false;
    }).mouseout(function () {
        autoscrolling = true;
    });
    
    setInterval(function () {
        if (autoscrolling) {
            $('.infiniteCarousel').trigger('next');
        }
    }, 2000);
});
//JQueryのLightboxプラグイン「prettyPhoto」
$(document).ready(function(){
	$(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'slow',theme:'light_square',slideshow:2000, autoplay_slideshow: true});
	$(".gallery:gt(0) a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'fast',slideshow:10000});
			
	$("#custom_content a[rel^='prettyPhoto']:first").prettyPhoto({
		custom_markup: '<div id="map_canvas" style="width:260px; height:265px"></div>',
		changepicturecallback: function(){ initialize(); }
	});

	$("#custom_content a[rel^='prettyPhoto']:last").prettyPhoto({
		custom_markup: '<div id="bsap_1237859" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6" style="height:260px"></div><div id="bsap_1251710" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div>',
		changepicturecallback: function(){ _bsap.exec(); }
	});
});
