//======================================================================================
//effects
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// Contributors:
//  Justin Palmer (http://encytemedia.com/)
//  Mark Pilgrim (http://diveintomark.org/)
//  Martin Bialasinki
//
// See scriptaculous.js for full license.   
//======================================================================================

//======================================================================================
//dragdrop
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//           (c) 2005 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
// See scriptaculous.js for full license.  
//======================================================================================

//======================================================================================
//controls
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//           (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
//           (c) 2005 Jon Tirsen (http://www.tirsen.com)
// Contributors:
//  Richard Livsey
//  Rahul Bhargava
//  Rob Wills
// See scriptaculous.js for full license.  
//======================================================================================

//======================================================================================
//extend

// ----------------------------------------------------------------------------
// Project   : Extend - Prototype OOP extension
// URL       : <http://www.ivy.fr/js/extend>
// ----------------------------------------------------------------------------
// Author    : Sebastien Pierre                              <sebastien@ivy.fr>
// License   : Revised BSD License
// ----------------------------------------------------------------------------
// Creation  : 08-Sep-2006
// Last mod  : 17-Nov-2006
// ----------------------------------------------------------------------------
//======================================================================================

/************************************************************************************************************
(C) www.dhtmlgoodies.com, October 2005

This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	

Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.

Thank you!

www.dhtmlgoodies.com
Alf Magne Kalleland

************************************************************************************************************/	
	


//======================================================================================

//======================================================================================
// Copyright (c) 2006 - 2007 Gabriel Lanzani (http://www.glanzani.com.ar)
// 
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// SEE CHANGELOG FOR A COMPLETE CHANGES OVERVIEW
// VERSION 0.3

//Modified by Mark Pentland (http://www.golden-orb.com)
//	Butchered this to make it work with pikipimp: icon support and independece from a select box.
//======================================================================================


// script.aculo.us slider.js v1.6.5, Wed Nov 08 14:17:49 CET 2006

// Copyright (c) 2005, 2006 Marty Haught, Thomas Fuchs 
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/

//======================================================================================

/* This notice must be untouched at all times.

wz_jsgraphics.js    v. 3.03
The latest version is available at
http://www.walterzorn.com
or http://www.devira.com
or http://www.walterzorn.de

Copyright (c) 2002-2004 Walter Zorn. All rights reserved.
Created 3. 11. 2002 by Walter Zorn (Web: http://www.walterzorn.com )
Last modified: 28. 1. 2008

Performance optimizations for Internet Explorer
by Thomas Frank and John Holdsworth.
fillPolygon method implemented by Matthieu Haller.

High Performance JavaScript Graphics Library.
Provides methods
- to draw lines, rectangles, ellipses, polygons
	with specifiable line thickness,
- to fill rectangles, polygons, ellipses and arcs
- to draw text.
NOTE: Operations, functions and branching have rather been optimized
to efficiency and speed than to shortness of source code.

LICENSE: LGPL

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License (LGPL) as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library 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
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA,
or see http://www.gnu.org/copyleft/lesser.html
*/


String.prototype.parseColor=function(){
  var _1="#";
  if(this.slice(0,4)=="rgb("){
    var _2=this.slice(4,this.length-1).split(",");
    var i=0;
    do{_1+=parseInt(_2[i]).toColorPart()}
      while(++i<3)
  }else{
    if(this.slice(0,1)=="#"){
      if(this.length==4){
        for(var i=1;i<4;i++){
          _1+=(this.charAt(i)+this.charAt(i)).toLowerCase()
        }
      }
      if(this.length==7){
        _1=this.toLowerCase()
      }
    }
  }
  return(_1.length==7?_1:(arguments[0]||this))
};

Element.collectTextNodes=function(_5){
  return $A($(_5).childNodes).collect(function(_6){
    return(_6.nodeType==3?_6.nodeValue:(_6.hasChildNodes()?Element.collectTextNodes(_6):""))
  }).flatten().join("")
};

Element.collectTextNodesIgnoreClass=function(_7,_8){
  return $A($(_7).childNodes).collect(function(_9){
    return(_9.nodeType==3?_9.nodeValue:((_9.hasChildNodes()&&!Element.hasClassName(_9,_8))?Element.collectTextNodesIgnoreClass(_9,_8):""))
  }).flatten().join("")
};

Element.setContentZoom=function(_a,_b){
  _a=$(_a);
  Element.setStyle(_a,{fontSize:(_b/100)+"em"});
  if(navigator.appVersion.indexOf("AppleWebKit")>0){window.scrollBy(0,0)}
};

Element.getOpacity=function(_c){
  var _d;
  if(_d=Element.getStyle(_c,"opacity")){return parseFloat(_d)}
  if(_d=(Element.getStyle(_c,"filter")||"").match(/alpha\(opacity=(.*)\)/)){
    if(_d[1]){return parseFloat(_d[1])/100}
  }
  return 1
};

Element.setOpacity=function(_e,_f){
  _e=$(_e);
  if(_f==1){
    Element.setStyle(_e,{opacity:(/Gecko/.test(navigator.userAgent)&&!/Konqueror|Safari|KHTML/.test(navigator.userAgent))?0.999999:null});
    if(/MSIE/.test(navigator.userAgent)){
      Element.setStyle(_e,{filter:Element.getStyle(_e,"filter").replace(/alpha\([^\)]*\)/gi,"")})
    }
  }else{
    if(_f<0.00001){_f=0}
    Element.setStyle(_e,{opacity:_f});
    if(/MSIE/.test(navigator.userAgent)){
      Element.setStyle(_e,{filter:Element.getStyle(_e,"filter").replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+_f*100+")"})
    }
  }
};

Element.getInlineOpacity=function(_10){
  return $(_10).style.opacity||""
};

Element.childrenWithClassName=function(_11,_12,_13){
  var _14=new RegExp("(^|\\s)"+_12+"(\\s|$)");
  var _15=$A($(_11).getElementsByTagName("*"))[_13?"detect":"select"](function(c){return(c.className&&c.className.match(_14))});
  if(!_15){_15=[]}return _15
};

Element.forceRerendering=function(_17){
  try{
    _17=$(_17);
    var n=document.createTextNode(" ");
    _17.appendChild(n);
    _17.removeChild(n)
  }catch(e){}
};

Array.prototype.call=function(){
  var _19=arguments;
  this.each(function(f){f.apply(this,_19)})
};

var Effect={tagifyText:function(_1b){
  var _1c="position:relative";
  if(/MSIE/.test(navigator.userAgent)){_1c+=";zoom:1"}_1b=$(_1b);
  $A(_1b.childNodes).each(function(_1d){
    if(_1d.nodeType==3){
      _1d.nodeValue.toArray().each(function(_1e){_1b.insertBefore(Builder.node("span",{style:_1c},_1e==" "?String.fromCharCode(160):_1e),_1d)});Element.remove(_1d)
    }
  })
},

multiple:function(_1f,_20){
  var _21;
  if(((typeof _1f=="object")||(typeof _1f=="function"))&&(_1f.length)){
    _21=_1f
  }else{
    _21=$(_1f).childNodes
  }
  var _22=Object.extend({speed:0.1,delay:0},arguments[2]||{});
  var _23=_22.delay;$A(_21).each(function(_24,_25){
    new _20(_24,Object.extend(_22,{delay:_25*_22.speed+_23}))
  })
},

PAIRS:{"slide":["SlideDown","SlideUp"],"blind":["BlindDown","BlindUp"],"appear":["Appear","Fade"],"blindr":["BlindDownFromRight","BlindUpFromRight"]},

toggle:function(_26,_27){
  _26=$(_26);
  _27=(_27||"appear").toLowerCase();
  var _28=Object.extend({queue:{position:"end",scope:(_26.id||"global"),limit:1}},arguments[2]||{});
  Effect[_26.visible()?Effect.PAIRS[_27][1]:Effect.PAIRS[_27][0]](_26,_28)
}
};

var Effect2=Effect;
Effect.Transitions={};
Effect.Transitions.linear=function(pos){return pos};
Effect.Transitions.sinoidal=function(pos){return(-Math.cos(pos*Math.PI)/2)+0.5};
Effect.Transitions.reverse=function(pos){return 1-pos};
Effect.Transitions.flicker=function(pos){return((-Math.cos(pos*Math.PI)/4)+0.75)+Math.random()/4};
Effect.Transitions.wobble=function(pos){return(-Math.cos(pos*Math.PI*(9*pos))/2)+0.5};
Effect.Transitions.pulse=function(pos){return(Math.floor(pos*10)%2==0?(pos*10-Math.floor(pos*10)):1-(pos*10-Math.floor(pos*10)))};
Effect.Transitions.none=function(pos){return 0};
Effect.Transitions.full=function(pos){return 1};
Effect.ScopedQueue=Class.create();
Object.extend(Object.extend(Effect.ScopedQueue.prototype,Enumerable),
              {initialize:function(){this.effects=[];this.interval=null},
              _each:function(_31){this.effects._each(_31)},
              
              add:function(_32){
                var _33=new Date().getTime();
                var _34=(typeof _32.options.queue=="string")?_32.options.queue:_32.options.queue.position;
                switch(_34){
                  case"front":this.effects.findAll(function(e){return e.state=="idle"}).each(function(e){e.startOn+=_32.finishOn;e.finishOn+=_32.finishOn});
                  break;
                  case"end":_33=this.effects.pluck("finishOn").max()||_33;
                  break
                }
                _32.startOn+=_33;
                _32.finishOn+=_33;
                if(!_32.options.queue.limit||(this.effects.length<_32.options.queue.limit)){
                  this.effects.push(_32)
                }
                if(!this.interval){
                  this.interval=setInterval(this.loop.bind(this),40)
                }
              },
              
              remove:function(_37){
                this.effects=this.effects.reject(function(e){return e==_37});
                if(this.effects.length==0){
                  clearInterval(this.interval);
                  this.interval=null
                }
              },
              
              loop:function(){
                var _39=new Date().getTime();
                this.effects.invoke("loop",_39)
              }
            }
);

Effect.Queues={instances:$H(),get:function(_3a){
  if(typeof _3a!="string"){return _3a}
  if(!this.instances[_3a]){this.instances[_3a]=new Effect.ScopedQueue()}
  return this.instances[_3a]
  }
};

Effect.Queue=Effect.Queues.get("global");
Effect.DefaultOptions={transition:Effect.Transitions.sinoidal,duration:1,fps:25,sync:false,from:0,to:1,delay:0,queue:"parallel"};
Effect.Base=function(){};
Effect.Base.prototype={
  
  position:null,start:function(_3b){
    this.options=Object.extend(Object.extend({},Effect.DefaultOptions),_3b||{});
    this.currentFrame=0;
    this.state="idle";
    this.startOn=this.options.delay*1000;
    this.finishOn=this.startOn+(this.options.duration*1000);
    this.event("beforeStart");
    if(!this.options.sync){
      Effect.Queues.get(typeof this.options.queue=="string"?"global":this.options.queue.scope).add(this)
    }
  },
  
  loop:function(_3c){
    if(_3c>=this.startOn){
      if(_3c>=this.finishOn){
        this.render(1);
        this.cancel();
        this.event("beforeFinish");
        if(this.finish){this.finish()}
        this.event("afterFinish");
        return
      }
      var pos=(_3c-this.startOn)/(this.finishOn-this.startOn);
      var _3e=Math.round(pos*this.options.fps*this.options.duration);
      if(_3e>this.currentFrame){
        this.render(pos);
        this.currentFrame=_3e
      }
    }
  },
  
  render:function(pos){
    if(this.state=="idle"){
      this.state="running";
      this.event("beforeSetup");
      if(this.setup){this.setup()}
      this.event("afterSetup")
    }
    if(this.state=="running"){
      if(this.options.transition){
        pos=this.options.transition(pos)
      }
      pos*=(this.options.to-this.options.from);
      pos+=this.options.from;
      this.position=pos;
      this.event("beforeUpdate");
      if(this.update){this.update(pos)}
      this.event("afterUpdate")
    }
  },
  
  cancel:function(){
    if(!this.options.sync){
      Effect.Queues.get(typeof this.options.queue=="string"?"global":this.options.queue.scope).remove(this)
    }
    this.state="finished"
  },
  
  event:function(_40){
    if(this.options[_40+"Internal"]){this.options[_40+"Internal"](this)}
    if(this.options[_40]){this.options[_40](this)}
  },
  
  inspect:function(){
    return"#<Effect:"+$H(this).inspect()+",options:"+$H(this.options).inspect()+">"
  }
};

Effect.Parallel=Class.create();
Object.extend(Object.extend(Effect.Parallel.prototype,Effect.Base.prototype),{
  
  initialize:function(_41){
    this.effects=_41||[];
    this.start(arguments[1])
  },
  
  update:function(_42){
    this.effects.invoke("render",_42)
  },
  
  finish:function(_43){
    this.effects.each(function(_44){
      _44.render(1);
      _44.cancel();
      _44.event("beforeFinish");
      if(_44.finish){_44.finish(_43)}
      _44.event("afterFinish")
    })
  }
});

Effect.Opacity=Class.create();
Object.extend(Object.extend(Effect.Opacity.prototype,Effect.Base.prototype),{
  
  initialize:function(_45){
    this.element=$(_45);
    if(/MSIE/.test(navigator.userAgent)&&(!this.element.hasLayout)){
      this.element.setStyle({zoom:1})
    }
    var _46=Object.extend({from:this.element.getOpacity()||0,to:1},arguments[1]||{});
    this.start(_46)
  },
  
  update:function(_47){
    this.element.setOpacity(_47)
  }}
);

Effect.Move=Class.create();
Object.extend(Object.extend(Effect.Move.prototype,Effect.Base.prototype),{
  
  initialize:function(_48){
    this.element=$(_48);
    var _49=Object.extend({x:0,y:0,mode:"relative"},arguments[1]||{});
    this.start(_49)
  },
  
  setup:function(){
    this.element.makePositioned();
    this.originalLeft=parseFloat(this.element.getStyle("left")||"0");
    this.originalTop=parseFloat(this.element.getStyle("top")||"0");
    if(this.options.mode=="absolute"){
      this.options.x=this.options.x-this.originalLeft;
      this.options.y=this.options.y-this.originalTop
    }
  },
  
  update:function(_4a){
    this.element.setStyle({left:this.options.x*_4a+this.originalLeft+"px",top:this.options.y*_4a+this.originalTop+"px"})
  }
});

Effect.MoveBy=function(_4b,_4c,_4d){
  return new Effect.Move(_4b,Object.extend({x:_4d,y:_4c},arguments[3]||{}))};
