// Array.push() prototype
if(!Array.prototype.push){
	Array.prototype.push = function(){
		for(var ct=0 ; ct< arguments.length ; ct++)	this[this.length] = arguments[ct];
	}
}
// Array.pop() prototype
if(!Array.prototype.pop){
    Array.prototype.pop =function(){
		var last_item = this[this.length-1];
		this.length = Math.max(this.length-1,0);
	    return last_item;
	}
}
// Array.shift() prototype
if(!Array.prototype.shift) {
	Array.prototype.shift = function(){
		var first_item = this[0];
		this.reverse();
		this.length = Math.max(this.length-1,0);
		this.reverse();
		return first_item;
	}
}
// Array.unshift() prototype
if(!Array.prototype.unshift) {
	Array.prototype.unshift = function() {
		this.reverse();
		for(var ct=arguments.length-1 ; ct>=0 ; ct--){
			this[this.length]=arguments[ct]
		}
		this.reverse();
		return this.length;
	}
}

/* set infomation box */
function set_info(info_src){
	var ar_temp1 = Array();
	var ar_temp2 = Array();
	var sz_html = "";
	var ct;
	

	var target_obj = document.getElementById("infobox");
	ar_temp1 = info_src.split("--sep--");

	for(ct=0;ct< ar_temp1.length ; ct++){
		ar_temp2 = ar_temp1[ct].split("\t");
		if(ar_temp2.length == 3){
			sz_html += '<div>';
			sz_html += '<h2>' + ar_temp2[0]+ '&nbsp;' + ar_temp2[1]+ '</h2>';
			sz_html += '<p>' + ar_temp2[2] + '</p>';
			sz_html += '</div>';
		}
		target_obj.innerHTML= sz_html;
	}
}

/* set what'new box */
function set_wnew(wnew_src){
	var ar_temp1;
	var ar_tdbody;

	var sz_html = "";
	var ct;
	
	var target_obj = document.getElementById("newdata");
	var set_tbody = document.createElement('tbody');

	ar_temp1 = wnew_src.split("\n");

	// tableはinnerHTMLでIEに追加するとおかしいことに_no
	ar_tdbody = new Array(ar_temp1.length);
	for(ct=0;ct< ar_temp1.length ; ct++){
		var ar_temp2 = ar_temp1[ct].split("\t");
		if(ar_temp2.length == 2){
			var set_tr = document.createElement('tr');
			var set_td = document.createElement('td');
			var set_th = document.createElement('th');
			var th_text_node = document.createTextNode(ar_temp2[0]);
			set_td.id = "whatnew_td_"+ ct;

			set_th.appendChild(th_text_node);
			set_tr.appendChild(set_th);
			set_tr.appendChild(set_td);

			set_tbody.appendChild(set_tr);
			ar_tdbody[ct] = ar_temp2[1];
		}
	}
	target_obj.appendChild(set_tbody);

	// new情報はタグ込みなので、後からinnerHTMLを使うことに_no
	for(ct=0;ct<ar_tdbody.length ; ct++){
		if(ar_tdbody[ct] != undefined){
			var tmp_obj = document.getElementById("whatnew_td_"+ct);
			tmp_obj.innerHTML = ar_tdbody[ct];
		}
	}
}

/* Whatsnewの背景を半透明にする処理 */
function set_alphabg(){
	var obj;

	if(document.getElementById("wnewlbbg")){
		obj = document.getElementById("wnewlbbg");
		obj.style.backgroundColor ="transparent";
		// is WinIE
		if(navigator.userAgent.indexOf('Win') != -1 && navigator.userAgent.indexOf('MSIE') != -1){
			obj.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='grapic/top/wnewbg.png',sizingMethod='scale')";
		}
		else{
			obj.style.backgroundImage = 'url("grapic/top/wnewbg.png")';
		}
	}
}

/* whatsnewの表示、非表示ボタン*/
function whatsnew_change(){
	var obj;
	var obj2;

	document.getElementById("whatsnew").style.zIndex = 10;

	if(document.getElementById("listbox")){
		obj = document.getElementById("listbox");
		if(obj.style.display == "none"){
			obj.style.display = "block";
			
			if(document.getElementById("wnewclose")){
				obj2 = document.getElementById("wnewclose");
				obj2.innerHTML = '<a href="javascript:void(0);" onClick="whatsnew_change();">＿</a>';
			}
		}
		else{
			obj.style.display = "none";

			if(document.getElementById("wnewclose")){
				obj2 = document.getElementById("wnewclose");
				obj2.innerHTML = '<a href="javascript:void(0);" onClick="whatsnew_change();">□</a>';
			}
		}
	}
}

function wnew_onmouse(){
	var obj

	if(document.getElementById("wnewlbbg")){
		obj = document.getElementById("wnewlbbg");
		obj.style.backgroundColor ="#ffffe8";
	}
}

