$.auto={
	init:function(){
		for (module in $.auto) {
			if($.auto[module].init)
			$.auto[module].init();
		}
	}
};
$(document).ready($.auto.init);
// Switches tabs on click

var tabTwin= 0;

$.auto.tabs = {
	init: function() {
		$('.subject , .tab-navi').each(function(){
			var f = $.auto.tabs.click;
			var group = this;
			$('.tab li,', group).each(function(){
				$('.tab li').css("cursor","pointer");
				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,', this.group).each(function(){
			$(this).removeClass('on');
			
			$('#'+this.id+'_area').hide();
		});
		$(".tab img").each(function(){
			this.src=this.src.replace("_on","");
			if($(this).hasClass("active")){
				$(this).removeClass("active");
			}
		});
		if(tabTwin) {
			$('.tab-navi01 #'+this.id).find("img").addClass("active");
			$('.tab-navi01 #'+this.id).find("img").attr("src",$('.tab-navi01 #'+this.id).find("img").attr("src").replace(".jpg","_on.jpg"));
			$('.tab-navi01 #'+this.id).find("img").attr("src",$('.tab-navi01 #'+this.id).find("img").attr("src").replace(".gif","_on.gif"));
			$('.tab-navi01 #'+this.id).addClass('on');
			$('.tab-navi02 #'+this.id).find("img").addClass("active");
			$('.tab-navi02 #'+this.id).find("img").attr("src",$('.tab-navi02 #'+this.id).find("img").attr("src").replace(".jpg","_on.jpg"));
			$('.tab-navi02 #'+this.id).find("img").attr("src",$('.tab-navi02 #'+this.id).find("img").attr("src").replace(".gif","_on.gif"));
			$('.tab-navi02 #'+this.id).addClass('on');
		}else{
			$(this).find("img").addClass("active");
			$(this).find("img").attr("src",$(this).find("img").attr("src").replace(".jpg","_on.jpg"));
			$(this).find("img").attr("src",$(this).find("img").attr("src").replace(".gif","_on.gif"));
			$(this).addClass('on');
		}
		$(tab).show();
		this.blur();
		return false;
	}
};