Effect.Scale=Class.create();
Object.extend(Object.extend(Effect.Scale.prototype,Effect.Base.prototype),{
  
  initialize:function(_4e,_4f){
    this.element=$(_4e);
    var _50=Object.extend({scaleX:true,scaleY:true,scaleContent:true,scaleFromCenter:false,scaleMode:"box",scaleFrom:100,scaleTo:_4f},
                           arguments[2]||{});
    this.start(_50)
  },
  
  setup:function(){
    this.restoreAfterFinish=this.options.restoreAfterFinish||false;
    this.elementPositioning=this.element.getStyle("position");
    this.originalStyle={};
    ["top","left","width","height","fontSize"].each(function(k){
      this.originalStyle[k]=this.element.style[k]}.bind(this));
      this.originalTop=this.element.offsetTop;
      this.originalLeft=this.element.offsetLeft;
      var _52=this.element.getStyle("font-size")||"100%";["em","px","%"].each(function(_53){
        if(_52.indexOf(_53)>0){
          this.fontSize=parseFloat(_52);
          this.fontSizeType=_53
        }
      }.bind(this));
    this.factor=(this.options.scaleTo-this.options.scaleFrom)/100;
    this.dims=null;
    if(this.options.scaleMode=="box"){
      this.dims=[this.element.offsetHeight,this.element.offsetWidth]
    }
    if(/^content/.test(this.options.scaleMode)){
      this.dims=[this.element.scrollHeight,this.element.scrollWidth]
    }
    if(!this.dims){
      this.dims=[this.options.scaleMode.originalHeight,this.options.scaleMode.originalWidth]
    }
  },
  
  update:function(_54){
    var _55=(this.options.scaleFrom/100)+(this.factor*_54);
    if(this.options.scaleContent&&this.fontSize){
      this.element.setStyle({fontSize:this.fontSize*_55+this.fontSizeType})
    }
    this.setDimensions(this.dims[0]*_55,this.dims[1]*_55)
  },
  
  finish:function(_56){if(this.restoreAfterFinish){
    this.element.setStyle(this.originalStyle)
  }},
  
  setDimensions:function(_57,_58){
    var d={};
    if(this.options.scaleX){d.width=_58+"px"}
    if(this.options.scaleY&&Math.round(_57)!=0){d.height=Math.round(_57)+"px"}
    if(this.options.scaleFromCenter){
      var _5a=(_57-this.dims[0])/2;
      var _5b=(_58-this.dims[1])/2;
      if(this.elementPositioning=="absolute"){
        if(this.options.scaleY){d.top=this.originalTop-_5a+"px"}
        if(this.options.scaleX){d.left=this.originalLeft-_5b+"px"}
      }else{
        if(this.options.scaleY){d.top=-_5a+"px"}
        if(this.options.scaleX){d.left=-_5b+"px"}
      }
    }
    this.element.setStyle(d)
  }
});

Effect.Highlight=Class.create();
Object.extend(Object.extend(Effect.Highlight.prototype,Effect.Base.prototype),{
  initialize:function(_5c){
    this.element=$(_5c);
    var _5d=Object.extend({startcolor:"#ffff99"},arguments[1]||{});
    this.start(_5d)
  },
  
  setup:function(){
    if(this.element.getStyle("display")=="none"){this.cancel();return}
    this.oldStyle={backgroundImage:this.element.getStyle("background-image")};
    this.element.setStyle({backgroundImage:"none"});
    if(!this.options.endcolor){
      this.options.endcolor=this.element.getStyle("background-color").parseColor("#ffffff")
    }
    if(!this.options.restorecolor){
      this.options.restorecolor=this.element.getStyle("background-color")
    }
    this._base=$R(0,2).map(function(i){
      return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16)}.bind(this));
    this._delta=$R(0,2).map(function(i){
      return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i]}.bind(this))
  },
  
  update:function(_60){
    this.element.setStyle({
      backgroundColor:$R(0,2).inject("#",function(m,v,i){return m+(Math.round(this._base[i]+(this._delta[i]*_60)).toColorPart())}.bind(this))
    })
  },
  
  finish:function(){
    this.element.setStyle(Object.extend(this.oldStyle,{backgroundColor:this.options.restorecolor}))
  }}
);

Effect.ScrollTo=Class.create();
Object.extend(Object.extend(Effect.ScrollTo.prototype,Effect.Base.prototype),{
  initialize:function(_64){
    this.element=$(_64);
    this.start(arguments[1]||{})},setup:function(){
      Position.prepare();
      var _65=Position.cumulativeOffset(this.element);
      if(this.options.offset){_65[1]+=this.options.offset}
      var max=window.innerHeight?window.height-window.innerHeight:document.body.scrollHeight-(document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight);
      this.scrollStart=Position.deltaY;
      this.delta=(_65[1]>max?max:_65[1])-this.scrollStart},update:function(_67){
        Position.prepare();
        window.scrollTo(Position.deltaX,this.scrollStart+(_67*this.delta))
      }
});

Effect.Fade=function(_68){
  _68=$(_68);
  var _69=_68.getInlineOpacity();
  var _6a=Object.extend({from:_68.getOpacity()||1,to:0,
    afterFinishInternal:function(_6b){
      if(_6b.options.to!=0){return}
      _6b.element.hide();
      _6b.element.setStyle({opacity:_69})
    }},arguments[1]||{}
  );
  return new Effect.Opacity(_68,_6a)
};

Effect.Appear=function(_6c){
  _6c=$(_6c);
  var _6d=Object.extend({
    from:(_6c.getStyle("display")=="none"?0:_6c.getOpacity()||0),to:1,
    afterFinishInternal:function(_6e){
      _6e.element.forceRerendering()
    },
    beforeSetup:function(_6f){
      _6f.element.setOpacity(_6f.options.from);
      _6f.element.show()
    }
  },arguments[1]||{}
  );
  return new Effect.Opacity(_6c,_6d)
};

Effect.Puff=function(_70){
  _70=$(_70);
  var _71={opacity:_70.getInlineOpacity(),position:_70.getStyle("position")};
  return new Effect.Parallel([new Effect.Scale(_70,200,{
    sync:true,scaleFromCenter:true,scaleContent:true,restoreAfterFinish:true
  }),new Effect.Opacity(_70,{sync:true,to:0})],Object.extend({duration:1,
  beforeSetupInternal:function(_72){
    _72.effects[0].element.setStyle({position:"absolute"})
  },
  afterFinishInternal:function(_73){
    _73.effects[0].element.hide();
    _73.effects[0].element.setStyle(_71)
  }
  },arguments[1]||{}))
};

Effect.BlindUp=function(_74){
  _74=$(_74);
  _74.makeClipping();
  return new Effect.Scale(_74,0,Object.extend({
    scaleContent:false,scaleX:false,restoreAfterFinish:true,
    afterFinishInternal:function(_75){
      _75.element.hide();
      _75.element.undoClipping()
    }
    },arguments[1]||{})
  )
};

Effect.BlindDown=function(_76){
  _76=$(_76);
  var _77=_76.getDimensions();
  return new Effect.Scale(_76,100,Object.extend({
    scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{
      originalHeight:_77.height,originalWidth:_77.width},restoreAfterFinish:true,
      afterSetup:function(_78){
        _78.element.makeClipping();
        _78.element.setStyle({height:"0px"});
        _78.element.show()
      },
      afterFinishInternal:function(_79){
        _79.element.undoClipping()
      }
    },
    arguments[1]||{})
  )
};

Effect.SwitchOff=function(_7a){
  _7a=$(_7a);
  var _7b=_7a.getInlineOpacity();
  return new Effect.Appear(_7a,{
    duration:0.4,from:0,transition:Effect.Transitions.flicker,
    afterFinishInternal:function(_7c){
      new Effect.Scale(_7c.element,1,{
        duration:0.3,scaleFromCenter:true,scaleX:false,scaleContent:false,
        restoreAfterFinish:true,beforeSetup:function(_7d){
          _7d.element.makePositioned();
          _7d.element.makeClipping()
        },
        afterFinishInternal:function(_7e){
          _7e.element.hide();
          _7e.element.undoClipping();
          _7e.element.undoPositioned();
          _7e.element.setStyle({opacity:_7b})
        }
      })
    }
  }
)};

Effect.DropOut=function(_7f){
  _7f=$(_7f);
  var _80={top:_7f.getStyle("top"),left:_7f.getStyle("left"),opacity:_7f.getInlineOpacity()};
  return new Effect.Parallel([new Effect.Move(_7f,{x:0,y:100,sync:true}),new Effect.Opacity(_7f,{sync:true,to:0})],
    Object.extend({duration:0.5,
      beforeSetup:function(_81){_81.effects[0].element.makePositioned()},
      afterFinishInternal:function(_82){
        _82.effects[0].element.hide();
        _82.effects[0].element.undoPositioned();
        _82.effects[0].element.setStyle(_80)
      }
    },arguments[1]||{})
  )
};

Effect.Shake=function(_83){
  _83=$(_83);
  var _84={top:_83.getStyle("top"),left:_83.getStyle("left")};
  return new Effect.Move(_83,{x:20,y:0,duration:0.05,
    afterFinishInternal:function(_85){
      new Effect.Move(_85.element,{
        x:-40,y:0,duration:0.1,afterFinishInternal:function(_86){
          new Effect.Move(_86.element,{x:40,y:0,duration:0.1,
            afterFinishInternal:function(_87){
              new Effect.Move(_87.element,{x:-40,y:0,duration:0.1,
                afterFinishInternal:function(_88){
                  new Effect.Move(_88.element,{
                    x:40,y:0,duration:0.1,afterFinishInternal:function(_89){
                      new Effect.Move(_89.element,{
                        x:-20,y:0,duration:0.05,
                          afterFinishInternal:function(_8a){
                            _8a.element.undoPositioned();
                            _8a.element.setStyle(_84)
                          }
                        }
                      )
                    }
                  })
                }
              })
            }}
          )
        }
      })
    }
  })
};

Effect.SlideDown=function(_8b){
  _8b=$(_8b);
  _8b.cleanWhitespace();
  var _8c=$(_8b.firstChild).getStyle("bottom");
  var _8d=_8b.getDimensions();
  return new Effect.Scale(_8b,100,Object.extend({
    scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:_8d.height,originalWidth:_8d.width},restoreAfterFinish:true,
      afterSetup:function(_8e){
        _8e.element.makePositioned();
        _8e.element.firstChild.makePositioned();
        if(window.opera){
          _8e.element.setStyle({top:""})
        }
        _8e.element.makeClipping();
        _8e.element.setStyle({height:"0px"});
        _8e.element.show()
      },
      
      afterUpdateInternal:function(_8f){
        _8f.element.firstChild.setStyle({
          bottom:(_8f.dims[0]-_8f.element.clientHeight)+"px"}
        )
      },
      
      afterFinishInternal:function(_90){
        _90.element.undoClipping();
        if(/MSIE/.test(navigator.userAgent)){
          _90.element.undoPositioned();
          _90.element.firstChild.undoPositioned()
        }else{
          _90.element.firstChild.undoPositioned();
          _90.element.undoPositioned()
        }
        _90.element.firstChild.setStyle({bottom:_8c})
      }
    },arguments[1]||{})
  )
};

Effect.SlideUp=function(_91){
  _91=$(_91);
  _91.cleanWhitespace();
  var _92=$(_91.firstChild).getStyle("bottom");
  return new Effect.Scale(_91,0,Object.extend({
    scaleContent:false,scaleX:false,scaleMode:"box",scaleFrom:100,restoreAfterFinish:true,
    
    beforeStartInternal:function(_93){
      _93.element.makePositioned();
      _93.element.firstChild.makePositioned();
      if(window.opera){_93.element.setStyle({top:""})}
      _93.element.makeClipping();
      _93.element.show()
    },
    
    afterUpdateInternal:function(_94){
      _94.element.firstChild.setStyle({bottom:(_94.dims[0]-_94.element.clientHeight)+"px"})
    },
    
    afterFinishInternal:function(_95){
      _95.element.hide();
      _95.element.undoClipping();
      _95.element.firstChild.undoPositioned();
      _95.element.undoPositioned();
      _95.element.setStyle({bottom:_92})
    }
  },arguments[1]||{}))
};

Effect.Squish=function(_96){
  return new Effect.Scale(_96,window.opera?1:0,{
    restoreAfterFinish:true,beforeSetup:function(_97){
      _97.element.makeClipping(_97.element)},
        afterFinishInternal:function(_98){
          _98.element.hide(_98.element);
          _98.element.undoClipping(_98.element)
        }
      }
    )
};

Effect.Grow=function(_99){
  _99=$(_99);
  var _9a=Object.extend({
    direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.full},
    arguments[1]||{}
  );
  var _9b={top:_99.style.top,left:_99.style.left,height:_99.style.height,width:_99.style.width,opacity:_99.getInlineOpacity()};
  var _9c=_99.getDimensions();
  var _9d,initialMoveY;
  var _9e,moveY;
  switch(_9a.direction){
    case"top-left":
      _9d=initialMoveY=_9e=moveY=0;
    break;
    case"top-right":
      _9d=_9c.width;initialMoveY=moveY=0;
      _9e=-_9c.width;
    break;
    case"bottom-left":
      _9d=_9e=0;
      initialMoveY=_9c.height;
      moveY=-_9c.height;
    break;
    case"bottom-right":
      _9d=_9c.width;
      initialMoveY=_9c.height;
      _9e=-_9c.width;
      moveY=-_9c.height;
    break;
    case"center":
      _9d=_9c.width/2;
      initialMoveY=_9c.height/2;
      _9e=-_9c.width/2;
      moveY=-_9c.height/2;
    break
  }
  return new Effect.Move(_99,{
    x:_9d,y:initialMoveY,duration:0.01,
      
      beforeSetup:function(_9f){
        _9f.element.hide();
        _9f.element.makeClipping();
        _9f.element.makePositioned()
      },
      
      afterFinishInternal:function(_a0){
        new Effect.Parallel([new Effect.Opacity(_a0.element,{sync:true,to:1,from:0,transition:_9a.opacityTransition}),new Effect.Move(_a0.element,{x:_9e,y:moveY,sync:true,transition:_9a.moveTransition}),new Effect.Scale(_a0.element,100,{scaleMode:{originalHeight:_9c.height,originalWidth:_9c.width},sync:true,scaleFrom:window.opera?1:0,transition:_9a.scaleTransition,restoreAfterFinish:true})],
          Object.extend({beforeSetup:function(_a1){_a1.effects[0].element.setStyle({height:"0px"});_a1.effects[0].element.show()},afterFinishInternal:function(_a2){_a2.effects[0].element.undoClipping();_a2.effects[0].element.undoPositioned();_a2.effects[0].element.setStyle(_9b)}},_9a))
      }
  })
};

