/*------------------------------------------------------------------------------*/
/*-------------------------------------準備-------------------------------------*/
/*------------------------------------------------------------------------------*/
/*ver 1.15*/
//HOMEへのURL
if(!fpToHome){var fpToHome = '../';}
//環境js読み込み
document.write('<script language="JavaScript" src="'+fpToHome+'js/conf_js.js"></script>');
document.write('<script language="JavaScript" src="'+fpToHome+'js/AC_RunActiveContent.js"></script>');
//Win,Macの判別
tmp = navigator.appVersion;
var osName = "win";
if(tmp.indexOf("Win")!=-1){var osName = "win"}
if(tmp.indexOf("Mac")!=-1){var osName = "mac"}
//css（EX,L,M,S）の読み取り
var css_size=getCookie("CssSize");
if (css_size=="") {css_size="m";setCookie("CssSize",css_size);}
//コーナー&カテゴリーID初期値
var corner_id = 0;
var category_id = 0;
//サブメニュー保存変数
var subMenuStr = "";
/*------------------------------------------------------------------------------*/
/*-----------------------------------初期設定-----------------------------------*/
/*------------------------------------------------------------------------------*/
//LOGOの設置
function LogoOrder(tmp_path,tmp_name){
	var htmlStr = '';
	htmlStr += '<a href="'+tmp_path+'" class="logo">'+tmp_name+'</a>';
	obj = document.getElementById("header").innerHTML = htmlStr;
}
//帯画像の設定
function CornerIMG() {
	if(document.getElementById("DivInfo")){
		var htmlStr = '';
		htmlStr += '<div class="corner"><img src="../images/corner_'+corner_id+'.gif"></div><br class="end">';
		document.getElementById("DivInfo").innerHTML = htmlStr;
	}
}
//日付の表示・非表示
function NewsDATE(corner_id) {//←←←←←←←←←←←←←1.16ではcorner_id削除のこと
	tmp = location.pathname;
	if(corner_id==1){
		document.getElementById("DivTitle").getElementsByTagName("p")[0].style.display="block";
	}
}
//Flashの設置（文字サイズ）
function CssOrder(tmp_x,tmp_y){
	movieName = fpToHome+"images/fla/font_size.swf?CssSize="+getCookie("CssSize");
	var htmlStr = '';
	htmlStr += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+tmp_x+'" height="'+tmp_y+'">';
	htmlStr += '	<param name="movie" value="'+movieName+'">';
	htmlStr += '	<param name="quality" value="high">';
	htmlStr += '	<embed src="'+movieName+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+tmp_x+'" height="'+tmp_y+'"></embed>';
	htmlStr += '</object>';
	objadd = document.createElement("div");
	objadd.setAttribute("id","css_size");
	obj = document.getElementById("header").appendChild(objadd);
	obj.innerHTML = htmlStr;
}
//Flashの設置（WebDirect）
function WebDirectOrder(tmp_x,tmp_y){
	var htmlStr = '';
	htmlStr += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+tmp_x+'" height="'+tmp_y+'">';
	htmlStr += '	<param name="movie" value="'+fpToHome+'images/fla/webdirect.swf">';
	htmlStr += '	<param name="quality" value="high">';
	htmlStr += '	<embed src="'+fpToHome+'images/fla/webdirect.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+tmp_x+'" height="'+tmp_y+'"></embed>';
	htmlStr += '</object>';
	objadd = document.createElement("div");
	objadd.setAttribute("id","webdirect");
	obj = document.getElementById("header").appendChild(objadd);
	obj.innerHTML = htmlStr;
}
//ヘッダーメニューの設置
function HeadMenuOrder(){
	var htmlStr = '';
	htmlStr += '<ul>';
	for (i in HederMenuArray) {
		htmlStr += '	<li class="headmenu';
		htmlStr += i;
		htmlStr += '"><a href="'+HederMenuArray[i][2]+'" target="'+HederMenuArray[i][3]+'">'+HederMenuArray[i][1]+'</a></li>';
	}
	htmlStr += '</ul>';
	objadd = document.createElement("div");
	objadd.setAttribute("id","headmenu");
	obj = document.getElementById("header").appendChild(objadd);
	obj.innerHTML = htmlStr;
}
//メニューの設置
function MenuOrder(){
	var htmlStr = '';
	htmlStr += '<p class="visit">Menu</p>';
	htmlStr += '<ul class="menu">';
	for (i in MainMenuArray) {
		htmlStr += '	<li class="';
		if(corner_id == i){htmlStr += 'select'+i;}else{htmlStr += 'menu'+i;}
		htmlStr += '"><a href="'+MainMenuArray[i][2]+'" target="'+MainMenuArray[i][3]+'">'+MainMenuArray[i][1]+'</a></li>';
	}
	htmlStr += '</ul>';
	document.getElementById("menu").innerHTML = htmlStr;
}
//バナーの設置
function BannerMenuOrder(){
	var htmlStr = '';
	htmlStr += '<p class="visit">banner</p>';
	htmlStr += '<ul class="banner">';
	for (i in BannerArray) {
		htmlStr += '<li class="banner'+i+'">';
		htmlStr += '<a href="'+BannerArray[i][2]+'" target="'+BannerArray[i][3]+'">'+BannerArray[i][1]+'</a></li>';
	}
	htmlStr += '</ul>';
	objadd = document.createElement("div");
	objadd.setAttribute("id","menubanner");
	obj = document.getElementById("menu").appendChild(objadd)
	obj.innerHTML = htmlStr;
}
//サブメニューの設置
function SubMenuOrder(corner_id,category_id){
	if(fpToHome == "./"){return;}
	if(corner_id >= 8000){return;}
	//alert(corner_id);
	if(corner_id<=1){
		resultText = "<p class='visit'>サブメニュー</p>\n<ul>";
//		resultText += "<li class='subtitle'><b>ニュース一覧</b></li>\n";
		resultText += "<li class='subtitle'><a href='./news.html' target=_self ><b>ニュース一覧</b></a></li>\n";
		resultText += "</ul>";
		document.getElementById("submenu").innerHTML = resultText;
		return;
	}else{
		httpObj = createXMLHttpRequest(EditLoadWait);
	}//htmlData  = "corner_id="+corner_id;
	//htmlData += "&category_id="+category_id;
	if (httpObj){
//		httpObj.open("GET",fpToHome+"news/rss/news.xml",true);
		httpObj.open("GET","./rss/news.xml",true);
		httpObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
		httpObj.send(null);
	}
}
function EditLoadWait() {
	if ((httpObj.readyState == 4) && (httpObj.status == 200)){
		xmlData = httpObj.responseXML;
		itemListTags = xmlData.getElementsByTagName("item");
		titleListTags = xmlData.getElementsByTagName("title");//記事タイトル
		linkListTags = xmlData.getElementsByTagName("link");//URL
		categoryListTags = xmlData.getElementsByTagName("category");//カテゴリー名
		itemSize = itemListTags.length;//記事数
		//alert(categoryListTags.length);
		//サブメニューHTMLの生成
		resultText = "<p class='visit'>サブメニュー</p>\n<ul>";
		prev_category_name = '';//カテゴリー名
		for(i=1;i<=itemSize;i++){
			title = titleListTags[i].childNodes[0].nodeValue;
			link = linkListTags[i].childNodes[0].nodeValue;
			category_name = categoryListTags[i-1].childNodes[0].nodeValue;
			if(category_name != prev_category_name){
				//<li class='subtitle'><b>%E7%97%85%E9%99%A2%E6%A6%82%E8%A6%81</b></li>
				resultText += "<li class='subtitle'><b>"+category_name+"</b></li>\n";
				prev_category_name = category_name;
			}
			resultText += "<li>・<a href='"+link+"' target=_self >"+title+"</a></li>\n";
		}
		resultText += "</ul>";
		document.getElementById("submenu").innerHTML = resultText;
	}else{
		resultText  = '<p class="visit">EditLoadWait</p>';
		document.getElementById("submenu").innerHTML = resultText;
	}
}
//コーナートップの処理
function cornerIndex(){
	if(fpToHome == "./"){return;}
	httpObj = createXMLHttpRequest(accessContents);
	//htmlData  = "corner_id="+corner_id;
	//htmlData += "&category_id="+category_id;
	if (httpObj){
//		httpObj.open("GET",fpToHome+"news/rss/news.xml",true);
		httpObj.open("GET","./rss/news.xml",true);
		httpObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
		httpObj.send(null);
	}
}
function accessContents() {
	if ((httpObj.readyState == 4) && (httpObj.status == 200)){
		xmlData = httpObj.responseXML;
		itemListTags = xmlData.getElementsByTagName("item");
		titleListTags = xmlData.getElementsByTagName("title");//記事タイトル
		linkListTags = xmlData.getElementsByTagName("link");//URL
		
		location.href = linkListTags[1].childNodes[0].nodeValue;//最初の記事へリンク
		
	}else{
		resultText  = '<p class="visit">Wait...</p>';
		document.getElementById("main").innerHTML = resultText;
	}
}

