
function _JSONscriptRequest_(fullUrl,charset,noCacheIE){this.fullUrl=fullUrl;this.charset=(charset==null||charset=='')?"UTF-8":charset;this.noCacheIE=noCacheIE;this.headLoc=document.getElementsByTagName("head").item(0);this.scriptId='JscriptId'+_JSONscriptRequest_.scriptCounter++;this.timeoutMSec=null;this.timeoutFunc=null;this.timerID=null;}
_JSONscriptRequest_.scriptCounter=1;_JSONscriptRequest_.prototype.setTimeoutFunc=function(func,timeValue){var jsonpr=this;var arg=[];for(var i=2;i<arguments.length;++i){arg.push(arguments[i]);}
jsonpr.timeoutFunc=function(){func.apply(jsonpr,arg)};jsonpr.timeoutMSec=timeValue;jsonpr.timerID=window.setTimeout(jsonpr.timeoutFunc,jsonpr.timeoutMSec);};_JSONscriptRequest_.prototype.clearTimeoutFunc=function(){var jsonpr=this;if(jsonpr.timerID)jsonpr.timerID=window.clearTimeout(jsonpr.timerID);jsonpr.timerID=null;jsonpr.timeoutFunc=null;jsonpr.timeoutMSec=null;};_JSONscriptRequest_.prototype.buildScriptTag=function(){this.scriptObj=document.createElement("script");this.scriptObj.setAttribute("type","text/javascript");this.scriptObj.setAttribute("charset",this.charset);this.scriptObj.setAttribute("src",this.fullUrl+(this.noCacheIE?this.getNoCacheParameterValue():""));this.scriptObj.setAttribute("id",this.scriptId);};_JSONscriptRequest_.prototype.getNoCacheParameterValue=function(){return"&noCacheIE="+new Date().getTime();};_JSONscriptRequest_.prototype.removeScriptTag=function(){try{this.headLoc.removeChild(this.scriptObj);}catch(e){}};_JSONscriptRequest_.prototype.addScriptTag=function(){this.headLoc.appendChild(this.scriptObj);};function EventDispatcher(){}
EventDispatcher.implement=function(obj){obj.__ed_eventContainer=new Object();obj.addEventListener=this._addEventListener;obj.removeEventListener=this._removeEventListener;obj.dispatchEvent=this._dispatchEvent;}
EventDispatcher.initialize=EventDispatcher.implement;EventDispatcher._addEventListener=function(_en,_obj){if(!_en||!_obj)return;if(typeof(_obj)=="object"||typeof(_obj)=="function"){if(this.__ed_eventContainer[_en]==null){this.__ed_eventContainer[_en]=new Array();}
this.removeEventListener(_en,_obj);this.__ed_eventContainer[_en].push(_obj);}}
EventDispatcher._removeEventListener=function(_en,_obj){if(!_en||!_obj)return;var a=this.__ed_eventContainer[_en];if(typeof(a)=="undefined")return;var l=a.length;for(var i=0;i<l;i++){if(a[i]==_obj){a.splice(i,1);return;}}}
EventDispatcher._dispatchEvent=function(_ev){if(!_ev)return;if(typeof(_ev)=="string")_ev=new EventObject(_ev,this);if(_ev.target==null)_ev.target=this;var a=this.__ed_eventContainer[_ev.type];if(a==null)return;var l=a.length;for(var i=0;i<l;i++){var ln=a[i];if(typeof(ln)=="object"){ln[_ev.type].apply(ln,arguments);}else{ln.apply(ln,arguments);}}}
function EventObject(_en,_tg){if(!_en)return;this.type=_en;this.target=_tg;}
JSONCALLBACK=new Array();function JSON(param){if(typeof(EventDispatcher)=="undefined"){alert("EventDispatcher has not been loaded !");return;}
EventDispatcher.implement(this);this.numId=JSON.scriptCounter;this.responseData=null;var obj=this;JSONCALLBACK[this.numId]=function(){obj.clearTimeoutFunc();obj.responseData=arguments;obj.dispatchEvent(new EventObject("onload",obj));}
this.scriptId='Jscript2Id'+JSON.scriptCounter++;this.callbackParamName=JSON.defaultCallbackParamName;var d=new Date();this.callbackFuncName="JSONCallback"+this.scriptId+d.getTime();var makeCallback=""+
this.callbackFuncName+"=function(){\n"+" JSONCALLBACK["+this.numId+"].apply(null,arguments);\n"+"}";eval(makeCallback);this.timeOutMS=5000;this.noCacheIE=false;if(param){if(param["fullUrl"])this.fullUrl=param["fullUrl"];if(param["callbackParamName"])this.callbackParamName=param["callbackParamName"];if(param["charset"])this.charset=param["charset"];if(param["timeOutMS"])this.timeOutMS=param["timeOutMS"];if(param["noCacheIE"])this.noCacheIE=param["noCacheIE"];}}
if(typeof(_JSONscriptRequest_)=="undefined"){alert("_JSONscriptRequest_ has not been loaded !")}
JSON.prototype=new _JSONscriptRequest_("");JSON.scriptCounter=0;JSON.defaultCallbackParamName="callback";JSON.prototype.get=function(fullUrl,charset,callbackParamName){if(fullUrl)this.fullUrl=fullUrl;if(callbackParamName)this.callbackParamName=callbackParamName;if(charset)this.charset=charset;if(typeof(this.fullUrl)!="string"){alert(this.id+"\nrequestURL is not string!\ntype=>"+typeof(this.fullUrl));return;}
if(typeof(this.callbackParamName)!="string"){alert(this.id+"\ncallbackParamName is not string!\ntype=>"+typeof(this.callbackParamName));return;}
if(this.fullUrl.indexOf(this.callbackParamName)!=-1){this.fullUrl.match(new RegExp(".*("+this.callbackParamName+"=.*)"));;if(RegExp.$1.indexOf("&")!=-1){this.fullUrl=this.fullUrl.replace(new RegExp(this.callbackParamName+"=.*&"),"");}else{this.fullUrl=this.fullUrl.replace(new RegExp("&"+this.callbackParamName+"=.*"),"");}}
this.fullUrl=this.fullUrl+"&"+this.callbackParamName+"="+this.callbackFuncName;this.clearTimeoutFunc();this.removeScriptTag();var obj=this;this.buildScriptTag();this.setTimeoutFunc(function(){obj.clearTimeoutFunc();obj.dispatchEvent(new EventObject("onerror",obj));},this.timeOutMS);this.addScriptTag();}
function Binding(sourceObject,sourceProperty,targetObject,targetProperty,eventType){if(typeof(EventDispatcher)=="undefined"){alert("EventDispatcher has not been loaded !");return;}
if(typeof(eventType)=="undefined")eventType=sourceProperty+"Changed";try{var handler=function(event){try{if(typeof(targetObject[targetProperty])=="function"){targetObject[targetProperty](sourceObject[sourceProperty]);}else{targetObject[targetProperty]=sourceObject[sourceProperty];}}catch(error){}};sourceObject.addEventListener(eventType,handler)
return{target:sourceObject,eventType:eventType,handler:handler};}catch(error){}}
Binding.release=function(token){try{token.target.removeEventListener(token.eventType,token.handler);delete token.handler;}catch(error){}}
function Template(tagMap,parameters){this.idTagName=Template.DEFAULT_ID_TAG_NAME;this.scriptDirectiveStartMarker=Template.DEFAULT_SCRIPT_DIRECTIVE_START_MARKER;this.scriptDirectiveEndMarker=Template.DEFAULT_SCRIPT_DIRECTIVE_END_MARKER;this.variableDirectiveMarker=Template.DEFAULT_VARIABLE_DIRECTIVE_MARKER;this.variableDirectiveStartMarker=Template.DEFAULT_VARIABLE_DIRECTIVE_START_MARKER;this.variableDirectiveEndMarker=Template.DEFAULT_VARIABLE_DIRECTIVE_END_MARKER;this.functionArgumentName=Template.DEFAULT_FUNCTION_ARGUMENT_NAME;this.tagMap=tagMap?tagMap:Template.DEFAULT_TAG_MAP;this.debug=Template.DEFAULT_DEBUG;this.parameters=parameters;}
Template.BUFFER={};Template.DEFAULT_ID_TAG_NAME="@id@";Template.DEFAULT_SCRIPT_DIRECTIVE_START_MARKER="<!--\\\$";Template.DEFAULT_SCRIPT_DIRECTIVE_END_MARKER="\\\$-->";Template.DEFAULT_VARIABLE_DIRECTIVE_START_MARKER="%=";Template.DEFAULT_VARIABLE_DIRECTIVE_END_MARKER="%";Template.DEFAULT_FUNCTION_ARGUMENT_NAME="data";Template.DEFAULT_TAG_MAP={"@id@":"id"}
Template.DEFAULT_DEBUG=false;Template.BANPEI="@@@";Template.randamString=function(){return new Date().getTime()+"_"+parseInt(Math.random()*99999999);}
Template.prototype.compile=function(source,parameters){parameters=parameters?parameters:this.parameters;if(!parameters)parameters={};var appendMode=parameters.appendMode;if(typeof(appendMode)=="undefined")addSfx=false;var addSfx=parameters.addSfx;if(typeof(addSfx)=="undefined")addSfx=false;var nestedProperty=parameters.nestedProperty;if(typeof(nestedProperty)=="undefined")nestedProperty=true;var safeMode=parameters.safeMode;if(typeof(safeMode)=="undefined")safeMode=nestedProperty;var useScript=parameters.useScript;if(typeof(useScript)=="undefined")useScript=true;source=Template.BANPEI+source+Template.BANPEI;var target="function_"+Template.randamString();var s1=addSfx?this.addSfxTag(source):source;var s2=this.trimReturnCode(s1);var s3=this.splitElement(s2,useScript);var s4=this.buildFunctionString(s3,appendMode,safeMode,nestedProperty);var s5=target+"="+s4;eval(s5)
return eval(target);}
Template.prototype.addSfxTag=function(source){var r=null;r=source.match(/<[^\/|!][^>]*[^-][\/]?>/g);if(r){var l=r.length;for(var i=0;i<l;i++){var orgStr=r[i];var idTag=this.idTagName;if(orgStr.match(/\/>$/g)){var repStr=orgStr.replace(/\/>/g," sfx=\""+idTag+"\" />")}else{var repStr=orgStr.replace(/>/g," sfx=\""+idTag+"\" >")}
orgStr=orgStr.replace(/\//g,"\\/");orgStr=orgStr.replace(/\./g,"\\.");orgStr=orgStr.replace(/\?/g,"\\?");orgStr=orgStr.replace(/\(/g,"\\(");orgStr=orgStr.replace(/\)/g,"\\)");orgStr=orgStr.replace(/\[/g,"\\[");orgStr=orgStr.replace(/\]/g,"\\]");orgStr=orgStr.replace(/\^/g,"\\^");orgStr=orgStr.replace(/\*/g,"\\*");orgStr=orgStr.replace(/\+/g,"\\+");orgStr=orgStr.replace(/\?/g,"\\?");orgStr=orgStr.replace(/\$/g,"\\$");var reg=new RegExp(orgStr,"g");source=source.replace(reg,repStr);}}
return source;}
Template.prototype.trimReturnCode=function(source){return source.replace(/[\n|\r]/g,"");}
Template.REG1=null;Template.REG2=null;Template.prototype.prepareSplitElement=function(){var regStr="(.*)("+this.scriptDirectiveStartMarker+")(.*)("+this.scriptDirectiveEndMarker+")(.*)";Template.REG1=new RegExp(regStr,"g");var regStr="(.*)("+this.variableDirectiveStartMarker+")(.*)("+this.variableDirectiveEndMarker+")(.*)";Template.REG2=new RegExp(regStr,"g");}
Template.prototype.splitElement=function(source,useScript){this.prepareSplitElement();var a1=this.splitElement3(source);if(!useScript)return a1;var l=a1.length;var a2=[];for(var i=0;i<l;i++){var s=a1[i];if(s.t)a2[a2.length]=s;else{var ta=this.splitElement2(s);var l2=ta.length;for(var i2=0;i2<l2;i2++)a2[a2.length]=ta[i2];}}
l=a2.length;var a3=[];for(var i=0;i<l;i++){var s=a2[i];if(s.t)a3[a3.length]=s;else{var ta=this.splitElement1(s);var l2=ta.length;for(var i2=0;i2<l2;i2++)a3[a3.length]=ta[i2];}}
return a3;}
Template.prototype.splitElement1=function(source){var r=source.match(Template.REG1);if(r){var $1=RegExp.$1;var $3=RegExp.$3;var $5=RegExp.$5;var ret1=this.splitElement1($1);ret1[ret1.length]={t:"s",s:$3};var ret3=this.splitElement1($5);var l=ret3.length;for(var i=0;i<l;i++)ret1[ret1.length]=ret3[i];return ret1;}
return[source];}
Template.prototype.splitElement2=function(source){var r=source.match(Template.REG2);if(r){var $1=RegExp.$1;var $3=RegExp.$3;var $5=RegExp.$5;var ret1=this.splitElement2($1);ret1[ret1.length]={t:"v",s:$3};var ret3=this.splitElement2($5);var l=ret3.length;for(var i=0;i<l;i++)ret1[ret1.length]=ret3[i];return ret1;}
return[source];}
Template.prototype.splitElement3=function(source){var s=[source];for(var tag in this.tagMap){s=this.splitElement31(s,tag);}
return s;}
Template.prototype.splitElement31=function(ss,tag){var ret=[];var l=ss.length;for(var i=0;i<l;i++){var s=ss[i];if(s.t){ret.push(s);}else{var a=s.split(tag);var l2=a.length;for(var i2=0;i2<l2;i2++){ret.push(a[i2]);if(typeof(a[i2+1])!="undefined")ret.push({t:"t",s:this.tagMap[tag],tag:tag});}}}
return ret;}
Template.prototype.buildFunctionString=function(elements,appendMode,safeMode,nestedProperty){var arg=this.functionArgumentName;var sb="s_"+Template.randamString();var s="";s+="function("+arg+"){";if(appendMode){s+="var "+sb+"='';";}else{s+="var "+sb+"=[];";}
for(var i=0;i<elements.length;i++){var element=elements[i];if(element==Template.BANPEI)continue;if(element.t=="s"){s+=element.s;}else if(element.t=="v"){if(appendMode){s+=sb+"+="+element.s+";";}else{s+=sb+".push("+element.s+");";}}else if(element.t=="t"){var adds;var np=nestedProperty;if(typeof(element.s)=="number")np=false;if(typeof(element.s)=="string"&&element.s.match(/^\d/))np=false;if(appendMode){if(np)adds=sb+"+="+arg+"."+element.s+";";else adds=sb+"+="+arg+"['"+element.s+"'];";if(safeMode)adds="try{"+adds+"}catch(error){"+sb+"+='"+element.tag+"'};";}else{if(np)adds=sb+".push("+arg+"."+element.s+");";else adds=sb+".push("+arg+"['"+element.s+"']);";if(safeMode)adds="try{"+adds+"}catch(error){"+sb+".push('"+element.tag+"')};";}
s+=adds;}else{while(element.indexOf(Template.BANPEI)>-1)element=element.replace(Template.BANPEI,"");var key="key_"+Template.randamString();while(typeof(Template.BUFFER[key])!="undefined")key="key_"+Template.randamString();Template.BUFFER[key]=element;if(appendMode){s+=sb+"+=Template.BUFFER['"+key+"'];";}else{s+=sb+".push(Template.BUFFER['"+key+"']);";}}}
if(appendMode){s+="return "+sb+";}"}else{s+="return "+sb+".join('');}"}
return s;}
