﻿
/*	-----------------------------------
	コンテンツページ初期処理メインロジック
	-----------------------------------*/
function firstProcess(){
	
	//統計用
	if( checkFrame() == false ){
		var toukei_tag = "<img src='/cgi-bin/toukei.pl?infoRef=" + document.referrer + "' width='1' height='1'>";
		document.body.innerHTML = toukei_tag;
	}
	
	//単独ページへのアクセスはURLリプレイス
	if( checkFrame() == false ){
		
		location.replace( getReplaceURI() );
		return true;
	}
	
	//インラインフレームの高さをセット
	setCArea();
	
	//インラインフレーム内を見える化
	document.body.style.visibility = "visible";
	
	//現在ページのブックマーク用URIを表示
	setURI();
	
	//ページ遷移後の初期処理（位置あわせなど）
	pageDef();
	
	return true;
}

/*	-----------------------------------
	インラインフレームの高さをセット
	-----------------------------------*/
function setCArea(){
	
	//親ページから見たインラインフレームオブジェクト
	var obj	= parent.document.getElementById("CFrame");
	
	//コンテンツエリア（インラインフレーム）に設定予定の幅と高さを決める
	var w = "700px";
	var h = document.getElementById("stage").clientHeight;
	if( checkBrowser() == 'Netscape' ){ h = document.body.clientHeight; }
	h += "px";
	
	//コンテンツエリア（インラインフレーム）にサイズをセット
	obj.style.width = w;
	obj.style.height = h;
}

/*	-----------------------------------
	ブラウザチェック
	-----------------------------------*/
function checkBrowser(){
	var str = navigator.userAgent;
	
	if( str.indexOf('MSIE') >= 0 ){
		if( str.indexOf('MSIE 8.0') >= 0 ){
			return 'MSIE8';
		}else{
			return 'MSIE';
		}
	}else if( str.indexOf('Firefox') >= 0 ){
		return 'Firefox';
	}else if( str.indexOf('Opera') >= 0 ){
		return 'Opera';
	}else if( str.indexOf('Netscape') >= 0 ){
		return 'Netscape';
	}else if( str.indexOf('Chrome') >= 0 ){
		return 'Chrome';
	}else if( str.indexOf('Safari') >= 0 ){
		return 'Safari';
	}else{
		return 'OTHER';
	}
}

/*	-----------------------------------
	親フレーム有無のチェック
	-----------------------------------*/
function checkFrame(){
	if( !parent.document.getElementById("CFrame") ){
		return false;
	}else{
		return true;
	}
}

/*	-----------------------------------
	現在のファイル名（ページ内リンクを含む）を返す
	-----------------------------------*/
function getFileName(){
	var myDomain = document.domain;
	var myRootURI = "http://" + myDomain + "/";
	
	var thisFilePass = document.URL;
	var thisFileName = thisFilePass.replace( myRootURI , "" );
	
	return thisFileName;
}

/*	-----------------------------------
	ブックマークURLを返す
	-----------------------------------*/
function getReplaceURI(){
	var myDomain = document.domain;
	var myRootURI = "http://" + myDomain + "/";
	var myJumpCGI = myRootURI + "cgi-bin/jump.cgi";
	
	var thisFilePass = document.URL;
	var thisFileName = thisFilePass.replace( myRootURI , "" );
	var id = thisFileName.replace( ".html" , "" );
	
	var replaceURI = "";
	if( (thisFileName.indexOf("cgi-bin") >= 0) || (thisFileName == "top.html") ){
		replaceURI = myRootURI;
	}else{
		replaceURI = myJumpCGI + "?id=" + id;
	}
	
	return replaceURI;
}

/*	-----------------------------------
	ブックマークURIをセットする
	-----------------------------------*/
function setURI(){
	var setsumei = "BookMark URL ： ";
	parent.document.getElementById("urlText").innerHTML = setsumei + getReplaceURI();
}

/*	-----------------------------------
	遷移後のデフォルト設定
	-----------------------------------*/
function pageDef(){
	
	// ページ内リンクがなければ遷移後の表示位置をトップへ
	if( getFileName().indexOf('#') < 0 ){
		parent.window.scroll(0,0);
	}
	
	// 左サイドバナーをビジブルに
	visibleLeftBun();
}

/*	-----------------------------------
	左サイドバナー透過メソッド
	-----------------------------------*/
function opLeftBun() {
	parent.document.getElementById("linkarea").style.opacity = "0.1";
	parent.document.getElementById("linkarea").style.filter = "progid:DXImageTransform.Microsoft.Alpha(Enabled=1,Style=0,Opacity=10)";
}

/*	-----------------------------------
	左サイドバナービジブルメソッド
	-----------------------------------*/
function visibleLeftBun() {
	parent.document.getElementById("linkarea").style.opacity = "1.0";
	parent.document.getElementById("linkarea").style.filter = "progid:DXImageTransform.Microsoft.Alpha(Enabled=1,Style=0,Opacity=100)";
}




