// Modification jca-cle  2005-07-05 
//     colums 116 : add in BwMain =>   BwUtil.call (this, "onBwLoaded()");
//     colums 5262: elsereturn => else return
var BwClasses = new Object();var BwHomePath = null;function BwMain (){BwCheck();BwBootstrapElement (document.body);try{BwUtil.call (this, "onBwLoaded()");} catch(e) {} }function BwCheck (){var ss = document.styleSheets;var l = ss.length;for (var i = 0; i < l; i++){var s = ss.item (i);var p = s.href.indexOf ("BW.css");if (p != -1){var prefix = s.href.substring (0, p);BwHomePath = prefix;return;}}if (BwHomePath == null) {alert ("The stylesheet BW/BW.css MUST be linked to the page"); }};function BwBootstrapElement (element){var l = element.childNodes.length;for (var i = 0; i < l; i++){var e = element.childNodes[i];var n = e.className;var c = null;var continueTraversal = true;var isaClass = false;if (n){c = BwClasses[n];if (c && c != null) {isaClass = true;}}if (isaClass) {e.BwClass = c;e.BwClass();continueTraversal = e.initFromDOM ();}if (continueTraversal) {BwBootstrapElement (e);}if (isaClass) {e.initFromDOMBubbling ();}}}function BwLoadInterface (parent, url){var q = new BwQuery();q.get (url);parent.innerHTML = q.getText();BwBootstrapElement (parent);};function BwGetById (id){return document.getElementById (id);};function log (str){var l = BwGetById ("log");if (!l){l = document.createElement("DIV");l.style.font="menu";l.id = "log";document.body.appendChild (l);}l.innerHTML += (str + "<br>");}if (window.addEventListener) {window.addEventListener ("load", BwMain, true);} else {window.attachEvent ("onload", BwMain);}Array.prototype.lookup = function (o){var l = this.length;for (var i = 0; i < l; i++) {if (this[i] == o) {return i;}}return -1;};BwClasses["BwCheckbox"] = BwCheckbox;function BwCheckbox (){this.isa = BwEditableWidget;this.isa();this.initFromDOM = BwCheckbox.initFromDOM;this.setValue = BwCheckbox.setValue;this.getValue = BwCheckbox.getValue;}BwCheckbox.newInstance = function (val, disabled){var self = document.createElement ("input");self.BwClass = BwCheckbox;self.BwClass();self.className = "BwCheckbox";if (val) {self.setAttribute ("checked", val);}self.initFromDOM ();if (typeof disabled != "undefined" && Boolean(disabled) == true) {self.disable();}return self;};BwCheckbox.initFromDOM = function (){BwEditableWidget.initFromDOM.call (this);/*this.style.display = "inline";*/this.type = "checkbox";/*this.ondblclick = function (e){if(e)e.stopPropagation();else window.event.cancelBubble=true;};*/};BwCheckbox.getValue = function (){return this.checked;};BwCheckbox.setValue = function (val){this.checked = val;};function BwColumn (list){this.list = list;this.name = null;this.size = null;this.code = null;this.value = null;}BwColumn.ERROR = "Invalid column specification";BwColumn.prototype.setAlign = function (s){this.align = (s) ? s : "left";};BwColumn.prototype.setSize = function (s){this.size = s;};BwColumn.prototype.setName = function (n){this.name = n;};BwColumn.prototype.loadValueCode = function (s){if (s == null || s.length == 0) {throw BwColumn.ERROR;}this.valueData = s;};BwColumn.prototype.loadRenderCode = function (c){var s = c;var p1 = s.indexOf ('(');if (p1 < 0) {throw BwColumn.ERROR;}var p2 = s.indexOf (')');if (p2 < 0) {throw BwColumn.ERROR;}var code = "return " + s.substring (0, p1) + ".newInstance(" ;s = s.substring (p1+1, p2);var l = s.length;var i = 0;while (l > 0){p1 = s.indexOf (',');if (p1 < 0) {p1 = l;}var d = s.substring (0, p1);if (i++ > 0) {code += ',';}if (d.indexOf ("'") == 0) {code += d;} else {code += ("s.getCasted('" + d + "')");}s = s.substring (p1+1, l);l = s.length;}this.code = new Function ("s", code + ");");};BwColumn.prototype.cellContent = function (src){var r = this.code (src);var s = r.style;s.whiteSpace = "nowrap";s.overflow = "hidden";if (r.editable){var _this = this;r.onchange = function(){_this.list.cellChanged(this);};r.onfocus = function(){_this.list.cellFocused(this);};}return r;};BwClasses["BwDate"] = BwDate;function BwDate (){this.isa = BwWidget;this.isa();this.initFromDOM = BwDate.initFromDOM;this.setValue = BwDate.setValue;this.getValue = BwDate.getValue;}/* date must be DD-MM-YYYY or YYYY-MM-DD */BwDate.newInstance = function (date, lang, separ){var self = document.createElement ("DIV");this.dateRank = 0;self.BwClass = BwDate;self.BwClass();self.className = "BwLabel";if (date){var isFrench = (lang=='FR')?true:false;self.setAttribute ("text", BwDate.format(date,isFrench,separ));self.setAttribute ("dateRank", BwDate.format(date,false,''));}self.initFromDOM();return self;};BwDate.initFromDOM = function (){BwWidget.initFromDOM.call (this);this.style.display="inline";this.style.MozUserSelect="none";this.style.cursor="default";this.onselectstart=function(){return false;};var txt = this.getAttribute ("text");if (txt != null) {this.setValue(txt);}return false;};BwDate.getValue = function (){var dateRank = this.getAttribute ("dateRank");if (dateRank != null)return dateRank;return 0;};BwDate.setValue = function (txt){this.innerHTML = txt;};/* date must be DD-MM-YYYY or YYYY-MM-DD */BwDate.format = function(date, isFrench, separ){if (date){if (separ==null)separ='/';var isDateFR = date.indexOf(separ,1)<4;if (isDateFR){var DD = date.substr(0,2);var MM = date.substr(3,2);var YY = date.substr(6,4);}else{var YY = date.substr(0,4);var MM = date.substr(5,2);var DD = date.substr(8,4);}if (isFrench==true)return (DD+separ+MM+separ+YY);else return (YY+separ+MM+separ+DD);}};function BwEditableWidget (){this.isa = BwWidget;this.isa();this.editable = true;this.initFromDOM = BwEditableWidget.initFromDOM;this.enable = BwEditableWidget.enable;this.disable = BwEditableWidget.disable;}BwEditableWidget.initFromDOM = function (){BwWidget.initFromDOM.call (this);};BwEditableWidget.enable = function (){this.disabled=false;};BwEditableWidget.disable = function (){this.disabled=true;};BwClasses["BwExpander"] = BwExpander;function BwExpander (){this.isa = BwWidget;this.isa();this.view = null;this.control = null;this.initFromDOM = BwExpander.initFromDOM;this.toggle = BwExpander.toggle;this.open = BwExpander.open;this.close = BwExpander.close;}BwExpander.initFromDOM = function (){BwWidget.initFromDOM.call (this);var txt = this.getAttribute ("label");var c = BwImageLabel.newInstance (null, txt);c.style.cursor="default";this.control = c;c.picture = BwStockIcon.newInstance ("closed");var p = c.picture;p.style.marginLeft="0px";p.attachBefore (c.text);var _this = this;c.onclick = function(){_this.toggle();};var v = BwView.newInstance();v.style.marginTop="5px";this.view = v;var child = this.firstChild;while (child != null){this.removeChild (child);v.appendChild (child);child = this.firstChild;}this.appendChild (c);this.appendChild (v);var opened = this.getAttribute ("opened");if (opened != null && opened == "true") {this.toggle();}this.onopen = this.getAttribute ("onopen");return false;};BwExpander.toggle = function (){if (this.view.visible()) {this.close();} else {this.open();}};BwExpander.open = function (){this.control.picture.setSource("opened");this.view.show();BwUtil.call	(this, this.onopen);/*BwUtil.forceRedraw ();*/};BwExpander.close = function (){this.control.picture.setSource("closed");this.view.hide();/*BwUtil.forceRedraw ();*/};BwClasses["BwImage"] = BwImage;function BwImage (){this.isa = BwWidget;this.isa();this.url = null;this.initFromDOM = BwImage.initFromDOM;this.draw = BwImage.draw;this.setSource = BwImage.setSource;this.getSource = BwImage.getSource;}BwImage.newInstance = function (src){var self = document.createElement ("IMG");self.BwClass = this;self.BwClass();if (src) {self.setAttribute ("source", src);}self.initFromDOM ();return self;};BwImage.initFromDOM = function (){BwWidget.initFromDOM.call (this);var s = this.style;s.MozUserSelect="none";s.MozUserInput="disabled";var u = this.getAttribute ("source");if (u) {this.setSource (u);}return false;};BwImage.draw = function (){var png = this.url.toLowerCase().indexOf(".png");if (document.all && png != -1) {this.src = BwHomePath + BwStockIcon.storagePath + "none.gif";this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.url + "')";}else {this.src = this.url;}};BwImage.getSource = function (){return this.url;};BwImage.setSource = function (src){this.url = src;this.draw();};BwClasses["BwImageLabel"] = BwImageLabel;function BwImageLabel (){this.isa = BwWidget;this.isa();this.picture = null;this.text = null;this.initFromDOM = BwImageLabel.initFromDOM;this.draw = BwImageLabel.draw;this.setImage= BwImageLabel.setImage;this.getImage= BwImageLabel.getImage;this.setLabel = BwImageLabel.setLabel;this.getLabel = BwImageLabel.getLabel;this.getValue = BwImageLabel.getValue;this.setValue = BwImageLabel.setValue;}BwImageLabel.newInstance = function (image, label){var self = document.createElement ("DIV");self.BwClass = this;self.BwClass();if (image && image != null) {self.setAttribute ("image", image);}if (label && label != null) {self.setAttribute ("label", label);}self.initFromDOM ();return self;};BwImageLabel.initFromDOM = function (){BwWidget.initFromDOM.call (this);this.draw();return false;};BwImageLabel.draw = function (){this.style.display="inline";var img = this.getAttribute ("image");if (img != null) {this.setImage (img);}var txt = this.getAttribute ("label");if (txt != null) {this.setLabel (txt);}return false;};BwImageLabel.setImage = function (img){var p = this.picture;if (p == null){p = BwImage.newInstance ();p.style.marginLeft="2px";p.style.marginRight="2px";p.style.verticalAlign = "middle";p.align="center";if (this.text != null) {p.attachBefore (this.text);} else {p.attach (this);}this.picture = p;}if (img != p.getSource()) {p.setSource (img);}};BwImageLabel.getImage = function (){var p = this.picture;if (p == null) return null;return p.getSource();};BwImageLabel.setLabel = function (txt){var t = this.text;if (t == null){t = BwLabel.newInstance ();t.attach (this);this.text=t;}if (txt != t.getValue()) {t.setValue (txt);}};BwImageLabel.getLabel = function (){var t = this.text;if (t == null) return null;return t.getValue();};BwImageLabel.getValue = function (){return this.getLabel();};BwImageLabel.setValue = function (txt){return this.setLabel (txt);};BwClasses["BwIntuitive"] = BwIntuitive;function BwIntuitive (){this.isa = BwEditableWidget;this.isa();this.disabled = false;this.list = null;this.field = null;this.initFromDOM = BwIntuitive.initFromDOM;this.initColumns = BwIntuitive.initColumns;this.showList = BwIntuitive.showList;this.setValue = BwIntuitive.setValue;this.getValue = BwIntuitive.getValue;this.keyUp = BwIntuitive.keyUp;this.keyDown = BwIntuitive.keyDown;this.disable = BwIntuitive.disable;this.enable = BwIntuitive.enable;this.lostFocus = BwIntuitive.lostFocus;this.gotFocus = BwIntuitive.gotFocus;}BwIntuitive.initFromDOM = function (){BwEditableWidget.initFromDOM.call (this);this.src = this.getAttribute ("src");this.record = this.getAttribute ("record");this.rowValue = this.getAttribute ("rowValue");this.columns = this.initColumns ();var f = BwTextfield.newInstance ("", false);f.autocomplete = "off";f.style.MozUserSelect="text";f.style.width=this.style.width;this.appendChild (f);this.field = f;var _this = this;var func = function (e) { _this.keyDown (e) };if (navigator.product == "Gecko") {f.onkeypress = func;} else {f.onkeydown = func;}f.onkeyup = function(e){ _this.keyUp (e) };f.onblur = function(){setTimeout(function(){_this.lostFocus();}, 100);};f.onfocus = function(){_this.gotFocus();};};BwIntuitive.lostFocus = function (){var now = new Date().getTime();var dif = now - this.focusTime;if (dif > 200 && this.list) {this.list.hide();}};BwIntuitive.gotFocus = function (){this.focusTime = new Date().getTime();};BwIntuitive.initColumns = function (){var cols = new Array();var c = this.firstChild;while (c != null){if (c.nodeType == 1 && c.className == 'BwColumn') {cols.push (c);}this.removeChild (c);c = this.firstChild;}return cols;};BwIntuitive.showList = function (){var l = this.list;var f = this.field;if (l == null) {var w = f.offsetWidth;if (navigator.product == "Gecko") {w -= 2;}l = BwList.newInstance (null, this.record, this.rowValue, false, false, this.columns, w, 100);l.style.position="absolute";l.style.zIndex="1";this.appendChild (l);this.list = l;var _t = this;l.onaction = function(){_t.setValue(_t.list.getValue());_t.list.hide();};l.onfocus = function(){_t.gotFocus();};l.onblur = function(){setTimeout(function(){_t.lostFocus();}, 100);};}l.show();var s = l.style;s.top = (BwUtil.getElementTopPosition (f) + f.offsetHeight - 1) + "px";s.left = (BwUtil.getElementLeftPosition (f)) + "px";return l;};BwIntuitive.keyDown = function (e){if (!e) e = window.event;var k = e.keyCode;if (k == 40 || k==38 || k==33 || k==34 || k==36 || k==35){this.list.keyPressed (e);}};BwIntuitive.keyUp = function (e){if (!e) e = window.event;var k = e.keyCode;if (k==40 || k==38 || k==33 || k==34 || k==36 || k==35) {return;}var l = this.list;var f = this.field;if (l != null && k == 27 || ((k == 8 || k == 46) && this.field.value == "")) {l.hide();return;}else if (l != null && k == 13 && l.visible()){var s = l.getSelection();if (s.length > 0) {f.value = l.getValue();}l.hide();return;}else if (l == null || !l.visible()) {l = this.showList();}if (k == 8 || k == 46 || (k > 64 && k < 91) || (k > 47 && k < 58) || (k > 95 && k < 106)){l.clear();l.layout();l.appendXML(this.src + f.value);}};BwIntuitive.getValue = function (){return this.field.value;};BwIntuitive.setValue = function (txt){this.field.value = txt;};BwIntuitive.disable = function (){this.disabled = true;this.field.disable();};BwIntuitive.enable = function (){this.disabled = false;this.field.enable();};BwClasses["BwLabel"] = BwLabel;function BwLabel (){this.isa = BwWidget;this.isa();this.initFromDOM = BwLabel.initFromDOM;this.setValue = BwLabel.setValue;this.getValue = BwLabel.getValue;this.disable = BwLabel.disable;this.enable = BwLabel.enable;}BwLabel.newInstance = function (txt){var self = document.createElement ("DIV");self.BwClass = BwLabel;self.BwClass();self.className = "BwLabel";if (txt) {self.setAttribute ("text", txt);}self.initFromDOM();return self;};BwLabel.initFromDOM = function (){BwWidget.initFromDOM.call (this);var s = this.style;s.display="inline";s.MozUserSelect="none";s.cursor="default";this.onselectstart=function(){return false;};var t = this.getAttribute ("text");if (t != null) {this.setValue (t);}return false;};BwLabel.getValue = function (){return this.innerHTML;};BwLabel.setValue = function (txt){this.innerHTML = txt;};BwLabel.disable = function (){if (navigator.product=="Gecko"){disabled=true;this.style.opacity="0.4";}else {this.disabled = true;}};BwLabel.enable = function (){if (navigator.product=="Gecko"){disabled=false;this.style.opacity="1";}else {this.disabled = false;}};BwClasses["BwLink"] = BwLink;function BwLink (){this.isa = BwWidget;this.isa();this.url = null;this.targ = null;this.initFromDOM = BwLink.initFromDOM;this.setUrl = BwLink.setUrl;this.getUrl = BwLink.getUrl;this.setTarget = BwLink.setTarget;this.getTarget = BwLink.getTarget;this.setValue = BwLink.setValue;this.getValue = BwLink.getValue;}BwLink.newInstance = function (linkName, linkUrl, linkTarget){var self = document.createElement ("A");self.BwClass = BwLink;self.BwClass();self.className = "BwLink";if (linkUrl==null) {self.setAttribute ("href", "#");} else {self.setAttribute ("href", linkUrl);}if (linkName) {self.setAttribute ("title", linkName);}if (linkTarget && linkUrl!='null') {self.setAttribute ("target", linkTarget);}self.initFromDOM();return self;};BwLink.initFromDOM = function (){BwWidget.initFromDOM.call (this);this.style.cursor="pointer";var linkName = this.getAttribute ("title");if (linkName != null)this.setValue (linkName);return false;};BwLink.setUrl = function (u){this.url = u;this.href=u;};BwLink.getUrl = function (){var u = this.url;if (u==null) return null;return u;};BwLink.setTarget = function (targ){this.targ = targ;this.target = targ;};BwLink.getTarget = function (){var t = this.targ;if (t==null) return null;return t;};BwLink.getValue = function (){return this.innerHTML;};BwLink.setValue = function (link){this.innerHTML = link;};BwClasses["BwList"] = BwList;function BwList (){this.isa = BwWidget;this.isa();this.columns = new Array();this.selection = new Array();this.primarySelection = null;this.naturalOrder = new Array();this.sortedOrder = new Array();this.sortedOrder._list = this;this.sortOrder = 0;this.sortedColumnIndex = -1;this.headerHeight = 0;this.header = null;this.list = null;this.headerTable = null;this.listTable = null;this.initFromDOM = BwList.initFromDOM;this.initColumns = BwList.initColumns;this.drawHeader = BwList.drawHeader;this.drawList = BwList.drawList;this.drawRows = BwList.drawRows;this.drawSelection = BwList.drawSelection;this.applyRowStyle = BwList.applyRowStyle;this.layout = BwList.layout;this.headerLayout = BwList.headerLayout;this.columnLayout = BwList.columnLayout;this.handleColumnHeaders = BwList.handleColumnHeaders;this.columnSort = BwList.columnSort;this.rowSelect = BwList.rowSelect;this.selectRowByValue = BwList.selectRowByValue;this.deselect = BwList.deselect;this.deselectAll = BwList.deselectAll;this.select = BwList.select;this.sort = BwList.sort;this._compare = BwList._compare;this.keyPressed = BwList.keyPressed;this.mouseDoubleClicked = BwList.mouseDoubleClicked;this.mouseClicked = BwList.mouseClicked;this.mouseMoved = BwList.mouseMoved;this.mousePressed = BwList.mousePressed;this.mouseReleased = BwList.mouseReleased;this.getSelection = BwList.getSelection;this.getCellValue = BwList.getCellValue;this.getValue = BwList.getValue;this.getLength = BwList.getLength;this.remove = BwList.remove;this.removeSelection = BwList.removeSelection;this.clear = BwList.clear;this.appendXML = BwList.appendXML;this.insertXML = BwList.insertXML;this.cellChanged = BwList.cellChanged;this.cellFocused = BwList.cellFocused;this.scrollToRow = BwList.scrollToRow;}BwList.newInstance = function (src, record, rowValue, multi, header, columns, width, height){var self = document.createElement ("div");self.BwClass = BwList;self.BwClass();self.className = "BwList";if (src != null) {self.setAttribute ("src", src);}self.setAttribute ("record", record);self.setAttribute ("rowValue", rowValue);self.setAttribute ("multi", multi);self.setAttribute ("showHeader", header);if (height && height != null) {self.style.height=height+"px";}if (width && width != null) {self.style.width=width+"px";}for (var i = 0; i < columns.length; i++) {self.appendChild (columns[i]);}self.initFromDOM();return self;};BwList.initFromDOM = function (){BwWidget.initFromDOM.call (this);var s = this.style;s.overflow="hidden";s.cursor = "default";s.MozUserInput="enabled";s.MozUserFocus="normal";var att = this.getAttribute ("multi");this.multi = (att == null || att == 'false') ? false : true;att = this.getAttribute ("sortable");this.sortable = (att == null || att == 'true') ? true : false;this.record = this.getAttribute ("record");this.rowValue = this.getAttribute ("rowValue");this.onselect = this.getAttribute ("onselect");this.onaction = this.getAttribute ("onaction");this.onchange = this.getAttribute ("onchange");this.initColumns();att = this.getAttribute ("showHeader");if (att == null || att == 'true') {this.drawHeader();}this.drawList();var _this=this;this.onclick=function(e){_this.mouseClicked(e);};this.ondblclick=function(e){_this.mouseDoubleClicked(e);};this.onmousemove=function(e){_this.mouseMoved(e);};this.onmousedown=function(e){_this.mousePressed(e);};this.onmouseup=function(e){_this.mouseReleased(e);};if (this.header != null) {this.list.onscroll=function(e){_this.header.scrollLeft=_this.list.scrollLeft;};}var f = function(e){return _this.keyPressed(e);};if (navigator.product == "Gecko") {this.onkeypress=f;} else {this.onkeydown=f;}att = this.getAttribute ("src");if (att != null) {this.appendXML (att, true);}this.layout();BwUtil.forceRedraw();this.layout();return false;};BwList.appendXML = function (source, nolayout){this.insertXML (source, null, nolayout);};BwList.insertXML = function (source, beforeRow, nolayout){if (typeof source == "string"){var query = new BwQuery();query.get (source);source = query.getMessage();}this.drawRows (source, beforeRow);if (this.sortedColumnIndex != -1) {this.sort (this.sortedColumnIndex, this.sortOrder);}if (beforeRow) {this.scrollToRow (beforeRow);}if (typeof nolayout == "undefined") {this.columnLayout();}this.headerLayout();};BwList.initColumns = function (){var curr = this.firstChild;while (curr != null){this.removeChild (curr);if (curr.className == "BwColumn"){var col = new BwColumn (this);col.setName (curr.getAttribute ("name"));col.setSize (curr.getAttribute ("size"));col.setAlign (curr.getAttribute ("align"));col.loadRenderCode (curr.getAttribute ("render"));var att = curr.getAttribute ("value");if (att && att != null) {col.loadValueCode (att);}this.columns.push (col);}curr = this.firstChild;}};BwList.drawHeader = function (){var h = document.createElement ("div");h.className = "header";var s = h.style;s.padding="0px";s.margin="0px";s.border="0px";s.position="absolute";s.overflow="hidden";this.appendChild (h);this.header = h;var ht = document.createElement ("table");ht.style.tableLayout="fixed";ht.style.borderCollapse="collapse";this.headerTable = ht;var tb = document.createElement ("tbody");ht.appendChild (tb);h.appendChild (ht);var tr = document.createElement ("tr");tb.appendChild (tr);var l = this.columns.length;for (var i = 0; i < l; i++){var col = this.columns[i];var td = document.createElement ("td");s = td.style;if (col.size != null) {s.width = col.size;}s.padding="0px";s.overflow="hidden";var d = document.createElement ("div");d.className="column";d.align=col.align;d.style.whiteSpace="nowrap";td.appendChild (d);var a = BwLabel.newInstance (col.name);a.style.whiteSpace="nowrap";a.style.margin="3px";a.attach (d);a = BwStockIcon.newInstance ("asc");a.style.visibility="hidden";a.align="center";a.attach (d);tr.appendChild (td);}};BwList.drawList = function (){var l = document.createElement ("div");l.style.overflow = "auto";l.className="list";var lt = document.createElement ("table");lt.style.tableLayout="fixed";lt.style.borderCollapse="collapse";var cg = document.createElement ("colgroup");var len = this.columns.length;for (var i = 0; i < len; i++){var c = document.createElement("col");cg.appendChild (c);this.columns[i].colPtr = c;}var tb = document.createElement ("tbody");lt.appendChild (cg);lt.appendChild (tb);l.appendChild (lt);this.appendChild (l);this.listTable = lt;this.list = l;};BwList.drawRows = function (source, beforeRow){var b = this.listTable.tBodies[0];var append = (beforeRow == null);var insertRow = (append) ? null : beforeRow;var rowIndex = (append) ? b.rows.length : beforeRow.rowIndex;var rows = new Array();var cols = this.columns;var clen = cols.length;var rec = source.lookup (this.record);if (rec == null) {return;}var p = rec.parentNode;var c = BwXml.childrenNamed (p, rec.nodeName);var l = c.length;var m = document.createElement ("tr");m.vAlign="middle";m.style.verticalAlign="middle";for (var i = 0; i < clen; i++){var td = document.createElement ("td");td.style.overflow="hidden";td.align = cols[i].align;m.appendChild (td);}this.applyRowStyle (m, rowIndex);for (var r = 0; r < l; r++) {var tr = m.cloneNode (true);rows.push (tr);source.changeRoot (c[r]);if (this.rowValue != null) {tr.value = source.getCasted (this.rowValue);}var tds = tr.childNodes;for (var i = 0; i < clen; i++){var col = cols[i];var td = tds[i];td.appendChild (col.cellContent (source));if (col.value != null) {td.value = source.getCasted (col.value);}td.onselectstart=function(){return typeof window.event.srcElement.editable!='undefined';};}source.changeRoot (null);if ((r%2) != 0) {this.applyRowStyle (tr, rowIndex, true);}if (append) {b.appendChild (tr);} else {b.insertBefore (tr, insertRow);}insertRow = tr.nextSibling;rowIndex++;}this.sortedOrder = this.sortedOrder.concat (rows);if (append) {this.naturalOrder = this.naturalOrder.concat (rows);}else{var i = this.naturalOrder.lookup (beforeRow);var a1 = this.naturalOrder.slice (0, i);var a2 = this.naturalOrder.slice (i);this.naturalOrder = a1.concat (rows, a2);var c = beforeRow;while (c != null){this.applyRowStyle (c, c.rowIndex, true);c = c.nextSibling;}this.drawSelection();}};BwList.drawSelection = function (){var s = this.selection;for (var i = 0; i < s.length; i++) {s[i].className="rowSelected";}};BwList.applyRowStyle = function (r, i, excludingCells){var s = ((i%2) == 0) ? "rowEven" : "rowOdd";var c = r.childNodes;var l = c.length;r.className = s;if (!excludingCells){for (var j = 0; j < l; j++){if (this.sortOrder != 0 && j == this.sortedColumnIndex) {c[j].className="sorted";} else {c[j].className="";}}}};BwList.layout = function (){if (this.header != null) {this.headerHeight = this.header.offsetHeight;this.list.style.paddingTop = this.headerHeight + 'px';}var h = this.clientHeight;h = (document.all) ? h : (h - this.headerHeight);if (h >= 0) {this.list.style.height = h + 'px';}var w = this.offsetWidth;if (navigator.product=="Gecko") {w--;}this.list.style.width = w + 'px';w = this.list.clientWidth;this.listTable.style.width = w + 'px';if (this.header != null){this.headerTable.style.width = w + "px";this.headerLayout();this.columnLayout();}};BwList.headerLayout = function (){if (this.header == null) return;var w = this.list.clientWidth;if (w > 0) {this.header.style.width = (w-1) + 'px';}};BwList.columnLayout = function (){if (this.header == null) return;var rows = this.listTable.tBodies[0].rows;if (rows.length == 0 || !rows[0].cells) return;var headCells = this.headerTable.tBodies[0].rows[0].cells;var l = headCells.length;for (var i = 0; i < l; i++){var h = headCells[i];var w = h.offsetWidth;var sw = w + 'px';h.style.width = sw;/*h.firstChild.style.width = sw;*/this.columns[i].colPtr.style.width = w;}};BwList.keyPressed = function (event){if (!event) event = window.event;var key = (event)?event.keyCode:window.event.keyCode;var rows = this.listTable.tBodies[0].rows;var row = (this.selection.length != 0) ? this.selection[this.selection.length-1] : null;var rowsPerPage = Math.floor ((this.list.clientHeight - this.headerHeight) / rows[0].offsetHeight);var last = rows.length - 1;switch (key){case 38:row = (row != null) ? row.previousSibling : rows[0];break;case 40:row = (row != null) ? row.nextSibling : rows[0];break;case 33:var i = 0;if (row != null) {i = (row.rowIndex - rowsPerPage);if (i < 0) i = 0;}row = rows[i];break;case 34:var i = 0;if (row != null) {i = (row.rowIndex + rowsPerPage);if (i > last) i = last;}row = rows[i];break;case 36:row = rows[0];break;case 35:row = rows[last];break;case 13:BwUtil.call (this, this.onaction);/*this.scrollToRow (row);*/return;default:return true;}if (row){this.rowSelect (row, event);this.scrollToRow (row);}return false;};BwList.mouseClicked = function (event){if (!event) event = window.event;if (this.targetColumn != null) {return false;}var target = (event.target)?event.target:event.srcElement;if (BwUtil.findParentElement (target, "DIV", "header") != null){if (target.nodeName != "TD") {target = BwUtil.findParentElement (target, "TD");}if (target != null && this.sortable) {this.columnSort (target.cellIndex);}}else{var row = BwUtil.findParentElement (target, "TR");if (row != null && BwUtil.findParentElement (row, "DIV", "list") != null) {this.rowSelect (row, event);}}return false;};BwList.mouseDoubleClicked = function (event){if (!event) event = window.event;if (this.onaction == null) {return true;}if (this.targetColumn != null) {return true;}var target = (event.target)?event.target:event.srcElement;var row = BwUtil.findParentElement (target, "TR");if (row != null && BwUtil.findParentElement (row, "DIV", "list") != null) {return BwUtil.call (this, this.onaction);}return true;};BwList.mousePressed = function (event){if (!event) event = window.event;if (this.targetColumn == null) {return;}this.lastX = (event.pageX)?event.pageX:event.x;this.lastX += this.list.scrollLeft;this.resizing = true;if (this.setCapture) {this.setCapture();}};BwList.mouseReleased = function (event){if (!event) event = window.event;this.resizing = false;if (this.releaseCapture) {this.releaseCapture();}return true;};BwList.mouseMoved = function (event){if (!event) event = window.event;var target = (event.target)?event.target:event.srcElement;var x = (event.pageX)?event.pageX:event.x;x += this.list.scrollLeft;if (this.resizing){var o = x - this.lastX;var w = this.targetColumnWidth + o;if (w <= 16) {return;}var w1 = w + "px";var w2 = (this.targetTableWidth + o) + "px";this.targetColumn.style.width = w1;/*this.targetColumn.firstChild.style.width = w1;*/this.columns[this.targetColumn.cellIndex].colPtr.style.width = w1;this.headerTable.style.width = w2;this.listTable.style.width = w2;}else if (BwUtil.findParentElement (target, "DIV", "header") != null){if (target.nodeName != "TD") {target = BwUtil.findParentElement (target, "TD");}if (target != null) {this.handleColumnHeaders (target, x);}}else{this.style.cursor = "default";this.targetColumn = null;}};BwList.handleColumnHeaders = function (target, x){var prev = target.previousSibling;var next = target.nextSibling;var left = BwUtil.getElementLeftPosition (target);var right = left + target.offsetWidth;this.resizing = false;if (prev && x <= (left + 7)) {this.style.cursor = "e-resize";this.targetColumn = prev;this.targetColumnWidth = prev.offsetWidth;this.targetTableWidth = this.headerTable.offsetWidth;}else if (x >= (right - 7)) {this.style.cursor = "e-resize";this.targetColumn = target;this.targetColumnWidth = target.offsetWidth;this.targetTableWidth = this.headerTable.offsetWidth;}else {this.style.cursor = "default";this.targetColumn = null;}};BwList.columnSort = function (col){var pc = this.sortedColumnIndex;var order = this.sortOrder;if (col != pc) {order = 0;}order = (++order % 3);this.sort (col, order);var s = this.selection;var l = s.length;if (l > 0) {this.scrollToRow (s[l-1]);}};BwList.sort = function (col, order, excludingCell){var h = this.headerTable.tBodies[0].rows[0].childNodes;var b = this.listTable.tBodies[0];var l = b.rows.length;var pc = this.sortedColumnIndex;var ic, s;if (col != pc && pc != -1){ic = h[pc].firstChild.firstChild.nextSibling;ic.style.visibility="hidden";h[pc].firstChild.className = "column";}this.sortOrder = order;this.sortedColumnIndex = col;ic = h[col].firstChild.firstChild.nextSibling;if (this.sortOrder != 0) {var asc = (this.sortOrder == 1);h[col].firstChild.className = "column sorted";ic.style.visibility="visible";ic.setSource (asc ? "asc" : "desc");var _this = this;this.sortedOrder.sort (function (a,b){return _this._compare(a,b);});s = this.sortedOrder;}else{h[col].firstChild.className = "column";ic.style.visibility="hidden";s = this.naturalOrder;}this.listTable.removeChild (b);	for (var i = 0; i < l; i++){var r = s[i];b.removeChild (r);this.applyRowStyle (r, i, excludingCell);b.appendChild (r);}this.listTable.appendChild (b);	this.drawSelection ();};BwList._compare = function (a, b){var i = this.sortedColumnIndex;a = this.getCellValue (a, i);b = this.getCellValue (b, i);if (a.toUpperCase && b.toUpperCase){a = a.toUpperCase();b = b.toUpperCase();}var r;if (a > b) r = 1;else if (a < b) r = -1;else r = 0;if (this.sortOrder == 2) r = -r;return r;};BwList.deselectAll = function (){var l = this.selection.length;for (var i = 0; i < l; i++) {this.deselect (this.selection[0]);}};BwList.deselect = function (row){if (!row) return;var c = row.childNodes;var l = c.length;var i = this.selection.lookup (row);if (i == -1) return;this.selection.splice (i, 1);var r = row.rowIndex;this.applyRowStyle (row, r);};BwList.selectRowByValue = function (value){var rows = this.listTable.tBodies[0].rows;var l = rows.length;for (var i = 0; i < l; i++){var r = rows[i];if (r.value == value) {this.rowSelect (r);this.scrollToRow (r);return;}}};BwList.select = function (row){var c = row.childNodes;var l = c.length;var i = this.selection.lookup (row);if (i != -1) return;this.selection.push (row);this.drawSelection();};BwList.rowSelect = function (row, e){var r = this.selection.lookup (row);if (e && e.ctrlKey){if (r == -1) {if (!this.multi && this.selection.length != 0) {this.deselect (this.selection[0]);}this.select (row);this.primarySelection = row;} else {this.deselect (row);if (this.selection.length == 0) {this.primarySelection = null;}}}else if (this.multi && e && e.shiftKey && this.primarySelection != null){var last = this.primarySelection;this.deselectAll();var i1 = last.rowIndex;var i2 = row.rowIndex;if (i1 < i2) {for (var i = i1; i <= i2; i++) {this.select (this.listTable.tBodies[0].rows[i]);}} else {for (var i = i1; i >= i2; i--) {this.select (this.listTable.tBodies[0].rows[i]);}}}else{this.deselectAll();this.select (row);this.primarySelection = row;}BwUtil.call (this, this.onselect);};BwList.getSelection = function (){return this.selection;};BwList.getCellValue = function (row, colIndex){var c = row.childNodes[colIndex];if (typeof c.value != "undefined") {return c.value;}c = c.firstChild;return c.getValue();};BwList.removeSelection = function (){var s = this.selection;while (s.length > 0) {this.remove (s[0], true);}var r = this.listTable.tBodies[0].rows;for (var i = 0; i < r.length; i++) {this.applyRowStyle (r[i], i, true);}this.headerLayout();};BwList.remove = function (row, freeze){var i;row.parentNode.removeChild (row);if (!freeze){var next = row.nextSibling;i = row.rowIndex;while (next != null){this.applyRowStyle (next, i, true);i++;next = next.nextSibling;}}i = this.selection.lookup (row);this.selection.splice (i, 1);i = this.naturalOrder.lookup (row);this.naturalOrder.splice (i, 1);i = this.sortedOrder.lookup (row);this.sortedOrder.splice (i, 1);if (!freeze) {this.headerLayout();}};BwList.clear = function (){var body = this.listTable.tBodies[0];var curr = body.rows[0];while (curr != null){var next = curr.nextSibling;body.removeChild (curr);curr = next;}this.selection = new Array();this.naturalOrder = new Array();this.sortedOrder = new Array();this.headerLayout();};BwList.getValue = function (){var s = this.selection;var l = s.length;if (l == 0) {return null;}return s[l-1].value;};BwList.getLength = function (){return this.listTable.tBodies[0].rows.length;};BwList.cellFocused = function (widget){var td = widget.parentNode;var row = td.parentNode;this.deselectAll();this.rowSelect (row);};BwList.cellChanged = function (widget){var td = widget.parentNode;var i = td.cellIndex;var row = td.parentNode;if (this.sortedColumnIndex == i) {this.sort (i, this.sortOrder);this.scrollToRow (row);}if (this.onchange && this.onchange != null){this.changedRow = row;this.changedCellIndex = i;BwUtil.call (this, this.onchange);}};BwList.scrollToRow = function (row){if (row.offsetTop < this.list.scrollTop) {this.list.scrollTop = row.offsetTop;}else if ((row.offsetTop + row.offsetHeight) > (this.list.scrollTop + this.list.clientHeight - this.headerHeight)) {this.list.scrollTop = row.offsetTop - this.list.clientHeight + this.headerHeight + row.offsetHeight;}};function BwMessage (name){this.dom = null;if (!name) {name = "message";}this.init (name);}BwMessage.initFromXML =function (dom){var msg = new BwMessage ();msg.dom = dom;msg.root = dom.documentElement;return msg;};BwMessage.prototype.init = function (name){var i = document.implementation;var d = (i.createDocument) ? i.createDocument ("","",null) : new ActiveXObject ("MSXML.DOMDocument");var r = d.createElement (name);d.appendChild (r);this.dom = d;this.root = r;};BwMessage.prototype.getName = function (){return this.dom.documentElement.nodeName;};BwMessage.prototype.changeRoot = function (obj){if (typeof obj == 'string') {obj = this.lookup (obj);}this.root = (obj == null) ? this.dom.documentElement : obj;};BwMessage.prototype.put = function (path, value){var n = this.create (path);return BwXml.setNodeValue (n, value);};BwMessage.prototype.get = function (path){var n = this.lookup (path);if (n == null) return null;return BwXml.getNodeValue(n);};BwMessage.prototype.getCasted = function (path){var v = this.get (path);if (v == null) return null;var n = new Number (v);if (!isNaN (n)) {v = n.valueOf();}return v;};BwMessage.prototype.count = function (path){var n = this.lookup (path);if (n == null) return -1;return BwXml.countHomonymNodes (n);};BwMessage.prototype.remove = function (path){var n = this.lookup (path);if (n == null) return null;return BwXml.removeNode (n);};BwMessage.prototype.create = function (path){try {return BwXml.navigate (path, this.root, true);} catch (e) {return null;}};BwMessage.prototype.lookup = function (path){try {return BwXml.navigate (path, this.root, false);} catch (e) {return null;}};BwClasses["BwNode"] = BwNode;function BwNode (){this.isa = BwWidget;this.isa();this.leaf = null;this.initFromDOM = BwNode.initFromDOM;this.draw = BwNode.draw;this.hasChild = BwNode.hasChild;this.getDepth = BwNode.getDepth;this.setIcon= BwNode.setIcon;this.getIcon= BwNode.getIcon;this.setLabel = BwNode.setLabel;this.getLabel = BwNode.getLabel;this.setExpander = BwNode.setExpander;this.indent = BwNode.indent;this.indentTree = BwNode.indentTree;this.open = BwNode.open;this.close = BwNode.close;this.toggle = BwNode.toggle;this.update = BwNode.update;this.select = BwNode.select;this.deselect = BwNode.deselect;this.detach = BwNode.detach;this.attach = BwNode.attach;this.attachBefore = BwNode.attachBefore;this.attachAfter = BwNode.attachAfter;this.resetBorders = BwNode.resetBorders;}BwNode.newInstance = function (icon, label, properties){var self = document.createElement ("DIV");self.setAttribute ("icon", icon);self.setAttribute ("label", label);if (properties && properties != null){for (p in properties) {self.setAttribute (p, properties[p]);}}self.BwClass = BwNode;self.BwClass();return self;};BwNode.initFromDOM = function (){BwWidget.initFromDOM.call (this);this.draw ();return true;};BwNode.detach = function (){this.deselect();var parent = this.getParentWidget();BwWidget.detach.call (this);if (parent.BwClass == BwNode) {parent.update();if (!parent.hasChild()) {parent.close();}}};BwNode.attachBefore = function (node){BwWidget.attachBefore.call (this, node);if (!this.leaf) {this.draw();}this.indentTree();};BwNode.attachAfter = function (node){if (!node.opened || !node.hasChild()) {BwWidget.attachAfter.call (this, node);}else{node.insertBefore (this, node.leaf.nextSibling);node.update();}if (!this.leaf) {this.draw();}this.indentTree();};BwNode.attach = function (node){if (node.BwClass == BwNode){if (node.hasChild()) {node.insertBefore (this, node.leaf.nextSibling);} else {node.appendChild (this);}node.open();}else{if (node.hasChildNodes()) {node.insertBefore (this, node.firstChild);} else {node.appendChild (this);}}if (!this.leaf) {this.draw();}this.indentTree ();};BwNode.indentTree = function (){this.indent();var c = this.childNodes;var l = c.length;for (var i = 0; i < l; i++){var n = c[i];if (n.BwClass && n.BwClass == BwNode) {n.indentTree ();}}};BwNode.getDepth = function (){var depth = 0;var p = this.getParentWidget();while (p != null && p.BwClass != BwTree) {depth++;p = p.getParentWidget();}return depth;};BwNode.hasChild = function (){var c = this.childNodes;var l = c.length;for (var i = 0; i < l; i++) {var n = c[i];if ((n.BwClass && n.BwClass == BwNode) || n.className == "BwNode") {return true;}}return false;};BwNode.draw = function (){var tree = this.getParentWidget (BwTree);var leaf = document.createElement ("DIV");var child = this.firstChild;if (child != null) {this.insertBefore (leaf, child);} else {this.appendChild (leaf);}this.leaf = leaf;var openDepth = tree.defaultOpenDepth;if (openDepth == -1) {this.opened = true;} else {this.opened = (this.getDepth() >= openDepth) ? false : true; }var pw = this.getParentWidget();this.style.display = (pw.BwClass != BwNode || pw.opened) ? "block" : "none";this.style.width = "100%";this.style.whiteSpace = "nowrap";leaf.className = "leaf";leaf.style.cursor="default";leaf.style.padding = "2px";leaf.style.marginBottom = "0px";var icon = this.getAttribute ("icon");var label = this.getAttribute("label");this.setExpander ();leaf.iconLabel = BwImageLabel.newInstance (icon, label);leaf.iconLabel.attach (leaf);leaf.onclick = BwNode.leafClicked;if (tree.draggable) {leaf.onmousedown = BwNode.leafDragStart;} else {leaf.onmousedown = function(){return false};}this.onmousedown = function(){return false};};BwNode.getIcon = function (){return this.leaf.iconLabel.getImage();};BwNode.getLabel = function (){return this.leaf.iconLabel.getLabel();};BwNode.indent = function (){var expander = this.leaf.expander;expander.style.marginLeft = (this.getDepth() * 18) + "px";		};BwNode.setExpander = function (){var expander = this.leaf.expander;if (!expander){expander = BwStockIcon.newInstance (); expander.style.marginRight = "5px";expander.style.verticalAlign="middle";expander.style.height="11px";expander.style.width="10px";expander.attach (this.leaf); this.leaf.expander = expander;}this.indent ();var icon;if (!this.hasChild()) {icon = "none";}else {icon = (this.opened) ? "opened" : "closed";expander.onclick = BwNode.expanderClicked;}expander.setSource (icon);};BwNode.open = function (){this.opened = true;this.update();};BwNode.close = function (){this.opened = false;this.update();};BwNode.toggle = function (){this.opened = !this.opened;this.update();};BwNode.update = function (){this.setExpander();var l = this.childNodes.length;for (var i = 0; i < l; i++){var n = this.childNodes[i];if (n.BwClass == BwNode) {n.style.display = (this.opened) ? "block" : "none";}}};BwNode.select = function (){var tree = this.getParentWidget (BwTree);if (tree.selectedNode != null) {tree.selectedNode.deselect();}this.leaf.style.backgroundColor = "Highlight";this.leaf.style.color = "#ffffff";tree.selectedNode = this;};BwNode.deselect = function (){var tree = this.getParentWidget (BwTree);if (tree.selectedNode != this) {return;}this.leaf.style.backgroundColor = "";this.leaf.style.color = "#000000";tree.selectedNode = null;};BwNode.expanderClicked = function (event){var node = this.parentNode.parentNode;if (!event) event = window.event;event.cancelBubble = true;node.toggle();};BwNode.leafClicked = function (event){var node = BwUtil.findContainerWidget (this, BwNode);var tree = node.getParentWidget (BwTree);if (!event) event = window.event;event.cancelBubble = true;if (tree.selectedNode == node) {return;}node.select ();if (tree.selectFunc != null) {tree.selectFunc (node);}};BwNode.leafDragStart = function (event){var node = BwUtil.findContainerWidget (this, BwNode);var tree = node.getParentWidget (BwTree);if (!event) event = window.event;event.cancelBubble = true;document.BwDragMaster = tree;if (tree.setCapture) {tree.onmousemove = BwNode.leafDrag;tree.onmouseup = BwNode.leafDrop;tree.onmouseover = BwNode.leafDragOver;tree.onloosecapture = BwNode.leafDrop;tree.setCapture();} else {document.onmousemove = BwNode.leafDrag;document.onmouseup = BwNode.leafDrop;tree.onmouseover = BwNode.leafDragOver;}tree.nodeDragged = node;tree.iconDragged = null;tree.leafOvered = null;return false;};BwNode.leafDrop = function (event){var tree = document.BwDragMaster;if (!event) event = window.event;event.cancelBubble = true;if (tree.releaseCapture) {tree.onmousemove = null;tree.onmouseup = null;tree.onmouseover = null;tree.onloosecapture = null;tree.releaseCapture();} else {document.onmousemove = null;document.onmouseup = null;tree.onmouseover = null;}if (tree.iconDragged != null){document.body.removeChild (tree.iconDragged);tree.iconDragged = null;var target = event.srcElement;if (!target) target = event.target;var src = tree.nodeDragged;var dst = BwUtil.findContainerWidget (target, BwNode);if (tree.leafOveredTier != 0 && dst != null && !dst.isaDescendantOf (src)){var needsReselect = (tree.selectedNode == src);src.detach();switch (tree.leafOveredTier){case 1: src.attachBefore (dst); break;case 2: src.attach (dst); break;case 3: src.attachAfter (dst); break;}if (needsReselect) {src.select();}}}if (tree.leafOvered != null){BwUtil.findContainerWidget (tree.leafOvered, BwNode).resetBorders();tree.leafOvered = null;}};BwNode.leafDrag = function (event){var tree = document.BwDragMaster;if (!event) event = window.event;event.cancelBubble = true;if (tree.iconDragged == null){var orig = tree.nodeDragged.leaf.iconLabel;var img = BwImageLabel.newInstance (orig.getImage(), orig.getLabel());img.style.position = "absolute";img.attach (document.body);tree.iconDragged = img;}var scrollY = document.body.scrollTop;var scrollX = document.body.scrollLeft;tree.iconDragged.style.left = (scrollX + event.clientX + 10) + "px";tree.iconDragged.style.top = (scrollY + event.clientY + 14) + "px";BwNode._updateDragDestination (event, tree);return false;};BwNode.leafDragOver = function (event){if (!event) event = window.event;event.cancelBubble = true;var target = event.srcElement;if (!target) target = event.target;var node = BwUtil.findContainerWidget (target, BwNode);if (node == null) return;var tree = node.getParentWidget(BwTree);var leaf = node.leaf;if (tree.leafOvered != leaf){if (tree.leafOvered != null) {BwUtil.findContainerWidget (tree.leafOvered, BwNode).resetBorders();}BwNode._newDragDestination (tree, leaf);BwNode._updateDragDestination (event, tree);}};BwNode._newDragDestination = function (tree, leaf){var dst = BwUtil.findContainerWidget (leaf, BwNode);var src = tree.nodeDragged;var acceptTier1 = BwTree.acceptAttach (src, dst, 1);var acceptTier2 = BwTree.acceptAttach (src, dst, 2);var acceptTier3 = BwTree.acceptAttach (src, dst, 3);var tier1;var tier2;var tier3;tree.leafOveredTier = 0;tree.leafOvered = leaf;tree.leafOveredTop = BwUtil.getElementTopPosition (leaf);var top = tree.leafOveredTop;var height = leaf.offsetHeight;if (acceptTier1 && acceptTier2 && acceptTier3){var offset = height / 3;tier1 = top + offset;tier2 = tier1 + offset;tier3 = tier2 + offset;}else if (!acceptTier1 && acceptTier2 && acceptTier3){var offset = height / 3;tier1 = top;tier2 = tier1 + (offset * 2);tier3 = tier2 + offset;}else if (acceptTier1 && !acceptTier2 && acceptTier3){var offset = height / 2;tier1 = top + offset;tier2 = tier1;tier3 = tier1 + offset;}else if (acceptTier1 && acceptTier2 && !acceptTier3){var offset = height / 3;tier1 = top + offset;tier2 = tier1 + (offset * 2);tier3 = tier2;}else if (!acceptTier1 && !acceptTier2 && acceptTier3){tier1 = top;tier2 = tier1;tier3 = tier2 + height;}else if (!acceptTier1 && acceptTier2 && !acceptTier3){tier1 = top;tier2 = tier1 + height;tier3 = tier2;}else if (acceptTier1 && !acceptTier2 && !acceptTier3){tier1 = top + height;tier2 = tier1tier3 = tier2;}else if (!acceptTier1 && !acceptTier2 && !acceptTier3){tier1 = top;tier2 = tier1tier3 = tier2;}tree.leafOveredTier1 = tier1;tree.leafOveredTier2 = tier2;tree.leafOveredTier3 = tier3;};BwNode._updateDragDestination = function (event, tree){if (tree.leafOvered == null) {return;}var y = tree.scrollTop + event.clientY;var tier;if (y >= tree.leafOveredTop && y < tree.leafOveredTier1) {tier = 1;} else if (y >= tree.leafOveredTier1 && y < tree.leafOveredTier2) {tier = 2;}else if (y >= tree.leafOveredTier2 && y < tree.leafOveredTier3) {tier = 3;} else {tier = 0;}if (tree.leafOveredTier == tier) {return;}tree.leafOveredTier = tier;var s = tree.leafOvered.style;switch (tier){case 1:BwUtil.findContainerWidget (tree.leafOvered, BwNode).resetBorders();s.borderTop = "1px solid ThreeDDarkShadow";s.paddingTop = "1px";return;case 2:s.border = "1px solid ThreeDDarkShadow";s.padding = "1px";return;case 3:BwUtil.findContainerWidget (tree.leafOvered, BwNode).resetBorders();s.borderBottom = "1px solid ThreeDDarkShadow";s.paddingBottom = "1px";return;} };BwNode.resetBorders = function (){this.leaf.style.padding = "2px";this.leaf.style.border = "0px";};BwClasses["BwNotebook"] = BwNotebook;function BwNotebook  (){this.isa = BwWidget;this.isa();this.tabContainer = null;this.tabs = new Array();this.pages = new Array();this.selectedTab = 0;this.initFromDOM = BwNotebook.initFromDOM;this.addPage = BwNotebook.addPage;this.indexFromTab = BwNotebook.indexFromTab;this.getSelectedTab = BwNotebook.getSelectedTab;}BwNotebook.initFromDOM = function (){BwWidget.initFromDOM.call (this);var t = document.createElement ("DIV");t.className = "tabContainer";if (this.firstChild == null) {this.appendChild (t);} else {this.insertBefore (t, this.firstChild);}var spacer = document.createElement ("DIV");spacer.style.clear = "both";t.appendChild (spacer);spacer = document.createElement ("DIV");spacer.style.clear = "both";t.appendChild (spacer);this.tabContainer = t;this.onselect = this.getAttribute ("onselect");return true;};BwNotebook.addPage = function (page){var i = this.pages.length;this.pages[i] = page;this.tabs[i] = page.tab;page.tab.attach (this);if (i != this.selectedTab) {page.hide();page.tab.renderDeselected();return false;} else {page.tab.renderSelected();return true;}};BwNotebook.indexFromTab = function (tab){var l = this.tabs.length;for (var i = 0; i < l; i++) {if (this.tabs[i] == tab) {return i;}}return -1;};BwNotebook.tabClicked = function (event){var tab = this;var n = tab.getParentWidget (BwNotebook);var i = n.indexFromTab (tab);var p = n.selectedTab;n.selectedTab = i;n.pages[p].hide();n.pages[i].show();if (p != 0) {n.tabs[p - 1].renderDeselected();}n.tabs[p].renderDeselected();if (i != 0) {n.tabs[i - 1].renderDeselected();}n.tabs[i].renderSelected();BwUtil.forceRedraw ();if (i != p && n.onselect) {BwUtil.call (n, n.onselect);}};BwNotebook.getSelectedTab = function (){return this.tabs[this.selectedTab];};BwClasses["BwNotebookPage"] = BwNotebookPage;function BwNotebookPage (){this.isa = BwView;this.isa();this.tab = null;this.initFromDOM = BwNotebookPage.initFromDOM;}BwNotebookPage.initFromDOM = function (){BwView.initFromDOM.call (this);var i = this.getAttribute ("image");var l = this.getAttribute ("label");this.tab = BwNotebookTab.newInstance (i, l);var n = this.getParentWidget(BwNotebook);var b = n.addPage (this);if (b) this.show();return false;};BwClasses["BwNotebookTab"] = BwNotebookTab;function BwNotebookTab (){this.isa = BwImageLabel;this.isa();this.initFromDOM = BwNotebookTab.initFromDOM;this.attach = BwNotebookTab.attach;this.renderSelected = BwNotebookTab.renderSelected;this.renderDeselected = BwNotebookTab.renderDeselected;}BwNotebookTab.newInstance = BwImageLabel.newInstance;BwNotebookTab.initFromDOM = function (){BwImageLabel.initFromDOM.call (this);var s = this.style;s.display="inline-block";s.cssFloat="left";s.styleFloat="left";s.position="relative";s.cursor="default";this.onclick = BwNotebook.tabClicked;return true;};BwNotebookTab.attach = function (notebook){var t = notebook.tabContainer;t.insertBefore (this, t.lastChild);};BwNotebookTab.renderSelected = function (){this.className = "tab selected";};BwNotebookTab.renderDeselected = function (){var notebook = this.getParentWidget (BwNotebook);var index = notebook.indexFromTab(this);this.className = "tab";if (index == 0) {this.className +=" first";} if (notebook.selectedTab == index + 1) {this.className += " beforesel";}};BwClasses["BwPopup"] = BwPopup;function BwPopup (){this.isa = BwEditableWidget;this.isa();this.initFromDOM = BwPopup.initFromDOM;this.initFromXML = BwPopup.initFromXML;this.drawRows = BwPopup.drawRows;this.getValue = BwPopup.getValue;}BwPopup.newInstance = function (src, record, value, label, disabled){var self = document.createElement ("select");self.BwClass = BwPopup;self.BwClass();self.className = "BwPopup";if (record) {self.setAttribute ("record", record);}if (value) {self.setAttribute ("value", value);}if (label) {self.setAttribute ("label", label);}if (src && typeof src == "string") {self.setAttribute ("src", src);}self.initFromDOM();if (typeof disabled != "undefined" && Boolean(disabled) == true) {self.disable();}return self;};BwPopup.initFromDOM = function (){BwEditableWidget.initFromDOM.call (this);this.style.display="inline";this.valueData = this.getAttribute ("rowValue");this.record = this.getAttribute ("record");this.labelData = this.getAttribute ("label");var s = this.getAttribute ("src");if (s != null) this.initFromXML (s);};BwPopup.initFromXML = function (source){if (typeof source == "string") {var q = new BwQuery();q.get (source);source = q.getMessage();}this.drawRows (source);};BwPopup.drawRows = function (source){var count = source.count (this.record);for (var r = 0; r < count; r++) {source.changeRoot (this.record + "[" + r + "]");var v = source.get (this.valueData);var l = source.get (this.labelData);var o = document.createElement ("option");o.setAttribute ("value", v);var t = document.createTextNode (l);o.appendChild (t);this.appendChild (o);source.changeRoot (null);}};BwPopup.getValue = function (){return this.options[this.selectedIndex].value;};function BwQuery (){this.asyncCallback = null;this.impl = null;if (document.all) {this.impl = new ActiveXObject("Microsoft.XMLHTTP");} else {this.impl = new XMLHttpRequest();}};BwQuery.prototype.get = function (url, callback){this.transmit ("GET", url, null, callback);};BwQuery.prototype.post = function (url, obj, callback){if (typeof obj == "object" && obj.constructor == BwMessage) {obj = obj.dom;}this.transmit ("POST", url, obj, callback);};BwQuery.prototype.transmit = function (method, url, obj, callback){var async = (typeof callback != "undefined");if (async) {this.asyncCallback = callback;}this.impl.open (method, this.buildUrl (url), async);if (async) {var _this = this;this.impl.onreadystatechange = function () { _this.readyStateChanged(); };}this.impl.send (obj);};BwQuery.prototype.readyStateChanged = function (){if (this.impl.readyState == 4) {this.asyncCallback ();}};BwQuery.prototype.setHeader = function (name, value){this.impl.setHeader (name, value);};BwQuery.prototype.getText = function (){return this.impl.responseText;};BwQuery.prototype.getMessage = function (){return BwMessage.initFromXML (this.impl.responseXML);};BwQuery.prototype.getXML = function (){return this.impl.responseXML;};BwQuery.prototype.getStatus = function (){return this.impl.status;};BwQuery.prototype.getStatusText = function (){return this.impl.statusText;};BwQuery.prototype.buildUrl = function (url){var l = document.location;if (url.indexOf ("/") == 0){var p = l.port;var h = l.host;var u = l.protocol + "//" + h;if (p != null && p != "" && h.indexOf (p) < 0) {u += (":" + p);}return (u + url);} else {var l = l.toString();var p = l.lastIndexOf ("/");var u = l.substr (0, p);return (u + "/" + url);}};BwClasses["BwRanking"] = BwRanking;function BwRanking (){this.isa = BwEditableWidget;this.isa();this.disabled = false;this.stars = 0;this.initFromDOM = BwRanking.initFromDOM;this.draw = BwRanking.draw;this.setValue = BwRanking.setValue;this.getValue = BwRanking.getValue;this.mouseClicked = BwRanking.mouseClicked;this.disable = BwRanking.disable;this.enable = BwRanking.enable;}BwRanking.newInstance = function (v){var self = document.createElement ("DIV");self.BwClass = BwRanking;self.BwClass();self.className = "BwRanking";self.setAttribute ("value", v);self.initFromDOM ();return self;};BwRanking.initFromDOM = function (){BwWidget.initFromDOM.call (this);this.style.display="inline";var v = this.getAttribute ("value");if (v != null) {this.stars = v;}this.draw();return false;};BwRanking.draw = function (){var s = this.style;s.height="16px";s.width="80px";for (var i = 0; i < 5; i++){var ico = (this.stars > i) ? "star" : "nostar";var img = BwStockIcon.newInstance(ico);s = img.style;s.width="16px";s.height="16px";s.border="0px";img.starIndex = i;img.attach (this);var _this = this;img.onclick = function(e){_this.mouseClicked(e);};}};BwRanking.mouseClicked = function (event){if (this.disabled) return;if (!event) event = window.event;var target = (event.target)?event.target:event.srcElement;var i = target.starIndex;if (this.stars == ++i) i--;this.setValue (i);};BwRanking.getValue = function (){return this.stars;};BwRanking.setValue = function (v){if (v<0)v=0;if (v>5)v=5;this.stars=v;if (this.childNodes.length == 0) {return;}for (var i = 0; i < 5; i++){var img = this.childNodes[i];var ico = (v>i) ? "star" : "nostar";img.setSource (ico);}BwUtil.call (this, this.onchange);};BwRanking.disable = function (){this.disabled = true;var s = this.style;s.opacity = "0.4";s.filter = "alpha(opacity=40)";};BwRanking.enable = function (){this.disabled = false;var s = this.style;s.opacity = "1";s.filter = "alpha(opacity=100)";};BwClasses["BwStockIcon"] = BwStockIcon;function BwStockIcon (){this.isa = BwImage;this.isa();this.draw = BwStockIcon.draw;}BwStockIcon.newInstance = BwImage.newInstance;BwStockIcon.storagePath = "icons/";BwStockIcon.draw = function (){var p = BwHomePath + BwStockIcon.storagePath;if (this.url == "none") {this.src = p + "none.gif";return;}if (document.all) {this.src = p + "none.gif";this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + p + this.url + ".png')";} else {this.src = p + this.url + ".png";}};BwClasses["BwTextfield"] = BwTextfield;function BwTextfield (){this.isa = BwEditableWidget;this.isa();this.initFromDOM = BwTextfield.initFromDOM;this.setValue = BwTextfield.setValue;this.getValue = BwTextfield.getValue;}BwTextfield.newInstance = function (val, disabled){var self = document.createElement ("input");self.BwClass = BwTextfield;self.BwClass();self.className = "BwTextfield";if (val) {self.setAttribute ("value", val);}self.initFromDOM ();if (typeof disabled != "undefined" && Boolean(disabled) == true) {self.disable();}return self;};BwTextfield.initFromDOM = function (){BwEditableWidget.initFromDOM.call (this);this.type = "text";this.style.MozUserSelect="text";this.ondblclick = function (e){if(e)e.stopPropagation();else window.event.cancelBubble=true;};};BwTextfield.getValue = function (){return this.value;};BwTextfield.setValue = function (txt){this.value = txt;};BwClasses["BwTree"] = BwTree;function BwTree (){this.isa = BwWidget;this.isa ();this.selectedNode = null;this.defaultOpenDepth = 0;this.draggable = true;this.reorderable = true;this.reparentable = true;this.selectFunc = null;this.attachBeforeFunc = null;this.attachAfterFunc = null;this.attachFunc = null;this.detachFunc = null;this.initFromDOM = BwTree.initFromDOM;this.getSelectedNode = BwTree.getSelectedNode;}BwTree.setBackground = function (){};BwTree.initFromDOM = function (){BwWidget.initFromDOM.call (this);this.style.backgroundColor="White";var att;att = this.getAttribute ("open");if (att && att != null) {this.defaultOpenDepth = att;}att = this.getAttribute ("reorder");if (att && att != null) {this.reorderable = (att == "false") ? false : true;}att = this.getAttribute ("reparent");if (att && att != null) {this.reparentable = (att == "false") ? false : true;}this.draggable = (this.reparentable || this.reorderable);att = this.getAttribute ("onSelect");if (att && att != null) {this.selectFunc = eval (att);}att = this.getAttribute ("onBeforeAttach");if (att && att != null) {this.attachBeforeFunc = eval (att);}att = this.getAttribute ("onAfterAttach");if (att && att != null) {this.attachAfterFunc = eval (att);}att = this.getAttribute ("onAttach");if (att && att != null) {this.attachFunc = eval (att);}att = this.getAttribute ("onDetach");if (att && att != null) {this.detachFunc = eval (att);}att = this.getAttribute ("src");if (!att || att == null) {return true;}else {var q = new BwQuery();q.get (att);var r = q.getXML();BwTree.initFromXML (r.documentElement, this);return false;}};BwTree.initFromXML = function (src, dst){var im = src.getAttribute ("image");var la = src.getAttribute ("label");var n = BwNode.newInstance (im, la);n.attach (dst);var c = src.childNodes;for (var i = 0; i < c.length; i++) {if (c[i].nodeType == 1) {BwTree.initFromXML (c[i], n);}}};BwTree.acceptAttach = function (src, dst, tier){if (dst == null || src == null || dst.isaDescendantOf (src)) {return false;}var tree = src.getParentWidget(BwTree);var bros = src.getParentWidget() == dst.getParentWidget(); switch (tier){case 1:if (!tree.reorderable || (!tree.reparentable && !bros)) {return false;} else {if (tree.attachBeforeFunc != null) {return tree.attachBeforeFunc (src, dst);} else {return true;}}case 2: if (tree.reparentable) {if (tree.attachFunc != null) {return tree.attachFunc (src, dst);} else {return true;}} else {return false;}case 3:if (!tree.reorderable || (!tree.reparentable && !bros) || (!tree.reparentable && dst.opened)) {return false;} else {if (tree.attachAfterFunc != null) {return tree.attachAfterFunc (src, dst);} else {return true;}}}};BwTree.getSelectedNode = function (){return this.selectedNode;};function BwUtil (){};BwUtil.findParentElement = function (element, parentNodeName, parentClassName, parentId){var e = element.parentNode;while (e != null){var n = (e.nodeName == parentNodeName);var c = (e.className == parentClassName);var i = (e.id == parentId);if (((parentNodeName != null && n) || (parentNodeName == null && !n)) &&((parentClassName != null && c) || (parentClassName == null && !c)) &&((parentId != null && i)  || (parentId == null && !i))) {return e;}e = e.parentNode;}return null;};BwUtil.findContainerWidget = function (element, widgetClass){var e = element.parentNode;while (e != null){if (e.BwClass) {if (!widgetClass) {return e;} else {if (e.BwClass == widgetClass) {return e;}}}e = e.parentNode;}return null;};BwUtil.getElementTopPosition = function (e){var t = e.offsetTop;var p = e.offsetParent;while (p) {t += p.offsetTop;p = p.offsetParent;}return t;};BwUtil.getElementLeftPosition = function (e){var l = e.offsetLeft;var p = e.offsetParent;while (p) {l += p.offsetLeft;p = p.offsetParent;}return l;};BwUtil.forceRedraw = function(){if (navigator.product == "Gecko"){document.body.style.display = "inline";document.body.style.display = "block";}};BwUtil.call = function (obj, func){if (obj == null || func == null) return;if (typeof func == 'function') return func.call (obj);else return eval(func);};BwClasses["BwView"] = BwView;function BwView (){this.isa = BwWidget;this.isa();this.bootstrapped = false;this.initFromDOM = BwView.initFromDOM;this.show = BwView.show;this.clear = BwView.clear;}BwView.newInstance = function (){var self = document.createElement ("div");self.BwClass = BwView;self.BwClass();self.initFromDOM();return self;};BwView.initFromDOM = function (){BwWidget.initFromDOM.call (this);this.hide();this.bootstrapped = false;var v = this.getAttribute ("visible");if (v == 'true' || v == true) {this.show();	}return false;};BwView.show = function (){BwWidget.show.call (this);if (!this.bootstrapped) {BwBootstrapElement (this);this.bootstrapped = true;}};BwView.clear = function (){this.innerHTML='';};function BwWidget (){this.initFromDOM = BwWidget.initFromDOM;this.initFromDOMBubbling = BwWidget.initFromDOMBubbling;this.show = BwWidget.show;this.hide = BwWidget.hide;this.visible = BwWidget.visible;this.detach = BwWidget.detach;this.attach = BwWidget.attach;this.attachBefore = BwWidget.attachBefore;this.attachAfter = BwWidget.attachAfter;this.getValue = BwWidget.getValue;this.setValue = BwWidget.setValue;this.getParentWidget = BwWidget.getParentWidget;this.isaDescendantOf = BwWidget.isaDescendantOf;}BwWidget.initFromDOM = function (){return true;};BwWidget.initFromDOMBubbling = function (){};BwWidget.show = function (){this.style.display = "block";};BwWidget.hide = function (){this.style.display = "none";};BwWidget.visible = function (){return (this.style.display != "none");};BwWidget.detach = function (){var p = this.parentNode;if (p != null) {p.removeChild (this);}};BwWidget.attach = function (node){node.appendChild (this);};BwWidget.attachBefore = function (node){node.parentNode.insertBefore (this, node);};BwWidget.attachAfter = function (node){var n = node.nextSibling;var p = node.parentNode;if (n != null) {p.insertBefore (this, n);} else {p.appendChild (this);}};BwWidget.getValue = function (){return null;};BwWidget.setValue = function (val){};BwWidget.isaDescendantOf = function (widget){var w = this;while (w != null){if (w == widget) return true;w = w.parentNode;}return false;};BwWidget.getParentWidget = function (widgetClass){return BwUtil.findContainerWidget (this, widgetClass);};function BwXml() { }BwXml.pathCache = new Object();BwXml.compilePath = function (path){var code = "var n=r;";var start = 0;var end = false;while (!end){var stop = path.indexOf('.', start);if (stop == -1) {stop = path.length;end = true;}var e = path.substring (start, stop);var a = null;var p = e.indexOf ('@');if (p != -1) {a = e.substring (p+1, e.length);e = e.substring (0, p);}var i = 0;var bo = e.indexOf ('[');if (bo != -1) {var bc = e.indexOf (']', bo);if (bc != -1){i = e.substring (bo+1,bc);e = e.substring (0,bo);}}if (e != "" || i != 0) {code=code+("n=BwXml.el(n,'"+e+"',"+i+",c);");}if (a != null && end) {code=code+("n=BwXml.at(n,'"+a+"',c);");}start=stop+1;}return new Function("r","c",code+"return n;");};BwXml.navigate = function (path, root, create){var c = BwXml.pathCache[path];if (!c || c == null) {c = BwXml.compilePath (path);BwXml.pathCache[path] = c;}return c(root,create);};BwXml.childrenNamed = function (parent, name){var n = new Array();var i = 0;var c = parent.firstChild;while (c != null){if (c.nodeType == 1 && c.nodeName == name) {n[i++] = c;}c = c.nextSibling;}return n;};BwXml.childElementNamedAtIndex = function (node, name, index, create){if (name == '') return node;var nodes = BwXml.childrenNamed (node, name);var l = nodes.length;if (index < l) return nodes[index];if (!create) return null;var gap = index - l + 1;var doc = node.ownerDocument;var n = null;for (var j = 0; j < gap; j++){n = doc.createElement (name);node.appendChild (n);}return n;};BwXml.attributeNamed = function (node, name, create){var a = node.getAttributeNode (name);if (a != null || (a == null && !create)) {return a;}node.setAttribute (name, "");return node.getAttributeNode (name);};BwXml.el = BwXml.childElementNamedAtIndex;BwXml.at = BwXml.attributeNamed;BwXml.getNodeValue = function (node){var c = node.childNodes;var l = c.length;for (var i = 0; i < l; i++){var n = c[i];if (n.nodeType == 3) {return n.nodeValue;}}return null;};BwXml.removeNode = function (node){var n = node;if (n.nodeType == 2) {n.ownerElement.removeAttributeNode (n);} else {n.parentNode.removeChild (n);}return n;};BwXml.countHomonymNodes = function (node){if (node.nodeType == 2) return 1;var n = BwXml.childrenNamed (node.parentNode, node.nodeName);return n.length;};BwXml.setNodeValue = function (node, value){if (node.nodeType == 2){node.value = value;return;}var c = node.childNodes;var l = c.length;for (var i = 0; i < l; i++){var n = c[i];if (n.nodeType == 3){if (value != null) n.data = value;else node.removeChild (n);return;}}if (value != null){var f = node.firstChild;var t = node.ownerDocument.createTextNode (value);if (f == null) {node.appendChild (t);} else {node.insertBefore (t, f);}}};