/****************************************************************************
 * 長い文章をアコーディオンする
 ****************************************************************************/
$(function() {
  $('.simple_accordion').each(function(){
    var simple_accordion_title = $(this).attr('title');
    var simple_accordion_link = 
      $('<a class="simple_accordion_link" href="javascript:void(0);">' + simple_accordion_title + 'を表示する。</a>').toggle(
        function(){
          $(this).text(simple_accordion_title + 'を閉じる。');
          $(this).parent().next().slideDown();
        },
        function(){
          $(this).text(simple_accordion_title + 'を表示する。');
          $(this).parent().next().slideUp();
        }
      );
    var simple_accordion_p = $('<p></p>').append(simple_accordion_link);
    $(this).css({'display':'none'}).before(simple_accordion_p);
  });
});

/****************************************************************************
 * 画像を切り替えるJavaScript「jQuery Slinky Slider」
 ****************************************************************************/
			/*
			 #		jQuery Slinky Slider Plugin
			 #		---------------------------
			 #		Version:			1.0
			 #		---------------------------
			 #		Author:				samhs
			 # 		http://ohwrite.co.uk/jquery/jquery-plugin-slinky-slider/
			 #		http://docs.jquery.com/Plugins/SlinkySlider
			 #
			 # 		Copyright (c) 2009 Sam Hampton-Smith
			 #
			 #		Dual licensed under the MIT and GPL licenses:
			 #	 	http://www.opensource.org/licenses/mit-license.php
			 #		http://www.gnu.org/licenses/gpl.html
			 #
			 #		Please view files mit.txt and gpl.txt for full license terms
			 #		And include these two files if you redistribute this software
			 */


(function($) {
		   
			$.fn.slinkySlider = function(settings) {	
				// Utility variables - do not alter
				var currentpanel;
				var panelwidth;
				var goforward = true;
				var t;
				settings = $.extend({}, $.fn.slinkySlider.defaults, settings);	

				return $(this).each(function(){
					panelwidth = $(this).width();
					$(this).css("overflow","hidden");
					settings.largesize = panelwidth-((settings.numberofpanels-1)*(settings.smallsize+settings.panelspacing));
					container = $(this);
					elheight = container.height();
					for (var i=1;i<=settings.numberofpanels;i++) {
						$(container).append("<div class='panelwrappers'><div class='panel'></div></div>");
						$(".panelwrappers:last .panel").load(settings.panelname+i+".html").parents(".panelwrappers").data("number",i);
					}
					currentpanel = $(".panelwrappers:first");
					$(".panelwrappers").css({
							"width"		:	settings.smallsize+"px", 
							"float"		:	"left",
							"height"	:	elheight+"px"});
					$(".panels").css({
							"width"		:	settings.largesize+"px",
							"height"	:	"100%"}); 
					$(currentpanel).css("width",settings.largesize+"px");
					$(".panelwrappers").not(":last").css("margin-right",settings.panelspacing+"px");
					$(".panelwrappers").each(function(){
						$(this).mouseover(function(){switchpanel(this);});
					});
					if (settings.doauto) t = setTimeout(function(){switchpanel(null);},settings.autotimer);
				});

				function switchpanel(newpanel) {
					if (newpanel==currentpanel) {
						// do nothing because we're already on this panel
					} else {
						var auto = false;
						if (newpanel==null) {
							auto = true;
							if (goforward && $(currentpanel).data("number")==settings.numberofpanels) {
								goforward=false;
							}
							if (!goforward && $(currentpanel).data("number")==1) {
								goforward=true;
							}						
							if (goforward) {
								newpanel = $(currentpanel).next();
							} else {
								newpanel = $(currentpanel).prev();
							}							
						}
						else {
							$(".panelwrappers").stop();
							clearTimeout(t);
						}
						$(".panelwrappers").not(newpanel).animate({width: settings.smallsize+"px"},settings.transition, "swing");
						$(newpanel).animate({width: settings.largesize+"px"},settings.transition, "swing");				
						currentpanel = newpanel;
						if (auto) t = setTimeout(function(){switchpanel(null);},settings.autotimer); 
				}
			}
		}
			
		$.fn.slinkySlider.defaults = {
			autotimer:5000,
			transition:1000,
			panelspacing:3,
			smallsize:40,
			numberofpanels:3,
			largesize:0,
			doauto:true,
			panelname:"panel"
		}

})(jQuery);

/****************************************************************************
 * FAQページの折りたたみとタブのJavaScript
 ****************************************************************************/

// 折りたたみ
$(document).ready(function() {
	$(".qaArea dt").hover(function(){
		$(this).css("cursor","pointer"); 
	},function(){
		$(this).css("cursor","default"); 
		});
	$(".qaArea dd").css("display","none");
	$(".qaArea dt").click(function(){
		$(this).next().slideToggle("normal");
		});
});
// 折りたたみここまで

// タブ
// jQuery_Auto 0.9
// Automatic functions for webpages (using the wonderful jQuery library)

// Copyright: (c) 2006, Michal Tatarynowicz (tatarynowicz@gmail.com)
// Licenced as Public Domain (http://creativecommons.org/licenses/publicdomain/)
// $Id: jquery_auto.js 426 2006-05-06 19:54:39Z Michał $

// Initialization
$.auto = {
	init: function() {
		for (module in $.auto) {
			if ($.auto[module].init)
				$.auto[module].init();
		}
	}
};
$(document).ready($.auto.init);
// Switches tabs on click
$.auto.tabs = {
	init: function() {
		$('.qaContainer').each(function(){
			var f = $.auto.tabs.click;
			var group = this;
			$('.tab li, li.tab', group).each(function(){
				this.group = group;
				$(this).click(f);
				$('#'+this.id+'_area').hide();
			}).filter(':first').trigger('click');
		});
	},
	click: function() {
		var tab = $('#'+this.id+'_area').get(0);
		$('.tab li, li.tab', this.group).each(function(){
			$(this).removeClass('active');
			$('#'+this.id+'_area').hide();
		});
		$(this).addClass('active');
		$(tab).show();
		this.blur();
		return false;
	}
};
// タブここまで






