//JavaScript; name="jsPlotXY.js"; date="19/7/2001"; author="mxk121"; email="mxk121@rsphysse.anu.edu.au";

var jsplot_num = 0;

function plotObject() {
   this.title = '';
   this.font = '\'Times New Roman\'';
   this.size = 20;
   this.color = '#000000';
   this.word = '.';
   this.left = 0;
   this.top = 0;
   this.right = screen.width;
   this.bottom = screen.height;
   this.xmin = 0;
   this.ymin = screen.height;
   this.xmax = screen.width;
   this.ymax = 0;
   this.graph = graph;
   this.grap = grap;
   this.axis = axis;
   this.axisstick0 = axisstick0;
   this.axisstick1 = axisstick1;
   this.pset = pset;
   this.stick = stick;
   this.line = line;
   this.xyscr = xyscr;
   this.winscr = winscr;
   this.rgb = rgb;
};

function xyscr(x0, y0, x1, y1) {
var x0, y0, x1, y1;
   this.xmin = (isNaN(eval(x0))) ? this.xmin : eval(x0); if (isNaN(this.xmin)) { return false; };
   this.ymin = (isNaN(eval(y0))) ? this.ymin : eval(y0); if (isNaN(this.ymin)) { return false; };
   this.xmax = (isNaN(eval(x1))) ? this.xmax : eval(x1); if (isNaN(this.xmax)) { return false; };
   this.ymax = (isNaN(eval(y1))) ? this.ymax : eval(y1); if (isNaN(this.ymax)) { return false; };
   return true;
};

function winscr(x0, y0, x1, y1) {
var x0, y0, x1, y1;
   this.left   = (isNaN(eval(x0))) ? this.left   : eval(x0); if (isNaN(this.left))   { return false; };
   this.top    = (isNaN(eval(y0))) ? this.top    : eval(y0); if (isNaN(this.top))    { return false; };
   this.right  = (isNaN(eval(x1))) ? this.right  : eval(x1); if (isNaN(this.right))  { return false; };
   this.bottom = (isNaN(eval(y1))) ? this.bottom : eval(y1); if (isNaN(this.bottom)) { return false; };
   return true;
};

function rgb(re, gr, bl) {
var re, gr, bl;
   if (isNaN(re) || isNaN(gr) || isNaN(bl)) { return false; };
   if ((re < 0) || (gr < 0) || (bl < 0)) { return false; };
   this.color = '#' + jsplot_hex(re) + jsplot_hex(gr) + jsplot_hex(bl);
   return true;
};

function jsplot_hex(num) {
var num;
var hex = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
   if (num <= 0) { return '00'; };
   if (0x100 <= num) { return 'FF'; };
   return (hex[Math.floor(num / 0x10)] + hex[Math.floor(num % 0x10)]);
};

