/*****************************************************************

	ActiveUI 0.1.5 - cross-browser DHTML widgets toolkit.
	Copyright (C) 2003 ActiveUI Software Ltd. All rights reserved. 
	More information at http://www.activeui.net/

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*****************************************************************/

 if(!window.Active){var Active={}}if(!Active.System){Active.System={}}if(!Active.HTML){Active.HTML={}}if(!Active.Templates){Active.Templates={}}if(!Active.HTTP){Active.HTTP={}}if(!Active.Text){Active.Text={}}if(!Active.XML){Active.XML={}}if(!Active.Controls){Active.Controls={}}(function(){if(!window.HTMLElement){return}var element=HTMLElement.prototype;element.setCapture=function(){};element.releaseCapture=function(){};element.attachEvent=function(name,handler){if(typeof handler !="function"){return}var nsName=name.replace(/^on/,"");var nsHandler=function(event){window.event=event;handler();window.event=null;};handler[name]=nsHandler;this.addEventListener(nsName,nsHandler,false);};element.detachEvent=function(name,handler){if(typeof handler !="function"){return}var nsName=name.replace(/^on/,"");this.removeEventListener(nsName,handler[name],false);handler[name]=null;};var getClientWidth=function(){return this.offsetWidth - 20;};var getClientHeight=function(){return this.offsetHeight - 20;};element.__defineGetter__("clientWidth",getClientWidth);element.__defineGetter__("clientHeight",getClientHeight);var getRuntimeStyle=function(){return this.style;};element.__defineGetter__("runtimeStyle",getRuntimeStyle);var setOuterHtml=function(s){var range=this.ownerDocument.createRange();range.setStartBefore(this);var fragment=range.createContextualFragment(s);this.parentNode.replaceChild(fragment,this);};element.__defineSetter__("outerHTML",setOuterHtml);})();(function(){if(!window.Event){return}var event=Event.prototype;if(!event){return}var getSrcElement=function(){return(this.target.nodeType==3)?this.target.parentNode:this.target;};event.__defineGetter__("srcElement",getSrcElement);var setReturnValue=function(value){if(!value){this.preventDefault()}};event.__defineSetter__("returnValue",setReturnValue);})();(function(){if(!window.CSSStyleSheet){return}var stylesheet=CSSStyleSheet.prototype;stylesheet.addRule=function(selector,rule){this.insertRule(selector+"{"+rule+"}",this.cssRules.length);};stylesheet.__defineGetter__("rules",function(){return this.cssRules});})();(function(){if(!window.XMLHttpRequest){return}var ActiveXObject=function(type){ActiveXObject[type](this);};ActiveXObject["MSXML2.DOMDocument"]=function(obj){obj.setProperty=function(){};obj.load=function(url){var xml=this;var async=this.async?true:false;var request=new XMLHttpRequest();request.open("GET",url,async);request.overrideMimeType("text/xml");if(async){request.onreadystatechange=function(){xml.readyState=request.readyState;if(request.readyState==4){xml.documentElement=request.responseXML.documentElement;xml.firstChild=xml.documentElement;request.onreadystatechange=null;}if(xml.onreadystatechange){xml.onreadystatechange()}}}this.parseError={errorCode:0,reason:"Emulation"};request.send(null);this.readyState=request.readyState;if(request.responseXML && !async){this.documentElement=request.responseXML.documentElement;this.firstChild=this.documentElement;}}};window.ActiveXObject=ActiveXObject;})();(function(){if(!window.XPathEvaluator){return}var elemXPathEvaluator=new XPathEvaluator();var element=Element.prototype;var attribute=Attr.prototype;element.selectNodes=function(path){var result=elemXPathEvaluator.evaluate(path,this,null,7,null);result.length=result.snapshotLength;result.item=function(i){return result.snapshotItem(i)};for(var i=0;i<result.length;i++){result[i]=result.snapshotItem(i)}return result;};element.selectSingleNode=function(path){var nodes=this.selectNodes(path);return(nodes.length)?nodes.item(0):null;};element.__defineGetter__("text",function(){return this.firstChild.nodeValue});attribute.__defineGetter__("text",function(){return this.nodeValue});})(); Active.System.Object=function(){};Active.System.Object.subclass=function(){var constructor=function(){this.init()};for(var i in this){constructor[i]=this[i]}constructor.prototype=new this();constructor.superclass=this;return constructor;};Active.System.Object.handle=function(error){throw(error);};Active.System.Object.create=function(){var obj=this.prototype;obj.clone=function(){if(this._clone.prototype!==this){this._clone=function(){this.init()};this._clone.prototype=this;}return new this._clone();};obj._clone=function(){};obj.init=function(){};obj.handle=function(error){throw(error);};obj.timeout=function(handler,delay){var self=this;var wrapper=function(){handler.call(self)};return window.setTimeout(wrapper,delay?delay:0);};obj.toString=function(){return "";};};Active.System.Object.create(); Active.System.Model=Active.System.Object.subclass();Active.System.Model.create=function(){var obj=this.prototype;var concat=function(){var i,s=arguments[0];for(i=1;i<arguments.length;i++){s+=arguments[i].substr(0,1).toUpperCase()+arguments[i].substr(1);}return s;};var get={};obj.getProperty=function(name,a,b,c){if(!get[name]){get[name]=concat("get",name)}return this[get[name]](a,b,c);};var set={};obj.setProperty=function(name,value,a,b,c){if(!set[name]){set[name]=concat("set",name)}return this[set[name]](value,a,b,c);};};Active.System.Model.create(); Active.System.HTML=Active.System.Object.subclass();Active.System.HTML.create=function(){var obj=this.prototype;obj.setTag=function(tag){this._tag=tag;};obj.getTag=function(){return this._tag;};obj._tag="div";obj.getId=function(){if(this.$self !==this){this.$self=this;if(this.$owner){this._id=this.$owner.getId()+"."+this.$name;}else if(this._parent){this._id=this._parent.getId()+"/"+this.$name;}else{this._id="tag"+this.all.id++;this.all[this._id]=this;}}return this.$index===""?this._id:this._id+":"+this.$index;};obj._id="";obj.all=Active.System.all={id:0};obj.setId=function(id){this._id=id;this.all[this._id]=this;this.$self=this;};obj.element=function(){var i,docs=this._docs,id=this.getId(),e;for(i in docs){e=docs[i].getElementById(id);if(e){return e}}};obj._docs=[document];obj.getClass=function(name){var param="_"+name+"Class";var value=this[param];return typeof(value)=="function"?value():value;};obj.setClass=function(name,value){var element=this.element();if(element){element.className=element.className.replace(new RegExp("(active-"+name+"-\\w+|$)")," active-"+name+"-"+value+" ");if(this.$index !==""){return}}if(this.data){return}var param="_"+name+"Class";if(this[param]==null){this._classes+=" "+name}this[param]=value;this._outerHTML="";};obj._classes="";obj.getStyle=function(name){var param="_"+name+"Style";var value=this[param];return typeof(value)=="function"?value():value;};obj.setStyle=function(name,value){var element=this.element();if(element){element.style[name]=value}if(this.data){return}var param="_"+name+"Style";if(this[param]==null){this._styles+=" "+name}this[param]=value;this._outerHTML="";};obj._styles="";obj.getAttribute=function(name){try{var param="_"+name+"Attribute";var value=this[param];return typeof(value)=="function"?value():value;}catch(error){this.handle(error);}};obj.setAttribute=function(name,value){try{var param="_"+name+"Attribute";if(this[param]==null){this._attributes+=" "+name}this[param]=value;this._outerHTML="";}catch(error){this.handle(error);}};obj._attributes="";obj.getEvent=function(name){try{var param="_"+name+"Event";var value=this[param];return value;}catch(error){this.handle(error);}};obj.setEvent=function(name,value){try{var param="_"+name+"Event";if(this[param]==null){this._events+=" "+name}this[param]=value;this._outerHTML="";}catch(error){this.handle(error);}};obj._events="";obj.getContent=function(name){try{var split=name.match(/^(\w+)\W(.+)$/);if(split){var ref=this.getContent(split[1]);return ref.getContent(split[2]);}else{var param="_"+name+"Content";var value=this[param];if((typeof value=="object")&&(value._parent !=this)){value=value.clone();value._parent=this;value.$name=name;this[param]=value;}return value;}}catch(error){this.handle(error);}};obj.setContent=function(name,value){try{if(arguments.length==1){this._content="";if(typeof name=="object"){for(var i in name){this.setContent(i,name[i])}}else{this.setContent("html",name);}}else{var split=name.match(/^(\w+)\W(.+)$/);if(split){var ref=this.getContent(split[1]);ref.setContent(split[2],value);this._innerHTML="";this._outerHTML="";}else{var param="_"+name+"Content";if(this[param]==null){this._content+=" "+name}if(typeof value=="object"){value._parent=this}this[param]=value;this._innerHTML="";this._outerHTML="";}}}catch(error){this.handle(error);}};obj._content="";obj.$index="";var getParamStr=function(i){return "{#"+i+"}"};obj.innerHTML=function(){try{if(this._innerHTML){return this._innerHTML}this._innerParamLength=0;var i,j,name,value,param1,param2,html,item,s="";var content=this._content.split(" ");for(i=1;i<content.length;i++){name=content[i];value=this["_"+name+"Content"];if(typeof(value)=="function"){param=getParamStr(this._innerParamLength++);this[param]=value;s+=param;}else if(typeof(value)=="object"){item=value;html=item.outerHTML().replace(/\{id\}/g,"{id}/"+name);for(j=item._outerParamLength-1;j>=0;j--){param1=getParamStr(j);param2=getParamStr(this._innerParamLength+j);if(param1 !=param2){html=html.replace(param1,param2)}this[param2]=item[param1];}this._innerParamLength+=item._outerParamLength;s+=html;}else{s+=value;}}this._innerHTML=s;return s;}catch(error){this.handle(error);}};obj.outerHTML=function(){try{if(this._outerHTML){return this._outerHTML}var innerHTML=this.innerHTML();this._outerParamLength=this._innerParamLength;if(!this._tag){return innerHTML}var i,tmp,name,value,param;var html="<"+this._tag+" id=\"{id}\"";tmp="";var classes=this._classes.split(" ");for(i=1;i<classes.length;i++){name=classes[i];value=this["_"+name+"Class"];if(typeof(value)=="function"){param=getParamStr(this._outerParamLength++);this[param]=value;value=param;}tmp+="active-"+name+"-"+value+" ";}if(tmp){html+=" class=\""+tmp+this.$browser+"\""}tmp="";var styles=this._styles.split(" ");for(i=1;i<styles.length;i++){name=styles[i];value=this["_"+name+"Style"];if(typeof(value)=="function"){param=getParamStr(this._outerParamLength++);this[param]=value;value=param;}tmp+=name+":"+value+";";}if(tmp){html+=" style=\""+tmp+"\""}tmp="";var attributes=this._attributes.split(" ");for(i=1;i<attributes.length;i++){name=attributes[i];value=this["_"+name+"Attribute"];if(typeof(value)=="function"){param=getParamStr(this._outerParamLength++);this[param]=value;value=param;}tmp+=" "+name+"=\""+value+"\"";}html+=tmp;tmp="";var events=this._events.split(" ");for(i=1;i<events.length;i++){name=events[i];value=this["_"+name+"Event"];if(typeof(value)=="function"){value="dispatch(event,this)";}tmp+=" "+name+"=\""+value+"\"";}html+=tmp;html+=">"+innerHTML+"</"+this._tag+">";this._outerHTML=html;return html;}catch(error){this.handle(error);}};obj.toString=function(){try{var i,s=this._outerHTML;if(!s){s=this.outerHTML()}s=s.replace(/\{id\}/g,this.getId());var max=this._outerParamLength;for(i=0;i<max;i++){var param="{#"+i+"}";var value=this[param]();s=s.replace(param,value);}return s;}catch(error){this.handle(error);}};obj.refresh=function(){try{var element=this.element();if(element){element.outerHTML=this.toString()}}catch(error){this.handle(error);}};obj.$browser="";if(window.__defineGetter__){obj.$browser="gecko"}if(navigator.userAgent.match("Opera")){obj.$browser="opera"}if(navigator.userAgent.match("Konqueror")){obj.$browser="khtml"}if(navigator.userAgent.match("KHTML")){obj.$browser="khtml"}};Active.System.HTML.create();var dispatch=function(event,element){var parts=element.id.split("/");var tag=parts[0].split(".");var obj=Active.System.all[tag[0]];var type="_on"+event.type+"Event";var i;for(i=1;i<tag.length;i++){var params=tag[i].split(":");obj=obj.getTemplate.apply(obj,params);}var target=obj;for(i=1;i<parts.length;i++){target=target.getContent(parts[i]);}if(window.HTMLElement){window.event=event}target[type].call(obj,event);if(window.HTMLElement){window.event=null}return;};var mouseover=function(element,name){try{var t=new Date();element.className+=" "+name;}catch(error){}};var mouseout=function(element,name){try{var t=new Date();element.className=element.className.replace(" "+name,"");}catch(error){}}; Active.System.Template=Active.System.HTML.subclass();Active.System.Template.create=function(){var obj=this.prototype;var _super=this.superclass.prototype;var _pattern=/^(\w+)\W(.+)$/;var join=function(){var i,s=arguments[0];for(i=1;i<arguments.length;i++){s+=arguments[i].substr(0,1).toUpperCase()+arguments[i].substr(1)}return s;};obj.defineModel=function(name){var external="_"+name+"Model";var defineProperty=join("define",name,"property");var definePropertyArray=join("define",name,"property","array");var getProperty=join("get",name,"property");var setProperty=join("set",name,"property");var get={};var set={};var getModel=join("get",name,"model");var setModel=join("set",name,"model");var updateModel=join("update",name,"model");this[defineProperty]=function(property,defaultValue){var _getProperty=join("get",name,property);var _setProperty=join("set",name,property);var _property="_"+join(name,property);var getPropertyMethod=function(){return this[_property];};this[_getProperty]=getPropertyMethod;this[_setProperty]=function(value){if(typeof value=="function"){this[_getProperty]=value;}else{if(this[_getProperty] !==getPropertyMethod){this[_getProperty]=getPropertyMethod}this[_property]=value;}this[updateModel](property);};this[_setProperty](defaultValue);};this[getProperty]=function(property,a,b,c){try{if(this[external]){return this[external].getProperty(property,a,b,c)}if(!get[property]){get[property]=join("get",name,property)}return this[get[property]](a,b,c);}catch(error){return this.handle(error);}};this[setProperty]=function(property,value,a,b,c){try{if(this[external]){return this[external].setProperty(property,a,b,c)}if(!set[property]){set[property]=join("set",name,property)}return this[set[property]](value,a,b,c);}catch(error){return this.handle(error);}};obj[getProperty]=function(property,a,b,c){if(this[external]){return this[external].getProperty(property,a,b,c)}return this.$owner[getProperty](property,a,b,c);};obj[setProperty]=function(property,value,a,b,c){if(this[external]){return this[external].setProperty(property,a,b,c)}return this.$owner[setProperty](property,value,a,b,c);};this[definePropertyArray]=function(property,defaultValue){var _getProperty=join("get",name,property);var _setProperty=join("set",name,property);var _getArray=join("get",name,property+"s");var _setArray=join("set",name,property+"s");var _array="_"+join(name,property+"s");var _getCount=join("get",name,"count");var _setCount=join("set",name,"count");var getFromArray=function(index){return this[_array][index];};var getStatic=function(){return this[_array];};var getNew=function(){var i,a=[],max=this[_getCount]();for(i=0;i<max;i++){a[i]=this[_getProperty](i)}return a;};this[_setProperty]=function(value,index){if(typeof value=="function"){this[_getProperty]=value;this[_getArray]=getNew;}else if(arguments.length==1){this[_array]=value;this[_getProperty]=getStatic;this[_getArray]=getNew;}else{if(this[_getArray] !=getStatic){this[_array]=this[_getArray]()}this[_array][index]=value;this[_getProperty]=getFromArray;this[_getArray]=getStatic;}this[updateModel](property);};this[_setArray]=function(value){if(typeof value=="function"){this[_getArray]=value;}else{this[_array]=value;this[_getProperty]=getFromArray;this[_getArray]=getStatic;this[_setCount](value.length);}this[updateModel](property);};this[_setProperty](defaultValue);};var proxyPrototype=new Active.System.Model;proxyPrototype.getProperty=function(property,a,b,c){return this._target[getProperty](property,a,b,c);};var proxy=join("_",name,"proxy");this[getModel]=function(){if(this[external]){return this[external]}if(!this[proxy]){this[proxy]=proxyPrototype.clone();this[proxy]._target=this;this[proxy].$owner=this.$owner;}return this[proxy];};obj[setModel]=function(model){this[external]=model;if(model){model.$owner=this}};obj[getModel]=function(a,b,c){if(this[external]){return this[external]}return this.$owner[getModel](a,b,c);};this[updateModel]=function(){};};obj.getModel=function(name){var getModel=join("get",name,"model");return this[getModel]();};obj.setModel=function(name,model){var setModel=join("set",name,"model");return this[setModel](model);};obj.defineProperty=function(name,defaultValue){if(name.match(_pattern)){var defineProperty=join("define",RegExp.$1,"property");if(this[defineProperty]){return this[defineProperty](RegExp.$2,defaultValue)}}};obj.definePropertyArray=function(name,defaultValue){if(name.match(_pattern)){var defineArray=join("define",RegExp.$1,"property","array");if(this[defineArray]){return this[defineArray](RegExp.$2,defaultValue)}}};obj.getProperty=function(name,a,b,c){if(name.match(_pattern)){var getProperty=join("get",RegExp.$1,"property");if(this[getProperty]){return this[getProperty](RegExp.$2,a,b,c)}}};obj.setProperty=function(name,value,a,b,c){if(name.match(_pattern)){var setProperty=join("set",RegExp.$1,"property");if(this[setProperty]){return this[setProperty](RegExp.$2,value,a,b,c)}}};obj.defineTemplate=function(name,template){var ref="_"+name+"Template";var get=join("get",name,"template");var set=join("set",name,"template");var getDefault=join("default",name,"template");this[get]=this[getDefault]=function(a,b,c){if(this[ref].$owner !=this){this[set](this[ref].clone())}if(a==null){return this[ref]}this[ref].$index=a;if(b==null){return this[ref]}this[ref].$index+=":"+b;if(c==null){return this[ref]}this[ref].$index+=":"+c;return this[ref];};obj[get]=function(a,b,c){return this.$owner[get](a,b,c);};obj[set]=function(template){this[ref]=template;if(template){template.$owner=this;template.$name=name;}};this[set](template);};obj.getTemplate=function(name){if(name.match(_pattern)){var get=join("get",RegExp.$1,"template");arguments[0]=RegExp.$2;var template=this[get]();return template.getTemplate.apply(template,arguments);}else{get=join("get",name,"template");var i,args=[];for(i=1;i<arguments.length;i++){args[i-1]=arguments[i]}return this[get].apply(this,args);}};obj.setTemplate=function(name,template,index){if(name.match(_pattern)){var get=join("get",RegExp.$1,"template");var n=RegExp.$2;this[get]().setTemplate(n,template,index);}else{var set=join("set",name,"template");this[set](template,index);}};obj.setAction=function(name,value){this["_"+name+"Action"]=value;};obj.action=function(name,source){if(!source){source=this}var action=this["_"+name+"Action"];if(typeof(action)=="function"){action.call(this,source)}else if(this.$owner){this.$owner.action(name,source)}};};Active.System.Template.create(); Active.System.Control=Active.System.Template.subclass();Active.System.Control.create=function(){var obj=this.prototype;obj.setEvent("oncontextmenu","return false");obj.setEvent("onselectstart","return false");};Active.System.Control.create(); Active.HTML.define=function(name,tag,type){if(!tag){tag=name.toLowerCase()}Active.HTML[name]=Active.System.HTML.subclass();Active.HTML[name].prototype.setTag(tag);};Active.HTML.define("DIV");Active.HTML.define("SPAN");Active.HTML.define("IMG");Active.HTML.define("TABLE");Active.HTML.define("TR");Active.HTML.define("TD"); Active.Templates.Text=Active.System.Template.subclass();Active.Templates.Text.create=function(){var obj=this.prototype;obj.setClass("templates","text");obj.setContent("text",function(){return this.getItemProperty("text")});obj.setEvent("onclick",function(){this.action("click")});};Active.Templates.Text.create(); Active.Templates.Image=Active.System.Template.subclass();Active.Templates.Image.create=function(){var obj=this.prototype;obj.setClass("templates","image");var image=new Active.HTML.SPAN;image.setClass("box","image");image.setClass("image",function(){return this.getItemProperty("image")});obj.setContent("image",image);obj.setContent("text",function(){return this.getItemProperty("text")});obj.setEvent("onclick",function(){this.action("click")});};Active.Templates.Image.create(); Active.Templates.Item=Active.System.Template.subclass();Active.Templates.Item.create=function(){var obj=this.prototype;obj.setClass("templates","item");obj.setClass("box","normal");var box=new Active.HTML.DIV;var image=new Active.HTML.SPAN;box.setClass("box","item");image.setClass("box","image");image.setClass("image",function(){return this.getItemProperty("image")});obj.setContent("box",box);obj.setContent("box/image",image);obj.setContent("box/text",function(){return this.getItemProperty("text")});};Active.Templates.Item.create(); Active.Templates.List=Active.System.Template.subclass();Active.Templates.List.create=function(){var obj=this.prototype;obj.setTag("");obj.defineTemplate("item",new Active.Templates.Text);var getItemProperty=function(property){return this.$owner.getDataProperty(property,this.$index);};obj.getItemTemplate=function(index){var template=this.defaultItemTemplate(index);if(!this._selected){this._selected=[];this.timeout(function(){this._selected=null});var i,values=this.getSelectionProperty("values");for(i=0;i<values.length;i++){this._selected[values[i]]=true}template.getItemProperty=getItemProperty;template.setClass("list","item");}if(this._selected[index]){template=template.clone();template.$index="";template.setClass("selection",true);template.$index=index;}return template;};var html=function(){var i,result=[],items=this.getItemsProperty("values");for(i=0;i<items.length;i++){result[i]=this.getItemTemplate(items[i]).toString()}return result.join("");};obj.setContent("html",html);};Active.Templates.List.create(); Active.Templates.Row=Active.Templates.List.subclass();Active.Templates.Row.create=function(){var obj=this.prototype;var _super=this.superclass.prototype;obj.setTag("div");obj.setClass("templates","row");obj.getDataProperty=function(property,i){return this.$owner.getDataProperty(property,this.$index,i);};obj.getItemsProperty=function(property){return this.getColumnProperty(property);};obj.getSelectionProperty=function(property){return this.getDummyProperty(property);};var getItemProperty=function(property){return this.$owner.getDataProperty(property,this.$index);};obj._itemTemplates=[];obj.getItemTemplate=function(i){if(this._itemTemplates[i]){this._itemTemplates[i].$self="";return this._itemTemplates[i];}var template=_super.getItemTemplate.call(this,i).clone();template.$index=i;template.setClass("column",i);template.setClass("row","cell");this._itemTemplates[i]=template;return template;};obj.setItemTemplate=function(template,i){if(arguments.length==1){return _super.setItemTemplate.call(this,template)}template.setClass("column",i);template.setClass("row","cell");template.$owner=this;template.$index=i;template.$name="item";template.getItemProperty=getItemProperty;this._itemTemplates[i]=template;};obj.setEvent("onclick",function(){this.action("selectRow")});};Active.Templates.Row.create(); Active.Templates.Header=Active.Templates.Item.subclass();Active.Templates.Header.create=function(){var obj=this.prototype;obj.setClass("templates","header");obj.setClass("column",function(){return this.$index});obj.setClass("sort",function(){return this.getSortProperty("index")!=this.$index?"none":this.getSortProperty("direction");});obj.setAttribute("title",function(){return this.getItemProperty("tooltip")});var div=new Active.HTML.DIV;div.setClass("box","div");div.setEvent("onmousedown",function(){this.action("startColumnResize")});div.setContent("html","&nbsp;");obj.setContent("div",div);obj.setEvent("onmousedown",function(){this.setClass("header","pressed");window.status="Sorting...";this.timeout(function(){this.action("columnSort")});});var sort=new Active.HTML.SPAN;sort.setClass("box","sort");obj.setContent("box/sort",sort);};Active.Templates.Header.create(); Active.Templates.Box=Active.System.Template.subclass();Active.Templates.Box.create=function(){var obj=this.prototype;obj.setClass("templates","box");obj.setClass("box","normal");var box=new Active.HTML.DIV;box.setClass("box","item");obj.setContent("box",box);};Active.Templates.Box.create(); Active.Templates.Scroll=Active.System.Template.subclass();Active.Templates.Scroll.create=function(){var obj=this.prototype;var _super=this.superclass.prototype;obj.setTag("");var Pane=Active.HTML.DIV;var Box=Active.Templates.Box;var data=new Pane;var top=new Pane;var left=new Pane;var corner=new Box;var fill=new Box;var scrollbars=new Pane;var space=new Pane;data.setClass("scroll","data");top.setClass("scroll","top");left.setClass("scroll","left");corner.setClass("scroll","corner");fill.setClass("scroll","fill");scrollbars.setClass("scroll","bars");space.setClass("scroll","space");obj.setContent("data",data);obj.setContent("top",top);obj.setContent("left",left);obj.setContent("corner",corner);obj.setContent("scrollbars",scrollbars);obj.setContent("data/html",function(){return this.getDataTemplate()});obj.setContent("top/html",function(){return this.getTopTemplate()});obj.setContent("left/html",function(){return this.getLeftTemplate()});obj.setContent("scrollbars/space",space);obj.setContent("top/fill",fill);var scroll=function(){var scrollbars=this.getContent("scrollbars").element();var data=this.getContent("data").element();var top=this.getContent("top").element();var left=this.getContent("left").element();var x=scrollbars.scrollLeft;var y=scrollbars.scrollTop;data.scrollLeft=x;top.scrollLeft=x;data.scrollTop=y;left.scrollTop=y;scrollbars=null;data=null;top=null;left=null;};scrollbars.setEvent("onscroll",scroll);var resize=function(){if(sizeAdjusted){sizeAdjusted=false;this.timeout(adjustSize,100);var data=this.getContent("data").element();var scrollbars=this.getContent("scrollbars").element();var top=this.getContent("top").element();var left=this.getContent("left").element();data.runtimeStyle.width="100%";top.runtimeStyle.width="100%";data.runtimeStyle.height="100%";left.runtimeStyle.height="100%";scrollbars.runtimeStyle.zIndex=1000;data=null;scrollbars=null;top=null;left=null;}};scrollbars.setEvent("onresize",resize);var sizeAdjusted=true,windowFlag=true;var adjustSize=function(){var self=this;if(window.addEventListener && windowFlag){windowFlag=false;window.addEventListener("resize",function(){resize.call(self)},false);}var data=this.getContent("data").element();var scrollbars=this.getContent("scrollbars").element();var top=this.getContent("top").element();var left=this.getContent("left").element();var space=this.getContent("scrollbars/space").element();if(data){space.runtimeStyle.height=data.scrollHeight > data.offsetHeight?data.scrollHeight:0;space.runtimeStyle.width=data.scrollWidth > data.offsetWidth?data.scrollWidth:0;var y=scrollbars.clientHeight;var x=scrollbars.clientWidth;data.runtimeStyle.width=x;top.runtimeStyle.width=x;data.runtimeStyle.height=y;left.runtimeStyle.height=y;top.scrollLeft=data.scrollLeft;left.scrollTop=data.scrollTop;scrollbars.runtimeStyle.zIndex=0;}data=null;scrollbars=null;top=null;left=null;space=null;sizeAdjusted=true;};obj.setAction("adjustSize",function(){this.timeout(adjustSize,500);});obj.toString=function(){this.timeout(adjustSize);return _super.toString.call(this);};};Active.Templates.Scroll.create(); Active.Controls.Grid=Active.System.Control.subclass();Active.Controls.Grid.create=function(){var obj=this.prototype;obj.setClass("controls","grid");obj.defineTemplate("layout",new Active.Templates.Scroll);obj.defineTemplate("data",new Active.Templates.List);obj.defineTemplate("left",new Active.Templates.List);obj.defineTemplate("top",new Active.Templates.List);obj.setTemplate("data/item",new Active.Templates.Row);obj.setTemplate("left/item",new Active.Templates.Item);obj.setTemplate("top/item",new Active.Templates.Header);obj.defineModel("row");obj.defineProperty("row/count",function(){return this.getDataProperty("count")});obj.defineProperty("row/index",function(i){return i});obj.definePropertyArray("row/text",function(i){return i+1});obj.definePropertyArray("row/image","none");obj.definePropertyArray("row/value",function(i){return i});obj.defineModel("column");obj.defineProperty("column/count",0);obj.defineProperty("column/index",function(i){return i});obj.definePropertyArray("column/text",function(i){return "Column "+i});obj.definePropertyArray("column/image","none");obj.definePropertyArray("column/value",function(i){return i});obj.definePropertyArray("column/tooltip","");obj.defineModel("data");obj.defineProperty("data/count",0);obj.defineProperty("data/index",function(i){return i});obj.defineProperty("data/text","");obj.defineProperty("data/image","none");obj.defineProperty("data/value",function(i,j){return this.getDataText(i,j)});obj.defineModel("items");obj.defineModel("selection");obj.defineProperty("selection/index",-1);obj.defineProperty("selection/multiple",false);obj.defineProperty("selection/count",0);obj.definePropertyArray("selection/value",0);obj.defineModel("dummy");obj.defineProperty("dummy/count",0);obj.definePropertyArray("dummy/value",-1);obj.defineModel("sort");obj.defineProperty("sort/index",-1);obj.defineProperty("sort/direction","none");obj.getLeftTemplate=function(){var template=this.defaultLeftTemplate();template.setDataModel(this.getRowModel());template.setItemsModel(this.getRowModel());template.setSelectionModel(this.getDummyModel());return template;};obj.getTopTemplate=function(){var template=this.defaultTopTemplate();template.setDataModel(this.getColumnModel());template.setItemsModel(this.getColumnModel());template.setSelectionModel(this.getDummyModel());return template;};obj.getDataTemplate=function(){var template=this.defaultDataTemplate();template.setDataModel(this.getDataModel());template.setItemsModel(this.getRowModel());return template;};obj.getCellTemplate=function(i){return this.getTemplate("data/item/item",i)};obj.setCellTemplate=function(template,i){this.setTemplate("data/item/item",template,i)};obj.setContent(function(){return this.getLayoutTemplate()});obj.setColumnHeaderHeight=function(height){var layout=this.getTemplate("layout");layout.getContent("top").setStyle("height",height);layout.getContent("corner").setStyle("height",height);layout.getContent("left").setStyle("padding-top",height);layout.getContent("data").setStyle("padding-top",height);};obj.setRowHeaderWidth=function(width){var layout=this.getTemplate("layout");layout.getContent("left").setStyle("width",width);layout.getContent("corner").setStyle("width",width);layout.getContent("top").setStyle("padding-left",width);layout.getContent("data").setStyle("padding-left",width);};var startColumnResize=function(header){var el=header.element();var pos=event.clientX;var size=el.offsetWidth;var grid=this;var doResize=function(){var el=header.element();el.style.width=size+event.clientX - pos;el=null;};var endResize=function(){var el=header.element();el.detachEvent("onmousemove",doResize);el.detachEvent("onmouseup",endResize);el.detachEvent("onlosecapture",endResize);el.releaseCapture();var width=size+event.clientX - pos;el.style.width=width;var ss=document.styleSheets[document.styleSheets.length-1];var i,selector=".active-column-"+header.getItemProperty("index");for(i=0;i<ss.rules.length;i++){if(ss.rules[i].selectorText==selector){ss.rules[i].style.width=width;el=null;grid.getTemplate("layout").action("adjustSize");return;}}ss.addRule(".active-column-"+index,"width:"+width+"px");el=null;grid.getTemplate("layout").action("adjustSize");};el.attachEvent("onmousemove",doResize);el.attachEvent("onmouseup",endResize);el.attachEvent("onlosecapture",endResize);el.setCapture();el=null;event.cancelBubble=true;};obj.setAction("startColumnResize",startColumnResize);var setSelectionIndex=obj.setSelectionIndex;obj.setSelectionIndex=function(index){var current=this.getSelectionIndex();this.setSelectionValues([index]);setSelectionIndex.call(this,index);this.timeout(function(){this.getTemplate("data/item",current).refresh();this.getTemplate("data/item",index).refresh();});};var selectRow=function(src){this.setProperty("selection/index",src.getProperty("item/index"));};obj.setAction("selectRow",selectRow);obj.sort=function(index){var i,v1,v2,a={},rows=this.getRowProperty("values"),direction="ascending";if((this.getSortProperty("index")==index)&&(this.getSortProperty("direction")=="ascending")){direction="descending";}for(i=0;i<rows.length;i++){v1=this.getDataProperty("text",i,index);v2=Number(v1.replace(/[,]/g,""));a[i]=isNaN(v2)?v1:v2;}function ascending(x,y){return a[x] > a[y]?1:(a[x]==a[y]?0:-1)}function descending(x,y){return a[x] > a[y]?-1:(a[x]==a[y]?0:1)}rows.sort(direction=="ascending"?ascending:descending);this.setRowProperty("values",rows);this.setSortProperty("index",index);this.setSortProperty("direction",direction);};obj.setAction("columnSort",function(src){var i=src.getItemProperty("index");window.status="Sorting...";this.sort(i);this.refresh();this.timeout(function(){window.status=""});});};Active.Controls.Grid.create(); Active.HTTP.Request=Active.System.Model.subclass();Active.HTTP.Request.create=function(){var obj=this.prototype;obj.setURL=function(url){try{this._url=url;this._http=new ActiveXObject("MSXML2.XMLHTTP");this._http.open("GET",url,false);this._http.send();}catch(error){this.handle(error);}};};Active.HTTP.Request.create(); Active.Text.Table=Active.HTTP.Request.subclass();Active.Text.Table.create=function(){var obj=this.prototype;var _super=this.superclass.prototype;obj.setURL=function(url){_super.setURL.call(this,url);var i,table=[],a=this._http.responseText.split(/\n/);for(i=0;i<a.length;i++){table[i]=a[i].match(/(^[^,"]+(?=,)|[^,"][^"]*(?=(,|",))|[^,"][^"]+[^,"](?=("|$)))/g);}this._data=table;};this._data=[[""]];obj.getCount=function(){return this._data.length;};obj.getText=function(i,j){return this._data[i][j];};obj.getIndex=function(i){return i;};};Active.Text.Table.create(); Active.XML.Model=Active.System.Model.subclass();Active.XML.Model.create=function(){var obj=this.prototype;obj.setRootPath=function(xpath){this._rootPath=xpath;};obj._rootPath="/*";obj.setNodesPath=function(xpath){this._nodesPath=xpath;};obj._nodesPath="*";obj.setURL=function(url){try{this._url=url;this._parser=new ActiveXObject("MSXML2.DOMDocument");this._parser.async=false;this._parser.setProperty("SelectionLanguage","XPath");this._parser.load(url);this._root=this._parser.documentElement.selectSingleNode(this._rootPath);this._nodes=this._root.selectNodes(this._nodesPath);}catch(error){this.handle(error);}};obj.getCount=function(){return this._nodes?this._nodes.length:0;};obj.getIndex=function(i){return i;};};Active.XML.Model.create(); Active.XML.Table=Active.XML.Model.subclass();Active.XML.Table.create=function(){var obj=this.prototype;obj.setTextPath=function(xpathArray){this._textPath=xpathArray;};obj._textPath=[];for(var i=0;i<100;i++){obj._textPath[i]="*["+(i+1)+"]"}obj.getText=function(i,j){if(!this._nodes){return ""}var node=this._nodes.item(i).selectSingleNode(this._textPath[j]);return node?node.text:"";};};Active.XML.Table.create();