Effect.Shrink=function(_a3){
  _a3=$(_a3);
  var _a4=Object.extend({
    direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.none},
      arguments[1]||{});
  var _a5={
    top:_a3.style.top,left:_a3.style.left,height:_a3.style.height,width:_a3.style.width,opacity:_a3.getInlineOpacity()
  };
  var _a6=_a3.getDimensions();
  var _a7,moveY;
  switch(_a4.direction){
    case"top-left":
      _a7=moveY=0;
    break;
    case"top-right":
      _a7=_a6.width;
      moveY=0;
    break;
    case"bottom-left":
      _a7=0;
      moveY=_a6.height;
    break;
    case"bottom-right":
      _a7=_a6.width;
      moveY=_a6.height;
    break;
    case"center":
      _a7=_a6.width/2;
      moveY=_a6.height/2;
    break
  }
  return new Effect.Parallel([new Effect.Opacity(_a3,{sync:true,to:0,from:1,transition:_a4.opacityTransition}),new Effect.Scale(_a3,window.opera?1:0,{sync:true,transition:_a4.scaleTransition,restoreAfterFinish:true}),new Effect.Move(_a3,{x:_a7,y:moveY,sync:true,transition:_a4.moveTransition})],
    Object.extend({
      beforeStartInternal:function(_a8){
        _a8.effects[0].element.makePositioned();
        _a8.effects[0].element.makeClipping()
      },
      
      afterFinishInternal:function(_a9){
        _a9.effects[0].element.hide();
        _a9.effects[0].element.undoClipping();
        _a9.effects[0].element.undoPositioned();
        _a9.effects[0].element.setStyle(_a5)
      }
    },_a4))
};

Effect.Pulsate=function(_aa){
  _aa=$(_aa);
  var _ab=arguments[1]||{};
  var _ac=_aa.getInlineOpacity();
  var _ad=_ab.transition||Effect.Transitions.sinoidal;
  var _ae=function(pos){return _ad(1-Effect.Transitions.pulse(pos))};
  _ae.bind(_ad);
  return new Effect.Opacity(_aa,Object.extend(Object.extend({
    duration:3,from:0,
    afterFinishInternal:function(_b0){
      _b0.element.setStyle({opacity:_ac})
    }
  },_ab),{transition:_ae}))
};

Effect.Fold=function(_b1){
  _b1=$(_b1);
  var _b2={top:_b1.style.top,left:_b1.style.left,width:_b1.style.width,height:_b1.style.height};
  Element.makeClipping(_b1);
  return new Effect.Scale(_b1,5,Object.extend({
    scaleContent:false,scaleX:false,
    afterFinishInternal:function(_b3){
      new Effect.Scale(_b1,1,{scaleContent:false,scaleY:false,afterFinishInternal:function(_b4){_b4.element.hide();_b4.element.undoClipping();_b4.element.setStyle(_b2)}})
    }
  },arguments[1]||{}))
};

["setOpacity","getOpacity","getInlineOpacity","forceRerendering","setContentZoom","collectTextNodes","collectTextNodesIgnoreClass","childrenWithClassName"].each(function(f){Element.Methods[f]=Element[f]});
Element.Methods.visualEffect=function(_b6,_b7,_b8){
  s=_b7.gsub(/_/,"-").camelize();
  effect_class=s.charAt(0).toUpperCase()+s.substring(1);
  new Effect[effect_class](_b6,_b8);
  return $(_b6)
};

Element.addMethods();
Effect.BlindUpFromRight=function(_b9){
  _b9=$(_b9);
  _b9.makeClipping();
  return new Effect.Scale(_b9,0,Object.extend({
    scaleContent:false,scaleY:false,restoreAfterFinish:true,
    afterFinishInternal:function(_ba){
      _ba.element.hide();
      _ba.element.undoClipping()
    }
  },arguments[1]||{}))
};

Effect.BlindDownFromRight=function(_bb){
  _bb=$(_bb);
  var _bc=_bb.getDimensions();
  return new Effect.Scale(_bb,100,Object.extend({
    scaleContent:false,scaleY:false,scaleFrom:0,scaleMode:{
      originalHeight:_bc.height,originalWidth:_bc.width},
      restoreAfterFinish:true,
      afterSetup:function(_bd){
        _bd.element.makeClipping();
        _bd.element.setStyle({width:"0px"});
        _bd.element.show()
      },
      
      afterFinishInternal:function(_be){
        _be.element.undoClipping()
      }
    },arguments[1]||{})
  )
};

var Autocompleter={};
Autocompleter.Base=function(){};
Autocompleter.Base.prototype={
  baseInitialize:function(_1,_2,_3){
    this.element=$(_1);
    this.update=$(_2);
    this.hasFocus=false;
    this.changed=false;
    this.active=false;
    this.index=0;
    this.entryCount=0;
    if(this.setOptions){
      this.setOptions(_3)
    }else{
      this.options=_3||{}
    }
    this.options.paramName=this.options.paramName||this.element.name;
    this.options.tokens=this.options.tokens||[];
    this.options.frequency=this.options.frequency||0.4;
    this.options.minChars=this.options.minChars||1;
    this.options.onShow=this.options.onShow||function(_4,_5){
      if(!_5.style.position||_5.style.position=="absolute"){
        _5.style.position="absolute";
        Position.clone(_4,_5,{setHeight:false,offsetTop:_4.offsetHeight})
      }
      Effect.Appear(_5,{duration:0.15})
    };
    this.options.onHide=this.options.onHide||function(_6,_7){
      new Effect.Fade(_7,{duration:0.15})
    };
    if(typeof(this.options.tokens)=="string"){
      this.options.tokens=new Array(this.options.tokens)
    }
    this.observer=null;
    this.element.setAttribute("autocomplete","off");
    Element.hide(this.update);
    Event.observe(this.element,"blur",this.onBlur.bindAsEventListener(this));
    Event.observe(this.element,"keypress",this.onKeyPress.bindAsEventListener(this))},
      
      show:function(){
        if(Element.getStyle(this.update,"display")=="none"){
          this.options.onShow(this.element,this.update)
        }
        if(!this.iefix&&(navigator.appVersion.indexOf("MSIE")>0)&&(navigator.userAgent.indexOf("Opera")<0)&&(Element.getStyle(this.update,"position")=="absolute")){
          new Insertion.After(this.update,"<iframe id=\""+this.update.id+"_iefix\" "+"style=\"display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);\" "+"src=\"javascript:false;\" frameborder=\"0\" scrolling=\"no\"></iframe>");
          this.iefix=$(this.update.id+"_iefix")
        }
        if(this.iefix){
          setTimeout(this.fixIEOverlapping.bind(this),50)
        }
      },
      
      fixIEOverlapping:function(){
        Position.clone(this.update,this.iefix);
        this.iefix.style.zIndex=1;
        this.update.style.zIndex=2;Element.show(this.iefix)
      },
      
      hide:function(){
        this.stopIndicator();
        if(Element.getStyle(this.update,"display")!="none"){
          this.options.onHide(this.element,this.update)
        }
        if(this.iefix){
          Element.hide(this.iefix)
        }
      },
      
      startIndicator:function(){
        if(this.options.indicator){
          Element.show(this.options.indicator)
        }
      },
      
      stopIndicator:function(){
        if(this.options.indicator){Element.hide(this.options.indicator)}
      },
      
      onKeyPress:function(_8){
        if(this.active){
          switch(_8.keyCode){
            case Event.KEY_TAB:case Event.KEY_RETURN:this.selectEntry();
              Event.stop(_8);
            case Event.KEY_ESC:this.hide();
              this.active=false;
              Event.stop(_8);
              return;
            case Event.KEY_LEFT:case Event.KEY_RIGHT:return;
            case Event.KEY_UP:this.markPrevious();
              this.render();
              if(navigator.appVersion.indexOf("AppleWebKit")>0){Event.stop(_8)}
              return;
            case Event.KEY_DOWN:this.markNext();
              this.render();
              if(navigator.appVersion.indexOf("AppleWebKit")>0){
                Event.stop(_8)
              }
              return
          }
        }else{
          if(_8.keyCode==Event.KEY_TAB||_8.keyCode==Event.KEY_RETURN||(navigator.appVersion.indexOf("AppleWebKit")>0&&_8.keyCode==0)){return}
        }
        this.changed=true;
        this.hasFocus=true;
        if(this.observer){clearTimeout(this.observer)}
        this.observer=setTimeout(this.onObserverEvent.bind(this),this.options.frequency*1000)
      },
      
      activate:function(){
        this.changed=false;
        this.hasFocus=true;
        this.getUpdatedChoices()
      },
      
      onHover:function(_9){
        var _a=Event.findElement(_9,"LI");
        if(this.index!=_a.autocompleteIndex){this.index=_a.autocompleteIndex;this.render()}
        Event.stop(_9)},
          onClick:function(_b){
            var _c=Event.findElement(_b,"LI");
            this.index=_c.autocompleteIndex;
            this.selectEntry();
            this.hide()
          },
          
          onBlur:function(_d){
            setTimeout(this.hide.bind(this),250);
            this.hasFocus=false;
            this.active=false
          },
          
          render:function(){
            if(this.entryCount>0){
              for(var i=0;i<this.entryCount;i++){
                this.index==i?Element.addClassName(this.getEntry(i),"selected"):Element.removeClassName(this.getEntry(i),"selected")
              }
              if(this.hasFocus){
                this.show();
                this.active=true
              }
            }else{
              this.active=false;this.hide()
            }
          },
          
          markPrevious:function(){
            if(this.index>0){
              this.index--
            }else{
              this.index=this.entryCount-1
            }
          },
          
          markNext:function(){
            if(this.index<this.entryCount-1){
              this.index++
            }else{
              this.index=0
            }
          },
          
          getEntry:function(_f){return this.update.firstChild.childNodes[_f]},
          
          getCurrentEntry:function(){return this.getEntry(this.index)},
          
          selectEntry:function(){this.active=false;this.updateElement(this.getCurrentEntry())},
          
          updateElement:function(_10){
            if(this.options.updateElement){
              this.options.updateElement(_10);
              return
            }
            var _11="";
            if(this.options.select){
              var _12=document.getElementsByClassName(this.options.select,_10)||[];
              if(_12.length>0){
                _11=Element.collectTextNodes(_12[0],this.options.select)
              }
            }else{
              _11=Element.collectTextNodesIgnoreClass(_10,"informal")
            }
            var _13=this.findLastToken();
            if(_13!=-1){
              var _14=this.element.value.substr(0,_13+1);
              var _15=this.element.value.substr(_13+1).match(/^\s+/);
              if(_15){_14+=_15[0]}
              this.element.value=_14+_11
            }else{
              this.element.value=_11
            }
            this.element.focus();
            if(this.options.afterUpdateElement){
              this.options.afterUpdateElement(this.element,_10)
            }
          },
          
          updateChoices:function(_16){
            if(!this.changed&&this.hasFocus){
              this.update.innerHTML=_16;
              Element.cleanWhitespace(this.update);
              Element.cleanWhitespace(this.update.firstChild);
              if(this.update.firstChild&&this.update.firstChild.childNodes){
                this.entryCount=this.update.firstChild.childNodes.length;
                for(var i=0;i<this.entryCount;i++){
                  var _18=this.getEntry(i);
                  _18.autocompleteIndex=i;
                  this.addObservers(_18)
                }
              }else{
                this.entryCount=0
              }
              this.stopIndicator();
              this.index=0;
              this.render()
            }
          },
          
          addObservers:function(_19){
            Event.observe(_19,"mouseover",this.onHover.bindAsEventListener(this));
            Event.observe(_19,"click",this.onClick.bindAsEventListener(this))
          },
          
          onObserverEvent:function(){
            this.changed=false;
            if(this.getToken().length>=this.options.minChars){
              this.startIndicator();
              this.getUpdatedChoices()
            }else{
              this.active=false;
              this.hide()
            }
          },
          
          getToken:function(){
            var _1a=this.findLastToken();
            if(_1a!=-1){
              var ret=this.element.value.substr(_1a+1).replace(/^\s+/,"").replace(/\s+$/,"")
            }else{
              var ret=this.element.value
            }
            return/\n/.test(ret)?"":ret
          },
          
          findLastToken:function(){
            var _1d=-1;
            for(var i=0;i<this.options.tokens.length;i++){
              var _1f=this.element.value.lastIndexOf(this.options.tokens[i]);
              if(_1f>_1d){_1d=_1f}
            }
            return _1d
          }
};

Ajax.Autocompleter=Class.create();
Object.extend(Object.extend(Ajax.Autocompleter.prototype,Autocompleter.Base.prototype),{
  initialize:function(_20,_21,url,_23){
    this.baseInitialize(_20,_21,_23);
    this.options.asynchronous=true;
    this.options.onComplete=this.onComplete.bind(this);
    this.options.defaultParams=this.options.parameters||null;
    this.url=url
  },
  
  getUpdatedChoices:function(){
    entry=encodeURIComponent(this.options.paramName)+"="+encodeURIComponent(this.getToken());
    this.options.parameters=this.options.callback?this.options.callback(this.element,entry):entry;
    if(this.options.defaultParams){
      this.options.parameters+="&"+this.options.defaultParams
    }
    new Ajax.Request(this.url,this.options)
  },
  
  onComplete:function(_24){
    this.updateChoices(_24.responseText)
  }}
);

Autocompleter.Local=Class.create();
Autocompleter.Local.prototype=Object.extend(new Autocompleter.Base(),{
  initialize:function(_25,_26,_27,_28){
    this.baseInitialize(_25,_26,_28);
    this.options.array=_27
  },
  
  getUpdatedChoices:function(){
    this.updateChoices(this.options.selector(this))
  },
  
  setOptions:function(_29){
    this.options=Object.extend({choices:10,partialSearch:true,partialChars:2,ignoreCase:true,fullSearch:false,
    selector:function(_2a){
      var ret=[];
      var _2c=[];
      var _2d=_2a.getToken();
      var _2e=0;
      for(var i=0;i<_2a.options.array.length&&ret.length<_2a.options.choices;i++){
        var _30=_2a.options.array[i];
        var _31=_2a.options.ignoreCase?_30.toLowerCase().indexOf(_2d.toLowerCase()):_30.indexOf(_2d);
        while(_31!=-1){
          if(_31==0&&_30.length!=_2d.length){
            ret.push("<li><strong>"+_30.substr(0,_2d.length)+"</strong>"+_30.substr(_2d.length)+"</li>");
            break
          }else{
            if(_2d.length>=_2a.options.partialChars&&_2a.options.partialSearch&&_31!=-1){
              if(_2a.options.fullSearch||/\s/.test(_30.substr(_31-1,1))){
                _2c.push("<li>"+_30.substr(0,_31)+"<strong>"+_30.substr(_31,_2d.length)+"</strong>"+_30.substr(_31+_2d.length)+"</li>");
                break
              }
            }
          }
          _31=_2a.options.ignoreCase?_30.toLowerCase().indexOf(_2d.toLowerCase(),_31+1):_30.indexOf(_2d,_31+1)
        }
      }
      if(_2c.length){ret=ret.concat(_2c.slice(0,_2a.options.choices-ret.length))}
      return"<ul>"+ret.join("")+"</ul>"}},_29||{})
    }
  }
);

