<!--
document.write('<script id="dynld"></script>');
function ExpUtil(){
	this.version="0.5.0";
	this.code_smp = "0123456789abcdef";
    this.className="ExpUtil";
    // イベント種類別に登録情報を記録 eventList['eventName']=new ExpList();
    if(!ExpUtil.eventList) ExpUtil.eventList = new Array();
    
    this.getEventList=function(eventName){
        return ExpUtil.eventList[eventName];
    }

    this.addEventList=function(eventName){
        var evens=new ExpUtil.EventList();
        evens.getObj=function(objKey){
            if(!objKey) return null;
            var obj=this.get(objKey);
            for(;!obj;obj=this.get(objKey)){
                if((objKey.nodeType==1 || objKey.nodeType==3) && objKey.parentNode){
                    objKey=objKey.parentNode;
                }else return null;
            }
            return obj;
        }
        return ExpUtil.eventList[eventName]=evens;
    }

    this.getNewList=function(){
        return new ExpUtil.EventList();
    }

	/*****************************************************
	 * HTMLのエレメントを指定したIDで取得する。
	 * @param id： 対象エレメントのid
	 *****************************************************/
	this.getElementByID=function(id){
        return (document.all)? document.all[id] : document.getElementById(id);
    }
	/*****************************************************
	 * 10進数のカラーコードを16進数に変換する関数
	 * @param number10： 9桁10進数のカラーコード
	 *  ※ number10は数値型でも文字型でも良い
	 *****************************************************/
	this.color10to16=function(num10){
		if(!num10){
			alert("カラーコード変換の対象は設定されていません。[" + num10 + "]");
		}
		num10=(num10+"").replace(/,/, "").replace(/,/, "");
		if(num10.length!=9){
			num10="000000000".substr(0,9-num10.length)+num10;
		}
		var fval=new Array(3);
		fval[0]=this.get16(num10.substr(0,3));
		fval[1]=this.get16(num10.substr(3,3));
		fval[2]=this.get16(num10.substr(6,3));
		return "#"+(fval[0] +""+ fval[1] +""+ fval[2]).toUpperCase();
	}
	
	this.get16 = function(str10){
		var str16=eval(str10).toString(16)+"";
		if(str16.length<2) return "0" + str16;
		return str16;
	}
	/*****************************************************
	 * 10進数のカラーコードを16進数に変換する関数
	 * @param number10： 9桁10進数のカラーコード
	 *  ※ number10は数値型でも文字型でも良い
	 *****************************************************/
	this.color16to10 = function(num16) {
		num16=num16.replace(/#/, "");
		var f = num16.toLowerCase();
		if(!f){
			alert("カラーコード変換の対象は正しくありません。");
			return null;
		}else{
			var fval=new Array();
			for(i=0;i<=5;i++) {
		      fval[i] = f.substring(i,i+1);
		      fval[i] = this.code_smp.indexOf(fval[i]);
			}
			for(i=0;i<=5;i+=2) fval[i] = fval[i] * 16;
			var code10_1 = eval(fval[0]) + eval(fval[1]);
			var code10_2 = eval(fval[2]) + eval(fval[3]);
			var code10_3 = eval(fval[4]) + eval(fval[5]);
			return code10_1+","+code10_2+","+code10_3;
	   }
	}

	/*****************************************************
	 * 曜日コードから曜日曜日名を取得する。
	 * @param number10： 9桁10進数のカラーコード
	 *  ※ number10は数値型でも文字型でも良い
	 *****************************************************/
	this.dayNameList=new Array("日", "月", "火", "水", "木", "金", "土" );
	this.getDayName = function(num){return this.dayNameList[num];}

	/*********************************
	 * 要素の属性情報を取得する
	 * @param node：対象の要素
	 * @return 対象要素の属性リスト
	 *  list[key]=value
	 *********************************/
	this.getAttributes = function(node, debug){
		var list=new Array();
		var target=node.attributes;
		var v="";
		for (var i=0;i<target.length;i++) {
			list[target.item(i).nodeName] = target.item(i).value;
			v+= target.item(i).nodeName +  " = " + target.item(i).value+"\n";
		}
		if(debug) alert(v + ";   " + target.item(0).value);
		return list;
	}
	
	/*********************************
	 * 指定されたElementの子ノードを
	 * 総べで削除する。
	 * @param node：対象の要素
	 *********************************/
	this.removeChild = function(node){
		while(node.hasChildNodes()) node.removeChild(node.firstChild);
	}

	/*********************************
	 * オブジェクトプロパティを表示する
	 * @param obj：対象の要素
	 * @param oneTime：一回切り実行オプション
	 *********************************/
	this.f=false;
	this.show=function(obj, oneTime){
		if(oneTime && this.f) return;
		var v="";
		for(var index in obj) if(obj[index]!=null&&obj[index]!="")v+=index + " = " + obj[index]+"\n";
		alert(v);
		this.f=true;
	}

	/*********************************
	 * 数字にカンマ編集を行う
	 * @param target：対象の文字列
	 * @return ：編集結果
	 *********************************/
	this.AddComma = function(target){
		var result = "0"; 
		if (target==null || (target+"").length==0){ 
			return result; 
		}else{
			target+="";
			// 負符号の対応
			var str = (target.indexOf(",")==-1)? target : this.DelComma(result);
			var sing=str.substring(0,1); 
			if(sing!="-"){ 
				sing=""; 
			}else{ 
				str = str.replace(/-/i,"");
				if (str.length==0 || str=="0") return 0;
			} 
			// 小数部取得 
			var floPart = ""; 
			var index = str.indexOf("."); 
			if(index>0){ 
				floPart = str.substring(index, str.length); 
				str = str.substring(0,index); 
			} 
			// カンマを付ける 
			var ext = str.length % 3; 
			var cnt = Math.floor(str.length / 3); 
			var head = "", tail = "", body = ""; 
			if ( ext > 0 ){ 
				head = str.substr(0,ext); 
				tail = str.substr(ext,str.length); 
			}else tail = str; 
			// カンマ編集しない場合 
			if ( cnt == 0 ) body = ""; 
			else{ 
			// カンマ編集する場合 
				if ( ext > 0 ) body = "," + tail.substr(0,3); 
				else body = tail.substr(0,3); 
				for( i=1;i<cnt;i++ ) body += "," + tail.substr(3*i,3); 
			} 
			result = sing + head + body + floPart; 
		} 
		return result;
	};

	/*********************************
	 * 数字型文字列のカンマを取り除く
	 * @param target：対象の文字列
	 * @return ：編集結果
	 *********************************/
	this.DelComma = function(target){
		var result = 0;
		if (target==null || (target+"").length==0){
			return result; 
		}else 
		while(target.indexOf(",")>=0){target=target.replace(/-/i,",");}
		return target;
	};

	/*********************************
	 * 文字列のスペースを取り除く
	 * @param str：対象の文字列
	 * @return ：編集結果
	 *********************************/
	this.trim=function(str){
		var result=str.toString();
		while(result.indexOf(" ",0)>-1) result=result.replace(/ /, "");
		return result;
	};

	/*********************************
	 * ダイナミックローディング
	 * @param jsFileName：ローディングの対象URL
	 * @return ：編集結果
	 *********************************/
	this.dynamicLoad=function(jsFileName){
		if( document.all ){ 
			if( navigator.userAgent.indexOf("Win")!=-1 ){
				//--for document.all && Win
				eval(document.all('dynld')).src = jsFileName;
			} else if( navigator.userAgent.indexOf("Mac")!=-1 ){
				//--for document.all && Mac
				document.body.insertAdjacentHTML('BeforeEnd' ,'<scr'+'ipt src="'+jsFileName+'"><scr'+'ipt/>');
			}
		} else if(document.getElementById){
			//--for w3c-dom  widthout document.all 
			var cnode =document.getElementById('dynld');
			var nnode = document.createElement('script');
			nnode.src = jsFileName;
			nnode.id  = 'dynld';
			cnode.parentNode.replaceChild(nnode,cnode);
		} else {
			return false;
			//--for nondhtml(n4...)
			if(document.images){
				var datasrc   = new Image();
				datasrc.src   = jsFileName;
				location.href = datasrc.src;
			}
		}
		return true;
	};

  this.ua = navigator.userAgent;
  this.getKEYCODE=function (e){
    if(this.ua.indexOf("Safari")!=-1 ||
       this.ua.search('opera(\ |\/)6')!=-1)  //s1,o6不可
      return null
    else if(document.layers)            //n4用
      return  e.which
    else if(document.all)               //e4,e5,e6,o7用
      return  event.keyCode
    else if(document.getElementById)    //n6,n7,moz用
      return  e.charCode
    else return null                    //上記以外
  };

  this.getKEYVALUE=function(e){
  	return String.fromCharCode(this.getKEYCODE(e));
  };
}

/***********************************************************************
 * Elementとオブジェクトのメソッドとの間にリンクを張る。
 * @pram  element   ：イベント発生するElementオブジェクト
 * @pram  obj       ：イベント発生後の処理依頼対象クラスのインスタンス
 *                    ユーザークラス(classNameプロパティが必要)
 * @pram  func	    ：イベント発生後の実行する処理のメソッド名(文字)
 * @pram  eventKind ：イベント種類名(文字)
 *                    例："onclick","onchanged"等
 ***********************************************************************/
ExpUtil.prototype.addEvent=function(element, obj, func, eventKind){
    if(!element){
        alert("イベント登録の対象要素は正しく設定されていません。\n＊登録中断した！");
        return;
    }else
    if(!element["window"] && !element.nodeType){
        alert("イベント登録の対象要素は正しく設定されていません。\n＊登録中断した！");
        return;
    }else
    if(!obj || !obj.className){
        alert("イベント登録先は正しく設定されていません。\n＊登録中断した！");
        return;
    }else
    if(!func || typeof(func)!="string"){
        alert("イベント登録の処理は正しく設定されていません。\n＊登録中断した！");
        return;
    }else
    if(!eventKind || typeof(eventKind)!="string"){
        alert("登録するイベントの種類は正しく設定されていません。\n＊登録中断した！");
        return;
    }
    var events=this.getEventList(eventKind);
    if(!events){
        // 指定されたイベントの管理用配列作成
        events = this.addEventList(eventKind);
        // 指定されたイベントのメソッド作成『 ExpUtil.onclick = function(event){ExpUtil.runFunc('onclick', event);} 』
        if(element==document) 
            eval(this.className + "." + eventKind + "Doc=function(event){" + this.className + ".runDocFunc('" + eventKind + "', event);}");
        else
            eval(this.className + "." + eventKind + "=function(event){" + this.className + ".runFunc('" + eventKind + "', event);}");
    }
    // 指定されたイベントを対象Elementに登録 『 element.onclick=ExpUtil.onclick 』実行
    if(element==document) 
        eval("element." + eventKind + "=" + this.className + "." + eventKind + "Doc");
    else
        eval("element." + eventKind + "=" + this.className + "." + eventKind);
    events.put(element, {'obj':obj, 'funcName':func});
}

/***********************************************
 * 対象のイベントを実行する
 *オブジェクトのファンクションとリンクする。
 * @pram  eventKind	：登録されたイベント名文字列
 * @pram  event	    ：イベント
 ***********************************************/
ExpUtil.runFunc=function(eventKind, event ){
    var events=ExpUtil.eventList[eventKind];
    if(!events) return;
    event = (document.all)? window.event : event;
    var o = events.getObj((document.all)? event.srcElement : event.target);
    if(!o){
        alert("イベントの発生元の["+eventKind+"]に対する処理が登録されていません。");
        return;
    }
    eval("o.obj."+ o.funcName +'(event);');
}

/*
ExpUtil.prototype.addDocEvent=function(obj, func, eventKind){
    var element=document;
    var events=this.getEventList(eventKind);
    if(!events){
        // 指定されたイベントの管理用配列作成
        events = this.addEventList(eventKind);
        // 指定されたイベントのメソッド作成『 ExpUtil.onclick = function(event){ExpUtil.runFunc('onclick', event);} 』
        eval(this.className + "." + eventKind + "=function(event){" + this.className + ".runDocFunc('" + eventKind + "', event);}");
    }
    // 指定されたイベントを対象Elementに登録 『 element.onclick=ExpUtil.onclick 』実行
    eval("element." + eventKind + "=" + this.className + "." + eventKind);
    events.put(element, {'obj':obj, 'funcName':func});
}
*/

ExpUtil.runDocFunc=function(eventKind, event ){
    var events=ExpUtil.eventList[eventKind];
    if(!events) return;
    var o = events.get(document);
	if(!o) return;
	eval("o.obj."+ o.funcName +'(event);');
}

//-------------------------------------------------------------------------------------------//
ExpUtil.EventList=function(){
    this.list=new Array();
    this.length=0;
    
    this.put=function(objKey, objValue){
        // 指定のキーは既に存在した場合は登録の書き換えを行う。
        if(this.containsKey(objKey)){
            var i=0;
            for(;i<this.length;i++) if(this.list[i].key===objKey){
                this.list[i]={key:objKey, value:objValue};
                return i;
            }
        }
        this.length=this.list.length;
        this.list[this.length++]={key:objKey, value:objValue};
        return this.length-1;
    };

    this.containsKey=function(objKey){
        return this.get(objKey)!=null;
    };

    this.get=function(objKey){
        for(var i=0;i<this.length;i++) if(this.list[i].key===objKey){
            return this.list[i].value;
        }
        return null;
    };

    this.getKey=function(i){
        if(i>=this.length) return null;
        return this.list[i].key;
    };

    this.getValue=function(i){
        if(i>=this.length) return null;
        return this.list[i].value;
    };

    this.getIndex=function(objKey){
        for(var i=0;i<this.length;i++) if(this.list[i].key===objKey){
            return i
        }
        return -1;
    };
}
//-------------------------------------------------------------------------------------------//

//-->
