if(window.top!=window.self)self.location.href="WHITE.png"

xr=15; xg=15; xb=15; rlschar=15; glschar=15; blschar=15;
txtr=0; txtg=0; txtb=8; txtrlschar=0; txtglschar=0; txtblschar=0;
tempr=15; tempg=15; tempb=15; temprlschar=15; tempglschar=15; tempblschar=15;
saved_BG=""
saved_TEXT=""
selector="BGCOLOR"
textcolor="000080"
savecolor="FFFFFF"
savecount=0
savelength=10
tintflag=false
openw=false

function makeArray(n){for(i=0;i<n;i++){this[i]=0}}

choice=new makeArray(10)
choice[0]="B0D0D0";choice[1]="?";choice[2]="?";choice[3]="?";choice[4]="?";
choice[5]="?";choice[6]="?";choice[7]="?";choice[8]="?";choice[9]="?";

txtcol=new makeArray(10)
txtcol[0]="000077";txtcol[1]="?";txtcol[2]="?";txtcol[3]="?";txtcol[4]="?";
txtcol[5]="?";txtcol[6]="?";txtcol[7]="?";txtcol[8]="?";txtcol[9]="?";

hex=new makeArray(17)
hex[0]="0";hex[1]="1";hex[2]="2";hex[3]="3";
hex[4]="4";hex[5]="5";hex[6]="6";hex[7]="7"
hex[8]="8";hex[9]="9";hex[10]="A";hex[11]="B";
hex[12]="C";hex[13]="D";hex[14]="E";hex[15]="F";hex[16]="FF";

function set_BG()
{
 clear_tints()
 restore_bg_values()
 selector="BGCOLOR"
 document.form1.radios[0].checked=true
 setbg()
}
function set_TEXT()
{
 clear_tints()
 restore_text_values()
 selector="TEXT"
 document.form1.radios[1].checked=true
 setbg()
}
function save_bg_values(){tempr=xr;temprlschar=rlschar;tempg=xg;tempglschar=glschar;tempb=xb;tempblschar=blschar}
function restore_bg_values(){xr=tempr;rlschar=temprlschar;xg=tempg;glschar=tempglschar;xb=tempb;blschar=tempblschar}
function save_text_values(){txtr=xr;txtrlschar=rlschar;txtg=xg;txtglschar=glschar;txtb=xb;txtblschar=blschar}
function restore_text_values(){xr=txtr;rlschar=txtrlschar;xg=txtg;glschar=txtglschar;xb=txtb;blschar=txtblschar}

function set_decimal(str)
{
 document.form1.dred.value=parseInt("0x"+str.charAt(1)+str.charAt(2))
 document.form1.dgreen.value=parseInt("0x"+str.charAt(3)+str.charAt(4))
 document.form1.dblue.value=parseInt("0x"+str.charAt(5)+str.charAt(6))
}
function save()
{
 self.focus()
 if ((saved_TEXT!=textcolor)||(saved_BG!=savecolor))
 {
  saved_BG  =savecolor
  saved_TEXT=textcolor
  choice[savecount]=savecolor
  txtcol[savecount]=textcolor
  if(savelength>savecount)savecount++
  else for(i=0;i<=(savelength-1);i++){if("TEXT"==selector)txtcol[i]=txtcol[i+1];else choice[i]=choice[i+1]}
 }
}
function recall()
{
 self.focus()
 if(0!=savecount)
 {
  helpw=window.open('','ColorChoices','top=0,left=0,height=314,width=450,status=yes,menubar=yes,scrollbars=yes,resizable=yes')
  helpw.document.writeln('<HTML><HEAD><TITLE>Saved Color Choices<\/TITLE>')
  helpw.document.writeln('<STYLE>HTML,BODY{margin:0;padding:0}<\/STYLE>')
  helpw.document.writeln('<\/HEAD><BODY onLoad="opener.openw=true" onUnload="opener.openw=false"><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=10 WIDTH="100%">')
  for(i=(savecount);i>0;i--){helpw.document.writeln('<TR><TD BGCOLOR="#'+choice[i-1]+'"><FONT FACE="verdana,sans-serif" COLOR='+txtcol[i-1]+'><H4><FONT COLOR=black>'+choice[i-1]+'<\/FONT><FONT FACE="verdana,sans-serif" COLOR=white>&nbsp;&nbsp;&nbsp;'+choice[i-1]+'<\/FONT><BR><BR>Text&nbsp;=&nbsp;'+txtcol[i-1]+'<\/H4>____<\/FONT><\/TD><\/TR>')}
  helpw.document.writeln('<TR><TD>Save As... HTML only<\/TD><\/TR>')
  helpw.document.writeln('<\/TABLE><\/BODY><\/HTML>')
  helpw.document.close()
  helpw.focus()
 }
}
function close_pop(){if(openw)helpw.close()}

