<!--
// 汎用JavaScript
// site.js
// HEADタグの間に以下の記述を追加しておく
// <script language="JavaScript" src="/js/site.js"></script>
//
// html本体読込後に実行したい場合はbodyタグにonLoadイベントとして定義しておく
// <BODY onLoad="bodyLoad();">
function bodyLoad(){
	//user_pref("javascript.console.open_on_error", true);
	// html本体読込後に実行するfunctionを列記する
	var dmmy = addlinks1();
	// var dmmy = addlinks2();
	var dmmy = dellinks1();
	var dmmy = tagchg();
}

	function resize_waku(){
		// ブラウザーの幅が大きい場合、あまり横に広げない
		clientSize=getWindowClientSize();
		//var obj1=document.all && document.all(id).getElementsByTagName('table') || document.getElementById && document.getElementById(id).getElementsByTagName('table');
		var obj1=document.getElementById("waku");
		if(obj1){
			//alert(obj1.tagName);
			if(clientSize.width > 800){
				//alert("800px以上");
				obj1.style.width = "790px";
			}else if(clientSize.width < 801 && clientSize.width > 630){
				// 800px以下400px以上の場合は、最大幅で表示
				//alert("400～800px");
				obj1.style.width = "100%";
			}else{
				// 400px以下の場合は、400px固定表示
				//alert("400px以下");
				obj1.style.width = "620px";
			}
		}
	}
	function getWindowClientSize(){
		// ブラウザーのサイズを取得
		var result={"width":0,"height":0};
		if(window.self&&self.innerWidth){
			result.width=self.innerWidth;
			result.height=self.innerHeight;
		}else if(document.documentElement && document.documentElement.clientHeight){
			result.width=document.documentElement.clientWidth;
			result.height=document.documentElement.clientHeight;
		}else{
			result.width=document.body.clientWidth;
			result.height=document.body.clientHeight;
		}
		return result;
	}

// ******** ここから汎用関数 ********


function dellinks1(){
	// リンクに現在表示中と同じリンクがあった場合、リンク属性を解除する。
	var obj = document.getElementById('categories').getElementsByTagName('a');
	var valname;
	for (var i=0; i <= obj.length-1; i++){
		valname=obj[i].getAttribute("href");
		//alert(valname);
		if (valname == document.URL){
			//alert(obj[i].className);
			//リンク情報削除
			obj[i].className="nolink";		//a.nolink スタイルを適用。site.cssに定義しておくこと
			obj[i].removeAttribute('href',"");
		}
	}
}

function addlinks1(){
	// トップページとサイトマップのリンクを作成する
	var obj = document.getElementById('categories').getElementsByTagName('li');
	var valname;
	for (var i=0; i <= obj.length-1; i++){
		valname=obj[i].innerHTML;
		var valname1 = valname.substr(0,6);
		//alert(valname);
		if (valname1 == "トップページ"){
			//alert(obj[i].className);
			//トップページのリンクを追加
			obj[i].innerHTML = "<a href='http://koubou.nin29.com/' title='トップページへ'>トップページ</a>"
				+ valname.substr(6,600);
			obj[i].style.borderWidth = "0px";
		}
		if (valname1 == "サイトマップ"){
			//alert(obj[i].className);
			//サイトマップのリンクを追加
			obj[i].innerHTML = "<a href='/sitemap.php' title='IT工房にんにく庵のホームページをご案内'>サイトマップ</a>"
				+ valname.substr(6,300);
		}
	}
}

function addlinks2(){
	// お知らせと更新情報のリンク先を変更する
	var obj = document.getElementById('categories').getElementsByTagName('a');
	var valname;
	for (var i=0; i <= obj.length-1; i++){
		valname=obj[i].innerHTML;
		//alert(valname);
		if (valname == "お知らせ"){
			//alert(obj[i].className);
			obj[i].setAttribute('href',"http://koubou.nin29.com/info.html");
		}
		if (valname == "更新情報"){
			//alert(obj[i].className);
			obj[i].setAttribute('href',"http://koubou.nin29.com/update.html");
		}
	}
}

function tagchg(){
	// お知らせのh1タグをh2タグに変更する
	//alert(document.URL);
	if (document.URL == "http://koubou.nin29.com/001/10/"){
		var obj = document.getElementById('body').getElementsByTagName('h1');
		var valname;
		for (var i=obj.length-1; i >= 0 ; i--){
			valname=obj[i].innerHTML;
			//alert(valname);
			obj[i].outerHTML = "<h2>" + valname + "</h2>";
		}
		var obj1 = document.getElementById('body-inner').getElementsByTagName('div');
		//alert(obj1[0].innerHTML);
		obj1[0].innerHTML = "<h1>お知らせ</h1>" + obj1[0].innerHTML;
	}
}
function copyText(id){
	//引数で指定されたidの値をクリップボードにコピーする
	var text = document.getElementById(id).value;
	clipboardData.setData("Text", text);
}

// 一部をページ読み込み時非表示にして、クリックすると表示させる
function showImage(id){
	//alert(id);
	if(navigator.appName.charAt(0)=="M"){
		if (navigator.appVersion.indexOf("MSIE 5") != -1 || navigator.appVersion.indexOf("MSIE 6") != -1){
			if(document.getElementById){
				document.getElementById(id).style.display="block";
			}
		}
		else{
			if(document.all){
				document.all(id).style.display="block";
			}
		}
	}
	if(navigator.appName.charAt(0)=="N"){
		if(document.getElementById){
			document.getElementById(id).style.display="block";
		}
		if(document.layers){
			document.layers[id].display="show";
		}
	}
}

if(document.getElementById){
	document.writeln('<style type="text/css" media="all">');
	document.writeln('<!--');
	document.writeln('.beforeshow{display:none;}');
	document.writeln('.beforehide{display:block;}');
	document.writeln('-->');
	document.writeln('</style>');
}
function showHide(showid, hideid){
	if(showid == null){var showid = 'next';}
	if(hideid == null){var hideid = 'beforehide';}
	document.getElementById(showid).style.display = "block";
	document.getElementById(hideid).style.display = "none";
	return false;
}
function showHideA(showid1, showid2){
	// showid1で指定された部分を表示したり、非表示にしたりする。
	// showid2で指定されたスタイルを変更する
	if(document.getElementById(showid1).style.display == 'block'){
		document.getElementById(showid1).style.display = "none";
	}else{
		document.getElementById(showid1).style.display = "block";
	}
	if(document.getElementById(showid2).className == 'listplus'){
		document.getElementById(showid2).className = "listminus";
	}else{
		document.getElementById(showid2).className = "listplus";
	}
	return false;
}

// 一部をページ読み込み時非表示にして、クリックすると表示させる  －ここまで－
// -->

