document.write('<div id="login_menu"></div>');

//
// xml
//
var sys = new Object() ;

/* xml接続補助スクリプト */
sys.xmlHandler = function( referer)
{
	if ( window.XMLHttpRequest) {
		this.method = new XMLHttpRequest() ;
	} else if ( window.ActiveXObject) {
		try {
			this.method = new ActiveXObject( "Msxml2.XMLHTTP") ;
		} catch(e) {
			this.method = new ActiveXObject( "Microsoft.XMLHTTP") ;
		}
	} else {
		return false ;
	}

	this.name			= "xmlhttphandler" ;
	this.get_xml		= null ;
	this.data			= null ;
	this.loaded		= false ;
	this.referer		= ( typeof( referer) == "function") ? referer : null ;

	this.read		= function( value, method, url, sync)
	{
		var httpobj = this ;
		httpobj.method.open( method, url, sync) ;
		httpobj.method.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		httpobj.method.send( value) ;

		var timer = setInterval( function()
		{
			if ( httpobj.method.readyState == 4)
			{
				clearInterval( timer) ;
				if ( ( httpobj.get_xml == true || httpobj.get_xml == null) && httpobj.method.responseXML) {
					httpobj.data = httpobj.method.responseXML ;
				} else
				if( ( httpobj.get_xml == false || httpobj.get_xml == null) && httpobj.method.responseText) {
					httpobj.data = httpobj.method.responseText ;
				} else {
					httpobj.data = null ;
				}
				httpobj.loaded = true ;
				if ( httpobj.referer) referer( httpobj) ;
			}
		}, 50) ;

	}

	return true ;

}