Field.scrollFreeActivate=function(_32){
  setTimeout(function(){
    Field.activate(_32)},1)
};

Ajax.InPlaceEditor=Class.create();
Ajax.InPlaceEditor.defaultHighlightColor="#FFFF99";
Ajax.InPlaceEditor.prototype={initialize:function(_33,url,_35){
  this.url=url;
  this.element=$(_33);
  this.options=Object.extend({okButton:true,okText:"ok",cancelLink:true,cancelText:"cancel",savingText:"Saving...",clickToEditText:"Click to edit",okText:"ok",rows:1,
    onComplete:function(_36,_37){
      new Effect.Highlight(_37,{startcolor:this.options.highlightcolor})
    },
    
    onFailure:function(_38){
      alert("Error communicating with the server: "+_38.responseText.stripTags())
    },
    
    callback:function(_39){
      return Form.serialize(_39)
    },
    
    handleLineBreaks:true,loadingText:"Loading...",savingClassName:"inplaceeditor-saving",loadingClassName:"inplaceeditor-loading",formClassName:"inplaceeditor-form",highlightcolor:Ajax.InPlaceEditor.defaultHighlightColor,highlightendcolor:"#FFFFFF",externalControl:null,submitOnBlur:false,ajaxOptions:{},evalScripts:false},_35||{}
  );
  if(!this.options.formId&&this.element.id){
    this.options.formId=this.element.id+"-inplaceeditor";
    if($(this.options.formId)){this.options.formId=null}
  }
  if(this.options.externalControl){
    this.options.externalControl=$(this.options.externalControl)
  }
  this.originalBackground=Element.getStyle(this.element,"background-color");
  if(!this.originalBackground){this.originalBackground="transparent"}
  this.element.title=this.options.clickToEditText;
  this.onclickListener=this.enterEditMode.bindAsEventListener(this);
  this.mouseoverListener=this.enterHover.bindAsEventListener(this);
  this.mouseoutListener=this.leaveHover.bindAsEventListener(this);
  Event.observe(this.element,"click",this.onclickListener);
  Event.observe(this.element,"mouseover",this.mouseoverListener);
  Event.observe(this.element,"mouseout",this.mouseoutListener);
  if(this.options.externalControl){
    Event.observe(this.options.externalControl,"click",this.onclickListener);
    Event.observe(this.options.externalControl,"mouseover",this.mouseoverListener);
    Event.observe(this.options.externalControl,"mouseout",this.mouseoutListener)
  }
},

enterEditMode:function(evt){
  if(this.saving){return}
  if(this.editing){return}
  this.editing=true;
  this.onEnterEditMode();
  if(this.options.externalControl){
    Element.hide(this.options.externalControl)
  }
  Element.hide(this.element);
  this.createForm();
  this.element.parentNode.insertBefore(this.form,this.element);
  Field.scrollFreeActivate(this.editField);
  if(evt){Event.stop(evt)}
  return false
},

createForm:function(){
  this.form=document.createElement("form");
  this.form.id=this.options.formId;
  Element.addClassName(this.form,this.options.formClassName);
  this.form.onsubmit=this.onSubmit.bind(this);
  this.createEditField();
  if(this.options.textarea){
    var br=document.createElement("br");
    this.form.appendChild(br)
  }
  if(this.options.okButton){
    okButton=document.createElement("input");
    okButton.type="submit";
    okButton.value=this.options.okText;okButton.className="editor_ok_button";
    this.form.appendChild(okButton)
  }
  if(this.options.cancelLink){
    cancelLink=document.createElement("a");
    cancelLink.href="#";
    cancelLink.appendChild(document.createTextNode(this.options.cancelText));
    cancelLink.onclick=this.onclickCancel.bind(this);
    cancelLink.className="editor_cancel";
    this.form.appendChild(cancelLink)
  }
},

hasHTMLLineBreaks:function(_3c){
  if(!this.options.handleLineBreaks){return false}
  return _3c.match(/<br/i)||_3c.match(/<p>/i)
},

convertHTMLLineBreaks:function(_3d){
  return _3d.replace(/<br>/gi,"\n").replace(/<br\/>/gi,"\n").replace(/<\/p>/gi,"\n").replace(/<p>/gi,"")
},

createEditField:function(){
  var _3e;
  if(this.options.loadTextURL){
    _3e=this.options.loadingText
  }else{
    _3e=this.getText()
  }
  var obj=this;
  if(this.options.rows==1&&!this.hasHTMLLineBreaks(_3e)){
    this.options.textarea=false;
    var _40=document.createElement("input");
    _40.obj=this;
    _40.type="text";
    _40.name="value";
    _40.value=_3e;
    _40.style.backgroundColor=this.options.highlightcolor;
    _40.className="editor_field";
    var _41=this.options.size||this.options.cols||0;
    if(_41!=0){_40.size=_41}
    if(this.options.submitOnBlur){_40.onblur=this.onSubmit.bind(this)}
    this.editField=_40
  }else{
    this.options.textarea=true;
    var _42=document.createElement("textarea");
    _42.obj=this;
    _42.name="value";
    _42.value=this.convertHTMLLineBreaks(_3e);
    _42.rows=this.options.rows;
    _42.cols=this.options.cols||40;
    _42.className="editor_field";
    if(this.options.submitOnBlur){_42.onblur=this.onSubmit.bind(this)}
    this.editField=_42
  }
  if(this.options.loadTextURL){this.loadExternalText()}
  this.form.appendChild(this.editField)
},

getText:function(){
  return this.element.innerHTML
},

loadExternalText:function(){
  Element.addClassName(this.form,this.options.loadingClassName);
  this.editField.disabled=true;
  new Ajax.Request(this.options.loadTextURL,Object.extend({
    asynchronous:true,onComplete:this.onLoadedExternalText.bind(this)
  },this.options.ajaxOptions)
  )
},

onLoadedExternalText:function(_43){
  Element.removeClassName(this.form,this.options.loadingClassName);
  this.editField.disabled=false;
  this.editField.value=_43.responseText.stripTags()
},

onclickCancel:function(){
  this.onComplete();
  this.leaveEditMode();
  return false
},

onFailure:function(_44){
  this.options.onFailure(_44);
  if(this.oldInnerHTML){
    this.element.innerHTML=this.oldInnerHTML;
    this.oldInnerHTML=null
  }
  return false
},

onSubmit:function(){
  var _45=this.form;
  var _46=this.editField.value;
  this.onLoading();
  if(this.options.evalScripts){
    new Ajax.Request(this.url,Object.extend({
      parameters:this.options.callback(_45,_46),onComplete:this.onComplete.bind(this),onFailure:this.onFailure.bind(this),asynchronous:true,evalScripts:true
    },this.options.ajaxOptions))
  }else{
    new Ajax.Updater({
      success:this.element,failure:null},this.url,Object.extend({parameters:this.options.callback(_45,_46),onComplete:this.onComplete.bind(this),onFailure:this.onFailure.bind(this)
      },this.options.ajaxOptions)
    )
  }
  if(arguments.length>1){Event.stop(arguments[0])}
  return false
},

onLoading:function(){
  this.saving=true;
  this.removeForm();
  this.leaveHover();
  this.showSaving()
},

showSaving:function(){
  this.oldInnerHTML=this.element.innerHTML;
  this.element.innerHTML=this.options.savingText;
  Element.addClassName(this.element,this.options.savingClassName);
  this.element.style.backgroundColor=this.originalBackground;
  Element.show(this.element)
},

removeForm:function(){
  if(this.form){
    if(this.form.parentNode){Element.remove(this.form)}
    this.form=null
  }
},

enterHover:function(){
  if(this.saving){return}
  this.element.style.backgroundColor=this.options.highlightcolor;
  if(this.effect){this.effect.cancel()}
  Element.addClassName(this.element,this.options.hoverClassName)
},

leaveHover:function(){
  if(this.options.backgroundColor){this.element.style.backgroundColor=this.oldBackground}
  Element.removeClassName(this.element,this.options.hoverClassName);
  if(this.saving){return}
  this.effect=new Effect.Highlight(this.element,{
    startcolor:this.options.highlightcolor,endcolor:this.options.highlightendcolor,restorecolor:this.originalBackground
  })
},

leaveEditMode:function(){
  Element.removeClassName(this.element,this.options.savingClassName);
  this.removeForm();
  this.leaveHover();
  this.element.style.backgroundColor=this.originalBackground;
  Element.show(this.element);
  if(this.options.externalControl){Element.show(this.options.externalControl)}
  this.editing=false;
  this.saving=false;
  this.oldInnerHTML=null;
  this.onLeaveEditMode()
},

onComplete:function(_47){
  this.leaveEditMode();
  this.options.onComplete.bind(this)(_47,this.element)
},

onEnterEditMode:function(){},

onLeaveEditMode:function(){},

dispose:function(){
  if(this.oldInnerHTML){this.element.innerHTML=this.oldInnerHTML}
  this.leaveEditMode();
  Event.stopObserving(this.element,"click",this.onclickListener);
  Event.stopObserving(this.element,"mouseover",this.mouseoverListener);
  Event.stopObserving(this.element,"mouseout",this.mouseoutListener);
  if(this.options.externalControl){
    Event.stopObserving(this.options.externalControl,"click",this.onclickListener);
    Event.stopObserving(this.options.externalControl,"mouseover",this.mouseoverListener);
    Event.stopObserving(this.options.externalControl,"mouseout",this.mouseoutListener)
  }
}};

Ajax.InPlaceCollectionEditor=Class.create();
Object.extend(Ajax.InPlaceCollectionEditor.prototype,Ajax.InPlaceEditor.prototype);
Object.extend(Ajax.InPlaceCollectionEditor.prototype,{
  createEditField:function(){
    if(!this.cached_selectTag){
      var _48=document.createElement("select");
      var _49=this.options.collection||[];
      var _4a;
      _49.each(function(e,i){
        _4a=document.createElement("option");
        _4a.value=(e instanceof Array)?e[0]:e;
        if(this.options.value==_4a.value){_4a.selected=true}
        _4a.appendChild(document.createTextNode((e instanceof Array)?e[1]:e));
        _48.appendChild(_4a)
      }.bind(this));
      this.cached_selectTag=_48
    }
    this.editField=this.cached_selectTag;
    if(this.options.loadTextURL){this.loadExternalText()}
    this.form.appendChild(this.editField);
    this.options.callback=function(_4d,_4e){return"value="+encodeURIComponent(_4e)}
    }
  }
);

Form.Element.DelayedObserver=Class.create();
Form.Element.DelayedObserver.prototype={
  initialize:function(_4f,_50,_51){
    this.delay=_50||0.5;
    this.element=$(_4f);
    this.callback=_51;
    this.timer=null;
    this.lastValue=$F(this.element);
    Event.observe(this.element,"keyup",this.delayedListener.bindAsEventListener(this))
  },
  
  delayedListener:function(_52){
    if(this.lastValue==$F(this.element)){return}
    if(this.timer){clearTimeout(this.timer)}
    this.timer=setTimeout(this.onTimerEvent.bind(this),this.delay*1000);
    this.lastValue=$F(this.element)
  },
  
  onTimerEvent:function(){
    this.timer=null;this.callback(this.element,$F(this.element))
  }
};