function graph(type, imax, xfunc,  yfunc, rfunc, gfunc, bfunc, bgcolor, axcolor) {
var type, imax, xfunc,  yfunc, rfunc, gfunc, bfunc, bgcolor, axcolor;
var i, x, y, X, Y, conf, ww, wh, win;
var html = '';
var mem = window.status; 
   type = (type) ? String(type) : 'dot';
   imax = (!isNaN(eval(imax))) ? eval(imax) : 101;
   xfunc = (xfunc) ? String(xfunc) : 'i';
   yfunc = (yfunc) ? String(yfunc) : 'i';
   rfunc = (rfunc) ? String(rfunc) : '0';
   gfunc = (gfunc) ? String(gfunc) : '0';
   bfunc = (bfunc) ? String(bfunc) : '0';
   bgcolor = (bgcolor) ? String(bgcolor) : '#FFFFFF';
   axcolor = (axcolor) ? String(axcolor) : '#C0C0C0';

   window.status = 'wait ...'; setTimeout('',10);
   ww = this.left + this.right + this.size;
   wh = this.top + this.bottom + this.size;

   switch (type) {
    case 'dot':
      for (i = 0; i < imax; i++) {
         if (i % 500 == 0) {
            window.status = 'wait ... (' + Math.round(100 * i / imax) + '%)'; 
            setTimeout('',10); 
         };
         if (this.rgb(eval(rfunc), eval(gfunc), eval(bfunc))) {
            html += this.pset(eval(xfunc), eval(yfunc));
         };
      };
      window.status = 'wait ... (' + Math.round(100 * i / imax) + '%)'; setTimeout('',10);
      conf = confirm('Axis ON\n\n(This requires a large amount of memory.)');
      html = this.axis(axcolor, conf) + html;
      break;
    case 'stick':
      for (i = 0; i < imax; i++) {
         if (i % 50 == 0) {
            window.status = 'wait ... (' + Math.round(100 * i / imax) + '%)'; 
            setTimeout('',10); 
         };
         if (this.rgb(eval(rfunc), eval(gfunc), eval(bfunc))) {
            html += this.stick(eval(xfunc), eval(yfunc), bgcolor);
         };
      };
      window.status = 'wait ... (' + Math.round(100 * i / imax) + '%)'; setTimeout('',10);
      conf = confirm('Axis ON\n\n(This requires a large amount of memory.)');
      html = this.axisstick0(axcolor, bgcolor, conf) + html;
      html += this.axisstick1(axcolor, bgcolor, conf);
      break;
    case 'line':
      i = 0;
      x = eval(xfunc); y = eval(yfunc);
      for (i = 0; i < imax; i++) {
         if (i % 10 == 0) {
            window.status = 'wait ... (' + Math.round(100 * i / imax) + '%)'; 
            setTimeout('',10); 
         };
         if (this.rgb(eval(rfunc), eval(gfunc), eval(bfunc))) {
            X = eval(xfunc); Y = eval(yfunc);
            html += this.line(x, y, X, Y);
            x = X, y = Y;
         };
      };
      window.status = 'wait ... (' + Math.round(100 * i / imax) + '%)'; setTimeout('',10);
      conf = confirm('Axis ON\n\n(This requires a large amount of memory.)');
      html = this.axis(axcolor, conf) + html;
      break;
    default:
      break;
   };

   html = 'style="font-family:' + this.font + '; font-size:' + this.size + 'px;"> \n' + html;
   html = '<html> \n<body bgcolor="' + bgcolor + '" ' + html; 

   html += ('<' + '/body> \n<' + '/html>\n');

   window.status = 'plotting ' + imax + ' data ...';
   setTimeout('',10); 

   win = open('', 'w' + jsplot_num, 'width=' + ww + ',height=' + wh + ',resizable=no');
   win.document.open();
   win.document.write(html);
   win.document.close();
   win.document.title = this.title;
   win.focus();

   jsplot_num += 1;
   window.status = mem;

   return win;
};

function grap(type, imax, xfunc, yfunc, rfunc, gfunc, bfunc) {
var type, imax, xfunc,  yfunc, rfunc, gfunc, bfunc;
var i, x, y, X, Y;
var htm = '';
var mem = window.status; 
   type = (type) ? String(type) : 'dot';
   imax = (!isNaN(eval(imax))) ? eval(imax) : 101;
   xfunc = (xfunc) ? String(xfunc) : 'i';
   yfunc = (yfunc) ? String(yfunc) : 'i';
   rfunc = (rfunc) ? String(rfunc) : '0';
   gfunc = (gfunc) ? String(gfunc) : '0';
   bfunc = (bfunc) ? String(bfunc) : '0';

   window.status = 'wait ...'; setTimeout('',10);

   switch (type) {
    case 'dot':
      for (i = 0; i < imax; i++) {
         if (i % 500 == 0) {
            window.status = 'wait ... (' + Math.round(100 * i / imax) + '%)'; 
            setTimeout('',10); 
         };
         if (this.rgb(eval(rfunc), eval(gfunc), eval(bfunc))) {
            htm += this.pset(eval(xfunc), eval(yfunc));
         };
      };
      window.status = 'wait ... (' + Math.round(100 * i / imax) + '%)'; setTimeout('',10);
      break;
    case 'line':
      i = 0;
      x = eval(xfunc); y = eval(yfunc);
      for (i = 0; i < imax; i++) {
         if (i % 10 == 0) {
            window.status = 'wait ... (' + Math.round(100 * i / imax) + '%)'; 
            setTimeout('',10); 
         };
         if (this.rgb(eval(rfunc), eval(gfunc), eval(bfunc))) {
            X = eval(xfunc); Y = eval(yfunc);
            htm += this.line(x, y, X, Y);
            x = X, y = Y;
         };
      };
      window.status = 'wait ... (' + Math.round(100 * i / imax) + '%)'; setTimeout('',10);
      break;
    default:
      break;
   };
   window.status = mem;
   return htm;
};

