packages feed

hledger-web (empty) → 0.13

raw patch · 16 files changed

+4986/−0 lines, 16 filesdep +basedep +bytestringdep +directorysetup-changedbinary-added

Dependencies added: base, bytestring, directory, failure, file-embed, filepath, hamlet, hledger, hledger-lib, io-storage, parsec, safe, template-haskell, wai-extra, yesod

Files

+ .hledger/web/combo_select.gif view

binary file changed (absent → 309 bytes)

+ .hledger/web/dhtmlxcombo.js view
@@ -0,0 +1,1359 @@+//v.2.6 build 100722++/*
+Copyright DHTMLX LTD. http://www.dhtmlx.com
+You allowed to use this component or parts of it under GPL terms
+To use it on other terms or get Professional edition of the component please contact us at sales@dhtmlx.com
+*/+
+/*_TOPICS_
+@0:Initialization
+@1:Selection control
+@2:Add/delete
+@3:Reserved
+@4:Methods of Option object
+*/
+
+/**
+*  Build combobox from existing select control.
+*
+*
+*  @param   parent      {string} id of existing select control
+*  @param   size      {int } size of control, optional
+*  @return            {object} combobox object
+*  @type   public
+*  @topic   0
+*
+*/
+
+function dhtmlXComboFromSelect(parent,size){
+   if (typeof(parent)=="string")
+      parent=document.getElementById(parent);
+   
+   
+   size=size||parent.getAttribute("width")||(window.getComputedStyle?window.getComputedStyle(parent,null)["width"]:(parent.currentStyle?parent.currentStyle["width"]:0));
+   if ((!size)||(size=="auto"))
+   		size=parent.offsetWidth||100;
+
+   var z=document.createElement("SPAN");
+   
+	
+  
+   parent.parentNode.insertBefore(z,parent);
+   parent.style.display='none';
+
+    var s_type = parent.getAttribute('opt_type');
+	
+   var w= new dhtmlXCombo(z,parent.name,size,s_type,parent.tabIndex);
+   
+   var x=new Array();
+   var sel=0;
+   for (var i=0; i<parent.options.length; i++){
+      if (parent.options[i].selected) sel=i;
+      var label=parent.options[i].innerHTML;
+      var val=parent.options[i].getAttribute("value");
+      if ((typeof(val)=="undefined")||(val===null)) val=label;
+      x[i]={value:val,text:label,img_src:parent.options[i].getAttribute("img_src")};
+   }
+    if(x.length)
+    w.addOption(x);
+   
+   
+	parent.parentNode.removeChild(parent);
+	w.selectOption(sel,null,true);
+	if (parent.onchange) 
+		w.attachEvent("onChange",parent.onchange);
+   		
+   	if(parent.style.direction=="rtl" && w.setRTL) 
+   		w.setRTL(true);
+   	
+   return w;
+}
+
+var dhtmlXCombo_optionTypes = [];
+/**
+*     @desc: build combobox
+*     @param: parent - (string) id of existing object which will be used as container
+*     @param: name - (string) name of combobox - will be used in FORM
+*     @param: width - (int) size of combobox
+*     @param: tabIndex - (int) tab index, optional
+*     @type: public
+*     @topic: 0
+*/
+function dhtmlXCombo(parent,name,width,optionType,tabIndex){
+      if (typeof(parent)=="string")
+         parent=document.getElementById(parent);
+
+      this.dhx_Event();
+      this.optionType = (optionType != window.undefined && dhtmlXCombo_optionTypes[optionType]) ? optionType : 'default';
+      this._optionObject = dhtmlXCombo_optionTypes[this.optionType];
+
+      this._disabled = false;
+	  
+	  if (!window.dhx_glbSelectAr){
+          window.dhx_glbSelectAr=new Array();
+          window.dhx_openedSelect=null;
+          window.dhx_SelectId=1;
+          dhtmlxEvent(document.body,"click",this.closeAll);
+          dhtmlxEvent(document.body,"keydown",function(e){ try { if ((e||event).keyCode==9)  window.dhx_glbSelectAr[0].closeAll(); } catch(e) {} return true; } );
+      }
+		
+     if (parent.tagName=="SELECT")
+         return dhtmlXComboFromSelect(parent);
+      else
+         this._createSelf(parent,name,width,tabIndex);
+      dhx_glbSelectAr.push(this);
+}
+
+/**
+*     @desc: change control size
+*     @param: new_size - (int) new size value
+*     @type: public
+*     @topic: 0
+*/
+   dhtmlXCombo.prototype.setSize = function(new_size){
+      this.DOMlist.style.width=new_size+"px";
+      if (this.DOMlistF) this.DOMlistF.style.width=new_size+"px";
+      this.DOMelem.style.width=new_size+"px";
+      this.DOMelem_input.style.width = Math.max(0,(new_size-19))+'px';
+   }      
+/**
+*     @desc: switch between combobox and auto-filter modes
+*     @param: mode - (boolean) enable filtering mode
+*     @param: url - (string) url for filtering from XML, optional
+*     @param: cache - (boolean) XML caching, optional
+*     @param: autosubload - (boolean) enable auto load additional suggestions on selecting last loaded option
+*     @type: public
+*     @topic: 0
+*/
+   dhtmlXCombo.prototype.enableFilteringMode = function(mode,url,cache,autosubload){
+      this._filter=convertStringToBoolean(mode);
+
+      if (url){
+         this._xml=url;
+         this._autoxml=convertStringToBoolean(autosubload);
+      }
+      if (convertStringToBoolean(cache)) this._xmlCache=[];
+      //this.DOMelem_button.style.display=(this._filter?"none":"");
+   }
+   
+   dhtmlXCombo.prototype.setFilteringParam=function(name,value){
+   		if (!this._prs) this._prs=[];
+   		this._prs.push([name,value]);
+   }
+/**
+*     @desc: disable combobox
+*     @param: mode - (boolean) disable combobox
+*     @type: public
+*     @topic: 1
+*/
+   dhtmlXCombo.prototype.disable = function(mode){
+      var z=convertStringToBoolean(mode);
+      if (this._disabled==z) return;
+      this.DOMelem_input.disabled=z;
+      this._disabled=z;
+   }
+/**
+*     @desc: switch to readonly mode
+*     @param: mode - (boolean) readonly mode
+*     @param: autosearch - (boolean) true by default 
+*     @type: public
+*     @topic: 1
+*/
+   dhtmlXCombo.prototype.readonly = function(mode,autosearch){
+        this.DOMelem_input.readOnly=mode ? true : false;
+		if(autosearch===false || mode===false){
+			this.DOMelem.onkeyup=function(ev){ }
+		} else {
+			var that = this;
+			this.DOMelem.onkeyup=function(ev){ 
+				ev=ev||window.event; 
+				if (ev.keyCode!=9) ev.cancelBubble=true;
+				if((ev.keyCode >= 48 && ev.keyCode <= 57)||(ev.keyCode >= 65 && ev.keyCode <= 90)){
+					for(var i=0; i<that.optionsArr.length; i++){
+						var text = that.optionsArr[i].text;
+						if(text.toString().toUpperCase().indexOf(String.fromCharCode(ev.keyCode)) == 0){
+								that.selectOption(i);
+								break;
+						}
+					}
+					ev.cancelBubble=true;
+				}
+			}
+		}
+	}	
+   
+/**
+*     @desc: get Option by value
+*     @param: value - (string) value of option in question
+*     @type: public
+*     @return: option object
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype.getOption = function(value)
+   {
+      for(var i=0; i<this.optionsArr.length; i++)
+         if(this.optionsArr[i].value==value)
+            return this.optionsArr[i];
+      return null;
+   }
+/**
+*     @desc: get Option by label
+*     @param: label - (string) label of option in question
+*     @type: public
+*     @return: option object
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype.getOptionByLabel = function(value)
+   {
+	  //value=value.replace(/&/g,"&amp;")
+      for(var i=0; i<this.optionsArr.length; i++)
+         if(this.optionsArr[i].text==value || this.optionsArr[i]._ctext==value)
+            return this.optionsArr[i];
+      return null;
+   }
+/**
+*     @desc: get Option by index
+*     @param: ind - (int) index of option in question
+*     @type: public
+*     @return: option object
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype.getOptionByIndex = function(ind){
+      return this.optionsArr[ind];
+   }
+/**
+*     @desc: clear all options from combobox
+*     @type: public
+*     @param: value - (bool) clear current value as well
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype.clearAll = function(all)
+   {
+	  if (all) this.setComboText("");   	  
+      this.optionsArr=new Array();
+      this.redrawOptions();
+      if (all) this._confirmSelection();
+   }
+/**
+*     @desc: delete option by value
+*     @param: value - (string) value of option in question
+*     @type: public
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype.deleteOption = function(value)
+   {
+        var ind=this.getIndexByValue(value);
+      if(ind<0) return;                            
+      if (this.optionsArr[ind]==this._selOption) this._selOption=null;
+      this.optionsArr.splice(ind, 1);
+      this.redrawOptions();
+   }
+
+/**
+*     @desc: enable/disable immideatly rendering after changes in combobox
+*     @param: mode - (boolean) enable/disable
+*     @type: public
+*     @topic: 1
+*/
+   dhtmlXCombo.prototype.render=function(mode){
+      this._skiprender=(!convertStringToBoolean(mode));
+      this.redrawOptions();
+   }
+
+/**
+*     @desc: update option in combobox
+*     @param: oldvalue - (string) index of option in question
+*     @param: avalue - (variable)
+*     @type: public
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype.updateOption = function(oldvalue, avalue, atext, acss)
+   {
+      var dOpt=this.getOption(oldvalue);
+      if (typeof(avalue)!="object") avalue={text:atext,value:avalue,css:acss};
+      dOpt.setValue(avalue);
+        this.redrawOptions();
+   }
+/**
+*     @desc: add new option
+*     @param: value - (variable) - different input for different kinds of options - please refer to examples
+*     @type: public
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype.addOption = function(options)
+   {
+      if (!arguments[0].length || typeof(arguments[0])!="object")
+         args = [arguments];
+      else
+         args = options;
+
+      this.render(false);
+        for (var i=0; i<args.length; i++) {
+            var attr = args[i];
+         if (attr.length){
+               attr.value = attr[0]||"";
+               attr.text = attr[1]||"";
+               attr.css = attr[2]||"";
+         }
+            this._addOption(attr);
+        }
+      this.render(true);
+   }
+
+   dhtmlXCombo.prototype._addOption = function(attr)
+   {
+         dOpt = new this._optionObject();
+         this.optionsArr.push(dOpt);
+         dOpt.setValue.apply(dOpt,[attr]);
+         this.redrawOptions();
+   }
+
+
+/**
+*     @desc: return index of item by value
+*     @param: value - (string) value of option in question
+*     @type: public
+*     @return: option index
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype.getIndexByValue = function(val){
+      for(var i=0; i<this.optionsArr.length; i++)
+         if(this.optionsArr[i].value == val) return i;
+      return -1;
+   }
+
+/**
+*     @desc: get value of selected item
+*     @type: public
+*     @return: option value
+*     @topic: 2 
+*/
+   dhtmlXCombo.prototype.getSelectedValue = function(){
+      return (this._selOption?this._selOption.value:null);
+   }
+/**
+*     @desc: get current text in combobox
+*     @type: public
+*     @return: combobox text
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype.getComboText = function(){
+      return this.DOMelem_input.value;
+   }
+/**
+*     @desc: set text in covmbobox
+*     @param: text - (string) new text label
+*     @type: public
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype.setComboText = function(text){
+      this.DOMelem_input.value=text;
+   }
+   
+/**
+*     @desc: set text in covmbobox
+*     @param: text - (string) new text label
+*     @type: public
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype.setComboValue = function(text){
+      this.setComboText(text);
+	  for(var i=0; i<this.optionsArr.length; i++)
+         if (this.optionsArr[i].data()[0]==text)
+         return this.selectOption(i,null,true);      
+      this.DOMelem_hidden_input.value=text;
+   }
+
+/**
+*     @desc: get value which will be sent with form
+*     @type: public
+*     @return: combobox value
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype.getActualValue = function(){
+      return this.DOMelem_hidden_input.value;
+   }
+/**
+*     @desc: get text of selected option
+*     @type: public
+*     @return: text of option
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype.getSelectedText = function(){
+      return (this._selOption?this._selOption.text:"");
+   }
+/**
+*     @desc: get index of selected option
+*     @type: public
+*     @return: option index
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype.getSelectedIndex = function(){
+      for(var i=0; i<this.optionsArr.length; i++)
+         if(this.optionsArr[i] == this._selOption) return i;
+      return -1;
+   }
+/**
+*     @desc: set name used while form submit
+*     @param: name - (string) new combobox name
+*     @type: public
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype.setName = function(name){  
+        this.DOMelem_hidden_input.name = name;
+        this.DOMelem_hidden_input2 = name.replace(/(\]?)$/, "_new_value$1");
+
+        this.name = name;
+   }
+/**
+*     @desc: show combox ( reversion to hide command )
+*     @param: mode - (boolean) enable/disable
+*     @type: public
+*     @topic: 1
+*/
+   dhtmlXCombo.prototype.show = function(mode){
+      if (convertStringToBoolean(mode))
+         this.DOMelem.style.display = "";
+      else
+         this.DOMelem.style.display = "none";
+   }
+
+/**
+*     @desc: destroy object and any related HTML elements
+*     @type: public
+*     @topic: 0
+*/
+   dhtmlXCombo.prototype.destructor = function()
+   {
+      this.DOMParent.removeChild(this.DOMelem);
+      this.DOMlist.parentNode.removeChild(this.DOMlist);
+      var s=dhx_glbSelectAr;
+      this.DOMParent=this.DOMlist=this.DOMelem=0;
+      this.DOMlist.combo=this.DOMelem.combo=0;
+      for(var i=0; i<s.length; i++)
+      {
+         if(s[i] == this)
+         {
+            s[i] = null;
+            s.splice(i,1);
+            return;
+         }
+      }
+   }
+
+/**
+*     @desc: create self HTML
+*     @type: private
+*     @topic: 0
+*/
+      dhtmlXCombo.prototype._createSelf = function(selParent, name, width, tab)
+      {
+         if (width.toString().indexOf("%")!=-1){ 
+            var self = this;
+            var resWidht=parseInt(width)/100;
+            window.setInterval(function(){ 
+               if (!selParent.parentNode) return;
+               var ts=selParent.parentNode.offsetWidth*resWidht-2;
+               if (ts<0) return;
+               if (ts==self._lastTs) return;
+               self.setSize(self._lastTs=ts);},500);
+            var width=parseInt(selParent.offsetWidth); //mm
+         }
+
+         var width=parseInt(width||100); //mm
+         this.ListPosition = "Bottom"; //set optionlist positioning
+         this.DOMParent = selParent;
+         this._inID = null;
+         this.name = name;
+
+         this._selOption = null; //selected option object pointer
+         this.optionsArr = Array();
+
+            var opt = new this._optionObject();
+            opt.DrawHeader(this,name, width,tab);
+         //HTML select part 2 - options list DIV element
+         this.DOMlist = document.createElement("DIV");
+         this.DOMlist.className = 'dhx_combo_list '+(dhtmlx.skin?dhtmlx.skin+"_list":"");
+         this.DOMlist.style.width=width-(_isIE?0:0)+"px";
+		 if (_isOpera || _isKHTML ) 
+		 		this.DOMlist.style.overflow="auto";      
+         this.DOMlist.style.display = "none";
+         document.body.insertBefore(this.DOMlist,document.body.firstChild);         
+         if (_isIE)    {
+            this.DOMlistF = document.createElement("IFRAME");
+            this.DOMlistF.style.border="0px";
+            this.DOMlistF.className = 'dhx_combo_list';
+            this.DOMlistF.style.width=width-(_isIE?0:0)+"px";
+            this.DOMlistF.style.display = "none";
+            this.DOMlistF.src="javascript:false;"; 
+            document.body.insertBefore(this.DOMlistF,document.body.firstChild);
+            }
+
+
+
+         this.DOMlist.combo=this.DOMelem.combo=this;
+
+         this.DOMelem_input.onkeydown = this._onKey;
+          this.DOMelem_input.onkeypress = this._onKeyF;
+         this.DOMelem_input.onblur = this._onBlur;
+         this.DOMelem.onclick = this._toggleSelect;
+         this.DOMlist.onclick = this._selectOption;
+         this.DOMlist.onmousedown = function(){
+         	this._skipBlur=true;
+     	 }
+         
+         this.DOMlist.onkeydown = function(e){
+         	this.combo.DOMelem_input.focus();
+         	(e||event).cancelBubble=true;
+         	this.combo.DOMelem_input.onkeydown(e)
+     	 }
+		  this.DOMlist.onmouseover = this._listOver;
+     	 
+      }
+
+      dhtmlXCombo.prototype._listOver = function(e)
+      { 
+         e = e||event;
+         e.cancelBubble = true;
+         var node = (_isIE?event.srcElement:e.target);
+         var that = this.combo;
+         if ( node.parentNode == that.DOMlist ) {
+            if(that._selOption) that._selOption.deselect(); 
+			if(that._tempSel) that._tempSel.deselect();
+           
+		    var i=0;
+            for (i; i<that.DOMlist.childNodes.length; i++) {
+               if (that.DOMlist.childNodes[i]==node) break;
+            }
+            var z=that.optionsArr[i];
+           that._tempSel=z;
+           that._tempSel.select();
+        	  
+			if ((that._autoxml)&&((i+1)==that._lastLength)){
+				that._fetchOptions(i+1,that._lasttext||""); 
+            }           
+         }
+
+      }
+
+/**
+*     @desc: place option list in necessary place on screen
+*     @type: private
+*     @topic: 0
+*/
+      dhtmlXCombo.prototype._positList = function()
+      {
+	  	//if(this.ListAutoPosit) this.enableOptionAutoPositioning(true); //mm auto posit
+         var pos=this.getPosition(this.DOMelem);
+         if(this.ListPosition == 'Bottom'){
+            this.DOMlist.style.top = pos[1]+this.DOMelem.offsetHeight-1+"px";
+            this.DOMlist.style.left = pos[0]+"px";
+         }
+         else if(this.ListPosition == 'Top'){ //mm
+				this.DOMlist.style.top = pos[1] - this.DOMlist.offsetHeight+"px";
+            	
+				this.DOMlist.style.left = pos[0]+"px"; //mm
+          }
+		  else{
+			this.DOMlist.style.top = pos[1]+"px";
+            this.DOMlist.style.left = pos[0]+this.DOMelem.offsetWidth+"px";
+         }
+     
+      }
+	  
+	dhtmlXCombo.prototype.getPosition = function(oNode,pNode){
+		if (_isChrome){ 
+			if(!pNode)
+			var pNode = document.body
+			
+			var oCurrentNode=oNode;
+			var iLeft=0;
+			var iTop=0;
+			while ((oCurrentNode)&&(oCurrentNode!=pNode)){
+			iLeft+=oCurrentNode.offsetLeft-oCurrentNode.scrollLeft;
+			iTop+=oCurrentNode.offsetTop-oCurrentNode.scrollTop;
+			oCurrentNode=oCurrentNode.offsetParent;
+			}
+			if (pNode == document.body ){
+			if (_isIE && _isIE<8){
+			
+			if (document.documentElement.scrollTop)
+			iTop+=document.documentElement.scrollTop;
+			if (document.documentElement.scrollLeft)
+			iLeft+=document.documentElement.scrollLeft;
+			}
+			else
+			if (!_isFF){
+			iLeft+=document.body.offsetLeft;
+			iTop+=document.body.offsetTop;
+			}
+			}
+			return new Array(iLeft,iTop);
+		}
+		var pos = getOffset(oNode);
+        return [pos.left, pos.top];
+        
+	}
+/**
+*     @desc: correct current selection ( move it to first visible option )
+*     @type: private
+*     @topic: 2
+*/
+      dhtmlXCombo.prototype._correctSelection = function(){
+		 if (this.getComboText()!="")
+         for (var i=0; i<this.optionsArr.length; i++)
+            if (!this.optionsArr[i].isHidden()){
+               return this.selectOption(i,true,false);
+           }
+         this.unSelectOption();
+      }
+/**
+*     @desc: select next option in combobox
+*     @param: step - (int) step size
+*     @type: private
+*     @topic: 2
+*/
+      dhtmlXCombo.prototype.selectNext = function(step){
+         var z=this.getSelectedIndex()+step;
+         while (this.optionsArr[z]){
+            if (!this.optionsArr[z].isHidden())
+               return this.selectOption(z,false,false);
+            z+=step;
+         }
+      }
+/**
+*     @desc: on keypressed handler
+*     @type: private
+*     @topic: 0
+*/
+      dhtmlXCombo.prototype._onKeyF = function(e){
+         var that=this.parentNode.combo;
+         var ev=e||event;
+         ev.cancelBubble=true;
+         if (ev.keyCode=="13" || ev.keyCode=="9" ){
+         	that._confirmSelection();
+         	that.closeAll();
+     	} else
+        if (ev.keyCode=="27" ){
+         	that._resetSelection();
+         	that.closeAll();
+     	} else that._activeMode=true;
+         if (ev.keyCode=="13" || ev.keyCode=="27" ){ //enter
+            that.callEvent("onKeyPressed",[ev.keyCode])
+            return false;
+         }
+         return true;
+      }
+/**
+*     @desc: on keyup handler
+*     @type: private
+*     @topic: 0
+*/
+      dhtmlXCombo.prototype._onKey = function(e){
+         var that=this.parentNode.combo;
+         (e||event).cancelBubble=true;
+         var ev=(e||event).keyCode;
+         if (ev>15 && ev<19) return true; //shift,alt,ctrl
+        if (ev==27) return;
+        if ((that.DOMlist.style.display!="block")&&(ev!="13")&&(ev!="9")&&((!that._filter)||(that._filterAny)))
+            that.DOMelem.onclick(e||event);
+       
+		if ((ev!="13")&&(ev!="9")){
+         	window.setTimeout(function(){ that._onKeyB(ev); },1);
+         	if (ev=="40" || ev=="38")
+         		return false;
+     	}
+         else if (ev==9){
+         	that.closeAll();
+         	(e||event).cancelBubble=false;
+         }
+      }
+      dhtmlXCombo.prototype._onKeyB = function(ev)
+      {
+         if (ev=="40"){  //down
+            var z=this.selectNext(1);
+         } else if (ev=="38"){ //up
+            this.selectNext(-1);
+         } else{
+            this.callEvent("onKeyPressed",[ev])
+            if (this._filter) return this.filterSelf((ev==8)||(ev==46));
+            for(var i=0; i<this.optionsArr.length; i++)
+               if (this.optionsArr[i].data()[1]==this.DOMelem_input.value){
+//                  ev.cancelBubble=true;
+                  this.selectOption(i,false,false);
+                  return false;
+                  }
+            this.unSelectOption();
+         }
+         return true;
+      }
+
+
+/**
+*     @desc: on data change handler
+*     @type: private
+*     @topic: 0
+*/
+      dhtmlXCombo.prototype._onBlur = function()
+      {
+          var self = this.parentNode._self;
+          window.setTimeout(function(){
+          	if (self.DOMlist._skipBlur) return !(self.DOMlist._skipBlur=false);
+          	self._confirmSelection();        
+          	self.callEvent("onBlur",[]);
+          },100)
+          
+      }
+/**
+*     @desc: redraw combobox options
+*     @type: private
+*     @topic: 2
+*/
+      dhtmlXCombo.prototype.redrawOptions = function(){
+         if (this._skiprender) return;
+         for(var i=this.DOMlist.childNodes.length-1; i>=0; i--)
+            this.DOMlist.removeChild(this.DOMlist.childNodes[i]);
+         for(var i=0; i<this.optionsArr.length; i++)
+            this.DOMlist.appendChild(this.optionsArr[i].render());
+			
+		
+		
+						
+
+      }
+/**
+*     @desc: load list of options from XML
+*     @param: url - (string) xml url
+*     @type: public
+*     @topic: 0
+*/
+      dhtmlXCombo.prototype.loadXML = function(url,afterCall){
+         this._load=true;
+         this.callEvent("onXLS",[]);
+		 if (this._prs)
+           	for (var i=0; i<this._prs.length; i++)
+           		url+=[getUrlSymbol(url),escape(this._prs[i][0]),"=",escape(this._prs[i][1])].join("");         
+         if ((this._xmlCache)&&(this._xmlCache[url])){
+            this._fillFromXML(this,null,null,null,this._xmlCache[url]);
+            if (afterCall) afterCall();
+        }
+         else{
+            var xml=(new dtmlXMLLoaderObject(this._fillFromXML,this,true,true));
+            if (afterCall) xml.waitCall=afterCall;
+            xml._cPath=url;
+            xml.loadXML(url);
+         }
+      }
+
+/**
+*     @desc: load list of options from XML string
+*     @param: astring - (string) xml string
+*     @type: public
+*     @topic: 0
+*/
+      dhtmlXCombo.prototype.loadXMLString = function(astring){
+         var xml=(new dtmlXMLLoaderObject(this._fillFromXML,this,true,true));
+         xml.loadXMLString(astring);
+      }
+
+/**
+*     @desc: on XML load handler
+*     @type: private
+*     @topic: 0
+*/
+      dhtmlXCombo.prototype._fillFromXML = function(obj,b,c,d,xml){
+         if (obj._xmlCache) obj._xmlCache[xml._cPath]=xml;
+
+         //check that XML is correct 
+         var toptag=xml.getXMLTopNode("complete");
+         if (toptag.tagName!="complete") return;
+         var top=xml.doXPath("//complete");
+         var options=xml.doXPath("//option");
+         
+         var add = false;
+         
+         obj.render(false);
+         if ((!top[0])||(!top[0].getAttribute("add"))){
+            obj.clearAll();
+            obj._lastLength=options.length;
+	         if (obj._xml){
+	         if ((!options) || (!options.length)) 
+	         	obj.closeAll();
+	         else {
+	         		if (obj._activeMode){
+	         			obj._positList();
+	        			obj.DOMlist.style.display="block";
+	         			if (_isIE) obj._IEFix(true);
+         			}
+	     	 }}            
+         } else {
+            obj._lastLength+=options.length||Infinity;
+	        add = true;
+        }
+
+         for (var i=0; i<options.length; i++) {
+            var attr = new Object();
+            attr.text = options[i].firstChild?options[i].firstChild.nodeValue:"";
+            for (var j=0; j<options[i].attributes.length; j++) {
+               var a = options[i].attributes[j];
+               if (a)
+                  attr[a.nodeName] = a.nodeValue;
+            }
+            obj._addOption(attr);
+         }
+         obj.render(add!=true || (!!options.length));
+         	
+         if ((obj._load)&&(obj._load!==true))
+            obj.loadXML(obj._load);
+         else{
+            obj._load=false;
+             if ((!obj._lkmode)&&(obj._filter))
+               obj._correctSelection();
+            }
+
+         var selected=xml.doXPath("//option[@selected]");
+         if (selected.length)
+         	obj.selectOption(obj.getIndexByValue(selected[0].getAttribute("value")),false,true);
+
+         obj.callEvent("onXLE",[]);
+
+      }
+/**
+*     @desc: deselect option
+*     @type: public
+*     @topic: 1
+*/
+      dhtmlXCombo.prototype.unSelectOption = function(){
+         if (this._selOption) this._selOption.deselect();
+         if(this._tempSel) this._tempSel.deselect();
+         this._tempSel=this._selOption=null;
+      }
+	  
+/**
+*     @desc: confirms combo value (recommended to be called on form submit)
+*     @type: public
+*     @topic: 1
+*/
+	 dhtmlXCombo.prototype.confirmValue = function(){
+         this._confirmSelection();
+	 }
+	  
+	  
+      dhtmlXCombo.prototype._confirmSelection = function(data,status){
+      	if(arguments.length==0){
+      	    var z=this.getOptionByLabel(this.DOMelem_input.value);
+          	data = z?z.value:this.DOMelem_input.value;
+          	status = (z==null);
+          	if (data==this.getActualValue()) return;
+      	}
+          	
+      	this.DOMelem_hidden_input.value=data;
+        this.DOMelem_hidden_input2.value = (status?"true":"false");
+      	this.callEvent("onChange",[]);
+      	this._activeMode=false;
+  	  }
+      dhtmlXCombo.prototype._resetSelection = function(data,status){
+      		var z=this.getOption(this.DOMelem_hidden_input.value);
+      		this.setComboValue(z?z.data()[0]:this.DOMelem_hidden_input.value)
+      		this.setComboText(z?z.data()[1]:this.DOMelem_hidden_input.value)
+  	  }  	  
+  	  
+/**
+*     @desc: select option
+*     @param: ind - (int) index of option in question
+*     @param: filter - (boolean) enable autocomplit range, optional
+*     @param: conf - (boolean) true for real selection, false for pre-selection
+*     @type: public
+*     @topic: 1
+*/
+      dhtmlXCombo.prototype.selectOption = function(ind,filter,conf){
+      	 if (arguments.length<3) conf=true;
+         this.unSelectOption();
+         var z=this.optionsArr[ind];
+         if (!z)  return;
+         this._selOption=z;
+         this._selOption.select();
+
+         var corr=this._selOption.content.offsetTop+this._selOption.content.offsetHeight-this.DOMlist.scrollTop-this.DOMlist.offsetHeight;
+         if (corr>0) this.DOMlist.scrollTop+=corr;
+            corr=this.DOMlist.scrollTop-this._selOption.content.offsetTop;
+         if (corr>0) this.DOMlist.scrollTop-=corr;
+         var data=this._selOption.data();
+
+	 	 if (conf){
+	 	 	this.setComboText(data[1]);
+	 	 	this._confirmSelection(data[0],false);
+		 
+         	if ((this._autoxml)&&((ind+1)==this._lastLength))
+            	this._fetchOptions(ind+1,this._lasttext||"");
+		}
+
+         if (filter){
+            var text=this.getComboText();
+            if (text!=data[1]){
+               this.setComboText(data[1]);
+               dhtmlXRange(this.DOMelem_input,text.length+1,data[1].length);
+            }
+         }
+         else
+            this.setComboText(data[1]);
+         this._selOption.RedrawHeader(this);
+
+         /*Event*/
+         this.callEvent("onSelectionChange",[]);
+      }
+/**
+*     @desc: option on select handler
+*     @type: private
+*     @topic: 2
+*/
+      dhtmlXCombo.prototype._selectOption = function(e)
+      {
+         (e||event).cancelBubble = true;
+         var node=(_isIE?event.srcElement:e.target);
+         var that=this.combo;
+         while (!node._self) {
+            node = node.parentNode;
+            if (!node)
+               return;
+         }
+
+         var i=0;
+         for (i; i<that.DOMlist.childNodes.length; i++) {
+            if (that.DOMlist.childNodes[i]==node) break;
+         }
+         that.selectOption(i,false,true);
+         that.closeAll();
+         that.callEvent("onBlur",[])
+         that._activeMode=false;
+      }
+/**
+*     @desc: open list of options 
+*     @type: public
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype.openSelect = function(){ 
+   	
+	
+    
+	  if (this._disabled) return;
+      this.closeAll();
+      this._positList();
+      this.DOMlist.style.display="block";
+      this.callEvent("onOpen",[]);
+	  if(this._tempSel) this._tempSel.deselect();
+	  if(this._selOption) this._selOption.select();
+	  if(this._selOption){
+	 	var corr=this._selOption.content.offsetTop+this._selOption.content.offsetHeight-this.DOMlist.scrollTop-this.DOMlist.offsetHeight;
+         if (corr>0) this.DOMlist.scrollTop+=corr;
+            corr=this.DOMlist.scrollTop-this._selOption.content.offsetTop;
+         if (corr>0) this.DOMlist.scrollTop-=corr;
+	  }
+	  /* if (this.autoOptionSize){
+        	var x=this.DOMlist.offsetWidth; 
+			
+        	for ( var i=0; i<this.optionsArr.length; i++){
+				if(i==0) alert("this.DOMlist.childNodes[i].scrollWidth ="+ this.DOMlist.childNodes[i].scrollWidth + "> x= "+ x);
+        		if (this.DOMlist.childNodes[i].scrollWidth > x)
+        			x=this.DOMlist.childNodes[i].scrollWidth;
+			}
+        			
+			this.DOMlist.style.width=x+"px";
+		}*/
+		
+		      
+      if (_isIE) this._IEFix(true);
+      this.DOMelem_input.focus();
+	
+      if (this._filter) this.filterSelf();
+   }
+/**
+*     @desc: open(close) list
+*     @type: private
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype._toggleSelect = function(e)
+   {
+      var that=this.combo;
+      if ( that.DOMlist.style.display == "block" ) {
+      that.closeAll();
+      } else {
+         that.openSelect();
+      }
+      (e||event).cancelBubble = true;
+   }
+
+    dhtmlXCombo.prototype._fetchOptions=function(ind,text){
+         if (text=="") { this.closeAll();  return this.clearAll();   }
+         var url=this._xml+((this._xml.indexOf("?")!=-1)?"&":"?")+"pos="+ind+"&mask="+encodeURIComponent(text);
+         this._lasttext=text;
+         if (this._load) this._load=url;
+         else {
+			if (!this.callEvent("onDynXLS",[text,ind])) return;
+			this.loadXML(url);
+     	 }
+    }
+/**
+*     @desc: filter list of options
+*     @type: private
+*     @topic: 2
+*/
+    dhtmlXCombo.prototype.filterSelf = function(mode)
+   {
+      var text=this.getComboText();
+      if (this._xml){
+         this._lkmode=mode;
+         this._fetchOptions(0,text);
+      }
+      try{ var filter=new RegExp("^"+text,"i"); } catch (e){ var filter=new RegExp("^"+text.replace(/([\[\]\{\}\(\)\+\*\\])/g,"\\$1")); }
+      this.filterAny=false;
+      for(var i=0; i<this.optionsArr.length; i++){
+      	 var z=filter.test(this.optionsArr[i].text);
+      	 this.filterAny|=z;
+         this.optionsArr[i].hide(!z);
+      }
+      if (!this.filterAny) {
+		  this.closeAll();
+		  this._activeMode=true;
+	  }
+      else {
+      	  if (this.DOMlist.style.display!="block")
+      	   		this.openSelect();
+	      if (_isIE) this._IEFix(true);
+  		}
+         
+        if (!mode)
+         this._correctSelection();   
+        else this.unSelectOption();
+   }
+ 
+ 
+
+
+/**
+*     @desc: set hidden iframe for IE
+*     @type: private
+*     @topic: 2
+*/
+   dhtmlXCombo.prototype._IEFix = function(mode){
+      this.DOMlistF.style.display=(mode?"block":"none");
+        this.DOMlistF.style.top=this.DOMlist.style.top;
+        this.DOMlistF.style.left=this.DOMlist.style.left;
+   }
+/**
+*     @desc: close opened combobox list
+*     @type: public
+*     @topic: 1
+*/
+   dhtmlXCombo.prototype.closeAll = function()
+   {
+      if(window.dhx_glbSelectAr)
+         for (var i=0; i<dhx_glbSelectAr.length; i++){
+            if (dhx_glbSelectAr[i].DOMlist.style.display=="block") {
+               dhx_glbSelectAr[i].DOMlist.style.display = "none";
+               if (_isIE) dhx_glbSelectAr[i]._IEFix(false);
+            }
+            dhx_glbSelectAr[i]._activeMode=false;
+        }
+   }
+ 
+		
+/**
+*     @desc: create selection range in input control
+*     @param: InputId - (string) id of input ( object can be used as well )
+*     @param: Start - (int) start selection position
+*     @param: End - (int) end selection position
+*     @type: public
+*     @topic: 0
+*/
+function dhtmlXRange(InputId, Start, End)
+{
+   var Input = typeof(InputId)=='object' ? InputId : document.getElementById(InputId);
+   try{    Input.focus();   } catch(e){};
+   var Length = Input.value.length;
+   Start--;
+   if (Start < 0 || Start > End || Start > Length)
+      Start = 0;
+   if (End > Length)
+      End = Length;
+   if (Start==End) return;
+   if (Input.setSelectionRange) {
+      Input.setSelectionRange(Start, End);
+   } else if (Input.createTextRange) {
+      var range = Input.createTextRange();
+      range.moveStart('character', Start);
+      range.moveEnd('character', End-Length);
+	  try{
+         range.select();
+	  }
+	  catch(e){
+	  }
+   }
+}
+/**
+*     @desc: combobox option object constructor
+*     @type: public
+*     @topic: 0
+*/
+      dhtmlXCombo_defaultOption = function(){
+         this.init();
+      }
+/**
+*     @desc: option initialization function
+*     @type: private
+*     @topic: 4
+*/
+      dhtmlXCombo_defaultOption.prototype.init = function(){
+         this.value = null;
+         this.text = "";
+         this.selected = false;
+         this.css = "";
+      }
+/**
+*     @desc: mark option as selected
+*     @type: public
+*     @topic: 4
+*/
+      dhtmlXCombo_defaultOption.prototype.select = function(){
+         if (this.content){
+            this.content.className="dhx_selected_option"+(dhtmlx.skin?" combo_"+dhtmlx.skin+"_sel":"");
+		}
+      }
+/**
+*     @desc: hide option
+*     @param: mode - (boolean)
+*     @type: public
+*     @topic: 4
+*/
+      dhtmlXCombo_defaultOption.prototype.hide = function(mode){
+         this.render().style.display=mode?"none":"";
+      }
+/**
+*     @desc: return hide state of option
+*     @type: public
+*     @return: hide state of option
+*     @topic: 4
+*/
+      dhtmlXCombo_defaultOption.prototype.isHidden = function(){
+         return (this.render().style.display=="none");
+      }
+/**
+*     @desc: mark option as not selected
+*     @type: public
+*     @topic: 4
+*/
+      dhtmlXCombo_defaultOption.prototype.deselect = function(){
+         if (this.content) this.render();
+            this.content.className="";
+      }
+/**
+*     @desc: set value of option
+*     @param: value - (string) value
+*     @param: text - (string) text
+*     @param: css - (string) css style string
+*     @type: public
+*     @topic: 4
+*/
+dhtmlXCombo_defaultOption.prototype.setValue = function(attr){
+    this.value = attr.value||"";
+    this.text = attr.text||"";
+    this.css = attr.css||"";
+   this.content=null;
+}
+
+				
+/**
+*     @desc: render option
+*     @type: private
+*     @topic: 4
+*/
+      dhtmlXCombo_defaultOption.prototype.render = function(){
+         if (!this.content){
+            this.content=document.createElement("DIV");
+        this.content._self = this;
+
+            this.content.style.cssText='width:100%; overflow:hidden;'+this.css;
+            if (_isOpera || _isKHTML ) this.content.style.padding="2px 0px 2px 0px";
+            this.content.innerHTML=this.text;
+            this._ctext=_isIE?this.content.innerText:this.content.textContent;
+         }
+         return this.content;
+      }
+/**
+*     @desc: return option data
+*     @type: public
+*     @return: array of data related to option
+*     @topic: 4
+*/
+      dhtmlXCombo_defaultOption.prototype.data = function(){
+         if (this.content)
+            return [this.value,this._ctext ? this._ctext : this.text];
+      }
+
+dhtmlXCombo_defaultOption.prototype.DrawHeader = function(self, name, width, tab)
+{
+    var z=document.createElement("DIV");
+    z.style.width = width+"px";
+    z.className = 'dhx_combo_box '+(dhtmlx.skin||"");
+    z._self = self;
+	self.DOMelem = z;
+   	this._DrawHeaderInput(self, name, width,tab);
+	this._DrawHeaderButton(self, name, width);
+    self.DOMParent.appendChild(self.DOMelem);
+}
+
+dhtmlXCombo_defaultOption.prototype._DrawHeaderInput = function(self, name, width,tab)
+{
+
+	var z=document.createElement('input');
+	z.setAttribute("autocomplete","off"); 
+	z.type = 'text';
+	z.className = 'dhx_combo_input';
+
+   if (tab) z.tabIndex=tab;
+   z.style.width = width-19-(document.compatMode=="BackCompat"?0:3)+'px';
+   self.DOMelem.appendChild(z);
+   self.DOMelem_input = z;
+
+   z = document.createElement('input');
+   z.type = 'hidden';
+   z.name = name;
+   self.DOMelem.appendChild(z);
+   self.DOMelem_hidden_input = z;
+
+   z = document.createElement('input');
+   z.type = 'hidden';
+   z.name = (name||"").replace(/(\]?)$/, "_new_value$1");
+   z.value="true";
+   self.DOMelem.appendChild(z);
+   self.DOMelem_hidden_input2 = z;
+}
+
+dhtmlXCombo_defaultOption.prototype._DrawHeaderButton = function(self, name, width)
+{
+   var z=document.createElement('img');
+   z.className = 'dhx_combo_img';
+  if(dhtmlx.image_path) dhx_globalImgPath = dhtmlx.image_path;
+   z.src = (window.dhx_globalImgPath?dhx_globalImgPath:"")+'combo_select'+(dhtmlx.skin?"_"+dhtmlx.skin:"")+'.gif';
+   self.DOMelem.appendChild(z);
+   self.DOMelem_button=z;
+}
+
+dhtmlXCombo_defaultOption.prototype.RedrawHeader = function(self)
+{
+}
+
+
+dhtmlXCombo_optionTypes['default'] = dhtmlXCombo_defaultOption;
+
+dhtmlXCombo.prototype.dhx_Event=function()
+{
+   this.dhx_SeverCatcherPath="";
+
+   this.attachEvent = function(original, catcher, CallObj)
+   {
+      CallObj = CallObj||this;
+      original = 'ev_'+original;
+       if ( ( !this[original] ) || ( !this[original].addEvent ) ) {
+           var z = new this.eventCatcher(CallObj);
+           z.addEvent( this[original] );
+           this[original] = z;
+       }
+       return ( original + ':' + this[original].addEvent(catcher) );   //return ID (event name & event ID)
+   }
+   this.callEvent=function(name,arg0){
+         if (this["ev_"+name]) return this["ev_"+name].apply(this,arg0);
+       return true;
+   }
+   this.checkEvent=function(name){
+         if (this["ev_"+name]) return true;
+       return false;
+   }
+
+   this.eventCatcher = function(obj)
+   {
+       var dhx_catch = new Array();
+       var m_obj = obj;
+       var func_server = function(catcher,rpc)
+                         {
+                           catcher = catcher.split(":");
+                     var postVar="";
+                     var postVar2="";
+                           var target=catcher[1];
+                     if (catcher[1]=="rpc"){
+                           postVar='<?xml version="1.0"?><methodCall><methodName>'+catcher[2]+'</methodName><params>';
+                        postVar2="</params></methodCall>";
+                        target=rpc;
+                     }
+                           var z = function() {
+                                   }
+                           return z;
+                         }
+       var z = function()
+             {
+                   if (dhx_catch)
+                      var res=true;
+                   for (var i=0; i<dhx_catch.length; i++) {
+                      if (dhx_catch[i] != null) {
+                           var zr = dhx_catch[i].apply( m_obj, arguments );
+                           res = res && zr;
+                      }
+                   }
+                   return res;
+                }
+       z.addEvent = function(ev)
+                {
+                       if ( typeof(ev) != "function" )
+                           if (ev && ev.indexOf && ev.indexOf("server:") == 0)
+                               ev = new func_server(ev,m_obj.rpcServer);
+                           else
+                               ev = eval(ev);
+                       if (ev)
+                           return dhx_catch.push( ev ) - 1;
+                       return false;
+                }
+       z.removeEvent = function(id)
+                   {
+                     dhx_catch[id] = null;
+                   }
+       return z;
+   }
+
+   this.detachEvent = function(id)
+   {
+      if (id != false) {
+         var list = id.split(':');            //get EventName and ID
+         this[ list[0] ].removeEvent( list[1] );   //remove event
+      }
+   }
+};
+
+
+//combo
+(function(){
+	dhtmlx.extend_api("dhtmlXCombo",{
+		_init:function(obj){
+			if (obj.image_path) 
+				dhx_globalImgPath=obj.image_path;
+			return [obj.parent, obj.name, (obj.width||"100%"), obj.type, obj.index ];
+		},
+		filter:"filter_command",
+		auto_height:"enableOptionAutoHeight",
+		auto_position:"enableOptionAutoPositioning",
+		auto_width:"enableOptionAutoWidth",
+		xml:"loadXML",
+		readonly:"readonly",
+		items:"addOption"
+	},{
+		filter_command:function(data){
+			if (typeof data == "string")
+				this.enableFilteringMode(true,data);
+			else
+				this.enableFilteringMode(data);
+		}
+	});
+})();
+
+
+//(c)dhtmlx ltd. www.dhtmlx.com
+ .hledger/web/dhtmlxcommon.js view
@@ -0,0 +1,940 @@+//v.2.6 build 100722++/*
+Copyright DHTMLX LTD. http://www.dhtmlx.com
+You allowed to use this component or parts of it under GPL terms
+To use it on other terms or get Professional edition of the component please contact us at sales@dhtmlx.com
+*/+dhtmlx=function(obj){
+	for (var a in obj) dhtmlx[a]=obj[a];
+	return dhtmlx; //simple singleton
+};
+dhtmlx.extend_api=function(name,map,ext){
+	var t = window[name];
+	if (!t) return; //component not defined
+	window[name]=function(obj){
+		if (obj && typeof obj == "object" && !obj.tagName){
+			var that = t.apply(this,(map._init?map._init(obj):arguments));
+			//global settings
+			for (var a in dhtmlx)
+				if (map[a]) this[map[a]](dhtmlx[a]);			
+			//local settings
+			for (var a in obj){
+				if (map[a]) this[map[a]](obj[a]);
+				else if (a.indexOf("on")==0){
+					this.attachEvent(a,obj[a]);
+				}
+			}
+		} else
+			var that = t.apply(this,arguments);
+		if (map._patch) map._patch(this);
+		return that||this;
+	};
+	window[name].prototype=t.prototype;
+	if (ext)
+		dhtmlXHeir(window[name].prototype,ext);
+};
+
+dhtmlxAjax={
+	get:function(url,callback){
+		var t=new dtmlXMLLoaderObject(true);
+		t.async=(arguments.length<3);
+		t.waitCall=callback;
+		t.loadXML(url)
+		return t;
+	},
+	post:function(url,post,callback){
+		var t=new dtmlXMLLoaderObject(true);
+		t.async=(arguments.length<4);
+		t.waitCall=callback;
+		t.loadXML(url,true,post)
+		return t;
+	},
+	getSync:function(url){
+		return this.get(url,null,true)
+	},
+	postSync:function(url,post){
+		return this.post(url,post,null,true);		
+	}
+}
+
+/**
+  *     @desc: xmlLoader object
+  *     @type: private
+  *     @param: funcObject - xml parser function
+  *     @param: object - jsControl object
+  *     @param: async - sync/async mode (async by default)
+  *     @param: rSeed - enable/disable random seed ( prevent IE caching)
+  *     @topic: 0
+  */
+function dtmlXMLLoaderObject(funcObject, dhtmlObject, async, rSeed){
+	this.xmlDoc="";
+
+	if (typeof (async) != "undefined")
+		this.async=async;
+	else
+		this.async=true;
+
+	this.onloadAction=funcObject||null;
+	this.mainObject=dhtmlObject||null;
+	this.waitCall=null;
+	this.rSeed=rSeed||false;
+	return this;
+};
+/**
+  *     @desc: xml loading handler
+  *     @type: private
+  *     @param: dtmlObject - xmlLoader object
+  *     @topic: 0
+  */
+dtmlXMLLoaderObject.prototype.waitLoadFunction=function(dhtmlObject){
+	var once = true;
+	this.check=function (){
+		if ((dhtmlObject)&&(dhtmlObject.onloadAction != null)){
+			if ((!dhtmlObject.xmlDoc.readyState)||(dhtmlObject.xmlDoc.readyState == 4)){
+				if (!once)
+					return;
+
+				once=false; //IE 5 fix
+				if (typeof dhtmlObject.onloadAction == "function")
+					dhtmlObject.onloadAction(dhtmlObject.mainObject, null, null, null, dhtmlObject);
+
+				if (dhtmlObject.waitCall){
+					dhtmlObject.waitCall.call(this,dhtmlObject);
+					dhtmlObject.waitCall=null;
+				}
+			}
+		}
+	};
+	return this.check;
+};
+
+/**
+  *     @desc: return XML top node
+  *     @param: tagName - top XML node tag name (not used in IE, required for Safari and Mozilla)
+  *     @type: private
+  *     @returns: top XML node
+  *     @topic: 0  
+  */
+dtmlXMLLoaderObject.prototype.getXMLTopNode=function(tagName, oldObj){
+	if (this.xmlDoc.responseXML){
+		var temp = this.xmlDoc.responseXML.getElementsByTagName(tagName);
+		if(temp.length==0 && tagName.indexOf(":")!=-1)
+			var temp = this.xmlDoc.responseXML.getElementsByTagName((tagName.split(":"))[1]);
+		var z = temp[0];
+	} else
+		var z = this.xmlDoc.documentElement;
+
+	if (z){
+		this._retry=false;
+		return z;
+	}
+
+	if ((_isIE)&&(!this._retry)){
+		//fall back to MS.XMLDOM
+		var xmlString = this.xmlDoc.responseText;
+		var oldObj = this.xmlDoc;
+		this._retry=true;
+		this.xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
+		this.xmlDoc.async=false;
+		this.xmlDoc["loadXM"+"L"](xmlString);
+
+		return this.getXMLTopNode(tagName, oldObj);
+	}
+	dhtmlxError.throwError("LoadXML", "Incorrect XML", [
+		(oldObj||this.xmlDoc),
+		this.mainObject
+	]);
+
+	return document.createElement("DIV");
+};
+
+/**
+  *     @desc: load XML from string
+  *     @type: private
+  *     @param: xmlString - xml string
+  *     @topic: 0  
+  */
+dtmlXMLLoaderObject.prototype.loadXMLString=function(xmlString){
+	{
+		try{
+			var parser = new DOMParser();
+			this.xmlDoc=parser.parseFromString(xmlString, "text/xml");
+		}
+		catch (e){
+			this.xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
+			this.xmlDoc.async=this.async;
+			this.xmlDoc["loadXM"+"L"](xmlString);
+		}
+	}
+
+	this.onloadAction(this.mainObject, null, null, null, this);
+
+	if (this.waitCall){
+		this.waitCall();
+		this.waitCall=null;
+	}
+}
+/**
+  *     @desc: load XML
+  *     @type: private
+  *     @param: filePath - xml file path
+  *     @param: postMode - send POST request
+  *     @param: postVars - list of vars for post request
+  *     @topic: 0
+  */
+dtmlXMLLoaderObject.prototype.loadXML=function(filePath, postMode, postVars, rpc){
+	if (this.rSeed)
+		filePath+=((filePath.indexOf("?") != -1) ? "&" : "?")+"a_dhx_rSeed="+(new Date()).valueOf();
+	this.filePath=filePath;
+
+	if ((!_isIE)&&(window.XMLHttpRequest))
+		this.xmlDoc=new XMLHttpRequest();
+	else {
+		if (document.implementation&&document.implementation.createDocument){
+			this.xmlDoc=document.implementation.createDocument("", "", null);
+			this.xmlDoc.onload=new this.waitLoadFunction(this);
+			this.xmlDoc.load(filePath);
+			return;
+		} else
+			this.xmlDoc=new ActiveXObject("Microsoft.XMLHTTP");
+	}
+
+	if (this.async)
+		this.xmlDoc.onreadystatechange=new this.waitLoadFunction(this);
+	this.xmlDoc.open(postMode ? "POST" : "GET", filePath, this.async);
+
+	if (rpc){
+		this.xmlDoc.setRequestHeader("User-Agent", "dhtmlxRPC v0.1 ("+navigator.userAgent+")");
+		this.xmlDoc.setRequestHeader("Content-type", "text/xml");
+	}
+
+	else if (postMode)
+		this.xmlDoc.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
+		
+	this.xmlDoc.setRequestHeader("X-Requested-With","XMLHttpRequest");
+	this.xmlDoc.send(null||postVars);
+
+	if (!this.async)
+		(new this.waitLoadFunction(this))();
+};
+/**
+  *     @desc: destructor, cleans used memory
+  *     @type: private
+  *     @topic: 0
+  */
+dtmlXMLLoaderObject.prototype.destructor=function(){
+	this._filterXPath = null;
+	this._getAllNamedChilds = null;
+	this._retry = null;
+	this.async = null;
+	this.rSeed = null;
+	this.filePath = null;
+	this.onloadAction = null;
+	this.mainObject = null;
+	this.xmlDoc = null;
+	this.doXPath = null;
+	this.doXPathOpera = null;
+	this.doXSLTransToObject = null;
+	this.doXSLTransToString = null;
+	this.loadXML = null;
+	this.loadXMLString = null;
+	// this.waitLoadFunction = null;
+	this.doSerialization = null;
+	this.xmlNodeToJSON = null;
+	this.getXMLTopNode = null;
+	this.setXSLParamValue = null;
+	return null;
+}
+
+dtmlXMLLoaderObject.prototype.xmlNodeToJSON = function(node){
+        var t={};
+        for (var i=0; i<node.attributes.length; i++)
+            t[node.attributes[i].name]=node.attributes[i].value;
+        t["_tagvalue"]=node.firstChild?node.firstChild.nodeValue:"";
+        for (var i=0; i<node.childNodes.length; i++){
+            var name=node.childNodes[i].tagName;
+            if (name){
+                if (!t[name]) t[name]=[];
+                t[name].push(this.xmlNodeToJSON(node.childNodes[i]));
+            }            
+        }        
+        return t;
+    }
+
+/**  
+  *     @desc: Call wrapper
+  *     @type: private
+  *     @param: funcObject - action handler
+  *     @param: dhtmlObject - user data
+  *     @returns: function handler
+  *     @topic: 0  
+  */
+function callerFunction(funcObject, dhtmlObject){
+	this.handler=function(e){
+		if (!e)
+			e=window.event;
+		funcObject(e, dhtmlObject);
+		return true;
+	};
+	return this.handler;
+};
+
+/**  
+  *     @desc: Calculate absolute position of html object
+  *     @type: private
+  *     @param: htmlObject - html object
+  *     @topic: 0  
+  */
+function getAbsoluteLeft(htmlObject){
+	return getOffset(htmlObject).left;
+}
+/**
+  *     @desc: Calculate absolute position of html object
+  *     @type: private
+  *     @param: htmlObject - html object
+  *     @topic: 0  
+  */
+function getAbsoluteTop(htmlObject){
+	return getOffset(htmlObject).top;
+}
+
+function getOffsetSum(elem) {
+	var top=0, left=0;
+	while(elem) {
+		top = top + parseInt(elem.offsetTop);
+		left = left + parseInt(elem.offsetLeft);
+		elem = elem.offsetParent;
+	}
+	return {top: top, left: left};
+}
+function getOffsetRect(elem) {
+	var box = elem.getBoundingClientRect();
+	var body = document.body;
+	var docElem = document.documentElement;
+	var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop;
+	var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft;
+	var clientTop = docElem.clientTop || body.clientTop || 0;
+	var clientLeft = docElem.clientLeft || body.clientLeft || 0;
+	var top  = box.top +  scrollTop - clientTop;
+	var left = box.left + scrollLeft - clientLeft;
+	return { top: Math.round(top), left: Math.round(left) };
+}
+function getOffset(elem) {
+	if (elem.getBoundingClientRect) {
+		return getOffsetRect(elem);
+	} else {
+		return getOffsetSum(elem);
+	}
+}
+
+/**  
+*     @desc: Convert string to it boolean representation
+*     @type: private
+*     @param: inputString - string for covertion
+*     @topic: 0
+*/
+function convertStringToBoolean(inputString){
+	if (typeof (inputString) == "string")
+		inputString=inputString.toLowerCase();
+
+	switch (inputString){
+		case "1":
+		case "true":
+		case "yes":
+		case "y":
+		case 1:
+		case true:
+			return true;
+			break;
+
+		default: return false;
+	}
+}
+
+/**  
+*     @desc: find out what symbol to use as url param delimiters in further params
+*     @type: private
+*     @param: str - current url string
+*     @topic: 0  
+*/
+function getUrlSymbol(str){
+	if (str.indexOf("?") != -1)
+		return "&"
+	else
+		return "?"
+}
+
+function dhtmlDragAndDropObject(){
+	if (window.dhtmlDragAndDrop)
+		return window.dhtmlDragAndDrop;
+
+	this.lastLanding=0;
+	this.dragNode=0;
+	this.dragStartNode=0;
+	this.dragStartObject=0;
+	this.tempDOMU=null;
+	this.tempDOMM=null;
+	this.waitDrag=0;
+	window.dhtmlDragAndDrop=this;
+
+	return this;
+};
+
+dhtmlDragAndDropObject.prototype.removeDraggableItem=function(htmlNode){
+	htmlNode.onmousedown=null;
+	htmlNode.dragStarter=null;
+	htmlNode.dragLanding=null;
+}
+dhtmlDragAndDropObject.prototype.addDraggableItem=function(htmlNode, dhtmlObject){
+	htmlNode.onmousedown=this.preCreateDragCopy;
+	htmlNode.dragStarter=dhtmlObject;
+	this.addDragLanding(htmlNode, dhtmlObject);
+}
+dhtmlDragAndDropObject.prototype.addDragLanding=function(htmlNode, dhtmlObject){
+	htmlNode.dragLanding=dhtmlObject;
+}
+dhtmlDragAndDropObject.prototype.preCreateDragCopy=function(e){
+	if ((e||window.event) && (e||event).button == 2)
+		return;
+
+	if (window.dhtmlDragAndDrop.waitDrag){
+		window.dhtmlDragAndDrop.waitDrag=0;
+		document.body.onmouseup=window.dhtmlDragAndDrop.tempDOMU;
+		document.body.onmousemove=window.dhtmlDragAndDrop.tempDOMM;
+		return false;
+	}
+
+	window.dhtmlDragAndDrop.waitDrag=1;
+	window.dhtmlDragAndDrop.tempDOMU=document.body.onmouseup;
+	window.dhtmlDragAndDrop.tempDOMM=document.body.onmousemove;
+	window.dhtmlDragAndDrop.dragStartNode=this;
+	window.dhtmlDragAndDrop.dragStartObject=this.dragStarter;
+	document.body.onmouseup=window.dhtmlDragAndDrop.preCreateDragCopy;
+	document.body.onmousemove=window.dhtmlDragAndDrop.callDrag;
+	window.dhtmlDragAndDrop.downtime = new Date().valueOf();
+	
+
+	if ((e)&&(e.preventDefault)){
+		e.preventDefault();
+		return false;
+	}
+	return false;
+};
+dhtmlDragAndDropObject.prototype.callDrag=function(e){
+	if (!e)
+		e=window.event;
+	dragger=window.dhtmlDragAndDrop;
+	if ((new Date()).valueOf()-dragger.downtime<100) return;
+
+	if ((e.button == 0)&&(_isIE))
+		return dragger.stopDrag();
+
+	if (!dragger.dragNode&&dragger.waitDrag){
+		dragger.dragNode=dragger.dragStartObject._createDragNode(dragger.dragStartNode, e);
+
+		if (!dragger.dragNode)
+			return dragger.stopDrag();
+
+		dragger.dragNode.onselectstart=function(){return false;}
+		dragger.gldragNode=dragger.dragNode;
+		document.body.appendChild(dragger.dragNode);
+		document.body.onmouseup=dragger.stopDrag;
+		dragger.waitDrag=0;
+		dragger.dragNode.pWindow=window;
+		dragger.initFrameRoute();
+	}
+
+	if (dragger.dragNode.parentNode != window.document.body){
+		var grd = dragger.gldragNode;
+
+		if (dragger.gldragNode.old)
+			grd=dragger.gldragNode.old;
+
+		//if (!document.all) dragger.calculateFramePosition();
+		grd.parentNode.removeChild(grd);
+		var oldBody = dragger.dragNode.pWindow;
+
+		if (grd.pWindow &&	grd.pWindow.dhtmlDragAndDrop.lastLanding)
+			grd.pWindow.dhtmlDragAndDrop.lastLanding.dragLanding._dragOut(grd.pWindow.dhtmlDragAndDrop.lastLanding);	
+			
+		//		var oldp=dragger.dragNode.parentObject;
+		if (_isIE){
+			var div = document.createElement("Div");
+			div.innerHTML=dragger.dragNode.outerHTML;
+			dragger.dragNode=div.childNodes[0];
+		} else
+			dragger.dragNode=dragger.dragNode.cloneNode(true);
+
+		dragger.dragNode.pWindow=window;
+		//		dragger.dragNode.parentObject=oldp;
+
+		dragger.gldragNode.old=dragger.dragNode;
+		document.body.appendChild(dragger.dragNode);
+		oldBody.dhtmlDragAndDrop.dragNode=dragger.dragNode;
+	}
+
+	dragger.dragNode.style.left=e.clientX+15+(dragger.fx
+		? dragger.fx*(-1)
+		: 0)
+		+(document.body.scrollLeft||document.documentElement.scrollLeft)+"px";
+	dragger.dragNode.style.top=e.clientY+3+(dragger.fy
+		? dragger.fy*(-1)
+		: 0)
+		+(document.body.scrollTop||document.documentElement.scrollTop)+"px";
+
+	if (!e.srcElement)
+		var z = e.target;
+	else
+		z=e.srcElement;
+	dragger.checkLanding(z, e);
+}
+
+dhtmlDragAndDropObject.prototype.calculateFramePosition=function(n){
+	//this.fx = 0, this.fy = 0;
+	if (window.name){
+		var el = parent.frames[window.name].frameElement.offsetParent;
+		var fx = 0;
+		var fy = 0;
+
+		while (el){
+			fx+=el.offsetLeft;
+			fy+=el.offsetTop;
+			el=el.offsetParent;
+		}
+
+		if ((parent.dhtmlDragAndDrop)){
+			var ls = parent.dhtmlDragAndDrop.calculateFramePosition(1);
+			fx+=ls.split('_')[0]*1;
+			fy+=ls.split('_')[1]*1;
+		}
+
+		if (n)
+			return fx+"_"+fy;
+		else
+			this.fx=fx;
+		this.fy=fy;
+	}
+	return "0_0";
+}
+dhtmlDragAndDropObject.prototype.checkLanding=function(htmlObject, e){
+	if ((htmlObject)&&(htmlObject.dragLanding)){
+		if (this.lastLanding)
+			this.lastLanding.dragLanding._dragOut(this.lastLanding);
+		this.lastLanding=htmlObject;
+		this.lastLanding=this.lastLanding.dragLanding._dragIn(this.lastLanding, this.dragStartNode, e.clientX,
+			e.clientY, e);
+		this.lastLanding_scr=(_isIE ? e.srcElement : e.target);
+	} else {
+		if ((htmlObject)&&(htmlObject.tagName != "BODY"))
+			this.checkLanding(htmlObject.parentNode, e);
+		else {
+			if (this.lastLanding)
+				this.lastLanding.dragLanding._dragOut(this.lastLanding, e.clientX, e.clientY, e);
+			this.lastLanding=0;
+
+			if (this._onNotFound)
+				this._onNotFound();
+		}
+	}
+}
+dhtmlDragAndDropObject.prototype.stopDrag=function(e, mode){
+	dragger=window.dhtmlDragAndDrop;
+
+	if (!mode){
+		dragger.stopFrameRoute();
+		var temp = dragger.lastLanding;
+		dragger.lastLanding=null;
+
+		if (temp)
+			temp.dragLanding._drag(dragger.dragStartNode, dragger.dragStartObject, temp, (_isIE
+				? event.srcElement
+				: e.target));
+	}
+	dragger.lastLanding=null;
+
+	if ((dragger.dragNode)&&(dragger.dragNode.parentNode == document.body))
+		dragger.dragNode.parentNode.removeChild(dragger.dragNode);
+	dragger.dragNode=0;
+	dragger.gldragNode=0;
+	dragger.fx=0;
+	dragger.fy=0;
+	dragger.dragStartNode=0;
+	dragger.dragStartObject=0;
+	document.body.onmouseup=dragger.tempDOMU;
+	document.body.onmousemove=dragger.tempDOMM;
+	dragger.tempDOMU=null;
+	dragger.tempDOMM=null;
+	dragger.waitDrag=0;
+}
+
+dhtmlDragAndDropObject.prototype.stopFrameRoute=function(win){
+	if (win)
+		window.dhtmlDragAndDrop.stopDrag(1, 1);
+
+	for (var i = 0; i < window.frames.length; i++){
+		try{
+		if ((window.frames[i] != win)&&(window.frames[i].dhtmlDragAndDrop))
+			window.frames[i].dhtmlDragAndDrop.stopFrameRoute(window);
+		} catch(e){}
+	}
+
+	try{
+	if ((parent.dhtmlDragAndDrop)&&(parent != window)&&(parent != win))
+		parent.dhtmlDragAndDrop.stopFrameRoute(window);
+	} catch(e){}
+}
+dhtmlDragAndDropObject.prototype.initFrameRoute=function(win, mode){
+	if (win){
+		window.dhtmlDragAndDrop.preCreateDragCopy();
+		window.dhtmlDragAndDrop.dragStartNode=win.dhtmlDragAndDrop.dragStartNode;
+		window.dhtmlDragAndDrop.dragStartObject=win.dhtmlDragAndDrop.dragStartObject;
+		window.dhtmlDragAndDrop.dragNode=win.dhtmlDragAndDrop.dragNode;
+		window.dhtmlDragAndDrop.gldragNode=win.dhtmlDragAndDrop.dragNode;
+		window.document.body.onmouseup=window.dhtmlDragAndDrop.stopDrag;
+		window.waitDrag=0;
+
+		if (((!_isIE)&&(mode))&&((!_isFF)||(_FFrv < 1.8)))
+			window.dhtmlDragAndDrop.calculateFramePosition();
+	}
+	try{
+	if ((parent.dhtmlDragAndDrop)&&(parent != window)&&(parent != win))
+		parent.dhtmlDragAndDrop.initFrameRoute(window);
+	}catch(e){}
+
+	for (var i = 0; i < window.frames.length; i++){
+		try{
+		if ((window.frames[i] != win)&&(window.frames[i].dhtmlDragAndDrop))
+			window.frames[i].dhtmlDragAndDrop.initFrameRoute(window, ((!win||mode) ? 1 : 0));
+		} catch(e){}
+	}
+}
+
+var _isFF = false;
+var _isIE = false;
+var _isOpera = false;
+var _isKHTML = false;
+var _isMacOS = false;
+var _isChrome = false;
+
+if (navigator.userAgent.indexOf('Macintosh') != -1)
+	_isMacOS=true;
+
+
+if (navigator.userAgent.toLowerCase().indexOf('chrome')>-1)
+	_isChrome=true;
+
+if ((navigator.userAgent.indexOf('Safari') != -1)||(navigator.userAgent.indexOf('Konqueror') != -1)){
+	var _KHTMLrv = parseFloat(navigator.userAgent.substr(navigator.userAgent.indexOf('Safari')+7, 5));
+
+	if (_KHTMLrv > 525){ //mimic FF behavior for Safari 3.1+
+		_isFF=true;
+		var _FFrv = 1.9;
+	} else
+		_isKHTML=true;
+} else if (navigator.userAgent.indexOf('Opera') != -1){
+	_isOpera=true;
+	_OperaRv=parseFloat(navigator.userAgent.substr(navigator.userAgent.indexOf('Opera')+6, 3));
+}
+
+
+else if (navigator.appName.indexOf("Microsoft") != -1){
+	_isIE=true;
+	if (navigator.appVersion.indexOf("MSIE 8.0")!= -1 && document.compatMode != "BackCompat") _isIE=8;
+} else {
+	_isFF=true;
+	var _FFrv = parseFloat(navigator.userAgent.split("rv:")[1])
+}
+
+
+//multibrowser Xpath processor
+dtmlXMLLoaderObject.prototype.doXPath=function(xpathExp, docObj, namespace, result_type){
+	if (_isKHTML || (!_isIE && !window.XPathResult))
+		return this.doXPathOpera(xpathExp, docObj);
+
+	if (_isIE){ //IE
+		if (!docObj)
+			if (!this.xmlDoc.nodeName)
+				docObj=this.xmlDoc.responseXML
+			else
+				docObj=this.xmlDoc;
+
+		if (!docObj)
+			dhtmlxError.throwError("LoadXML", "Incorrect XML", [
+				(docObj||this.xmlDoc),
+				this.mainObject
+			]);
+
+		if (namespace != null)
+			docObj.setProperty("SelectionNamespaces", "xmlns:xsl='"+namespace+"'"); //
+
+		if (result_type == 'single'){
+			return docObj.selectSingleNode(xpathExp);
+		}
+		else {
+			return docObj.selectNodes(xpathExp)||new Array(0);
+		}
+	} else { //Mozilla
+		var nodeObj = docObj;
+
+		if (!docObj){
+			if (!this.xmlDoc.nodeName){
+				docObj=this.xmlDoc.responseXML
+			}
+			else {
+				docObj=this.xmlDoc;
+			}
+		}
+
+		if (!docObj)
+			dhtmlxError.throwError("LoadXML", "Incorrect XML", [
+				(docObj||this.xmlDoc),
+				this.mainObject
+			]);
+
+		if (docObj.nodeName.indexOf("document") != -1){
+			nodeObj=docObj;
+		}
+		else {
+			nodeObj=docObj;
+			docObj=docObj.ownerDocument;
+		}
+		var retType = XPathResult.ANY_TYPE;
+
+		if (result_type == 'single')
+			retType=XPathResult.FIRST_ORDERED_NODE_TYPE
+		var rowsCol = new Array();
+		var col = docObj.evaluate(xpathExp, nodeObj, function(pref){
+			return namespace
+		}, retType, null);
+
+		if (retType == XPathResult.FIRST_ORDERED_NODE_TYPE){
+			return col.singleNodeValue;
+		}
+		var thisColMemb = col.iterateNext();
+
+		while (thisColMemb){
+			rowsCol[rowsCol.length]=thisColMemb;
+			thisColMemb=col.iterateNext();
+		}
+		return rowsCol;
+	}
+}
+
+function _dhtmlxError(type, name, params){
+	if (!this.catches)
+		this.catches=new Array();
+
+	return this;
+}
+
+_dhtmlxError.prototype.catchError=function(type, func_name){
+	this.catches[type]=func_name;
+}
+_dhtmlxError.prototype.throwError=function(type, name, params){
+	if (this.catches[type])
+		return this.catches[type](type, name, params);
+
+	if (this.catches["ALL"])
+		return this.catches["ALL"](type, name, params);
+
+	alert("Error type: "+arguments[0]+"\nDescription: "+arguments[1]);
+	return null;
+}
+
+window.dhtmlxError=new _dhtmlxError();
+
+
+//opera fake, while 9.0 not released
+//multibrowser Xpath processor
+dtmlXMLLoaderObject.prototype.doXPathOpera=function(xpathExp, docObj){
+	//this is fake for Opera
+	var z = xpathExp.replace(/[\/]+/gi, "/").split('/');
+	var obj = null;
+	var i = 1;
+
+	if (!z.length)
+		return [];
+
+	if (z[0] == ".")
+		obj=[docObj]; else if (z[0] == ""){
+		obj=(this.xmlDoc.responseXML||this.xmlDoc).getElementsByTagName(z[i].replace(/\[[^\]]*\]/g, ""));
+		i++;
+	} else
+		return [];
+
+	for (i; i < z.length; i++)obj=this._getAllNamedChilds(obj, z[i]);
+
+	if (z[i-1].indexOf("[") != -1)
+		obj=this._filterXPath(obj, z[i-1]);
+	return obj;
+}
+
+dtmlXMLLoaderObject.prototype._filterXPath=function(a, b){
+	var c = new Array();
+	var b = b.replace(/[^\[]*\[\@/g, "").replace(/[\[\]\@]*/g, "");
+
+	for (var i = 0; i < a.length; i++)
+		if (a[i].getAttribute(b))
+			c[c.length]=a[i];
+
+	return c;
+}
+dtmlXMLLoaderObject.prototype._getAllNamedChilds=function(a, b){
+	var c = new Array();
+
+	if (_isKHTML)
+		b=b.toUpperCase();
+
+	for (var i = 0; i < a.length; i++)for (var j = 0; j < a[i].childNodes.length; j++){
+		if (_isKHTML){
+			if (a[i].childNodes[j].tagName&&a[i].childNodes[j].tagName.toUpperCase() == b)
+				c[c.length]=a[i].childNodes[j];
+		}
+
+		else if (a[i].childNodes[j].tagName == b)
+			c[c.length]=a[i].childNodes[j];
+	}
+
+	return c;
+}
+
+function dhtmlXHeir(a, b){
+	for (var c in b)
+		if (typeof (b[c]) == "function")
+			a[c]=b[c];
+	return a;
+}
+
+function dhtmlxEvent(el, event, handler){
+	if (el.addEventListener)
+		el.addEventListener(event, handler, false);
+
+	else if (el.attachEvent)
+		el.attachEvent("on"+event, handler);
+}
+
+//============= XSL Extension ===================================
+
+dtmlXMLLoaderObject.prototype.xslDoc=null;
+dtmlXMLLoaderObject.prototype.setXSLParamValue=function(paramName, paramValue, xslDoc){
+	if (!xslDoc)
+		xslDoc=this.xslDoc
+
+	if (xslDoc.responseXML)
+		xslDoc=xslDoc.responseXML;
+	var item =
+		this.doXPath("/xsl:stylesheet/xsl:variable[@name='"+paramName+"']", xslDoc,
+			"http:/\/www.w3.org/1999/XSL/Transform", "single");
+
+	if (item != null)
+		item.firstChild.nodeValue=paramValue
+}
+dtmlXMLLoaderObject.prototype.doXSLTransToObject=function(xslDoc, xmlDoc){
+	if (!xslDoc)
+		xslDoc=this.xslDoc;
+
+	if (xslDoc.responseXML)
+		xslDoc=xslDoc.responseXML
+
+	if (!xmlDoc)
+		xmlDoc=this.xmlDoc;
+
+	if (xmlDoc.responseXML)
+		xmlDoc=xmlDoc.responseXML
+
+	//MOzilla
+	if (!_isIE){
+		if (!this.XSLProcessor){
+			this.XSLProcessor=new XSLTProcessor();
+			this.XSLProcessor.importStylesheet(xslDoc);
+		}
+		var result = this.XSLProcessor.transformToDocument(xmlDoc);
+	} else {
+		var result = new ActiveXObject("Msxml2.DOMDocument.3.0");
+		try{
+			xmlDoc.transformNodeToObject(xslDoc, result);
+		}catch(e){
+			result = xmlDoc.transformNode(xslDoc);
+		}
+	}
+	return result;
+}
+
+dtmlXMLLoaderObject.prototype.doXSLTransToString=function(xslDoc, xmlDoc){
+	var res = this.doXSLTransToObject(xslDoc, xmlDoc);
+	if(typeof(res)=="string")
+		return res;
+	return this.doSerialization(res);
+}
+
+dtmlXMLLoaderObject.prototype.doSerialization=function(xmlDoc){
+	if (!xmlDoc)
+			xmlDoc=this.xmlDoc;
+	if (xmlDoc.responseXML)
+			xmlDoc=xmlDoc.responseXML
+	if (!_isIE){
+		var xmlSerializer = new XMLSerializer();
+		return xmlSerializer.serializeToString(xmlDoc);
+	} else
+		return xmlDoc.xml;
+}
+
+/**
+*   @desc: 
+*   @type: private
+*/
+dhtmlxEventable=function(obj){
+		obj.attachEvent=function(name, catcher, callObj){
+			name='ev_'+name.toLowerCase();
+			if (!this[name])
+				this[name]=new this.eventCatcher(callObj||this);
+				
+			return(name+':'+this[name].addEvent(catcher)); //return ID (event name & event ID)
+		}
+		obj.callEvent=function(name, arg0){ 
+			name='ev_'+name.toLowerCase();
+			if (this[name])
+				return this[name].apply(this, arg0);
+			return true;
+		}
+		obj.checkEvent=function(name){
+			return (!!this['ev_'+name.toLowerCase()])
+		}
+		obj.eventCatcher=function(obj){
+			var dhx_catch = [];
+			var z = function(){
+				var res = true;
+				for (var i = 0; i < dhx_catch.length; i++){
+					if (dhx_catch[i] != null){
+						var zr = dhx_catch[i].apply(obj, arguments);
+						res=res&&zr;
+					}
+				}
+				return res;
+			}
+			z.addEvent=function(ev){
+				if (typeof (ev) != "function")
+					ev=eval(ev);
+				if (ev)
+					return dhx_catch.push(ev)-1;
+				return false;
+			}
+			z.removeEvent=function(id){
+				dhx_catch[id]=null;
+			}
+			return z;
+		}
+		obj.detachEvent=function(id){
+			if (id != false){
+				var list = id.split(':');           //get EventName and ID
+				this[list[0]].removeEvent(list[1]); //remove event
+			}
+		}
+		obj.detachAllEvents = function(){
+			for (var name in this){
+				if (name.indexOf("ev_")==0) 
+					delete this[name];
+			}
+		}
+}
+ .hledger/web/favicon.ico view

binary file changed (absent → 1150 bytes)

+ .hledger/web/hledger.js view
@@ -0,0 +1,158 @@+/* hledger web ui javascripts */+/* depends on jquery, other support libs, and additional js inserted inline */++$(document).ready(function() {++    /* maybe show forms */+    if ($.url.param('add')) addformToggle();+    else if ($.url.param('edit')) editformToggle();++});++function filterformToggle() {+ var a = document.getElementById('addform');+ var e = document.getElementById('editform');+ var f = document.getElementById('filterform');+ var i = document.getElementById('importform');+ var t = document.getElementById('transactions');+ var alink = document.getElementById('addformlink');+ var elink = document.getElementById('editformlink');+ var flink = document.getElementById('filterformlink');+ var ilink = document.getElementById('importformlink');+ var jlink = document.getElementById('journallink');+ var rlink = document.getElementById('registerlink');++ if (f.style.display == 'none') {+  flink.style['font-weight'] = 'bold';+  f.style.display = 'block';+ } else {+  flink.style['font-weight'] = 'normal';+  f.style.display = 'none';+ }+ return false;+}++function addformToggle() {+ var a = document.getElementById('addform');+ var e = document.getElementById('editform');+ var f = document.getElementById('filterform');+ var i = document.getElementById('importform');+ var t = document.getElementById('transactions');+ var alink = document.getElementById('addformlink');+ var elink = document.getElementById('editformlink');+ var flink = document.getElementById('filterformlink');+ var ilink = document.getElementById('importformlink');+ var jlink = document.getElementById('journallink');+ var rlink = document.getElementById('registerlink');++ if (a.style.display == 'none') {+  alink.style['font-weight'] = 'bold';+  elink.style['font-weight'] = 'normal';+  ilink.style['font-weight'] = 'normal';+  jlink.style['font-weight'] = 'normal';+  rlink.style['font-weight'] = 'normal';+  a.style.display = 'block';+  e.style.display = 'none';+  i.style.display = 'none';+  t.style.display = 'none';+ } else {+  alink.style['font-weight'] = 'normal';+  elink.style['font-weight'] = 'normal';+  ilink.style['font-weight'] = 'normal';+  a.style.display = 'none';+  e.style.display = 'none';+  i.style.display = 'none';+  t.style.display = 'block';+ }+ return false;+}++function editformToggle() {+ var a = document.getElementById('addform');+ var e = document.getElementById('editform');+ var ej = document.getElementById('journalselect');+ var f = document.getElementById('filterform');+ var i = document.getElementById('importform');+ var t = document.getElementById('transactions');+ var alink = document.getElementById('addformlink');+ var elink = document.getElementById('editformlink');+ var flink = document.getElementById('filterformlink');+ var ilink = document.getElementById('importformlink');+ var jlink = document.getElementById('journallink');+ var rlink = document.getElementById('registerlink');++ if (e.style.display == 'none') {+  alink.style['font-weight'] = 'normal';+  elink.style['font-weight'] = 'bold';+  ilink.style['font-weight'] = 'normal';+  jlink.style['font-weight'] = 'normal';+  rlink.style['font-weight'] = 'normal';+  a.style.display = 'none';+  i.style.display = 'none';+  t.style.display = 'none';+  e.style.display = 'block';+  editformJournalSelect();+ } else {+  alink.style['font-weight'] = 'normal';+  elink.style['font-weight'] = 'normal';+  ilink.style['font-weight'] = 'normal';+  a.style.display = 'none';+  e.style.display = 'none';+  i.style.display = 'none';+  t.style.display = 'block';+ }+ return false;+}++function editformJournalSelect() {+ var textareas = $('textarea', $('form#editform'));+ for (i=0; i<textareas.length; i++) {+   textareas[i].style.display = 'none';+   textareas[i].disabled = true;+ }+ if (event.target.value) {+   var journalid = event.target.value+'_textarea';+   var textarea = document.getElementById(journalid);+ }+ else {+   var textarea = textareas[0];+ }+ textarea.style.display = 'block';+ textarea.disabled = false;+ return true;+}++function importformToggle() {+ var a = document.getElementById('addform');+ var e = document.getElementById('editform');+ var f = document.getElementById('filterform');+ var i = document.getElementById('importform');+ var t = document.getElementById('transactions');+ var alink = document.getElementById('addformlink');+ var elink = document.getElementById('editformlink');+ var flink = document.getElementById('filterformlink');+ var ilink = document.getElementById('importformlink');+ var jlink = document.getElementById('journallink');+ var rlink = document.getElementById('registerlink');++ if (i.style.display == 'none') {+  alink.style['font-weight'] = 'normal';+  elink.style['font-weight'] = 'normal';+  ilink.style['font-weight'] = 'bold';+  jlink.style['font-weight'] = 'normal';+  rlink.style['font-weight'] = 'normal';+  a.style.display = 'none';+  e.style.display = 'none';+  i.style.display = 'block';+  t.style.display = 'none';+ } else {+  alink.style['font-weight'] = 'normal';+  elink.style['font-weight'] = 'normal';+  ilink.style['font-weight'] = 'normal';+  a.style.display = 'none';+  e.style.display = 'none';+  i.style.display = 'none';+  t.style.display = 'block';+ }+ return false;+}
+ .hledger/web/jquery.js view
@@ -0,0 +1,154 @@+/*!+ * jQuery JavaScript Library v1.4.2+ * http://jquery.com/+ *+ * Copyright 2010, John Resig+ * Dual licensed under the MIT or GPL Version 2 licenses.+ * http://jquery.org/license+ *+ * Includes Sizzle.js+ * http://sizzlejs.com/+ * Copyright 2010, The Dojo Foundation+ * Released under the MIT, BSD, and GPL Licenses.+ *+ * Date: Sat Feb 13 22:33:48 2010 -0500+ */+(function(A,w){function ma(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(ma,1);return}c.ready()}}function Qa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,j){var i=a.length;if(typeof b==="object"){for(var o in b)X(a,o,b[o],f,e,d);return a}if(d!==w){f=!j&&f&&c.isFunction(d);for(o=0;o<i;o++)e(a[o],b,f?d.call(a[o],o,e(a[o],b)):d,j);return a}return i?+e(a[0],b):w}function J(){return(new Date).getTime()}function Y(){return false}function Z(){return true}function na(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function oa(a){var b,d=[],f=[],e=arguments,j,i,o,k,n,r;i=c.data(this,"events");if(!(a.liveFired===this||!i||!i.live||a.button&&a.type==="click")){a.liveFired=this;var u=i.live.slice(0);for(k=0;k<u.length;k++){i=u[k];i.origType.replace(O,"")===a.type?f.push(i.selector):u.splice(k--,1)}j=c(a.target).closest(f,a.currentTarget);n=0;for(r=+j.length;n<r;n++)for(k=0;k<u.length;k++){i=u[k];if(j[n].selector===i.selector){o=j[n].elem;f=null;if(i.preType==="mouseenter"||i.preType==="mouseleave")f=c(a.relatedTarget).closest(i.selector)[0];if(!f||f!==o)d.push({elem:o,handleObj:i})}}n=0;for(r=d.length;n<r;n++){j=d[n];a.currentTarget=j.elem;a.data=j.handleObj.data;a.handleObj=j.handleObj;if(j.handleObj.origHandler.apply(j.elem,e)===false){b=false;break}}return b}}function pa(a,b){return"live."+(a&&a!=="*"?a+".":"")+b.replace(/\./g,"`").replace(/ /g,+"&")}function qa(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function ra(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var f=c.data(a[d++]),e=c.data(this,f);if(f=f&&f.events){delete e.handle;e.events={};for(var j in f)for(var i in f[j])c.event.add(this,j,f[j][i],f[j][i].data)}}})}function sa(a,b,d){var f,e,j;b=b&&b[0]?b[0].ownerDocument||b[0]:s;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===s&&!ta.test(a[0])&&(c.support.checkClone||!ua.test(a[0]))){e=+true;if(j=c.fragments[a[0]])if(j!==1)f=j}if(!f){f=b.createDocumentFragment();c.clean(a,b,f,d)}if(e)c.fragments[a[0]]=j?f:1;return{fragment:f,cacheable:e}}function K(a,b){var d={};c.each(va.concat.apply([],va.slice(0,b)),function(){d[this]=a});return d}function wa(a){return"scrollTo"in a&&a.document?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var c=function(a,b){return new c.fn.init(a,b)},Ra=A.jQuery,Sa=A.$,s=A.document,T,Ta=/^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,Ua=/^.[^:#\[\.,]*$/,Va=/\S/,+Wa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Xa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,R=Array.prototype.slice,ya=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(a==="body"&&!b){this.context=s;this[0]=s.body;this.selector="body";this.length=1;return this}if(typeof a==="string")if((d=Ta.exec(a))&&+(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Xa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=sa([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}return c.merge(this,a)}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return T.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a);return c.merge(this,+a)}else return!b||b.jquery?(b||T).find(a):c(b).find(a);else if(c.isFunction(a))return T.ready(a);if(a.selector!==w){this.selector=a.selector;this.context=a.context}return c.makeArray(a,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){var f=c();c.isArray(a)?ba.apply(f,a):c.merge(f,a);f.prevObject=this;f.context=this.context;if(b===+"find")f.selector=this.selector+(this.selector?" ":"")+d;else if(b)f.selector=this.selector+"."+b+"("+d+")";return f},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this,+function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,j,i,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b<d;b++)if((e=arguments[b])!=null)for(j in e){i=a[j];o=e[j];if(a!==o)if(f&&o&&(c.isPlainObject(o)||c.isArray(o))){i=i&&(c.isPlainObject(i)||+c.isArray(i))?i:c.isArray(o)?[]:{};a[j]=c.extend(f,i,o)}else if(o!==w)a[j]=o}return a};c.extend({noConflict:function(a){A.$=Sa;if(a)A.jQuery=Ra;return c},isReady:false,ready:function(){if(!c.isReady){if(!s.body)return setTimeout(c.ready,13);c.isReady=true;if(Q){for(var a,b=0;a=Q[b++];)a.call(s,c);Q=null}c.fn.triggerHandler&&c(s).triggerHandler("ready")}},bindReady:function(){if(!xa){xa=true;if(s.readyState==="complete")return c.ready();if(s.addEventListener){s.addEventListener("DOMContentLoaded",+L,false);A.addEventListener("load",c.ready,false)}else if(s.attachEvent){s.attachEvent("onreadystatechange",L);A.attachEvent("onload",c.ready);var a=false;try{a=A.frameElement==null}catch(b){}s.documentElement.doScroll&&a&&ma()}}},isFunction:function(a){return $.call(a)==="[object Function]"},isArray:function(a){return $.call(a)==="[object Array]"},isPlainObject:function(a){if(!a||$.call(a)!=="[object Object]"||a.nodeType||a.setInterval)return false;if(a.constructor&&!aa.call(a,"constructor")&&!aa.call(a.constructor.prototype,+"isPrototypeOf"))return false;var b;for(b in a);return b===w||aa.call(a,b)},isEmptyObject:function(a){for(var b in a)return false;return true},error:function(a){throw a;},parseJSON:function(a){if(typeof a!=="string"||!a)return null;a=c.trim(a);if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return A.JSON&&A.JSON.parse?A.JSON.parse(a):(new Function("return "++a))();else c.error("Invalid JSON: "+a)},noop:function(){},globalEval:function(a){if(a&&Va.test(a)){var b=s.getElementsByTagName("head")[0]||s.documentElement,d=s.createElement("script");d.type="text/javascript";if(c.support.scriptEval)d.appendChild(s.createTextNode(a));else d.text=a;b.insertBefore(d,b.firstChild);b.removeChild(d)}},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,b,d){var f,e=0,j=a.length,i=j===w||c.isFunction(a);if(d)if(i)for(f in a){if(b.apply(a[f],+d)===false)break}else for(;e<j;){if(b.apply(a[e++],d)===false)break}else if(i)for(f in a){if(b.call(a[f],f,a[f])===false)break}else for(d=a[0];e<j&&b.call(d,e,d)!==false;d=a[++e]);return a},trim:function(a){return(a||"").replace(Wa,"")},makeArray:function(a,b){b=b||[];if(a!=null)a.length==null||typeof a==="string"||c.isFunction(a)||typeof a!=="function"&&a.setInterval?ba.call(b,a):c.merge(b,a);return b},inArray:function(a,b){if(b.indexOf)return b.indexOf(a);for(var d=0,f=b.length;d<f;d++)if(b[d]===+a)return d;return-1},merge:function(a,b){var d=a.length,f=0;if(typeof b.length==="number")for(var e=b.length;f<e;f++)a[d++]=b[f];else for(;b[f]!==w;)a[d++]=b[f++];a.length=d;return a},grep:function(a,b,d){for(var f=[],e=0,j=a.length;e<j;e++)!d!==!b(a[e],e)&&f.push(a[e]);return f},map:function(a,b,d){for(var f=[],e,j=0,i=a.length;j<i;j++){e=b(a[j],j,d);if(e!=null)f[f.length]=e}return f.concat.apply([],f)},guid:1,proxy:function(a,b,d){if(arguments.length===2)if(typeof b==="string"){d=a;a=d[b];b=w}else if(b&&+!c.isFunction(b)){d=b;b=w}if(!b&&a)b=function(){return a.apply(d||this,arguments)};if(a)b.guid=a.guid=a.guid||b.guid||c.guid++;return b},uaMatch:function(a){a=a.toLowerCase();a=/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||!/compatible/.test(a)&&/(mozilla)(?:.*? rv:([\w.]+))?/.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}},browser:{}});P=c.uaMatch(P);if(P.browser){c.browser[P.browser]=true;c.browser.version=P.version}if(c.browser.webkit)c.browser.safari=+true;if(ya)c.inArray=function(a,b){return ya.call(b,a)};T=c(s);if(s.addEventListener)L=function(){s.removeEventListener("DOMContentLoaded",L,false);c.ready()};else if(s.attachEvent)L=function(){if(s.readyState==="complete"){s.detachEvent("onreadystatechange",L);c.ready()}};(function(){c.support={};var a=s.documentElement,b=s.createElement("script"),d=s.createElement("div"),f="script"+J();d.style.display="none";d.innerHTML="   <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";+var e=d.getElementsByTagName("*"),j=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!j)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(j.getAttribute("style")),hrefNormalized:j.getAttribute("href")==="/a",opacity:/^0.55$/.test(j.style.opacity),cssFloat:!!j.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:s.createElement("select").appendChild(s.createElement("option")).selected,+parentNode:d.removeChild(d.appendChild(s.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(i){}a.insertBefore(b,a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}try{delete b.test}catch(o){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function k(){c.support.noCloneEvent=+false;d.detachEvent("onclick",k)});d.cloneNode(true).fireEvent("onclick")}d=s.createElement("div");d.innerHTML="<input type='radio' name='radiotest' checked='checked'/>";a=s.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var k=s.createElement("div");k.style.width=k.style.paddingLeft="1px";s.body.appendChild(k);c.boxModel=c.support.boxModel=k.offsetWidth===2;s.body.removeChild(k).style.display="none"});a=function(k){var n=+s.createElement("div");k="on"+k;var r=k in n;if(!r){n.setAttribute(k,"return;");r=typeof n[k]==="function"}return r};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=j=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ya=0,za={};c.extend({cache:{},expando:G,noData:{embed:true,object:true,+applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var f=a[G],e=c.cache;if(!f&&typeof b==="string"&&d===w)return null;f||(f=++Ya);if(typeof b==="object"){a[G]=f;e[f]=c.extend(true,{},b)}else if(!e[f]){a[G]=f;e[f]={}}a=e[f];if(d!==w)a[b]=d;return typeof b==="string"?a[b]:a}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{if(c.support.deleteExpando)delete a[c.expando];+else a.removeAttribute&&a.removeAttribute(c.expando);delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===w){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===w&&this.length)f=c.data(this[0],a);return f===w&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this,+a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===+w)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var Aa=/[\n\t]/g,ca=/\s+/,Za=/\r/g,$a=/href|src|style/,ab=/(button|input)/i,bb=/(button|input|object|select|textarea)/i,+cb=/^(a|area)$/i,Ba=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(n){var r=c(this);r.addClass(a.call(this,n,r.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1)if(e.className){for(var j=" "+e.className+" ",+i=e.className,o=0,k=b.length;o<k;o++)if(j.indexOf(" "+b[o]+" ")<0)i+=" "+b[o];e.className=c.trim(i)}else e.className=a}return this},removeClass:function(a){if(c.isFunction(a))return this.each(function(k){var n=c(this);n.removeClass(a.call(this,k,n.attr("class")))});if(a&&typeof a==="string"||a===w)for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1&&e.className)if(a){for(var j=(" "+e.className+" ").replace(Aa," "),i=0,o=b.length;i<o;i++)j=j.replace(" "+b[i]+" ",+" ");e.className=c.trim(j)}else e.className=""}return this},toggleClass:function(a,b){var d=typeof a,f=typeof b==="boolean";if(c.isFunction(a))return this.each(function(e){var j=c(this);j.toggleClass(a.call(this,e,j.attr("class"),b),b)});return this.each(function(){if(d==="string")for(var e,j=0,i=c(this),o=b,k=a.split(ca);e=k[j++];){o=f?o:!i.hasClass(e);i[o?"addClass":"removeClass"](e)}else if(d==="undefined"||d==="boolean"){this.className&&c.data(this,"__className__",this.className);this.className=+this.className||a===false?"":c.data(this,"__className__")||""}})},hasClass:function(a){a=" "+a+" ";for(var b=0,d=this.length;b<d;b++)if((" "+this[b].className+" ").replace(Aa," ").indexOf(a)>-1)return true;return false},val:function(a){if(a===w){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var j=b?d:0;for(d=b?d+1:e.length;j<d;j++){var i=+e[j];if(i.selected){a=c(i).val();if(b)return a;f.push(a)}}return f}if(Ba.test(b.type)&&!c.support.checkOn)return b.getAttribute("value")===null?"on":b.value;return(b.value||"").replace(Za,"")}return w}var o=c.isFunction(a);return this.each(function(k){var n=c(this),r=a;if(this.nodeType===1){if(o)r=a.call(this,k,n.val());if(typeof r==="number")r+="";if(c.isArray(r)&&Ba.test(this.type))this.checked=c.inArray(n.val(),r)>=0;else if(c.nodeName(this,"select")){var u=c.makeArray(r);c("option",this).each(function(){this.selected=+c.inArray(c(this).val(),u)>=0});if(!u.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return w;if(f&&b in c.attrFn)return c(a)[b](d);f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==w;b=f&&c.props[b]||b;if(a.nodeType===1){var j=$a.test(b);if(b in a&&f&&!j){if(e){b==="type"&&ab.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");+a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:bb.test(a.nodeName)||cb.test(a.nodeName)&&a.href?0:w;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&j?a.getAttribute(b,2):a.getAttribute(b);return a===null?w:a}return c.style(a,b,d)}});var O=/\.(.*)$/,db=function(a){return a.replace(/[^\w\s\.\|`]/g,+function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==A&&!a.frameElement)a=A;var e,j;if(d.handler){e=d;d=e.handler}if(!d.guid)d.guid=c.guid++;if(j=c.data(a)){var i=j.events=j.events||{},o=j.handle;if(!o)j.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,arguments):w};o.elem=a;b=b.split(" ");for(var k,n=0,r;k=b[n++];){j=e?c.extend({},e):{handler:d,data:f};if(k.indexOf(".")>-1){r=k.split(".");+k=r.shift();j.namespace=r.slice(0).sort().join(".")}else{r=[];j.namespace=""}j.type=k;j.guid=d.guid;var u=i[k],z=c.event.special[k]||{};if(!u){u=i[k]=[];if(!z.setup||z.setup.call(a,f,r,o)===false)if(a.addEventListener)a.addEventListener(k,o,false);else a.attachEvent&&a.attachEvent("on"+k,o)}if(z.add){z.add.call(a,j);if(!j.handler.guid)j.handler.guid=d.guid}u.push(j);c.event.global[k]=true}a=null}}},global:{},remove:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){var e,j=0,i,o,k,n,r,u,z=c.data(a),+C=z&&z.events;if(z&&C){if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(e in C)c.event.remove(a,e+b)}else{for(b=b.split(" ");e=b[j++];){n=e;i=e.indexOf(".")<0;o=[];if(!i){o=e.split(".");e=o.shift();k=new RegExp("(^|\\.)"+c.map(o.slice(0).sort(),db).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(r=C[e])if(d){n=c.event.special[e]||{};for(B=f||0;B<r.length;B++){u=r[B];if(d.guid===u.guid){if(i||k.test(u.namespace)){f==null&&r.splice(B--,1);n.remove&&n.remove.call(a,u)}if(f!=+null)break}}if(r.length===0||f!=null&&r.length===1){if(!n.teardown||n.teardown.call(a,o)===false)Ca(a,e,z.handle);delete C[e]}}else for(var B=0;B<r.length;B++){u=r[B];if(i||k.test(u.namespace)){c.event.remove(a,n,u.handler,B);r.splice(B--,1)}}}if(c.isEmptyObject(C)){if(b=z.handle)b.elem=null;delete z.events;delete z.handle;c.isEmptyObject(z)&&c.removeData(a)}}}}},trigger:function(a,b,d,f){var e=a.type||a;if(!f){a=typeof a==="object"?a[G]?a:c.extend(c.Event(e),a):c.Event(e);if(e.indexOf("!")>=0){a.type=+e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return w;a.result=w;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d,b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(j){}if(!a.isPropagationStopped()&&+f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){f=a.target;var i,o=c.nodeName(f,"a")&&e==="click",k=c.event.special[e]||{};if((!k._default||k._default.call(d,a)===false)&&!o&&!(f&&f.nodeName&&c.noData[f.nodeName.toLowerCase()])){try{if(f[e]){if(i=f["on"+e])f["on"+e]=null;c.event.triggered=true;f[e]()}}catch(n){}if(i)f["on"+e]=i;c.event.triggered=false}}},handle:function(a){var b,d,f,e;a=arguments[0]=c.event.fix(a||A.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;+if(!b){d=a.type.split(".");a.type=d.shift();f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)")}e=c.data(this,"events");d=e[a.type];if(e&&d){d=d.slice(0);e=0;for(var j=d.length;e<j;e++){var i=d[e];if(b||f.test(i.namespace)){a.handler=i.handler;a.data=i.data;a.handleObj=i;i=i.handler.apply(this,arguments);if(i!==w){a.result=i;if(i===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}}return a.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),+fix:function(a){if(a[G])return a;var b=a;a=c.Event(b);for(var d=this.props.length,f;d;){f=this.props[--d];a[f]=b[f]}if(!a.target)a.target=a.srcElement||s;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){b=s.documentElement;d=s.body;a.pageX=a.clientX+(b&&b.scrollLeft||d&&d.scrollLeft||0)-(b&&b.clientLeft||d&&d.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop||+d&&d.scrollTop||0)-(b&&b.clientTop||d&&d.clientTop||0)}if(!a.which&&(a.charCode||a.charCode===0?a.charCode:a.keyCode))a.which=a.charCode||a.keyCode;if(!a.metaKey&&a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==w)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:c.proxy,special:{ready:{setup:c.bindReady,teardown:c.noop},live:{add:function(a){c.event.add(this,a.origType,c.extend({},a,{handler:oa}))},remove:function(a){var b=true,d=a.origType.replace(O,"");c.each(c.data(this,+"events").live||[],function(){if(d===this.origType.replace(O,""))return b=false});b&&c.event.remove(this,a.origType,oa)}},beforeunload:{setup:function(a,b,d){if(this.setInterval)this.onbeforeunload=d;return false},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}}};var Ca=s.removeEventListener?function(a,b,d){a.removeEventListener(b,d,false)}:function(a,b,d){a.detachEvent("on"+b,d)};c.Event=function(a){if(!this.preventDefault)return new c.Event(a);if(a&&a.type){this.originalEvent=+a;this.type=a.type}else this.type=a;this.timeStamp=J();this[G]=true};c.Event.prototype={preventDefault:function(){this.isDefaultPrevented=Z;var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=false}},stopPropagation:function(){this.isPropagationStopped=Z;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Z;this.stopPropagation()},isDefaultPrevented:Y,isPropagationStopped:Y,+isImmediatePropagationStopped:Y};var Da=function(a){var b=a.relatedTarget;try{for(;b&&b!==this;)b=b.parentNode;if(b!==this){a.type=a.data;c.event.handle.apply(this,arguments)}}catch(d){}},Ea=function(a){a.type=a.data;c.event.handle.apply(this,arguments)};c.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){c.event.special[a]={setup:function(d){c.event.add(this,b,d&&d.selector?Ea:Da,a)},teardown:function(d){c.event.remove(this,b,d&&d.selector?Ea:Da)}}});if(!c.support.submitBubbles)c.event.special.submit=+{setup:function(){if(this.nodeName.toLowerCase()!=="form"){c.event.add(this,"click.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="submit"||d==="image")&&c(b).closest("form").length)return na("submit",this,arguments)});c.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="text"||d==="password")&&c(b).closest("form").length&&a.keyCode===13)return na("submit",this,arguments)})}else return false},teardown:function(){c.event.remove(this,".specialSubmit")}};+if(!c.support.changeBubbles){var da=/textarea|input|select/i,ea,Fa=function(a){var b=a.type,d=a.value;if(b==="radio"||b==="checkbox")d=a.checked;else if(b==="select-multiple")d=a.selectedIndex>-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},fa=function(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Fa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",+e);if(!(f===w||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:fa,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return fa.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return fa.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,+"_change_data",Fa(a))}},setup:function(){if(this.type==="file")return false;for(var a in ea)c.event.add(this,a+".specialChange",ea[a]);return da.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return da.test(this.nodeName)}};ea=c.event.special.change.filters}s.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,f)}c.event.special[b]={setup:function(){this.addEventListener(a,+d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var j in d)this[b](j,f,d[j],e);return this}if(c.isFunction(f)){e=f;f=w}var i=b==="one"?c.proxy(e,function(k){c(this).unbind(k,i);return e.apply(this,arguments)}):e;if(d==="unload"&&b!=="one")this.one(d,f,e);else{j=0;for(var o=this.length;j<o;j++)c.event.add(this[j],d,i,f)}return this}});c.fn.extend({unbind:function(a,b){if(typeof a==="object"&&+!a.preventDefault)for(var d in a)this.unbind(d,a[d]);else{d=0;for(var f=this.length;d<f;d++)c.event.remove(this[d],a,b)}return this},delegate:function(a,b,d,f){return this.live(b,d,f,a)},undelegate:function(a,b,d){return arguments.length===0?this.unbind("live"):this.die(b,null,d,a)},trigger:function(a,b){return this.each(function(){c.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){a=c.Event(a);a.preventDefault();a.stopPropagation();c.event.trigger(a,b,this[0]);return a.result}},+toggle:function(a){for(var b=arguments,d=1;d<b.length;)c.proxy(a,b[d++]);return this.click(c.proxy(a,function(f){var e=(c.data(this,"lastToggle"+a.guid)||0)%d;c.data(this,"lastToggle"+a.guid,e+1);f.preventDefault();return b[e].apply(this,arguments)||false}))},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var Ga={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};c.each(["live","die"],function(a,b){c.fn[b]=function(d,f,e,j){var i,o=0,k,n,r=j||this.selector,+u=j?this:c(this.context);if(c.isFunction(f)){e=f;f=w}for(d=(d||"").split(" ");(i=d[o++])!=null;){j=O.exec(i);k="";if(j){k=j[0];i=i.replace(O,"")}if(i==="hover")d.push("mouseenter"+k,"mouseleave"+k);else{n=i;if(i==="focus"||i==="blur"){d.push(Ga[i]+k);i+=k}else i=(Ga[i]||i)+k;b==="live"?u.each(function(){c.event.add(this,pa(i,r),{data:f,selector:r,handler:e,origType:i,origHandler:e,preType:n})}):u.unbind(pa(i,r),e)}}return this}});c.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),+function(a,b){c.fn[b]=function(d){return d?this.bind(b,d):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});A.attachEvent&&!A.addEventListener&&A.attachEvent("onunload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}});(function(){function a(g){for(var h="",l,m=0;g[m];m++){l=g[m];if(l.nodeType===3||l.nodeType===4)h+=l.nodeValue;else if(l.nodeType!==8)h+=a(l.childNodes)}return h}function b(g,h,l,m,q,p){q=0;for(var v=m.length;q<v;q++){var t=m[q];+if(t){t=t[g];for(var y=false;t;){if(t.sizcache===l){y=m[t.sizset];break}if(t.nodeType===1&&!p){t.sizcache=l;t.sizset=q}if(t.nodeName.toLowerCase()===h){y=t;break}t=t[g]}m[q]=y}}}function d(g,h,l,m,q,p){q=0;for(var v=m.length;q<v;q++){var t=m[q];if(t){t=t[g];for(var y=false;t;){if(t.sizcache===l){y=m[t.sizset];break}if(t.nodeType===1){if(!p){t.sizcache=l;t.sizset=q}if(typeof h!=="string"){if(t===h){y=true;break}}else if(k.filter(h,[t]).length>0){y=t;break}}t=t[g]}m[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,+e=0,j=Object.prototype.toString,i=false,o=true;[0,0].sort(function(){o=false;return 0});var k=function(g,h,l,m){l=l||[];var q=h=h||s;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||typeof g!=="string")return l;for(var p=[],v,t,y,S,H=true,M=x(h),I=g;(f.exec(""),v=f.exec(I))!==null;){I=v[3];p.push(v[1]);if(v[2]){S=v[3];break}}if(p.length>1&&r.exec(g))if(p.length===2&&n.relative[p[0]])t=ga(p[0]+p[1],h);else for(t=n.relative[p[0]]?[h]:k(p.shift(),h);p.length;){g=p.shift();if(n.relative[g])g+=p.shift();+t=ga(g,t)}else{if(!m&&p.length>1&&h.nodeType===9&&!M&&n.match.ID.test(p[0])&&!n.match.ID.test(p[p.length-1])){v=k.find(p.shift(),h,M);h=v.expr?k.filter(v.expr,v.set)[0]:v.set[0]}if(h){v=m?{expr:p.pop(),set:z(m)}:k.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=v.expr?k.filter(v.expr,v.set):v.set;if(p.length>0)y=z(t);else H=false;for(;p.length;){var D=p.pop();v=D;if(n.relative[D])v=p.pop();else D="";if(v==null)v=h;n.relative[D](y,v,M)}}else y=[]}y||(y=t);y||k.error(D||+g);if(j.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))l.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&l.push(t[g]);else l.push.apply(l,y);else z(y,l);if(S){k(S,q,l,m);k.uniqueSort(l)}return l};k.uniqueSort=function(g){if(B){i=o;g.sort(B);if(i)for(var h=1;h<g.length;h++)g[h]===g[h-1]&&g.splice(h--,1)}return g};k.matches=function(g,h){return k(g,null,null,h)};k.find=function(g,h,l){var m,q;if(!g)return[];+for(var p=0,v=n.order.length;p<v;p++){var t=n.order[p];if(q=n.leftMatch[t].exec(g)){var y=q[1];q.splice(1,1);if(y.substr(y.length-1)!=="\\"){q[1]=(q[1]||"").replace(/\\/g,"");m=n.find[t](q,h,l);if(m!=null){g=g.replace(n.match[t],"");break}}}}m||(m=h.getElementsByTagName("*"));return{set:m,expr:g}};k.filter=function(g,h,l,m){for(var q=g,p=[],v=h,t,y,S=h&&h[0]&&x(h[0]);g&&h.length;){for(var H in n.filter)if((t=n.leftMatch[H].exec(g))!=null&&t[2]){var M=n.filter[H],I,D;D=t[1];y=false;t.splice(1,1);if(D.substr(D.length-+1)!=="\\"){if(v===p)p=[];if(n.preFilter[H])if(t=n.preFilter[H](t,v,l,p,m,S)){if(t===true)continue}else y=I=true;if(t)for(var U=0;(D=v[U])!=null;U++)if(D){I=M(D,t,U,v);var Ha=m^!!I;if(l&&I!=null)if(Ha)y=true;else v[U]=false;else if(Ha){p.push(D);y=true}}if(I!==w){l||(v=p);g=g.replace(n.match[H],"");if(!y)return[];break}}}if(g===q)if(y==null)k.error(g);else break;q=g}return v};k.error=function(g){throw"Syntax error, unrecognized expression: "+g;};var n=k.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,+CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(g){return g.getAttribute("href")}},+relative:{"+":function(g,h){var l=typeof h==="string",m=l&&!/\W/.test(h);l=l&&!m;if(m)h=h.toLowerCase();m=0;for(var q=g.length,p;m<q;m++)if(p=g[m]){for(;(p=p.previousSibling)&&p.nodeType!==1;);g[m]=l||p&&p.nodeName.toLowerCase()===h?p||false:p===h}l&&k.filter(h,g,true)},">":function(g,h){var l=typeof h==="string";if(l&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,q=g.length;m<q;m++){var p=g[m];if(p){l=p.parentNode;g[m]=l.nodeName.toLowerCase()===h?l:false}}}else{m=0;for(q=g.length;m<q;m++)if(p=g[m])g[m]=+l?p.parentNode:p.parentNode===h;l&&k.filter(h,g,true)}},"":function(g,h,l){var m=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("parentNode",h,m,g,p,l)},"~":function(g,h,l){var m=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("previousSibling",h,m,g,p,l)}},find:{ID:function(g,h,l){if(typeof h.getElementById!=="undefined"&&!l)return(g=h.getElementById(g[1]))?[g]:[]},NAME:function(g,h){if(typeof h.getElementsByName!=="undefined"){var l=[];+h=h.getElementsByName(g[1]);for(var m=0,q=h.length;m<q;m++)h[m].getAttribute("name")===g[1]&&l.push(h[m]);return l.length===0?null:l}},TAG:function(g,h){return h.getElementsByTagName(g[1])}},preFilter:{CLASS:function(g,h,l,m,q,p){g=" "+g[1].replace(/\\/g,"")+" ";if(p)return g;p=0;for(var v;(v=h[p])!=null;p++)if(v)if(q^(v.className&&(" "+v.className+" ").replace(/[\t\n]/g," ").indexOf(g)>=0))l||m.push(v);else if(l)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},+CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,l,m,q,p){h=g[1].replace(/\\/g,"");if(!p&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,l,m,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,h);else{g=k.filter(g[3],h,l,true^q);l||m.push.apply(m,+g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,l){return!!k(l[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},+text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},+setFilters:{first:function(g,h){return h===0},last:function(g,h,l,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,l){return h<l[3]-0},gt:function(g,h,l){return h>l[3]-0},nth:function(g,h,l){return l[3]-0===h},eq:function(g,h,l){return l[3]-0===h}},filter:{PSEUDO:function(g,h,l,m){var q=h[1],p=n.filters[q];if(p)return p(g,l,h,m);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h=+h[3];l=0;for(m=h.length;l<m;l++)if(h[l]===g)return false;return true}else k.error("Syntax error, unrecognized expression: "+q)},CHILD:function(g,h){var l=h[1],m=g;switch(l){case "only":case "first":for(;m=m.previousSibling;)if(m.nodeType===1)return false;if(l==="first")return true;m=g;case "last":for(;m=m.nextSibling;)if(m.nodeType===1)return false;return true;case "nth":l=h[2];var q=h[3];if(l===1&&q===0)return true;h=h[0];var p=g.parentNode;if(p&&(p.sizcache!==h||!g.nodeIndex)){var v=0;for(m=p.firstChild;m;m=+m.nextSibling)if(m.nodeType===1)m.nodeIndex=++v;p.sizcache=h}g=g.nodeIndex-q;return l===0?g===0:g%l===0&&g/l>=0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var l=h[1];g=n.attrHandle[l]?n.attrHandle[l](g):g[l]!=null?g[l]:g.getAttribute(l);l=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m===+"="?l===h:m==="*="?l.indexOf(h)>=0:m==="~="?(" "+l+" ").indexOf(h)>=0:!h?l&&g!==false:m==="!="?l!==h:m==="^="?l.indexOf(h)===0:m==="$="?l.substr(l.length-h.length)===h:m==="|="?l===h||l.substr(0,h.length+1)===h+"-":false},POS:function(g,h,l,m){var q=n.setFilters[h[2]];if(q)return q(g,l,h,m)}}},r=n.match.POS;for(var u in n.match){n.match[u]=new RegExp(n.match[u].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[u]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[u].source.replace(/\\(\d+)/g,function(g,+h){return"\\"+(h-0+1)}))}var z=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){z=function(g,h){h=h||[];if(j.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var l=0,m=g.length;l<m;l++)h.push(g[l]);else for(l=0;g[l];l++)h.push(g[l]);return h}}var B;if(s.documentElement.compareDocumentPosition)B=function(g,h){if(!g.compareDocumentPosition||+!h.compareDocumentPosition){if(g==h)i=true;return g.compareDocumentPosition?-1:1}g=g.compareDocumentPosition(h)&4?-1:g===h?0:1;if(g===0)i=true;return g};else if("sourceIndex"in s.documentElement)B=function(g,h){if(!g.sourceIndex||!h.sourceIndex){if(g==h)i=true;return g.sourceIndex?-1:1}g=g.sourceIndex-h.sourceIndex;if(g===0)i=true;return g};else if(s.createRange)B=function(g,h){if(!g.ownerDocument||!h.ownerDocument){if(g==h)i=true;return g.ownerDocument?-1:1}var l=g.ownerDocument.createRange(),m=+h.ownerDocument.createRange();l.setStart(g,0);l.setEnd(g,0);m.setStart(h,0);m.setEnd(h,0);g=l.compareBoundaryPoints(Range.START_TO_END,m);if(g===0)i=true;return g};(function(){var g=s.createElement("div"),h="script"+(new Date).getTime();g.innerHTML="<a name='"+h+"'/>";var l=s.documentElement;l.insertBefore(g,l.firstChild);if(s.getElementById(h)){n.find.ID=function(m,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(m[1]))?q.id===m[1]||typeof q.getAttributeNode!=="undefined"&&+q.getAttributeNode("id").nodeValue===m[1]?[q]:w:[]};n.filter.ID=function(m,q){var p=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&p&&p.nodeValue===q}}l.removeChild(g);l=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,l){l=l.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;l[m];m++)l[m].nodeType===1&&h.push(l[m]);l=h}return l};g.innerHTML="<a href='#'></a>";+if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=k,h=s.createElement("div");h.innerHTML="<p class='TEST'></p>";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){k=function(m,q,p,v){q=q||s;if(!v&&q.nodeType===9&&!x(q))try{return z(q.querySelectorAll(m),p)}catch(t){}return g(m,q,p,v)};for(var l in g)k[l]=g[l];h=null}}();+(function(){var g=s.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}:+function(g,h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ga=function(g,h){var l=[],m="",q;for(h=h.nodeType?[h]:h;q=n.match.PSEUDO.exec(g);){m+=q[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;q=0;for(var p=h.length;q<p;q++)k(g,h[q],l);return k.filter(m,l)};c.find=k;c.expr=k.selectors;c.expr[":"]=c.expr.filters;c.unique=k.uniqueSort;c.text=a;c.isXMLDoc=x;c.contains=E})();var eb=/Until$/,fb=/^(?:parents|prevUntil|prevAll)/,+gb=/,/;R=Array.prototype.slice;var Ia=function(a,b,d){if(c.isFunction(b))return c.grep(a,function(e,j){return!!b.call(e,j,e)===d});else if(b.nodeType)return c.grep(a,function(e){return e===b===d});else if(typeof b==="string"){var f=c.grep(a,function(e){return e.nodeType===1});if(Ua.test(b))return c.filter(b,f,!d);else b=c.filter(b,f)}return c.grep(a,function(e){return c.inArray(e,b)>=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f<e;f++){d=b.length;+c.find(a,this[f],b);if(f>0)for(var j=d;j<b.length;j++)for(var i=0;i<d;i++)if(b[i]===b[j]){b.splice(j--,1);break}}return b},has:function(a){var b=c(a);return this.filter(function(){for(var d=0,f=b.length;d<f;d++)if(c.contains(this,b[d]))return true})},not:function(a){return this.pushStack(Ia(this,a,false),"not",a)},filter:function(a){return this.pushStack(Ia(this,a,true),"filter",a)},is:function(a){return!!a&&c.filter(a,this).length>0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,j=+{},i;if(f&&a.length){e=0;for(var o=a.length;e<o;e++){i=a[e];j[i]||(j[i]=c.expr.match.POS.test(i)?c(i,b||this.context):i)}for(;f&&f.ownerDocument&&f!==b;){for(i in j){e=j[i];if(e.jquery?e.index(f)>-1:c(f).is(e)){d.push({selector:i,elem:f});delete j[i]}}f=f.parentNode}}return d}var k=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,r){for(;r&&r.ownerDocument&&r!==b;){if(k?k.index(r)>-1:c(r).is(a))return r;r=r.parentNode}return null})},index:function(a){if(!a||typeof a===+"string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(qa(a[0])||qa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",+d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?+a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);eb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||gb.test(f))&&fb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||a.nodeType!==1||!c(a).is(d));){a.nodeType===+1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ja=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ka=/(<([\w:]+)[^>]*?)\/>/g,hb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,La=/<([\w:]+)/,ib=/<tbody/i,jb=/<|&#?\w+;/,ta=/<script|<object|<embed|<option|<style/i,ua=/checked\s*(?:[^=]|=\s*.checked.)/i,Ma=function(a,b,d){return hb.test(d)?+a:b+"></"+d+">"},F={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div<div>","</div>"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=+c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},+wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},+prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,+this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,f;(f=this[d])!=null;d++)if(!a||c.filter(a,[f]).length){if(!b&&f.nodeType===1){c.cleanData(f.getElementsByTagName("*"));c.cleanData([f])}f.parentNode&&f.parentNode.removeChild(f)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild);+return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ja,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ra(this,b);ra(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Ja,+""):null;else if(typeof a==="string"&&!ta.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(La.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ka,Ma);try{for(var b=0,d=this.length;b<d;b++)if(this[b].nodeType===1){c.cleanData(this[b].getElementsByTagName("*"));this[b].innerHTML=a}}catch(f){this.empty().append(a)}}else c.isFunction(a)?this.each(function(e){var j=c(this),i=j.html();j.empty().append(function(){return a.call(this,e,i)})}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&+this[0].parentNode){if(c.isFunction(a))return this.each(function(b){var d=c(this),f=d.html();d.replaceWith(a.call(this,b,f))});if(typeof a!=="string")a=c(a).detach();return this.each(function(){var b=this.nextSibling,d=this.parentNode;c(this).remove();b?c(b).before(a):c(d).append(a)})}else return this.pushStack(c(c.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,true)},domManip:function(a,b,d){function f(u){return c.nodeName(u,"table")?u.getElementsByTagName("tbody")[0]||+u.appendChild(u.ownerDocument.createElement("tbody")):u}var e,j,i=a[0],o=[],k;if(!c.support.checkClone&&arguments.length===3&&typeof i==="string"&&ua.test(i))return this.each(function(){c(this).domManip(a,b,d,true)});if(c.isFunction(i))return this.each(function(u){var z=c(this);a[0]=i.call(this,u,b?z.html():w);z.domManip(a,b,d)});if(this[0]){e=i&&i.parentNode;e=c.support.parentNode&&e&&e.nodeType===11&&e.childNodes.length===this.length?{fragment:e}:sa(a,this,o);k=e.fragment;if(j=k.childNodes.length===+1?(k=k.firstChild):k.firstChild){b=b&&c.nodeName(j,"tr");for(var n=0,r=this.length;n<r;n++)d.call(b?f(this[n],j):this[n],n>0||e.cacheable||this.length>1?k.cloneNode(true):k)}o.length&&c.each(o,Qa)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);var e=this.length===1&&this[0].parentNode;if(e&&e.nodeType===11&&e.childNodes.length===1&&d.length===1){d[b](this[0]);+return this}else{e=0;for(var j=d.length;e<j;e++){var i=(e>0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),i);f=f.concat(i)}return this.pushStack(f,a,d.selector)}}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;for(var e=[],j=0,i;(i=a[j])!=null;j++){if(typeof i==="number")i+="";if(i){if(typeof i==="string"&&!jb.test(i))i=b.createTextNode(i);else if(typeof i==="string"){i=i.replace(Ka,Ma);var o=(La.exec(i)||["",+""])[1].toLowerCase(),k=F[o]||F._default,n=k[0],r=b.createElement("div");for(r.innerHTML=k[1]+i+k[2];n--;)r=r.lastChild;if(!c.support.tbody){n=ib.test(i);o=o==="table"&&!n?r.firstChild&&r.firstChild.childNodes:k[1]==="<table>"&&!n?r.childNodes:[];for(k=o.length-1;k>=0;--k)c.nodeName(o[k],"tbody")&&!o[k].childNodes.length&&o[k].parentNode.removeChild(o[k])}!c.support.leadingWhitespace&&V.test(i)&&r.insertBefore(b.createTextNode(V.exec(i)[0]),r.firstChild);i=r.childNodes}if(i.nodeType)e.push(i);else e=+c.merge(e,i)}}if(d)for(j=0;e[j];j++)if(f&&c.nodeName(e[j],"script")&&(!e[j].type||e[j].type.toLowerCase()==="text/javascript"))f.push(e[j].parentNode?e[j].parentNode.removeChild(e[j]):e[j]);else{e[j].nodeType===1&&e.splice.apply(e,[j+1,0].concat(c.makeArray(e[j].getElementsByTagName("script"))));d.appendChild(e[j])}return e},cleanData:function(a){for(var b,d,f=c.cache,e=c.event.special,j=c.support.deleteExpando,i=0,o;(o=a[i])!=null;i++)if(d=o[c.expando]){b=f[d];if(b.events)for(var k in b.events)e[k]?+c.event.remove(o,k):Ca(o,k,b.handle);if(j)delete o[c.expando];else o.removeAttribute&&o.removeAttribute(c.expando);delete f[d]}}});var kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,Na=/alpha\([^)]*\)/,Oa=/opacity=([^)]*)/,ha=/float/i,ia=/-([a-z])/ig,lb=/([A-Z])/g,mb=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob={position:"absolute",visibility:"hidden",display:"block"},pb=["Left","Right"],qb=["Top","Bottom"],rb=s.defaultView&&s.defaultView.getComputedStyle,Pa=c.support.cssFloat?"cssFloat":"styleFloat",ja=+function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!kb.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter=+Na.test(a)?a.replace(Na,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Oa.exec(f.filter)[1])/100+"":""}if(ha.test(b))b=Pa;b=b.replace(ia,ja);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,j=b==="width"?pb:qb;function i(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(j,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a,+"border"+this+"Width",true))||0})}a.offsetWidth!==0?i():c.swap(a,ob,i);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Oa.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ha.test(b))b=Pa;if(!d&&e&&e[b])f=e[b];else if(rb){if(ha.test(b))b="float";b=b.replace(lb,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f=+a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ia,ja);f=a.currentStyle[b]||a.currentStyle[d];if(!mb.test(f)&&nb.test(f)){b=e.left;var j=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=j}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=+a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var sb=J(),tb=/<script(.|\s)*?\/script>/gi,ub=/select|textarea/i,vb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,N=/=\?(&|$)/,ka=/\?/,wb=/(\?|&)_=.*?(&|$)/,xb=/^(\w+:)?\/\/([^\/?#]+)/,yb=/%20/g,zb=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!==+"string")return zb.call(this,a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);f="POST"}var j=this;c.ajax({url:a,type:f,dataType:"html",data:b,complete:function(i,o){if(o==="success"||o==="notmodified")j.html(e?c("<div />").append(i.responseText.replace(tb,"")).find(e):i.responseText);d&&j.each(d,[i.responseText,o,i])}});return this},+serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||ub.test(this.nodeName)||vb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),+function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,+global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:A.XMLHttpRequest&&(A.location.protocol!=="file:"||!A.ActiveXObject)?function(){return new A.XMLHttpRequest}:function(){try{return new A.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&&+e.success.call(k,o,i,x);e.global&&f("ajaxSuccess",[x,e])}function d(){e.complete&&e.complete.call(k,x,i);e.global&&f("ajaxComplete",[x,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}function f(q,p){(e.context?c(e.context):c.event).trigger(q,p)}var e=c.extend(true,{},c.ajaxSettings,a),j,i,o,k=a&&a.context||e,n=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,e.traditional);if(e.dataType==="jsonp"){if(n==="GET")N.test(e.url)||(e.url+=(ka.test(e.url)?+"&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!N.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&N.test(e.data)||N.test(e.url))){j=e.jsonpCallback||"jsonp"+sb++;if(e.data)e.data=(e.data+"").replace(N,"="+j+"$1");e.url=e.url.replace(N,"="+j+"$1");e.dataType="script";A[j]=A[j]||function(q){o=q;b();d();A[j]=w;try{delete A[j]}catch(p){}z&&z.removeChild(C)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache===+false&&n==="GET"){var r=J(),u=e.url.replace(wb,"$1_="+r+"$2");e.url=u+(u===e.url?(ka.test(e.url)?"&":"?")+"_="+r:"")}if(e.data&&n==="GET")e.url+=(ka.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");r=(r=xb.exec(e.url))&&(r[1]&&r[1]!==location.protocol||r[2]!==location.host);if(e.dataType==="script"&&n==="GET"&&r){var z=s.getElementsByTagName("head")[0]||s.documentElement,C=s.createElement("script");C.src=e.url;if(e.scriptCharset)C.charset=e.scriptCharset;if(!j){var B=+false;C.onload=C.onreadystatechange=function(){if(!B&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){B=true;b();d();C.onload=C.onreadystatechange=null;z&&C.parentNode&&z.removeChild(C)}}}z.insertBefore(C,z.firstChild);return w}var E=false,x=e.xhr();if(x){e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async);try{if(e.data||a&&a.contentType)x.setRequestHeader("Content-Type",e.contentType);if(e.ifModified){c.lastModified[e.url]&&x.setRequestHeader("If-Modified-Since",+c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}r||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(ga){}if(e.beforeSend&&e.beforeSend.call(k,x,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");x.abort();return false}e.global&&f("ajaxSend",[x,e]);var g=x.onreadystatechange=function(q){if(!x||x.readyState===0||q==="abort"){E||+d();E=true;if(x)x.onreadystatechange=c.noop}else if(!E&&x&&(x.readyState===4||q==="timeout")){E=true;x.onreadystatechange=c.noop;i=q==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";var p;if(i==="success")try{o=c.httpData(x,e.dataType,e)}catch(v){i="parsererror";p=v}if(i==="success"||i==="notmodified")j||b();else c.handleError(e,x,i,p);d();q==="timeout"&&x.abort();if(e.async)x=null}};try{var h=x.abort;x.abort=function(){x&&h.call(x);+g("abort")}}catch(l){}e.async&&e.timeout>0&&setTimeout(function(){x&&!E&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||a,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===+1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;e&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b===+"json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(i,o){if(c.isArray(o))c.each(o,function(k,n){b||/\[\]$/.test(i)?f(i,n):d(i+"["+(typeof n==="object"||c.isArray(n)?k:"")+"]",n)});else!b&&o!=null&&typeof o==="object"?c.each(o,function(k,n){d(i+"["+k+"]",n)}):f(i,o)}function f(i,o){o=c.isFunction(o)?o():o;e[e.length]=encodeURIComponent(i)+"="+encodeURIComponent(o)}var e=[];if(b===w)b=c.ajaxSettings.traditional;+if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var j in a)d(j,a[j]);return e.join("&").replace(yb,"+")}});var la={},Ab=/toggle|show|hide/,Bb=/^([+-]=)?([\d+-.]+)(.*)$/,W,va=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a||a===0)return this.animate(K("show",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");+this[a].style.display=d||"";if(c.css(this[a],"display")==="none"){d=this[a].nodeName;var f;if(la[d])f=la[d];else{var e=c("<"+d+" />").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();la[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a<b;a++)this[a].style.display=c.data(this[a],"olddisplay")||"";return this}},hide:function(a,b){if(a||a===0)return this.animate(K("hide",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");!d&&d!=="none"&&c.data(this[a],+"olddisplay",c.css(this[a],"display"))}a=0;for(b=this.length;a<b;a++)this[a].style.display="none";return this}},_toggle:c.fn.toggle,toggle:function(a,b){var d=typeof a==="boolean";if(c.isFunction(a)&&c.isFunction(b))this._toggle.apply(this,arguments);else a==null||d?this.each(function(){var f=d?a:c(this).is(":hidden");c(this)[f?"show":"hide"]()}):this.animate(K("toggle",3),a,b);return this},fadeTo:function(a,b,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,d)},+animate:function(a,b,d,f){var e=c.speed(b,d,f);if(c.isEmptyObject(a))return this.each(e.complete);return this[e.queue===false?"each":"queue"](function(){var j=c.extend({},e),i,o=this.nodeType===1&&c(this).is(":hidden"),k=this;for(i in a){var n=i.replace(ia,ja);if(i!==n){a[n]=a[i];delete a[i];i=n}if(a[i]==="hide"&&o||a[i]==="show"&&!o)return j.complete.call(this);if((i==="height"||i==="width")&&this.style){j.display=c.css(this,"display");j.overflow=this.style.overflow}if(c.isArray(a[i])){(j.specialEasing=+j.specialEasing||{})[i]=a[i][1];a[i]=a[i][0]}}if(j.overflow!=null)this.style.overflow="hidden";j.curAnim=c.extend({},a);c.each(a,function(r,u){var z=new c.fx(k,j,r);if(Ab.test(u))z[u==="toggle"?o?"show":"hide":u](a);else{var C=Bb.exec(u),B=z.cur(true)||0;if(C){u=parseFloat(C[2]);var E=C[3]||"px";if(E!=="px"){k.style[r]=(u||1)+E;B=(u||1)/z.cur(true)*B;k.style[r]=B+E}if(C[1])u=(C[1]==="-="?-1:1)*u+B;z.custom(B,u,E)}else z.custom(B,u,"")}});return true})},stop:function(a,b){var d=c.timers;a&&this.queue([]);+this.each(function(){for(var f=d.length-1;f>=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:K("show",1),slideUp:K("hide",1),slideToggle:K("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration===+"number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||+c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(j){return e.step(j)}this.startTime=J();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;+this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!W)W=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=J(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=+this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem,+e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b<a.length;b++)a[b]()||a.splice(b--,1);a.length||+c.fx.stop()},stop:function(){clearInterval(W);W=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){c.style(a.elem,"opacity",a.now)},_default:function(a){if(a.elem.style&&a.elem.style[a.prop]!=null)a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit;else a.elem[a.prop]=a.now}}});if(c.expr&&c.expr.filters)c.expr.filters.animated=function(a){return c.grep(c.timers,function(b){return a===b.elem}).length};c.fn.offset="getBoundingClientRect"in s.documentElement?+function(a){var b=this[0];if(a)return this.each(function(e){c.offset.setOffset(this,a,e)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);var d=b.getBoundingClientRect(),f=b.ownerDocument;b=f.body;f=f.documentElement;return{top:d.top+(self.pageYOffset||c.support.boxModel&&f.scrollTop||b.scrollTop)-(f.clientTop||b.clientTop||0),left:d.left+(self.pageXOffset||c.support.boxModel&&f.scrollLeft||b.scrollLeft)-(f.clientLeft||b.clientLeft||0)}}:function(a){var b=+this[0];if(a)return this.each(function(r){c.offset.setOffset(this,a,r)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);c.offset.initialize();var d=b.offsetParent,f=b,e=b.ownerDocument,j,i=e.documentElement,o=e.body;f=(e=e.defaultView)?e.getComputedStyle(b,null):b.currentStyle;for(var k=b.offsetTop,n=b.offsetLeft;(b=b.parentNode)&&b!==o&&b!==i;){if(c.offset.supportsFixedPosition&&f.position==="fixed")break;j=e?e.getComputedStyle(b,null):b.currentStyle;+k-=b.scrollTop;n-=b.scrollLeft;if(b===d){k+=b.offsetTop;n+=b.offsetLeft;if(c.offset.doesNotAddBorder&&!(c.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(b.nodeName))){k+=parseFloat(j.borderTopWidth)||0;n+=parseFloat(j.borderLeftWidth)||0}f=d;d=b.offsetParent}if(c.offset.subtractsBorderForOverflowNotVisible&&j.overflow!=="visible"){k+=parseFloat(j.borderTopWidth)||0;n+=parseFloat(j.borderLeftWidth)||0}f=j}if(f.position==="relative"||f.position==="static"){k+=o.offsetTop;n+=o.offsetLeft}if(c.offset.supportsFixedPosition&&+f.position==="fixed"){k+=Math.max(i.scrollTop,o.scrollTop);n+=Math.max(i.scrollLeft,o.scrollLeft)}return{top:k,left:n}};c.offset={initialize:function(){var a=s.body,b=s.createElement("div"),d,f,e,j=parseFloat(c.curCSS(a,"marginTop",true))||0;c.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"});b.innerHTML="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";+a.insertBefore(b,a.firstChild);d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==j;a.removeChild(b);+c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),j=parseInt(c.curCSS(a,"top",true),10)||0,i=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a,+d,e);d={top:b.top-e.top+j,left:b.left-e.left+i};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top-+f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||s.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],j;if(!e)return null;if(f!==w)return this.each(function(){if(j=wa(this))j.scrollTo(!a?f:c(j).scrollLeft(),a?f:c(j).scrollTop());else this[d]=f});else return(j=wa(e))?"pageXOffset"in j?j[a?"pageYOffset":+"pageXOffset"]:c.support.boxModel&&j.document.documentElement[d]||j.document.body[d]:e[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;if(c.isFunction(f))return this.each(function(j){var i=c(this);i[d](f.call(this,j,i[d]()))});return"scrollTo"in+e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===w?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});A.jQuery=A.$=c})(window);
+ .hledger/web/jquery.url.js view
@@ -0,0 +1,1 @@+jQuery.url=function(){var segments={};var parsed={};var options={url:window.location,strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};var parseUri=function(){str=decodeURI(options.url);var m=options.parser[options.strictMode?"strict":"loose"].exec(str);var uri={};var i=14;while(i--){uri[options.key[i]]=m[i]||""}uri[options.q.name]={};uri[options.key[12]].replace(options.q.parser,function($0,$1,$2){if($1){uri[options.q.name][$1]=$2}});return uri};var key=function(key){if(!parsed.length){setUp()}if(key=="base"){if(parsed.port!==null&&parsed.port!==""){return parsed.protocol+"://"+parsed.host+":"+parsed.port+"/"}else{return parsed.protocol+"://"+parsed.host+"/"}}return(parsed[key]==="")?null:parsed[key]};var param=function(item){if(!parsed.length){setUp()}return(parsed.queryKey[item]===null)?null:parsed.queryKey[item]};var setUp=function(){parsed=parseUri();getSegments()};var getSegments=function(){var p=parsed.path;segments=[];segments=parsed.path.length==1?{}:(p.charAt(p.length-1)=="/"?p.substring(1,p.length-1):path=p.substring(1)).split("/")};return{setMode:function(mode){strictMode=mode=="strict"?true:false;return this},setUrl:function(newUri){options.url=newUri===undefined?window.location:newUri;setUp();return this},segment:function(pos){if(!parsed.length){setUp()}if(pos===undefined){return segments.length}return(segments[pos]===""||segments[pos]===undefined)?null:segments[pos]},attr:key,param:param}}();
+ .hledger/web/style.css view
@@ -0,0 +1,258 @@+/* hledger web ui styles */++/*------------------------------------------------------------------------------------------*/+/* 1. colours */++/* green */+body                                                                 { background-color:#efe; }+.registerreport .odd                                                 { background-color:#ded; }+.filtering                                                           { background-color:#ded; }+/* #main                                                                { border-color:#ded; } see below */+/* .journalreport td                                                    { border-color:thin solid #ded; } see below */++/* white */+/* body                                                                 { background-color:#fff; } */+/* .registerreport .odd                                                 { background-color:#eee; } */+/* .filtering                                                           { background-color:#ddd; } */+/* #main                                                                { border-color:#eee; } see below */+/* .journalreport td                                                    { border-color:thin solid #eee; } see below */++.negative                                                            { color:#800; }+#messages                                                            { color:red; background-color:#fee; }+#addform input.textinput, #addform .dhx_combo_input, .dhx_combo_list { background-color:#eee; }+#editform textarea                                                   { background-color:#eee; }++/*------------------------------------------------------------------------------------------*/+/* 2. font families & sizes */+/* overspecified for cross-browser robustness */+body                                               { font-family:helvetica,arial,"sans serif"; }+pre                                                { font-family:courier,"courier new",monospace; }+input.textinput, .dhx_combo_input, .dhx_combo_list { font-size:small; }+#editform textarea                                 { font-family:courier,"courier new",monospace; font-size:small; }+.nav2                                              { font-size:small; }+#filterform                                        { font-size:small; }+.topleftlink                                       { font-size:small; }+.toprightlink                                      { font-size:small; }+#journaldesc                                       { font-size:small; }+.help                                              { font-size:smaller; }+.form                                              { font-size:small; }+.journalreport                                     { font-size:small; }+.balancereport                                     { font-size:small; }+.registerreport                                    { font-size:small; }+#showmoreaccounts                                  { font-size:small; }+/* #addformlink                                    { font-size:small; } */+/* #editformlink                                   { font-size:small; } */++/*------------------------------------------------------------------------------------------*/+/* 3. layout */++body                        { margin:0; }++#navbar                     { padding:2px; }+.topleftlink                { float:left; margin-right:1em; padding:2px; }+.toprightlink               { float:right; margin-left:1em; padding:2px; }+#navbar h1                  { display:inline-block; vertical-align:top; margin:0; }+#journalinfo                { vertical-align:middle; margin:0; }+/* #navbar                  { padding:4px; border-bottom:2px solid #ddd; } */++#messages                   { margin:0.5em;}+.help                       { font-style: italic; }+.helprow td                 { padding-bottom:8px; }++#content                    { padding:4px; }++#sidebar { float:left; padding-right:1em; margin-bottom:5em; }++#main { overflow:auto; border-left:thin solid #ded; padding-left:1em; }++#navlinks                   { margin-bottom:1em; }+.navlink                    { }+.navlinkcurrent             { font-weight:bold; }+.form                       { margin:0em; }++#filterformdiv              { margin:0 0 1em 0; white-space:nowrap; }+#filterform                 { margin:0; }+#filterform span            { padding:4px; }+#stopfilterlink             { font-weight:bold; }+.filtering                  { font-weight:bold; }++#main .journal { }+#main .register { }+/* .current                    { font-weight:bold; } */+.description                { padding-left:1em; white-space:normal; }+.account                    { white-space:normal; padding-left:1em; }+.amount                     { white-space:nowrap; padding-left:1em; }+.balance                    { white-space:nowrap; padding-left:1em; }+.account, .amount, .balance { width:2em; }  /* minimum width */+.positive                   { }++table.journalreport         { border-spacing: 0; }+.journalreport td           { border-top:thin solid #ded; }+.journalreport pre          { margin-top:0; }++.balancereport              { border-spacing:0; }+.balancereport tr           { vertical-align:bottom; border-spacing:0; }+.balancereport .title       { white-space:nowrap; }+.balancereport .item        { }+.balancereport td           { padding:0; }+.totalrule td               { border-top:thin solid black; }++table.registerreport        { border-spacing:0; }+.registerreport tr          { vertical-align:top; }+.registerreport td          { padding-bottom:0.2em; }+.registerreport .date       { white-space:nowrap; }+.firstposting td            { }+#accountsheading            { font-weight:bold; white-space:nowrap; margin-bottom:1em; }+#showmoreaccounts           { }+++#addform input.textinput, #addform .dhx_combo_input, .dhx_combo_list   { padding:4px; }+#addform table              { }+#addform #addbuttonrow      { text-align:right; }+/* #editform                   { width:95%; } */+#editform textarea          { width:100%; padding:4px; }+#filterform table           { border-spacing:0; padding-left:0em; }+++/*------------------------------------------------------------------------------------------*/+/* 4. dhtmlx.com auto-completing combo box styles */++.dhx_combo_input{+/* color:#333333; */+/* font-family: Arial; */+/* font-size: 9pt; */+/* border:0px; */+/* padding:2px 2px 2px 2px; */+/* position:absolute; */+/* top:0px; */+}++/* table {border:thin solid red} */+/* div {border:thin solid yellow} */++.dhx_combo_box{+    position:relative;+    display:inline-block;+    /* text-align:left; */+    /* height:20px; */+    /* _height:22px; */+    /* overflow:hidden; */+    /* background-color: white; */+}++.dhx_combo_list{+    position:absolute;+    z-index:230;+    overflow-y:auto;+    overflow-x:hidden;+    white-space:nowrap;+    border:1px solid black;+    height:50%;+    /* background-color: white; */+}++.dhx_combo_list div{+    cursor:default;+    padding:2px 2px 2px 2px;+}++.dhx_selected_option{+    background-color:navy;+    color:white;+}++.dhx_combo_img{+    /* display:none; */+    width:18px;+    height:20px;+    position:absolute;+    top:12px;+    right:-10px;+}++.dhx_combo_option_img{+	position:relative;+	top:1px;+	margin:0px;+	margin-left:2px;+	left:0px;+	width:18px; height:18px;+}++/* .combo_dhx_sel{ */+/* .dhx_selected_option{ */+/*    background-image: url("../static/images/bg_selection.gif") !important; */+/*    background-position: bottom; */+/*    background-repeat: repeat-x; */+/*    color:black; */+/* } */++++/* .dhx_combo_img_rtl{ */+/* 	position:absolute; */+/* 	top:0px; */+/* 	left:1px; */+/* 	width:17px; */+/* 	height:20px; */+/* } */+/* .dhx_combo_option_img_rtl{ */+/* 	float:right; */+/* 	margin-right :0px; */+/* 	width:18px; height:18px; */+/* } */++/* .dhx_combo_list_rtl{ */+/* 	direction: rtl; */+/* 	unicode-bidi : bidi-override; */+/*    position:absolute; */+/*    z-index:230; */+/*    overflow-y:auto; */+/*    overflow-x:hidden; */+/*    border:1px solid black; */+/*    height:100px; */+/*    /\* font-family: Arial; *\/ */+/*    font-size: 9pt; */+/*    background-color: white; */+/* } */+/* .dhx_combo_list_rtl div{ */+/* 	direction: rtl; */+/* 	unicode-bidi : bidi-override; */+/* 	padding:2px 2px 2px 2px; */+/* } */+/* .dhx_combo_list_rtl div div{ */+/* 	float :right !important; */+/* 	cursor:default; */+/* } */+/* .dhx_combo_list_rtl div img{ */+/* 	float :right !important; */+/* } */+/* .dhx_combo_list_rtl div input{ */+/* 	float :right !important; */+/* } */++/* .dhx_combo_box.dhx_skyblue{ */+/* 	border:1px solid #a4bed4; */+/* } */+/* .dhx_combo_box.dhx_skyblue .dhx_combo_input { */+/* 	font-family:Tahoma; */+/* 	font-size: 11px; */+/* 	padding:3px; */+/* } */+/* .dhx_combo_list.dhx_skyblue_list{ */+/* 	background-color: #eaf2fb; */+/* 	border:1px solid #a4bed4; */+/* 	font-family:Tahoma; */+/* 	font-size: 11px; */+/* } */+/* .dhx_combo_list.dhx_skyblue_list div{ */+/* 	cursor:default; */+/* 	padding:3px 4px; */+/* } */+/* .dhx_combo_list_rtl.dhx_skyblue_list{ */+/*    background-color: #eaf2fb; */+/* 	border:1px solid #a4bed4; */+/* 	font-family:Tahoma; */+/* 	font-size: 11px; */+/* } */+
+ Hledger/Web/App.hs view
@@ -0,0 +1,1087 @@+{-# LANGUAGE CPP, QuasiQuotes, TemplateHaskell, TypeFamilies, GeneralizedNewtypeDeriving #-}+{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses, FlexibleContexts #-}+{-| +The web app providing a richer interface to hledger's data.+-}+-- with authentication, registration and persistent storage of user accounts (not yet)+module Hledger.Web.App+    ( App (..)+    , withApp+    )+where+import Control.Applicative ((<$>), (<*>))+-- import Control.Failure+-- import qualified Data.ByteString.Lazy as L+import Data.Either+-- import System.Directory+import System.FilePath ((</>), takeFileName)+import System.IO.Storage (putValue, getValue)+import Text.ParserCombinators.Parsec hiding (string)++-- import Database.Persist.GenericSql (ConnectionPool, SqlPersist, runMigration, migrate)+import Yesod+import Yesod.Helpers.Static+-- import Yesod.Helpers.Auth+-- import Yesod.Mail+-- import Yesod.WebRoutes+-- import Text.Hamlet (defaultHamletSettings)+-- import Text.Hamlet.RT++import Hledger.Cli.Add (appendToJournalFile)+import Hledger.Cli.Balance+import Hledger.Cli.Print+import Hledger.Cli.Register+import Hledger.Cli.Options hiding (value)+import Hledger.Cli.Utils+import Hledger.Cli.Version (version)+import Hledger.Data hiding (insert, today)+import Hledger.Read (journalFromPathAndString)+import Hledger.Read.JournalReader (someamount)+import Hledger.Web.Settings (+    --   withConnectionPool+    -- , runConnectionPool+    -- , staticroot+      datadir+    -- , hamletFile+    -- , cassiusFile+    -- , juliusFile+    , hledgerorgurl+    , manualurl+    , style_css+    , hledger_js+    , jquery_js+    , jquery_url_js+    , dhtmlxcommon_js+    , dhtmlxcombo_js+    , robots_txt+    )+++----------------------------------------------------------------------+-- define the web app+----------------------------------------------------------------------++-- persistent data schema for the web app. User account info is stored here,+-- hledger's main data is stored in the usual places (journal files etc.)+-- persist (quasi-quoter from persistent) defines a list of data entities.+-- mkPersist (template haskell from persistent) defines persistence-capable data types based on these.+-- mkPersist [$persist|+-- User+--     ident String+--     password String null update+--     UniqueUser ident+-- Email+--     email String+--     user UserId null update+--     verkey String null update+--     UniqueEmail email+-- |]++-- run-time data kept by the web app.+data App = App+    { -- appConnPool :: Maybe ConnectionPool+     appRoot    :: String+    ,appDataDir :: FilePath+    ,appOpts    :: [Opt]+    ,appArgs    :: [String]+    ,appJournal :: Journal+    ,appStatic  :: Static+    }++-- parseRoutes (quasi-quoter from web-routes) defines a list of route patterns for the web app.+-- mkYesod (template haskell from yesod) defines types for the web app based on the routes.+-- /auth            AuthR             Auth getAuth+mkYesod "App" [$parseRoutes|+/                IndexR            GET+/favicon.ico     FaviconR          GET+/robots.txt      RobotsR           GET+/static          StaticR           Static appStatic+/journalonly     JournalOnlyR      GET POST+/registeronly    RegisterOnlyR     GET+/accounts        AccountsOnlyR     GET+/journal         JournalR          GET POST+/register        RegisterR         GET POST+|]+-- /addformrt       AddformRTR        GET++type Handler = GHandler App App++instance Yesod App where+    approot = appRoot++    -- defaultLayout widget = do+    --     mmsg <- getMessage+    --     pc <- widgetToPageContent $ do+    --         widget+    --         addCassius $(cassiusFile "default-layout")+    --     hamletToRepHtml $(hamletFile "default-layout")++    -- authRoute _ = Just $ AuthR LoginR++    -- static file-serving optimisations, disable for the moment+    -- urlRenderOverride a (StaticR s) =+    --     Just $ uncurry (joinPath a staticroot) $ format s+    --   where+    --     format = formatPathSegments ss+    --     ss :: Site StaticRoute (String -> Maybe (GHandler Static App ChooseRep))+    --     ss = getSubSite+    urlRenderOverride _ _ = Nothing+    -- addStaticContent ext' _ content = do+    --     let fn = base64md5 content ++ '.' : ext'+    --     let statictmp = datadir ++ "/tmp/"+    --     liftIO $ createDirectoryIfMissing True statictmp+    --     liftIO $ L.writeFile (statictmp ++ fn) content+    --     return $ Just $ Right (StaticR $ StaticRoute ["tmp", fn] [], [])++-- instance YesodPersist App where+--     type YesodDB App = SqlPersist+--     runDB db = do+--       y <- getYesod+--       let p = appConnPool y+--       case p of Just p' -> runConnectionPool db p'+--                 Nothing -> error "no connection pool, programmer error" -- XXX++-- instance YesodAuth App where+--     type AuthEntity App = User+--     type AuthEmailEntity App = Email++--     defaultDest _ = IndexR++--     getAuthId creds _extra = runDB $ do+--         x <- getBy $ UniqueUser $ credsIdent creds+--         case x of+--             Just (uid, _) -> return $ Just uid+--             Nothing -> do+--                 fmap Just $ insert $ User (credsIdent creds) Nothing++--     openIdEnabled _ = True++--     emailSettings _ = Just EmailSettings {+--           addUnverified = \email verkey -> runDB $ insert $ Email email Nothing (Just verkey)+--         , sendVerifyEmail = sendVerifyEmail'+--         , getVerifyKey = runDB . fmap (join . fmap emailVerkey) . get+--         , setVerifyKey = \eid key -> runDB $ update eid [EmailVerkey $ Just key]+--         , verifyAccount = \eid -> runDB $ do+--             me <- get eid+--             case me of+--                 Nothing -> return Nothing+--                 Just e -> do+--                     let email = emailEmail e+--                     case emailUser e of+--                         Just uid -> return $ Just uid+--                         Nothing -> do+--                             uid <- insert $ User email Nothing+--                             update eid [EmailUser $ Just uid]+--                             return $ Just uid+--         , getPassword = runDB . fmap (join . fmap userPassword) . get+--         , setPassword = \uid pass -> runDB $ update uid [UserPassword $ Just pass]+--         , getEmailCreds = \email -> runDB $ do+--             me <- getBy $ UniqueEmail email+--             case me of+--                 Nothing -> return Nothing+--                 Just (eid, e) -> return $ Just EmailCreds+--                     { emailCredsId = eid+--                     , emailCredsAuthId = emailUser e+--                     , emailCredsStatus = isJust $ emailUser e+--                     , emailCredsVerkey = emailVerkey e+--                     }+--         , getEmail = runDB . fmap (fmap emailEmail) . get+--         }++-- sendVerifyEmail' :: String -> String -> String -> GHandler Auth m ()+-- sendVerifyEmail' email _ verurl =+--     liftIO $ renderSendMail Mail+--             { mailHeaders =+--                 [ ("From", "noreply")+--                 , ("To", email)+--                 , ("Subject", "Verify your email address")+--                 ]+--             , mailPlain = verurl+--             , mailParts = return Part+--                 { partType = "text/html; charset=utf-8"+--                 , partEncoding = None+--                 , partDisposition = Inline+--                 , partContent = renderHamlet id [$hamlet|+-- %p Please confirm your email address by clicking on the link below.+-- %p+--     %a!href=$verurl$ $verurl$+-- %p Thank you+-- |]+--                 }+--             }++-- | Migrate the app's persistent data and run the given yesod/persistent/wai-ish IO action on it.+-- withApp :: App -> (Yesod.Application -> IO a) -> IO a+-- withApp app f = toPersistentApp app >>= toWaiApp >>= f+withApp :: App -> (Yesod.Application -> IO a) -> IO a+withApp app f = toWaiApp app >>= f++-- -- | Obtain a persistent db connection pool to the app, and run any necessary data migrations.+-- toPersistentApp :: App -> IO App+-- toPersistentApp app = withConnectionPool $ \p -> do+--     flip runConnectionPool p $ runMigration $ do+--         migrate (undefined :: User)+--         migrate (undefined :: Email)+--         return ()+--     return app{appConnPool=Just p}+++----------------------------------------------------------------------+-- handler utilities, common templates+----------------------------------------------------------------------++nulltemplate = [$hamlet||]++-- | A bundle of useful data passed to templates.+data TemplateData = TD {+     here         :: AppRoute -- ^ the current page's route+    ,title        :: String             -- ^ page's title+    ,msg          :: Maybe Html         -- ^ transient message+    ,a            :: String             -- ^ a (acct/desc filter pattern) parameter+    ,p            :: String             -- ^ p (period expression) parameter+    ,j            :: Journal            -- ^ the current journal+    ,today        :: Day                -- ^ the current day+    }++mktd = TD {+      here = IndexR+     ,title = "hledger"+     ,msg = Nothing+     ,a = ""+     ,p = ""+     ,j = nulljournal+     ,today = ModifiedJulianDay 0+     }++-- | Gather the data useful for a hledger web request handler, including:+-- initial command-line options, current a and p query string values, a+-- journal filter specification based on the above and the current time,+-- an up-to-date parsed journal, the current route, and the current ui+-- message if any.+getHandlerData :: Handler (String, String, [Opt], FilterSpec, Journal, Maybe Html, AppRoute)+getHandlerData = do+  Just here <- getCurrentRoute+  (a, p, opts, fspec) <- getReportParameters+  (j, err) <- getLatestJournal opts+  msg <- getMessage' err+  return (a, p, opts, fspec, j, msg, here)+    where+      -- | Get current report parameters for this request.+      getReportParameters :: Handler (String, String, [Opt], FilterSpec)+      getReportParameters = do+          app <- getYesod+          t <- liftIO $ getCurrentLocalTime+          a <- fromMaybe "" <$> lookupGetParam "a"+          p <- fromMaybe "" <$> lookupGetParam "p"+          let opts = appOpts app ++ [Period p]+              args = appArgs app ++ words' a+              fspec = optsToFilterSpec opts args t+          return (a, p, opts, fspec)++      -- | Quote-sensitive words, ie don't split on spaces which are inside quotes.+      words' :: String -> [String]+      words' = fromparse . parsewith ((quotedPattern <|> pattern) `sepBy` many1 spacenonewline)+          where+            pattern = many (noneOf " \n\r\"")+            quotedPattern = between (oneOf "'\"") (oneOf "'\"") $ many $ noneOf "'\""++      -- | Update our copy of the journal if the file changed. If there is an+      -- error while reloading, keep the old one and return the error, and set a+      -- ui message.+      getLatestJournal :: [Opt] -> Handler (Journal, Maybe String)+      getLatestJournal opts = do+        j <- liftIO $ fromJust `fmap` getValue "hledger" "journal"+        (jE, changed) <- liftIO $ journalReloadIfChanged opts j+        if not changed+         then return (j,Nothing)+         else case jE of+                Right j' -> do liftIO $ putValue "hledger" "journal" j'+                               return (j',Nothing)+                Left e  -> do setMessage $ string "error while reading" {- ++ ": " ++ e-}+                              return (j, Just e)++      -- | Helper to work around a yesod feature (can't set and get a message in the same request.)+      getMessage' :: Maybe String -> Handler (Maybe Html)+      getMessage' newmsgstr = do+        oldmsg <- getMessage+        return $ maybe oldmsg (Just . string) newmsgstr++-- | Wrap a template with the standard hledger web ui page layout.+pageLayout :: TemplateData -> Hamlet AppRoute -> Hamlet AppRoute+pageLayout td@TD{title=basetitle, msg=msg, p=p, j=j, today=today} content = [$hamlet|+!!!+%html+ %head+  %title $title'$+  %meta!http-equiv=Content-Type!content=$metacontent$+  %script!type=text/javascript!src=@StaticR.jquery_js@+  %script!type=text/javascript!src=@StaticR.jquery_url_js@+  %script!type=text/javascript!src=@StaticR.dhtmlxcommon_js@+  %script!type=text/javascript!src=@StaticR.dhtmlxcombo_js@+  %script!type=text/javascript!src=@StaticR.hledger_js@+  %link!rel=stylesheet!type=text/css!media=all!href=@StaticR.style_css@+ %body+  ^navbar.td^+  #messages $m$+  #content+   ^content^+|]+ where title' = basetitle ++ " - " ++ journaltitle+       (journaltitle, _) = journalTitleDesc j p today+       metacontent = "text/html; charset=utf-8"+       m = fromMaybe (string "") msg++-- | Global toolbar/heading area.+navbar :: TemplateData -> Hamlet AppRoute+navbar TD{p=p,j=j,today=today} = [$hamlet|+ #navbar+  %a.topleftlink!href=$hledgerorgurl$+   hledger+   <br />+   $version$+  %a.toprightlink!href=$manualurl$!target=hledgerhelp manual+  %h1 $title$+  \ $+  %span#journaldesc $desc$+|]+  where (title, desc) = journalTitleDesc j p today++-- | Generate a title and description for the given journal, period+-- expression, and date.+journalTitleDesc :: Journal -> String -> Day -> (String, String)+journalTitleDesc j p today = (title, desc)+  where+    title = printf "%s" (takeFileName $ journalFilePath j) :: String+    desc  = printf "%s" (showspan span) :: String+    span = either (const $ DateSpan Nothing Nothing) snd (parsePeriodExpr today p)+    showspan (DateSpan Nothing Nothing) = ""+    showspan s = " (" ++ dateSpanAsText s ++ ")"++-- | Links to the main views.+navlinks :: TemplateData -> Hamlet AppRoute+navlinks td = [$hamlet|+ #navlinks+  ^accountsjournallink^+  \ | $+  ^accountsregisterlink^+  \ | $+  %a#addformlink!href!onclick="return addformToggle()" add transaction+  %a#importformlink!href!onclick="return importformToggle()"!style=display:none; import transactions+  \ | $+  %a#editformlink!href!onclick="return editformToggle()" edit journal+|]+--  \ | $+ where+   accountsjournallink  = navlink td "journal" JournalR+   accountsregisterlink = navlink td "register" RegisterR++navlink :: TemplateData -> String -> AppRoute -> Hamlet AppRoute+navlink TD{here=here,a=a,p=p} s dest = [$hamlet|%a#$s$link.$style$!href=@?u@ $s$|]+ where u = (dest, concat [(if null a then [] else [("a", a)])+                         ,(if null p then [] else [("p", p)])])+       style | dest == here = "navlinkcurrent"+             | otherwise    = "navlink"++-- | Form controlling journal filtering parameters.+filterform :: TemplateData -> Hamlet AppRoute+filterform TD{here=here,a=a,p=p} = [$hamlet|+ #filterformdiv+  %form#filterform.form!method=GET!style=display:$visible$;+   %table.form+    %tr.$filteringperiodclass$+     %td+      filter by period:+      \ $+     %td+      %input!name=p!size=60!value=$p$+      ^phelp^+      \ $+     %td!align=right+      ^stopfilteringperiod^+    %tr.$filteringclass$+     %td+      filter by account/description:+      \ $+     %td+      %input!name=a!size=60!value=$a$+      ^ahelp^+      \ $+      %input!type=submit!value=filter $+      \ $+     %td!align=right+      ^stopfiltering^+|]+ where+  ahelp = helplink "filter-patterns" "?"+  phelp = helplink "period-expressions" "?"+  filtering = not $ null a+  filteringperiod = not $ null p+  visible = "block"+  filteringclass = if filtering then "filtering" else ""+  filteringperiodclass = if filteringperiod then "filtering" else ""+  stopfiltering = if filtering then [$hamlet|%a#stopfilterlink!href=@?u@ clear filter|] else nulltemplate+      where u = (here, if filteringperiod then [("p", p)] else [])+  stopfilteringperiod = if filteringperiod then [$hamlet|%a#stopfilterlink!href=@?u@ clear filter|] else nulltemplate+      where u = (here, if filtering then [("a", a)] else [])++-- | Link to a topic in the manual.+helplink :: String -> String -> Hamlet AppRoute+helplink topic label = [$hamlet|%a!href=$u$!target=hledgerhelp $label$|]+    where u = manualurl ++ if null topic then "" else '#':topic++{-++-- | Render a runtime template with the provided runtime data as html.+renderHamletFileRT :: FilePath -> HamletMap AppRoute -> Handler Html+renderHamletFileRT hfile hmap = do+  hrt <- readTemplateFile hfile >>= parseHamletRT defaultHamletSettings+  renderHamletRT hrt hmap urlParamsToString++-- | Read a file from the app's templates directory.+readTemplateFile :: FilePath -> Handler String+readTemplateFile hfile = do+  dir <- appDataDir `fmap` getYesod+  liftIO $ readFile $ dir </> hfile++-- what to do if rendering a runtime template fails.+instance Failure HamletException Handler+    where failure = error' . show++renderHamletAsHtml :: Hamlet AppRoute -> Html+renderHamletAsHtml h = h urlParamsToString++htmlAsHamlet :: Html -> Hamlet AppRoute+htmlAsHamlet h = [$hamlet|$h$|]++urlParamsToString :: AppRoute -> [(String,String)] -> String+urlParamsToString u [] = show u+urlParamsToString u ps = show u ++ "?" ++ intercalate "&" [k++"="++v | (k,v) <- ps]++-- | Convert a string to a hamlet HDHtml data item.+hdstring :: String -> HamletData AppRoute+hdstring = HDHtml . string++-- | Convert a simple list of strings to hamlet's complicated HDList type.+hdstringlist :: [String] -> HamletData AppRoute+hdstringlist ss = HDList [ [([], hdstring s)] | s <- ss ]++-- renderHamletRT' :: Failure HamletException m => HamletMap AppRoute -> HamletRT -> m Html+-- renderHamletRT' m h = renderHamletRT h m urlParamsToString++-- parseHamletRT' :: Failure HamletException m => String -> m HamletRT+-- parseHamletRT' s = parseHamletRT defaultHamletSettings s++-- hamletToHamletRT ::  Failure HamletException m => Hamlet AppRoute -> m HamletRT+-- hamletToHamletRT h = stringToHamletRT $ show $ unsafeByteString $ renderHamlet show h++-}++----------------------------------------------------------------------+-- handlers/views+----------------------------------------------------------------------++getFaviconR :: Handler ()+getFaviconR = sendFile "image/x-icon" $ datadir </> "favicon.ico"++----------------------------------------------------------------------++getRobotsR :: Handler RepPlain+getRobotsR = return $ RepPlain $ toContent robots_txt++----------------------------------------------------------------------++getIndexR :: Handler ()+getIndexR = redirect RedirectTemporary defaultroute where defaultroute = JournalR++----------------------------------------------------------------------++-- getDemoR :: Handler RepHtml+-- getDemoR = do+--     -- mu <- maybeAuth+--     defaultLayout $ do+--         h2id <- newIdent+--         setTitle $ string "hledger front page"+--         addBody $(hamletFile "homepage")+--         addStyle $(cassiusFile "homepage")+--         addJavascript $(juliusFile "homepage")++----------------------------------------------------------------------++-- | A combined accounts and journal view.+getJournalR :: Handler RepHtml+getJournalR = do+  (a, p, opts, fspec, j, msg, here) <- getHandlerData+  today <- liftIO getCurrentDay+  -- app <- getYesod+  -- t <- liftIO $ getCurrentLocalTime+  let -- args = appArgs app+      -- fspec' = optsToFilterSpec opts args t+      sidecontent = balanceReportAsHtml opts td $ balanceReport opts fspec j+      maincontent = journalReportAsHtml opts td $ journalReport opts fspec j+      td = mktd{here=here, title="hledger journal", msg=msg, a=a, p=p, j=j, today=today}+      editform' = editform td+  hamletToRepHtml $ pageLayout td [$hamlet|+ %div#content+  %div#sidebar+   ^sidecontent^+  %div#main.journal+   ^navlinks.td^+   ^addform.td^+   ^editform'^+   ^importform^+   %div#transactions+    ^filterform.td^+    ^maincontent^+|]++postJournalR :: Handler RepPlain+postJournalR = postJournalOnlyR++----------------------------------------------------------------------++-- | A combined accounts and register view.+getRegisterR :: Handler RepHtml+getRegisterR = do+  (a, p, opts, fspec, j, msg, here) <- getHandlerData+  today <- liftIO getCurrentDay+  -- app <- getYesod+  -- t <- liftIO $ getCurrentLocalTime+  let -- args = appArgs app+      -- opts' = Empty:opts+      -- fspec' = optsToFilterSpec opts' args t+      sidecontent = balanceReportAsHtml opts td $ balanceReport opts fspec j+      maincontent = registerReportAsHtml opts td $ registerReport opts fspec j+      td = mktd{here=here, title="hledger register", msg=msg, a=a, p=p, j=j, today=today}+      editform' = editform td+  hamletToRepHtml $ pageLayout td [$hamlet|+ %div#content+  %div#sidebar+   ^sidecontent^+  %div#main.journal+   ^navlinks.td^+   ^addform.td^+   ^editform'^+   ^importform^+   %div#transactions+    ^filterform.td^+    ^maincontent^+|]++postRegisterR :: Handler RepPlain+postRegisterR = postJournalOnlyR++----------------------------------------------------------------------++-- | A simple accounts and balances view like hledger balance.+getAccountsOnlyR :: Handler RepHtml+getAccountsOnlyR = do+  (a, p, opts, fspec, j, msg, here) <- getHandlerData+  today <- liftIO getCurrentDay+  let td = mktd{here=here, title="hledger accounts", msg=msg, a=a, p=p, j=j, today=today}+  hamletToRepHtml $ pageLayout td $ balanceReportAsHtml opts td $ balanceReport opts fspec j++-- | Render a balance report as HTML.+balanceReportAsHtml :: [Opt] -> TemplateData -> BalanceReport -> Hamlet AppRoute+balanceReportAsHtml _ td@TD{here=here,a=a,p=p} (items,total) = [$hamlet|+^accountsheading^+%table.balancereport+ $forall items i+  ^itemAsHtml' i^+ %tr.totalrule+  %td!colspan=2+ %tr+  %td+  %td!align=right $mixedAmountAsHtml.total$+|]+ where+   accountsheading = [$hamlet|+                      #accountsheading+                       accounts+                       \ $+                       ^showlinks^+                      |]+       where+         filteringaccts = not $ null a+         showlinks = [$hamlet|%span#showmoreaccounts ^showmore^ ^showall^|]+         showmore = case (filteringaccts, items) of+                      -- cunning parent account logic+                      (True, ((acct, _, _, _):_)) ->+                          let a' = if isAccountRegex a then a else acct+                              a'' = accountNameToAccountRegex $ parentAccountName $ accountRegexToAccountName a'+                              parenturl = (here, [("a",a''), ("p",p)])+                          in [$hamlet|+                              \ | $+                              %a!href=@?parenturl@ show more &uarr;+                              |]+                      _ -> nulltemplate+         showall = if filteringaccts+                    then [$hamlet|+                          \ | $+                          %a!href=@?allurl@ show all+                          |]+                    else nulltemplate+             where allurl = (here, [("p",p)])+   itemAsHtml' = itemAsHtml td+   itemAsHtml :: TemplateData -> BalanceReportItem -> Hamlet AppRoute+   itemAsHtml TD{p=p} (acct, adisplay, adepth, abal) = [$hamlet|+     %tr.item+      %td.account+       $indent$+       %a!href=$aurl$ $adisplay$+      %td.balance!align=right $mixedAmountAsHtml.abal$+     |] where+       -- current = if not (null a) && containsRegex a acct then "current" else ""+       indent = preEscapedString $ concat $ replicate (2 * adepth) "&nbsp;"+       aurl = printf ".?a=%s%s" (accountNameToAccountRegex acct) p' :: String+       p' = if null p then "" else printf "&p=%s" p++accountNameToAccountRegex :: String -> String+accountNameToAccountRegex "" = ""+accountNameToAccountRegex a = printf "^%s(:|$)" a++accountRegexToAccountName :: String -> String+accountRegexToAccountName = gsubRegexPR "^\\^(.*?)\\(:\\|\\$\\)$" "\\1"++isAccountRegex  :: String -> Bool+isAccountRegex s = take 1 s == "^" && (take 5 $ reverse s) == ")$|:("++----------------------------------------------------------------------++-- | A basic journal view, like hledger print, with editing.+getJournalOnlyR :: Handler RepHtml+getJournalOnlyR = do+  (a, p, opts, fspec, j, msg, here) <- getHandlerData+  today <- liftIO getCurrentDay+  let td = mktd{here=here, title="hledger journal", msg=msg, a=a, p=p, j=j, today=today}+      editform' = editform td+      txns = journalReportAsHtml opts td $ journalReport opts fspec j+  hamletToRepHtml $ pageLayout td [$hamlet|+%div#journal+ %div.nav2+  %a#addformlink!href!onclick="return addformToggle()" add one transaction+  \ | $+  %a#editformlink!href!onclick="return editformToggle()" edit the whole journal+ ^addform.td^+ ^editform'^+ #transactions ^txns^+|]++-- | Render a journal report as HTML.+journalReportAsHtml :: [Opt] -> TemplateData -> JournalReport -> Hamlet AppRoute+journalReportAsHtml _ td items = [$hamlet|+%table.journalreport+ $forall number.items i+  ^itemAsHtml' i^+|]+ where+   number = zip [1..]+   itemAsHtml' = itemAsHtml td+   itemAsHtml :: TemplateData -> (Int, JournalReportItem) -> Hamlet AppRoute+   itemAsHtml _ (n, t) = [$hamlet|+     %tr.item.$evenodd$+      %td.transaction+       %pre $txn$+     |] where+       evenodd = if even n then "even" else "odd"+       txn = trimnl $ showTransaction t where trimnl = reverse . dropWhile (=='\n') . reverse++addform :: TemplateData -> Hamlet AppRoute+addform td = [$hamlet|+%script!type=text/javascript+ $$(document).ready(function() {+    /* dhtmlxcombo setup */+    window.dhx_globalImgPath="../static/";+    var desccombo  = new dhtmlXCombo("description");+    var acct1combo = new dhtmlXCombo("account1");+    var acct2combo = new dhtmlXCombo("account2");+    desccombo.enableFilteringMode(true);+    acct1combo.enableFilteringMode(true);+    acct2combo.enableFilteringMode(true);+    desccombo.setSize(300);+    acct1combo.setSize(300);+    acct2combo.setSize(300);+    /* desccombo.enableOptionAutoHeight(true, 20); */+    /* desccombo.setOptionHeight(200); */+ });+%form#addform!method=POST!style=display:none;+  %table.form+   %tr+    %td!colspan=4+     %table+      %tr#descriptionrow+       %td+        Date:+       %td+        %input.textinput!size=15!name=date!value=$date$+       %td!style=padding-left:1em;+        Description:+       %td+        %select!id=description!name=description+         %option+         $forall descriptions d+          %option!value=$d$ $d$+      %tr.helprow+       %td+       %td+        .help $datehelp$ $+       %td+       %td+        .help $deschelp$+   ^postingsfields.td^+   %tr#addbuttonrow+    %td!colspan=4+     %input!type=hidden!name=action!value=add+     %input!type=submit!name=submit!value="add transaction"+     $if manyfiles+      \ to: ^journalselect.files.j.td^+|]+ where+  -- datehelplink = helplink "dates" "..."+  datehelp = "eg: 2010/7/20"+  deschelp = "eg: supermarket (optional)"+  date = "today"+  descriptions = sort $ nub $ map tdescription $ jtxns $ j td+  manyfiles = (length $ files $ j td) > 1++postingsfields :: TemplateData -> Hamlet AppRoute+postingsfields td = [$hamlet|+ ^p1^+ ^p2^+|]+  where+    p1 = postingfields td 1+    p2 = postingfields td 2++postingfields :: TemplateData -> Int -> Hamlet AppRoute+postingfields TD{j=j} n = [$hamlet|+ %tr#postingrow+  %td!align=right $acctlabel$:+  %td+   %select!id=$acctvar$!name=$acctvar$+    %option+    $forall acctnames a+     %option!value=$a$ $a$+  ^amtfield^+ %tr.helprow+  %td+  %td+   .help $accthelp$+  %td+  %td+   .help $amthelp$+|]+ where+  numbered = (++ show n)+  acctvar = numbered "account"+  amtvar = numbered "amount"+  acctnames = sort $ journalAccountNamesUsed j+  (acctlabel, accthelp, amtfield, amthelp)+       | n == 1     = ("To account"+                     ,"eg: expenses:food"+                     ,[$hamlet|+                       %td!style=padding-left:1em;+                        Amount:+                       %td+                        %input.textinput!size=15!name=$amtvar$!value=""+                       |]+                     ,"eg: $6"+                     )+       | otherwise = ("From account"+                     ,"eg: assets:bank:checking"+                     ,nulltemplate+                     ,""+                     )++editform :: TemplateData -> Hamlet AppRoute+editform TD{j=j} = [$hamlet|+ %form#editform!method=POST!style=display:none;+  %table.form#editform+   $if manyfiles+    %tr+     %td!colspan=2+      Editing ^journalselect.files.j^+   %tr+    %td!colspan=2+     $forall files.j f+      %textarea!id=$fst.f$_textarea!name=text!rows=25!cols=80!style=display:none;!disabled=disabled+       $snd.f$+   %tr#addbuttonrow+    %td+     %span.help ^formathelp^+    %td!align=right+     %span.help Are you sure ? This will overwrite the journal. $+     %input!type=hidden!name=action!value=edit+     %input!type=submit!name=submit!value="save journal"+     \ or $+     %a!href!onclick="return editformToggle()" cancel+|] -- XXX textarea ids are unquoted journal file paths, which is not valid html+  where+    manyfiles = (length $ files j) > 1+    formathelp = helplink "file-format" "file format help"++journalselect :: [(FilePath,String)] -> Hamlet AppRoute+journalselect journalfiles = [$hamlet|+     %select!id=journalselect!name=journal!onchange="editformJournalSelect()"+      $forall journalfiles f+       %option!value=$fst.f$ $fst.f$+|]++importform :: Hamlet AppRoute+importform = [$hamlet|+ %form#importform!method=POST!style=display:none;+  %table.form+   %tr+    %td+     %input!type=file!name=file+     %input!type=hidden!name=action!value=import+     %input!type=submit!name=submit!value="import from file"+     \ or $+     %a!href!onclick="return importformToggle()" cancel+|]++postJournalOnlyR :: Handler RepPlain+postJournalOnlyR = do+  action <- runFormPost' $ maybeStringInput "action"+  case action of Just "edit"   -> postEditForm+                 Just "import" -> postImportForm+                 _             -> postAddForm++-- | Handle a journal add form post.+postAddForm :: Handler RepPlain+postAddForm = do+  (_, _, _, _, j, _, _) <- getHandlerData+  today <- liftIO getCurrentDay+  -- get form input values. M means a Maybe value.+  (dateM, descM, acct1M, amt1M, acct2M, amt2M, journalM) <- runFormPost'+    $ (,,,,,,)+    <$> maybeStringInput "date"+    <*> maybeStringInput "description"+    <*> maybeStringInput "account1"+    <*> maybeStringInput "amount1"+    <*> maybeStringInput "account2"+    <*> maybeStringInput "amount2"+    <*> maybeStringInput "journal"+  -- supply defaults and parse date and amounts, or get errors.+  let dateE = maybe (Left "date required") (either (\e -> Left $ showDateParseError e) Right . fixSmartDateStrEither today) dateM+      descE = Right $ fromMaybe "" descM+      acct1E = maybe (Left "to account required") Right acct1M+      acct2E = maybe (Left "from account required") Right acct2M+      amt1E = maybe (Left "amount required") (either (const $ Left "could not parse amount") Right . parseWithCtx nullctx someamount) amt1M+      amt2E = maybe (Right missingamt)       (either (const $ Left "could not parse amount") Right . parseWithCtx nullctx someamount) amt2M+      journalE = maybe (Right $ journalFilePath j)+                       (\f -> if f `elem` journalFilePaths j+                              then Right f+                              else Left $ "unrecognised journal file path: " ++ f)+                       journalM+      strEs = [dateE, descE, acct1E, acct2E, journalE]+      amtEs = [amt1E, amt2E]+      errs = lefts strEs ++ lefts amtEs+      [date,desc,acct1,acct2,journalpath] = rights strEs+      [amt1,amt2] = rights amtEs+      -- if no errors so far, generate a transaction and balance it or get the error.+      tE | not $ null errs = Left errs+         | otherwise = either (\e -> Left ["unbalanced postings: " ++ (head $ lines e)]) Right+                        (balanceTransaction Nothing $ nulltransaction { -- imprecise balancing+                           tdate=parsedate date+                          ,tdescription=desc+                          ,tpostings=[+                            Posting False acct1 amt1 "" RegularPosting [] Nothing+                           ,Posting False acct2 amt2 "" RegularPosting [] Nothing+                           ]+                          })+  -- display errors or add transaction+  case tE of+   Left errs -> do+    -- save current form values in session+    setMessage $ string $ intercalate "; " errs+    redirect RedirectTemporary RegisterR++   Right t -> do+    let t' = txnTieKnot t -- XXX move into balanceTransaction+    liftIO $ appendToJournalFile journalpath $ showTransaction t'+    setMessage $ string $ printf "Added transaction:\n%s" (show t')+    redirect RedirectTemporary RegisterR++-- | Handle a journal edit form post.+postEditForm :: Handler RepPlain+postEditForm = do+  (_, _, _, _, j, _, _) <- getHandlerData+  -- get form input values, or validation errors.+  -- getRequest >>= liftIO (reqRequestBody req) >>= mtrace+  (textM, journalM) <- runFormPost'+    $ (,)+    <$> maybeStringInput "text"+    <*> maybeStringInput "journal"+  let textE = maybe (Left "No value provided") Right textM+      journalE = maybe (Right $ journalFilePath j)+                       (\f -> if f `elem` journalFilePaths j+                              then Right f+                              else Left "unrecognised journal file path")+                       journalM+      strEs = [textE, journalE]+      errs = lefts strEs+      [text,journalpath] = rights strEs+  -- display errors or perform edit+  if not $ null errs+   then do+    setMessage $ string $ intercalate "; " errs+    redirect RedirectTemporary JournalR++   else do+    -- try to avoid unnecessary backups or saving invalid data+    filechanged' <- liftIO $ journalSpecifiedFileIsNewer j journalpath+    told <- liftIO $ readFileStrictly journalpath+    let tnew = filter (/= '\r') text+        changed = tnew /= told || filechanged'+    if not changed+     then do+       setMessage $ string $ "No change"+       redirect RedirectTemporary JournalR+     else do+      jE <- liftIO $ journalFromPathAndString Nothing journalpath tnew+      either+       (\e -> do+          setMessage $ string e+          redirect RedirectTemporary JournalR)+       (const $ do+          liftIO $ writeFileWithBackup journalpath tnew+          setMessage $ string $ printf "Saved journal %s\n" (show journalpath)+          redirect RedirectTemporary JournalR)+       jE++-- | Handle an import page post.+postImportForm :: Handler RepPlain+postImportForm = do+  setMessage $ string $ "can't handle file upload yet"+  redirect RedirectTemporary JournalR+  -- -- get form input values, or basic validation errors. E means an Either value.+  -- fileM <- runFormPost' $ maybeFileInput "file"+  -- let fileE = maybe (Left "No file provided") Right fileM+  -- -- display errors or import transactions+  -- case fileE of+  --  Left errs -> do+  --   setMessage $ string errs+  --   redirect RedirectTemporary JournalR++  --  Right s -> do+  --    setMessage $ string $ s+  --    redirect RedirectTemporary JournalR++----------------------------------------------------------------------++-- | A simple postings view like hledger register.+getRegisterOnlyR :: Handler RepHtml+getRegisterOnlyR = do+  (a, p, opts, fspec, j, msg, here) <- getHandlerData+  today <- liftIO getCurrentDay+  let td = mktd{here=here, title="hledger register", msg=msg, a=a, p=p, j=j, today=today}+  hamletToRepHtml $ pageLayout td $ registerReportAsHtml opts td $ registerReport opts fspec j++-- | Render a register report as HTML.+registerReportAsHtml :: [Opt] -> TemplateData -> RegisterReport -> Hamlet AppRoute+registerReportAsHtml _ td items = [$hamlet|+%table.registerreport+ %tr.headings+  ^headings^+ $forall number.items i+  ^itemAsHtml' i^+|]+ where+   number = zip [1..]+   headings = [$hamlet|+               %th.date!align=left Date+               %th.description!align=left Description+               %th.account!align=left Account+               %th.amount!align=right Amount+               %th.balance!align=right Balance+               |]+   itemAsHtml' = itemAsHtml td+   itemAsHtml :: TemplateData -> (Int, RegisterReportItem) -> Hamlet AppRoute+   itemAsHtml TD{p=p} (n, (ds, posting, b)) = [$hamlet|+     %tr.item.$evenodd$.$firstposting$+      %td.date $date$+      %td.description $desc$+      %td.account+       %a!href=$aurl$ $acct$+      %td.amount!align=right $mixedAmountAsHtml.pamount.posting$+      %td.balance!align=right $mixedAmountAsHtml.b$+     |] where+       evenodd = if even n then "even" else "odd"+       (firstposting, date, desc) = case ds of Just (da, de) -> ("firstposting", show da, de)+                                               Nothing -> ("", "", "")+       acct = paccount posting+       aurl = printf ".?a=%s%s" (accountNameToAccountRegex acct) p' :: String+       p' = if null p then "" else printf "&p=%s" p++mixedAmountAsHtml b = preEscapedString $ addclass $ intercalate "<br>" $ lines $ show b+    where addclass = printf "<span class=\"%s\">%s</span>" c+          c = case isNegativeMixedAmount b of Just True -> "negative amount"+                                              _         -> "positive amount"++----------------------------------------------------------------------++-- | A standalone journal edit form page.+-- getEditR :: Handler RepHtml+-- getEditR = do+--   (a, p, _, _, _, msg, here) <- getHandlerData+--   today <- liftIO getCurrentDay+--   -- reload journal's text without parsing, if changed     -- XXX are we doing this right ?+--   j <- liftIO $ fromJust `fmap` getValue "hledger" "journal"+--   changed <- liftIO $ journalFileIsNewer j+--   s <- liftIO $ if changed then readFile (filepath j) else return (jtext j) -- XXX readFile may throw an error+--   let td = mktd{here=here, title="hledger journal edit", msg=msg, a=a, p=p, j=j, today=today}+--   hamletToRepHtml $ pageLayout td $ editform td s++----------------------------------------------------------------------+{-+-- | An add form with template files reloaded at runtime.+getAddformRTR :: Handler RepHtml+getAddformRTR = do+  (a, p, _, _, j, msg, here) <- getHandlerData+  today <- liftIO getCurrentDay+  let td = mktd{here=here, title="hledger add transaction", msg=msg, a=a, p=p, j=j, today=today}+      descriptions = sort $ nub $ map tdescription $ jtxns j+      acctnames = sort $ journalAccountNamesUsed j+      postingData n = [+                       (["acctlabel"], hdstring acctlabel)+                      ,(["acctvar"],   hdstring acctvar)+                      ,(["acctnames"], hdstringlist acctnames)+                      ,(["amtfield"],  HDHtml $ renderHamletAsHtml amtfield)+                      ,(["accthelp"],  hdstring accthelp)+                      ,(["amthelp"],   hdstring amthelp)+                      ] :: HamletMap AppRoute+          where+            numbered = (++ show n)+            acctvar = numbered "account"+            amtvar = numbered "amount"+            (acctlabel, accthelp, amtfield, amthelp)+                | n == 1     = ("To account"+                              ,"eg: expenses:food"+                              ,[$hamlet|+                                %td!style=padding-left:1em;+                                 Amount:+                                %td+                                 %input.textinput!size=15!name=$amtvar$!value=""+                                |]+                              ,"eg: $6"+                              )+                | otherwise = ("From account"+                              ,"eg: assets:bank:checking"+                              ,nulltemplate+                              ,""+                              )+  pfields1 <- renderHamletFileRT "addformpostingfields.hamlet" (postingData 1)+  pfields2 <- renderHamletFileRT "addformpostingfields.hamlet" (postingData 2)+  addform  <- renderHamletFileRT "addform.hamlet" ([+                                                 (["date"], hdstring "today")+                                                ,(["desc"], hdstring "")+                                                ,(["descriptions"], hdstringlist descriptions)+                                                ,(["datehelp"], hdstring "eg: 2010/7/20")+                                                ,(["deschelp"], hdstring "eg: supermarket (optional)")+                                                ,(["postingfields1"], HDHtml pfields1)+                                                ,(["postingfields2"], HDHtml pfields2)+                                                ,(["manyfiles"], HDBool $ (length $ files $ j) > 1)+--                                                ,(["files"], ... $ files $ j)+                                                ] :: HamletMap AppRoute)+  hamletToRepHtml $ pageLayout td $ htmlAsHamlet addform+-}
+ Hledger/Web/Files.hs view
@@ -0,0 +1,44 @@+{-# LANGUAGE TemplateHaskell #-}+{-| ++Support files used by the web app are embedded here at compile time via+template haskell magic.  This allows us minimise deployment hassle by+recreating them on the filesystem when needed (since hamlet can not use+the embedded files directly.)  Installing on the filesystem has the added+benefit of making them easily customisable.++-}+module Hledger.Web.Files+    (+     files+    ,createFilesIfMissing+    )+where+import Control.Monad+import qualified Data.ByteString as B+import Data.FileEmbed (embedDir)+import System.Directory++import Hledger.Web.Settings (datadir)+++-- | An embedded copy of all files below the the hledger-web data+-- directory (@.hledger/web/@) at compile time, as (FilePath,ByteString)+-- pairs.+files :: [(FilePath, B.ByteString)]+files = $(embedDir datadir)++-- | If the hledger-web data directory (@.hledger/web/@) does not exist in+-- the current directory, create and fill it with the web app support+-- files (templates, stylesheets, images etc.) Returns True if the+-- directory was missing.+createFilesIfMissing :: IO Bool+createFilesIfMissing = do+  exists <- doesDirectoryExist datadir+  if exists+   then return False+   else do+     createDirectoryIfMissing True datadir  +     setCurrentDirectory datadir+     forM_ files $ \(f,d) -> B.writeFile f d+     return True
+ Hledger/Web/Main.hs view
@@ -0,0 +1,102 @@+{-# LANGUAGE CPP #-}+{-|+hledger-web - a hledger add-on providing a web interface.+Copyright (c) 2007-2010 Simon Michael <simon@joyful.com>+Released under GPL version 3 or later.+-}++module Hledger.Web.Main where++#if __GLASGOW_HASKELL__ <= 610+import Prelude hiding (putStr, putStrLn)+import System.IO.UTF8 (putStr, putStrLn)+#endif+import Control.Concurrent (forkIO, threadDelay)+import Network.Wai.Handler.SimpleServer (run)+import System.Exit (exitFailure)+import System.IO.Storage (withStore, putValue,)+import Yesod.Content (typeByExt)+import Yesod.Helpers.Static (fileLookupDir)+import System.Console.GetOpt++import Hledger.Cli.Options+import Hledger.Cli.Utils (withJournalDo, openBrowserOn)+import Hledger.Cli.Version (progversionstr, binaryfilename)+import Hledger.Data+import Hledger.Web.App (App(..), withApp)+import Hledger.Web.Files (createFilesIfMissing)+import Hledger.Web.Settings (browserstartdelay, defhost, defport, datadir)+++progname_web = progname_cli ++ "-web"++options_web :: [OptDescr Opt]+options_web = [+  Option ""  ["base-url"]     (ReqArg BaseUrl "URL") "use this base url (default http://localhost:PORT)"+ ,Option ""  ["port"]         (ReqArg Port "N")      "serve on tcp port N (default 5000)"+ ]++usage_preamble_web =+  "Usage: hledger-web [OPTIONS] [PATTERNS]\n" +++  "\n" +++  "Reads your ~/.journal file, or another specified by $LEDGER or -f, and\n" +++  "starts a web ui server. Also attempts to start a web browser (unless --debug).\n" +++  "\n"++usage_options_web = usageInfo "hledger-web options:" options_web ++ "\n"++usage_web = concat [+             usage_preamble_web+            ,usage_options_web+            ,usage_options_cli+            ,usage_postscript_cli+            ]++main :: IO ()+main = do+  (opts, args) <- parseArgumentsWith $ options_cli++options_web+  run opts args+    where+      run opts args+       | Help `elem` opts             = putStr usage_web+       | Version `elem` opts          = putStrLn $ progversionstr progname_web+       | BinaryFilename `elem` opts   = putStrLn $ binaryfilename progname_web+       | otherwise                    = withJournalDo opts args "web" web++-- | The web command.+web :: [Opt] -> [String] -> Journal -> IO ()+web opts args j = do+  created <- createFilesIfMissing+  if created+   then do+     putStrLn $ "Installing support files in "++datadir++" - done, please run again."+     exitFailure+   else do+     putStrLn $ "Using support files in "++datadir+     let host    = defhost+         port    = fromMaybe defport $ portFromOpts opts+         baseurl = fromMaybe (printf "http://%s:%d" host port) $ baseUrlFromOpts opts+     unless (Debug `elem` opts) $ forkIO (browser baseurl) >> return ()+     server baseurl port opts args j++server :: String -> Int -> [Opt] -> [String] -> Journal -> IO ()+server baseurl port opts args j = do+  printf "Starting http server on port %d with base url %s\n" port baseurl+  withStore "hledger" $ do+    putValue "hledger" "journal" j+    withApp App{+              -- appConnPool=Nothing+              appRoot=baseurl+             ,appDataDir=datadir+             ,appStatic=fileLookupDir datadir $ typeByExt -- ++[("hamlet","text/plain")]+             ,appOpts=opts+             ,appArgs=args+             ,appJournal=j+             } $ run port++browser :: String -> IO ()+browser baseurl = do+  threadDelay $ fromIntegral browserstartdelay+  putStrLn "Attempting to start a web browser"+  openBrowserOn baseurl >> return ()+
+ Hledger/Web/Settings.hs view
@@ -0,0 +1,127 @@+{-# LANGUAGE CPP #-}+module Hledger.Web.Settings+    (+     hamletFile+    , cassiusFile+    , juliusFile+    -- , connStr+    -- , ConnectionPool+    -- , withConnectionPool+    -- , runConnectionPool+    , approot+    , staticroot+    , datadir+    , defhost+    , defport+    , browserstartdelay+    , hledgerorgurl+    , manualurl+    , style_css+    , hledger_js+    , jquery_js+    , jquery_url_js+    , dhtmlxcommon_js+    , dhtmlxcombo_js+    , robots_txt+    ) where++import Language.Haskell.TH.Syntax+import System.FilePath ((</>))+import qualified Text.Cassius as H+import qualified Text.Hamlet as H+import qualified Text.Julius as H+import Text.Printf (printf)+-- import Database.Persist.Sqlite+-- import Yesod (MonadCatchIO)+import Yesod.Helpers.Static+++browserstartdelay = 100000 -- microseconds++----------------------------------------------------------------------+-- urls+----------------------------------------------------------------------++hledgerorgurl     = "http://hledger.org"+manualurl         = hledgerorgurl++"/MANUAL.html"++defhost           = "localhost"+defport           = 5000++approot :: String+#ifdef PRODUCTION+approot = printf "http://%s:%d" defhost (defport :: Int)+#else+approot = printf "http://%s:%d" defhost (defport :: Int)+#endif++staticroot :: String+staticroot = approot ++ "/static"++-- Some static routes we can refer to by name, without hard-coded filesystem location.+style_css       = StaticRoute ["style.css"] []+hledger_js      = StaticRoute ["hledger.js"] []+jquery_js       = StaticRoute ["jquery.js"] []+jquery_url_js   = StaticRoute ["jquery.url.js"] []+dhtmlxcommon_js = StaticRoute ["dhtmlxcommon.js"] []+dhtmlxcombo_js  = StaticRoute ["dhtmlxcombo.js"] []++-- Content for /robots.txt+robots_txt = "User-agent: *"+++----------------------------------------------------------------------+-- filesystem+----------------------------------------------------------------------++-- | Hard-coded data directory path. This must be in your current dir when+-- you compile. At run time it's also required but we'll auto-create it.+datadir :: FilePath+datadir = "./.hledger/web/"++-- The following are compile-time macros. If the file paths they point to+-- don't exist, they will give an error (at compile time). If PRODUCTION+-- is defined, files are read only once at (startup?) time, otherwise+-- repeatedly at run time.++hamletFile :: FilePath -> Q Exp+#ifdef PRODUCTION+hamletFile x = H.hamletFile $ datadir </> (x ++ ".hamlet")+#else+hamletFile x = H.hamletFileDebug $ datadir </> (x ++ ".hamlet")+#endif++cassiusFile :: FilePath -> Q Exp+#ifdef PRODUCTION+cassiusFile x = H.cassiusFile $ datadir </> (x ++ ".cassius")+#else+cassiusFile x = H.cassiusFileDebug $ datadir </> (x ++ ".cassius")+#endif++juliusFile :: FilePath -> Q Exp+#ifdef PRODUCTION+juliusFile x = H.juliusFile $ datadir </> (x ++ ".julius")+#else+juliusFile x = H.juliusFileDebug $ datadir </> (x ++ ".julius")+#endif++----------------------------------------------------------------------+-- database+----------------------------------------------------------------------++-- connStr :: String+-- #ifdef PRODUCTION+-- connStr = "production.db3"+-- #else+-- connStr = "debug.db3"+-- #endif++-- connectionCount :: Int+-- connectionCount = 10++-- withConnectionPool :: MonadCatchIO m => (ConnectionPool -> m a) -> m a+-- withConnectionPool = withSqlitePool connStr connectionCount++-- runConnectionPool :: MonadCatchIO m => SqlPersist m a -> ConnectionPool -> m a+-- runConnectionPool = runSqlPool+
+ LICENSE view
@@ -0,0 +1,674 @@+                    GNU GENERAL PUBLIC LICENSE+                       Version 3, 29 June 2007++ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>+ Everyone is permitted to copy and distribute verbatim copies+ of this license document, but changing it is not allowed.++                            Preamble++  The GNU General Public License is a free, copyleft license for+software and other kinds of works.++  The licenses for most software and other practical works are designed+to take away your freedom to share and change the works.  By contrast,+the GNU General Public License is intended to guarantee your freedom to+share and change all versions of a program--to make sure it remains free+software for all its users.  We, the Free Software Foundation, use the+GNU General Public License for most of our software; it applies also to+any other work released this way by its authors.  You can apply it to+your programs, too.++  When we speak of free software, we are referring to freedom, not+price.  Our General Public Licenses are designed to make sure that you+have the freedom to distribute copies of free software (and charge for+them if you wish), that you receive source code or can get it if you+want it, that you can change the software or use pieces of it in new+free programs, and that you know you can do these things.++  To protect your rights, we need to prevent others from denying you+these rights or asking you to surrender the rights.  Therefore, you have+certain responsibilities if you distribute copies of the software, or if+you modify it: responsibilities to respect the freedom of others.++  For example, if you distribute copies of such a program, whether+gratis or for a fee, you must pass on to the recipients the same+freedoms that you received.  You must make sure that they, too, receive+or can get the source code.  And you must show them these terms so they+know their rights.++  Developers that use the GNU GPL protect your rights with two steps:+(1) assert copyright on the software, and (2) offer you this License+giving you legal permission to copy, distribute and/or modify it.++  For the developers' and authors' protection, the GPL clearly explains+that there is no warranty for this free software.  For both users' and+authors' sake, the GPL requires that modified versions be marked as+changed, so that their problems will not be attributed erroneously to+authors of previous versions.++  Some devices are designed to deny users access to install or run+modified versions of the software inside them, although the manufacturer+can do so.  This is fundamentally incompatible with the aim of+protecting users' freedom to change the software.  The systematic+pattern of such abuse occurs in the area of products for individuals to+use, which is precisely where it is most unacceptable.  Therefore, we+have designed this version of the GPL to prohibit the practice for those+products.  If such problems arise substantially in other domains, we+stand ready to extend this provision to those domains in future versions+of the GPL, as needed to protect the freedom of users.++  Finally, every program is threatened constantly by software patents.+States should not allow patents to restrict development and use of+software on general-purpose computers, but in those that do, we wish to+avoid the special danger that patents applied to a free program could+make it effectively proprietary.  To prevent this, the GPL assures that+patents cannot be used to render the program non-free.++  The precise terms and conditions for copying, distribution and+modification follow.++                       TERMS AND CONDITIONS++  0. Definitions.++  "This License" refers to version 3 of the GNU General Public License.++  "Copyright" also means copyright-like laws that apply to other kinds of+works, such as semiconductor masks.++  "The Program" refers to any copyrightable work licensed under this+License.  Each licensee is addressed as "you".  "Licensees" and+"recipients" may be individuals or organizations.++  To "modify" a work means to copy from or adapt all or part of the work+in a fashion requiring copyright permission, other than the making of an+exact copy.  The resulting work is called a "modified version" of the+earlier work or a work "based on" the earlier work.++  A "covered work" means either the unmodified Program or a work based+on the Program.++  To "propagate" a work means to do anything with it that, without+permission, would make you directly or secondarily liable for+infringement under applicable copyright law, except executing it on a+computer or modifying a private copy.  Propagation includes copying,+distribution (with or without modification), making available to the+public, and in some countries other activities as well.++  To "convey" a work means any kind of propagation that enables other+parties to make or receive copies.  Mere interaction with a user through+a computer network, with no transfer of a copy, is not conveying.++  An interactive user interface displays "Appropriate Legal Notices"+to the extent that it includes a convenient and prominently visible+feature that (1) displays an appropriate copyright notice, and (2)+tells the user that there is no warranty for the work (except to the+extent that warranties are provided), that licensees may convey the+work under this License, and how to view a copy of this License.  If+the interface presents a list of user commands or options, such as a+menu, a prominent item in the list meets this criterion.++  1. Source Code.++  The "source code" for a work means the preferred form of the work+for making modifications to it.  "Object code" means any non-source+form of a work.++  A "Standard Interface" means an interface that either is an official+standard defined by a recognized standards body, or, in the case of+interfaces specified for a particular programming language, one that+is widely used among developers working in that language.++  The "System Libraries" of an executable work include anything, other+than the work as a whole, that (a) is included in the normal form of+packaging a Major Component, but which is not part of that Major+Component, and (b) serves only to enable use of the work with that+Major Component, or to implement a Standard Interface for which an+implementation is available to the public in source code form.  A+"Major Component", in this context, means a major essential component+(kernel, window system, and so on) of the specific operating system+(if any) on which the executable work runs, or a compiler used to+produce the work, or an object code interpreter used to run it.++  The "Corresponding Source" for a work in object code form means all+the source code needed to generate, install, and (for an executable+work) run the object code and to modify the work, including scripts to+control those activities.  However, it does not include the work's+System Libraries, or general-purpose tools or generally available free+programs which are used unmodified in performing those activities but+which are not part of the work.  For example, Corresponding Source+includes interface definition files associated with source files for+the work, and the source code for shared libraries and dynamically+linked subprograms that the work is specifically designed to require,+such as by intimate data communication or control flow between those+subprograms and other parts of the work.++  The Corresponding Source need not include anything that users+can regenerate automatically from other parts of the Corresponding+Source.++  The Corresponding Source for a work in source code form is that+same work.++  2. Basic Permissions.++  All rights granted under this License are granted for the term of+copyright on the Program, and are irrevocable provided the stated+conditions are met.  This License explicitly affirms your unlimited+permission to run the unmodified Program.  The output from running a+covered work is covered by this License only if the output, given its+content, constitutes a covered work.  This License acknowledges your+rights of fair use or other equivalent, as provided by copyright law.++  You may make, run and propagate covered works that you do not+convey, without conditions so long as your license otherwise remains+in force.  You may convey covered works to others for the sole purpose+of having them make modifications exclusively for you, or provide you+with facilities for running those works, provided that you comply with+the terms of this License in conveying all material for which you do+not control copyright.  Those thus making or running the covered works+for you must do so exclusively on your behalf, under your direction+and control, on terms that prohibit them from making any copies of+your copyrighted material outside their relationship with you.++  Conveying under any other circumstances is permitted solely under+the conditions stated below.  Sublicensing is not allowed; section 10+makes it unnecessary.++  3. Protecting Users' Legal Rights From Anti-Circumvention Law.++  No covered work shall be deemed part of an effective technological+measure under any applicable law fulfilling obligations under article+11 of the WIPO copyright treaty adopted on 20 December 1996, or+similar laws prohibiting or restricting circumvention of such+measures.++  When you convey a covered work, you waive any legal power to forbid+circumvention of technological measures to the extent such circumvention+is effected by exercising rights under this License with respect to+the covered work, and you disclaim any intention to limit operation or+modification of the work as a means of enforcing, against the work's+users, your or third parties' legal rights to forbid circumvention of+technological measures.++  4. Conveying Verbatim Copies.++  You may convey verbatim copies of the Program's source code as you+receive it, in any medium, provided that you conspicuously and+appropriately publish on each copy an appropriate copyright notice;+keep intact all notices stating that this License and any+non-permissive terms added in accord with section 7 apply to the code;+keep intact all notices of the absence of any warranty; and give all+recipients a copy of this License along with the Program.++  You may charge any price or no price for each copy that you convey,+and you may offer support or warranty protection for a fee.++  5. Conveying Modified Source Versions.++  You may convey a work based on the Program, or the modifications to+produce it from the Program, in the form of source code under the+terms of section 4, provided that you also meet all of these conditions:++    a) The work must carry prominent notices stating that you modified+    it, and giving a relevant date.++    b) The work must carry prominent notices stating that it is+    released under this License and any conditions added under section+    7.  This requirement modifies the requirement in section 4 to+    "keep intact all notices".++    c) You must license the entire work, as a whole, under this+    License to anyone who comes into possession of a copy.  This+    License will therefore apply, along with any applicable section 7+    additional terms, to the whole of the work, and all its parts,+    regardless of how they are packaged.  This License gives no+    permission to license the work in any other way, but it does not+    invalidate such permission if you have separately received it.++    d) If the work has interactive user interfaces, each must display+    Appropriate Legal Notices; however, if the Program has interactive+    interfaces that do not display Appropriate Legal Notices, your+    work need not make them do so.++  A compilation of a covered work with other separate and independent+works, which are not by their nature extensions of the covered work,+and which are not combined with it such as to form a larger program,+in or on a volume of a storage or distribution medium, is called an+"aggregate" if the compilation and its resulting copyright are not+used to limit the access or legal rights of the compilation's users+beyond what the individual works permit.  Inclusion of a covered work+in an aggregate does not cause this License to apply to the other+parts of the aggregate.++  6. Conveying Non-Source Forms.++  You may convey a covered work in object code form under the terms+of sections 4 and 5, provided that you also convey the+machine-readable Corresponding Source under the terms of this License,+in one of these ways:++    a) Convey the object code in, or embodied in, a physical product+    (including a physical distribution medium), accompanied by the+    Corresponding Source fixed on a durable physical medium+    customarily used for software interchange.++    b) Convey the object code in, or embodied in, a physical product+    (including a physical distribution medium), accompanied by a+    written offer, valid for at least three years and valid for as+    long as you offer spare parts or customer support for that product+    model, to give anyone who possesses the object code either (1) a+    copy of the Corresponding Source for all the software in the+    product that is covered by this License, on a durable physical+    medium customarily used for software interchange, for a price no+    more than your reasonable cost of physically performing this+    conveying of source, or (2) access to copy the+    Corresponding Source from a network server at no charge.++    c) Convey individual copies of the object code with a copy of the+    written offer to provide the Corresponding Source.  This+    alternative is allowed only occasionally and noncommercially, and+    only if you received the object code with such an offer, in accord+    with subsection 6b.++    d) Convey the object code by offering access from a designated+    place (gratis or for a charge), and offer equivalent access to the+    Corresponding Source in the same way through the same place at no+    further charge.  You need not require recipients to copy the+    Corresponding Source along with the object code.  If the place to+    copy the object code is a network server, the Corresponding Source+    may be on a different server (operated by you or a third party)+    that supports equivalent copying facilities, provided you maintain+    clear directions next to the object code saying where to find the+    Corresponding Source.  Regardless of what server hosts the+    Corresponding Source, you remain obligated to ensure that it is+    available for as long as needed to satisfy these requirements.++    e) Convey the object code using peer-to-peer transmission, provided+    you inform other peers where the object code and Corresponding+    Source of the work are being offered to the general public at no+    charge under subsection 6d.++  A separable portion of the object code, whose source code is excluded+from the Corresponding Source as a System Library, need not be+included in conveying the object code work.++  A "User Product" is either (1) a "consumer product", which means any+tangible personal property which is normally used for personal, family,+or household purposes, or (2) anything designed or sold for incorporation+into a dwelling.  In determining whether a product is a consumer product,+doubtful cases shall be resolved in favor of coverage.  For a particular+product received by a particular user, "normally used" refers to a+typical or common use of that class of product, regardless of the status+of the particular user or of the way in which the particular user+actually uses, or expects or is expected to use, the product.  A product+is a consumer product regardless of whether the product has substantial+commercial, industrial or non-consumer uses, unless such uses represent+the only significant mode of use of the product.++  "Installation Information" for a User Product means any methods,+procedures, authorization keys, or other information required to install+and execute modified versions of a covered work in that User Product from+a modified version of its Corresponding Source.  The information must+suffice to ensure that the continued functioning of the modified object+code is in no case prevented or interfered with solely because+modification has been made.++  If you convey an object code work under this section in, or with, or+specifically for use in, a User Product, and the conveying occurs as+part of a transaction in which the right of possession and use of the+User Product is transferred to the recipient in perpetuity or for a+fixed term (regardless of how the transaction is characterized), the+Corresponding Source conveyed under this section must be accompanied+by the Installation Information.  But this requirement does not apply+if neither you nor any third party retains the ability to install+modified object code on the User Product (for example, the work has+been installed in ROM).++  The requirement to provide Installation Information does not include a+requirement to continue to provide support service, warranty, or updates+for a work that has been modified or installed by the recipient, or for+the User Product in which it has been modified or installed.  Access to a+network may be denied when the modification itself materially and+adversely affects the operation of the network or violates the rules and+protocols for communication across the network.++  Corresponding Source conveyed, and Installation Information provided,+in accord with this section must be in a format that is publicly+documented (and with an implementation available to the public in+source code form), and must require no special password or key for+unpacking, reading or copying.++  7. Additional Terms.++  "Additional permissions" are terms that supplement the terms of this+License by making exceptions from one or more of its conditions.+Additional permissions that are applicable to the entire Program shall+be treated as though they were included in this License, to the extent+that they are valid under applicable law.  If additional permissions+apply only to part of the Program, that part may be used separately+under those permissions, but the entire Program remains governed by+this License without regard to the additional permissions.++  When you convey a copy of a covered work, you may at your option+remove any additional permissions from that copy, or from any part of+it.  (Additional permissions may be written to require their own+removal in certain cases when you modify the work.)  You may place+additional permissions on material, added by you to a covered work,+for which you have or can give appropriate copyright permission.++  Notwithstanding any other provision of this License, for material you+add to a covered work, you may (if authorized by the copyright holders of+that material) supplement the terms of this License with terms:++    a) Disclaiming warranty or limiting liability differently from the+    terms of sections 15 and 16 of this License; or++    b) Requiring preservation of specified reasonable legal notices or+    author attributions in that material or in the Appropriate Legal+    Notices displayed by works containing it; or++    c) Prohibiting misrepresentation of the origin of that material, or+    requiring that modified versions of such material be marked in+    reasonable ways as different from the original version; or++    d) Limiting the use for publicity purposes of names of licensors or+    authors of the material; or++    e) Declining to grant rights under trademark law for use of some+    trade names, trademarks, or service marks; or++    f) Requiring indemnification of licensors and authors of that+    material by anyone who conveys the material (or modified versions of+    it) with contractual assumptions of liability to the recipient, for+    any liability that these contractual assumptions directly impose on+    those licensors and authors.++  All other non-permissive additional terms are considered "further+restrictions" within the meaning of section 10.  If the Program as you+received it, or any part of it, contains a notice stating that it is+governed by this License along with a term that is a further+restriction, you may remove that term.  If a license document contains+a further restriction but permits relicensing or conveying under this+License, you may add to a covered work material governed by the terms+of that license document, provided that the further restriction does+not survive such relicensing or conveying.++  If you add terms to a covered work in accord with this section, you+must place, in the relevant source files, a statement of the+additional terms that apply to those files, or a notice indicating+where to find the applicable terms.++  Additional terms, permissive or non-permissive, may be stated in the+form of a separately written license, or stated as exceptions;+the above requirements apply either way.++  8. Termination.++  You may not propagate or modify a covered work except as expressly+provided under this License.  Any attempt otherwise to propagate or+modify it is void, and will automatically terminate your rights under+this License (including any patent licenses granted under the third+paragraph of section 11).++  However, if you cease all violation of this License, then your+license from a particular copyright holder is reinstated (a)+provisionally, unless and until the copyright holder explicitly and+finally terminates your license, and (b) permanently, if the copyright+holder fails to notify you of the violation by some reasonable means+prior to 60 days after the cessation.++  Moreover, your license from a particular copyright holder is+reinstated permanently if the copyright holder notifies you of the+violation by some reasonable means, this is the first time you have+received notice of violation of this License (for any work) from that+copyright holder, and you cure the violation prior to 30 days after+your receipt of the notice.++  Termination of your rights under this section does not terminate the+licenses of parties who have received copies or rights from you under+this License.  If your rights have been terminated and not permanently+reinstated, you do not qualify to receive new licenses for the same+material under section 10.++  9. Acceptance Not Required for Having Copies.++  You are not required to accept this License in order to receive or+run a copy of the Program.  Ancillary propagation of a covered work+occurring solely as a consequence of using peer-to-peer transmission+to receive a copy likewise does not require acceptance.  However,+nothing other than this License grants you permission to propagate or+modify any covered work.  These actions infringe copyright if you do+not accept this License.  Therefore, by modifying or propagating a+covered work, you indicate your acceptance of this License to do so.++  10. Automatic Licensing of Downstream Recipients.++  Each time you convey a covered work, the recipient automatically+receives a license from the original licensors, to run, modify and+propagate that work, subject to this License.  You are not responsible+for enforcing compliance by third parties with this License.++  An "entity transaction" is a transaction transferring control of an+organization, or substantially all assets of one, or subdividing an+organization, or merging organizations.  If propagation of a covered+work results from an entity transaction, each party to that+transaction who receives a copy of the work also receives whatever+licenses to the work the party's predecessor in interest had or could+give under the previous paragraph, plus a right to possession of the+Corresponding Source of the work from the predecessor in interest, if+the predecessor has it or can get it with reasonable efforts.++  You may not impose any further restrictions on the exercise of the+rights granted or affirmed under this License.  For example, you may+not impose a license fee, royalty, or other charge for exercise of+rights granted under this License, and you may not initiate litigation+(including a cross-claim or counterclaim in a lawsuit) alleging that+any patent claim is infringed by making, using, selling, offering for+sale, or importing the Program or any portion of it.++  11. Patents.++  A "contributor" is a copyright holder who authorizes use under this+License of the Program or a work on which the Program is based.  The+work thus licensed is called the contributor's "contributor version".++  A contributor's "essential patent claims" are all patent claims+owned or controlled by the contributor, whether already acquired or+hereafter acquired, that would be infringed by some manner, permitted+by this License, of making, using, or selling its contributor version,+but do not include claims that would be infringed only as a+consequence of further modification of the contributor version.  For+purposes of this definition, "control" includes the right to grant+patent sublicenses in a manner consistent with the requirements of+this License.++  Each contributor grants you a non-exclusive, worldwide, royalty-free+patent license under the contributor's essential patent claims, to+make, use, sell, offer for sale, import and otherwise run, modify and+propagate the contents of its contributor version.++  In the following three paragraphs, a "patent license" is any express+agreement or commitment, however denominated, not to enforce a patent+(such as an express permission to practice a patent or covenant not to+sue for patent infringement).  To "grant" such a patent license to a+party means to make such an agreement or commitment not to enforce a+patent against the party.++  If you convey a covered work, knowingly relying on a patent license,+and the Corresponding Source of the work is not available for anyone+to copy, free of charge and under the terms of this License, through a+publicly available network server or other readily accessible means,+then you must either (1) cause the Corresponding Source to be so+available, or (2) arrange to deprive yourself of the benefit of the+patent license for this particular work, or (3) arrange, in a manner+consistent with the requirements of this License, to extend the patent+license to downstream recipients.  "Knowingly relying" means you have+actual knowledge that, but for the patent license, your conveying the+covered work in a country, or your recipient's use of the covered work+in a country, would infringe one or more identifiable patents in that+country that you have reason to believe are valid.++  If, pursuant to or in connection with a single transaction or+arrangement, you convey, or propagate by procuring conveyance of, a+covered work, and grant a patent license to some of the parties+receiving the covered work authorizing them to use, propagate, modify+or convey a specific copy of the covered work, then the patent license+you grant is automatically extended to all recipients of the covered+work and works based on it.++  A patent license is "discriminatory" if it does not include within+the scope of its coverage, prohibits the exercise of, or is+conditioned on the non-exercise of one or more of the rights that are+specifically granted under this License.  You may not convey a covered+work if you are a party to an arrangement with a third party that is+in the business of distributing software, under which you make payment+to the third party based on the extent of your activity of conveying+the work, and under which the third party grants, to any of the+parties who would receive the covered work from you, a discriminatory+patent license (a) in connection with copies of the covered work+conveyed by you (or copies made from those copies), or (b) primarily+for and in connection with specific products or compilations that+contain the covered work, unless you entered into that arrangement,+or that patent license was granted, prior to 28 March 2007.++  Nothing in this License shall be construed as excluding or limiting+any implied license or other defenses to infringement that may+otherwise be available to you under applicable patent law.++  12. No Surrender of Others' Freedom.++  If conditions are imposed on you (whether by court order, agreement or+otherwise) that contradict the conditions of this License, they do not+excuse you from the conditions of this License.  If you cannot convey a+covered work so as to satisfy simultaneously your obligations under this+License and any other pertinent obligations, then as a consequence you may+not convey it at all.  For example, if you agree to terms that obligate you+to collect a royalty for further conveying from those to whom you convey+the Program, the only way you could satisfy both those terms and this+License would be to refrain entirely from conveying the Program.++  13. Use with the GNU Affero General Public License.++  Notwithstanding any other provision of this License, you have+permission to link or combine any covered work with a work licensed+under version 3 of the GNU Affero General Public License into a single+combined work, and to convey the resulting work.  The terms of this+License will continue to apply to the part which is the covered work,+but the special requirements of the GNU Affero General Public License,+section 13, concerning interaction through a network will apply to the+combination as such.++  14. Revised Versions of this License.++  The Free Software Foundation may publish revised and/or new versions of+the GNU General Public License from time to time.  Such new versions will+be similar in spirit to the present version, but may differ in detail to+address new problems or concerns.++  Each version is given a distinguishing version number.  If the+Program specifies that a certain numbered version of the GNU General+Public License "or any later version" applies to it, you have the+option of following the terms and conditions either of that numbered+version or of any later version published by the Free Software+Foundation.  If the Program does not specify a version number of the+GNU General Public License, you may choose any version ever published+by the Free Software Foundation.++  If the Program specifies that a proxy can decide which future+versions of the GNU General Public License can be used, that proxy's+public statement of acceptance of a version permanently authorizes you+to choose that version for the Program.++  Later license versions may give you additional or different+permissions.  However, no additional obligations are imposed on any+author or copyright holder as a result of your choosing to follow a+later version.++  15. Disclaimer of Warranty.++  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.++  16. Limitation of Liability.++  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF+SUCH DAMAGES.++  17. Interpretation of Sections 15 and 16.++  If the disclaimer of warranty and limitation of liability provided+above cannot be given local legal effect according to their terms,+reviewing courts shall apply local law that most closely approximates+an absolute waiver of all civil liability in connection with the+Program, unless a warranty or assumption of liability accompanies a+copy of the Program in return for a fee.++                     END OF TERMS AND CONDITIONS++            How to Apply These Terms to Your New Programs++  If you develop a new program, and you want it to be of the greatest+possible use to the public, the best way to achieve this is to make it+free software which everyone can redistribute and change under these terms.++  To do so, attach the following notices to the program.  It is safest+to attach them to the start of each source file to most effectively+state the exclusion of warranty; and each file should have at least+the "copyright" line and a pointer to where the full notice is found.++    <one line to give the program's name and a brief idea of what it does.>+    Copyright (C) <year>  <name of author>++    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 3 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, see <http://www.gnu.org/licenses/>.++Also add information on how to contact you by electronic and paper mail.++  If the program does terminal interaction, make it output a short+notice like this when it starts in an interactive mode:++    <program>  Copyright (C) <year>  <name of author>+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.+    This is free software, and you are welcome to redistribute it+    under certain conditions; type `show c' for details.++The hypothetical commands `show w' and `show c' should show the appropriate+parts of the General Public License.  Of course, your program's commands+might be different; for a GUI interface, you would use an "about box".++  You should also get your employer (if you work as a programmer) or school,+if any, to sign a "copyright disclaimer" for the program, if necessary.+For more information on this, and how to apply and follow the GNU GPL, see+<http://www.gnu.org/licenses/>.++  The GNU General Public License does not permit incorporating your program+into proprietary programs.  If your program is a subroutine library, you+may consider it more useful to permit linking proprietary applications with+the library.  If this is what you want to do, use the GNU Lesser General+Public License instead of this License.  But first, please read+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ hledger-web.cabal view
@@ -0,0 +1,78 @@+name:           hledger-web+version: 0.13+category:       Finance+synopsis:       A hledger add-on command providing a web interface.+description:    +    A hledger add-on command providing a web interface.+license:        GPL+license-file:   LICENSE+author:         Simon Michael <simon@joyful.com>+maintainer:     Simon Michael <simon@joyful.com>+homepage:       http://hledger.org+bug-reports:    http://code.google.com/p/hledger/issues+stability:      beta+tested-with:    GHC==6.12+cabal-version:  >= 1.6+build-type:     Simple+data-dir:       .hledger+data-files:+                web/combo_select.gif+                web/dhtmlxcombo.js+                web/dhtmlxcommon.js+                web/favicon.ico+                web/hledger.js+                web/jquery.js+                web/jquery.url.js+                web/style.css+extra-tmp-files:+extra-source-files:++source-repository head+  type:     darcs+  location: http://joyful.com/repos/hledger++Flag production+    Description:   Build in production mode, which reads template files only once at startup.+    Default:       False++executable hledger-web+  main-is:        hledger-web.hs+  ghc-options:    -threaded -W+  if flag(production)+      cpp-options: -DPRODUCTION+  other-modules:+                  Hledger.Web.Main+                  Hledger.Web.App+                  Hledger.Web.Files+                  Hledger.Web.Settings+  build-depends:+                  hledger == 0.13+                 ,hledger-lib == 0.13+                 -- ,HUnit+                 ,base >= 3 && < 5+                 ,bytestring+                 -- ,containers+                 -- ,csv+                 ,directory+                 ,filepath+                 -- ,mtl+                 -- ,old-locale+                 -- ,old-time+                 ,parsec+                 -- ,process+                 -- ,regexpr >= 0.5.1+                 ,safe >= 0.2+                 -- ,split == 0.1.*+                 -- ,time+                 -- ,utf8-string >= 0.3.5 && < 0.4+                 ,io-storage >= 0.3 && < 0.4+                 ,yesod >= 0.6.1.2 && < 0.7+                 ,hamlet >= 0.6.0.1 && < 0.7+                 -- ,convertible-text >= 0.3.0.1 && < 0.4+                 -- ,data-object >= 0.3.1.2 && < 0.4+                 ,failure >= 0.1 && < 0.2+                 -- ,persistent == 0.2.*+                 -- ,persistent-sqlite == 0.2.*+                 ,template-haskell >= 2.4 && < 2.6+                 ,wai-extra == 0.2.*+                 ,file-embed == 0.0.*
+ hledger-web.hs view
@@ -0,0 +1,2 @@+#!/usr/bin/env runhaskell+import Hledger.Web.Main (main)