var Droppables={drops:[],remove:function(_1){
  this.drops=this.drops.reject(function(d){return d.element==$(_1)})
},
  add:function(_3){
    _3=$(_3);
    var _4=Object.extend({greedy:true,hoverclass:null,tree:false},arguments[1]||{});
    if(_4.containment){
      _4._containers=[];
      var _5=_4.containment;
      if((typeof _5=="object")&&(_5.constructor==Array)){
        _5.each(function(c){_4._containers.push($(c))})
      }else{
        _4._containers.push($(_5))
      }
    }
    if(_4.accept){_4.accept=[_4.accept].flatten()}
    Element.makePositioned(_3);
    _4.element=_3;
    this.drops.push(_4)
  },
  
  findDeepestChild:function(_7){
    deepest=_7[0];
    for(i=1;i<_7.length;++i){
      if(Element.isParent(_7[i].element,deepest.element)){deepest=_7[i]}
    }
    return deepest
  },
  
  isContained:function(_8,_9){
    var _a;
    if(_9.tree){_a=_8.treeNode}else{_a=_8.parentNode}
    return _9._containers.detect(function(c){return _a==c})
  },
  
  isAffected:function(_c,_d,_e){
    return((_e.element!=_d)&&((!_e._containers)||this.isContained(_d,_e))&&((!_e.accept)||(Element.classNames(_d).detect(function(v){return _e.accept.include(v)})))&&Position.within(_e.element,_c[0],_c[1]))
  },
  
  deactivate:function(_10){
    if(_10.hoverclass){
      Element.removeClassName(_10.element,_10.hoverclass)
    }
    this.last_active=null
  },
  
  activate:function(_11){
    if(_11.hoverclass){
      Element.addClassName(_11.element,_11.hoverclass)
    }
    this.last_active=_11
  },
  
  show:function(_12,_13){
    if(!this.drops.length){return}
    var _14=[];
    if(this.last_active){
      this.deactivate(this.last_active)
    }
    this.drops.each(function(_15){
      if(Droppables.isAffected(_12,_13,_15)){_14.push(_15)}
    });
    if(_14.length>0){
      drop=Droppables.findDeepestChild(_14);
      Position.within(drop.element,_12[0],_12[1]);
      if(drop.onHover){
        drop.onHover(_13,drop.element,Position.overlap(drop.overlap,drop.element))
      }
      Droppables.activate(drop)
    }
  },
  
  fire:function(_16,_17){
    if(!this.last_active){return}
    Position.prepare();
    if(this.isAffected([Event.pointerX(_16),Event.pointerY(_16)],_17,this.last_active)){
      if(this.last_active.onDrop){
        this.last_active.onDrop(_17,this.last_active.element,_16)
      }
    }
  },
  
  reset:function(){
    if(this.last_active){
      this.deactivate(this.last_active)
    }
  }
  };
  
  var Draggables={drags:[],observers:[],register:function(_18){
    if(this.drags.length==0){
      this.eventMouseUp=this.endDrag.bindAsEventListener(this);
      this.eventMouseMove=this.updateDrag.bindAsEventListener(this);
      this.eventKeypress=this.keyPress.bindAsEventListener(this);
      Event.observe(document,"mouseup",this.eventMouseUp);
      Event.observe(document,"mousemove",this.eventMouseMove);
      Event.observe(document,"keypress",this.eventKeypress)
    }
    this.drags.push(_18)
  },
  
  unregister:function(_19){
    this.drags=this.drags.reject(function(d){return d==_19});
    if(this.drags.length==0){
      Event.stopObserving(document,"mouseup",this.eventMouseUp);
      Event.stopObserving(document,"mousemove",this.eventMouseMove);
      Event.stopObserving(document,"keypress",this.eventKeypress)
    }
  },
  
  activate:function(_1b){window.focus();this.activeDraggable=_1b},
  
  deactivate:function(){this.activeDraggable=null},
  
  updateDrag:function(_1c){
    if(!this.activeDraggable){return}
    var _1d=[Event.pointerX(_1c),Event.pointerY(_1c)];
    if(this._lastPointer&&(this._lastPointer.inspect()==_1d.inspect())){return}
    this._lastPointer=_1d;
    this.activeDraggable.updateDrag(_1c,_1d)
  },
  
  endDrag:function(_1e){
    if(!this.activeDraggable){return}
    this._lastPointer=null;
    this.activeDraggable.endDrag(_1e);
    this.activeDraggable=null
  },
  
  keyPress:function(_1f){
    if(this.activeDraggable){this.activeDraggable.keyPress(_1f)}
  },
  
  addObserver:function(_20){this.observers.push(_20);this._cacheObserverCallbacks()},
  
  removeObserver:function(_21){
    this.observers=this.observers.reject(function(o){return o.element==_21});
    this._cacheObserverCallbacks()
  },
  
  notify:function(_23,_24,_25){
    if(this[_23+"Count"]>0){this.observers.each(function(o){if(o[_23]){o[_23](_23,_24,_25)}})}
  },
  
  _cacheObserverCallbacks:function(){
    ["onStart","onEnd","onDrag"].each(function(_27){
      Draggables[_27+"Count"]=Draggables.observers.select(function(o){return o[_27]}).length})
  }
};

var Draggable=Class.create();
Draggable.prototype={
  initialize:function(_29){
    var _2a=Object.extend({handle:false,
    starteffect:function(_2b){
      new Effect.Opacity(_2b,{duration:0.2,from:1,to:0.7})
    },
    
    reverteffect:function(_2c,_2d,_2e){
      var dur=Math.sqrt(Math.abs(_2d^2)+Math.abs(_2e^2))*0.02;_2c._revert=new Effect.Move(_2c,{x:-_2e,y:-_2d,duration:dur})
    },
    
    endeffect:function(_30){
      new Effect.Opacity(_30,{duration:0.2,from:0.7,to:1})
    },
    
    zindex:1000,revert:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,snap:false
    },arguments[1]||{});
    this.element=$(_29);
    if(_2a.handle&&(typeof _2a.handle=="string")){
      var h=Element.childrenWithClassName(this.element,_2a.handle,true);
      if(h.length>0){this.handle=h[0]}
    }
    if(!this.handle){this.handle=$(_2a.handle)}
    if(!this.handle){this.handle=this.element}
    if(_2a.scroll&&!_2a.scroll.scrollTo&&!_2a.scroll.outerHTML){_2a.scroll=$(_2a.scroll)}
    Element.makePositioned(this.element);
    this.delta=this.currentDelta();
    this.options=_2a;
    this.dragging=false;
    this.eventMouseDown=this.initDrag.bindAsEventListener(this);
    Event.observe(this.handle,"mousedown",this.eventMouseDown);
    Draggables.register(this)
  },

  destroy:function(){
    Event.stopObserving(this.handle,"mousedown",this.eventMouseDown);
    Draggables.unregister(this)
  },
  
  currentDelta:function(){
    return([parseInt(Element.getStyle(this.element,"left")||"0"),parseInt(Element.getStyle(this.element,"top")||"0")])
  },
  
  initDrag:function(_32){
    if(Event.isLeftClick(_32)){
      var src=Event.element(_32);
      if(src.tagName&&(src.tagName=="INPUT"||src.tagName=="SELECT"||src.tagName=="OPTION"||src.tagName=="BUTTON"||src.tagName=="TEXTAREA")){return}
      if(this.element._revert){
        this.element._revert.cancel();
        this.element._revert=null
      }
      var _34=[Event.pointerX(_32),Event.pointerY(_32)];
      var pos=Position.cumulativeOffset(this.element);
      this.offset=[0,1].map(function(i){return(_34[i]-pos[i])});
      Draggables.activate(this);
      Event.stop(_32)
    }
  },
  
  startDrag:function(_37){
    this.dragging=true;
    if(this.options.zindex){
      this.originalZ=parseInt(Element.getStyle(this.element,"z-index")||0);
      this.element.style.zIndex=this.options.zindex
    }
    if(this.options.ghosting){
      this._clone=this.element.cloneNode(true);
      Position.absolutize(this.element);
      this.element.parentNode.insertBefore(this._clone,this.element)
    }
    if(this.options.scroll){
      if(this.options.scroll==window){
        var _38=this._getWindowScroll(this.options.scroll);
        this.originalScrollLeft=_38.left;
        this.originalScrollTop=_38.top
      }else{
        this.originalScrollLeft=this.options.scroll.scrollLeft;
        this.originalScrollTop=this.options.scroll.scrollTop
      }
    }
    Draggables.notify("onStart",this,_37);
    if(this.options.starteffect){this.options.starteffect(this.element)
    }
  },
  
  updateDrag:function(_39,_3a){
    if(!this.dragging){this.startDrag(_39)}
    Position.prepare();
    Droppables.show(_3a,this.element);
    Draggables.notify("onDrag",this,_39);
    this.draw(_3a);
    if(this.options.change){this.options.change(this)}
    if(this.options.scroll){
      this.stopScrolling();
      var p;
      if(this.options.scroll==window){
        with(this._getWindowScroll(this.options.scroll)){p=[left,top,left+width,top+height]}
      }else{
        p=Position.page(this.options.scroll);
        p[0]+=this.options.scroll.scrollLeft;
        p[1]+=this.options.scroll.scrollTop;
        p.push(p[0]+this.options.scroll.offsetWidth);
        p.push(p[1]+this.options.scroll.offsetHeight)
      }
      var _3c=[0,0];
      if(_3a[0]<(p[0]+this.options.scrollSensitivity)){
        _3c[0]=_3a[0]-(p[0]+this.options.scrollSensitivity)
      }
      if(_3a[1]<(p[1]+this.options.scrollSensitivity)){
        _3c[1]=_3a[1]-(p[1]+this.options.scrollSensitivity)
      }
      if(_3a[0]>(p[2]-this.options.scrollSensitivity)){
        _3c[0]=_3a[0]-(p[2]-this.options.scrollSensitivity)
      }
      if(_3a[1]>(p[3]-this.options.scrollSensitivity)){
        _3c[1]=_3a[1]-(p[3]-this.options.scrollSensitivity)
      }
      this.startScrolling(_3c)
    }
    if(navigator.appVersion.indexOf("AppleWebKit")>0){window.scrollBy(0,0)}
    Event.stop(_39)
  },
  
  finishDrag:function(_3d,_3e){
    this.dragging=false;
    if(this.options.ghosting){
      Position.relativize(this.element);
      Element.remove(this._clone);
      this._clone=null
    }
    if(_3e){Droppables.fire(_3d,this.element)}
    Draggables.notify("onEnd",this,_3d);
    var _3f=this.options.revert;
    if(_3f&&typeof _3f=="function"){_3f=_3f(this.element)}
    var d=this.currentDelta();
    if(_3f&&this.options.reverteffect){
      this.options.reverteffect(this.element,d[1]-this.delta[1],d[0]-this.delta[0])
    }else{
      this.delta=d
    }
    if(this.options.zindex){this.element.style.zIndex=this.originalZ}
    if(this.options.endeffect){this.options.endeffect(this.element)}
    Draggables.deactivate(this);
    Droppables.reset()
  },
  
  keyPress:function(_41){
    if(_41.keyCode!=Event.KEY_ESC){return}
    this.finishDrag(_41,false);
    Event.stop(_41)
  },
  
  endDrag:function(_42){
    if(!this.dragging){return}
    this.stopScrolling();
    this.finishDrag(_42,true);
    Event.stop(_42)
  },
  
  draw:function(_43){
    var pos=Position.cumulativeOffset(this.element);
    var d=this.currentDelta();
    pos[0]-=d[0];
    pos[1]-=d[1];
    if(this.options.scroll&&(this.options.scroll!=window)){
      pos[0]-=this.options.scroll.scrollLeft-this.originalScrollLeft;
      pos[1]-=this.options.scroll.scrollTop-this.originalScrollTop
    }
    var p=[0,1].map(function(i){
      return(_43[i]-pos[i]-this.offset[i])}.bind(this));
    if(this.options.snap){
      if(typeof this.options.snap=="function"){
        p=this.options.snap(p[0],p[1])
      }else{
        if(this.options.snap instanceof Array){
          p=p.map(function(v,i){return Math.round(v/this.options.snap[i])*this.options.snap[i]}.bind(this))
        }else{
          p=p.map(function(v){return Math.round(v/this.options.snap)*this.options.snap}.bind(this))
        }
      }
    }
    var _4b=this.element.style;
    if((!this.options.constraint)||(this.options.constraint=="horizontal")){_4b.left=p[0]+"px"}
    if((!this.options.constraint)||(this.options.constraint=="vertical")){_4b.top=p[1]+"px"}
    if(_4b.visibility=="hidden"){_4b.visibility=""}
  },
  
  stopScrolling:function(){
    if(this.scrollInterval){
      clearInterval(this.scrollInterval);
      this.scrollInterval=null;
      Draggables._lastScrollPointer=null
    }
  },
  
  startScrolling:function(_4c){
    this.scrollSpeed=[_4c[0]*this.options.scrollSpeed,_4c[1]*this.options.scrollSpeed];
    this.lastScrolled=new Date();
    this.scrollInterval=setInterval(this.scroll.bind(this),10)
  },
  
  scroll:function(){
    var _4d=new Date();
    var _4e=_4d-this.lastScrolled;
    this.lastScrolled=_4d;
    if(this.options.scroll==window){
      with(this._getWindowScroll(this.options.scroll)){
        if(this.scrollSpeed[0]||this.scrollSpeed[1]){
          var d=_4e/1000;this.options.scroll.scrollTo(left+d*this.scrollSpeed[0],top+d*this.scrollSpeed[1])
        }
      }
    }else{
      this.options.scroll.scrollLeft+=this.scrollSpeed[0]*_4e/1000;
      this.options.scroll.scrollTop+=this.scrollSpeed[1]*_4e/1000
    }
    Position.prepare();
    Droppables.show(Draggables._lastPointer,this.element);
    Draggables.notify("onDrag",this);
    Draggables._lastScrollPointer=Draggables._lastScrollPointer||$A(Draggables._lastPointer);
    Draggables._lastScrollPointer[0]+=this.scrollSpeed[0]*_4e/1000;Draggables._lastScrollPointer[1]+=this.scrollSpeed[1]*_4e/1000;
    if(Draggables._lastScrollPointer[0]<0){
      Draggables._lastScrollPointer[0]=0
    }
    if(Draggables._lastScrollPointer[1]<0){
      Draggables._lastScrollPointer[1]=0
    }
    this.draw(Draggables._lastScrollPointer);
    if(this.options.change){this.options.change(this)}
  },
  
  _getWindowScroll:function(w){
    var T,L,W,H;
    with(w.document){
      if(w.document.documentElement&&documentElement.scrollTop){
        T=documentElement.scrollTop;
        L=documentElement.scrollLeft
      }else{
        if(w.document.body){
          T=body.scrollTop;
          L=body.scrollLeft
        }
      }
      if(w.innerWidth){
        W=w.innerWidth;H=w.innerHeight
      }else{
        if(w.document.documentElement&&documentElement.clientWidth){
          W=documentElement.clientWidth;
          H=documentElement.clientHeight
        }else{
          W=body.offsetWidth;
          H=body.offsetHeight
        }
      }
    }
    return{top:T,left:L,width:W,height:H}
  }
};

var SortableObserver=Class.create();
SortableObserver.prototype={
  initialize:function(_52,_53){
    this.element=$(_52);
    this.observer=_53;
    this.lastValue=Sortable.serialize(this.element)
  },
  
  onStart:function(){
    this.lastValue=Sortable.serialize(this.element)
  },
  
  onEnd:function(){
    Sortable.unmark();
    if(this.lastValue!=Sortable.serialize(this.element)){this.observer(this.element)}
  }
};

