/*********************************************
 *             [[ VEIN System ]]             *
 *                                           *
 *     authentication.js                     *
 *     2001.01.01                            *
 *     update 2001.04.25 For External File   *
 *     Programed by YIL Akira Yamanouchi     *
 *     Copyright (c) 2001 Akira Yamanouchi   *
 *********************************************/

var veintop = "http://vein.ne.jp/index.shtml";
var localindicator = "file:";
var globalindicator = "vein";
//var globalindicator = "vein.ne.jp";
//var globalindicator = "http://vein.ne.jp"; /* http://www.vein.ne.jp対策のため、vein.ne.jpに変更040908山 */
var is_local = false;
var limit_count = 0;
var guest_limit_mess = "../../../../sys/guestlimit.htm";
var timelimit = 30;
var fileid;

function initialize() {
	setlocalattri();
}

function setlocalattri() {
	s = document.URL;
	if(  0 <= s.indexOf(localindicator) ) {
		is_local = true;
	} else {
		is_local = false;
	}
}

function is_member_throughgate() {
	if( is_local ) {
		return true;
	}

	if( !top.vein_attri || top.vein_attri == 0 || top.vein_attri == "" ) {
//		alert("トップの情報が取得できません。（Top Attribute Error 01）");
		return false;
	}
	if( top.vein_attri & top.v_guest ) {
		return true;
	}

	s = top.document.referrer;
	if( s == "" ) {
//		alert("経路の探索ができません。（Referrer Error 02）");
		return false;
	}

	if(  0 <= s.indexOf(globalindicator) ) {
		if( (top.vein_id != "") && ((top.vein_attri & top.v_member) || (top.vein_attri & top.v_admin) ) ) {
			return true;
		} else {
//			alert("トップの情報が取得できません。（Top Attribute Error 03）"+top.vein_id+","+top.vein_attri);
			return false;
		}
	} else {
//		alert("経路の探索ができません。（Referrer Error 04）"+s);
		return false;
	}
}

function deport() {
	to_top = confirm("トップ画面でログインしてから閲覧してください。\nVEINトップに行く場合はOK、戻る場合はキャンセルを押してください（戻り先がない場合はトップに行きます）。\nPlease login from top page.\nPress OK to jump to top, cancel to go back.");
	if( to_top == true ) {
		top.location.href = veintop;
	} else {
		if( document.referrer == "" ) {
			top.location.href = veintop;
		} else {
			history.back();
		}
	}
}

function display_limit() {
	if(top.vein_lang == "english") {
		return true;
	}
	if( fileid.indexOf("IDS",0) == 0 ) {
		return true;
	}
	if( (top.vein_attri & top.v_guest) || (top.vein_attri & top.v_void) ) {
		setTimeout("display_limit()",1000);
		limit_count++;
		if(limit_count > timelimit) {
			document.location.href = guest_limit_mess;
		}
	}
	return true;
}
	
