﻿lightWeightBinder= {}; lightWeightBinder.utilities= { addHandler: function addHandler(element,eventName,handler)
{ if (element.addEventListener)
element.addEventListener(eventName, handler, false); else if (element.attachEvent)
element.attachEvent('on' + eventName, handler);}, removeHandler: function removeHandler(element,eventName,handler)
{ if (element.removeEventListener)
element.removeEventListener(eventName, handler, false); else if (element.detachEvent)
element.detachEvent('on' + eventName, handler);}, addInternalHandler: function addInternalHandler(obj,eventName,handler)
{ if (! obj[eventName])
{ obj["_"+eventName]= []; obj[eventName]= function()
{ var handlers= obj["_"+eventName]; for (var i=0;handlers!=null&&i<handlers.length;i++)
handlers[i].apply(obj,arguments);};}
obj["_"+eventName].push(handler);}, removeInternalHandler: function removeInternalHandler(obj,eventName,handler)
{ var handlers= obj["_"+eventName]; if (handlers)
{ for (var i=0;i<handlers.length;i++)
if (handlers[i]==handler)
handlers.splice(i,1); if (handlers.length==0)
{ delete obj[eventName]; delete obj["_"+eventName];}
}
}, createProxy: function createProxy(servicePath,method)
{ var i= method.indexOf("("); var methodName; var argNames= []; if (i>=0)
{ var argList= method.substr(i+1,method.length-i-2); if (argList.length>0)
argNames= argList.split(","); methodName= method.substr(0,i);}
else
methodName= method; var that= this; return function(){ that._invoke(servicePath,methodName,argNames,arguments);};}, _createHttpRequestor: function _createHttpRequestor()
{ var prefix= 'Msxml2'; for (;;)
{ try
{ var rc= new ActiveXObject(prefix+".XMLHTTP"); return rc;}
catch(ex)
{ }
if (prefix=='Msxml2')
prefix= 'Microsoft'; else
break;}
return new XMLHttpRequest();}, _invoke: function _invoke(servicePath,methodName,argNames,args)
{ var r= this._createHttpRequestor(); r.open("POST",servicePath+"/"+methodName,true); r.setRequestHeader("Content-Type","application/json; charset=utf-8"); var callback= args[argNames.length]; var error= args[argNames.length+1]; var context= args[argNames.length+2]; r.onreadystatechange= function()
{ if (r.readyState==4)
{ var err; r.onreadystatechange= function(){}; if (r.status<200 || r.status>=300)
err= new Error("HTTP error:"+r.status); if (r.getResponseHeader("Content-Type").indexOf("application/json")>=0)
{ var obj= eval("("+r.responseText+")"); if (r.getResponseHeader("jsonerror")=="true")
err= new Error(obj.Message);}
else
obj= r.responseText; if (err)
if (error)
error(err,context)
else
alert(err.message); else
callback(obj,context); r= null;}
}; var body= "{"; for (var i=0;i<argNames.length;i++)
{ if (body.length>1)
body+=","; body+= "'"+argNames[i]+"':"+this._toJson(args[i]);}
body+= "}"; r.send(body);}, startsWith:function startsWith(s,t)
{ if (s==null)
return false; return s.indexOf(t)==0;}, endsWith:function endsWith(s,t)
{ if (s==null)
return false; var i= s.lastIndexOf(t); return i==s.length-t.length;}, _toJson: function _toJson(obj)
{ switch (typeof(obj))
{ case "string":
return "'"+obj+"'"; default:
return obj.toString();}
}, redirect: function redirect(url)
{ window.location.href= this._makeAbsolute(url);}, _makeAbsolute: function _makeAbsolute(url)
{ return (url.indexOf("://")>=0)?url:window.location.href.replace(/[^/]*$/,url);}, _padzero: function _padzero(i)
{ var s= i.toString(); if (s.length==1)
s= "0"+s; return s;}, _cssToDomName: function _cssToDomName(name)
{ return (name=="inner-html" || name=="inner-text")?"innerHTML":name.replace(/-(.)/,function(str,p1){ return p1.toUpperCase();});}, stringOf: function stringOf(o)
{ return this.objectToLocaleString(o);}, objectFromInvariantString: function objectFromInvariantString(s,type)
{ if (s==null)
{ if (type=="Number")
return 0; else if (type=="Date")
return null; else
return "";}
if (type=="Date")
{ if (! s)
return null; return new Date(parseInt(s.substr(0,4),10),parseInt(s.substr(5,2),10)-1,parseInt(s.substr(8,2),10));}
if (type=="Number")
{ if (! s)
return "0"; return parseInt(s,10);}
if (type=="Boolean")
return s=="1"; return s;}, objectToInvariantString: function objectToInvariantString(o)
{ if (o==null)
return ""; if (typeof(o)=="date" || o instanceof Date)
return o.getFullYear().toString()+"-"+this._padzero(o.getMonth()+1)+"-"+this._padzero(o.getDate())+"T00:00:00"; if (typeof(o)=="boolean" || o instanceof Boolean)
return o?"1":"0"; return o.toString();}, objectFromLocaleString: function objectFromLocaleString(s,type)
{ if (type=="Date")
{ if (!s)
return null; var part= s.split('/'); var y= parseInt(part[2],10); var m= parseInt(part[1],10)-1; var d= parseInt(part[0],10); var dt= new Date(y,m,d); if (dt.getFullYear()!=y || dt.getMonth()!=m || dt.getDate()!=d)
throw new Error("Illegal Date. Please ensure all dates are in the format dd/mm/yyyy, e.g. 01/01/2007"); return dt;}
if (type=="Number")
{ if (! s)
return 0; return parseInt(s,10);}
if (type=="Boolean")
{ return (s=="true") || (s=="on");}
return s;}, objectToLocaleString: function objectToLocaleString(o)
{ if (!o && o!=0)
return ""; if (typeof(o)=="date" || o instanceof Date)
return this._padzero(o.getDate())+"/"+this._padzero(o.getMonth()+1)+"/"+o.getFullYear().toString(); return o.toString();}, _scrollIntoView: function _scrollIntoView(parent,top,height,left,width)
{ if (top<parent.scrollTop)
parent.scrollTop= top; if ((top+height)>parent.scrollTop+parent.clientHeight)
parent.scrollTop= top+height-parent.clientHeight; if (left<parent.scrollLeft)
parent.scrollLeft= left; if ((left+width)>parent.scrollLeft+parent.clientWidth)
parent.scrollLeft= left+width-parent.clientWidth; if (parent.offsetParent)
this._scrollIntoView(parent.offsetParent,top+parent.offsetTop+parent.clientTop-parent.scrollTop,height, left+parent.offsetLeft+parent.clientWidth-parent.scrollLeft,width);}, scrollIntoView: function scrollIntoView(el)
{ if (el.offsetParent)
this._scrollIntoView(el.offsetParent,el.offsetTop,el.offsetHeight,el.offsetLeft,el.offsetWidth);}, coalesce: function coalesce()
{ for (var i=0;i<arguments.length;i++)
if (arguments[i]) return arguments[i]; return null;}, createDelegate: function createDelegate(instance,method)
{ var staticArgs= []; for (var i=2;i<arguments.length;i++)
staticArgs.push(arguments[i]); if (method==null)
alert("null method"); return function()
{ var fullArgs= []; for (var i=0;i<staticArgs.length;i++)
fullArgs.push(staticArgs[i]); for (var i=0;i<arguments.length;i++)
fullArgs.push(arguments[i]); method.apply(instance,fullArgs);}
}, serializeXml: function serializeXml(node)
{ if (window.XMLSerializer)
{ var xmlSerializer = new XMLSerializer(); return xmlSerializer.serializeToString(node);}
else
return node.xml;}, getXmlDoc: function getXmlDoc(markup)
{ if (window.DOMParser)
{ var domParser= new window.DOMParser(); return domParser.parseFromString(markup,"text/xml");}
else
{ var version= ".3.0"; for (;;)
{ try
{ var xd = new ActiveXObject("Msxml2.DOMDocument"+version); xd.async = false; xd.loadXML(markup); xd.setProperty('SelectionLanguage', 'XPath'); return xd;}
catch (ex)
{ }
if (version)
version= ""; else
break;}
}
}, selectSingleNode: function selectSingleNode(node,xpath)
{ if (typeof(node.selectSingleNode)!="undefined")
return node.selectSingleNode(xpath); var nodes= this.selectNodes(node,xpath); return nodes.iter();}, selectNodes: function selectNodes(node,xpath)
{ var rc= {}; if (typeof(node.selectNodes)!="undefined")
{ rc.nodes= node.selectNodes(xpath); rc.i= 0; rc.iter= function() { return this.nodes[this.i++];}
rc.count= function() { return this.nodes.length;}
}
else
{ var doc= node.ownerDocument?node.ownerDocument:node; rc.i= 0; rc.nodes= doc.evaluate(xpath,node,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null); rc.iter= function() { return this.nodes.snapshotItem(this.i++);}
rc.count= function() { return this.nodes.snapshotLength;}
}
return rc;}, getNodeTextContent: function getNodeTextContent(node,text)
{ return (node==null)?"":((typeof(node.text)!="undefined")?node.text:node.textContent);}, setNodeTextContent: function setNodeTextContent(node,text)
{ if (typeof(node.text)!="undefined")
node.text= text; else
node.textContent= text;}, stopPropagation: function stopPropagation(e)
{ if (! e)
e= window.event; if (e && e.stopPropagation)
e.stopPropagation(); else if (e && e.cancelBubble)
e.cancelBubble= true;}, preventDefault: function preventDefault(e)
{ if (! e)
e= window.event; if (e && e.preventDefault)
e.preventDefault(); else if (e)
e.returnValue= false;}, _classRegExp: function(cls)
{ return new RegExp("(^"+cls+" ?)|( "+cls+"(?= |$))");}, addClass: function addClass(el,cls)
{ if (el.className.search(this._classRegExp(cls))==-1)
el.className+= ' '+cls;}, removeClass: function removeClass(el,cls)
{ el.className= el.className.replace(this._classRegExp(cls),"");}
}; lightWeightBinder.nodeList= function(lbm)
{ this.nodes= []; this.lbm= lbm;}; lightWeightBinder.nodeList.prototype= { find: function find(name)
{ for (var i=0,node;node=this.nodes[i];i++)
{ if (node.name.valueOf()==name.valueOf())
return node;}
return null;}, findCreate: function findCreate(name,parent)
{ var node= this.find(name); if (node==null)
{ node= new lightWeightBinder.node(this.lbm,name); node.parent= parent; if (parent._xmlNode && name.charAt(0)!="$")
node._xmlNode= this.lbm._utils.selectSingleNode(parent._xmlNode,name); this.nodes.push(node);}
return node;}, _pathSeparator: '/', _head: function _head(path)
{ var i= path.indexOf(this._pathSeparator); if (i>=0)
return path.substring(0,i); else
return path;}, _tail: function _tail(path)
{ var i= path.indexOf(this._pathSeparator); if (i>=0)
return path.substring(i+1); else
return "";}, findLeafNode: function findLeafNode(path,parent)
{ var node= this.findCreate(this._head(path),parent); var tail= this._tail(path); if (tail.length>0)
node= node.findLeafNode(tail); return node;}
}; lightWeightBinder._expression= function _expression(expr,dataSrc,re,e,attributeName,handlerName,element)
{ var p= []; var rc= expr.replace(re, function (str)
{ if (str.indexOf("/")<0 && str.indexOf("$")<0)
return str; var node= dataSrc._addHandler(str,attributeName,handlerName,element,e); p[p.length]= function()
{ return node.get_Value();}; return "p["+(p.length-1)+"]()";} ); this.evalExpr= function()
{ return eval(rc);}
}; lightWeightBinder._manager= function()
{ this._utils= lightWeightBinder.utilities; this._nodeList= new lightWeightBinder.nodeList(this); this._lists= []; this._constantListNodes= []; this._transients= []; this._doc= this._utils.getXmlDoc("<root/>"); this._xmlNode= this._doc.firstChild; this._triggers= []; this._internalEventHandlerCount= 0; this._externalEventHandlerCount= 0; this._nodeRe= /[$A-Za-z][_a-zA-Z0-9/$]{0,}/ig; this._fullNodeRe= /^[$A-Za-z][_a-zA-Z0-9/$]*$/i; this.noOp= {};}
lightWeightBinder._manager.prototype= { get_Dirty: function get_Dirty()
{ return this._utils.selectSingleNode(this.parent._xmlNode,this.name+"[descendant-or-self::*[@originalValue or @errorMessage or @deleted or @inserted]]")!=null;}, get_ProcessingExternalChange: function get_ProcessingExternalChange()
{ return this._processingExternalChange;}, get_NotificationsEnabled: function get_NotificationsEnabled()
{ return ! this._disableNotifications;}, set_NotificationsEnabled: function set_NotificationsEnabled(value,dontNotify)
{ this._disableNotifications= ! value; if (value && ! dontNotify)
this._notify();}, propertyChanged: function propertyChanged(obj,propertyName)
{ if (obj._nodeList)
{ var node= obj._nodeList.find("$"+propertyName); if (node!=null)
{ if (node.updated)
node.updated();}
}
}, displayError: function displayError(element,errText)
{ if (errText)
{ var err= null; if (element.nextSibling!=null && element.nextSibling.className=="errorMessage")
err= element.nextSibling; if (err==null)
{ err= document.createElement("span"); err.className="errorMessage"; err.appendChild(document.createTextNode(errText)); if (element.nextSibling)
element.parentNode.insertBefore(err,element.nextSibling); else
element.parentNode.appendChild(err);}
else
err.firstChild.data= errText;}
else
{ if (element.nextSibling!=null && element.nextSibling.className=="errorMessage")
element.nextSibling.parentNode.removeChild(element.nextSibling);}
}, _forceXmlNode: function()
{ }, _fillSelectOptionsInt: function(list,doc,listName)
{ var nodes= null; if (doc)
nodes= this._utils.selectNodes(doc,"/root/"+listName); while (list.options.length>0)
list.remove(0); var textName= list.getAttribute("lbm-text"); if (! textName) textName= "text"; var idName= list.getAttribute("lbm-id"); if (! idName) idName= "id"; var node; if (nodes)
while (node= nodes.iter())
{ var opt= new Option(this._utils.getNodeTextContent(this._utils.selectSingleNode(node,textName)), this._utils.getNodeTextContent(this._utils.selectSingleNode(node,idName))); opt.style.cssFloat= "none"; list.options[list.options.length]= opt;}
}, _fillAllSelectOptions: function _fillSelectOptions(lists,doc)
{ for (var i=0,list;list=this._lists[i];i++)
if (! lists || lists.indexOf(list.getAttribute("lbm-list"))>=0)
this._fillSelectOptionsInt(list,doc,list.getAttribute("lbm-list"));}, fillSelectOptions: function fillSelectOptions(element,listName)
{ this._fillSelectOptionsInt(element,this._doc,listName);}, assignValue: function assignValue(nodePath,v,force)
{ var node= this.findNode(nodePath); if (typeof(v)=="number" || v instanceof Number)
node._type= "Number"; else if (typeof(v)=="boolean" || v instanceof Boolean)
node._type= "Number"; else if (typeof(v)=="date" || v instanceof Date)
node._type= "Date"; node.set_Value(v,force);}, assignExpr: function assignExpr(nodePath,expr,force)
{ this.findNode(nodePath).set_Value(this.evalExpr(expr),force);}, addTrigger: function addTrigger(expr)
{ var that= this; var e= new lightWeightBinder.node(this,""); e.parent= this; e.get_Value= function(){ return this._expr.evalExpr();}
e.get_Value_Once= function()
{ this.pec= that._processingExternalChange; if (! this.timer)
this.timer= window.setTimeout(function()
{ e.timer= null; var prev= that._processingExternalChange; that._processingExternalChange= e.pec; e.get_Value(); that._processingExternalChange= prev;},1);}
e._expr= new lightWeightBinder._expression(expr,this,this._nodeRe,e,"","get_Value_Once"); this._triggers.push(e); return e;}, evalExpr: function evalExpr(expr)
{ if (!expr)
return; if (! this._fullNodeRe.test(expr))
{ return this._evalExpr(expr,this._nodeRe);}
else
{ var leafNode= this._nodeList.findLeafNode(expr,this); return leafNode?leafNode.getValueAsString():null;}
}, _evalExpr: function _evalExpr(expr,re)
{ var p= []; var that= this; var rc= expr.replace(re,function (str) { if (str.indexOf("/")<0 && str.indexOf("$")<0) return str; var node= that._nodeList.findLeafNode(str,that); p[p.length]= function(){ return node.get_Value();} ; return "p["+(p.length-1)+"]()";} ); return eval(rc);}, lookup: function lookup(id,listName,valueItem,idItem)
{ var node= this._utils.selectSingleNode(this._doc,"/root/"+listName+"["+(idItem?idItem:"id")+"='"+id+"']/"+(valueItem?valueItem:"text")); return node?this._utils.getNodeTextContent(node):"";}, addHandlers: function addHandlers()
{ if (this._handlersAdded)
return; this._handlersAdded= true; this._lists.length= 0; if (arguments.length>0)
{ for (var i=0,element;element=document.getElementById(arguments[i]);i++)
this.addHandlersForElement(element,true);}
else
{ this.addHandlersForElement(document.body,true);}
while (this._constantListNodes.length>0)
{ var info= this._constantListNodes.pop(); var c= info.tab.get_Count(); var delta= info.count-c; while (delta-->0)
{ var newNode= info.tab.parent._xmlNode.ownerDocument.createElement(info.tab.name); info.tab.parent._xmlNode.appendChild(newNode);}
info.tab.set_Position(0);}
}, removeHandlers: function removeHandlers()
{ if (arguments.length>0)
{ for (var i=0,element;element=document.getElementById(arguments[i]);i++)
this.removeHandlersForElement(element,true);}
else
{ var elements= document.body.all; for (var i=0,element;element=elements[i];i++)
this.removeHandlersForElement(element);}
}, _iterateLbAttributesForElement: function _iterateLbAttributesForElement(element,callback)
{ if (! element.attributes)
return; if (element.attributes.length>40)
{ for (var i=element.attributes.length-1;i>=0;i--)
{ var attrib= element.attributes[i]; if (attrib.nodeName.indexOf("lb:")==0 || attrib.nodeName.indexOf("lb-")==0)
callback(element,attrib.nodeName.toLowerCase(),attrib.nodeValue); else if (! attrib.expando)
break;}
}
else
{ for (var i=0;i<element.attributes.length;i++)
{ var attrib= element.attributes[i]; if (attrib.nodeName.indexOf("lb:")==0 || attrib.nodeName.indexOf("lb-")==0)
callback(element,attrib.nodeName.toLowerCase(),attrib.nodeValue);}
}
}, removeTransients: function removeTransients()
{ var transientIds= []; for (var i=0;i<this.transients.length;i++)
{ transientIds[i]= this._transients[i].id; this.removeHandlersForElement(this._transients[i]);}
this._transients= []; return transientIds;}, addTransients: function addTransients(transientIds)
{ for (var i=0;i<transientIds.length;i++)
this.addHandlersForElement(document.getElementById(transientIds[i]));}, addHandlersForElement: function addHandlersForElement(element,recurse,insideTemplate)
{ if (element.getAttribute("lbm-transient")=="true")
this._transients.push(element); var listName= element.getAttribute("lbm-list"); if (listName)
{ var listNode= this._nodeList.findLeafNode(listName,this); if (element.tagName=="SELECT")
{ this._lists.push(element); this._addExternalHandler(element,"change",this._utils.createDelegate(listNode,listNode._notifySelectChange));}
else if (! insideTemplate)
{ var delegate= this._utils.createDelegate(listNode,listNode._updateList,element); this._addInternalHandler(listNode,"listChanged",delegate,element);}
}
if (element.getAttribute("lbm-index") && ! element.getAttribute("lbm-cloned") && element.parentNode && element.parentNode.tagName)
{ var listName= element.parentNode.getAttribute("lbm-list"); if (listName)
{ var listNode= this._nodeList.findLeafNode(listName,this); if (listNode)
this._addExternalHandler(element,"click",this._utils.createDelegate(listNode,listNode._notifyClick)); var index= parseInt(element.getAttribute("lbm-index")); if (index==0)
this._constantListNodes.push({ tab:listNode }); this._constantListNodes[this._constantListNodes.length-1].count= index+1;}
}
var dlgt= null; var that= this; this._iterateLbAttributesForElement(element, function(element,attribName,attribValue)
{ switch (attribName.substr(3))
{ case "value":
var leafNode= that._addHandler(attribValue,attribName.substr(3),"_updateValue",element); if (leafNode && typeof(element.value)=="string")
dlgt= that._utils.createDelegate(leafNode,leafNode._notifyChange); break; case "enabled":
that._addHandler(attribValue,attribName.substr(3),"_updateEnabled",element); break; case "visible":
that._addHandler(attribValue,attribName.substr(3),"_updateVisible",element); break; default:
if (attribName.substr(3).indexOf("style-")==0)
that._addHandler(attribValue,attribName.substr(9),"_updateStyle",element); else if (attribName.substr(3).indexOf("class-")==0)
that._addHandler(attribValue,attribName.substr(9),"_updateClass",element); else
that._addHandler(attribValue,attribName.substr(3),"_updateAttribute",element); break;}
}); if (dlgt)
this._addExternalHandler(element,(element.type=="radio"||element.type=="checkbox")?"click":"change",dlgt); if (recurse)
{ for (var j=0,child;child=element.childNodes[j];j++)
if (child.getAttribute)
this.addHandlersForElement(child,true);}
}, removeHandlersForElement: function removeHandlersForElement(element,recurse)
{ var handlerInfo= element._handlerInfo; if (handlerInfo)
{ if (handlerInfo.internalHandlers)
for (var i=0,handler;handler= handlerInfo.internalHandlers[i];i++)
{ this._utils.removeInternalHandler(handler.leafNode,handler.eventType,handler.delegate); this.internalEventHandlerCount--;}
if (handlerInfo.externalHandlers)
for (var j=0,handler;handler= handlerInfo.externalHandlers[j];j++)
{ this._utils.removeHandler(handler.element,handler.eventType,handler.delegate); this.externalEventHandlerCount--;}
element._handlerInfo= null;}
if (recurse)
{ for (var j=0,child;child=element.childNodes[j];j++)
if (child.nodeType==1)
this.removeHandlersForElement(child,true);}
}, _addHandler: function _addHandler(expr,attributeName,handlerName,element,target)
{ if (! this._fullNodeRe.test(expr))
{ var e= new lightWeightBinder.node(this,""); e.parent= this; e.get_Value= function() { return this._expr.evalExpr();}
e._expr= new lightWeightBinder._expression(expr,this,this._nodeRe,e,attributeName,handlerName,element); if (element)
{ e[handlerName].call(e,element,attributeName); var handlerInfo= element._handlerInfo; if (! handlerInfo)
{ handlerInfo= element._handlerInfo= {};}
if (! handlerInfo.exprs)
handlerInfo.exprs= []; handlerInfo.exprs[handlerInfo.exprs.length]= e;}
return e;}
else
{ var leafNode= this._nodeList.findLeafNode(expr,this); if (! target)
target= leafNode; if (attributeName=="inner-text" || attributeName=="inner-html" || attributeName=="value")
leafNode._type= (element["type"]=="checkbox")?"Boolean":element.getAttribute("lbm-type"); var delegate= this._utils.createDelegate(target,target[handlerName],element,attributeName); this._addInternalHandler(leafNode,"updated",delegate,element); return leafNode;}
}, _addInternalHandler: function _addInternalHandler(leafNode,eventType,delegate,element)
{ this._utils.addInternalHandler(leafNode,eventType,delegate); this._internalEventHandlerCount++; if (! element)
return; if (! element._handlerInfo)
element._handlerInfo= {}; var handlerInfo= element._handlerInfo; if (! handlerInfo.internalHandlers)
handlerInfo.internalHandlers= []; handlerInfo.internalHandlers[handlerInfo.internalHandlers.length]= { leafNode:leafNode, delegate:delegate, eventType:eventType };}, _addExternalHandler: function _addExternalHandler(element,eventType,delegate)
{ this._utils.addHandler(element,eventType,delegate); this.externalEventHandlerCount++; if (! element._handlerInfo)
element._handlerInfo= {}; var handlerInfo= element._handlerInfo; if (! handlerInfo.externalHandlers)
handlerInfo.externalHandlers= []; handlerInfo.externalHandlers[handlerInfo.externalHandlers.length]= { element:element, delegate:delegate, eventType:eventType };}, findNode: function findNode(path)
{ return this._nodeList.findLeafNode(path,this);}, _removeErrors: null, getChanges: function getChanges(lists)
{ var rc= "<root>"; var nodes= this._utils.selectNodes(this._xmlNode,lists.replace(","," or ")); var node; while (node= nodes.iter())
rc+= this._utils.serializeXml(node); rc+= "</root>"; return rc.replace(this._removeErrors,"");}, perform: function perform(actor,lists,callback)
{ this.addHandlers(); try
{ var args= []; for (var i=3;i<arguments.length;i++)
args[args.length]= arguments[i]; args[args.length]= this._utils.createDelegate(this,this._onServiceComplete); args[args.length]= this._utils.createDelegate(this,this._onServiceFailed); args[args.length]= {lists:lists,callback:callback,args:args }; args[args.length]= null; this._setLoading(lists,true); actor.apply(this,args);}
catch (ex)
{ this._setLoading(lists,false); alert(ex.message);}
}, loadData: function loadData(xml,lists)
{ this.addHandlers(); var doc= this._utils.getXmlDom("<root>"+xml+"</root>"); this._onServiceComplete(doc,{lists:lists});}, loadList: function loadList(listName,list)
{ this.addHandlers(); var doc= this._utils.getXmlDom("<root/>"); for (var i=0;i<list.length;i++)
{ var node= doc.createElement(listName); var child= doc.createElement("text"); node.appendChild(child); child.appendChild(doc.createTextNode(list[i])); doc.firstChild.appendChild(node);}
this.onServiceComplete(doc,{lists:listName});}, _setLoading: function _setLoading(lists,loading)
{ if (! lists)
return; var l= lists.split(","); for (var i=0;i<l.length;i++)
{ var nodeName= l[i]; if (nodeName.charAt(nodeName.length-1)=='+')
nodeName= nodeName.substr(0,nodeName.length-1); this.findNode(nodeName).set_Loading(loading);}
}, _onServiceComplete: function _onServiceComplete(doc,context)
{ if (typeof(doc)=="string")
doc= this._utils.getXmlDoc(doc); this._setLoading(context.lists,false); this._disableNotifications= true; this._fillAllSelectOptions(context.lists,doc); var pendingStack= []; for (var i=0,node;node=this._nodeList.nodes[i];i++)
if (! context.lists || context.lists.indexOf(node.name)>=0)
{ if (node.name.charAt(0)!="$")
{ var appending= context.lists!=null && context.lists.indexOf(node.name+"+")>=0; if (! appending)
{ var p=0; var xmlnodes= this._utils.selectNodes(this._xmlNode,node.name); var xmlnode; var j= 0; while (xmlnode= xmlnodes.iter())
{ var selected= false; if (xmlnode==node._xmlNode)
{ p= j; selected= true;}
xmlnode.parentNode.removeChild(xmlnode); if (selected)
node._xmlNode= null; if (node.listChanged)
node.listChanged("remove",{ index:0,selected:selected }); j++;}
}
var selnode= node._xmlNode; var insertAt= selnode; if (doc)
{ xmlnodes= this._utils.selectNodes(doc,"/root/"+node.name); var xmlnode; var j=0; if (appending)
j= node.get_Position(); var pending= { node:node, p:p, appending:appending }; while (xmlnode=xmlnodes.iter())
{ if (insertAt && insertAt.nextSibling)
this._xmlNode.insertBefore(xmlnode,insertAt.nextSibling); else
this._xmlNode.appendChild(xmlnode); insertAt= xmlnode; if (! pending.start)
pending.start= xmlnode; pending.finish= xmlnode;}
}
if (pending.start)
pendingStack.push(pending); node._flagDirty();}
}
while (pendingStack.length>0)
{ var pending= pendingStack.pop(); var xmlnode= pending.start; var node= pending.node; var selnode= pending.node._xmlNode; var j=0; if (appending)
j= node.get_Position()+1; for (;;)
{ var selected= false; if (!pending.appending && (! selnode))
{ selnode= xmlnode; selected= true;}
if (node.listChanged)
{ node._xmlNode= xmlnode; node._selectChildNodes(); node.listChanged("insert",{index:j,selected:selected});}
j++; if (xmlnode==pending.finish)
break; else
xmlnode= xmlnode.nextSibling;}
node._xmlNode= selnode; node._selectChildNodes();}
this._disableNotifications= false; if (! doc || this._utils.selectSingleNode(this._doc,"/"+"/"+"*[@errorMessage]")==null)
{ if (context && context.callback)
context.callback(context);}
for (var i=0,node;node=this._nodeList.nodes[i];i++)
if (! context.lists || context.lists.indexOf(node.name)>=0)
{ node._notify(true);}
}, _onServiceFailed: function _onServiceFailed(error)
{ alert("Service Error:"+error.message?error.message:error.get_message());}, _notify: function _notify()
{ for (var i=0,node;node=this._nodeList.nodes[i];i++)
node._notify(true);}
}
lightWeightBinder.manager= new lightWeightBinder._manager(); lightWeightBinder.node= function(lbm,name)
{ this.parent= null; this._nodeList= null; this.name= name; this.lbm= lbm; this._xmlNode= null; this._type= null; this._clickHandlers= {}; this._loading= false;}
lightWeightBinder.node.prototype= { get_Value: function get_Value()
{ if (this._xmlNode)
{ return lightWeightBinder.utilities.objectFromInvariantString(this.lbm._utils.getNodeTextContent(this._xmlNode),this._type);}
if (this.name.charAt(0)=='$')
return this.parent["get_"+this.name.substr(1)](); return lightWeightBinder.utilities.objectFromInvariantString(null,this._type);}, set_Value: function set_Value(value,force)
{ this._forceXmlNode(); if (this._xmlNode)
{ var prevValue= this.lbm._utils.getNodeTextContent(this._xmlNode); var newValue= lightWeightBinder.utilities.objectToInvariantString(value); if (prevValue.replace(/\n|\r/g,"")==newValue.replace(/\n|\r/g,"") && ! force)
return; this.lbm._utils.setNodeTextContent(this._xmlNode,newValue); if (this._xmlNode.getAttribute("originalValue")==null)
this._xmlNode.setAttribute("originalValue",prevValue); else if (this._xmlNode.getAttribute("originalValue")==newValue)
this._xmlNode.removeAttribute("originalValue"); this._notify(); this._flagDirty(true);}
}, get_Error: function get_Error()
{ if (this._xmlNode)
return this._xmlNode.getAttribute("errorMessage"); return null;}, get_Position: function get_Position()
{ if (this._xmlNode && this._xmlNode.parentNode)
{ var nodes= this.lbm._utils.selectNodes(this._xmlNode.parentNode,this.name+"[not (@deleted)]"); var node; var i= 0; while (node=nodes.iter())
{ if (node==this._xmlNode)
return i; i++;}
}
return -1;}, set_Position: function set_Position(index)
{ if (typeof(index)=="string" || index instanceof String)
index= parseInt(index); if (index==-1)
this._setXmlNode(null); else
this._goInternal(index+1);}, get_Count: function get_Count()
{ if (! this.parent || ! this.parent._xmlNode)
return 0; return this.lbm._utils.selectNodes(this.parent._xmlNode,this.name+"[not (@deleted)]").count();}, get_HasErrors: function get_HasErrors()
{ if (! this._xmlNode)
return false; return this.lbm._utils.selectSingleNode(this._xmlNode,"descendant-or-self::*[@errorMessage]")!=null;}, get_Dirty: function get_Dirty()
{ if (! this.parent || ! this.parent._xmlNode)
return false; return this.lbm._utils.selectSingleNode(this.parent._xmlNode,this.name+"[descendant-or-self::*[@originalValue or @errorMessage or @deleted or @inserted]]")!=null;}, get_Loading: function get_Loading()
{ return this.loading;}, set_Loading: function set_Loading(l)
{ this.loading= l; this.lbm.propertyChanged(this,"Loading");}, getValueAsString: function getValueAsString()
{ return this.lbm._utils.stringOf(this.get_Value());}, _findTemplate: function _findTemplate(element,name,exact)
{ var defTemplate= null; var child= element.firstChild; while (child)
{ if (child.getAttribute && child.getAttribute("lbm-template")=="item" && ! child.getAttribute("lbm-cloned"))
defTemplate= child; if (child.getAttribute && child.getAttribute("lbm-template")==name && ! child.getAttribute("lbm-cloned"))
return child; child= child.nextSibling;}
return exact?null:defTemplate;}, _cloneTemplate: function _cloneTemplate(element,classPrefix,selected,index,exact)
{ var template= this._findTemplate(element,selected?"selectedItem":"item",exact); if (!template) return null; var newItem= template.cloneNode(true); newItem.style.display= ""; var delegate= this.lbm._utils.createDelegate(this,this._notifyClick); this._clickHandlers[newItem.uniqueID]= delegate; this.lbm._utils.addHandler(newItem,"click",delegate); newItem.setAttribute("lbm-index",index); if (this.get_HasErrors())
this.lbm._utils.addClass(newItem,classPrefix+"errorItem"); if (selected)
this.lbm._utils.addClass(newItem,classPrefix+"selectedItem"); this.lbm._utils.addClass(newItem,classPrefix+((index%2==0)?"item":"alternateItem")); this._updateChildProperties(newItem,selected); newItem.setAttribute("lbm-cloned","true"); return newItem;}, _forceXmlNode: function _forceXmlNode()
{ if (! this._xmlNode)
{ this.parent._forceXmlNode(); this._xmlNode= this.parent._xmlNode.ownerDocument.createElement(this.name); this.parent._xmlNode.appendChild(this._xmlNode);}
}, _notify: function _notify(recurse)
{ if (! this.lbm._disableNotifications)
{ if (this.updated)
this.updated();}
this.lbm.propertyChanged(this,"Position"); if (recurse && this._nodeList!=null)
for (var j= 0,node;node=this._nodeList.nodes[j];j++)
{ node._notify(recurse); if (node.name.charAt(0)!="$" && this._xmlNode)
{ if (node.listChanged)
node._fillList(node.listChanged);}
}
}, _fillList: function _fillList(handler,appending,parentNotSelected)
{ var prevDisableNotifications= lightWeightBinder._disableNotifications; this.lbm._disableNotifications= true; var p= this.get_Position(); if (handler && ! appending)
handler("remove",{all:true,selectedIndex:p }); if (this.parent._xmlNode!=null)
{ var prevNode= this._xmlNode; var nodes= this.lbm._utils.selectNodes(this.parent._xmlNode,this.name+"[not(@deleted)]"); var node; var i= appending?(this.get_Position()+1):0; while (node= nodes.iter())
{ this._xmlNode= node; this._selectChildNodes(); if (handler)
handler("insert",{index:i,selected:(node==prevNode)&&!parentNotSelected}); i++;}
this._xmlNode= prevNode; this._selectChildNodes();}
this.lbm._disableNotifications= prevDisableNotifications;}, _selectChildNodes: function _selectChildNodes(keepPosition)
{ if (this._nodeList)
for (var j=0,node;node=this._nodeList.nodes[j];j++)
{ if (node.name.charAt(0)!="$")
{ var p= keepPosition?node.getPosition():0; if (p<0) p= 0; node._xmlNode= this._xmlNode?this.lbm._utils.selectSingleNode(this._xmlNode,node.name+"[not (@deleted)]["+(p+1)+"]"):null;}
if (node._nodeList)
node._selectChildNodes(keepPosition);}
}, _notifyChange: function _notifyChange(ev)
{ var previousValue= null; var target= ev.target?ev.target:ev.srcElement; try
{ this.lbm._processingExternalChange= target; previousValue= this.getValueAsString(); if (target.type=="checkbox")
this.set_Value(target.checked,"Boolean"); else
this.set_Value(this.lbm._utils.objectFromLocaleString(target.value,this._type)); this.lbm._processingExternalChange= null;}
catch(ex)
{ this.lbm._processingExternalChange= null; if (ex!=null && ex.message!="SILENT")
alert(ex.message?ex.message:"Illegal value"); target.value= previousValue; this.set_Value(lightWeightBinder.utilities.objectFromLocaleString(target.value,this._type)); target.focus();}
}, _notifySelectChange: function _notifySelectChange(ev)
{ this._setXmlNode(this.lbm._utils.selectSingleNode(this.parent._xmlNode,this.name+"[id='"+(ev.target?ev.target:ev.srcElement).value+"']")); this.lbm._utils.preventDefault(ev);}, _notifyClick: function _notifyClick(ev)
{ var item= ev.target?ev.target:ev.srcElement; var isLink= (item.tagName=="A"); var indexItem= null; while (item && item.getAttribute && ! this.lbm._utils.endsWith(item.getAttribute("lbm-list"),this.name))
{ if (item.getAttribute("lbm-index")!=null)
indexItem= item; item= item.parentNode;}
if (indexItem)
{ this.set_Position(parseInt(indexItem.getAttribute("lbm-index")),true); if (! isLink)
this.lbm._utils.preventDefault(ev);}
}, findLeafNode: function findLeafNode(tail)
{ if (tail.length>0)
{ if (this._nodeList==null)
this._nodeList= new lightWeightBinder.nodeList(this.lbm); return this._nodeList.findLeafNode(tail,this);}
}, _findItem: function _findItem(element,index)
{ var child= element.firstChild; while (child)
{ if (child.getAttribute && child.getAttribute("lbm-index")==index.toString())
return child; child=child.nextSibling;}
return null;}, _updateList: function _updateList(element,op,args)
{ var classPrefix= ""; var child= element.firstChild; while (child!=null)
{ if (child && child.getAttribute && child.getAttribute("lbm-template") && child.getAttribute("lbm-index")==null && child.className)
{ classPrefix= child.className+"_"; break;}
child= child.nextSibling;}
var newItem= null; if (element.tagName!="SELECT")
{ if (op=="remove")
{ var child= element.firstChild; while (child)
{ var nextChild= child.nextSibling; if (child && child.getAttribute && child.getAttribute("lbm-cloned")=="true" && (args.all || child.getAttribute("lbm-index")==args.index))
{ if (args.selected || parseInt(child.getAttribute("lbm-index"))==args.selectedIndex)
this.lbm.removeHandlersForElement(child); var delegate= this._clickHandlers[child.uniqueID]; if (delegate)
{ this.lbm._utils.removeHandler(child,"click",delegate); delete this._clickHandlers[child.uniqueID];}
var decPoint= child.nextSibling; while (decPoint && decPoint.getAttribute)
{ decPoint.setAttribute("lbm-index",parseInt(decPoint.getAttribute("lbm-index"))-1); decPoint= decPoint.nextSibling;}
element.removeChild(child); if (!args.all)
break;}
child= nextChild;}
}
else if (op=="insert")
{ var item= this._cloneTemplate(element,classPrefix,args.selected,args.index); if (item)
{ var c= element.firstChild; var found= false; var foundTemplate= false; while (c)
{ var nextc= c.nextSibling; if (c.getAttribute)
{ if (foundTemplate && ! c.getAttribute("lbm-template"))
break; if (found)
if (c.getAttribute("lbm-index"))
c.setAttribute("lbm-index",parseInt(c.getAttribute("lbm-index"))+1); if (c.getAttribute("lbm-index")==args.index)
{ element.insertBefore(item,c); nextc= c; found= true;}
if (c.getAttribute("lbm-template"))
foundTemplate= true;}
c= nextc;}
if (! found)
{ if (c)
element.insertBefore(item,c); else
element.appendChild(item);}
if (args.selected)
this.lbm._utils.scrollIntoView(item);}
}
else if (op=="deselect")
{ var oldItem= this._findItem(element,args.index); if (oldItem)
{ this.lbm._utils.removeClass(oldItem,classPrefix+"selectedItem"); if (oldItem.getAttribute("lbm-cloned"))
{ this.lbm.removeHandlersForElement(oldItem,true); if (oldItem.getAttribute("lbm-template")=="selectedItem")
{ newItem= this._cloneTemplate(element,classPrefix,false,args.index); element.insertBefore(newItem,oldItem); element.removeChild(oldItem);}
}
}
}
else if (op=="select")
{ var item= this._findItem(element,args.index); if (item)
{ if (item.getAttribute("lbm-cloned"))
{ newItem= this._cloneTemplate(element,classPrefix,true,args.index,true); if (newItem)
{ element.insertBefore(newItem,item); element.removeChild(item); item= newItem;}
}
this.lbm._utils.addClass(item,classPrefix+"selectedItem"); if (item.getAttribute("lbm-cloned"))
this.lbm.addHandlersForElement(item,true); this.lbm._utils.scrollIntoView(item);}
}
}
}, _updateChildProperties: function _updateChildProperties(child,selected)
{ if (selected)
this.lbm.addHandlersForElement(child,true,true); var listPath= child.getAttribute("lbm-list"); if (listPath)
{ var listNode= this.lbm.findNode(listPath); var delegate= this.lbm._utils.createDelegate(listNode,listNode._updateList,child); listNode._fillList(delegate,false,!selected);}
var that= this; this.lbm._iterateLbAttributesForElement(child, function(element,attribName,attribValue)
{ var v= this.lbm.evalExpr(attribValue); switch (attribName.substr(3))
{ case "enabled":
that._setEnabled(element,v); break; case "visible":
that._setVisible(element,v); break; default:
if (attribName.substr(3).indexOf("style-")==0)
that._updateStyle(element,attribName.substr(9),v); else if (attribName.substr(3).indexOf("class-")==0)
that._updateClass(element,attribName.substr(9),v); else
that._updateAttribute(element,attribName.substr(3),v); break;}
}); for (var i=0;i<child.childNodes.length;i++)
{ var node= child.childNodes[i]; if (node.getAttribute && !node.getAttribute("lbm-template"))
this._updateChildProperties(node,selected);}
}, _updateValue: function _updateValue(element)
{ var handled= false; var v= this.getValueAsString(); if (this.lbm.beforeUpdateValue)
handled= this.lbm.beforeUpdateValue(this,element,v); if (! handled && typeof(element.value)=="string")
{ if (element.type=="checkbox")
element.checked= this.get_Value(); else if (element.type=="radio")
element.checked= v==element.value; else
{ if (element.type=="select-one" && ! v)
element.selectedIndex= -1; else
element.value= v;}
}
if (this.lbm.afterUpdateValue)
this.lbm.afterUpdateValue(this,element,v); this.lbm.displayError(element,this.get_Error());}, _updateEnabled: function _updateEnabled(element)
{ this._setEnabled(element,this.get_Value());}, _setEnabled: function(element,enabled)
{ if (this.lbm.beforeUpdateEnabled)
if (this.lbm.beforeUpdateEnabled(this,element,enabled))
return; if (enabled)
{ element.removeAttribute("disabled"); this.lbm._utils.removeClass(element,"disabled");}
else
{ this.lbm._utils.addClass(element,"disabled"); element.setAttribute("disabled","disabled");}
if (this.lbm.afterUpdateEnabled)
this.lbm.afterUpdateEnabled(this,element,enabled);}, _updateVisible: function _updateVisible(element)
{ this._setVisible(element,this.get_Value());}, _setVisible: function(element,visible)
{ if (this.lbm.beforeUpdateVisible)
if (this.lbm.beforeUpdateVisible(this,element,visible))
return; if (visible)
element.style.display= ""; else
element.style.display= "none"; if (this.lbm.afterUpdateVisible)
this.lbm.afterUpdateVisible(this,element,visible);}, _updateAttribute: function updateAttribute(element,attribName,v)
{ if (arguments.length<3)
v= this.getValueAsString(); if (v==this.lbm.noOp)
return; if (this.lbm.beforeUpdateAttribute)
if (this.lbm.beforeUpdateAttribute(this,element,attribName,v))
return; if (element[this.lbm._utils._cssToDomName(attribName)]!= v)
try
{ element[this.lbm._utils._cssToDomName(attribName)]= v;}
catch (ex)
{ }
if (this.lbm.afterUpdateAttribute)
this.lbm.afterUpdateAttribute(this,element,attribName,v);}, _updateStyle: function updateStyle(element,styleName,v)
{ if (arguments.length<3)
v= this.getValueAsString(); if (this.lbm.beforeUpdateStyle)
if (this.lbm.beforeUpdateStyle(this,element,styleName,v))
return; if (element.style[this.lbm._utils._cssToDomName(styleName)]!= v)
element.style[this.lbm._utils._cssToDomName(styleName)]= v; if (this.lbm.afterUpdateStyle)
this.lbm.afterUpdateStyle(this,element,styleName,v);}, _updateClass: function _updateClass(element,className,v)
{ if (arguments.length<3)
v= this.get_Value(); if (this.lbm.beforeUpdateClass)
if( this.lbm.beforeUpdateClass(this,element,className,b))
return; if (v)
this.lbm._utils.addClass(element,className); else
this.lbm._utils.removeClass(element,className); if (this.lbm.afterUpdateClass)
this.lbm.afterUpdateClass(this,element,className,b);}, _flagDirty: function _flagDirty(dirty)
{ var node= this; while (node)
{ this.lbm.propertyChanged(node,"Dirty"); node= node.parent;}
}, _setXmlNode: function _setXmlNode(newNode,dirty)
{ if (this._xmlNode==newNode)
return; if (dirty)
{ this._flagDirty(true); this.lbm.propertyChanged(this,"Count");}
var handler= null; if (! lightWeightBinder.disableNotifications)
handler= this.listChanged; if (handler && this._xmlNode && ! dirty)
handler("deselect",{ index:this.get_Position()}); this._xmlNode= newNode; this._selectChildNodes(); if (handler && this._xmlNode && ! dirty)
handler("select",{ index:this.get_Position()}); this._notify(true);}, insertBeforeCurrent: function insertBeforeCurrent()
{ if (this._xmlNode)
{ if (this.listChanged)
this.listChanged("deselect",{ index:this.get_Position()}); var newNode= this._xmlNode.ownerDocument.createElement(this.name); this.parent._xmlNode.insertBefore(newNode,this._xmlNode); newNode.setAttribute("inserted","true"); this._setXmlNode(newNode,true); if (this.listChanged)
this.listChanged("insert",{ index:this.get_Position(), selected:true });}
}, insertAfterCurrent: function insertAfterCurrent()
{ if (this._xmlNode)
{ if (this.listChanged)
this.listChanged("deselect",{ index:this.get_Position()}); var newNode= this._xmlNode.ownerDocument.createElement(this.name); if (this._xmlNode.nextSibling)
this.parent._xmlNode.insertBefore(newNode,this._xmlNode.nextSibling); else
this.parent._xmlNode.appendChild(newNode); newNode.setAttribute("inserted","true"); this._setXmlNode(newNode,true); if (this.listChanged)
this.listChanged("insert",{ index:this.get_Position(),selected:true});}
}, hasValue: function hasValue(value,name)
{ if (! this.parent)
return null; return this.lbm._utils.selectSingleNode(this.parent._xmlNode,this.name+"["+(name?name:"id")+"='"+value+"']");}, goToValue: function goToValue(value,name)
{ var node= this.hasValue(value,name); this._setXmlNode(node); return (node!=null);}, append: function append()
{ if (this.parent)
{ if (this.listChanged)
this.listChanged("deselect",{ index:this.get_Position()}); var newNode= this.parent._xmlNode.ownerDocument.createElement(this.name); this.parent._xmlNode.appendChild(newNode); newNode.setAttribute("inserted","true"); this._setXmlNode(newNode,true); if (this.listChanged)
this.listChanged("insert",{ index:this.get_Count()-1, selected:true});}
}, clearRange: function clearRange(initialCond,whileCond)
{ if (this.parent)
{ var nodes= this.lbm._utils.selectNodes(this.parent._xmlNode,this.name); var node; var handler= this.listChanged; var prevNode= this._xmlNode; var doNothing= true; var i= 0; var p= initialCond.position; var test= whileCond.test; if (nodes)
while (node= nodes.iter())
{ if (i==p)
doNothing= false; if (! doNothing)
{ this._xmlNode= node; this._selectChildNodes(); if (! this.lbm.evalExpr(test))
break; if (handler)
{ this._xmlNode= node; handler("remove",{ index:this.get_Position()});}
this.parent._xmlNode.removeChild(node);}
i++;}
this._xmlNode= prevNode; this._selectChildNodes();}
}, deleteCurrent: function deleteCurrent(goPrevious)
{ if (this._xmlNode)
{ var prevNode= this._xmlNode; var nextNode= this._getAdjacent(! goPrevious); if (prevNode==nextNode)
nextNode= this._getAdjacent(goPrevious); if (prevNode==nextNode)
nextNode= null; var pos= this.get_Position(); if (prevNode.getAttribute("inserted")=="true")
prevNode.parentNode.removeChild(prevNode); else
prevNode.setAttribute("deleted","true"); if (this.listChanged)
this.listChanged("remove",{ index:pos, selected:true }); if (nextNode!=null)
this._xmlNode= null; this._setXmlNode(nextNode); this._flagDirty(true); this.lbm.propertyChanged(this,"Count");}
}, clearCurrent: function clearCurrent(goPrevious)
{ if (this._xmlNode)
{ this._xmlNode.setAttribute("inserted","true"); this.deleteCurrent(goPrevious);}
}, clear: function clear()
{ var p= this.get_Position(); this._setXmlNode(null); var parentNode= this.parent._xmlNode; if (parentNode)
{ var xmlnodes= this.lbm._utils.selectNodes(parentNode,this.name); var xmlnode; while (xmlnode=xmlnodes.iter())
parentNode.removeChild(xmlnode); this._flagDirty(); this.lbm.propertyChanged(this,"Count"); if (this.listChanged)
this.listChanged("remove", {all:true,selectedIndex:p});}
}, _goInternal: function _goInternal(expr)
{ if (this.parent && this.parent._xmlNode)
{ var newLoc= this.lbm._utils.selectSingleNode(this.parent._xmlNode,this.name+"[not (@deleted)]["+expr+"]"); this._setXmlNode(newLoc);}
}, _getAdjacent: function _getAdjacent(forward)
{ var testLoc= this._xmlNode; if (testLoc)
do
{ var testLoc= forward?testLoc.nextSibling:testLoc.previousSibling; if (testLoc && ! testLoc.getAttribute("deleted") && testLoc.nodeName==this.name)
{ return testLoc;}
} while (testLoc); return this._xmlNode;}, goFirst: function goFirst()
{ this._goInternal(1);}, goLast: function goLast()
{ this._goInternal("last()");}, goNext: function goNext()
{ this._setXmlNode(this._getAdjacent(true));}, goPrevious: function goPrevious()
{ this._setXmlNode(this._getAdjacent(false));}
}; lightWeightBinder.utilities.addHandler(window,"load",function(){ lightWeightBinder.manager.addHandlers();}); 
