var BunkatsuFlg = 1;         // 分割表示フラグ
var hyozureFlg  = 0;         // 表ズレ表示フラグ
var downloadFlg = 0;         // ダウンロード画面切り替えフラグ
var targetNo = 0;            // Documentターゲット番号
var windowNo = 0;            // 別窓表示のWindow名
var targetName;              // Form ターゲットオブジェクト名
var dwnlistTemplate = 'DocumentVoiceList';
var connect;                 // URLの入力値の接続文字 "?" か "&"
voiceCounter=0;
maxCount=0;
voiceArray = new Array();

// #############################################################
//
// SetGamen()
//
// Radio ボタンのセット
//
function SetGamen(n){
	voicelist.document.forms[0].Gamen[n-1].checked = true;
	TargetSet(n)
}


// #############################################################
//
// setConnect()
//
// URL の入力変数の結合文字
//
function setConnect(n){
	if( n == 0 ){
		connect = '?';
	}else if(n == 1){
		connect = '&';
	}else{
		connect = '';
	}
}


// #############################################################
//
// TargetSet()
//
// Documentのターゲットオブジェクトのセット
//   document0：１画面表示の Document ターゲット名
//   document1：２画面表示上部の Document ターゲット名
//   document2：２画面表示下部の Document ターゲット名
//
function TargetSet(n){
	if(BunkatsuFlg == 1){
		targetName = Page.document;
		targetNo = 0;
	}else if(BunkatsuFlg == 2){
		if(n == 1){
			targetName = Page.Page1.document;
			targetNo = 1;
		}else if(n == 2){
			targetName = Page.Page2.document;
			targetNo = 2;
		}
	}
}


// #############################################################
//
// downloadList()
//
// 発言内容表示
//
function downloadList(url){
		if(dwnlistTemplate != 'DocOneVoicelistDownload'){
			dwnlistTemplate = 'DocOneVoicelistDownload';
    }else{
			dwnlistTemplate = 'DocOneVoicelist';
    }
    Voicelist.document.location.href = url + '?Template=' + dwnlistTemplate;
}


// #############################################################
//
// Hyozure()
//
// 表ズレ表示
// Flg: 0=折り返す
//      1=折り返し無し
//
function Hyozure(url, n){
	setConnect(n);
		TargetSet(targetNo);
		if(hyozureFlg == 0){
		targetName.location.href = url + connect + 'Template=DocPage2';
		hyozureFlg = 1;
		}else if(hyozureFlg == 1){
		targetName.location.href = url + connect + 'Template=DocPage';
		hyozureFlg = 0;
		}
}


// #############################################################
// Bunkatsu()
//
// 分割表示
// Flg: 1=１画面表示
//      2=２画面表示
//
function Bunkatsu(url, n){
	setConnect(n);
	if(BunkatsuFlg == 1){
	// ２画面表示にする
		Page.document.location.href= url + connect + 'Template=BunkatsuFrame';
		Voicelist.document.forms[0].Gamen[1].checked = true;
		BunkatsuFlg = 2;
		targetNo=2;
    }else if(BunkatsuFlg == 2){
	// １画面表示にする
		Page.document.location.href = url;
		BunkatsuFlg = 1;
		targetNo=0;
    }
	hyozureFlg  = 0;
}


// #############################################################
//
// showDocumentVoice()
//
// 発言内容表示
//
function showDocumentVoice(url, n){
	setConnect(n);
    TargetSet(targetNo);
    
    if(hyozureFlg == 1){
		orikaeshi = connect + 'Template=DocPage2';
    }else{
		orikaeshi = connect + 'Template=DocPage';
    }
    targetName.location.href = url + orikaeshi;
}


// #############################################################
//
// OtherWindow()
//
// 別窓表示
//
function OtherWindow(url){
	windowNo++;
	OpenWindow = window.open("",windowNo,"toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,close=yes,width=600,height=600");
	OpenWindow.location = url;
}


// #############################################################
//
// moveSelectDocument()
//
// 発言内容移動
//
function moveSelectDocument(VoiceNo,type){
	if(type == 'All'){
		voiceCounter = VoiceNo;
	}else if(type == 'Sel'){
		for(i=0;i < maxCount; i++){
			if( voiceArray[i] == VoiceNo ){
				voiceCounter = i+1;
			}
		}
	}
	Page.document.location.hash = "LinkNo" + VoiceNo;
}


// #############################################################
//
// moveDocumentVoice()
//
// 前発言/次発言の移動処理
//
function moveDocumentVoice(max, addcount){
	voiceCounter += addcount;
	if(0 >= voiceCounter){
		voiceCounter = 1;
	}else if(max <= voiceCounter){
		voiceCounter = max;
	}
	Page.document.location.hash = "LinkNo" + voiceCounter;
}


// #############################################################
//
// moveSelDocumentVoice()
//
// 前発言/次発言の移動処理
//
function moveSelDocumentVoice(max, addcount){
	voiceCounter += addcount;
	if(0 >= voiceCounter){
		voiceCounter = 1;
	}else if(max < voiceCounter){
		voiceCounter = max;
	}
	if(max != 0){
		Page.document.location.hash = "LinkNo" + voiceArray[voiceCounter - 1];
	}
}

