﻿<?xml version="1.0" encoding="UTF-8" ?> 
<Module>
  <ModulePrefs title="JS function ver.1_2_2" 
	height="490" 
	author="Soichiro Takeda" 
	author_email="info@samurai-logic.com" 
	title_url="http://www.samurai-logic.com/" 
	screenshot="http://www.samurai-logic.com/gadget/img/js122.png" 
	thumbnail="http://www.samurai-logic.com/gadget/img/function2.png" 
	description="read data to run javascript function or create canvas graph image." /> 
  <Content type="html">
     <![CDATA[ 

<script type="text/javascript">

if ((!window.CanvasRenderingContext2D) && (/MSIE/.test(navigator.userAgent))) {

(function () {
  var m = Math;
  var mr = m.round;
  var ms = m.sin;
  var mc = m.cos;
  var Z = 10;
  var Z2 = Z / 2;

  var G_vmlCanvasManager_ = {
    init: function (opt_doc) {
      var doc = opt_doc || document;
      if (/MSIE/.test(navigator.userAgent) && !window.opera) {
        var self = this;
        doc.attachEvent("onreadystatechange", function () {
          self.init_(doc);
        });
      }
    },

    init_: function (doc) {
      if (doc.readyState == "complete") {
        if (!doc.namespaces["g_vml_"]) {
          doc.namespaces.add("g_vml_", "urn:schemas-microsoft-com:vml");
        }
        var ss = doc.createStyleSheet();
        ss.cssText = "canvas{display:inline-block;overflow:hidden;" +
            "text-align:left;width:300px;height:150px}" +
            "g_vml_\\:*{behavior:url(#default#VML)}";

        var els = doc.getElementsByTagName("canvas");
        for (var i = 0; i < els.length; i++) {
          if (!els[i].getContext) {
            this.initElement(els[i]);
          }
        }
      }
    },

    fixElement_: function (el) {
      var outerHTML = el.outerHTML;

      var newEl = el.ownerDocument.createElement(outerHTML);
      if (outerHTML.slice(-2) != "/>") {
        var tagName = "/" + el.tagName;
        var ns;

        while ((ns = el.nextSibling) && ns.tagName != tagName) {
          ns.removeNode();
        }
        if (ns) {
          ns.removeNode();
        }
      }
      el.parentNode.replaceChild(newEl, el);
      return newEl;
    },
    initElement: function (el) {
      el = this.fixElement_(el);
      el.getContext = function () {
        if (this.context_) {
          return this.context_;
        }
        return this.context_ = new CanvasRenderingContext2D_(this);
      };
      el.attachEvent('onpropertychange', onPropertyChange);
      el.attachEvent('onresize', onResize);

      var attrs = el.attributes;
      if (attrs.width && attrs.width.specified) {
        el.style.width = attrs.width.nodeValue + "px";
      } else {
        el.width = el.clientWidth;
      }
      if (attrs.height && attrs.height.specified) {
        el.style.height = attrs.height.nodeValue + "px";
      } else {
        el.height = el.clientHeight;
      }
      return el;
    }
  };

  function onPropertyChange(e) {
    var el = e.srcElement;

    switch (e.propertyName) {
      case 'width':
        el.style.width = el.attributes.width.nodeValue + "px";
        el.getContext().clearRect();
        break;
      case 'height':
        el.style.height = el.attributes.height.nodeValue + "px";
        el.getContext().clearRect();
        break;
    }
  }

  function onResize(e) {
    var el = e.srcElement;
    if (el.firstChild) {
      el.firstChild.style.width =  el.clientWidth + 'px';
      el.firstChild.style.height = el.clientHeight + 'px';
    }
  }

  G_vmlCanvasManager_.init();
  var dec2hex = [];
  for (var i = 0; i < 16; i++) {
    for (var j = 0; j < 16; j++) {
      dec2hex[i * 16 + j] = i.toString(16) + j.toString(16);
    }
  }
  function createMatrixIdentity() {
    return [
      [1, 0, 0],
      [0, 1, 0],
      [0, 0, 1]
    ];
  }

  function matrixMultiply(m1, m2) {
    var result = createMatrixIdentity();

    for (var x = 0; x < 3; x++) {
      for (var y = 0; y < 3; y++) {
        var sum = 0;

        for (var z = 0; z < 3; z++) {
          sum += m1[x][z] * m2[z][y];
        }

        result[x][y] = sum;
      }
    }
    return result;
  }

/*********************************************************
   Modified(test) 23 July,2008 samurai-logic.com
**********************************************************/


  function matrixMultiply2(m1, m2) {
    var result = createMatrixIdentity();

	result[0][0]=eval(m1[0][0]*m2[0][0])+eval(m1[1][0]*m2[0][1]);//a1*a2+c1*b2
	result[0][1]=eval(m1[0][1]*m2[0][0])+eval(m1[1][1]*m2[0][1]);//b1*a2+d1*b2
	result[0][2]=0;

	result[1][0]=eval(m1[0][0]*m2[1][0])+eval(m1[1][0]*m2[1][1]);//a1*c2+c1*d2
	result[1][1]=eval(m1[0][1]*m2[1][0])+eval(m1[1][1]*m2[1][1]);//b1*c2+d1*d2
	result[1][2]=0;

	result[2][0]=eval(m1[0][0]*m2[2][0])+eval(m1[1][0]*m2[2][1]);//+eval(m1[2][0]);//a1*e2+c1*f2+e1
	result[2][1]=eval(m1[0][1]*m2[2][0])+eval(m1[1][1]*m2[2][1]);//+eval(m1[2][1]);//b1*e2+d1*f2+f1
	result[2][2]=1;

    return result;
  }


  function copyState(o1, o2) {
    o2.fillStyle     = o1.fillStyle;
    o2.lineCap       = o1.lineCap;
    o2.lineJoin      = o1.lineJoin;
    o2.lineWidth     = o1.lineWidth;
    o2.miterLimit    = o1.miterLimit;
    o2.shadowBlur    = o1.shadowBlur;
    o2.shadowColor   = o1.shadowColor;
    o2.shadowOffsetX = o1.shadowOffsetX;
    o2.shadowOffsetY = o1.shadowOffsetY;
    o2.strokeStyle   = o1.strokeStyle;
    o2.arcScaleX_    = o1.arcScaleX_;
    o2.arcScaleY_    = o1.arcScaleY_;
  }

  function processStyle(styleString) {
    var str, alpha = 1;

    styleString = String(styleString);
    if (styleString.substring(0, 3) == "rgb") {
      var start = styleString.indexOf("(", 3);
      var end = styleString.indexOf(")", start + 1);
      var guts = styleString.substring(start + 1, end).split(",");

      str = "#";
      for (var i = 0; i < 3; i++) {
        str += dec2hex[Number(guts[i])];
      }

      if ((guts.length == 4) && (styleString.substr(3, 1) == "a")) {
        alpha = guts[3];
      }
    } else {
      str = styleString;
    }

    return [str, alpha];
  }

  function processLineCap(lineCap) {
    switch (lineCap) {
      case "butt":
        return "flat";
      case "round":
        return "round";
      case "square":
      default:
        return "square";
    }
  }

   function CanvasRenderingContext2D_(surfaceElement) {
    this.m_ = createMatrixIdentity();
    this.mStack_ = [];
    this.aStack_ = [];
    this.currentPath_ = [];
    this.strokeStyle = "#000";
    this.fillStyle = "#000";
    this.lineWidth = 1;
    this.lineJoin = "miter";
    this.lineCap = "butt";
    this.miterLimit = Z * 1;
    this.globalAlpha = 1;
    this.canvas = surfaceElement;

    var el = surfaceElement.ownerDocument.createElement('div');
    el.style.width =  surfaceElement.clientWidth + 'px';
    el.style.height = surfaceElement.clientHeight + 'px';
    el.style.overflow = 'hidden';
    el.style.position = 'absolute';
    surfaceElement.appendChild(el);

    this.element_ = el;
    this.arcScaleX_ = 1;
    this.arcScaleY_ = 1;
  };

  var contextPrototype = CanvasRenderingContext2D_.prototype;
  contextPrototype.clearRect = function() {
    this.element_.innerHTML = "";
    this.currentPath_ = [];
  };

  contextPrototype.beginPath = function() {
    this.currentPath_ = [];
  };

  contextPrototype.moveTo = function(aX, aY) {
    this.currentPath_.push({type: "moveTo", x: aX, y: aY});
    this.currentX_ = aX;
    this.currentY_ = aY;
  };

  contextPrototype.lineTo = function(aX, aY) {
    this.currentPath_.push({type: "lineTo", x: aX, y: aY});
    this.currentX_ = aX;
    this.currentY_ = aY;
  };

  contextPrototype.bezierCurveTo = function(aCP1x, aCP1y,
                                            aCP2x, aCP2y,
                                            aX, aY) {
    this.currentPath_.push({type: "bezierCurveTo",
                           cp1x: aCP1x,
                           cp1y: aCP1y,
                           cp2x: aCP2x,
                           cp2y: aCP2y,
                           x: aX,
                           y: aY});
    this.currentX_ = aX;
    this.currentY_ = aY;
  };

  contextPrototype.quadraticCurveTo = function(aCPx, aCPy, aX, aY) {

    var cp1x = this.currentX_ + 2.0 / 3.0 * (aCPx - this.currentX_);
    var cp1y = this.currentY_ + 2.0 / 3.0 * (aCPy - this.currentY_);
    var cp2x = cp1x + (aX - this.currentX_) / 3.0;
    var cp2y = cp1y + (aY - this.currentY_) / 3.0;
    this.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, aX, aY);
  };

  contextPrototype.arc = function(aX, aY, aRadius,
                                  aStartAngle, aEndAngle, aClockwise) {
    aRadius *= Z;
    var arcType = aClockwise ? "at" : "wa";

    var xStart = aX + (mc(aStartAngle) * aRadius) - Z2;
    var yStart = aY + (ms(aStartAngle) * aRadius) - Z2;

    var xEnd = aX + (mc(aEndAngle) * aRadius) - Z2;
    var yEnd = aY + (ms(aEndAngle) * aRadius) - Z2;

    if (xStart == xEnd && !aClockwise) {
      xStart += 0.125; 
    }

    this.currentPath_.push({type: arcType,
                           x: aX,
                           y: aY,
                           radius: aRadius,
                           xStart: xStart,
                           yStart: yStart,
                           xEnd: xEnd,
                           yEnd: yEnd});

  };

  contextPrototype.rect = function(aX, aY, aWidth, aHeight) {
    this.moveTo(aX, aY);
    this.lineTo(aX + aWidth, aY);
    this.lineTo(aX + aWidth, aY + aHeight);
    this.lineTo(aX, aY + aHeight);
    this.closePath();
  };

  contextPrototype.strokeRect = function(aX, aY, aWidth, aHeight) {
    // Will destroy any existing path (same as FF behaviour)
    this.beginPath();
    this.moveTo(aX, aY);
    this.lineTo(aX + aWidth, aY);
    this.lineTo(aX + aWidth, aY + aHeight);
    this.lineTo(aX, aY + aHeight);
    this.closePath();
    this.stroke();
  };

  contextPrototype.fillRect = function(aX, aY, aWidth, aHeight) {
    // Will destroy any existing path (same as FF behaviour)
    this.beginPath();
    this.moveTo(aX, aY);
    this.lineTo(aX + aWidth, aY);
    this.lineTo(aX + aWidth, aY + aHeight);
    this.lineTo(aX, aY + aHeight);
    this.closePath();
    this.fill();
  };

  contextPrototype.createLinearGradient = function(aX0, aY0, aX1, aY1) {
    var gradient = new CanvasGradient_("gradient");
    return gradient;
  };

  contextPrototype.createRadialGradient = function(aX0, aY0,
                                                   aR0, aX1,
                                                   aY1, aR1) {
    var gradient = new CanvasGradient_("gradientradial");
    gradient.radius1_ = aR0;
    gradient.radius2_ = aR1;
    gradient.focus_.x = aX0;
    gradient.focus_.y = aY0;
    return gradient;
  };

  contextPrototype.drawImage = function (image, var_args) {
    var dx, dy, dw, dh, sx, sy, sw, sh;

    var oldRuntimeWidth = image.runtimeStyle.width;
    var oldRuntimeHeight = image.runtimeStyle.height;
    image.runtimeStyle.width = 'auto';
    image.runtimeStyle.height = 'auto';

    var w = image.width;
    var h = image.height;

    image.runtimeStyle.width = oldRuntimeWidth;
    image.runtimeStyle.height = oldRuntimeHeight;

    if (arguments.length == 3) {
      dx = arguments[1];
      dy = arguments[2];
      sx = sy = 0;
      sw = dw = w;
      sh = dh = h;
    } else if (arguments.length == 5) {
      dx = arguments[1];
      dy = arguments[2];
      dw = arguments[3];
      dh = arguments[4];
      sx = sy = 0;
      sw = w;
      sh = h;
    } else if (arguments.length == 9) {
      sx = arguments[1];
      sy = arguments[2];
      sw = arguments[3];
      sh = arguments[4];
      dx = arguments[5];
      dy = arguments[6];
      dw = arguments[7];
      dh = arguments[8];
    } else {
      throw "Invalid number of arguments";
    }

    var d = this.getCoords_(dx, dy);

    var w2 = sw / 2;
    var h2 = sh / 2;

    var vmlStr = [];

    var W = 10;
    var H = 10;

    vmlStr.push(' <g_vml_:group',
                ' coordsize="', Z * W, ',', Z * H, '"',
                ' coordorigin="0,0"' ,
                ' style="width:', W, ';height:', H, ';position:absolute;');

    if (this.m_[0][0] != 1 || this.m_[0][1]) {
      var filter = [];

      filter.push("M11='", this.m_[0][0], "',",
                  "M12='", this.m_[1][0], "',",
                  "M21='", this.m_[0][1], "',",
                  "M22='", this.m_[1][1], "',",
                  "Dx='", mr(d.x / Z), "',",
                  "Dy='", mr(d.y / Z), "'");

      var max = d;
      var c2 = this.getCoords_(dx + dw, dy);
      var c3 = this.getCoords_(dx, dy + dh);
      var c4 = this.getCoords_(dx + dw, dy + dh);

      max.x = Math.max(max.x, c2.x, c3.x, c4.x);
      max.y = Math.max(max.y, c2.y, c3.y, c4.y);

      vmlStr.push("padding:0 ", mr(max.x / Z), "px ", mr(max.y / Z),
                  "px 0;filter:progid:DXImageTransform.Microsoft.Matrix(",
                  filter.join(""), ", sizingmethod='clip');")
    } else {
      vmlStr.push("top:", mr(d.y / Z), "px;left:", mr(d.x / Z), "px;")
    }

    vmlStr.push(' ">' ,
                '<g_vml_:image src="', image.src, '"',
                ' style="width:', Z * dw, ';',
                ' height:', Z * dh, ';"',
                ' cropleft="', sx / w, '"',
                ' croptop="', sy / h, '"',
                ' cropright="', (w - sx - sw) / w, '"',
                ' cropbottom="', (h - sy - sh) / h, '"',
                ' />',
                '</g_vml_:group>');

    this.element_.insertAdjacentHTML("BeforeEnd",
                                    vmlStr.join(""));
  };

  contextPrototype.stroke = function(aFill) {
    var lineStr = [];
    var lineOpen = false;
    var a = processStyle(aFill ? this.fillStyle : this.strokeStyle);
    var color = a[0];
    var opacity = a[1] * this.globalAlpha;

    var W = 10;
    var H = 10;

    lineStr.push('<g_vml_:shape',
                 ' fillcolor="', color, '"',
                 ' filled="', Boolean(aFill), '"',
                 ' style="position:absolute;width:', W, ';height:', H, ';"',
                 ' coordorigin="0 0" coordsize="', Z * W, ' ', Z * H, '"',
                 ' stroked="', !aFill, '"',
                 ' strokeweight="', this.lineWidth, '"',
                 ' strokecolor="', color, '"',
                 ' path="');

    var newSeq = false;
    var min = {x: null, y: null};
    var max = {x: null, y: null};

    for (var i = 0; i < this.currentPath_.length; i++) {
      var p = this.currentPath_[i];

      if (p.type == "moveTo") {
        lineStr.push(" m ");
        var c = this.getCoords_(p.x, p.y);
        lineStr.push(mr(c.x), ",", mr(c.y));
      } else if (p.type == "lineTo") {
        lineStr.push(" l ");
        var c = this.getCoords_(p.x, p.y);
        lineStr.push(mr(c.x), ",", mr(c.y));
      } else if (p.type == "close") {
        lineStr.push(" x ");
      } else if (p.type == "bezierCurveTo") {
        lineStr.push(" c ");
        var c = this.getCoords_(p.x, p.y);
        var c1 = this.getCoords_(p.cp1x, p.cp1y);
        var c2 = this.getCoords_(p.cp2x, p.cp2y);
        lineStr.push(mr(c1.x), ",", mr(c1.y), ",",
                     mr(c2.x), ",", mr(c2.y), ",",
                     mr(c.x), ",", mr(c.y));
      } else if (p.type == "at" || p.type == "wa") {
        lineStr.push(" ", p.type, " ");
        var c  = this.getCoords_(p.x, p.y);
        var cStart = this.getCoords_(p.xStart, p.yStart);
        var cEnd = this.getCoords_(p.xEnd, p.yEnd);

        lineStr.push(mr(c.x - this.arcScaleX_ * p.radius), ",",
                     mr(c.y - this.arcScaleY_ * p.radius), " ",
                     mr(c.x + this.arcScaleX_ * p.radius), ",",
                     mr(c.y + this.arcScaleY_ * p.radius), " ",
                     mr(cStart.x), ",", mr(cStart.y), " ",
                     mr(cEnd.x), ",", mr(cEnd.y));
      }

      if(c) {
        if (min.x == null || c.x < min.x) {
          min.x = c.x;
        }
        if (max.x == null || c.x > max.x) {
          max.x = c.x;
        }
        if (min.y == null || c.y < min.y) {
          min.y = c.y;
        }
        if (max.y == null || c.y > max.y) {
          max.y = c.y;
        }
      }
    }
    lineStr.push(' ">');

    if (typeof this.fillStyle == "object") {
      var focus = {x: "50%", y: "50%"};
      var width = (max.x - min.x);
      var height = (max.y - min.y);
      var dimension = (width > height) ? width : height;

      focus.x = mr((this.fillStyle.focus_.x / width) * 100 + 50) + "%";
      focus.y = mr((this.fillStyle.focus_.y / height) * 100 + 50) + "%";

      var colors = [];

      if (this.fillStyle.type_ == "gradientradial") {
        var inside = (this.fillStyle.radius1_ / dimension * 100);

        var expansion = (this.fillStyle.radius2_ / dimension * 100) - inside;
      } else {
        var inside = 0;
        var expansion = 100;
      }

      var insidecolor = {offset: null, color: null};
      var outsidecolor = {offset: null, color: null};

      this.fillStyle.colors_.sort(function (cs1, cs2) {
        return cs1.offset - cs2.offset;
      });

      for (var i = 0; i < this.fillStyle.colors_.length; i++) {
        var fs = this.fillStyle.colors_[i];

        colors.push( (fs.offset * expansion) + inside, "% ", fs.color, ",");

        if (fs.offset > insidecolor.offset || insidecolor.offset == null) {
          insidecolor.offset = fs.offset;
          insidecolor.color = fs.color;
        }

        if (fs.offset < outsidecolor.offset || outsidecolor.offset == null) {
          outsidecolor.offset = fs.offset;
          outsidecolor.color = fs.color;
        }
      }
      colors.pop();

      lineStr.push('<g_vml_:fill',
                   ' color="', outsidecolor.color, '"',
                   ' color2="', insidecolor.color, '"',
                   ' type="', this.fillStyle.type_, '"',
                   ' focusposition="', focus.x, ', ', focus.y, '"',
                   ' colors="', colors.join(""), '"',
                   ' opacity="', opacity, '" />');
    } else if (aFill) {
      lineStr.push('<g_vml_:fill color="', color, '" opacity="', opacity, '" />');
    } else {
      lineStr.push(
        '<g_vml_:stroke',
        ' opacity="', opacity,'"',
        ' joinstyle="', this.lineJoin, '"',
        ' miterlimit="', this.miterLimit, '"',
        ' endcap="', processLineCap(this.lineCap) ,'"',
        ' weight="', this.lineWidth, 'px"',
        ' color="', color,'" />'
      );
    }

    lineStr.push("</g_vml_:shape>");

    this.element_.insertAdjacentHTML("beforeEnd", lineStr.join(""));

    this.currentPath_ = [];
  };

  contextPrototype.fill = function() {
    this.stroke(true);
  }

  contextPrototype.closePath = function() {
    this.currentPath_.push({type: "close"});
  };

  /**
   * @private
   */
  contextPrototype.getCoords_ = function(aX, aY) {
    return {
      x: Z * (aX * this.m_[0][0] + aY * this.m_[1][0] + this.m_[2][0]) - Z2,
      y: Z * (aX * this.m_[0][1] + aY * this.m_[1][1] + this.m_[2][1]) - Z2
    }
  };

  contextPrototype.save = function() {
    var o = {};
    copyState(this, o);
    this.aStack_.push(o);
    this.mStack_.push(this.m_);
    this.m_ = matrixMultiply(createMatrixIdentity(), this.m_);
  };

  contextPrototype.restore = function() {
    copyState(this.aStack_.pop(), this);
    this.m_ = this.mStack_.pop();
  };
 
/******************************************************* 

 Add "setmatrix" attribute 23 July,2008 samurai-logic.com 

********************************************************/

  contextPrototype.setmatrix = function(aM,bM,cM,dM,eM,fM) {
    var m1 = [
      [aM, bM, 0],
      [cM, dM, 0],
      [eM, fM, 1]
    ];
    var m2 = [
      [1,  0,  0],
      [0,  1,  0],
      [eM, fM, 1]
    ];
    this.m_ = m1;//matrixMultiply(m1,m2);
  }

  contextPrototype.translate = function(aX, aY) {
    var m1 = [
      [1,  0,  0],
      [0,  1,  0],
      [aX, aY, 1]
    ];

    this.m_ = matrixMultiply(m1, this.m_);
  };

  contextPrototype.rotate = function(aRot) {
    var c = mc(aRot);
    var s = ms(aRot);

    var m1 = [
      [c,  s, 0],
      [-s, c, 0],
      [0,  0, 1]
    ];

    this.m_ = matrixMultiply(m1, this.m_);
  };

  contextPrototype.scale = function(aX, aY) {
    this.arcScaleX_ *= aX;
    this.arcScaleY_ *= aY;
    var m1 = [
      [aX, 0,  0],
      [0,  aY, 0],
      [0,  0,  1]
    ];

    this.m_ = matrixMultiply(m1, this.m_);
  };

  contextPrototype.clip = function() {
  };

  contextPrototype.arcTo = function() {
  };

  contextPrototype.createPattern = function() {
    return new CanvasPattern_;
  };
  function CanvasGradient_(aType) {
    this.type_ = aType;
    this.radius1_ = 0;
    this.radius2_ = 0;
    this.colors_ = [];
    this.focus_ = {x: 0, y: 0};
  }
  CanvasGradient_.prototype.addColorStop = function(aOffset, aColor) {
    aColor = processStyle(aColor);
    this.colors_.push({offset: 1-aOffset, color: aColor});
  };
  function CanvasPattern_() {}
  G_vmlCanvasManager = G_vmlCanvasManager_;
  CanvasRenderingContext2D = CanvasRenderingContext2D_;
  CanvasGradient = CanvasGradient_;
  CanvasPattern = CanvasPattern_;

})();

} // if

var H=100;
var H2=100; //height of textarea function1,2,3  tt[4] to tt[6]
var T=134;  //top of textarea function1,2,3  tt[4] to tt[6]
var up=0; // up is zIndex of layer which is currently shown
var zi=6; // zi is zIndex of layer
var tt=["A","B","C","D","E","F","G"];
var ll=["lay1","lay2","lay3","lay4","lay5","lay6","lay7"];
var tb=["tb1","tb2","tb3","tb4","tb5","tb6","tb7"];
var gpi=["tit","pi1","pi2","pi3","pi4","pi5","pi6","pi7","pi8","pi9","pi10","pi11","pi12"];
var gbar=["tit","bar1","bar2","bar3","bar4","bar5","bar6","bar7","bar8","bar9","bar10",
	  "bar11","bar12","bar13","bar14","bar15","bar16","bar17","bar18","bar19","bar20",
	  "bar21","bar22","bar23","bar24","bar25","bar26","bar27","bar28","bar29","bar30",
	  "bar31","bar32","bar33","bar34","bar35","bar36","bar37","bar38","bar39","bar40",
  	  "bar41","bar42","bar43","bar44","bar45","bar46","bar47","bar48","bar49","bar50",
	  "grid1","grid2","grid3","grid4"];

data1=new Array();
data2=new Array();
data3=new Array();

function $s(id){ /* this function will select textarea when ondblclick event */
var el=$id(id);
el.select();
}

function $id(id){
 var element = document.getElementById(id);
 return element = (!element) ? $info(id,"D") : element;
}

function $info(id,out){
var el=$id(out);
el.value='"'+id+'" not found.';
$cc(4);
}


function $cc_A(n){

   for (var i=0;i<4;i++){
     var tx=$id(tt[i]);
     var ly=$id(ll[i]);

     if (window.attachEvent && !window.opera){
	ly.style.cssText = "height:"+H+"px; width:265px;";
	tx.style.cssText = "height:"+H+"px; width:265px;";
     }else{
	ly.setAttribute("style", "height:"+H+"px; width:265px;");
	tx.setAttribute("style", "height:"+H+"px; width:265px;");
     }	
   }
   for (var i=4;i<7;i++){
     var tx=$id(tt[i]);
     var ly=$id(ll[i]);

     if (window.attachEvent && !window.opera){
	ly.style.cssText = "height:"+H2+"px; top:"+T+"px; width:265px;";
	tx.style.cssText = "height:"+H2+"px; top:"+T+"px; width:265px;";
     }else{
	ly.setAttribute("style", "height:"+H2+"px; top:"+T+"px; width:265px;");
	tx.setAttribute("style", "height:"+H2+"px; top:"+T+"px; width:265px;");
     }	
   }

}

var tempH,tempT,tempH2;

function $cc(n) {  /* this fucntion change layer when tab is clicked */

// for Google Chrome and Safari (movable textarea)

//  if (/Chrome/.test(navigator.userAgent) || (/Safari/.test(navigator.userAgent))) $cc_A(n);

var layn=$id(ll[n-1]);
var tabn=$id(tb[n-1]);
var el=$id(tt[n-1]);
//if (eval(n) == up) {el.focus(); return;}
layn.style.zIndex=zi+1;
tabn.style.zIndex=zi+1;
up=n; zi+=5; 
el.focus();
}

/* this function change font-size of all textarea tt["A" to "G"] */

function $fs(fs) {
//var fs=$id("fs").value;
 for (i=0;i<tt.length;i++){
  var id=$id(tt[i]);
  id.style.fontSize=fs.value;
 }
}

/* this function change font-family of all textarea tt["A" to "G"] */

function $ff(ff) {
 for (i=0;i<tt.length;i++){
  var id=$id(tt[i]);
  id.style.fontFamily=ff.value;
 }
}

/************************ Animation ******************************/

var lmt=0;
var ht=0;
var flag=false; /* this var is avoid error. while flag is true, layer is animating.  */
var spn=60; /* this is span of animating */

function $up() {
if (H<=spn-20 || flag==true) return;
flag=true;
timer=setInterval("$mv(-4,-spn)",10);
}

function $dwn() {
if (H>=100+spn || flag==true) return;
flag=true;
timer=setInterval("$mv(4,spn)",10);
}

/*************************************/
function $mv(x,xx){
  if (lmt==xx) {
   T=eval(H+34+ht);
   clearInterval(timer); if (x>=0) H+=60; else H-=60;
   flag=false;
   delete ttt; delete ff; delete fs;
   ht=0;lmt=0;return;
  }

var ff=$id("ff").value;
var fs=$id("fs").value;
var ttt=0; /* this var ttt will ajust layer height */

if (H==160) ttt=-120; /* adjust height and top */
if (H==40) ttt=120;
 
 ht=lmt+x;
 H2=eval(H-ht+ttt);

  for (var i=4;i<7;i++){
     var tx=$id(tt[i]);
     var ly=$id(ll[i]);
     if (window.attachEvent && !window.opera){
	ly.style.cssText = "height:"+H2+"px; top:"+eval(H+34+ht)+"px;";
	tx.style.cssText = "height:"+H2+"px; top:"+eval(H+34+ht)+"px;font-size:"+fs+";font-family:"+ff+";";
     }else{
	ly.setAttribute("style", "height:"+H2+"px; top:"+eval(H+34+ht)+"px;z-index:"+eval(7-i)+";");
	tx.setAttribute("style", "height:"+H2+"px; top:"+eval(H+34+ht)+"px;z-index:"+eval(7-i)+";font-size:"+fs+";font-family:"+ff+";");
     }	
  }
  for (var i=0;i<4;i++){
     var tx=$id(tt[i]);
     var ly=$id(ll[i]);
     if (window.attachEvent && !window.opera){
	ly.style.cssText = "height:"+eval(H+ht)+"px;";
	tx.style.cssText = "height:"+eval(H+ht)+"px;font-size:"+fs+";font-family:"+ff+";";
     }else{
	ly.setAttribute("style", "height:"+eval(H+ht)+"px;z-index:"+eval(4-i)+";");
	tx.setAttribute("style", "height:"+eval(H+ht)+"px;z-index:"+eval(4-i)+";font-size:"+fs+";font-family:"+ff+";");
     }
  }
lmt+=x; /* x = 3 */
}

/********************************** Tool Box animation *****************************/

var grow=false; // grow is "true" at first position
var add=0;
var span=0;
var tW=0;
var tH=0;
var tT=0;
var tL=0;
var dif=0;

function $tool(id,ht,wt){
	if(flag==true) return;
	flag=true;
//grow=true==>laybox is opened
	if(grow==true) {mv=5;tW=wt*2;tH=wt;tT=298-wt;tL=262-wt*2;span=wt;
	  temp2=$id("slct"); document.body.removeChild(temp2);
	  temp2=$id("slct2"); document.body.removeChild(temp2);
	  temp2=$id("tools"); document.body.removeChild(temp2);
	} 
	else {mv=-5;tW=0;tH=0;tT=298;tL=262;span=-wt;}
	nm=new String(id);

   if (window.attachEvent && !window.opera) {
	if(grow==true) {tW=wt*2+5; tH=wt+5; tT=298-wt; tL=262-wt*2;} 
	else {tT=284; tL=262; tW=5;tH=20;}
   }
	toolbox=setInterval("$toolAnimation(nm,mv,span)",12);

}

dts=["data1","data2","data3"];
tool=["strip tags","escape html","unescape html","escape string","unescape string","create table"];

function $toolAnimation(id,x,z){ /* x=width y=height z=span */
  if (lmt==z) { /* limit increase by x(mv) each call untill it rearch z(span) */
	clearInterval(toolbox);
	var temp=$id("boxbutton");	
	if (x>0) {
	  grow=false; temp.value="Open";
	}else {grow=true; temp.value="Close";
	    var el = document.createElement("select");
	    el.setAttribute("id","slct");
	    el.setAttribute("title","select data");
	    document.body.appendChild(el);

	    for (var i=0;i<=dts.length-1;i++){
	      var op=document.createElement("option");
	      op.setAttribute("value",dts[i]);
	      op.innerHTML=dts[i];
	      el.appendChild(op); 
	    }

	    var el2 = document.createElement("select");
	    el2.setAttribute("id","slct2");
	    el2.setAttribute("title","select command from menu");
	    document.body.appendChild(el2);

	    for (var i=0;i<=tool.length-1;i++){
	      var op2=document.createElement("option");
	      op2.setAttribute("value",tool[i]);
	      op2.innerHTML=tool[i];
	      el2.appendChild(op2); 
	    }
	    var el3 = document.createElement("button");
	    el3.setAttribute("id","tools");
	    el3.setAttribute("title","execute command");
	    el3.setAttribute("value","execute");el3.innerHTML="execute";
	    document.body.appendChild(el3);

		el3.onclick=function(){$TOOL();}
	}

	delete temp; 
	flag=false;
	add=0;lmt=0;dif=0;return;
  }

	var el=$id(id);
	add=lmt+x;

	/************* Width & Height & TOP & LEFT ***********/

     if(add<=-42) dif=add+42;
     else if(add>=0) dif=add/1.45-90;//dif=add/1.5-90;
if (window.attachEvent && !window.opera && add<=-28) dif=add+28;
if (window.attachEvent && !window.opera && add>=0) dif=add/1.20-90;

	if (window.attachEvent && !window.opera){
	  el.style.cssText = "width:"+eval(tW-add*2)+"px; height:"+eval(tH-(add-dif))+"px;top:"+eval(tT+add-dif)+"px;left:"+eval(tL+add*2)+"px;";
 	}else{
	  el.setAttribute("style", "width:"+eval(tW-add*2)+"px; height:"+eval(tH-(add-dif))+"px;top:"+eval(tT+add-dif)+"px;left:"+eval(tL+add*2)+"px;");
	}
	lmt+=x;
}

/****************** $TOOL ********************************/
/* tool[]
0:"strip tags" 1:"escape html" 2:"unescape html"
3:"escape string"4:"unescape string" 5:"create table"
*/

function $TOOL(){
var dt = $id("slct").value;
var exc=$id("slct2").value;
var D=$id("D");
//alert(dt+":"+exc);

if (exc==tool[5]) $r(dt.replace(/a/g,""));

  switch(dt){
	case dts[0]: var str=$id("A").value; var data=data1; break;
	case dts[1]: var str=$id("B").value; var data=data2; break;
	case dts[2]: var str=$id("C").value; var data=data3; break;
	default: break;
  }

if (str=="" || str==null) {D.value='no data : '+dt; $cc(4); return;}

  switch(exc){
	case tool[0]: D.value=str.replace(/<\/?[^>]+>/gi," ").replace(/\n\s*/g,"\n").replace(/^\s+|\s+$|\s+(?!\S)/g,""); $cc(4); break;

	case tool[1]: D.value=str.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"); $cc(4); break;
	case tool[2]: D.value=str.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/(&#39;|&#039(\;?))/g,"'"); $cc(4); break;

	case tool[3]: D.value=escape(str); $cc(4); break;
	case tool[4]: D.value=unescape(str); $cc(4); break;
	case tool[5]: var str="<table>";
		      for(var i=0; i<data.length;i++){
			str+="<tr>"; 
			  for(var j=0; j<data[i].length; j++) str+="<td>"+data[i][j]+"</td>";
			str+="</tr>\n";
		      }
			str+="</table>"; D.value=str; $cc(4); break;

	default: break;
  }
delete str; delete dt; delete D; delete exc;
}

/******************  $r read data ************************/
function $r(dt){

reg=/\d\,\d{3}/g; /* test number */

 switch(dt){
 case "dt1":
	var sortData=$id("A").value; 
	if(sortData=="") break;
	var sortData=fmd(sortData);
	data1=sortData.split("\n");
	for(var i=0; i<data1.length; i++) {
	 // if (typeof data1[i]!="undefined"){
	     data1[i]=data1[i].split(" ");
 	     if (data1[i][0]=="") data1[i].shift(); //in case of bug
		for (var j=0;j<data1[i].length;j++){
		  if (reg.test(data1[i][j])) data1[i][j]=data1[i][j].replace(/,/g,"");

		  if (isNaN(data1[i][j])==false)
		    data1[i][j]=eval(data1[i][j]); /* if data is number then eval data */
		}
	 // }
	}
	break;

 case "dt2":
	var sortData=$id("B").value;
	if(sortData=="") break;
	var sortData=fmd(sortData);

	data2=sortData.split("\n");
	for(var i=0; i<data2.length; i++) {
	  data2[i]=data2[i].split(" ");
	  if (data2[i][0]=="") data2[i].shift();
		for (var j=0;j<data2[i].length;j++){
		  if (reg.test(data2[i][j])) data2[i][j]=data2[i][j].replace(/,/g,"");
		  if (isNaN(data2[i][j])==false)
		    data2[i][j]=eval(data2[i][j]);
		}
	}
	break;

 case "dt3":
	var sortData=$id("C").value;
	if(sortData=="") break;
	var sortData=fmd(sortData);
	
	data3=sortData.split("\n");
	for(var i=0; i<data3.length; i++) {
	   data3[i]=data3[i].split(" ");
	   if (data3[i][0]=="") data3[i].shift();
		for (var j=0;j<data3[i].length;j++){
		  if (reg.test(data3[i][j])) data3[i][j]=data3[i][j].replace(/,/g,"");
		  if (isNaN(data3[i][j])==false)
		    data3[i][j]=eval(data3[i][j]);
		}
	}
 }
delete sortData; delete reg;
//sortData=null;
}

function fmd(str){

	str=str.replace(/^\s+|\s+$/g,"").replace(/\s\n+|\n+/g,"#_#samurai-logic#_#");
	str=str.replace(/[　\s\t]+/g," ").replace(/#_#samurai-logic#_#/g,"\n");
	//str=str.replace(/\n+/g,"\n");

return str;
}


/*********************************** $Get() **********************************/

function $Get(){
var fnc = $id("FC").value;

 switch (fnc){
  case "fc1":
   var str = $id("E").value; break;
  case "fc2":
   var str = $id("F").value; break;
  case "fc3":
   var str = $id("G").value; break;
  default:
   var str = $id("E").value;
 }

reg1=/\s*data1\s*\[|\s*data1.\w/g;
reg2=/\s*data2\s*\[|\s*data2.\w/g;
reg3=/\s*data3\s*\[|\s*data3.\w/g;

 if (reg1.test(str)) $r("dt1");
 if (reg2.test(str)) $r("dt2"); 
 if (reg3.test(str)) $r("dt3");

delete reg1; delete reg2; delete reg3;

return str;
}

/***********************  $e ************************/

/*reg=/\s*data[1,2,3]\s*\[/g; ---> 'data1[', 'data2[', 'data3[' */

function $e(){

//var FUNC = $id("FC").value;
var STR_STR=$Get();

regCvs=/\s*ctx\./;  // regExp of "ctx"

var isCvs=false; // if isCvs=true, it's canvas expression  also zindex=true in case remove canvas

//if (/\$\C\(/.test(STR_STR)==false){
  if (STR_STR.search(regCvs)>=0) { // if "ctx." is found
	clearInterval(timeSet);
	clearInterval(daySet);
	clearInterval(ieSet);
	var id=document.getElementById("cvs");
	if(id) document.body.removeChild(id);

	$cvs(); 
	zindex=true; 
	isCvs=true;
  }

  Rg1 = /\s*DATA1/;
  Rg2 = /\s*DATA2/;
  Rg3 = /\s*DATA3/;

  STR_STR=STR_STR.replace(Rg1,'var DATA1=$id("A").value; DATA1');
  STR_STR=STR_STR.replace(Rg2,'var DATA2=$id("B").value; DATA2');
  STR_STR=STR_STR.replace(Rg3,'var DATA3=$id("C").value; DATA3');

  if (isCvs==true) {
	var DDDD=$id("D");
        try{ eval(STR_STR); } catch(e) {DDDD.value="error:"+e; $cc(4); }
	STR_STR=null; delete Rg1; delete Rg2; delete Rg3;
	return;
  }
//}
/* if ctx. then execute canvas and return */

 var DDDD=$id("D");

try{ var ans=eval(STR_STR); } 
catch(e) {DDDD.value="error:"+e; $cc(4); delete STR_STR;  delete regCvs; delete DDDD; return;}
 
 if (ans!='') $cc(4);

 DDDD.value=eval(STR_STR);

 delete STR_STR;  delete regCvs; delete DDDD;
}

/*********************** Canvas ******************************************/

var zindex=false;
var _pi=0;
var ctx;
var Time=false;

var img = new Image();
img.src="http://www.samurai-logic.com/gadget/img/omega.png";

function $cvs(){ /* this function create canvas area and set "ctx" as canvas element */
//if (flag==true) return;
	var id=document.getElementById("cvs");

	//if (id) {return;}
	if (id) ctx=null; //cannot delete ctx, ctx=null

	var el = document.createElement('canvas');
	el.setAttribute('id', 'cvs');

	el.setAttribute('width', 269);
	el.setAttribute('height', 150);

	document.body.appendChild(el);

	  if (window.attachEvent && !window.opera){
	    G_vmlCanvasManager.initElement(document.getElementById('cvs'));
	  }

	ctx=document.getElementById("cvs").getContext("2d");
}

function $draw(){
//var ctx=$id("cvs").getContext("2d");
	$cvs();
  //ctx.lineWidth = 1;
	  ctx.strokeStyle = 'black';
	  ctx.fillStyle = 'white';
	ctx.beginPath();
	ctx.moveTo(37, 3);
	  if (window.attachEvent && !window.opera){
	    ctx.lineTo(265, 3);
	    ctx.lineTo(265, 120);
	  }else{
	    ctx.lineTo(295, 3);
	    ctx.lineTo(295, 120);
 	  }
	ctx.lineTo(37, 120);
	ctx.closePath();
	ctx.fill();
	ctx.save();
}

/*********** remonve canvas ********/

function $rem2(){_pi=0; $rem(); init(); }

function $rem(){
    if (Time==true){ //if clock moving
	clearInterval(timeSet);//clear before removeChild
	clearInterval(daySet);
//if (/MSIE/.test(navigator.userAgent)) 
	clearInterval(ieSet);

	var id=document.getElementById("day");
	if(id) document.body.removeChild(id); //remove day

	var id=document.getElementById("cvs");
	if(id) {document.body.removeChild(id);}//else{$info("data","D"); init();}
	id=null;
    }

   if (zindex==false) return;//zindex==false --> same graph and don't need to remove

   if (gtype==0){
	for (var i=0;i<gpi.length;i++){
	 var el=document.getElementById(gpi[i]);
	 if (el) document.body.removeChild(el);
	}
   }else if (gtype==1){
	for (var i=0;i<gbar.length;i++){
	 var el=document.getElementById(gbar[i]);
	 if (el) document.body.removeChild(el);
	}
   }else if (gtype==2){
	for (var i=0;i<gbar.length;i++){
	 var el=document.getElementById(gbar[i]);
	 if (el) document.body.removeChild(el);
	}
   }else {}

   if (grid==true){
	for (var i=13;i<=15;i++){
	 var gd=document.getElementById(gbar[i]);
	 if (gd) document.body.removeChild(gd);
	}
   }
  grid=false; /* initialize grid and zindex, gtype, isvt */
  zindex=false;
  gtype=3;
  isvt=null;

}

function init(){
  $cvs();
  clock();
  $day();

 // var min = TIME.getMinutes();

  daySet=setInterval($day,60000);// 60 sec.

  Time=true; //true ---> clock is ticking

  //if (/MSIE/.test(navigator.userAgent))
    ieSet=setInterval($rem2,71500); //release memory

    timeSet=setInterval(clock,1000);
}

function $day(){
  var day = (new Date()).getDate();
  if(!el) {
    var el = document.createElement('div');
    el.setAttribute('id', "day");
    document.body.appendChild(el);
  }
  el.innerHTML=(day);
  el=null;
}

var grid=false;/* this flag is for a number of gridline. true-->need to remove */
var first=false;
var isvt;
var gtype=3; 
/* gtype=0 -> pi, 
   gtype=1 -> bar, 
   gtype=2 -> line */

/*****************************************************************

******************** canvas main function ************************

******************************************************************/

function $Graph(){

var DT=$id("DT").value;
var CH=$id("Chart").value;
var vh=$id("VH").value;

//if(DT="dt1") {$r("dt1"); alert(data1.length);}

/*** when vertical or horizontal is selected, reset _pi=0.***/

//if (gtype==3) first=true; /* first time */

if ((vh=="vt" && isvt==false)||(vh=="hz" && isvt==true)){ zindex=true;_pi=0;}
if (gtype==3){/*alert("first pass");*/ }
else if ((CH=="pi" && gtype!=0)||(CH=="bar" && gtype!=1)||(CH=="line" && gtype!=2)){ zindex=true;_pi=0;}

if (zindex==true || Time==true) $rem();
zindex=true;
_pi+=1;

var sum=0;
var k=0;
temp=new Array();
itm=new Array();

var colors=["#FF0000","#FFC0CB","#000080","#00FF00","#800000",
	    "#FFFF00","#FF1493","#7FFFD4","#4B0082","#008000",
	    "#E6E6FA","#2F4F4F","#FF8C00","#9ACD32","#FFD700",
	    "#D2691E","#4682B4","#008B8B","#AFEEEE","#9400D3"];

var colors2=["#00008B","#FF0000","#32CD32","#800000","#4B0082",
	     "#FF8C00","#3CB371","#B8860B","#0000CD","#FF00FF",
	     "#00FF7F","#A52A2A","#20B2AA","#FF6347","#9370DB",
	     "#8B4513","#483D8B","#FF1493","#7FFF00","#DC143C"];

var colors3=["#000080","#FF0000","#4B0082","#ff0000","#DC143C",
	     "#FF4500","#FF00FF","#00008B","#191970","#0000FF",
	     "#32CD32","#9400D3"];

/*****************************************************************
	push integer to temp[] 
	push items to itm[] , and push title to itm[last]
*****************************************************************/

/***************  if 'horizontal' is selected ********************/

 if (vh=="hz") {isvt=false; /* isvt is to remove canvas before, when it changes */
  switch(DT){
  case "dt1": $r("dt1");
   if(data1.length<=1 || data1.length<=_pi) { 
     //$cc(1); $info("A");	  /* $info write "no data"*/
     _pi=0; zindex=false; return; /* initiate _pi & zindex before exit */
   }
   var tdata=data1[_pi].length;
   //tdata=(tdata>21)? 21:tdata;    /* lmt datas to push into array */
   for (var i=0; i<tdata; i++){
    if (isNaN(data1[_pi][i])!=true) { /* data[][] is integer then push */
	//sum+=data1[_pi][i]; 
	temp[k]=data1[_pi][i];  /* push integer to temp[k] 'k' is different from integer 'i' */
	itm[k]=data1[0][i];     /* push items to itm[k] */
	k++;
    }
    itm[k]=data1[_pi][0];   /* push title to last array of items */
   }
   break;

  case "dt2": $r("dt2");  /* $r read and put datas to array(data2) */ 
   if(data2.length<=1 || data2.length<=_pi) {$cc(2); //$info("B");
     _pi=0; zindex=false; return;
   }
   var tdata=data2[_pi].length;
   //tdata=(tdata>21)? 21:tdata;
   for (var i=0; i<tdata; i++){
    if (isNaN(data2[_pi][i])!=true) {
	//sum+=data2[_pi][i]; 
	temp[k]=data2[_pi][i];
	itm[k]=data2[0][i];
	k++;
    }
    itm[k]=data2[_pi][0];
   }
   break;

  case "dt3": $r("dt3");
   if(data3.length<=1 || data3.length<=_pi) {$cc(3); //$info("C");
     _pi=0; zindex=false; return;
   }
   var tdata=data3[_pi].length;
   //tdata=(tdata>21)? 21:tdata;
   for (var i=0; i<tdata; i++){
    if (isNaN(data3[_pi][i])!=true) {
	//sum+=data3[_pi][i]; 
	temp[k]=data3[_pi][i];
	itm[k]=data3[0][i];
	k++;
    }
    itm[k]=data3[_pi][0];
   }
   break;

   default: alert("error what's data name???"); return;
  }
 }

/***************  else 'vertical' is selected ********************/

 else if (vh=="vt") {isvt=true;
  switch(DT){
  case "dt1": $r("dt1");
   if(data1.length<=1 || data1.length<=_pi) {$cc(1); //$info("A");
     _pi=0; zindex=false; return;
   }
   var tdata=data1.length;
   //tdata=(tdata>21)? 21:tdata;
   for (var i=0; i<tdata; i++){
    if (isNaN(data1[i][_pi])!=true) {
	//sum+=data1[i][_pi]; 
	temp[k]=data1[i][_pi];
	itm[k]=data1[i][0];
	k++;
    }
    itm[k]=data1[0][_pi];
   }
   break;

  case "dt2": $r("dt2");
   if(data2.length<=1 || data2.length<=_pi) {$cc(2); //$info("B");
      _pi=0; zindex=false; return;
   }
   var tdata=data2.length;
   //tdata=(tdata>21)? 21:tdata;
   for (var i=0; i<tdata; i++){
    if (isNaN(data2[i][_pi])!=true) {
	//sum+=data2[i][_pi]; 
	temp[k]=data2[i][_pi];
	itm[k]=data2[_pi][0];
	k++;
    }
    itm[k]=data2[0][_pi];
   }
   break;

  case "dt3": $r("dt3");
   if(data3.length<=1 || data3.length<=_pi) {$cc(3); //$info("C");
     _pi=0; zindex=false; return;
   }
   var tdata=data3.length;
   //tdata=(tdata>21)? 21:tdata;
   for (var i=0; i<tdata; i++){
    if (isNaN(data3[i][_pi])!=true) {
	//sum+=data3[i][_pi]; 
	temp[k]=data3[i][_pi];
	itm[k]=data3[_pi][0];
	k++;
    }
    itm[k]=data3[0][_pi];
   }
   break;

   default: alert("error what's data name???"); return;
  }
 }//else if "vt"

 else {gtype=3; return;}  /** gtype==3 will initiate all **/

	$cvs();

   switch(CH){
	/******************  pi graph **********************/

    case "pi": gtype=0;	var x=0;

	for (var h=0; h<temp.length; h++) 
	  if (temp[h]>0) {sum+=temp[h]; temp[x]=temp[h]; itm[x]=itm[h]; x++; } /* find sum and num of positive value */

	var arc=-0.5*Math.PI;
	ctx.translate(95,75);
	ctx.strokeStyle = "#c0c0c0";
	ctx.lineWidth = 0.2;

	j=Math.floor(Math.random()*20);
	/******************** for loop ***********************/

	for (i=0; i<x; i++){

	  a=(Math.floor(Math.random()+2)/2*5)%2; /** step 1 or 3 ahead of color array **/
	 if (j>=17) j=0;
	  j+=(a==0)? 3:a; /* add 1 or 3 */

	if(typeof colors[j]=='undefined') j=1;

	  var l=temp[i]/sum*360*Math.PI/180+arc;

	if (window.attachEvent && !window.opera){
	  ctx.fillStyle = colors[j];
	}else{
	  ctx.globalAlpha = 0.9;
	  //ctx.shadowBlur = 50;

	  var Rgrad  = ctx.createRadialGradient(0,0,20,0,0,105);
	  Rgrad.addColorStop(0,colors[j]);
	  Rgrad.addColorStop(1,"#fff");
	/* Rgrad.addColorStop(1,"#333");
	  Rgrad.addColorStop(0.2,'rgba(255, 255, 255, 0.9)');#B0E0E6
	*/
	  ctx.fillStyle = Rgrad;
	}

	  ctx.beginPath();
	  ctx.moveTo(0,0);
	  ctx.arc(0,0,60,arc,l,false);  /* pi graph */
	  ctx.closePath();
	  ctx.fill();
	  ctx.stroke();

	  ctx.beginPath();		/* reset style */
	  ctx.fillStyle = colors[j];
	  ctx.rect(70,-65+(i*15),6,6);  /* rect */
	  ctx.fill();
	  ctx.stroke();

	/******** title and content texts *************/

	 if (i<x) arc=l;	/* store arc start for next pi */
	 if (i<10){		/* 10 items is limit  */
	  var el = document.createElement('div');
	  el.setAttribute('id', gpi[i+1]);

	  document.body.appendChild(el);
	  if (typeof itm[i]!="undefined") el.innerHTML=(itm[i]);
	 }
	}

	var el = document.createElement('div');
	el.setAttribute('id', gpi[0]);
	document.body.appendChild(el);
	if (typeof itm[k]!="undefined") el.innerHTML=(itm[k]);

	el=null;

	ctx.beginPath();
	ctx.lineWidth = 1;
	ctx.strokeStyle = "111";//'#325FA2';
	ctx.arc(0,0,60,0,Math.PI*2,true);
	ctx.stroke();
	ctx.translate(-95,-75); /* reset position */
	break;

    case "bar": gtype=1;
	/******************  bar graph **********************/

	ctx.beginPath();
	ctx.moveTo(37, 3);

	ctx.strokeStyle = '#555';
	ctx.fillStyle = 'white';
	ctx.fillRect(37,3,230,122);
	ctx.lineWidth = 0.5;
	ctx.beginPath();
	ctx.moveTo(37,30);
	ctx.lineTo(267,30)
	ctx.closePath();
	ctx.stroke();
	ctx.beginPath();
	ctx.moveTo(37,61);
	ctx.lineTo(267,61)
	ctx.closePath();
	ctx.stroke();
	ctx.beginPath();
	ctx.moveTo(37,92);
	ctx.lineTo(267,92)
	ctx.closePath();
	ctx.stroke();
	ctx.beginPath();
	ctx.moveTo(37,123);
	ctx.lineTo(267,123)
	ctx.closePath();
	ctx.stroke();

	var l=temp.length;
	var x=(l>11)? 11:l; /* loop max 11 times */

	var l=220/x; //l=(l>20)? 20:l;
	var max=temp[0];//alert(l);
	var min=temp[0];

	for (i=0;i<temp.length;i++){ /* length-1 because last item is title */
	 if (temp[i]>max) max=temp[i];
	 if (temp[i]<min) min=temp[i];
	}

/* temp[i]-min --> min(temp)=0.00 and divide with (max-min) --> max(temp)=1.00  */
/* ok, now max value=110 and range=0% to 100%  */

var dif=max-min;
var mm=min/dif*92;

	for (i=0;i<temp.length;i++) {
	 if(min<0) 
	  temp[i]=(temp[i])/dif*92-mm;
	 else 
	  temp[i]=temp[i]/max*92;
	}

	j=Math.floor(Math.random()*20);

/**-------------- start for loop ----------------**/

	for (i=0;i<x;i++){

	  a=(Math.floor(Math.random()+2)/2*5)%2; 

	 if (j>=17) j=0;
	  j+=(a==0)? 3:a; 

	 if(typeof colors2[j]=='undefined') j=1; /* just in case */

	  //ctx.fillStyle = colors2[j];//色ははっきりした色に固定させる(別配列)

	/* low-high = 123px(3 to 123) left-right(37px to 267px) */

	/* fillRect(x-start, y-start, width, height */
	if (window.attachEvent && !window.opera){
	  ctx.fillStyle = colors2[j];
	}else{
	  var Lgrad  = ctx.createLinearGradient(0,0, 0,200); /* Lgrad is liner gradation*/
	      Lgrad.addColorStop(0,colors2[j]);
	      Lgrad.addColorStop(1,'#ffffff');
	      ctx.fillStyle = Lgrad;
	}

	if(min<0){
	 if(temp[i]+mm>0)
	  ctx.fillRect(45+(i*l),123-temp[i],15,temp[i]+mm);
	 else	  
	  ctx.fillRect(45+(i*l),123+mm,15,Math.abs(temp[i]+mm));/* safari bug when temp+mm<0 */
	}else{ 
	  ctx.fillRect(45+(i*l),123-temp[i],15,temp[i]);
	}
	/******** title and content texts    BAR *************/

	if (i<temp.length) k=l;
	  var el = document.createElement('div');
	  el.setAttribute('id', gbar[i+1]);
 	
	 if (window.attachEvent && !window.opera)
	   el.style.cssText = "left:"+eval(40+(i*l))+";";
	 else
	   el.setAttribute("style", "left:"+eval(40+(i*l))+";");
	
	  document.body.appendChild(el);
	  if (typeof itm[i]!="undefined") el.innerHTML=(itm[i]);
	
	}/* for loop end */

	var el = document.createElement('div');
	el.setAttribute('id', gbar[0]);
	document.body.appendChild(el);
	if (typeof itm[itm.length-1]!="undefined") el.innerHTML=(itm[itm.length-1]);

	var zz=0; /* zz is to draw zero line */

	if(min<0) {	/* if miniman value is below zero */
	  max=dif;	/* dif=max-min --> span of bars */
	  zz=-min;	/* zz is */
	  ctx.strokeStyle="#000";
	  ctx.beginPath();
	  ctx.moveTo(37,123+mm);
	  ctx.lineTo(267,123+mm); /* mm=min/dif*92 --> length of minus bar  */
	  ctx.closePath();
	  ctx.stroke();		/* draw zero line here */
	} 

	for (i=51;i<=54;i++){
	 var gd = document.createElement('div');
	 gd.setAttribute('id', gbar[i]);
	 document.body.appendChild(gd);
	 gd.innerHTML=((max*(54-i)/3)-zz).toFixed(1);
	}
	grid=true; /* now grid number is shown, so need to remove to show next */
	break;

    case "line":gtype=2;
	/******************  line graph **********************/

	ctx.beginPath();
	ctx.moveTo(37, 3);

	ctx.strokeStyle = '#555';
	ctx.fillStyle = 'white';
	ctx.fillRect(37,3,230,123);
	ctx.lineWidth = 1;
	ctx.beginPath();
	ctx.moveTo(37,30);
	ctx.lineTo(267,30)
	ctx.closePath();
	ctx.stroke();
	ctx.beginPath();
	ctx.moveTo(37,61);
	ctx.lineTo(267,61)
	ctx.closePath();
	ctx.stroke();
	ctx.beginPath();
	ctx.moveTo(37,92);
	ctx.lineTo(267,92)
	ctx.closePath();
	ctx.stroke();
	ctx.beginPath();
	ctx.moveTo(37,123);
	ctx.lineTo(267,123)
	ctx.closePath();
	ctx.stroke();

	var l=temp.length;
	var x=(l>50)? 50:l;

	var l=220/x;
	var max=temp[0];
	var min=temp[0];

	for (i=0;i<temp.length;i++){ /* length-1 because last item is title */
	 if (temp[i]>max) max=temp[i];
	 if (temp[i]<min) min=temp[i];
	}
	var dif=max-min;

   for (i=0;i<temp.length;i++) {
	if(dif==0)
	  temp[i]=temp[i]/max*92;	/* max value is set to 92 */
	else
	  temp[i]=((temp[i]-min)/dif)*92;
   }

/* ok, now max value=92 and range=0% to 100%  */
/* temp[i]-min --> min(temp)=0.00 and divide with dif(max-min) --> max(temp)=1.00  */

	j=Math.floor(Math.random()*19);

	//  b=Math.random();
	 // a=eval(((b+2)/2*5).toFixed(0)%2); 
	// if (j>=8) j=2;
	 // j+=(a==0)? 2:a; 

	 if(typeof colors3[j]=='undefined') j=1; /* just in case */

	  ctx.fillStyle = colors3[j];
	  ctx.strokeStyle = colors3[j];		/* use strong color */
	  ctx.lineWidth = 3;

/**-------------- start for loop  * line graph *---------------**/

	for (i=0;i<x;i++){

	  if(i==0) {
	    ctx.beginPath(); ctx.lineJoin = "bevel";
	    ctx.moveTo(37,123-temp[i]); 
	  } /* at first */

	  ctx.lineTo(45+(i*l),123-temp[i]);

	  if(i==(x-1)) { /*ctx.closePath();*/ ctx.stroke();} /* close line at last */

	  if (!window.attachEvent)
	    ctx.fillRect(41+(i*l),119-temp[i],7,7);

	  //ctx.fillRect(45+(i*l),123-temp[i],15,temp[i]);  /* range is 0 to 123px */

	/******** title and content texts  LINE*************/
	var print=false;

	 //if (i<temp.length) k=l;
	if (x>=30 && i%5==0) {print=true;}
	else if(x<=29 &&x>=15 && i%3==0){print=true;}
	else if(x<=14){print=true;}

	 if(print==true){
	  var el = document.createElement('div');
	  el.setAttribute('id', gbar[i+1]);
 	
	  if (window.attachEvent && !window.opera)
	    el.style.cssText = "left:"+eval(35+(i*l))+";";
	  else
	    el.setAttribute("style", "left:"+eval(35+(i*l))+";");
	
	  document.body.appendChild(el);
	  if (typeof itm[i]!="undefined") el.innerHTML=(itm[i]);
	 }/* if */

	}/* for loop end */

	var el = document.createElement('div');
	el.setAttribute('id', gbar[0]);
	document.body.appendChild(el);
	if (typeof itm[itm.length-1]!="undefined") el.innerHTML=(itm[itm.length-1]);
	
	for (i=51;i<=54;i++){
	 var gd = document.createElement('div');
	 gd.setAttribute('id', gbar[i]);
	 document.body.appendChild(gd);
	 gd.innerHTML=(max-(i-51)*dif/3).toFixed(1);
	if(dif==0) {i+=2;max=0;}
	}
	grid=true; /* now grid number is shown, so need to remove to show next */
	break;

    default: alert("select type of graph!");

   }/* switch end */

  print=false;
  delete temp; delete itm;
  delete colors; delete colors2; delete colors3;
  data1=null; data2=null; data3=null;
  sum=null;  dif=null; max=null; min=null;
}

onload=function show(){
var data=$id("smpl");
var data2=$id("smpl2");
var data3=$id("smpl3");

var el=$id("A");
var el2=$id("E");
var el3=$id("F");
el.value=data.value;
el2.value=data2.value;
el3.value=data3.value;
init();
}


function clock(){

  var TIME = new Date();
  var sec = TIME.getSeconds();
  var min = TIME.getMinutes();
  var hr  = TIME.getHours();
  hr = (hr>=12)? hr-12:hr;

 // var ctx = document.getElementById('cvs').getContext('2d');

  var lg  = ctx.createLinearGradient(0,0, 0,150); /* Lgrad is liner gradation*/
  lg.addColorStop(0,'#333');
  lg.addColorStop(0.5,'#c0c0c0');
  //lg.addColorStop(1,'#000000');
  ctx.fillStyle = lg;

//ctx.fillStyle="#333";
  ctx.fillRect(0,0,269,150);

 // img.width="140"; img.height="140";

  ctx.drawImage(img,15,5,140,140);
  ctx.save();

  ctx.translate(85,75);
  ctx.scale(0.4,0.4);
  ctx.rotate(-Math.PI/2+0.01);
  ctx.strokeStyle = "#c0c0c0";
  ctx.fillStyle = "#111";
  //ctx.lineWidth = 4;
  ctx.lineCap = "round";

  ctx.save();
  ctx.rotate( hr*(Math.PI/6) + (Math.PI/360)*min + (Math.PI/21600)*sec );

 if (window.attachEvent && !window.opera) ctx.lineWidth = 6;
 else ctx.lineWidth = 13;

  ctx.beginPath();
  ctx.moveTo(8,0);
  ctx.lineTo(91,0);
  ctx.stroke();

 if (window.attachEvent && !window.opera) ctx.lineWidth = 2;
 else ctx.lineWidth = 4;

  ctx.beginPath();
  ctx.moveTo(90,0);
  ctx.lineTo(97,0);
  ctx.stroke();
  ctx.strokeStyle = "#fff";
  ctx.beginPath();
  ctx.moveTo(15,0);
  ctx.lineTo(82,0);
  ctx.stroke();
  ctx.restore();

  ctx.strokeStyle = "#c0c0c0";
  ctx.save();
  ctx.rotate( (Math.PI/30)*min + (Math.PI/1800)*sec );

 if (window.attachEvent && !window.opera) ctx.lineWidth = 4;
 else ctx.lineWidth = 10;

  ctx.beginPath();
  ctx.moveTo(8,0);
  ctx.lineTo(127,0);
  ctx.stroke();

 if (window.attachEvent && !window.opera) ctx.lineWidth = 1;
 else ctx.lineWidth = 3;
  ctx.beginPath();
  ctx.moveTo(125,0);
  ctx.lineTo(133,0);
  ctx.stroke();
  ctx.strokeStyle = "#fff";
  ctx.beginPath();
  ctx.moveTo(15,0);
  ctx.lineTo(118,0);
  ctx.stroke();
  ctx.restore();

 //excanvas has little problem
 //if(window.attachEvent && !window.opera) {ctx.restore();return;}

  ctx.save();

  ctx.rotate(sec * Math.PI/30);
  ctx.strokeStyle = "#c0c0c0";
  ctx.fillStyle = "#fff";

 if (window.attachEvent && !window.opera) ctx.lineWidth = 2;
 else ctx.lineWidth = 5;

  ctx.beginPath();
  ctx.moveTo(0,0);
  ctx.lineTo(135,0);
  ctx.stroke();

 if (window.attachEvent && !window.opera) ctx.lineWidth = 4;
 else ctx.lineWidth = 9;

  ctx.beginPath();
  ctx.moveTo(-39,0);
  ctx.lineTo(0,0);
  ctx.stroke();

 if (window.attachEvent && !window.opera) ctx.lineWidth = 2;
 else ctx.lineWidth = 5;

  ctx.fillStyle = "#fff";
  ctx.beginPath();
  ctx.arc(90,0,2,0,Math.PI*2,true);
  ctx.arc(95,0,5,0,Math.PI*2,true);
  ctx.arc(100,0,4,0,Math.PI*2,true);
  ctx.arc(105,0,2,0,Math.PI*2,true);
  ctx.stroke();

  ctx.fill();

  ctx.fillStyle = "#555";
  ctx.beginPath();
  ctx.arc(0,0,4,0,Math.PI*2,true);
  ctx.fill();
  ctx.restore();
  ctx.restore();//restore Date
}
</script>

<style type="text/css"> 
*{font-family: Tahoma, Arial, Helvetica, sans-serif;}
body{text-align:center;height:500px;}

.tab,.fnc1,.fnc2,.fnc3{margin:0px;padding:0px;
width:265px;height:100px;font-size:11px;overflow-x:auto; overflow-y:auto;
}

.fnc1{background:#E6E6E6;}
.fnc2{background:#C9F3FF;}
.fnc3{background:#CEFFC2;}

/*  all id = "position:absolute". so layers will be set its position steadly.  */

#b1{position:absolute;left:190px;top:238px;height:16.5px;width:40px;font-size:10px;}
#b2{position:absolute;left:230px;top:238px;height:16.5px;width:40px;font-size:10px;}

#DT{margin:0px;height:18px;width:70px;font-size:11px; font-weight:bold;color:#ffff00;background:#000;}
#VH{margin:0px;height:18px;width:70px;font-size:11px; font-weight:bold;color:#ffff00;background:#000;}
#Chart{margin:0px;height:20px;width:70px;font-size:11px; 
font-weight:bold;color:#ffff00;background:#000;}

//#msg{position:absolute;left:20px;top:258px;}
#FC{margin:0px;height:18px;width:85px;font-size:11px;
font-weight:bold;color:#ffff00;background:#000;}
#RD{margin:0px;height:20px;width:72px;font-size:11px;}
#RF{margin:0px;height:20px;font-size:9px;}
#html{margin:0px;height:20px;width:90px;font-size:11px;}

#boxbutton{position:absolute;left:228px; top:279px; height:25px; width:40px;font-size:10px;
font-weight:bold; z-index:11; padding:0px;cursor:pointer; border:#fff 3px inset;}


#laybox { position:absolute; left:262px; top:298px; z-index:10;
background-color:#c0c0c0; width:0px; height:0px; border:#ff0000 3px inset;}

*html #laybox {position:absolute; left:262px; top:279px; z-index:10;
background-color:#c0c0c0; width:0px; height:0px; border:#ff0000 3px inset;}

.laybox{ }

#tbl{position:absolute;left:0px;top:254px;width:269px;height:50px;
border: 2px ridge #fff; background:#000;}
#tbl2{position:absolute;left:0px;top:304px;width:269px;height:20px;
border: 2px ridge #fff; background:#000;}
#img{position:absolute;left:0px;top:510px;}

#txt {  position:absolute; width:260px;
top:1px;left:0px; font-size:10px; color:#ff0000;
}
#txt a{ color:blue;text-decoration:none;cursor:pointer;}
#txt a:hover,a:focus{color:#FF8C00;}
.txt {color:#FF0000;}

#cvs{ position:absolute;left:0px;top:340px;background:#B0E0E6;width:269px; height:150px; }

div.lay { padding:1px; width:265px; height:100px; 
border:1px solid; font-size:13px; }
#lay1 { position:absolute; left:0px; top:30px; z-index:4; 
background-color:#ccc; border-color:#ccc; }
#lay2 { position:absolute; left:0px; top:30px; z-index:3; 
background-color:#87CEFA; border-color:#87CEFA; }
#lay3 { position:absolute; left:0px; top:30px; z-index:2; 
background-color:#ADFF2F; border-color:#ADFF2F; }
#lay4 { position:absolute; left:0px; top:30px; z-index:1; 
background-color:#FA8072; border-color:#FA8072; }

#lay5 { position:absolute; left:0px; top:134px; background-color:#ccc;
border-color: #ccc; z-index:4; }
#lay6 { position:absolute; left:0px; top:134px; background-color:#87CEFA;
border-color: #87CEFA; z-index:3; }
#lay7 { position:absolute; left:0px; top:134px; background-color:#ADFF2F; 
border-color: #ADFF2F; z-index:3; }

div.tb { padding:1px; width:30px; height:13px; border:1px solid; font-size:12px;cursor:hand;cursor:pointer;}
div.tb-r { padding:1px; width:45px; height:13px; border:1px solid; font-size:12px;cursor:hand;cursor:pointer;}
#tb1 { position:absolute; left:0px; top:15px; z-index:4; background-color:#ccc; border-color:#ccc;border-bottom:transparent;}
#tb2 { position:absolute; left:35px; top:15px; z-index:3; background-color:#87CEFA; border-color:#87CEFA; border-bottom:transparent;}
#tb3 { position:absolute; left:70px; top:15px; z-index:2; background-color:#ADFF2F; border-color:#ADFF2F; border-bottom:transparent;}
#tb4 { position:absolute; left:105px; top:15px; z-index:1; background-color:#FA8072; border-color:#FA8072;border-bottom:transparent; }

div.tb-f { padding:0px; width:58px; height:13px; border:1px solid; font-size:12px;cursor:hand;cursor:pointer;}
#tb5 { position:absolute; left:0px; top:238px; z-index:3; background-color:#ccc; border-color:#ccc; border-top:transparent;}
#tb6 { position:absolute; left:58px; top:238px; z-index:2; background-color:#87CEFA; border-color:#87CEFA; border-top:transparent;}
#tb7 { position:absolute; left:116px; top:238px; z-index:1; background-color:#ADFF2F; border-color:#ADFF2F;border-top:transparent; }

#fs{position:absolute;top:12px;left:218px;width:50px;height:18px;font-size:11px; 
font-weight:bold;color:#ffff00;background:#000; cursor:default;}
#ff{position:absolute;top:12px;left:160px;width:60px;height:18px;font-size:11px;
font-weight:bold;color:#ffff00;background:#000;cursor:default;}

#footer{position:absolute;top:2px;/*345px;*/left:5px;font-size:9px;}

#tit{position:absolute;top:350px;left:5px;width:200px;height:18px;font-size:11px;font-weight:bold;text-align:left;color:#4B0082;}

#pi1{position:absolute;top:345px;left:175px;width:100px;height:18px;font-size:10px;text-align:left;}
#pi2{position:absolute;top:360px;left:175px;width:100px;height:18px;font-size:10px;text-align:left;}

#pi3{position:absolute;top:375px;left:175px;width:100px;height:18px;font-size:10px;text-align:left;}
#pi4{position:absolute;top:390px;left:175px;width:100px;height:18px;font-size:10px;text-align:left;}

#pi5{position:absolute;top:405px;left:175px;width:100px;height:18px;font-size:10px;text-align:left;}
#pi6{position:absolute;top:420px;left:175px;width:100px;height:18px;font-size:10px;text-align:left;}

#pi7{position:absolute;top:435px;left:175px;width:100px;height:18px;font-size:10px;text-align:left;}
#pi8{position:absolute;top:450px;left:175px;width:100px;height:18px;font-size:10px;text-align:left;}

#pi9{position:absolute;top:465px;left:175px;width:100px;height:18px;font-size:10px;text-align:left;}
#pi10{position:absolute;top:480px;left:175px;width:100px;height:18px;font-size:10px;text-align:left;}

#pi11{position:absolute;top:495px;left:175px;width:100px;height:18px;font-size:10px;text-align:left;}
#pi12{position:absolute;top:510px;left:175px;width:100px;height:18px;font-size:10px;text-align:left;}

#bar1{position:absolute;top:465px;left:45px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar2{position:absolute;top:475px;left:65px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar3{position:absolute;top:465px;left:85px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar4{position:absolute;top:475px;left:105px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar5{position:absolute;top:465px;left:125px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar6{position:absolute;top:475px;left:145px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar7{position:absolute;top:465px;left:165px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar8{position:absolute;top:475px;left:185px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar9{position:absolute;top:465px;left:205px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar10{position:absolute;top:475px;left:225px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}

#bar11{position:absolute;top:465px;left:45px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar12{position:absolute;top:475px;left:65px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar13{position:absolute;top:465px;left:85px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar14{position:absolute;top:475px;left:105px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar15{position:absolute;top:465px;left:125px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar16{position:absolute;top:475px;left:145px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar17{position:absolute;top:465px;left:165px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar18{position:absolute;top:475px;left:185px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar19{position:absolute;top:465px;left:205px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar20{position:absolute;top:475px;left:225px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}

#bar21{position:absolute;top:465px;left:45px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar22{position:absolute;top:475px;left:65px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar23{position:absolute;top:465px;left:85px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar24{position:absolute;top:475px;left:105px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar25{position:absolute;top:465px;left:125px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar26{position:absolute;top:475px;left:145px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar27{position:absolute;top:465px;left:165px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar28{position:absolute;top:475px;left:185px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar29{position:absolute;top:465px;left:205px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar30{position:absolute;top:475px;left:225px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}

#bar31{position:absolute;top:465px;left:45px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar32{position:absolute;top:475px;left:65px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar33{position:absolute;top:465px;left:85px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar34{position:absolute;top:475px;left:105px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar35{position:absolute;top:465px;left:125px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar36{position:absolute;top:475px;left:145px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar37{position:absolute;top:465px;left:165px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar38{position:absolute;top:475px;left:185px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar39{position:absolute;top:465px;left:205px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar40{position:absolute;top:475px;left:225px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}

#bar41{position:absolute;top:465px;left:45px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar42{position:absolute;top:475px;left:65px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar43{position:absolute;top:465px;left:85px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar44{position:absolute;top:475px;left:105px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar45{position:absolute;top:465px;left:125px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar46{position:absolute;top:475px;left:145px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar47{position:absolute;top:465px;left:165px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar48{position:absolute;top:475px;left:185px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar49{position:absolute;top:465px;left:205px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}
#bar50{position:absolute;top:475px;left:225px;width:40px;height:11px;font-size:9px;text-align:left;overflow-x:hidden; overflow-y:hidden;}


#grid1{position:absolute;top:365px;left:2px;width:32px;height:10px;font-size:10px;text-align:left;color:navy;}
#grid2{position:absolute;top:395px;left:2px;width:32px;height:10px;font-size:10px;text-align:left;color:navy;}
#grid3{position:absolute;top:425px;left:2px;width:32px;height:10px;font-size:10px;text-align:left;color:navy;}
#grid4{position:absolute;top:455px;left:2px;width:32px;height:10px;font-size:10px;text-align:left;color:navy;}

#day{position:absolute;top:449px; left:81px; font-family:Arial Narrow; 
/*font-weight:bold;width:32px;height:8px;*/ font-size:9px;text-align:center;color:#999;}

.bbb{font-size:10px; width:86px; padding:0px; height:18px;cursor:hand;cursor:pointer;}
.con{float:left; height:500px;}

#slct{position:absolute;background:navy;top:270px;color:#fff;left:7px;width:60px;height:20px;font-size:11px; font-weight:bold; z-index:13;border:#fff 2px inset;}
#slct2{position:absolute;background:navy;top:270px;color:#fff;left:67px;width:100px;height:20px;font-size:11px; font-weight:bold; z-index:13;border:#fff 2px inset;}
#tools{position:absolute;background:red;top:270px;color:#fff;left:167px;width:60px;height:20px;font-size:11px; font-weight:bold; z-index:13;border:#fff 2px inset;}
</style>


<div class="con">

<div id="txt">JS Function ver. 1_2_2 &ensp;&ensp;<a href='http://www.samurai-logic.com/' target='_blank'>Samurai-Logic.com</a></div>

  <select onchange="$fs(this)" id="fs" title="select font size">
   <option value="8px">8px</option>
   <option value="9px">9px</option>
   <option value="10px">10px</option>
   <option value="11px" selected>11px</option>
   <option value="12px">12px</option>
   <option value="13px">13px</option>
   <option value="14px">14px</option>
   <option value="15px">15px</option>
   <option value="16px">16px</option>
   <option value="18px">18px</option>
   <option value="20px">20px</option>
   <option value="22px">22px</option>
  </select>

  <select id="ff" onchange="$ff(this)" title="select font family">
   <option value="Arial">Arial</option>
   <option value="Arial narrow">ArialNarrow</option>
   <option value="Verdana">Verdana</option>
   <option value="Tahoma" selected>Tahoma</option>
   <option value="Impact">Impact</option>
   <option value="Comic Sans MS">ComicSans</option>
   <option value="Default">Default</option>
  </select> 

    <div id="lay1" class="lay">
	<textarea type="text" class="tab" id="A" ondblclick="$s('A')"></textarea>
    </div>
    <div id="lay2" class="lay">
	<textarea type="text" class="tab" id="B" ondblclick="$s('B')"></textarea>
    </div>
    <div id="lay3" class="lay">
	<textarea type="text" class="tab" id="C" ondblclick="$s('C')"></textarea>
    </div>
    <div id="lay4" class="lay">
	<textarea type="text" class="tab" id="D" ondblclick="$s('D')"></textarea>
    </div>
    <div id="lay5" class="lay">
	<textarea type="text" class="fnc1" id="E" ondblclick="$s('E')"></textarea>
    </div>
    <div id="lay6" class="lay">
	<textarea type="text" class="fnc2" id="F" ondblclick="$s('F')"></textarea>
    </div>
    <div id="lay7" class="lay">
	<textarea type="text" class="fnc3" id="G" ondblclick="$s('G')"></textarea>
    </div>

<div id="tb1" class="tb" title="data1 tab" onclick="$cc(1);">data1</div>
<div id="tb2" class="tb" onclick="$cc(2);">data2</div>
<div id="tb3" class="tb" onclick="$cc(3);">data3</div>
<div id="tb4" class="tb-r" onclick="$cc(4);">output</div>

<div id="tb5" class="tb-f" onclick="$cc(5);">function1</div>
<div id="tb6" class="tb-f" onclick="$cc(6);">function2</div>
<div id="tb7" class="tb-f" onclick="$cc(7);">function3</div>

<table id="tbl">
<tr><td>

<center>
  <select id="DT" title="select data">
   <option value="dt1">data1
   <option value="dt2">data2
   <option value="dt3">data3
  </select>
  <select id="VH" title="select vertical or horizontal">
   <option value="vt">vertical
   <option value="hz">horizontal
  </select>
  <select id="Chart" title="select type of graph to draw">
   <option value="pi">pi graph
   <option value="bar">bar graph
   <option value="line">line graph
  </select>

<input type="button" id="dg" class="bbb" value="draw graph" title="Draw Chart" onclick="$Graph()">
<input type="button" id="rem" class="bbb" title="remove canvas area" value="Clock" onclick="$rem2()">
</center>

</td>

</tr>
</table>
<table id="tbl2"><tr><td>
<center>
  <select id="FC" title="select function">
   <option value="fc1">function1
   <option value="fc2">function2
   <option value="fc3">function3
  </select>
<input type="button" id="RF" class="bbb" onclick="$e();" title="Run JavaScript function" value="Run JavaScript"><br />
</center>
</td></tr></table>

<input type="button" id="b1" class="bbb" title="Move up" onclick="$up();" value="UP">
<input type="button" id="b2" class="bbb" title="Move down" onclick="$dwn();" value="DOWN">

<input type="button" id="boxbutton" title="Tool" onclick="$tool('laybox',130,130);" value="Tool">

<div id="laybox" class="laybox"></div>

<textarea id="smpl" style="visibility:hidden">
Sample AAA BBB CCC DDD EEE FFF
Jan. 150 200 100 250 160 220
Feb. 200 -100 80 120 40 -80
Mar. 150 600 100 80 20 100
Apr. 0 50 250 100 80 200
May. -10 50 100 20 -20 50
Jun. -20 100 30 60 250 -80
Jul. 100 150 300 180 400 50
Aug. 50 100 80 250 60 40
</textarea>

<textarea id="smpl2" style="visibility:hidden">
/*************************************
   Javascript function Example 
   How to use this textarea
   write javascript code 
	and click "Run JavaScript"	
*************************************/

/*-------------------------------------

 Example1 : use DATA1, DATA2, DATA3

DATA1.match(/pattern/g)
DATA2.replace(/pattern/g,"string")

DATA1=string value of 'data1' tab
DATA2=string value of 'data2' tab
DATA3=string value of 'data3' tab

NG: 
var str=DATA1; ==> error

//in case if you want to store 'string' value of data1 to "str", then write

var str=$id("A"); 
//str=document.getElementById("A"); 

str.value;	// return values to output tab.

--------------------------------------

//data1 ==> "A", data 2==>"B", data 3==>"C"

--------------------------------------

//Example2 : "data1" to "data3"

//if you write "data1", then values of "data1" tab will be stored in array 

data1[1][1]*data1[2][1];

// NOTE : data1["vertical"]["horizontal"]

------------------------------------------

//Example3 : write function

function test(val){
  var i=10;
  return i*val;
}

test(5); // this will return value 50 to "outout tab".


----------------------------------------*/
</textarea>


<textarea id="smpl3" style="visibility:hidden">
//Example 4: Canvas
//you can use canvas, starting with "ctx."

ctx.fillStyle = 'red';
ctx.scale(1.1,1.1);
ctx.beginPath();
ctx.moveTo(75,40);
ctx.bezierCurveTo(75,37,70,25,50,25);
ctx.bezierCurveTo(20,25,20,62.5,20,62.5);
ctx.bezierCurveTo(20,80,40,102,75,120);
ctx.bezierCurveTo(110,102,130,80,130,62.5);
ctx.bezierCurveTo(130,62.5,130,25,100,25);
ctx.bezierCurveTo(85,25,75,37,75,40);
ctx.fill();
var lg  = ctx.createLinearGradient(0,0, 0,150); 
lg.addColorStop(0,'#fff');
lg.addColorStop(0.6,'#ff0000');
ctx.fillStyle = lg;
ctx.scale(0.98,0.9);
ctx.translate(1.5,8);
ctx.beginPath();
ctx.moveTo(75,40);
ctx.bezierCurveTo(75,37,70,25,50,25);
ctx.bezierCurveTo(20,25,20,62.5,20,62.5);
ctx.bezierCurveTo(20,80,40,102,75,120);
ctx.bezierCurveTo(110,102,130,80,130,62.5);
ctx.bezierCurveTo(130,62.5,130,25,100,25);
ctx.bezierCurveTo(85,25,75,37,75,40);
ctx.fill();
</textarea>

</div>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3833063-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>

]]>
</Content> 
</Module>