/*
function SubMenuOrder(corner_id,category_id){
	if(fpToHome == "./"){return;}
	if(corner_id >= 8000){return;}
	httpObj = createXMLHttpRequest(EditLoadWait);
	htmlData  = "corner_id="+corner_id;
	htmlData += "&category_id="+category_id;
	if (httpObj){
		httpObj.open("POST",fpToHome+"tool_parts/submenu.php",true);
		httpObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
		httpObj.send(htmlData);
	}
}
function EditLoadWait() {
	if ((httpObj.readyState == 4) && (httpObj.status == 200)){
		checkText = decodeURIComponent(httpObj.responseText);
		document.getElementById("submenu").innerHTML = checkText;
	}else{
		checkText  = '<p class="visit">EditLoadWait</p>';
		document.getElementById("submenu").innerHTML = checkText;
	}
}
*/




/*
--------------------------------------------
1.16で、上記の2関数と差し替え
※今まで行っていたDBへのアクセスは
　フォルダIDの取得へ移動
--------------------------------------------
//サブメニューの設置
function SubMenuOrder(){
	if(fpToHome == "./"){return;}
	if(corner_id >= 8000){return;}
	document.getElementById("submenu").innerHTML = subMenuStr;
}
*/
//フッターの設置
function FooterOrder(c_year,tmp_name){
	var myData = new Date();
	myData.getFullYear();
	var htmlStr = '';
	htmlStr += 'Copyright(C)'+c_year+' '+tmp_name+' All rights reserved.';
	document.getElementById("footer").innerHTML = htmlStr;
}
//フォルダIDの取得
function FolderID(){
	if(document.getElementById("DivInfo")!=null){
		tmp = document.getElementById("DivInfo").innerHTML;
		tmp = tmp.split("category_")[1];
		corner_id = Number(tmp.split("_")[0]);
		tmp = tmp.split("_")[1];
		category_id = Number(tmp.split(".")[0]);
	}
}
/*
--------------------------------------------
1.16で、上記の1関数と差し替え
※それに伴いconf_js.jsファイルに
　phpLoad()関数を設置のこと
--------------------------------------------
//フォルダIDの取得(DBアクセス)////////////////////////
function FolderID(){
	httpObj = createXMLHttpRequest(LoadWait);
	tmp = location.href;
	tmp_end = tmp.lastIndexOf(".",tmp.length);
	tmp_sta = tmp.lastIndexOf("/",tmp.length)+1;
	knr_id = tmp.substring(tmp_sta,tmp_end);
	htmlData  = "knr_id="+knr_id;
	if (httpObj){
		httpObj.open("POST",fpToHome+"tool_parts/sub_access.php",true);
		httpObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
		httpObj.send(htmlData);
	}
}
//↑の処理待ち用
function LoadWait() {
	if ((httpObj.readyState == 4) && (httpObj.status == 200)){
		checkText = decodeURIComponent(httpObj.responseText);
		checkText = checkText.split('\t');
		corner_id = checkText[0];
		category_id = checkText[1];
		subMenuStr = checkText[2];
		phpLoad();
	}else{
		checkText  = '<p class="visit"></p>';
		document.getElementById("submenu").innerHTML = checkText;
	}
}
//////////////////////////////////////////////////////
*/
//URLの変換
function fnOpenURL(url){
	var arrayURL = url.split('?');
	arrayURL[1] = arrayURL[1].replace(/:/g, '%3A');
	arrayURL[1] = arrayURL[1].replace(/\//g, '%2F');
	document.location.href=arrayURL.join("?");
}

/*------------------------------------------------------------------------------*/
/*---------------------------------cssの切り替え--------------------------------*/
/*------------------------------------------------------------------------------*/
function replace_css(css_size,url){
	if(osName=="win"){
		switch(css_size){
			case "ex":document.body.style.fontSize = "1.3em";break;
			case "l":document.body.style.fontSize = "1.1em";break;
			case "m":document.body.style.fontSize = "0.95em";break;
			case "s":document.body.style.fontSize = "0.8em";break;
		}
	}else{
		switch(css_size){
			case "ex":document.body.style.fontSize = "1.3em";break;
			case "l":document.body.style.fontSize = "1.1em";break;
			case "m":document.body.style.fontSize = "0.9em";break;
			case "s":document.body.style.fontSize = "0.7em";break;
		}
	}
	setCookie("CssSize",css_size);
	//location.reload();
}
function getCookie(key){
	tmp=document.cookie+";";
	tmp1=tmp.indexOf(key, 0);
	if(tmp1!=-1){
		tmp=tmp.substring(tmp1,tmp.length);
		start=tmp.indexOf("=",0)+1;
		end=tmp.indexOf(";",start);
		return(unescape(tmp.substring(start,end)));
	}
	return("");
}
function setCookie(key,val) {
	setDay = new Date();
	setDay.setTime(setDay.getTime()+(30*1000*60*60*24));
	expDay = setDay.toGMTString();
	document.cookie=key+"="+escape(val)+";expires="+expDay + ";path=/;";
}

/*------------------------------------------------------------------------------*/
/*---------------------------------Viewerの表示---------------------------------*/
/*------------------------------------------------------------------------------*/
var WindowX = 0;
var WindowY = 65;
var WinStepCount = 0;
function ViewerSay() {
	//スライドショー用ウィンドウを用意しておく
	float_Viewer_obj_add = document.createElement("div");
	float_Viewer_obj_add.setAttribute("id","float_Viewer");
	float_Viewer_obj = document.getElementsByTagName("body")[0].appendChild(float_Viewer_obj_add);
	cssStylePos(float_Viewer_obj,WindowX,WindowY);
	float_Viewer_obj.style.visibility="hidden";
	float_Viewer_obj.style.display="none";
}

/*入力フォームの表示、非表示*/
function Viewer(mythis){
	obj=document.getElementById("float_Viewer");
	obj.style.opacity = WinStepCount;
	obj.style.MozOpacity = WinStepCount;
	obj.style.filter = "alpha(opacity="+WinStepCount*100+")";
	WinStepCount=WinStepCount+0.2;
	if (WinStepCount <= 1){setTimeout("Viewer()",50);}else{obj.style.filter = "alpha(enabled=false)";}
	if (WinStepCount != "0.2"){return;}
	obj.style.display="block";
	obj.style.visibility="visible";
	DivAlt = mythis.getElementsByTagName("img")[0].getAttribute("alt");
	DivSrc = mythis.getElementsByTagName("img")[0].getAttribute("src");
	ImgNo = DivSrc.slice(DivSrc.lastIndexOf("_")+1,-4);
	WindowX = (document.documentElement.clientWidth/2)-(obj.clientWidth/2);
	cssStylePos(obj,WindowX,WindowY);
	obj.innerHTML = ViewerPrint(DivSrc,DivAlt,ImgNo);
}
function ViewerOff(){
	obj=document.getElementById("float_Viewer")
	obj.style.visibility="hidden";
	obj.style.display="none";
	WinStepCount = 0;
}

function ViewerNext(NextNo){
	obj = document.getElementById("float_Viewer")
	DivAlt = document.getElementById("main").getElementsByTagName("IMG")[NextNo].getAttribute("alt");
	DivSrc = document.getElementById("main").getElementsByTagName("IMG")[NextNo].getAttribute("src");
	ImgNo = DivSrc.slice(DivSrc.lastIndexOf("_")+1,-4);
	obj.innerHTML = ViewerPrint(DivSrc,DivAlt,ImgNo);
}
function ViewerPrint(DivSrc,DivAlt,ImgNo){
	img_array = new Array();
	NowNo = new Number();
	img_leng = document.getElementById("main").getElementsByTagName("IMG").length;
	for(i = 0;i < img_leng;i++){
		obj =  document.getElementById("main").getElementsByTagName("IMG")[i];
		tmp_no = obj.getAttribute("src");
		tmp_no = Number(tmp_no.slice(tmp_no.lastIndexOf("_")+1,-4));
		tmp_tag = obj.parentNode.parentNode.parentNode.getAttribute("onclick")
		//キャプション付かチェックして変数に格納
		if(tmp_tag){
			if(tmp_no == Number(ImgNo)){NowNo=img_array.length;}
			img_array.push(i);
		}
	}
	htmlstr  = '<p class="close_b"><a onclick="ViewerOff()"></a></p>';
	htmlstr += '<img src="'+DivSrc+'" alt="'+DivAlt+'">';
	if(img_array[NowNo+1]){htmlstr += '<p class="next_b"><a onclick="ViewerNext('+img_array[NowNo+1]+')"></a></p>';}
	if(img_array[NowNo-1]){htmlstr += '<p class="back_b"><a onclick="ViewerNext('+img_array[NowNo-1]+')"></a></p>';}
	htmlstr += '<p class="coment">'+DivAlt+'</p>';
	return htmlstr;
}
/*------------------------------------------------------------------------------*/
/*------------------------------ボタンロールオーバー----------------------------*/
/*------------------------------------------------------------------------------*/
function PreloadImg() {
	gifno=1;MM_m=new Array();
	for (i in MainMenuArray) {
		MM_m[i] = new Image;
		MM_m[i].src = "../images/css_menu"+gifno+".gif";
		gifno++;
	}
	gifno=1;MM_h=new Array();
	for (i in HederMenuArray) {
		MM_h[i] = new Image;
		MM_h[i].src = "../images/css_headmenu"+gifno+".gif";
		gifno++;
	}
	gifno=1;MM_b=new Array();
	for (i in BannerArray) {
		MM_b[i] = new Image;
		MM_b[i].src = "../images/css_banner"+gifno+".gif";
		gifno++;
	}
}
/*
*/
function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	 if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function cssStylePos(float_Viewer_obj,WindowX,WindowY){
	var point;
	if(navigator.appName == 'Microsoft Internet Explorer'){
		// IE 用のコード
		float_Viewer_obj.style.posLeft = Xscrollpoint()[0] + WindowX;
		float_Viewer_obj.style.posTop = Xscrollpoint()[1] + WindowY;
	} else if(navigator.userAgent.indexOf('Safari') != -1){
		// Safari 用のコード
		float_Viewer_obj.style.posLeft = Xscrollpoint()[0] + WindowX;
		float_Viewer_obj.style.posTop = Xscrollpoint()[1] + WindowY;
	} else if(navigator.userAgent.indexOf("Opera")!=-1){
		// Opera 用のコード
		float_Viewer_obj.style.posLeft = Xscrollpoint()[0] + WindowX;
		float_Viewer_obj.style.posTop = Xscrollpoint()[1] + WindowY;
	} else if(navigator.userAgent.indexOf('Gecko') != -1){
		// Mozilla 用のコード
		float_Viewer_obj.style.left = Xscrollpoint()[0] + WindowX + "px";
		float_Viewer_obj.style.top = Xscrollpoint()[1] + WindowY + "px";
	} else {
		// その他のブラウザ
		float_Viewer_obj.style.left = Xscrollpoint()[0] + WindowX + "px";
		float_Viewer_obj.style.top = Xscrollpoint()[1] + WindowY + "px";
	}
	return;
}
//scroll時の座標
function Xscrollpoint(){
	var point;
	if(window.opera){
		// Opera 用のコード
		point = [document.body.scrollLeft,document.body.scrollTop];
	} else if(navigator.appName == 'Konqueror'){
		// Konqueror 用のコード
	} else if(navigator.appName == 'Microsoft Internet Explorer'){
		// IE 用のコード
		point = [document.documentElement.scrollLeft,document.documentElement.scrollTop];
	} else if(navigator.userAgent.indexOf('Safari') != -1){
		// Safari 用のコード
		point = [document.body.scrollLeft,document.body.scrollTop];
	} else if(navigator.userAgent.indexOf('Firebird') != -1){
		// Firebird 用のコード
	} else if(navigator.userAgent.indexOf('Netscape') != -1){
		// Netscape 6,7 用のコード
	} else if(navigator.userAgent.indexOf('Gecko') != -1){
		// Mozilla 用のコード
		point = [document.documentElement.scrollLeft,document.documentElement.scrollTop];
	} else if(navigator.appName == 'Netscape'){
		// Netscape Navigator, Communicator 用のコード
	} else {
		// その他のブラウザ
	}
	return point;
}

/*------------------------------------------------------------------------------*/
/*-------------------------------------AJAX-------------------------------------*/
/*------------------------------------------------------------------------------*/
/*phpとのやり取り*/
function createXMLHttpRequest(cbFunc){
	var XMLhttpObject = null;
	try{
		XMLhttpObject = new XMLHttpRequest();
	}catch(e){
		try{
			XMLhttpObject = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				XMLhttpObject = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
				return null;
			}
		}
	}
	if (XMLhttpObject) XMLhttpObject.onreadystatechange = cbFunc;
	return XMLhttpObject;
}

