var TabSwitch = {
	
	className:"tabSwitch_",
	groupID:"",
	tabGroup:[],
	isIE6:false,
	
	
	/* セットアップ　2009/07/30 更新
	==================================================================================================== */
	setUp:function(id,noscript){
		//IE6の判定
		this.isIE6 = (navigator.appVersion.indexOf("MSIE 6.0")>0)?true:false
		this.groupID = id;
		var targetClass = this.className + this.groupID;
		var aEle = document.getElementsByTagName("a");
		for(var i=0,l=aEle.length;i<l;i++){
			if(aEle[i].className.match(targetClass)){
				//グループに格納
				this.tabGroup.push(aEle[i]);
				//プリロード
				var t = aEle[i].firstChild;
				if(t.nodeType==1&&t.nodeName.toLowerCase()=="img"){
					if(t.src.match(/_off\./g)){
						RollOverImage.preLoad(t.src.replace(/_off\./i,"_on."));
					}else if(t.src.match(/_on\./g)){
						RollOverImage.preLoad(t.src.replace(/_on\./i,"_off."));
						RollOverImage.preLoad(t.src.replace(/_on\./i,"_ov."));
					}
				}
				//イベント設定
				aEle[i].onclick = function(){
					var ts = TabSwitch;
					ts.resetTab();
					ts.resetCursor()
					ts.setTab(this);
					ts.setCursor(this);
					ts.tabZindex(this);
					ts.contentHide();
					ts.contentShow(this.href.split("#")[1]);
					return false;
				};
				//IE6専用イベント設定
				if(this.isIE6){
					aEle[i].onmouseover = 
					aEle[i].onmouseout = function(){
						var obj = this.filters["DXImageTransform.Microsoft.AlphaImageLoader"];
						if(obj.src.match(/_off\./g)){
							obj.src = obj.src.replace(/_off\./i,"_ov.");
						}else if(obj.src.match(/_ov\./g)){
							obj.src = obj.src.replace(/_ov\./i,"_off.");
						}
					};
				}
			}
		}
		//タブ本体の可視化
		var tabs = document.getElementById("tab_" + this.groupID);
		if(tabs) tabs.style.display = "block";
		//noscript対応用タブの不可視化
		if(noscript.length>0){
			for(var j=0,m=noscript.length;j<m;j++){
				document.getElementById(noscript[j]).style.display = "none";
			}
		}
		//初期表示コンテンツの設定
		this.contentHide();
		this.contentShow(this.tabGroup[0].href.split("#")[1]);
	},
	
	
	/* 全タブのリセット
	==================================================================================================== */
	resetTab:function(){
		var arr = this.tabGroup;
		for(var i=0,l=arr.length;i<l;i++){
			var img = (this.isIE6)?arr[i].filters["DXImageTransform.Microsoft.AlphaImageLoader"]:arr[i].firstChild;
			img.src = img.src.replace(/_on\./i,"_off.");
		}
	},
	
	
	/* 対象タブのセット
	==================================================================================================== */
	setTab:function(t){
		var img = (this.isIE6)?t.filters["DXImageTransform.Microsoft.AlphaImageLoader"]:t.firstChild;
		img.src = (img.src.match(/_ov\./g))?img.src.replace(/_ov\./i,"_on."):img.src.replace(/_off\./i,"_on.");
	},
	
	
	/* カーソルのリセット
	==================================================================================================== */
	resetCursor:function(){
		var arr = this.tabGroup;
		for(var i=0,l=arr.length;i<l;i++){
			arr[i].style.cursor = "pointer";
		}
	},
	
	
	/* カーソルのセット
	==================================================================================================== */
	setCursor:function(t){
		t.style.cursor = "default";
	},
	
	
	/* タブの深度の更新
	==================================================================================================== */
	tabZindex:function(t){
		var arr = this.tabGroup;
		for(var i=0,l=arr.length;i<l;i++){
			arr[i].parentNode.style.zIndex = i + 1;
		}
		t.parentNode.style.zIndex = i + 1;
	},
	
	
	/* コンテンツの非表示
	==================================================================================================== */
	contentHide:function(){
		var arr = this.tabGroup;
		for(var i=0,l=arr.length;i<l;i++){
			var targetID = arr[i].href.split("#")[1];
			document.getElementById(targetID).style.display = "none";
		}
	},
	
	
	/* コンテンツの表示
	==================================================================================================== */
	contentShow:function(id){
		document.getElementById(id).style.display = "block";
	}
	
	
};