function pset(x, y, sx, sy) {
var x, y, sx, sy;
var le, to, ri, bo, wi, he, x0, x1, y0, y1;
var str = '';
   if (isNaN(eval(x))) {return str; };
   if (isNaN(eval(y))) {return str; };
   if (isNaN(eval(sx))) {sx = 0; };
   if (isNaN(eval(sy))) {sy = 0; };

   le = this.left;
   to = this.top;
   ri = this.right;
   bo = this.bottom;
   wi = ri - le;
   he = bo - to;
   x0 = this.xmin;
   y0 = this.ymin;
   x1 = this.xmax;
   y1 = this.ymax;

   x = (x0 == x1) ? (le + wi / 2) : (le + wi * ((x - x0) / (x1 - x0)));
   y = (y0 == y1) ? (to + he / 2) : (to + he * (1 - (y - y0) / (y1 - y0)));

   if (x < le) { return str; };
   if (ri < x) { return str; };
   if (y < to) { return str; };
   if (bo < y) { return str; };

   str += ('<span style="position:absolute; ');
   str += ('top:' + Math.round(y + sy) + '; left:' + Math.round(x + sx) + '; ');
   str += ('color:' + this.color + '">');
   str += this.word;
   str += ('<' + '/span> \n');
   return str;
};

function stick(x, y, bgcolor) {
var x, y, bgcolor;
var si, le, to, ri, bo, wi, he, x0, x1, y0, y1;
var str = '';
   if (isNaN(eval(x))) {return str; };
   if (isNaN(eval(y))) {return str; };
   if (!bgcolor) {return str; };

   le = this.left;
   to = this.top;
   ri = this.right;
   bo = this.bottom;
   wi = ri - le;
   he = bo - to;
   x0 = this.xmin;
   y0 = this.ymin;
   x1 = this.xmax;
   y1 = this.ymax;

   x = (x0 == x1) ? (le + wi / 2) : (le + wi * ((x - x0) / (x1 - x0)));
   y = (y0 == y1) ? (to + he / 2) : (to + he * (1 - (y - y0) / (y1 - y0)));

   if (x < le) { return str; };
   if (ri < x) { return str; };

   while (y < bo) {
      if (y < to) { y = to; continue; };
      str += ('<span style="position:absolute; ');
      str += ('top:' + Math.round(y) + '; left:' + Math.round(x) + '; ');
      str += ('color:' + this.color + '">');
      str += this.word;
      str += ('<' + '/span> \n');
      y += this.size / 2;
   };

   str += ('<span style="position:absolute; ');
   str += ('top:' + Math.round(bo) + '; left:' + Math.round(x) + '; ');
   str += ('color:' + bgcolor + '">');
   str += this.word;
   str += ('<' + '/span> \n');
   return str;
};

function line(x, y, X, Y, sx, sy) {
var x, y, X, Y, sx, sy;
var le, to, ri, bo, wi, he, x0, x1, y0, y1, i, j, m;
var str = '';
   if (isNaN(eval(x))) {return str; };
   if (isNaN(eval(y))) {return str; };
   if (isNaN(eval(X))) {X = x; };
   if (isNaN(eval(Y))) {Y = y; };
   if (isNaN(eval(sx))) {sx = 0; };
   if (isNaN(eval(sy))) {sy = 0; };

   le = this.left;
   to = this.top;
   ri = this.right;
   bo = this.bottom;
   wi = ri - le;
   he = bo - to;
   x0 = this.xmin;
   y0 = this.ymin;
   x1 = this.xmax;
   y1 = this.ymax;

   x = (x0 == x1) ? (le + wi / 2) : (le + wi * ((x - x0) / (x1 - x0)));
   y = (y0 == y1) ? (to + he / 2) : (to + he * (1 - (y - y0) / (y1 - y0)));
   X = (x0 == x1) ? (le + wi / 2) : (le + wi * ((X - x0) / (x1 - x0)));
   Y = (y0 == y1) ? (to + he / 2) : (to + he * (1 - (Y - y0) / (y1 - y0)));

   if ((x < le) && (X < le)) { return str; };
   if ((ri < x) && (ri < X)) { return str; };
   if ((y < to) && (Y < to)) { return str; };
   if ((bo < y) && (bo < Y)) { return str; };

   if ((x == X) && (y == Y)) {
      str += ('<span style="position:absolute; ');
      str += ('top:' + Math.round(y + sy) + '; left:' + Math.round(x + sx) + '; ');
      str += ('color:' + this.color + '">');
      str += this.word;
      str += ('<' + '/span> \n');
      return str;
   };

   if (Math.abs((Y - y) / (X - x)) < 1) {
      if (X < x) { m = X; X = x; x = m; m = Y; Y = y; y = m; };
      for (i = x; i <= X; i++) {
         j = Math.round(((Y - y) * i + X * y - x * Y) / (X - x));

         if (i < le) { continue; };
         if (ri < i) { continue; };
         if (j < to) { continue; };
         if (bo < j) { continue; };

         str += ('<span style="position:absolute; ');
         str += ('top:' + Math.round(j + sy) + '; left:' + Math.round(i + sx) + '; ');
         str += ('color:' + this.color + '">');
         str += this.word;
         str += ('<' + '/span> \n');
      };
   } else {
      if (Y < y) { m = X; X = x; x = m; m = Y; Y = y; y = m; };
      for (j = y; j <= Y; j++) {
         i = Math.round(((X - x) * j + Y * x - y * X) / (Y - y));

         if (i < le) { continue; };
         if (ri < i) { continue; };
         if (j < to) { continue; };
         if (bo < j) { continue; };

         str += ('<span style="position:absolute; ');
         str += ('top:' + Math.round(j + sy) + '; left:' + Math.round(i + sx) + '; ');
         str += ('color:' + this.color + '">');
         str += this.word;
         str += ('<' + '/span> \n');
      };
   };

   return str;
};