var XMLParse = function()
{
	// NodeType
	// 1 : 単一ノード型
	// 2 : 属性を含むノード
	// 4 : 値を含むノード
	// 8 : 開放型ノード
	// 16 : 終了ノード型
	var node_count = 0 ;
	var xml_list = new Array() ;
	var xml_map = new Object() ;
	var tmp_list = new Object() ;
	var tmp_map = new Object() ;

	/* XMLの読込 */
	this.read = function( value, method, url, sync, referer)
	{
		var decode = this.decode ;
		var referer = ( typeof( referer) == "function") ? referer : null ;
		// XML認証の開始
		var xml = new sys.xmlHandler() ;
		xml.get_xml = false ;
		xml.read( value, method, url, false) ;

		var timer = setInterval( function() {
			if ( xml.loaded) {
				clearInterval( timer) ;
				var xmlnd = decode( xml.method.responseText) ;
				if ( referer) referer( xmlnd) ;
				return true ;
			}
		}, 50) ;

	}

	/* XMLの展開 */
	this.decode = function( text)
	{
		if ( typeof( text) != "string" || text.length == 0) return false ;
		text = text.replace( /<\?[^\>]+?>/igm, "") ;
		text = text.substr( text.indexOf( "<")) ;

		var lv = 0 ; var lv_nm = new Array() ; var nd = null ;
		xml_list = new Array() ;

		// バックスペースの削除(保険)
		text = text.replace( /[\b]/g, " ") ;
		// CDATA項目の事前取得
		var cdata = text.match( /<!\[CDATA\[[^\b]*?\]\]>/ig) ;
		if ( cdata) for ( var i = 0 ; i < cdata.length ; i ++) { text = text.replace( cdata[i], " <$CDATA$"+i+"$>") ; }
		// ノードの分割処理
		var nodes = new Array() ;
		var j = text.match( /<(\/?[a-z]{1}[^>]*)>/igm) ;
		for ( var i = 0 ; i < j.length ; i ++) {
			var x = text.substr( 0, text.indexOf( j[i])) ;
			nodes.push( ( x ? x : ""), j[i]) ;
			text = text.substr( text.indexOf(j[i]) + j[i].length) ;
		}
		// ノードの頭だし
		while( nodes[0].substr(0,1)!="<") { nodes.shift() ; }
		nodes.push( "") ;
											  
		// XMLノードを順次取得
		while( nd = nodes.shift())
		{
			// ノード補正
			if ( nd.substr(0,1) != "<") nodes.unshift( " ") ;
			nd = nd.replace( /[\s]/mg, " ") ;
			// 直後のテキストノードを取得
			var txnd = null ;
			if ( nodes.length > 0) {
				var i = nodes.shift() ;
				if ( txnd = i.match( /<\$CDATA\$([\d]+)\$>/i)) {
					txnd = cdata[txnd[1]].replace( /<!\[CDATA\[([^\b]+?)\]\]>/im, "$1") ;
				} else {
					txnd = i ;
				}
			}
			// ノードを更に分割
			nd = nd.match( /^<(\/)?([^\s\/]+)(.*?)(\/)?>$/i) ;
			// ノード名を取得
			var nn = nd[2].toLowerCase() ;

			// ノード型を判定
			var nd_type = 0 ;
			if ( nd[1]) { nd_type |= 16 ; } else {
				nd_type |= ( nd[4]) ? 1 : 8 ;
			}

			// 属性文字列を取得
			var atr = null ;
			nd_type |= ( (nd_type&16) == 0 && nd[3] && ( atr = nd[3].match( /[\s]*[^\=]+?\=\"?[^\"]*\"?/igm))) ? 2 : 0 ;

			// 値型の特定
			if ( ! (nd_type&17) && txnd) nd_type |= 4 ;

			//## 値の適用
			var elm = { type : nd_type, name : nn, value : null, attribute : {}} ;
			//属性適用
			if ( nd_type&2 && atr.length > 0) {
				elm.attribute = new Object() ;
				for ( var i = 0 ; i < atr.length ; i ++) {
					var j = atr[i].match( /^[\s]+([^=]+)=\"?([^\"]+)\"?/m) ; if ( ! j) continue ;
					elm.attribute[j[1].toLowerCase()] = j[2] ;
				}
			}
			// 値適用
			if ( (nd_type&4) && typeof( txnd) == "string" && txnd.length > 0) {
				if ( txnd.match( /<!\[cdata\[([^\]]*)\]\]>/im)) {
					elm.value = RegExp.$1 ;
				} else {
					txnd = txnd.replace( /&lt;/ig, "<") ;
					txnd = txnd.replace( /&gt;/ig, ">") ;
					txnd = txnd.replace( /&quot;/ig, "\"") ;
					txnd = txnd.replace( /&amp;/ig, "&") ;
					elm.value = txnd ;
				}
			}

			//## 各モード別の処理
			elm.level = lv_nm.length ;
			// オープン型
			if ( (nd_type&8) == 8) {
				lv_nm.push( elm) ;
			} else
			// クローズ型
			if ( (nd_type&16)) {
				var x = lv_nm.pop() ;
				if ( elm.name != x.name) { alert( "終了型の一致しない要素があります") ; return false ; }
				elm.level -= 1 ;
			}

			//## タイプ補正処理
			var i = node_count - 1 ;
			if ( xml_list[i]) {
				// VALUEを含める事が出来ない要素への処理
				if ( (elm.type&9) > 0 && (xml_list[i].type&13) == 12) {
					xml_list[i].value = null ;
					xml_list[i].type &= ~4 ;
				} else
				// VALUEを持つ事が可能な要素への処理
				if ( (elm.type&16) && (xml_list[i].type&5) == 4 && xml_list[i].name == elm.name) {
					xml_list[i].type &= 6 ;
				}
			}

			elm.discode = node_count ++ ;
			xml_list[elm.discode] = (elm.type&16) > 0 ? false : xml_list[elm.discode] = elm ;

		}

		// マップ作成
		createMap( 0, xml_map) ;
		// 親子関係の評価
		setRelation() ;
		xmllist = xml_list ;
		xmlmap = xml_map ;

		return xml_list[0] ;

	}

	/* XMLへの変換 */
	this.encode = function( discode)
	{
		var xml = new Array() ;
		if ( ! nd) {
			var nd = xml_list[0] ;
			xml.push( "<?xml version=\"1.0\" encoding=\""+(document.charset?document.charset:document.characterSet)+"\"?>") ;
		}

		this.func = function( map)
		{
			var xml = new Array() ;
			// 指定階層配列の作成
			var tmap = new Array() ; var elm = [ null, null] ;
			for ( var i in map) { tmap.push( { discode : Number(i), is_open : ( typeof( map[i]) == "object" ? true : false)}) ; }
			// XMLの取得
			for ( var i = 0 ; i < tmap.length ; i ++) {
				var list = xml_list[tmap[i].discode] ;
				if ( ! list) continue ;
				var tab = "" ; for ( x = 0 ; x < list.level - def_lv ; x ++) { tab += "\t" ; }
				var str = "<" + list.name ;
				if ( list.type&2) {
					for ( var x in list.attribute) { str += " " + x + "=\""+ String( list.attribute[x]) +"\"" ; }
				}
				str += ( list.type&1) ? " />" : ">" ;
				if ( list.type&4) {
					if ( list.value.match( /[<>]+/)) {
						str += "<![CDATA[" + list.value + "]]>" ;
					} else {
						str += list.value ;
					}
						str += "</" + list.name + ">" ;
				}
				xml.push( tab + str) ;
				if ( (list.type&12) == 8) { xml.push( this.func( map[list.discode])) ; xml.push( tab + "</" + list.name + ">") ; }
			}
			return xml.join( "\n") ;
		}

		// 抽出対象XMLを取得する
		if ( discode) { var get = searchMap( discode, xml_map) ; }
		map = ( get) ? get.map : xml_map ;
		var def_lv = ( get) ? get.list.level : 0 ;

		xml.push( this.func( map)) ;
		return xml.join( "\n") ;

	}

	/* 全てのノードをフォーマットし、最初のノードを作成する */
	this.format = function( name)
	{
		if ( ! name.match( /^([a-z0-9_]+)$/i)) return false ;
		node_count = 1 ;
		xml_list = [ { type : 1, name : name, level : 0, attribute : {}, value : null, discode : 0}] ;
		xml_map = { 0 : true} ;
		setRelation() ;
		return xml_list[0] ;
	}

	/* 最初のノード取得 */
	this.getNode = function() { return xml_list[0] ; }

	/* マップから特定のコードを持つ配列を取得 */
	var searchMap = function( discode, map)
	{
		if ( ! map) var map = xml_map ;
		var rval = false ;
		for( var i in map) {
			if ( i == discode) {
				rval = new Object() ;
				rval.list = xml_list[discode] ;
				rval.map = new Object() ;
				rval.map[discode] = map[i] ;
				break ;
			}
			if ( typeof( map[i]) == "object") { rval = searchMap( discode, map[i]) ; if ( rval != false) break ; }
		}

		return rval ;

	}

	// 初期XMLマップ作成
	var createMap = function( num, map) {
		var list = xml_list ;
		if ( typeof( map) != "object") map = new Object() ;
		var def = list[num] ; if ( ! def) return map ; 
		for ( var i = num ; i < list.length ; i ++) {
			if ( list[i] == false) continue ;
			if ( def.level > list[i].level) break ;
			if ( def.level != list[i].level) continue ;
			map[i] = true ;
			if ( (list[i].type&8)) map[i] = createMap( i+1, map[i]) ;
		}
		return map ;
	}

	/* 関連性評価 */
	var setRelation = function( id)
	{
		this.func = function( list, map, prev)
		{
			// 指定階層配列の作成
			var tmap = new Array() ; var elm = [ null, null] ;
			for ( var i in map) { tmap.push( { discode : Number(i), is_open : ( typeof( map[i]) == "object" ? true : false)}) ; }
			// 階層別の処理を取得する
			for ( var i = 0 ; i < tmap.length ; i ++)
			{
				var rel = [ null, null] ;
				// 親ノードの指定
				list[tmap[i].discode].parentNode = ( prev == null || isNaN(prev)) ? null : list[prev] ;
				// 最初のノードと最後のノード取得
				if ( i == 0) { elm[0] = tmap[i].discode ; }
				if ( i == tmap.length - 1) { elm[1] = tmap[i].discode ; }
				// 直前後のノードを取得
				list[tmap[i].discode].previousSibling = ( i > 0) ? list[tmap[i-1].discode] : null ;
				list[tmap[i].discode].nextSibling = ( i < tmap.length - 1) ? list[tmap[i+1].discode] : null ;
				// 子階層への処理受け渡し
				if ( tmap[i].is_open) { rel = this.func( list, map[tmap[i].discode], tmap[i].discode) ; }
				// 子階層関連付け
				list[tmap[i].discode].firstChild = ( rel[0]) ? list[rel[0]] : null ;
				list[tmap[i].discode].lastChild = ( rel[1]) ? list[rel[1]] : null ;
				// 子階層リストの作成
				list[tmap[i].discode].childNodes = new Object() ; var x = 0 ;
				if ( typeof(map[tmap[i].discode]) == "object") {
					for ( var j in map[tmap[i].discode]) {
						list[tmap[i].discode].childNodes[x] = list[j] ; x ++ ;
					}
				}
				list[tmap[i].discode].childNodes.length = x ;
				// 子階層へのショートカット作成
				var nd = list[tmap[i].discode] ; var nds = new Object() ;
				for ( var nn in nd) { if ( nn.match( /^_.+/)) delete( nd[nn]) ; }
				if ( nd.childNodes.length > 0) {
					for ( var j = 0 ; j < nd.childNodes.length ; j ++) {
						var ndk = "_" + nd.childNodes[j].name ;
						if ( typeof( nds[ndk]) != "object") nds[ndk] = 0 ;
						if ( typeof( nd[ndk]) != "object") nd[ndk] = new Object() ;
						nd[ndk][nds[ndk]] = nd.childNodes[i] ;
						nds[ndk] ++ ;
					}
					for ( var j in nds) { nd[j].length = nds[j] ; }
				}

				list[tmap[i].discode].volume = "XMLParse Object" ;
				setFunction( tmap[i].discode, map, list) ;
			}
			return elm ;
		} ;

		if ( ! id) {
			var list = xml_list ;
			var map = xml_map ;
		} else {
			var list = tmp_list[id] ;
			var map = tmp_map[id] ;
		}
		return this.func( xml_list, xml_map, null) ;

	}

	/* 関数付与 */
	var setFunction = function( discode, map, list)
	{
		var elm = list[discode] ; if ( ! elm) return false ;
		// 名前の取得
		elm.getName = function( name) {
			if ( name) {
				return ( elm.name.toLowerCase() == String(name).toLowerCase()) ? true : false ;
			} else {
				return elm.name ;
			}
		}
		// 名前の変更
		elm.setName = function( name) {
			if ( ! name.match( /^[a-z0-9_]+$/i)) return false ;
			elm.name = name ; return true ;
		}
		// 値の取得
		elm.getValue = function() { return ( elm.type&4) ? elm.value : false ; }
		// 値の適用
		elm.setValue = function( txt) {
			if ( elm.type&8) return false ;
			if ( ! txt) {
				elm.value = null ;
				elm.type = (elm.type&~4)|1 ;
			} else {
				elm.value = txt ;
				elm.type = (elm.type&~1)|4 ;
			}
		}
		// 属性値取得
		elm.getAttribute = function( name) {
			if ( ! typeof( name).match( /^(string|number)$/i)) return false ;
			name = String(name).toLowerCase() ;
			return ( this.attribute[name]) ? this.attribute[name] : false ;
		}
		// 属性値設定
		elm.setAttribute = function( name, value) {
			if ( ! typeof(name).match( /^(string|number)$/i)) return false ;
			if ( ! String(typeof(value)).match( /^(string|number|boolean)$/i)) return false ;
			name = name.toLowerCase() ;
			if ( this.attribute[name]) {
				this.attribute[name] = value ;
			} else {
				if ( String(name).match( /[<>\"= ]+/)) return false ;
				this.attribute[name] = value ;
			}
			elm.type |= 2 ;
			return true ;
		}
		// 属性値削除
		elm.removeAttribute = function( name) {
			if ( ! typeof(name).match( /^(string|number)$/i)) return false ;
			if ( ! this.attribute[name]) return true ;
			delete( this.attribute[name]) ;
			if ( elm.hasAttribute()) { elm.type |= 2 ; } else { elm.type &=~2 ; }
			return true ;
		}
		// 属性所持判定
		elm.hasAttribute = function() {
			var count = 0 ;
			for ( var i in this.attribute) { count ++ ; if ( count > 0) break ; }
			return ( count > 0) ? true : false ;
		}
		// 対象直前への要素追加
		elm.insertBefore = function( name, target) {
			if ( ! typeof( name).match( /^(string|number)$/i)) return false ;
			if ( String(name).match( /[<>\"= ]+/)) return false ;
			elm.setValue() ;
			if ( ! (elm.type&9)) return false ;
			if ( ! target || ! target.discode || ! list[target.discode] || list[target.discode].name != target.name) return false ;
			var telm = { name : name, discode : node_count ++ , level : target.level, value : null, attribute : new Object, type : 1 } ;
			var tmap = new Object() ;
			for ( var i in map[this.discode]) {
				if ( i == target.discode) { tmap[telm.discode] = true ; } tmap[i] = map[this.discode][i] ;
			}
			map[this.discode] = tmap ; list[telm.discode] = telm ; elm.type = ((elm.type&~1)|8) ;
			setRelation() ;
			return list[telm.discode] ;
		}
		// 対象の子の最後への要素追加
		elm.appendChild = function( name)
		{
			// 引数はノード名に使える文字列か
			if ( typeof( name) != "string" && typeof(name) != "number") return false ;
			if ( ! name.match( /^[a-z0-9_]+$/i)) return false ;
			// 自身は子階層を持てるか
			elm.setValue() ;
			// 取得オブジェクトのコピー作成/IDの保存
			var telm = { name : name, discode : node_count ++ , level : elm.level+1, value : null, attribute : {}, type : 1 } ;
			// XMLMapの改竄
			if ( map[elm.discode] == true) map[elm.discode] = new Object() ;
			map[elm.discode][telm.discode] = true ;
			// 新規XMLListへの追加
			list[telm.discode] = telm ; elm.type = (elm.type&~1)|8 ;
			// 親子関係の作成
			setRelation() ;
			return list[telm.discode] ;
		}
		// 対象の子階層への要素削除
		elm.removeChild = function( target) {
			if ( ! target || ! target.discode || ! list[target.discode] || list[target.discode].name != target.name || ! map[elm.discode][target.discode]) return false ;
			var tgt_id = target.discode ;
			while( target.hasChildNodes()) { target.removeChild( target.firstChild) ; }
			list[tgt_id] = false ; delete( map[elm.discode][tgt_id]) ;
			setRelation() ;
			if ( ! elm.hasChildNodes()) { elm.type &= ~1 ; map[elm.discode] = true ; }
			return true ;
		}
		// 同階層にある子ノードの位置を変更する
		elm.moveChildNode = function( cnd, tnd) {
			if ( ! elm.hasChildNodes()) return false ;
			if ( typeof( tnd) != "undefined" && ( ! tnd || ! tnd.discode || ! list[tnd.discode] || list[tnd.discode].name != tnd.name || ! map[elm.discode][tnd.discode])) return false ;
			if ( ! cnd || ! cnd.discode || ! list[cnd.discode] || list[cnd.discode].name != cnd.name || ! map[elm.discode][cnd.discode]) return false ;
			var cmap = map[elm.discode][cnd.discode] ;
			var emap = new Object() ; if ( ! tnd) emap[cnd.discode] = cmap ;
			for ( var i in map[elm.discode]) {
				if ( cnd.discode == i) continue ;
				emap[i] = map[elm.discode][i] ;
				if ( tnd && tnd.discode == i) emap[cnd.discode] = cmap ;
			}
			map[elm.discode] = emap ;
			setRelation() ;
			return true ;
		}
		// 自身または他のXMLオブジェクトの指定ノードを、自身のノードの子階層へと登録する
		elm.copyChildNode = function( base_nd, tnd) {
			// 引数の確認
			if ( ! base_nd.thisXMLParseObject) return false ;
			if ( tnd != undefined && ( ! tnd.thisXMLParseObject || ! map[elm.discode][tnd.discode])) return false ;
			// エレメントの追加
			if ( tnd) {
				var new_nd = elm.insertBefore( base_nd.getName(), tnd) ;
			} else {
				var new_nd = elm.appendChild( base_nd.getName()) ;
			}
			if ( ! new_nd) return false ;
			// Attribute値のコピー
			for ( var i in base_nd.attribute) { new_nd.setAttribute( i, base_nd.attribute[i]) ; }
			// 子ノードのコピー
			if ( base_nd.hasChildNodes()) {
				for ( var i = 0 ; i < base_nd.childNodes.length ; i ++) {
					if ( ! new_nd.copyChildNode( base_nd.childNodes[i]))
						{ new_nd.parentNode.removeChild( new_nd) ; return false ; }
				}
			} else
			// Value値の複製
			if ( base_nd.getValue()) {
				new_nd.setValue( base_nd.getValue()) ;
			}
			return new_nd ;
		}
		// 対象の子階層所持判定
		elm.hasChildNodes = function() { return ( elm.firstChild) ? true : false ; }
		// 対象の子階層に存在する特定タグ名を取得
		elm.getElementsByTagName = function( tagnm, in_myset) {
			if ( typeof( tagnm) != "string") return false ;
			var elm_list = new Object() ; var elm_line = 0 ;
			if ( elm.hasChildNodes()) {
				for ( var i = 0 ; i < elm.childNodes.length ; i ++) {
					if ( elm.childNodes[i].getName( tagnm)) elm_list[elm_line++] = elm.childNodes[i] ;
					if ( ! elm.childNodes[i].hasChildNodes()) continue ;
					var tmp_list = elm.childNodes[i].getElementsByTagName( tagnm) ;
					if ( ! tmp_list) continue ;
					for ( var j = 0 ; j < tmp_list.length ; j ++) { elm_list[elm_line++] = tmp_list[i] ; }
				}
			}
			elm_list.length = elm_line ;
			return ( elm_list.length > 0) ? elm_list : false ;
		}
		elm.thisXMLParseObject = function() { return true ; }

	}

}


//
// login
//
var loginObj = new Object;

loginObj._init = {
	xml_url : "http://www.sunrefre.jp/list/login_info.xml"
};

loginObj._data = new Object();

loginObj._load = function () {
	loginObj.xml.format();
}

//## XMLの取得
loginObj.xml = new Object;
loginObj.xml.format = function () {
	var ini = loginObj._init;
	
	var args = {
		query : "",
		method : "post",
		url : ini.xml_url,
		func : loginObj.xml.analyses
	}
	
	loginObj.xml.parse = new XMLParse();
	loginObj.xml.parse.read( args.query, args.method, args.url, false, args.func);

	return true;
}

//## XML解析処理
loginObj.xml.analyses = function ( nd) {
	var ini = loginObj._init;
	if ( typeof( nd) != "object") return false;
	
	if ( ! nd.getName("login") || ! nd.hasChildNodes()) {
		//alert("データの取得に失敗しました");
		return false;
	}
	
	//データ取得開始
	var cnt = nd.childNodes.length;
	
	for(var i = 0; i < cnt; i++) {
		var nd_2 = nd.childNodes[i] ;
		
		if ( nd_2.getName("is_login")) {
		  loginObj._data.is_login = ( nd_2.getValue() == "true") ? true : false ;
		}
		
		if ( nd_2.getName("html")) {
		  loginObj._data.html = nd_2.getValue();
		}
	}
	
	return true;
}

function Login_Menu() {
  var html;
  
  loginObj._load();
  
	var timer = setInterval( function() {
		clearInterval( timer) ;
		
  	if ( loginObj._data.is_login) {
      document.getElementById("login_menu").innerHTML = loginObj._data.html;
  	} else {
  	  document.getElementById("login_menu").style.display = "none";
  	}
		
	}, 100) ;
}

/*
if ( document.attachEvent) {
	window.attachEvent( "onload", Login_Menu) ;
} else {
	window.addEventListener( "load", Login_Menu, true) ;
}
*/

Login_Menu();