var Sortable={
  sortables:{},
  _findRootElement:function(_54){
    while(_54.tagName!="BODY"){
      if(_54.id&&Sortable.sortables[_54.id]){return _54}
      _54=_54.parentNode
    }
  },
  
  options:function(_55){
    _55=Sortable._findRootElement($(_55));
    if(!_55){return}
    return Sortable.sortables[_55.id]
  },
  
  destroy:function(_56){
    var s=Sortable.options(_56);
    if(s){
      Draggables.removeObserver(s.element);
      s.droppables.each(function(d){Droppables.remove(d)});
      s.draggables.invoke("destroy");
      delete Sortable.sortables[s.element.id]
    }
  },
  
  create:function(_59){
    _59=$(_59);
    var _5a=Object.extend({
      element:_59,tag:"li",dropOnEmpty:false,tree:false,treeTag:"ul",overlap:"vertical",constraint:"vertical",containment:_59,handle:false,only:false,hoverclass:null,ghosting:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,format:/^[^_]*_(.*)$/,onChange:Prototype.emptyFunction,onUpdate:Prototype.emptyFunction
    },arguments[1]||{}
    );this.destroy(_59);
    var _5b={revert:true,scroll:_5a.scroll,scrollSpeed:_5a.scrollSpeed,scrollSensitivity:_5a.scrollSensitivity,ghosting:_5a.ghosting,constraint:_5a.constraint,handle:_5a.handle};
    if(_5a.starteffect){_5b.starteffect=_5a.starteffect}
    if(_5a.reverteffect){
      _5b.reverteffect=_5a.reverteffect
    }else{
      if(_5a.ghosting){
        _5b.reverteffect=function(_5c){_5c.style.top=0;_5c.style.left=0}
      }
    }
    if(_5a.endeffect){_5b.endeffect=_5a.endeffect}
    if(_5a.zindex){_5b.zindex=_5a.zindex}
    var _5d={overlap:_5a.overlap,containment:_5a.containment,tree:_5a.tree,hoverclass:_5a.hoverclass,onHover:Sortable.onHover};
    var _5e={onHover:Sortable.onEmptyHover,overlap:_5a.overlap,containment:_5a.containment,hoverclass:_5a.hoverclass};
    Element.cleanWhitespace(_59);
    _5a.draggables=[];
    _5a.droppables=[];
    if(_5a.dropOnEmpty||_5a.tree){
      Droppables.add(_59,_5e);
      _5a.droppables.push(_59)
    }(this.findElements(_59,_5a)||[]).each(function(e){var _60=_5a.handle?Element.childrenWithClassName(e,_5a.handle)[0]:e;_5a.draggables.push(new Draggable(e,Object.extend(_5b,{handle:_60})));Droppables.add(e,_5d);if(_5a.tree){e.treeNode=_59}_5a.droppables.push(e)});
    if(_5a.tree){
      (Sortable.findTreeElements(_59,_5a)||[]).each(function(e){
        Droppables.add(e,_5e);
        e.treeNode=_59;
        _5a.droppables.push(e)})
    }
    this.sortables[_59.id]=_5a;
    Draggables.addObserver(new SortableObserver(_59,_5a.onUpdate))
  },
  
  findElements:function(_62,_63){
    return Element.findChildren(_62,_63.only,_63.tree?true:false,_63.tag)
  },
  
  findTreeElements:function(_64,_65){
    return Element.findChildren(_64,_65.only,_65.tree?true:false,_65.treeTag)
  },
  
  onHover:function(_66,_67,_68){
    if(Element.isParent(_67,_66)){return}
    if(_68>0.33&&_68<0.66&&Sortable.options(_67).tree){return}
    else
      {if(_68>0.5){Sortable.mark(_67,"before");
      if(_67.previousSibling!=_66){
        var _69=_66.parentNode;
        _66.style.visibility="hidden";
        _67.parentNode.insertBefore(_66,_67);
        if(_67.parentNode!=_69){Sortable.options(_69).onChange(_66)}
        Sortable.options(_67.parentNode).onChange(_66)
      }
    }else{
      Sortable.mark(_67,"after");
      var _6a=_67.nextSibling||null;
      if(_6a!=_66){
        var _6b=_66.parentNode;
        _66.style.visibility="hidden";
        _67.parentNode.insertBefore(_66,_6a);
        if(_67.parentNode!=_6b){
          Sortable.options(_6b).onChange(_66)
        }
        Sortable.options(_67.parentNode).onChange(_66)
      }
    }
    }
  },
    
  onEmptyHover:function(_6c,_6d,_6e){
    var _6f=_6c.parentNode;
    var _70=Sortable.options(_6d);
    if(!Element.isParent(_6d,_6c)){
      var _71;
      var _72=Sortable.findElements(_6d,{tag:_70.tag});
      var _73=null;
      if(_72){
        var _74=Element.offsetSize(_6d,_70.overlap)*(1-_6e);
        for(_71=0;_71<_72.length;_71+=1){
          if(_74-Element.offsetSize(_72[_71],_70.overlap)>=0){
            _74-=Element.offsetSize(_72[_71],_70.overlap)
          }else{
            if(_74-(Element.offsetSize(_72[_71],_70.overlap)/2)>=0){
              _73=_71+1<_72.length?_72[_71+1]:null;
              break
            }else{
              _73=_72[_71];
              break
            }
          }
        }
      }
      _6d.insertBefore(_6c,_73);
      Sortable.options(_6f).onChange(_6c);
      _70.onChange(_6c)
      }
    },
    
    unmark:function(){
      if(Sortable._marker){Element.hide(Sortable._marker)}
    },
    
    mark:function(_75,_76){
      var _77=Sortable.options(_75.parentNode);
      if(_77&&!_77.ghosting){return}
      if(!Sortable._marker){
        Sortable._marker=$("dropmarker")||document.createElement("DIV");
        Element.hide(Sortable._marker);
        Element.addClassName(Sortable._marker,"dropmarker");
        Sortable._marker.style.position="absolute";
        document.getElementsByTagName("body").item(0).appendChild(Sortable._marker)
      }
      var _78=Position.cumulativeOffset(_75);
      Sortable._marker.style.left=_78[0]+"px";
      Sortable._marker.style.top=_78[1]+"px";
      if(_76=="after"){
        if(_77.overlap=="horizontal"){
          Sortable._marker.style.left=(_78[0]+_75.clientWidth)+"px"
        }else{
          Sortable._marker.style.top=(_78[1]+_75.clientHeight)+"px"
        }
      }
      Element.show(Sortable._marker)
    },
    
    _tree:function(_79,_7a,_7b){
      var _7c=Sortable.findElements(_79,_7a)||[];
      for(var i=0;i<_7c.length;++i){
        var _7e=_7c[i].id.match(_7a.format);
        if(!_7e){continue}
        var _7f={id:encodeURIComponent(_7e?_7e[1]:null),element:_79,parent:_7b,children:new Array,position:_7b.children.length,container:Sortable._findChildrenElement(_7c[i],_7a.treeTag.toUpperCase())};
        if(_7f.container){
          this._tree(_7f.container,_7a,_7f)
        }
        _7b.children.push(_7f)
      }
      return _7b
    },
    
    _findChildrenElement:function(_80,_81){
      if(_80&&_80.hasChildNodes){
        for(var i=0;i<_80.childNodes.length;++i){
          if(_80.childNodes[i].tagName==_81){
            return _80.childNodes[i]
          }
        }
      }
      return null
    },
    
    tree:function(_83){
      _83=$(_83);
      var _84=this.options(_83);
      var _85=Object.extend({
        tag:_84.tag,treeTag:_84.treeTag,only:_84.only,name:_83.id,format:_84.format},
        arguments[1]||{});
      var _86={id:null,parent:null,children:new Array,container:_83,position:0};
      return Sortable._tree(_83,_85,_86)
    },
    
    _constructIndex:function(_87){
      var _88="";
      do{if(_87.id){_88="["+_87.position+"]"+_88}}
      while((_87=_87.parent)!=null);
      return _88
    },
    
    sequence:function(_89){
      _89=$(_89);
      var _8a=Object.extend(this.options(_89),arguments[1]||{});
      return $(this.findElements(_89,_8a)||[]).map(function(_8b){
        return _8b.id.match(_8a.format)?_8b.id.match(_8a.format)[1]:""
      })
    },
    
    setSequence:function(_8c,_8d){_8c=$(_8c);
      var _8e=Object.extend(this.options(_8c),arguments[2]||{});
      var _8f={};
      this.findElements(_8c,_8e).each(function(n){
        if(n.id.match(_8e.format)){
          _8f[n.id.match(_8e.format)[1]]=[n,n.parentNode]
        }n.parentNode.removeChild(n)
      });
      _8d.each(function(_91){
        var n=_8f[_91];
        if(n){n[1].appendChild(n[0]);
        delete _8f[_91]}}
      )
    },
    
    serialize:function(_93){
      _93=$(_93);
      var _94=Object.extend(Sortable.options(_93),arguments[1]||{});
      var _95=encodeURIComponent((arguments[1]&&arguments[1].name)?arguments[1].name:_93.id);
      if(_94.tree){
        return Sortable.tree(_93,arguments[1]).children.map(function(_96){
          return[_95+Sortable._constructIndex(_96)+"="+encodeURIComponent(_96.id)].concat(_96.children.map(arguments.callee))
        }).flatten().join("&")
      }else{
        return Sortable.sequence(_93,arguments[1]).map(function(_97){
          return _95+"[]="+encodeURIComponent(_97)
        }).join("&")
      }
    }
};
  
Element.isParent=function(_98,_99){
  if(!_98.parentNode||_98==_99){return false}
  if(_98.parentNode==_99){return true}
  return Element.isParent(_98.parentNode,_99)
};

Element.findChildren=function(_9a,_9b,_9c,_9d){
  if(!_9a.hasChildNodes()){return null}
  _9d=_9d.toUpperCase();
  if(_9b){_9b=[_9b].flatten()}
  var _9e=[];
  $A(_9a.childNodes).each(function(e){
    if(e.tagName&&e.tagName.toUpperCase()==_9d&&(!_9b||(Element.classNames(e).detect(function(v){return _9b.include(v)})))){_9e.push(e)}
    if(_9c){
      var _a1=Element.findChildren(e,_9b,_9c,_9d);
      if(_a1){_9e.push(_a1)}
    }
  });
  return(_9e.length>0?_9e.flatten():[])
};

Element.offsetSize=function(_a2,_a3){
  if(_a3=="vertical"||_a3=="height"){
    return _a2.offsetHeight
  }else{
    return _a2.offsetWidth
  }
};

Extend={VERSION:1.1,CLASSDEF:"CLASSDEF",DELETE:"DELETE",INSTANCE_RESERVED:{
  CLASSDEF:true,getClass:true,parentClass:true},setupClass:function(_1,_2){
    _2=_2||{};
    _1.prototype=_2;
    _1.methods={};
    for(var _3 in _2){
      _1.methods[_3]=_2[_3]
    }
    _1.inherited={};
    _1.parentClass=undefined;
    if(_2[Extend.CLASSDEF]){
      _1.className=_2[Extend.CLASSDEF].name
    }else{
      _1.className=undefined
    }
    _1.subclasses=_1.subclasses||[];
    _1.constructor=Extend.Operations.constructor;
    _1.reparent=Extend.Operations.reparent;
    _1.method=Extend.Operations.method;
    _1.update=Extend.Operations.update;
    if(_2[Extend.CLASSDEF]){_1.reparent(_2[Extend.CLASSDEF].parent)}
    _2.getClass=function(){return _1};
    _2.parentClass=function(){return this.getClass().parentClass};
    _2.parentCall=function(){
      var _4=[];
      for(var i=1;i<arguments.length;i++){
        _4.push(arguments[i])
      }
      return this.parentClass().method(arguments[0]).apply(this,_4)
    };
    _2.setClass=function(_6){return this.getClass().parentClass};
    for(var i=0;i<_1.subclasses;i++){
      _1.subclasses[i].reparent(_1)
    }
    return _1
  },
  
  Operations:{constructor:function(){
    return this.prototype.initialize||function(){}},reparent:function(_8){
      if(this.parentClass){
        var _9=this.subclasses.indexOf(this);
        this.parentClass.subclasses.splice(_9,1);
        for(var _a in this.inherited){
          this.method(_a,null,this.parentClass)
        }
      }
      this.parentClass=_8;
      if(!_8){return}
      var _b=_8.prototype;
      for(parent_method_name in _b){
        if(Extend.INSTANCE_RESERVED[parent_method_name]==true){continue}
        if(this.methods[parent_method_name]==undefined){
          this.method(parent_method_name,_b[parent_method_name],_8.inherited[parent_method_name]||_8)
        }
      }
      _8.subclasses.push(this)
    },
    
    update:function(_c){
      Extend.setupClass(this,_c||this.prototype)},method:function(_d,_e,_f){
        if(_e==undefined){
          var _10=this.prototype[_d];
          if(_d==undefined){
            throw new Error("Method not found: "+_d)
          }
          return _10
        }else{
          _f=_f||this;
          if(_f==this){
            if(_e==Extend.DELETE){
              delete this.methods[_d];
              delete this.inherited[_d];
              delete this.prototype[_d];
              if(this.parentClass){
                var _11=this.parentClass.method(_d);
                if(_11){
                  this.method(_d,_11,this.parentClass.inherited[_d]||this.parentClass)
                }
              }
            }else{
              this.methods[_d]=_e;
              this.prototype[_d]=_e;
              delete this.inherited[_d]
            }
          }else{
            if(_e==Extend.DELETE){
              delete this.inherited[_d];
              delete this.methods[_d];
              delete this.prototype[_d];
              if(this.parentClass){
                var _12=this.parentClass.method(_d);
                if(_12){
                  this.method(_d,_12,this.parentClass.inherited[_d]||this.parentClass)
                }
              }
            }else{
              if(this.methods[_d]==undefined){
                this.inherited[_d]=_f;
                this.prototype[_d]=_e
              }
            }
          }
          for(var i=0;i<this.subclasses.length;i++){
            this.subclasses[i].method(_d,_e,_f)
          }
        }
      }
    }
};
  
try{Class=Class}catch(Error){
  Class={create:function(){return function(){this.initialize.apply(this,arguments)}}}
}
Class._create=Class.create;
Class.create=function(_14){
  var _15=Extend.setupClass(Class._create(_14),_14);
  return _15
};

//wz_jsgraphics.js    v. 3.03

var jg_ok, jg_ie, jg_fast, jg_dom, jg_moz;


function _chkDHTM(x, i)
{
	x = document.body || null;
	jg_ie = x && typeof x.insertAdjacentHTML != "undefined" && document.createElement;
	jg_dom = (x && !jg_ie &&
		typeof x.appendChild != "undefined" &&
		typeof document.createRange != "undefined" &&
		typeof (i = document.createRange()).setStartBefore != "undefined" &&
		typeof i.createContextualFragment != "undefined");
	jg_fast = jg_ie && document.all && !window.opera;
	jg_moz = jg_dom && typeof x.style.MozOpacity != "undefined";
	jg_ok = !!(jg_ie || jg_dom);
}

function _pntCnvDom()
{
	var x = this.wnd.document.createRange();
	x.setStartBefore(this.cnv);
	x = x.createContextualFragment(jg_fast? this._htmRpc() : this.htm);
	if(this.cnv) this.cnv.appendChild(x);
	this.htm = "";
}

function _pntCnvIe()
{
	if(this.cnv) this.cnv.insertAdjacentHTML("BeforeEnd", jg_fast? this._htmRpc() : this.htm);
	this.htm = "";
}

function _pntDoc()
{
	this.wnd.document.write(jg_fast? this._htmRpc() : this.htm);
	this.htm = '';
}

function _pntN()
{
	;
}

function _mkDiv(x, y, w, h)
{
	this.htm += '<div style="position:absolute;'+
		'left:' + x + 'px;'+
		'top:' + y + 'px;'+
		'width:' + w + 'px;'+
		'height:' + h + 'px;'+
		'clip:rect(0,'+w+'px,'+h+'px,0);'+
		'background-color:' + this.color +
		(!jg_moz? ';overflow:hidden' : '')+
		';"><\/div>';
}