function tints(tint,nradio)
{
 self.focus()
 selector="BGCOLOR"
 document.form1.radios[0].checked=true
 document.form1.tint[nradio].checked=true
 document.form1.radios[0].checked=false
 if (tint!=savecolor) chosen=true
 savecolor=tint
 trgb="#"+tint
 document.bgColor=trgb
 set_decimal(trgb)
 document.form1.xred.value=""
 document.form1.xgreen.value=""
 document.form1.xblue.value=""
 tintflag=true
}
function clear_tints()
{
 for(i=0;i<7;i++) document.form1.tint[i].checked=false
 if("TEXT"!=selector) document.form1.radios[0].checked=true
 tintflag=false
}
function pal(r,g,b)
{
 tintflag=false
 if(16==r){rlschar=15;xr=15}else{rlschar=0;xr=r}
 if(16==g){glschar=15;xg=15}else{glschar=0;xg=g}
 if(16==b){blschar=15;xb=15}else{blschar=0;xb=b}
 setbg()
}
function setbg()
{
 self.focus()
 if (!tintflag)
 {
  clear_tints()

  if ("TEXT"==selector)
  {
   textcolor=hex[xr]+hex[rlschar]+hex[xg]+hex[glschar]+hex[xb]+hex[blschar]
   hrgb="#"+textcolor
   save_text_values()
   document.fgColor=hrgb
  }
  else
  {
   savecolor=hex[xr]+hex[rlschar]+hex[xg]+hex[glschar]+hex[xb]+hex[blschar]
   hrgb="#"+savecolor
   save_bg_values()
   document.bgColor=hrgb
   document.form1.sel.value=hrgb
   //document.getElementsByTagName("table").bgColor=hrgb


  }
  set_decimal(hrgb)
  document.form1.xred.value=" "+hex[xr]+hex[rlschar]
  document.form1.xgreen.value=" "+hex[xg]+hex[glschar]
  document.form1.xblue.value=" "+hex[xb]+hex[blschar]
 }
}


function setr(r){if(16==r){rlschar=15;xr=15}else{rlschar=0;xr=r}setbg()}
function setg(g){if(16==g){glschar=15;xg=15}else{glschar=0;xg=g}setbg()}
function setb(b){if(16==b){blschar=15;xb=15}else{blschar=0;xb=b}setbg()}

function rminus8(){if(0==(rlschar-8))rlschar=0;else{if(1>=xr){xr=0;rlschar=0}else{if(15==rlschar)rlschar=8;else{xr-=1;rlschar=8}}}setbg()}
function gminus4(){if(15==xg&&15==glschar)glschar=12;else{if(0==xg&&8>=glschar){glschar=0}else{if(0==glschar){xg-=1;glschar=12}else glschar-=4}}setbg()}
function bminus8(){if(0==(blschar-8))blschar=0;else{if(1>=xb){xb=0;blschar=0}else{if(15==blschar)blschar=8;else{xb-=1;blschar=8}}}setbg()}
function rplus8(){if((0==xr)&&(0==rlschar))xr=1;else if(16<=(rlschar+8)){rlschar=0;if(16<=(xr+1)){xr=15;rlschar=15}else{xr+=1}}else{rlschar+=8}setbg()}
function gplus4(){if(0==xg&&8>glschar)glschar=4;if(15==xg){if(12<=glschar)glschar=15;else glschar+=4}else if(12==glschar){xg+=1;glschar=0}else glschar+=4;setbg()}
function bplus8(){if((0==xb)&&(0==blschar))xb=1;else if(16<=(blschar+8)){blschar=0;if(16<=(xb+1)){xb=15;blschar=15}else{xb+=1}}else{blschar+=8}setbg()}

function darken() {if(1<xr||1<xg||1<xb){if(15==xr&&15==rlschar){rlschar=0}else{xr-=1}if(0>xr)xr=0;if(15==xg&&15==glschar){glschar=0}else{xg-=1}if(0>xg)xg=0;if(15==xb&&15==blschar){blschar=0}else{xb-=1}if(0>xb)xb=0;setbg()}self.focus()}
function lighten(){if(15>xr||15>xg||15>xb){xr+=1;if(15<xr){xr=15;rlschar=15}xg+=1;if(15<xg){xg=15;glschar=15}xb+=1;if(15<xb){xb=15;blschar=15}setbg()}self.focus()}

function inc_rh() {xr+=1;if(15<xr){xr=15;rlschar=15}setbg()}
function inc_gh() {xg+=1;if(15<xg){xg=15;glschar=15}setbg()}
function inc_bh() {xb+=1;if(15<xb){xb=15;blschar=15}setbg()}
function dec_rh() {if(15==xr&&15==rlschar){rlschar=0}else{xr-=1}if(0>xr)xr=0;setbg()}
function dec_gh() {if(15==xg&&15==glschar){glschar=0}else{xg-=1}if(0>xg)xg=0;setbg()}
function dec_bh() {if(15==xb&&15==blschar){blschar=0}else{xb-=1}if(0>xb)xb=0;setbg()}

function check()
{
 if (9>screen.colorDepth || 8==screen.pixelDepth) {document.form1.cmode.value=" 256 color mode"}
 else
 if (16>=screen.colorDepth || 16==screen.pixelDepth) {document.form1.cmode.value=" 16-bit color mode"}
 else document.form1.cmode.value=" True Color"
}
function init(){;check()}
function redo(){check();setTimeout('document.bgColor="#"+savecolor',450)}
onresize=redo;
