// JavaScript Document

// ロールオーバー
function initRollOverImages() {
  var image_cache = new Object();
  $("img.rover").each(function(i) {
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_ro = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
    image_cache[this.src] = new Image();
    image_cache[this.src].src = imgsrc_ro;
    $(this).hover(
      function() { if(!$(this).hasClass("active")){this.src = imgsrc_ro;} },
      function() {if(!$(this).hasClass("active")){this.src = imgsrc; }})
  });
}

$(document).ready(initRollOverImages);

//tab
$.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() {
		$('.tabArea').each(function(){
			var f = $.auto.tabs.click;
			var group = this;
			$('.tabList li', group).each(function(){
				$(this).css("cursor","pointer");
				this.group = group;
				$(this).click(f);
				$('#'+this.id+'Box').fadeOut();
			}).filter(':first').trigger('click');
		});
	},
	click: function(){
		var tab = $('#'+this.id+'Box').get(0);
		$('.tabList li', this.group).each(function(){
			$(this).removeClass('on');
			$('#'+this.id+'Box').hide();
		});
		$(".tabList img").each(function(){
			this.src=this.src.replace("_on","");
			if($(this).hasClass("active")){
				$(this).removeClass("active");
			}
		});
		$(this).find("img").addClass("active");
		$(this).find("img").attr("src",$(this).find("img").attr("src").replace(".gif","_on.gif"));
		$(this).addClass('on');
		$(tab).fadeIn("high");
		this.blur();
		return false;
	}
};