function _mkDivIe(x, y, w, h)
{
	this.htm += '%%'+this.color+';'+x+';'+y+';'+w+';'+h+';';
}

function _mkDivPrt(x, y, w, h)
{
	this.htm += '<div style="position:absolute;'+
		'border-left:' + w + 'px solid ' + this.color + ';'+
		'left:' + x + 'px;'+
		'top:' + y + 'px;'+
		'width:0px;'+
		'height:' + h + 'px;'+
		'clip:rect(0,'+w+'px,'+h+'px,0);'+
		'background-color:' + this.color +
		(!jg_moz? ';overflow:hidden' : '')+
		';"><\/div>';
}

var _regex =  /%%([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);/g;
function _htmRpc()
{
	return this.htm.replace(
		_regex,
		'<div style="overflow:hidden;position:absolute;background-color:'+
		'$1;left:$2;top:$3;width:$4;height:$5"></div>\n');
}

function _htmPrtRpc()
{
	return this.htm.replace(
		_regex,
		'<div style="overflow:hidden;position:absolute;background-color:'+
		'$1;left:$2;top:$3;width:$4;height:$5;border-left:$4px solid $1"></div>\n');
}

function _mkLin(x1, y1, x2, y2)
{
	if(x1 > x2)
	{
		var _x2 = x2;
		var _y2 = y2;
		x2 = x1;
		y2 = y1;
		x1 = _x2;
		y1 = _y2;
	}
	var dx = x2-x1, dy = Math.abs(y2-y1),
	x = x1, y = y1,
	yIncr = (y1 > y2)? -1 : 1;

	if(dx >= dy)
	{
		var pr = dy<<1,
		pru = pr - (dx<<1),
		p = pr-dx,
		ox = x;
		while(dx > 0)
		{--dx;
			++x;
			if(p > 0)
			{
				this._mkDiv(ox, y, x-ox, 1);
				y += yIncr;
				p += pru;
				ox = x;
			}
			else p += pr;
		}
		this._mkDiv(ox, y, x2-ox+1, 1);
	}

	else
	{
		var pr = dx<<1,
		pru = pr - (dy<<1),
		p = pr-dy,
		oy = y;
		if(y2 <= y1)
		{
			while(dy > 0)
			{--dy;
				if(p > 0)
				{
					this._mkDiv(x++, y, 1, oy-y+1);
					y += yIncr;
					p += pru;
					oy = y;
				}
				else
				{
					y += yIncr;
					p += pr;
				}
			}
			this._mkDiv(x2, y2, 1, oy-y2+1);
		}
		else
		{
			while(dy > 0)
			{--dy;
				y += yIncr;
				if(p > 0)
				{
					this._mkDiv(x++, oy, 1, y-oy);
					p += pru;
					oy = y;
				}
				else p += pr;
			}
			this._mkDiv(x2, oy, 1, y2-oy+1);
		}
	}
}

function _mkLin2D(x1, y1, x2, y2)
{
	if(x1 > x2)
	{
		var _x2 = x2;
		var _y2 = y2;
		x2 = x1;
		y2 = y1;
		x1 = _x2;
		y1 = _y2;
	}
	var dx = x2-x1, dy = Math.abs(y2-y1),
	x = x1, y = y1,
	yIncr = (y1 > y2)? -1 : 1;

	var s = this.stroke;
	if(dx >= dy)
	{
		if(dx > 0 && s-3 > 0)
		{
			var _s = (s*dx*Math.sqrt(1+dy*dy/(dx*dx))-dx-(s>>1)*dy) / dx;
			_s = (!(s-4)? Math.ceil(_s) : Math.round(_s)) + 1;
		}
		else var _s = s;
		var ad = Math.ceil(s/2);

		var pr = dy<<1,
		pru = pr - (dx<<1),
		p = pr-dx,
		ox = x;
		while(dx > 0)
		{--dx;
			++x;
			if(p > 0)
			{
				this._mkDiv(ox, y, x-ox+ad, _s);
				y += yIncr;
				p += pru;
				ox = x;
			}
			else p += pr;
		}
		this._mkDiv(ox, y, x2-ox+ad+1, _s);
	}

	else
	{
		if(s-3 > 0)
		{
			var _s = (s*dy*Math.sqrt(1+dx*dx/(dy*dy))-(s>>1)*dx-dy) / dy;
			_s = (!(s-4)? Math.ceil(_s) : Math.round(_s)) + 1;
		}
		else var _s = s;
		var ad = Math.round(s/2);

		var pr = dx<<1,
		pru = pr - (dy<<1),
		p = pr-dy,
		oy = y;
		if(y2 <= y1)
		{
			++ad;
			while(dy > 0)
			{--dy;
				if(p > 0)
				{
					this._mkDiv(x++, y, _s, oy-y+ad);
					y += yIncr;
					p += pru;
					oy = y;
				}
				else
				{
					y += yIncr;
					p += pr;
				}
			}
			this._mkDiv(x2, y2, _s, oy-y2+ad);
		}
		else
		{
			while(dy > 0)
			{--dy;
				y += yIncr;
				if(p > 0)
				{
					this._mkDiv(x++, oy, _s, y-oy+ad);
					p += pru;
					oy = y;
				}
				else p += pr;
			}
			this._mkDiv(x2, oy, _s, y2-oy+ad+1);
		}
	}
}

function _mkLinDott(x1, y1, x2, y2)
{
	if(x1 > x2)
	{
		var _x2 = x2;
		var _y2 = y2;
		x2 = x1;
		y2 = y1;
		x1 = _x2;
		y1 = _y2;
	}
	var dx = x2-x1, dy = Math.abs(y2-y1),
	x = x1, y = y1,
	yIncr = (y1 > y2)? -1 : 1,
	drw = true;
	if(dx >= dy)
	{
		var pr = dy<<1,
		pru = pr - (dx<<1),
		p = pr-dx;
		while(dx > 0)
		{--dx;
			if(drw) this._mkDiv(x, y, 1, 1);
			drw = !drw;
			if(p > 0)
			{
				y += yIncr;
				p += pru;
			}
			else p += pr;
			++x;
		}
	}
	else
	{
		var pr = dx<<1,
		pru = pr - (dy<<1),
		p = pr-dy;
		while(dy > 0)
		{--dy;
			if(drw) this._mkDiv(x, y, 1, 1);
			drw = !drw;
			y += yIncr;
			if(p > 0)
			{
				++x;
				p += pru;
			}
			else p += pr;
		}
	}
	if(drw) this._mkDiv(x, y, 1, 1);
}

function _mkOv(left, top, width, height)
{
	var a = (++width)>>1, b = (++height)>>1,
	wod = width&1, hod = height&1,
	cx = left+a, cy = top+b,
	x = 0, y = b,
	ox = 0, oy = b,
	aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
	st = (aa2>>1)*(1-(b<<1)) + bb2,
	tt = (bb2>>1) - aa2*((b<<1)-1),
	w, h;
	while(y > 0)
	{
		if(st < 0)
		{
			st += bb2*((x<<1)+3);
			tt += bb4*(++x);
		}
		else if(tt < 0)
		{
			st += bb2*((x<<1)+3) - aa4*(y-1);
			tt += bb4*(++x) - aa2*(((y--)<<1)-3);
			w = x-ox;
			h = oy-y;
			if((w&2) && (h&2))
			{
				this._mkOvQds(cx, cy, x-2, y+2, 1, 1, wod, hod);
				this._mkOvQds(cx, cy, x-1, y+1, 1, 1, wod, hod);
			}
			else this._mkOvQds(cx, cy, x-1, oy, w, h, wod, hod);
			ox = x;
			oy = y;
		}
		else
		{
			tt -= aa2*((y<<1)-3);
			st -= aa4*(--y);
		}
	}
	w = a-ox+1;
	h = (oy<<1)+hod;
	y = cy-oy;
	this._mkDiv(cx-a, y, w, h);
	this._mkDiv(cx+ox+wod-1, y, w, h);
}

function _mkOv2D(left, top, width, height)
{
	var s = this.stroke;
	width += s+1;
	height += s+1;
	var a = width>>1, b = height>>1,
	wod = width&1, hod = height&1,
	cx = left+a, cy = top+b,
	x = 0, y = b,
	aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
	st = (aa2>>1)*(1-(b<<1)) + bb2,
	tt = (bb2>>1) - aa2*((b<<1)-1);

	if(s-4 < 0 && (!(s-2) || width-51 > 0 && height-51 > 0))
	{
		var ox = 0, oy = b,
		w, h,
		pxw;
		while(y > 0)
		{
			if(st < 0)
			{
				st += bb2*((x<<1)+3);
				tt += bb4*(++x);
			}
			else if(tt < 0)
			{
				st += bb2*((x<<1)+3) - aa4*(y-1);
				tt += bb4*(++x) - aa2*(((y--)<<1)-3);
				w = x-ox;
				h = oy-y;

				if(w-1)
				{
					pxw = w+1+(s&1);
					h = s;
				}
				else if(h-1)
				{
					pxw = s;
					h += 1+(s&1);
				}
				else pxw = h = s;
				this._mkOvQds(cx, cy, x-1, oy, pxw, h, wod, hod);
				ox = x;
				oy = y;
			}
			else
			{
				tt -= aa2*((y<<1)-3);
				st -= aa4*(--y);
			}
		}
		this._mkDiv(cx-a, cy-oy, s, (oy<<1)+hod);
		this._mkDiv(cx+a+wod-s, cy-oy, s, (oy<<1)+hod);
	}

	else
	{
		var _a = (width-(s<<1))>>1,
		_b = (height-(s<<1))>>1,
		_x = 0, _y = _b,
		_aa2 = (_a*_a)<<1, _aa4 = _aa2<<1, _bb2 = (_b*_b)<<1, _bb4 = _bb2<<1,
		_st = (_aa2>>1)*(1-(_b<<1)) + _bb2,
		_tt = (_bb2>>1) - _aa2*((_b<<1)-1),

		pxl = new Array(),
		pxt = new Array(),
		_pxb = new Array();
		pxl[0] = 0;
		pxt[0] = b;
		_pxb[0] = _b-1;
		while(y > 0)
		{
			if(st < 0)
			{
				pxl[pxl.length] = x;
				pxt[pxt.length] = y;
				st += bb2*((x<<1)+3);
				tt += bb4*(++x);
			}
			else if(tt < 0)
			{
				pxl[pxl.length] = x;
				st += bb2*((x<<1)+3) - aa4*(y-1);
				tt += bb4*(++x) - aa2*(((y--)<<1)-3);
				pxt[pxt.length] = y;
			}
			else
			{
				tt -= aa2*((y<<1)-3);
				st -= aa4*(--y);
			}

			if(_y > 0)
			{
				if(_st < 0)
				{
					_st += _bb2*((_x<<1)+3);
					_tt += _bb4*(++_x);
					_pxb[_pxb.length] = _y-1;
				}
				else if(_tt < 0)
				{
					_st += _bb2*((_x<<1)+3) - _aa4*(_y-1);
					_tt += _bb4*(++_x) - _aa2*(((_y--)<<1)-3);
					_pxb[_pxb.length] = _y-1;
				}
				else
				{
					_tt -= _aa2*((_y<<1)-3);
					_st -= _aa4*(--_y);
					_pxb[_pxb.length-1]--;
				}
			}
		}

		var ox = -wod, oy = b,
		_oy = _pxb[0],
		l = pxl.length,
		w, h;
		for(var i = 0; i < l; i++)
		{
			if(typeof _pxb[i] != "undefined")
			{
				if(_pxb[i] < _oy || pxt[i] < oy)
				{
					x = pxl[i];
					this._mkOvQds(cx, cy, x, oy, x-ox, oy-_oy, wod, hod);
					ox = x;
					oy = pxt[i];
					_oy = _pxb[i];
				}
			}
			else
			{
				x = pxl[i];
				this._mkDiv(cx-x, cy-oy, 1, (oy<<1)+hod);
				this._mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod);
				ox = x;
				oy = pxt[i];
			}
		}
		this._mkDiv(cx-a, cy-oy, 1, (oy<<1)+hod);
		this._mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod);
	}
}

function _mkOvDott(left, top, width, height)
{
	var a = (++width)>>1, b = (++height)>>1,
	wod = width&1, hod = height&1, hodu = hod^1,
	cx = left+a, cy = top+b,
	x = 0, y = b,
	aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
	st = (aa2>>1)*(1-(b<<1)) + bb2,
	tt = (bb2>>1) - aa2*((b<<1)-1),
	drw = true;
	while(y > 0)
	{
		if(st < 0)
		{
			st += bb2*((x<<1)+3);
			tt += bb4*(++x);
		}
		else if(tt < 0)
		{
			st += bb2*((x<<1)+3) - aa4*(y-1);
			tt += bb4*(++x) - aa2*(((y--)<<1)-3);
		}
		else
		{
			tt -= aa2*((y<<1)-3);
			st -= aa4*(--y);
		}
		if(drw && y >= hodu) this._mkOvQds(cx, cy, x, y, 1, 1, wod, hod);
		drw = !drw;
	}
}

function _mkRect(x, y, w, h)
{
	var s = this.stroke;
	this._mkDiv(x, y, w, s);
	this._mkDiv(x+w, y, s, h);
	this._mkDiv(x, y+h, w+s, s);
	this._mkDiv(x, y+s, s, h-s);
}

function _mkRectDott(x, y, w, h)
{
	this.drawLine(x, y, x+w, y);
	this.drawLine(x+w, y, x+w, y+h);
	this.drawLine(x, y+h, x+w, y+h);
	this.drawLine(x, y, x, y+h);
}

function jsgFont()
{
	this.PLAIN = 'font-weight:normal;';
	this.BOLD = 'font-weight:bold;';
	this.ITALIC = 'font-style:italic;';
	this.ITALIC_BOLD = this.ITALIC + this.BOLD;
	this.BOLD_ITALIC = this.ITALIC_BOLD;
}
var Font = new jsgFont();

function jsgStroke()
{
	this.DOTTED = -1;
}
var Stroke = new jsgStroke();

