function $A(a){if(!a)return[];if(a.toArray)return a.toArray();var b=a.length,c=new Array(b);while(b--)c[b]=a[b];return c}if(navigator.userAgent.indexOf("AppleWebKit/")>-1){function $A(a){if(!a)return[];if(!(typeof a=="function"&&a=="[object NodeList]")&&a.toArray)return a.toArray();var b=a.length,c=new Array(b);while(b--)c[b]=a[b];return c}}Object.extend=function(a,c){for(var b in c)a[b]=c[b];return a};Object.extend(Function.prototype,{bind:function(){if(arguments.length<2&&arguments[0]===undefined)return this;var b=this,a=$A(arguments),c=a.shift();return function(){return b.apply(c,a.concat($A(arguments)))}}});var Class={create:function(){var b=null,c=$A(arguments);if(typeof c[0]=="function")b=c.shift();function a(){this.initialize.apply(this,arguments)}Object.extend(a,Class.Methods);a.superclass=b;a.subclasses=[];if(b){var e=function(){};e.prototype=b.prototype;a.prototype=new e;b.subclasses.push(a)}for(var d=0;d<c.length;d++)a.addMethods(c[d]);if(!a.prototype.initialize)a.prototype.initialize=function(){};a.prototype.constructor=a;return a}};Class.Methods={addMethods:function(g){var f=this.superclass&&this.superclass.prototype,b=Object.keys(g);!Object.keys({toString:true}).length&&b.push("toString","valueOf");for(var e=0,h=b.length;e<h;e++){var c=b[e],a=g[c];if(f&&typeof a=="function"&&a.argumentNames().first()=="$super")var d=a,a=Object.extend(function(a){return function(){return f[a].apply(this,arguments)}}(c).wrap(d),{valueOf:function(){return d},toString:function(){return d.toString()}});this.prototype[c]=a}return this}};var Buffalo=Class.create();Buffalo.BOCLASS="_BUFFALO_OBJECT_CLASS_";Buffalo.VERSION="1.2.3";Buffalo.debug=false;Buffalo.prototype={initialize:function(b,a,c){this.gateway=b;this.transport=null;if(typeof a=="undefined")this.async=true;else this.async=a;this.currentCallback=new Function;this.setEvents(c);this.queue=[];this.requesting=false},getGateway:function(){return this.gateway},setEvents:function(a){this.events={onLoading:Buffalo.Default.showLoading,onFinish:new Function,onException:new Function,onError:Buffalo.Default.showError};Object.extend(this.events,a||{})},_remoteCall:function(c,a,b){this.requesting=true;this.transport=XmlHttp.create();this.transport.open("POST",c,this.async);this.transport.send(a.xml());this.currentCallback=b;if(this.async){this.transport.onreadystatechange=this.onStateChange.bind(this);this.events.onLoading(true)}else this.response()},nextRemoteCall:function(){if(this.queue.length<=0)return;var a=this.queue.shift();this._remoteCall(a.url,a.call,a.callback)},remoteCall:function(a,c,g){for(var e=a.indexOf("."),f=a.substring(0,e),h=a.substring(e+1,a.length),i=this.gateway+"/buffalo/"+f,d=new Buffalo.Call(h),b=0;b<c.length;b++)d.addParameter(c[b]);this.queue.push({url:i,call:d,callback:g});!this.requesting&&this.nextRemoteCall()},remoteCall:function(a,c,d,g){for(var h=a.substring(0,a.lastIndexOf(".")),f=a.substring(a.lastIndexOf(".")),i=h+"!"+c+f,e=new Buffalo.Call(c),b=0;b<d.length;b++)e.addParameter(d[b]);this.queue.push({url:i,call:e,callback:g});!this.requesting&&this.nextRemoteCall()},onStateChange:function(){this.transport.readyState==4&&this.response()},response:function(){if(this.transport.status=="200"){var a,b=this.transport.responseText;if(b.indexOf("xmlns:burlap")==-1){b=b.replace("<burlap:reply>",'<burlap:reply xmlns:burlap="http://www.amowa.net/buffalo/">');a=new Buffalo.Reply(b)}else a=new Buffalo.Reply(this.transport);this.events.onLoading(false);this.currentCallback(a);this.events.onFinish(a);this.requesting=false;this.nextRemoteCall()}else this.events.onError(this.transport.responseText)}};Buffalo.Default={loadingPane:null,errorPane:null,showLoading:function(b){this.loadingPane=document.getElementById("buffalo_loading");if(this.loadingPane==null){var a=document.createElement("DIV");a.setAttribute("id","buffalo_loading");a.style.cssText="display:none;font-family:Verdana;font-size:11px;border:1px solid #00CC00;background-color:#A4FFA4;padding:1px;position:absolute;right:2px;top:1px;height:14px;z-index:10000";a.innerHTML="\u6b63\u5728\u52a0\u8f7d...";document.body.appendChild(a);this.loadingPane=a}if(b)this.loadingPane.style.display="";else this.loadingPane.style.display="none"},showError:function(b){this.errorPane=document.getElementById("buffalo_error");if(this.errorPane==null)if(b!=null&&b!=""){var a=document.createElement("DIV");a.setAttribute("id","buffalo_error");a.style.cssText="font-family:Verdana;font-size:11px;border:1px solid #00CC00;background-color:#fff;padding:1px;position:absolute;overflow:auto; right:1px; top:1px; width:500px; height:300px; z-index:1";a.innerHTML=b;document.body.appendChild(a);this.errorPane=a}},showException:function(){}};function getDomDocumentPrefix(){if(getDomDocumentPrefix.prefix)return getDomDocumentPrefix.prefix;for(var b=["MSXML2","Microsoft","MSXML","MSXML3"],c,a=0;a<b.length;a++)try{c=new ActiveXObject(b[a]+".DomDocument");return getDomDocumentPrefix.prefix=b[a]}catch(d){}throw new Error("Could not find an installed XML parser");}function getXmlHttpPrefix(){if(getXmlHttpPrefix.prefix)return getXmlHttpPrefix.prefix;for(var b=["MSXML2","Microsoft","MSXML","MSXML3"],c,a=0;a<b.length;a++)try{c=new ActiveXObject(b[a]+".XmlHttp");return getXmlHttpPrefix.prefix=b[a]}catch(d){}throw new Error("Could not find an installed XMLHttp object");}function XmlHttp(){}XmlHttp.create=function(){try{if(window.XMLHttpRequest){var a=new XMLHttpRequest;if(a.readyState==null){a.readyState=1;a.addEventListener("load",function(){a.readyState=4;typeof a.onreadystatechange=="function"&&a.onreadystatechange()},false)}return a}if(window.ActiveXObject)return new ActiveXObject(getXmlHttpPrefix()+".XmlHttp")}catch(b){}throw new Error("Your browser does not support XmlHttp objects");};function XmlDocument(){}XmlDocument.create=function(){try{if(document.implementation&&document.implementation.createDocument){var a=document.implementation.createDocument("","",null);if(a.readyState==null){a.readyState=1;a.addEventListener("load",function(){a.readyState=4;typeof a.onreadystatechange=="function"&&a.onreadystatechange()},false)}return a}if(window.ActiveXObject)return new ActiveXObject(getDomDocumentPrefix()+".DomDocument")}catch(b){}throw new Error("Your browser does not support XmlDocument objects");};if(window.DOMParser&&window.XMLSerializer&&window.Node&&Node.prototype&&Node.prototype.__defineGetter__){Document.prototype.loadXML=function(d){while(this.hasChildNodes())this.removeChild(this.lastChild);for(var b=(new DOMParser).parseFromString(d,"application/xml"),a=0,c=b.childNodes.length;a<c;a++)this.appendChild(this.importNode(b.childNodes[a],true))};Document.prototype.__defineGetter__("xml",function(){return(new XMLSerializer).serializeToString(this)})}function _list(a){if(!a.hasChildNodes()){a.nodeValue&&alert("type: "+a.nodeType+"; value: "+a.nodeValue.length);return}for(var c=a.childNodes,b=0;b<c.length;b++)_list(c[b])}Buffalo.Call=Class.create();Buffalo.Call.prototype={initialize:function(a){this.method=a;this.params=[]},addParameter:function(a){if(typeof a=="undefined")return;this.params[this.params.length]=a},xml:function(){for(var a="<burlap:call>\n<method>"+this.method+"</method>\n",b=0;b<this.params.length;b++){var c=this.params[b];a+=this.getParamXML(this.dataTypeOf(c),c)+"\n"}a+="</burlap:call>";Buffalo.debug&&alert(a);return a},dataTypeOf:function(b){if(b==null)return"null";var a=typeof b;a=a.toLowerCase();switch(a){case"number":if(Math.round(b)==b)a="int";else a="double";break;case"object":var c=b.constructor;if(c==Date)a="date";else if(c==Array)a="list";else a="map"}return a},doValueXML:function(b,c){var d,a=c;if(typeof c=="string"){a=a.replace(/&/g,"&amp;");a=a.replace(/</g,"&lt;");a=a.replace(/>/g,"&gt;");a=a.replace(/\"/g,"&quot;");d="<"+b+">"+a+"</"+b+">"}else d="<"+b+">"+c+"</"+b+">";return d},doBooleanXML:function(b){var a=b==true?1:0,c="<boolean>"+a+"</boolean>";return c},doDateXML:function(b){var a="<date>";a+=dateToISO8609(b);a+="</date>";return a},doArrayXML:function(b){var a="<list>\n";a+="<type></type>\n";a+="<length>"+b.length+"</length>\n";for(var c=0;c<b.length;c++)a+=this.getParamXML(this.dataTypeOf(b[c]),b[c])+"\n";a+="</list>\n";return a},doStructXML:function(a){var d=a[Buffalo.BOCLASS],e=d?d:"java.util.HashMap",c="<map>\n";c+="<type>"+e+"</type>\n";for(var b in a)if(a[b]!=e){if(typeof a[b]=="function")continue;c+=this.getParamXML(this.dataTypeOf(b),b)+"\n";c+=this.getParamXML(this.dataTypeOf(a[b]),a[b])+"\n"}c+="</map>\n";return c},doNullXML:function(){return"<null></null>"},getParamXML:function(c,b){var a;switch(c){case"date":a=this.doDateXML(b);break;case"list":a=this.doArrayXML(b);break;case"map":a=this.doStructXML(b);break;case"boolean":a=this.doBooleanXML(b);break;case"null":a=this.doNullXML();break;default:a=this.doValueXML(c,b)}return a}};function dateToISO8609(a){var b=a.getYear();if(b<2e3)b+=1900;var d=leadingZero(new String(a.getMonth()+1)),f=leadingZero(new String(a.getDate())),e=leadingZero(new String(a.getHours()))+leadingZero(new String(a.getMinutes()))+leadingZero(new String(a.getSeconds())),c=b+d+f+"T"+e+"Z";return c}function leadingZero(a){if(a.length==1)a="0"+a;return a}Buffalo.Reply=Class.create();Buffalo.Reply.prototype={initialize:function(b){this._isFault=false;this._type="null";this._objects=[];this._objectNodes=[];var a;if(typeof b=="string"){this._source=b;a=this.constructNodeFromXmlStringInIEOrFF(this._source)}else{this._source=b.responseText;if(b.responseXML)a=b.responseXML.documentElement;if(!a||!a.tagName)a=this.constructNodeFromXmlStringInIEOrFF(this._source)}Buffalo.debug&&alert(this._source);this.dataNode=a.firstChild;this._type=this._getType(this.dataNode)},constructNodeFromXmlStringInIEOrFF:function(b){var a=XmlDocument.create();a.async=false;a.loadXML(b);return a.documentElement},getType:function(){return this._type},getResult:function(){return this.deserialize(this.dataNode)},isFault:function(){return this._type=="fault"},isNull:function(){return this._type=="null"},getSource:function(){return this._source},deserialize:function(a){var b,c=this._getType(a);switch(c){case"boolean":b=this.doBoolean(a);break;case"date":b=this.doDate(a);break;case"double":b=this.doDouble(a);break;case"int":case"long":b=this.doInt(a);break;case"list":b=this.doList(a);break;case"map":b=this.doMap(a);break;case"null":b=this.doNull(a);break;case"ref":b=this.doRef(a);break;case"string":b=this.doString(a);break;case"xml":b=this.doXML(a);break;case"fault":b=this.doFault(a)}return b},_getType:function(a){return a.tagName.toLowerCase()},getNodeText:function(a){return a.childNodes.length==0?null:a.firstChild.nodeValue},doBoolean:function(a){var b=this.getNodeText(a);return b=="1"},doDate:function(b){var a=this.getNodeText(b),g=parseInt(a.substring(0,4),"10"),e=parseInt(a.substring(4,6),"10")-1,h=parseInt(a.substring(6,8),"10"),f=parseInt(a.substring(9,11),"10"),c=parseInt(a.substring(11,13),"10"),d=parseInt(a.substring(13,15),"10"),i=new Date(g,e,h,f,c,d);return i},doDouble:function(a){var b=this.getNodeText(a);return parseFloat(b)},doInt:function(a){var b=this.getNodeText(a);return parseInt(b)},doList:function(d){var a=[];this._objects[this._objects.length]=a;for(var c=d.childNodes,b=2;b<c.length;b++)a[a.length]=this.deserialize(c[b]);return a},doMap:function(d){var c={};this._objects[this._objects.length]=c;var a=d.childNodes;c[Buffalo.BOCLASS]=this.getNodeText(a[0]);for(var b=1;b<a.length;b+=2)if(a[b+1].hasChildNodes())c[this.getNodeText(a[b])]=this.deserialize(a[b+1]);else c[this.getNodeText(a[b])]=a[b+1].text;return c},doNull:function(){return null},doRef:function(a){var b=this.getNodeText(a),c=parseInt(b);return this._objects[c]},doString:function(b){var a=this.getNodeText(b);return a==null?"":a},doXML:function(a){var b=this.getNodeText(a);return unescape(b)},doFault:function(a){var c=this.getNodeText(a.childNodes[1]),d=this.getNodeText(a.childNodes[3]),b=this.deserialize(a.childNodes[5]);return new Buffalo.Fault(c,d,b)}};Buffalo.Fault=Class.create();Buffalo.Fault.prototype={initialize:function(c,a,b){this.code=c;this.message=a;this.detail=b},toString:function(){return"Buffalo.Fault:[code="+this.code+", message="+this.message+", detail="+this.detail+"]"}};Object.extend(Buffalo.prototype,{bindReply:function(b,c,a){this.remoteCall(b,c,function(b){Buffalo.Bind.bind(a,b.getResult())})}});Buffalo.Bind={bind:function(c,b){var a=Buffalo.getElementById(c);switch(a.tagName){case"INPUT":switch(a.type.toLowerCase()){case"text":case"hidden":case"password":Buffalo.BindFactory.bindText(a,b);break;case"checkbox":case"radio":Buffalo.BindFactory.bindRadioOrCheckbox(a,b)}break;case"TEXTAREA":Buffalo.BindFactory.bindText(a,b);break;case"TABLE":Buffalo.BindFactory.bindTable(a,b);break;case"SELECT":Buffalo.BindFactory.bindSelect(a,b);break;case"DIV":case"SPAN":alert(b);a.innerHTML=b}}};Buffalo.BindFactory={reportError:function(c,b,a){throw"Data bind failed: "+a;},bindText:function(b,a){b.value=a},bindRadioOrCheckbox:function(c,a){var b=false;switch(typeof a){case"boolean":b=a;break;case"string":b=a=="1"||a=="true"||a=="yes";break;case"number":b=parseInt(a)==1;break;default:b=false}c.checked=b},bindSelect:function(c,d){(typeof d!="object"||d.constructor!=Array)&&this.reportError(c,d,"Array Type Needed for binding select!");while(c.childNodes.length>0)c.removeChild(c.childNodes[0]);for(var e=0;e<d.length;e++){var a=document.createElement("OPTION"),b=d[e];if(b==null||typeof b=="undefined"){a.value="";a.text=""}if(typeof b!="object"){a.value=b;a.text=b}else{a.value=b[c.getAttribute("jvalue")];a.text=b[c.getAttribute("jtext")]}c.options.add(a)}},bindTable:function(g,f){var i=parseInt(g.getAttribute("jheight")),c=[],d=g.getElementsByTagName("TBODY")[0];if(g.getElementsByTagName("TBODY").length>0)while(d.rows.length>i)d.deleteRow(i);if(i==0){for(var l in f[0])c[c.length]=l;for(var m=g.insertRow(g.rows.length),a=0;a<c.length;a++){var k=m.insertCell(m.cells.length);k.innerHTML=c[a]}for(var a=0;a<f.length;a++){var b=g.insertRow(g.rows.length),j=f[a];for(l in j){var k=b.insertCell(b.cells.length);k.innerHTML=j[l]}}}if(i==1){for(var h=d.rows[0],a=0;a<h.cells.length;a++)c[c.length]=h.cells[a].getAttribute("jtext");for(var a=0;a<f.length;a++)for(var b=d.insertRow(d.rows.length),j=f[a],e=0;e<c.length;e++){var k=b.insertCell(b.cells.length);k.innerHTML=j[c[e]]}}if(i==2){for(var h=d.rows[0],a=0;a<h.cells.length;a++)c[c.length]=h.cells[a].getAttribute("jtext");for(var a=0;a<f.length;a++){var b;if(a==0)b=g.rows[1];else b=g.rows[1].cloneNode(true);a>0&&d.appendChild(b);for(var j=f[a],e=0;e<b.cells.length;e++){var k=b.cells[e];k.innerHTML=j[c[e]]}}}if(i>=3){for(var h=d.rows[0],a=0;a<h.cells.length;a++)c[c.length]=h.cells[a].getAttribute("jtext");for(var a=0;a<f.length;a++){var b;if(a==0)b=d.rows[1];else if(a==1)b=d.rows[2];else if(a%2==0)b=d.rows[1].cloneNode(true);else if(a%2==1)b=d.rows[2].cloneNode(true);a>1&&d.appendChild(b);for(var j=f[a],e=0;e<b.cells.length;e++){var k=b.cells[e];k.innerHTML=j[c[e]]}}}},bindRepeater:function(){}};Buffalo.bind=Buffalo.Bind.bind;Buffalo.View=Class.create();Buffalo.View.LAST_VIEWNAME=null;Buffalo.View.CURRENT_VIEW=null;Buffalo.View.HOME_VIEW=null;Buffalo.View.HISTORY_IFRAME_ID="buffalo-view-history-iframe";Buffalo.View.iframeLoaded=function(d){var c=d.href,b=c.indexOf("?"),a="";if(b>-1)a=c.substring(b+1);if(a=="")a=Buffalo.View.HOME_VIEW;Buffalo.View.CURRENT_VIEW!=null&&Buffalo.View.CURRENT_VIEW.doSwitchPart(a)};Buffalo.View.prototype={initialize:function(a){this.buffalo=a},switchPart:function(h,a,e,f){this.partId=h;this.viewName=a;if(typeof e=="undefined"||e==true)this.addToHistory=true;else this.addToHistory=false;if(Buffalo.View.LAST_VIEWNAME==null){Buffalo.View.HOME_VIEW=a;this.doSwitchPart(a,f);Buffalo.View.LAST_VIEWNAME=a;return}Buffalo.View.CURRENT_VIEW=this;if(this.addToHistory)if(document.getElementById(Buffalo.View.HISTORY_IFRAME_ID)){var c=document.getElementById(Buffalo.View.HISTORY_IFRAME_ID).src,d=c,g=c.indexOf("?");if(g>-1)d=c.substr(0,g);d+="?"+a;document.getElementById(Buffalo.View.HISTORY_IFRAME_ID).src=d}else{var b="It seems that you havent add the buffalo-blank.html as an Iframe for browser history.";b+="\nSo this view cannot add to browser history.";b+="\n\nTo prevent this dialog, use buffalo.switchPart(partId, viewName, false) or ";b+="add the buffalo-blank.html to your main page with id 'buffalo-view-history-iframe'.";alert(b)}this.doSwitchPart(a,f);Buffalo.View.LAST_VIEWNAME=a},doSwitchPart:function(a,d){this.buffalo.transport=XmlHttp.create();var b=a;this.buffalo.callback=d;try{if(/MSIE/.test(navigator.userAgent)){var c="_bfviewhackkey_="+(new Date).getTime();if(a.indexOf("?")>-1)b+="&"+c;else b+="?"+c}this.buffalo.transport.open("POST",b,this.buffalo.async)}catch(f){var e="Buffalo View Error: \n\n Cannot find view with name: ["+a+"]";alert(e)}this.buffalo.transport.send(null);if(this.buffalo.async){this.buffalo.transport.onreadystatechange=this._viewHandle.bind(this);this.buffalo.events.onLoading(true)}else this._processView();Buffalo.View.LAST_VIEWNAME=a},_viewHandle:function(){this._processView()},_processView:function(){if(this.buffalo.transport.readyState==4)if(this.buffalo.transport.status=="200"){var a=this.buffalo.transport.responseText;Buffalo.debug&&alert(a);this.buffalo.events.onLoading(false);this._showView(this.partId,this.viewName,a);this.buffalo.callback!=null&&this.buffalo.callback()}else this.buffalo.events.onError(this.buffalo.transport.responseText)},_showView:function(e,h,c){var d=/<script(.|\n)*?>(.|\n|\r\n)*?<\/script>/ig,g=/<script(.|\n)*?>((.|\n|\r\n)*)?<\/script>/im;document.getElementById(e).innerHTML=c.replace(d,"");var a=c.match(d);if(a)for(var b=0;b<a.length;b++){var f=a[b].match(g);this._executeScript(f[2],e)}},_executeScript:function(d,e){var b=e+"_SCRIPT_CONTAINER",c=document.getElementById(b),f=document.getElementsByTagName("SCRIPT");c!=null&&document.body.removeChild(c);var a=document.createElement("SCRIPT");a.setAttribute("id",b);a.text=d;document.body.appendChild(a)}};Object.extend(Buffalo.prototype,{switchView:function(b,a){this.switchPart("body",b,true,a)},switchPart:function(d,c,a,b){(new Buffalo.View(this)).switchPart(d,c,a,b)},changeLayout:function(){}});Buffalo.Form={formToBean:function(f,k,d){var b={};if(k)b[Buffalo.BOCLASS]=k;else b[Buffalo.BOCLASS]="java.util.Map";if(typeof d=="undefined"||d==true)d=true;else d=false;if(typeof f=="string")f=document.getElementById(f);for(var j=f.elements,h=0;h<j.length;h++){var a=j[h];switch(a.type){case"radio":if(a.checked)b[a.name]=a.value;break;case"checkbox":if(!b[a.name])b[a.name]=[];a.checked&&b[a.name].push(a.value);break;case"select-one":var e="",c,l=a.selectedIndex;if(l>=0){c=a.options[l];e=c.value;if(!e&&!("value"in c))e=c.text}b[a.name]=e;break;case"select-multiple":if(!b[a.name])b[a.name]=[];for(var i=0;i<a.options.length;i++){var c=a.options[i];if(c.selected){var g=c.value;if(!g&&!("value"in c))g=c.text;b[a.name].push(g)}}break;default:if(d){if(a.type!="submit"&&a.type!="button"&&a.type!="reset")b[a.name]=a.value}else b[a.name]=a.value}}return b},validate:function(){}}