function axis(axcolor, conf) {
var axcolor, conf;
var mc, x, y, x0, y0, x1, y1, adx, addx, ax0, ady, addy, ay0;
var l = 0;
var str = '';

   axcolor = (axcolor) ? String(axcolor) : '#C0C0C0';

   mc = this.color;
   this.color = axcolor;

   if (conf) {
      x0 = Math.min(this.xmin, this.xmax);
      y0 = Math.min(this.ymin, this.ymax);
      x1 = Math.max(this.xmin, this.xmax);
      y1 = Math.max(this.ymin, this.ymax);

      adx = Math.pow(10, exponent((x1 - x0) / 1.1));
      addx = Math.pow(10, exponent((x1 - x0) / 5));
      ax0 = Math.floor(x0 / adx) * adx;
      ady = Math.pow(10, exponent((y1 - y0) / 1.1));
      addy = Math.pow(10, exponent((y1 - y0) / 5));
      ay0 = Math.floor(y0 / ady) * ady;
      l = 0; for (i = ax0; i <= x1; i += adx) { if (x0 <= i && i <= x1) { l++ }; }; 
      if (l < 2) { adx = adx / 2};
      l = 0; for (i = ay0; i <= y1; i += ady) { if (y0 <= i && i <= y1) { l++ }; };
      if (l < 2) { ady = ady / 2};

      window.status = 'tick...'; setTimeout('',10);
      for (x = ax0; x <= x1; x += adx) {
         for (i = 1; i < 6; i++) {
            str += this.pset(x, this.ymin, 0, i);
            str += this.pset(x, this.ymax, 0, -i);
         };
      };
      for (y = ay0; y <= y1; y += ady) {
         for (i = 1; i < 6; i++) {
            str += this.pset(this.xmin, y, -i, 0);
            str += this.pset(this.xmax, y, i, 0);
         };
      };
      for (x = ax0; x <= x1; x += addx) {
         for (i = 1; i < 3; i++) {
            str += this.pset(x, this.ymin, 0, i);
            str += this.pset(x, this.ymax, 0, -i);
         };
      };
      for (y = ay0; y <= y1; y += addy) {
         for (i = 1; i < 3; i++) {
            str += this.pset(this.xmin, y, -i, 0);
            str += this.pset(this.xmax, y, i, 0);
         };
      };

      window.status = 'left...'; setTimeout('',10);
      str += this.line(this.xmin, this.ymax, this.xmin, this.ymin);
      window.status = 'bottom...'; setTimeout('',10);
      str += this.line(this.xmin, this.ymin, this.xmax, this.ymin);
      window.status = 'right...'; setTimeout('',10);
      str += this.line(this.xmax, this.ymin, this.xmax, this.ymax);
      window.status = 'top...'; setTimeout('',10);
      str += this.line(this.xmax, this.ymax, this.xmin, this.ymax);
   } else {
      for (i = 0; i < 20; i++) {
         str += this.pset(this.xmin, this.ymin, 0, -i);
         str += this.pset(this.xmin, this.ymin, i, 0);
         str += this.pset(this.xmin, this.ymax, 0, i);
         str += this.pset(this.xmin, this.ymax, i, 0);
         str += this.pset(this.xmax, this.ymin, 0, -i);
         str += this.pset(this.xmax, this.ymin, -i, 0);
         str += this.pset(this.xmax, this.ymax, 0, i);
         str += this.pset(this.xmax, this.ymax, -i, 0);
      };
   };

   this.color = mc;
   return str;
};