function jsGraphics(cnv, wnd)
{
	this.setColor = function(x)
	{
		this.color = x.toLowerCase();
	};

	this.setStroke = function(x)
	{
		this.stroke = x;
		if(!(x+1))
		{
			this.drawLine = _mkLinDott;
			this._mkOv = _mkOvDott;
			this.drawRect = _mkRectDott;
		}
		else if(x-1 > 0)
		{
			this.drawLine = _mkLin2D;
			this._mkOv = _mkOv2D;
			this.drawRect = _mkRect;
		}
		else
		{
			this.drawLine = _mkLin;
			this._mkOv = _mkOv;
			this.drawRect = _mkRect;
		}
	};

	this.setPrintable = function(arg)
	{
		this.printable = arg;
		if(jg_fast)
		{
			this._mkDiv = _mkDivIe;
			this._htmRpc = arg? _htmPrtRpc : _htmRpc;
		}
		else this._mkDiv = arg? _mkDivPrt : _mkDiv;
	};

	this.setFont = function(fam, sz, sty)
	{
		this.ftFam = fam;
		this.ftSz = sz;
		this.ftSty = sty || Font.PLAIN;
	};

	this.drawPolyline = this.drawPolyLine = function(x, y)
	{
		for (var i=x.length - 1; i;)
		{--i;
			this.drawLine(x[i], y[i], x[i+1], y[i+1]);
		}
	};

	this.fillRect = function(x, y, w, h)
	{
		this._mkDiv(x, y, w, h);
	};

	this.drawPolygon = function(x, y)
	{
		this.drawPolyline(x, y);
		this.drawLine(x[x.length-1], y[x.length-1], x[0], y[0]);
	};

	this.drawEllipse = this.drawOval = function(x, y, w, h)
	{
		this._mkOv(x, y, w, h);
	};

	this.fillEllipse = this.fillOval = function(left, top, w, h)
	{
		var a = w>>1, b = h>>1,
		wod = w&1, hod = h&1,
		cx = left+a, cy = top+b,
		x = 0, y = b, oy = b,
		aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
		st = (aa2>>1)*(1-(b<<1)) + bb2,
		tt = (bb2>>1) - aa2*((b<<1)-1),
		xl, dw, dh;
		if(w) while(y > 0)
		{
			if(st < 0)
			{
				st += bb2*((x<<1)+3);
				tt += bb4*(++x);
			}
			else if(tt < 0)
			{
				st += bb2*((x<<1)+3) - aa4*(y-1);
				xl = cx-x;
				dw = (x<<1)+wod;
				tt += bb4*(++x) - aa2*(((y--)<<1)-3);
				dh = oy-y;
				this._mkDiv(xl, cy-oy, dw, dh);
				this._mkDiv(xl, cy+y+hod, dw, dh);
				oy = y;
			}
			else
			{
				tt -= aa2*((y<<1)-3);
				st -= aa4*(--y);
			}
		}
		this._mkDiv(cx-a, cy-oy, w, (oy<<1)+hod);
	};

	this.fillArc = function(iL, iT, iW, iH, fAngA, fAngZ)
	{
		var a = iW>>1, b = iH>>1,
		iOdds = (iW&1) | ((iH&1) << 16),
		cx = iL+a, cy = iT+b,
		x = 0, y = b, ox = x, oy = y,
		aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
		st = (aa2>>1)*(1-(b<<1)) + bb2,
		tt = (bb2>>1) - aa2*((b<<1)-1),
		// Vars for radial boundary lines
		xEndA, yEndA, xEndZ, yEndZ,
		iSects = (1 << (Math.floor((fAngA %= 360.0)/180.0) << 3))
				| (2 << (Math.floor((fAngZ %= 360.0)/180.0) << 3))
				| ((fAngA >= fAngZ) << 16),
		aBndA = new Array(b+1), aBndZ = new Array(b+1);
		
		// Set up radial boundary lines
		fAngA *= Math.PI/180.0;
		fAngZ *= Math.PI/180.0;
		xEndA = cx+Math.round(a*Math.cos(fAngA));
		yEndA = cy+Math.round(-b*Math.sin(fAngA));
		_mkLinVirt(aBndA, cx, cy, xEndA, yEndA);
		xEndZ = cx+Math.round(a*Math.cos(fAngZ));
		yEndZ = cy+Math.round(-b*Math.sin(fAngZ));
		_mkLinVirt(aBndZ, cx, cy, xEndZ, yEndZ);

		while(y > 0)
		{
			if(st < 0) // Advance x
			{
				st += bb2*((x<<1)+3);
				tt += bb4*(++x);
			}
			else if(tt < 0) // Advance x and y
			{
				st += bb2*((x<<1)+3) - aa4*(y-1);
				ox = x;
				tt += bb4*(++x) - aa2*(((y--)<<1)-3);
				this._mkArcDiv(ox, y, oy, cx, cy, iOdds, aBndA, aBndZ, iSects);
				oy = y;
			}
			else // Advance y
			{
				tt -= aa2*((y<<1)-3);
				st -= aa4*(--y);
				if(y && (aBndA[y] != aBndA[y-1] || aBndZ[y] != aBndZ[y-1]))
				{
					this._mkArcDiv(x, y, oy, cx, cy, iOdds, aBndA, aBndZ, iSects);
					ox = x;
					oy = y;
				}
			}
		}
		this._mkArcDiv(x, 0, oy, cx, cy, iOdds, aBndA, aBndZ, iSects);
		if(iOdds >> 16) // Odd height
		{
			if(iSects >> 16) // Start-angle > end-angle
			{
				var xl = (yEndA <= cy || yEndZ > cy)? (cx - x) : cx;
				this._mkDiv(xl, cy, x + cx - xl + (iOdds & 0xffff), 1);
			}
			else if((iSects & 0x01) && yEndZ > cy)
				this._mkDiv(cx - x, cy, x, 1);
		}
	};

/* fillPolygon method, implemented by Matthieu Haller.
This javascript function is an adaptation of the gdImageFilledPolygon for Walter Zorn lib.
C source of GD 1.8.4 found at http://www.boutell.com/gd/

THANKS to Kirsten Schulz for the polygon fixes!

The intersection finding technique of this code could be improved
by remembering the previous intertersection, and by using the slope.
That could help to adjust intersections to produce a nice
interior_extrema. */
	this.fillPolygon = function(array_x, array_y)
	{
		var i;
		var y;
		var miny, maxy;
		var x1, y1;
		var x2, y2;
		var ind1, ind2;
		var ints;

		var n = array_x.length;
		if(!n) return;

		miny = array_y[0];
		maxy = array_y[0];
		for(i = 1; i < n; i++)
		{
			if(array_y[i] < miny)
				miny = array_y[i];

			if(array_y[i] > maxy)
				maxy = array_y[i];
		}
		for(y = miny; y <= maxy; y++)
		{
			var polyInts = new Array();
			ints = 0;
			for(i = 0; i < n; i++)
			{
				if(!i)
				{
					ind1 = n-1;
					ind2 = 0;
				}
				else
				{
					ind1 = i-1;
					ind2 = i;
				}
				y1 = array_y[ind1];
				y2 = array_y[ind2];
				if(y1 < y2)
				{
					x1 = array_x[ind1];
					x2 = array_x[ind2];
				}
				else if(y1 > y2)
				{
					y2 = array_y[ind1];
					y1 = array_y[ind2];
					x2 = array_x[ind1];
					x1 = array_x[ind2];
				}
				else continue;

				 //  Modified 11. 2. 2004 Walter Zorn
				if((y >= y1) && (y < y2))
					polyInts[ints++] = Math.round((y-y1) * (x2-x1) / (y2-y1) + x1);

				else if((y == maxy) && (y > y1) && (y <= y2))
					polyInts[ints++] = Math.round((y-y1) * (x2-x1) / (y2-y1) + x1);
			}
			polyInts.sort(_CompInt);
			for(i = 0; i < ints; i+=2)
				this._mkDiv(polyInts[i], y, polyInts[i+1]-polyInts[i]+1, 1);
		}
	};

	this.drawString = function(txt, x, y)
	{
		this.htm += '<div style="position:absolute;white-space:nowrap;'+
			'left:' + x + 'px;'+
			'top:' + y + 'px;'+
			'font-family:' +  this.ftFam + ';'+
			'font-size:' + this.ftSz + ';'+
			'color:' + this.color + ';' + this.ftSty + '">'+
			txt +
			'<\/div>';
	};

/* drawStringRect() added by Rick Blommers.
Allows to specify the size of the text rectangle and to align the
text both horizontally (e.g. right) and vertically within that rectangle */
	this.drawStringRect = function(txt, x, y, width, halign)
	{
		this.htm += '<div style="position:absolute;overflow:hidden;'+
			'left:' + x + 'px;'+
			'top:' + y + 'px;'+
			'width:'+width +'px;'+
			'text-align:'+halign+';'+
			'font-family:' +  this.ftFam + ';'+
			'font-size:' + this.ftSz + ';'+
			'color:' + this.color + ';' + this.ftSty + '">'+
			txt +
			'<\/div>';
	};

	this.drawImage = function(imgSrc, x, y, w, h, a)
	{
		this.htm += '<div style="position:absolute;'+
			'left:' + x + 'px;'+
			'top:' + y + 'px;'+
			// w (width) and h (height) arguments are now optional.
			// Added by Mahmut Keygubatli, 14.1.2008
			(w? ('width:' +  w + 'px;') : '') +
			(h? ('height:' + h + 'px;'):'')+'">'+
			'<img src="' + imgSrc +'"'+ (w ? (' width="' + w + '"'):'')+ (h ? (' height="' + h + '"'):'') + (a? (' '+a) : '') + '>'+
			'<\/div>';
	};

	this.clear = function()
	{
		this.htm = "";
		if(this.cnv) this.cnv.innerHTML = "";
	};

	this._mkOvQds = function(cx, cy, x, y, w, h, wod, hod)
	{
		var xl = cx - x, xr = cx + x + wod - w, yt = cy - y, yb = cy + y + hod - h;
		if(xr > xl+w)
		{
			this._mkDiv(xr, yt, w, h);
			this._mkDiv(xr, yb, w, h);
		}
		else
			w = xr - xl + w;
		this._mkDiv(xl, yt, w, h);
		this._mkDiv(xl, yb, w, h);
	};
	
	this._mkArcDiv = function(x, y, oy, cx, cy, iOdds, aBndA, aBndZ, iSects)
	{
		var xrDef = cx + x + (iOdds & 0xffff), y2, h = oy - y, xl, xr, w;

		if(!h) h = 1;
		x = cx - x;

		if(iSects & 0xff0000) // Start-angle > end-angle
		{
			y2 = cy - y - h;
			if(iSects & 0x00ff)
			{
				if(iSects & 0x02)
				{
					xl = Math.max(x, aBndZ[y]);
					w = xrDef - xl;
					if(w > 0) this._mkDiv(xl, y2, w, h);
				}
				if(iSects & 0x01)
				{
					xr = Math.min(xrDef, aBndA[y]);
					w = xr - x;
					if(w > 0) this._mkDiv(x, y2, w, h);
				}
			}
			else
				this._mkDiv(x, y2, xrDef - x, h);
			y2 = cy + y + (iOdds >> 16);
			if(iSects & 0xff00)
			{
				if(iSects & 0x0100)
				{
					xl = Math.max(x, aBndA[y]);
					w = xrDef - xl;
					if(w > 0) this._mkDiv(xl, y2, w, h);
				}
				if(iSects & 0x0200)
				{
					xr = Math.min(xrDef, aBndZ[y]);
					w = xr - x;
					if(w > 0) this._mkDiv(x, y2, w, h);
				}
			}
			else
				this._mkDiv(x, y2, xrDef - x, h);
		}
		else
		{
			if(iSects & 0x00ff)
			{
				if(iSects & 0x02)
					xl = Math.max(x, aBndZ[y]);
				else
					xl = x;
				if(iSects & 0x01)
					xr = Math.min(xrDef, aBndA[y]);
				else
					xr = xrDef;
				y2 = cy - y - h;
				w = xr - xl;
				if(w > 0) this._mkDiv(xl, y2, w, h);
			}
			if(iSects & 0xff00)
			{
				if(iSects & 0x0100)
					xl = Math.max(x, aBndA[y]);
				else
					xl = x;
				if(iSects & 0x0200)
					xr = Math.min(xrDef, aBndZ[y]);
				else
					xr = xrDef;
				y2 = cy + y + (iOdds >> 16);
				w = xr - xl;
				if(w > 0) this._mkDiv(xl, y2, w, h);
			}
		}
	};

	this.setStroke(1);
	this.setFont("verdana,geneva,helvetica,sans-serif", "12px", Font.PLAIN);
	this.color = "#000000";
	this.htm = "";
	this.wnd = wnd || window;

	if(!jg_ok) _chkDHTM();
	if(jg_ok)
	{
		if(cnv)
		{
			if(typeof(cnv) == "string")
				this.cont = document.all? (this.wnd.document.all[cnv] || null)
					: document.getElementById? (this.wnd.document.getElementById(cnv) || null)
					: null;
			else if(cnv == window.document)
				this.cont = document.getElementsByTagName("body")[0];
			// If cnv is a direct reference to a canvas DOM node
			// (option suggested by Andreas Luleich)
			else this.cont = cnv;
			// Create new canvas inside container DIV. Thus the drawing and clearing
			// methods won't interfere with the container's inner html.
			// Solution suggested by Vladimir.
			this.cnv = this.wnd.document.createElement("div");
			this.cnv.style.fontSize=0;
			this.cont.appendChild(this.cnv);
			this.paint = jg_dom? _pntCnvDom : _pntCnvIe;
		}
		else
			this.paint = _pntDoc;
	}
	else
		this.paint = _pntN;

	this.setPrintable(false);
}

function _mkLinVirt(aLin, x1, y1, x2, y2)
{
	var dx = Math.abs(x2-x1), dy = Math.abs(y2-y1),
	x = x1, y = y1,
	xIncr = (x1 > x2)? -1 : 1,
	yIncr = (y1 > y2)? -1 : 1,
	p,
	i = 0;
	if(dx >= dy)
	{
		var pr = dy<<1,
		pru = pr - (dx<<1);
		p = pr-dx;
		while(dx > 0)
		{--dx;
			if(p > 0)    //  Increment y
			{
				aLin[i++] = x;
				y += yIncr;
				p += pru;
			}
			else p += pr;
			x += xIncr;
		}
	}
	else
	{
		var pr = dx<<1,
		pru = pr - (dy<<1);
		p = pr-dy;
		while(dy > 0)
		{--dy;
			y += yIncr;
			aLin[i++] = x;
			if(p > 0)    //  Increment x
			{
				x += xIncr;
				p += pru;
			}
			else p += pr;
		}
	}
	for(var len = aLin.length, i = len-i; i;)
		aLin[len-(i--)] = x;
};

function _CompInt(x, y)
{
	return(x - y);
}

