//-----------------------------------------------------------------------//
// JavaScript Document
//-----------------------------------------------------------------------//

//-----------------------------------------------------------------------//
function check_ext( no_wnd )
{
	if( 5 != no_wnd.length ){
		alert( 'failure : page no' );
		no_wnd = '10000'
	}
	no = eval( no_wnd );

	return no;
}
//-----------------------------------------------------------------------//
function Call_index_html( path )
{
	parent.location.href = path + 'index.html?';
}
//-----------------------------------------------------------------------//
function ChangeWindow( url )
{
	location.replace( url );
}
//-----------------------------------------------------------------------//
function from_Index( path )
{
	if( parent.top_wnd ){
		// 何もしない
	}
	else{
		parent.location.href = path + 'index.html';
	}
}
//-----------------------------------------------------------------------//
//function OpenWindow(theURL,winName,features) 
//{ //v2.0
// 	window.open( theURL, winName, "width=10,height=10" );
//}
//-----------------------------------------------------------------------//

//-----------------------------------------------------------------------//
// クッキーの削除 //
//-----------------------------------------------------------------------//
function del_cookie( key )
{
	var strCount;
	//有効期限を前日日付にします。
	var dtExpire = new Date();
	dtExpire.setTime(dtExpire.getTime() - 1);
	//クッキーを取得し、更新します。
	strCount = GetCookie(key);
	document.cookie = key + "=" + strCount + "; expires=" + dtExpire.toGMTString();
}
//-----------------------------------------------------------------------//
// クッキーのセット / 取得 //
//-----------------------------------------------------------------------//
function SetCookie_No(key, val){

	//alert("cookie set");
	//alert(key + "=" + escape(val));

	// 有効期限を有効にする場合
	setDay = new Date();
	setDay.setTime(setDay.getTime()+(5*1000*60*60*24));	// 5日	1[ms]単位
	//setDay.setTime(setDay.getTime()+(1000*600));				// 10分 ( 60秒×10×1000[ms] )
	expDay = setDay.toGMTString();
	document.cookie = key + "=" + escape(val) + ";expires=" + expDay;

	//document.cookie = key + "=" + escape(val);
}
//-----------------------------------------------------------------------//
function GetCookie_No(key){

	var tmp = document.cookie;

	if(tmp != ""){
		var index2 = tmp.indexOf("=",0) + 1;
		var index3 = tmp.indexOf(";",index2);
		if( index3 < 0 ){
			index3 = index2 + 1;
		}
		if( (index2 < 20) && ((index3 - index2) < 7) ){	// 文字列長確認
			return( tmp.substring(index2,index3) );
		}
	}
	return(0);
}
//-----------------------------------------------------------------------//
// クッキーの取得 //
//-----------------------------------------------------------------------//
function GetCookie(key){

	var tmp = document.cookie + ";";
	var index1 = tmp.indexOf(key, 0);
	if(index1 != -1){
		tmp = tmp.substring(index1,tmp.length);
		var index2 = tmp.indexOf("=",0) + 1;
		var index3 = tmp.indexOf(";",index2);
		if( index3 < 0 ){
			index3 = index2 + 1;
		}
		if( (index2 < 20) && ((index3 - index2) < 7) ){	// 文字列長確認
			return(unescape(tmp.substring(index2,index3)));
		}
	}
	return("");
}
//-----------------------------------------------------------------------//
function cookie_enabled()
{
	if (navigator.cookieEnabled == undefined){
		return false;
	}
	else if (navigator.cookieEnabled == true){
		return true;
	}
	else if (navigator.cookieEnabled == false){
		return false;
	}
	return false;
}
//-----------------------------------------------------------------------//
function drop_down_menu( no, path )
{
	var cook = false;
	var sum_no;
	
	// Cookieのセットは top_menu_migration を参照 //
	prev_no = GetCookie('page_no');

	//--------------------------//
	// クッキーが使用可能か判定 //
	//--------------------------//
	cook = cookie_enabled();

	//*************************************//
	// 複数表示は中止、On/Offは有効 -> rev //
	//*************************************//

	// クッキー使用 不可 //
	if( cook == false ){
		//if( prev_no == no ){
		//	return;
		//}
		sum_no = no;
	}
	// クッキー使用 可 //
	else{
		if( prev_no & no ){	// セットされていればリセットする
			//sum_no = prev_no & ~no;				// 複数表示 可
			// sum_no = 0;				// rev		// 複数表示 不可	// 2008-07-18
			sum_no = no;												// 2008-07-18 追加
		}
		else{
			//sum_no = prev_no | no;				// 複数表示 可
			sum_no = no;				// rev		// 複数表示 不可
		}
	}
	// ----------------------------------------------------------------------------------------
	// クッキー保存 
	// ここでの保存は中止
	// ここで保存すると honma@127.0.0.1[1].txt, honma@127.0.0.1[2].txt, honma@127.0.0.1[3].txt などと
	// 複数のファイルが作成されてしまいうまく機能しなくなってしまうので中止
	// ( メニューが開く分には機能するが、閉じる方は２回目のクリックで閉じる )
	//
	// SetCookie_No( 'page_no', sum_no );  // cgi側へ移動 -> save_cookie( $menu_no );
	// ----------------------------------------------------------------------------------------
	
	//*************************************//
	// path = path.substring( 0, path.length - 3 );	// 先頭から ( 文字列長 − 3 ) 文字分取り出す
	migration_image_menu( no, sum_no, path + 'right_window/migration/' )
}
//-----------------------------------------------------------------------//
function link_behavior( id, color )
{
	var cnt = document.getElementById( id );
	cnt.style.color = color;
	//cnt.style.textdecoration = "underline";
	//document.getElementById('Cool1').style.textdecoration = "underline";
	//document.getElementById('Cool1').style.color = "#0066FF";
}
//-----------------------------------------------------------------------//
function whats_new_drop_down( no )
{
	var cook = false;
	var sum_no;
	prev_no = GetCookie_No('whats_new_page_no');
	//--------------------------//
	// クッキーが使用可能か判定 //
	//--------------------------//
	cook = cookie_enabled();

	//*************************************//
	// 複数表示は中止、On/Offは有効 -> rev //
	//*************************************//

	// クッキー使用 不可 //
	if( cook == false ){
		//if( prev_no == no ){
		//	return;
		//}
		sum_no = no;
	}
	// クッキー使用 可 //
	else{
		if( prev_no & no ){	// セットされていればリセットする
			sum_no = prev_no & ~no;				// 複数表示 可
			//sum_no = ~no;				// rev		// 複数表示 不可
		}
		else{
			sum_no = prev_no | no;				// 複数表示 可
			//sum_no = no;				// rev		// 複数表示 不可
		}
	}
	//*************************************//

	// parent.right_window.location.href = './whats_new.cgi?page=' + sum_no;
	parent.location.href = './whats_new.cgi?page=' + sum_no;
}
//-----------------------------------------------------------------------//
function migration_text_menu( page, path )
{
	//******************************//
	// 左側メニューウィンドウの更新 //
	//******************************//
	if( page > 512 ){
		alert( 'warning : Script' );
	}
	else{
		//parent.left_window.location.replace( path + 'third_migration_menu_window.cgi?page=' + page );
		parent.left_window.location.href = path + 'third_migration_menu_window.cgi?page=' + page;
	}
}
//-----------------------------------------------------------------------//
function migration_image_menu( push_no, no, path )
{
	//**********************//
	// 右側ウィンドウの更新 //
	//**********************//
	// スラブ電気泳動装置 //
	if( push_no == 1 ){
		parent.location.href = path + "migration/top_migration.cgi?page=" + no;
	}
	// サブマリンアガロース電気泳動 //
	else if( push_no == 2 ){
		parent.location.href = path + "sub_marin/sub_marin_series.cgi?page=" + no;
	}
	// クールホレスター電気泳動 //
	else if( push_no == 4 ){
		// alert( path + "cool_phore_star/top_cool_phore_star.cgi?page=" + no );
		parent.location.href = path + "cool_phore_star/top_cool_phore_star.cgi?page=" + no;
	}
	// ブロティング装置 //
	else if( push_no == 8 ){
		parent.location.href = path + "blot/top_blot.cgi?page=" + no;
	}
	// ゲルピッカー //
	else if( push_no == 16 ){
		parent.location.href = path + "gel_pickker/fluoro_phore_star_3000.cgi?page=" + no;
	}
	// 画像解析ソフト //
	else if( push_no == 32 ){
		parent.location.href = path + "soft/top_soft.cgi?page=" + no;
	}
	// レディメイドゲル //
	else if( push_no == 64 ){
		parent.location.href = path + "gel/top_gel.cgi?page=" + no;
	}
	// コンスタントパワーサプライ //
	else if( push_no == 128 ){
		parent.location.href = path + "power/top_power.cgi?page=" + no;
	}
	// アクセサリ //
	else if( push_no == 256 ){
		parent.location.href = path + "accessory/top_accessory.cgi?page=" + no;
	}
}
//-----------------------------------------------------------------------//