function wnew_outmouse(){
	var obj

	if(document.getElementById("wnewlbbg")){
		obj = document.getElementById("wnewlbbg");
		obj.style.backgroundColor ="transparent";
	}
}




/* XMLHttpRequest */
function create_XMLObject(){
	var t = this;
	this.isReqesting = false;
	this.obj_xmlhttp = false;

	this.create = function(){
		var result = false;

		/*@cc_on 
		/*@if (@_jscript_version >= 5)
		try {
				result = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				result = new ActiveXObject("Microsoft.XMLHTTP");

			} catch (E) {
				result = false;
			}
		}
	    @else
	        result = false;
		@end @*/

		if (!result && typeof XMLHttpRequest!='undefined') {
			result = new XMLHttpRequest();
		}
		
		return result;
	};
	
	this.open = function(url , isAsync){
		if(t.isReqesting == true){
			return false;
		}
		if(!t.obj_xmlhttp){
			t.obj_xmlhttp = t.create();
			if(!t.obj_xmlhttp){
				return false;
			}
		}

		t.obj_xmlhttp.open("GET",url , isAsync );
//		t.obj_xmlhttp.setRequestHeader("If-Modified-Since", "Thu, 01 Jun 1970 00:00:00 GMT");

	  	t.obj_xmlhttp.onreadystatechange = function(){ 
	   		if(t.obj_xmlhttp.readyState == 4 && (t.obj_xmlhttp.status  == 200 || t.obj_xmlhttp.status  == 0)){  // xmlhttp.status  == 200
//	   		if(t.obj_xmlhttp.readyState == 4 && t.obj_xmlhttp.status  == 200){  // xmlhttp.status  == 200

				t.isReqesting = false;
				t.callback(t.obj_xmlhttp.responseText);


	    		//4、load完了 変換開始
// xmlではなくtxtを使っています
//				var readXML = t.obj_xmlhttp.responseXML;
//				if(t.obj_xmlhttp.status == 0 && navigator.userAgent.indexOf("Win") > -1 && navigator.userAgent.indexOf("MSIE") > -1){
//					// vs ie-local
//					readXML.load(t.obj_xmlhttp.responseStream);
//				}
//				if(readXML == null || isParseError(readXML)) {
//					alert("適切なXMLではありません");
//			  	}
//				else{
//					t.isReqesting = false;
//					t.callback(readXML);
//				}

			}
			else if(1 <= t.obj_xmlhttp.readyState &&  t.obj_xmlhttp.readyState <= 3){
				//loading;
			}
		}

		try {
			t.obj_xmlhttp.send("");
			t.isReqesting = true;
		} catch (e) {
			// send失敗
		}
		return t.isReqesting;
	}
	this.callback = function(loadedXML){
		;
	}
}




/* DOM Onload */
var DOM = {
	ready : false ,
	__interval_timer_id : undefined ,

	__init_onload : function(){
		if(this.__interval_timer_id != undefined){
			clearInterval(this.__interval_timer_id);
			this.__interval_timer_id = undefined;
		}

		if(this.ready != true){
			this.ready = true;
			this.onload();
		}
	},
	check : function(){
		var t = this;
		var f_w_onload = function(){	// window.onloadの方が先に来てしまった場合用
			if(t.ready == false){
				t.__init_onload();
			}
		}

		if(window.addEventListener) {
			window.addEventListener("load", f_w_onload, false);
		}
		else if(window.attachEvent) {
			window.attachEvent("onload", f_w_onload);
		}
		else {
			widnow.onload = f_w_onload;
		}

		/*@cc_on @*/
		/*@if(@_win32)
			document.write('<script id="__dom_onload_for_ie_" defer src="javascript:void(0);"><\/script>');
		/*@end @*/

		if(this.ready){
			this.onload();
		}
		// from IE
		else if(document.getElementById("__dom_onload_for_ie_")){
			document.getElementById("__dom_onload_for_ie_").onreadystatechange = function(){
							if(this.readyState=='complete'){
								t.__init_onload();
							}
						};
		}
		// from firefox , mozilla
		else if (document.addEventListener) {
			document.addEventListener("DOMContentLoaded", function(){
								t.__init_onload();
							}, false);
		}
		// from safari , khtml
		else if(navigator.userAgent.match(/webkit|safari|khtml/)) {
			this.__interval_timer_id = setInterval(function() {
							if(document.readyState.match(/loaded|complete/)){
								t.__init_onload();
							}
						 } , 50);
		}
		//  from other
		else{
			var old_length = document.documentElement.getElementsByTagName("*").length;
			this.__interval_timer_id = setInterval(function() {
							var now_length = document.documentElement.getElementsByTagName("*").length;
							if(now_length >= old_length){
								t.__init_onload();
							}
							else{
								old_length = now_length;
							}
						 } , 100);
		}
	},
 	onload : function(){}
}
DOM.check();
