/* This notice must be untouched at all times.

wz_jsgraphics.js    v. 2.32
The latest version is available at
http://www.walterzorn.com
or http://www.devira.com
or http://www.walterzorn.de

Copyright (c) 2002-2004 Walter Zorn. All rights reserved.
Created 3. 11. 2002 by Walter Zorn (Web: http://www.walterzorn.com )
Last modified: 21. 6. 2005

Performance optimizations for Internet Explorer
by Thomas Frank and John Holdsworth.
fillPolygon method implemented by Matthieu Haller.

High Performance JavaScript Graphics Library.
Provides methods
- to draw lines, rectangles, ellipses, polygons
	with specifiable line thickness,
- to fill rectangles and ellipses
- to draw text.
NOTE: Operations, functions and branching have rather been optimized
to efficiency and speed than to shortness of source code.

LICENSE: LGPL

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License (LGPL) as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA,
or see http://www.gnu.org/copyleft/lesser.html
*/

//Modified by Lech Mazur Oct. 17, 2005 to remove unneeded functions and to reduce size
var jg_ihtm,jg_ie,jg_fast,jg_dom,jg_moz,jg_n4=(document.layers&&typeof document.classes!="undefined");function chkDHTM(a,b){a=document.body||null;jg_ie=a&&typeof a.insertAdjacentHTML!="undefined";jg_dom=(a&&!jg_ie&&typeof a.appendChild!="undefined"&&typeof document.createRange!="undefined"&&typeof(b=document.createRange()).setStartBefore!="undefined"&&typeof b.createContextualFragment!="undefined");jg_ihtm=!jg_ie&&!jg_dom&&a&&typeof a.innerHTML!="undefined";jg_fast=jg_ie&&document.all&&!window.opera;jg_moz=jg_dom&&typeof a.style.MozOpacity!="undefined"}function pntDoc(){this.wnd.document.write(jg_fast?this.htmRpc():this.htm);this.htm=''}function pntCnvDom(){var x=document.createRange();x.setStartBefore(this.cnv);x=x.createContextualFragment(jg_fast?this.htmRpc():this.htm);this.cnv.appendChild(x);this.htm=''}function pntCnvIe(){this.cnv.insertAdjacentHTML("BeforeEnd",jg_fast?this.htmRpc():this.htm);this.htm=''}function pntCnvIhtm(){this.cnv.innerHTML+=this.htm;this.htm=''}function pntCnv(){this.htm=''}function mkDiv(a,b,c,d){this.htm+='<div style="position:absolute;'+'left:'+a+'px;'+'top:'+b+'px;'+'width:'+c+'px;'+'height:'+d+'px;'+'clip:rect(0,'+c+'px,'+d+'px,0);'+'background-color:'+this.color+(!jg_moz?';overflow:hidden':'')+';"><\/div>'}function mkDivIe(a,b,c,d){this.htm+='%%'+this.color+';'+a+';'+b+';'+c+';'+d+';'}function mkDivPrt(a,b,c,d){this.htm+='<div style="position:absolute;'+'border-left:'+c+'px solid '+this.color+';'+'left:'+a+'px;'+'top:'+b+'px;'+'width:0px;'+'height:'+d+'px;'+'clip:rect(0,'+c+'px,'+d+'px,0);'+'background-color:'+this.color+(!jg_moz?';overflow:hidden':'')+';"><\/div>'}function mkLyr(a,b,c,d){this.htm+='<layer '+'left="'+a+'" '+'top="'+b+'" '+'width="'+c+'" '+'height="'+d+'" '+'bgcolor="'+this.color+'"><\/layer>\n'}var regex=/%%([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);/g;function htmRpc(){return this.htm.replace(regex,'<div style="overflow:hidden;position:absolute;background-color:'+'$1;left:$2;top:$3;width:$4;height:$5"></div>\n')}function htmPrtRpc(){return this.htm.replace(regex,'<div style="overflow:hidden;position:absolute;background-color:'+'$1;left:$2;top:$3;width:$4;height:$5;border-left:$4px solid $1"></div>\n')}function mkLin(a,b,c,d){if(a>c){var e=c;var f=d;c=a;d=b;a=e;b=f}var g=c-a,dy=Math.abs(d-b),x=a,y=b,yIncr=(b>d)?-1:1;if(g>=dy){var h=dy<<1,pru=h-(g<<1),p=h-g,ox=x;while((g--)>0){++x;if(p>0){this.mkDiv(ox,y,x-ox,1);y+=yIncr;p+=pru;ox=x}else p+=h}this.mkDiv(ox,y,c-ox+1,1)}else{var h=g<<1,pru=h-(dy<<1),p=h-dy,oy=y;if(d<=b){while((dy--)>0){if(p>0){this.mkDiv(x++,y,1,oy-y+1);y+=yIncr;p+=pru;oy=y}else{y+=yIncr;p+=h}}this.mkDiv(c,d,1,oy-d+1)}else{while((dy--)>0){y+=yIncr;if(p>0){this.mkDiv(x++,oy,1,y-oy);p+=pru;oy=y}else p+=h}this.mkDiv(c,oy,1,d-oy+1)}}}function mkLin2D(a,b,c,d){if(a>c){var e=c;var f=d;c=a;d=b;a=e;b=f}var g=c-a,dy=Math.abs(d-b),x=a,y=b,yIncr=(b>d)?-1:1;var s=this.stroke;if(g>=dy){if(s-3>0){var h=(s*g*Math.sqrt(1+dy*dy/(g*g))-g-(s>>1)*dy)/g;h=(!(s-4)?Math.ceil(h):Math.round(h))+1}else var h=s;var i=Math.ceil(s/2);var j=dy<<1,pru=j-(g<<1),p=j-g,ox=x;while((g--)>0){++x;if(p>0){this.mkDiv(ox,y,x-ox+i,h);y+=yIncr;p+=pru;ox=x}else p+=j}this.mkDiv(ox,y,c-ox+i+1,h)}else{if(s-3>0){var h=(s*dy*Math.sqrt(1+g*g/(dy*dy))-(s>>1)*g-dy)/dy;h=(!(s-4)?Math.ceil(h):Math.round(h))+1}else var h=s;var i=Math.round(s/2);var j=g<<1,pru=j-(dy<<1),p=j-dy,oy=y;if(d<=b){++i;while((dy--)>0){if(p>0){this.mkDiv(x++,y,h,oy-y+i);y+=yIncr;p+=pru;oy=y}else{y+=yIncr;p+=j}}this.mkDiv(c,d,h,oy-d+i)}else{while((dy--)>0){y+=yIncr;if(p>0){this.mkDiv(x++,oy,h,y-oy+i);p+=pru;oy=y}else p+=j}this.mkDiv(c,oy,h,d-oy+i+1)}}}function jsgFont(){this.PLAIN='font-weight:normal;';this.BOLD='font-weight:bold;';this.ITALIC='font-style:italic;';this.ITALIC_BOLD=this.ITALIC+this.BOLD;this.BOLD_ITALIC=this.ITALIC_BOLD}var Font=new jsgFont();function jsGraphics(h,j){this.setColor=new Function('arg','this.color = arg.toLowerCase();');this.setStroke=function(a){this.stroke=a;if(!(a+1)){}else if(a-1>0){this.drawLine=mkLin2D}else{this.drawLine=mkLin}};this.setPrintable=function(a){this.printable=a;if(jg_fast){this.mkDiv=mkDivIe;this.htmRpc=a?htmPrtRpc:htmRpc}else this.mkDiv=jg_n4?mkLyr:a?mkDivPrt:mkDiv};this.setFont=function(a,b,c){this.ftFam=a;this.ftSz=b;this.ftSty=c||Font.PLAIN};this.drawPolyline=this.drawPolyLine=function(a,b,c){for(var i=0;i<a.length-1;i++)this.drawLine(a[i],b[i],a[i+1],b[i+1])};this.fillRect=function(a,b,c,d){this.mkDiv(a,b,c,d)};this.drawPolygon=function(a,b){this.drawPolyline(a,b);this.drawLine(a[a.length-1],b[a.length-1],a[0],b[0])};this.drawString=function(a,b,c){this.htm+='<div style="position:absolute;white-space:nowrap;'+'left:'+b+'px;'+'top:'+c+'px;'+'font-family:'+this.ftFam+';'+'font-size:'+this.ftSz+';'+'color:'+this.color+';'+this.ftSty+'">'+a+'<\/div>'};this.drawStringRect=function(a,b,c,d,e){this.htm+='<div style="position:absolute;overflow:hidden;'+'left:'+b+'px;'+'top:'+c+'px;'+'width:'+d+'px;'+'text-align:'+e+';'+'font-family:'+this.ftFam+';'+'font-size:'+this.ftSz+';'+'color:'+this.color+';'+this.ftSty+'">'+a+'<\/div>'};this.drawImage=function(b,c,d,e,f,g){this.htm+='<div style="position:absolute;'+'left:'+c+'px;'+'top:'+d+'px;'+'width:'+e+';'+'height:'+f+';">'+'<img src="'+b+'" width="'+e+'" height="'+f+'"'+(g?(' '+g):'')+'>'+'<\/div>'};this.clear=function(){this.htm="";if(this.cnv)this.cnv.innerHTML=this.defhtm};this.setStroke(1);this.setFont('verdana,geneva,helvetica,sans-serif',String.fromCharCode(0x31,0x32,0x70,0x78),Font.PLAIN);this.color='#000000';this.htm='';this.wnd=j||window;if(!(jg_ie||jg_dom||jg_ihtm))chkDHTM();if(typeof h!='string'||!h)this.paint=pntDoc;else{this.cnv=document.all?(this.wnd.document.all[h]||null):document.getElementById?(this.wnd.document.getElementById(h)||null):null;this.defhtm=(this.cnv&&this.cnv.innerHTML)?this.cnv.innerHTML:'';this.paint=jg_dom?pntCnvDom:jg_ie?pntCnvIe:jg_ihtm?pntCnvIhtm:pntCnv}this.setPrintable(false)}function integer_compare(a,b){return(a<b)?-1:((a>b)*1)}