function axisstick0(axcolor, bgcolor, conf) {
var axcolor, bgcolor, conf;
var mc, x, y, x0, y0, x1, y1, adx, addx, ax0, ady, addy, ay0, ay1;
var l = 0;
var str = '';

   if (!bgcolor) { return str; };
   axcolor = (axcolor) ? String(axcolor) : '#C0C0C0';

   mc = this.color;
   this.color = axcolor;

   if (conf) {
      x0 = Math.min(this.xmin, this.xmax);
      y0 = Math.min(this.ymin, this.ymax);
      x1 = Math.max(this.xmin, this.xmax);
      y1 = Math.max(this.ymin, this.ymax);

      adx = Math.pow(10, exponent((x1 - x0) / 1.1));
      addx = Math.pow(10, exponent((x1 - x0) / 5));
      ax0 = Math.floor(x0 / adx) * adx;
      ady = Math.pow(10, exponent((y1 - y0) / 1.1));
      addy = Math.pow(10, exponent((y1 - y0) / 5));
      ay0 = Math.floor(y0 / ady) * ady;
      ay1 = Math.ceil(y1 / ady) * ady;
      l = 0; for (i = ax0; i <= x1; i += adx) { if (x0 <= i && i <= x1) { l++ }; }; 
      if (l < 2) { adx = adx / 2};
      l = 0; for (i = ay0; i <= y1; i += ady) { if (y0 <= i && i <= y1) { l++ }; };
      if (l < 2) { ady = ady / 2};

      window.status = 'tick...'; setTimeout('',10);
      for (x = ax0; x <= x1; x += adx) {
         for (i = 1; i < 6; i += (this.size / 2)) {
            this.color = axcolor;
            str += this.pset(x, this.ymax, 0, i - 6);
         };
         this.color = bgcolor;
         str += this.pset(x, this.ymax, 0, 0);
      };
      for (x = ax0; x <= x1; x += addx) {
         for (i = 1; i < 3; i += (this.size / 2)) {
            this.color = axcolor;
            str += this.pset(x, this.ymax, 0, i - 3);
         };
         this.color = bgcolor;
         str += this.pset(x, this.ymax, 0, 0);
      };
      if (this.ymin < this.ymax) {
         for (y = ay1; y0 <= y; y -= ady) {
            for (i = 1; i < 6; i++) {
               this.color = axcolor;
               str += this.pset(this.xmin, y, -i, 0);
               str += this.pset(this.xmax, y, i, 0);
               this.color = bgcolor;
               str += this.pset(this.xmin, y, -i, 1);
               str += this.pset(this.xmax, y, i, 1);
            };
         };
         for (y = ay1; y0 <= y; y -= addy) {
            for (i = 1; i < 3; i++) {
               this.color = axcolor;
               str += this.pset(this.xmin, y, -i, 0);
               str += this.pset(this.xmax, y, i, 0);
               this.color = bgcolor;
               str += this.pset(this.xmin, y, -i, 1);
               str += this.pset(this.xmax, y, i, 1);
            };
         };
      } else if (this.ymax < this.ymin) {
         for (y = ay0; y <= y1; y += ady) {
            for (i = 1; i < 6; i++) {
               this.color = axcolor;
               str += this.pset(this.xmin, y, -i, 0);
               str += this.pset(this.xmax, y, i, 0);
               this.color = bgcolor;
               str += this.pset(this.xmin, y, -i, 1);
               str += this.pset(this.xmax, y, i, 1);
            };
         };
         for (y = ay0; y <= y1; y += addy) {
            for (i = 1; i < 3; i++) {
               this.color = axcolor;
               str += this.pset(this.xmin, y, -i, 0);
               str += this.pset(this.xmax, y, i, 0);
               this.color = bgcolor;
               str += this.pset(this.xmin, y, -i, 1);
               str += this.pset(this.xmax, y, i, 1);
            };
         };
      };

      window.status = 'top...'; setTimeout('',10);
       this.color = axcolor;
        str += this.line(this.xmax, this.ymax, this.xmin, this.ymax);
       this.color = bgcolor;
        str += this.line(this.xmax, this.ymax, this.xmin, this.ymax, 0, 1);
      window.status = 'left...'; setTimeout('',10);
       this.color = axcolor;
        str += this.stick(this.xmin, this.ymax, axcolor);
      window.status = 'right...'; setTimeout('',10);
       this.color = axcolor;
        str += this.stick(this.xmax, this.ymax, axcolor);
   } else {
      this.color = axcolor;
      for (i = 0; i < 20; i++) {
         str += this.pset(this.xmin, this.ymax, i, 0);
         str += this.pset(this.xmax, this.ymax, -i, 0);
      };
      this.color = bgcolor;
      for (i = 0; i < 20; i++) {
         str += this.pset(this.xmin, this.ymax, i, 1);
         str += this.pset(this.xmax, this.ymax, -i, 1);
      };

      this.color = axcolor;
      for (i = 0; i < 20; i += this.size / 2) {
         str += this.pset(this.xmin, this.ymin, 0, i - 20);
         str += this.pset(this.xmax, this.ymin, 0, i - 20);
         str += this.pset(this.xmin, this.ymax, 0, i);
         str += this.pset(this.xmax, this.ymax, 0, i);
      };
      this.color = bgcolor;
      str += this.pset(this.xmin, this.ymin, 0, 1);
      str += this.pset(this.xmax, this.ymin, 0, 1);
      str += this.pset(this.xmin, this.ymax, 0, 20);
      str += this.pset(this.xmax, this.ymax, 0, 20);
   };

   this.color = mc;
   return str;
};

