// JavaScript Document
function changeSearch(Num){
	//設定を記入-------------------------------------------------
	var imgPass="images/top_page/";//イメージファイルのパスを記入
	var imgType="jpg";//イメージファイルの拡張子を記入
	var imgNameOn="search_on_";//アクティブ時のファイル名（拡張子と番号は書かない）
	var imgNameOff="search_off_";//ノンアクティブ時のファイル名（拡張子と番号は書かない）
	//-----------------------------------------------------------
	
	// topicsCount直下のdivの数（トピックの数）を数えます-----------
	var obj = document.getElementById("searchCount").childNodes; 
	var objNum = 3; // トピックスの数
	//-----------------------------------------------------------

	// Cookieに代入 20081104 ------------------------------------
	theName  = "tab_cookie";
	theValue = Num;
	theDay   = 7;
	setDay = new Date();
	setDay.setTime(setDay.getTime()+(theDay*1000*60*60*24));
	expDay = setDay.toGMTString();
	document.cookie = theName + "="+escape(theValue)+";expires="+expDay;
	//-----------------------------------------------------------
	
	
	//トピックの数だけ繰り返す
	for(i=0;i<objNum;i++){
		objNameTopics="search"+i;//タブのidを指定
		objNameTopicscon="searchcon"+i;//内容のidを指定
		
		if(i==Num){//アクティブトピックの時
			imgName=imgNameOn+i+"."+imgType;
			document.getElementById(objNameTopicscon).style.display="block";//表示
		}else{//ノンアクティブトピックの時
			imgName=imgNameOff+i+"."+imgType;
			document.getElementById(objNameTopicscon).style.display="none";//非表示
		}
		//タブ画像の指定--------------------------------------------
		selectImg=imgPass+imgName;
		selectTag=document.getElementById(objNameTopics);
		imgNode=document.createElement("img");
		imgNode.src=selectImg;
		selectTag.replaceChild(imgNode, selectTag.firstChild);
		//-----------------------------------------------------------
	}
}
// onload追記
function addEvent(elm,listener,fn){
	try{
		elm.addEventListener(listener,fn,false);
	}catch(e){
		elm.attachEvent("on"+listener,fn);
	}
}
// タブ初期化
function initTab(){
	theData   = "";
	theName   = "tab_cookie=";
	theCookie = document.cookie+";";
	start = theCookie.indexOf(theName);
	if (start != -1)
	{
		end = theCookie.indexOf(";",start);
		theData = unescape(theCookie.substring(start+theName.length,end));
		changeTab(theData);
	}
}
addEvent( window,'load', initTab );