function axisstick1(axcolor, bgcolor, conf) {
var axcolor, bgcolor, conf;
var mc, x, y, x0, y0, x1, y1, adx, addx, ax0;
var l = 0;
var str = '';

   if (!bgcolor) { return str; };
   axcolor = (axcolor) ? String(axcolor) : '#C0C0C0';

   mc = this.color;
   this.color = axcolor;

   if (conf) {
      x0 = Math.min(this.xmin, this.xmax);
      y0 = Math.min(this.ymin, this.ymax);
      x1 = Math.max(this.xmin, this.xmax);
      y1 = Math.max(this.ymin, this.ymax);

      adx = Math.pow(10, exponent((x1 - x0) / 1.1));
      addx = Math.pow(10, exponent((x1 - x0) / 5));
      ax0 = Math.floor(x0 / adx) * adx;
      l = 0; for (i = ax0; i <= x1; i += adx) { if (x0 <= i && i <= x1) { l++ }; }; 
      if (l < 2) { adx = adx / 2};

      window.status = 'bottom...'; setTimeout('',10);
      this.color = axcolor;
      str += this.line(this.xmax, this.ymin, this.xmin, this.ymin);
      this.color = bgcolor;
      str += this.line(this.xmax, this.ymin, this.xmin, this.ymin, 0, 1);

      window.status = 'tick...'; setTimeout('',10);
      for (x = ax0; x <= x1; x += addx) {
         for (i = 1; i < 3; i += (this.size / 2)) {
            this.color = axcolor;
            str += this.pset(x, this.ymin, 0, i);
            this.color = bgcolor;
            str += this.pset(x, this.ymin, 0, 3);
         };
      };
      for (x = ax0; x <= x1; x += adx) {
         for (i = 1; i < 6; i += (this.size / 2)) {
            this.color = axcolor;
            str += this.pset(x, this.ymin, 0, i);
            this.color = bgcolor;
            str += this.pset(x, this.ymin, 0, 6);
         };
      };
   } else {
      this.color = axcolor;
      for (i = 0; i < 20; i++) {
         str += this.pset(this.xmin, this.ymin, i, 0);
         str += this.pset(this.xmax, this.ymin, -i, 0);
      };
      this.color = bgcolor;
      for (i = 0; i < 20; i++) {
         str += this.pset(this.xmin, this.ymin, i, 1);
         str += this.pset(this.xmax, this.ymin, -i, 1);
      };
   };

   this.color = mc;
   return str;
};

function exponent (n) {
var n;
   n = n - 0;
   if (n != 0) {
      return Math.floor(Math.LOG10E * Math.log(Math.abs(n)));
   } else {
      return 0;
   };
};
