var x=0;
var r=0;
var totn=200;
var hits=0;
var misses=0;
var p1=0;
var q1=0;
var m=0;
var v=0;
var a=0;
var b=0;
var c=0;
var p=0;
var i=0;
var z=0;
var zt=0;
var mx=100;
var stp=0;
var totseg=0;
var chisq=0;
var dur=0;
var norm=new Array(210);
var normd=new Array(210);
var maxh=0;
var freqtxt="";

var df=0;
var pchi=0;
var tchi=0;
var achi=0;
var kchi=0;
var schi=0;
var zchi=0;
var dchi=0;

var hr$="";
var mn$="";
var sc$="";

var timeout=0;
var timeout1=0;

var monname=new Array("","January","February","March","April","May","June","July","August","September","October","November","December");

var mydate= new Date();
var theyear=mydate.getFullYear();
var themonth=mydate.getMonth()+1;
var theday=mydate.getDate();
var thehour=mydate.getHours();
var themin=mydate.getMinutes();
var thesec=mydate.getSeconds();

var x1a = 0.31938153;
var x2 = -0.356563782;
var x3 = 1.781477937;
var x4 = -1.821255978;
var x5 = 1.330274429;

var ht=new Array(50);
var neght=0;
var posht=0;

function setres(){
document.forms.matrix.Cont.value="Reset";
}

function begin(){
if(document.forms.matrix.Cont.value==""){return;}
if(document.forms.matrix.Cont.value=="Stop"){stp=1;dispfreq();document.forms.matrix.Cont.value="";clearTimeout(timeout1);timeout1=setTimeout("setres();",1000);return;}
if(document.forms.matrix.Cont.value=="Reset"){resetall();return;}
i=60;
totseg=1;
hits=0;
misses=0;
z=0;
zt=0;
chisq=0;
document.forms.matrix.Cont.value="Stop";

clearTimeout(timeout1);
clearTimeout(timeout);
timeout=setTimeout("doit();",1000);
}

function finddur(){
if(document.forms.matrix.D1.selectedIndex==0){dur=0;}
if(document.forms.matrix.D1.selectedIndex==1){dur=60;}
if(document.forms.matrix.D1.selectedIndex==2){dur=120;}
if(document.forms.matrix.D1.selectedIndex==3){dur=300;}
if(document.forms.matrix.D1.selectedIndex==4){dur=600;}
if(document.forms.matrix.D1.selectedIndex==5){dur=1200;}
if(document.forms.matrix.D1.selectedIndex==6){dur=1800;}
if(document.forms.matrix.D1.selectedIndex==7){dur=3600;}
if(document.forms.matrix.D1.selectedIndex==8){dur=7200;}
if(document.forms.matrix.D1.selectedIndex==9){dur=10800;}
if(document.forms.matrix.D1.selectedIndex==10){dur=14400;}
if(document.forms.matrix.D1.selectedIndex==11){dur=28800;}
if(document.forms.matrix.D1.selectedIndex==12){dur=43200;}
if(document.forms.matrix.D1.selectedIndex==13){dur=86400;}
}

function doit(){
clearTimeout(timeout);
finddur();

document.forms.matrix.D1.disabled=true;

if(dur!=0){
if(totseg>dur){stp=1;document.forms.matrix.Cont.value="Reset";dispfreq();return;}
}

if(stp==1){stp=0;return;}

if(i<1){clearbars();i=60;}

hits=0;
misses=0;
sample();
critrat();
ndist();
calcchi();
calcht();
disptime();
disp();
dispcomp();
i--;
totseg++;
clearTimeout(timeout);
timeout=setTimeout("doit();",1000);
}

function resetall(){

for(x=0;x<201;x++){norm[x]=0;normd[x]=0;}
maxh=0;
neght=0;
posht=0;
stp=0;
freqtxt="";
document.forms.matrix.D1.disabled=false;
document.forms.matrix.Text1.value="Highly Strange Events:\n\n";
document.forms.matrix.Text2.value="";
document.forms.matrix.Frq.value="";
clearbars();
totseg=0;
chisq=0;
i=60;
document.forms.matrix.Cont.value="Start";
document.forms.matrix.Year.value="";
document.forms.matrix.Hour.value="";
document.forms.matrix.Chi.value="";
document.forms.matrix.Button13.value="";
document.forms.matrix.Button15.value="";
document.forms.matrix.Button17.value="";
document.forms.matrix.TotTime.value="";
document.forms.matrix.Probab.value="";
document.forms.matrix.B0.style.height="30px";

document.forms.matrix.NN46.style.backgroundColor="white";
document.forms.matrix.NN45.style.backgroundColor="white";
document.forms.matrix.NN44.style.backgroundColor="white";
document.forms.matrix.NN43.style.backgroundColor="white";
document.forms.matrix.NN42.style.backgroundColor="white";
document.forms.matrix.NN41.style.backgroundColor="white";
document.forms.matrix.NN40.style.backgroundColor="white";
document.forms.matrix.NN39.style.backgroundColor="white";
document.forms.matrix.NN38.style.backgroundColor="white";
document.forms.matrix.NN37.style.backgroundColor="white";
document.forms.matrix.NN36.style.backgroundColor="white";
document.forms.matrix.NN35.style.backgroundColor="white";
document.forms.matrix.NN34.style.backgroundColor="white";
document.forms.matrix.NN33.style.backgroundColor="white";
document.forms.matrix.NN32.style.backgroundColor="white";
document.forms.matrix.NN31.style.backgroundColor="white";
document.forms.matrix.NN30.style.backgroundColor="white";
document.forms.matrix.NN29.style.backgroundColor="white";
document.forms.matrix.NN28.style.backgroundColor="white";
document.forms.matrix.NN27.style.backgroundColor="white";
document.forms.matrix.NN26.style.backgroundColor="white";
document.forms.matrix.NN25.style.backgroundColor="white";
document.forms.matrix.NN24.style.backgroundColor="white";
document.forms.matrix.NN23.style.backgroundColor="white";
document.forms.matrix.NN22.style.backgroundColor="white";
document.forms.matrix.NN21.style.backgroundColor="white";
document.forms.matrix.NN20.style.backgroundColor="white";
document.forms.matrix.NN19.style.backgroundColor="white";
document.forms.matrix.NN18.style.backgroundColor="white";
document.forms.matrix.NN17.style.backgroundColor="white";
document.forms.matrix.NN16.style.backgroundColor="white";
document.forms.matrix.NN15.style.backgroundColor="white";
document.forms.matrix.NN14.style.backgroundColor="white";
document.forms.matrix.NN13.style.backgroundColor="white";
document.forms.matrix.NN12.style.backgroundColor="white";
document.forms.matrix.NN11.style.backgroundColor="white";
document.forms.matrix.NN10.style.backgroundColor="white";
document.forms.matrix.NN9.style.backgroundColor="white";
document.forms.matrix.NN8.style.backgroundColor="white";
document.forms.matrix.NN7.style.backgroundColor="white";
document.forms.matrix.NN6.style.backgroundColor="white";
document.forms.matrix.NN5.style.backgroundColor="white";
document.forms.matrix.NN4.style.backgroundColor="white";
document.forms.matrix.NN3.style.backgroundColor="white";
document.forms.matrix.NN2.style.backgroundColor="white";
document.forms.matrix.NN1.style.backgroundColor="white";

document.forms.matrix.NP45.style.backgroundColor="white";
document.forms.matrix.NP44.style.backgroundColor="white";
document.forms.matrix.NP43.style.backgroundColor="white";
document.forms.matrix.NP42.style.backgroundColor="white";
document.forms.matrix.NP41.style.backgroundColor="white";
document.forms.matrix.NP40.style.backgroundColor="white";
document.forms.matrix.NP39.style.backgroundColor="white";
document.forms.matrix.NP38.style.backgroundColor="white";
document.forms.matrix.NP37.style.backgroundColor="white";
document.forms.matrix.NP36.style.backgroundColor="white";
document.forms.matrix.NP35.style.backgroundColor="white";
document.forms.matrix.NP34.style.backgroundColor="white";
document.forms.matrix.NP33.style.backgroundColor="white";
document.forms.matrix.NP32.style.backgroundColor="white";
document.forms.matrix.NP31.style.backgroundColor="white";
document.forms.matrix.NP30.style.backgroundColor="white";
document.forms.matrix.NP29.style.backgroundColor="white";
document.forms.matrix.NP28.style.backgroundColor="white";
document.forms.matrix.NP27.style.backgroundColor="white";
document.forms.matrix.NP26.style.backgroundColor="white";
document.forms.matrix.NP25.style.backgroundColor="white";
document.forms.matrix.NP24.style.backgroundColor="white";
document.forms.matrix.NP23.style.backgroundColor="white";
document.forms.matrix.NP22.style.backgroundColor="white";
document.forms.matrix.NP21.style.backgroundColor="white";
document.forms.matrix.NP20.style.backgroundColor="white";
document.forms.matrix.NP19.style.backgroundColor="white";
document.forms.matrix.NP18.style.backgroundColor="white";
document.forms.matrix.NP17.style.backgroundColor="white";
document.forms.matrix.NP16.style.backgroundColor="white";
document.forms.matrix.NP15.style.backgroundColor="white";
document.forms.matrix.NP14.style.backgroundColor="white";
document.forms.matrix.NP13.style.backgroundColor="white";
document.forms.matrix.NP12.style.backgroundColor="white";
document.forms.matrix.NP11.style.backgroundColor="white";
document.forms.matrix.NP10.style.backgroundColor="white";
document.forms.matrix.NP9.style.backgroundColor="white";
document.forms.matrix.NP8.style.backgroundColor="white";
document.forms.matrix.NP7.style.backgroundColor="white";
document.forms.matrix.NP6.style.backgroundColor="white";
document.forms.matrix.NP5.style.backgroundColor="white";
document.forms.matrix.NP4.style.backgroundColor="white";
document.forms.matrix.NP3.style.backgroundColor="white";
document.forms.matrix.NP2.style.backgroundColor="white";
document.forms.matrix.NP1.style.backgroundColor="white";

}

function sample(){
for (x=0;x<200;x++){ran2();if(r==1){hits++;}else{misses++};}
}

function ran2(){
r=(Math.floor(Math.random()*2)+1);
}

function critrat(){
p1= 0.5;
q1 = 0.5;
m = mx;
with (Math) {
v = sqrt(totn*p1*q1);
if (hits >= m) {
z = (hits-m-0.5)/v;
} else {
z = ((hits-m+0.5)/v);
}
}
chisq=chisq+Math.pow(z,2);
}

function ndist() {
a=Math.abs(z);
b=1/(1+a*0.2316419);
c=(1/Math.sqrt((2*Math.PI)))*Math.exp(-Math.pow(a,2)/2);
p=1-c*(parseFloat(x1a*b+x2*Math.pow(b,2))+parseFloat(x3*Math.pow(b,3))+parseFloat(x4*Math.pow(b,4))+parseFloat(x5*Math.pow(b,5)))
p=2*(1-p);
}

function calcht(){
if (p>=0.5){ht[i]=Math.floor((1-p)*(200/5))+11;}
if (p<=0.5){ht[i]=Math.floor((0.5-p)*(200/3))+31;}
if (p<=0.2){ht[i]=Math.floor((0.2-p)*(200/1))+51;}
if (p<=0.1){ht[i]=Math.floor((0.1-p)*(2000/5))+71;}
if (p<=0.05){ht[i]=Math.floor((0.05-p)*(2000/3))+91;}
if (p<=0.02){ht[i]=Math.floor((0.02-p)*(2000/1))+111;}
if (p<=0.01){ht[i]=Math.floor((0.01-p)*(20000/5))+131;}
if (p<=0.005){ht[i]=Math.floor((0.005-p)*(20000/3))+151;}
if (p<=0.002){ht[i]=Math.floor((0.002-p)*(20000/1))+171;}
if (p<=0.001){ht[i]=Math.floor((0.001-p)*(200000/5))+191;}
if (p<=0.0005){ht[i]=Math.floor((0.0005-p)*(200000/3))+211;}
if (p<=0.0002){ht[i]=Math.floor((0.0002-p)*(200000/1))+231;}
if (p<=0.0001){ht[i]=Math.floor((0.0001-p)*(2000000/5))+251;}
if (p<=0.00005){ht[i]=Math.floor((0.00005-p)*(2000000/3))+271;}
if (p<=0.00002){ht[i]=Math.floor((0.00002-p)*(2000000/1))+291;}
if (p<=0.00001){ht[i]=Math.floor((0.00001-p)*(20000000/5))+311;}
if (p<=0.000005){ht[i]=Math.floor((0.000005-p)*(20000000/3))+331;}
if (p<=0.000002){ht[i]=Math.floor((0.000002-p)*(20000000/1))+351;}
if (p<=0.000001){ht[i]=380;}

if (pchi>=0.5){ht[0]=Math.floor((1-pchi)*(200/5))+11;}
if (pchi<=0.5){ht[0]=Math.floor((0.5-pchi)*(200/3))+31;}
if (pchi<=0.2){ht[0]=Math.floor((0.2-pchi)*(200/1))+51;}
if (pchi<=0.1){ht[0]=Math.floor((0.1-pchi)*(2000/5))+71;}
if (pchi<=0.05){ht[0]=Math.floor((0.05-pchi)*(2000/3))+91;}
if (pchi<=0.02){ht[0]=Math.floor((0.02-pchi)*(2000/1))+111;}
if (pchi<=0.01){ht[0]=Math.floor((0.01-pchi)*(20000/5))+131;}
if (pchi<=0.005){ht[0]=Math.floor((0.005-pchi)*(20000/3))+151;}
if (pchi<=0.002){ht[0]=Math.floor((0.002-pchi)*(20000/1))+171;}
if (pchi<=0.001){ht[0]=Math.floor((0.001-pchi)*(200000/5))+191;}
if (pchi<=0.0005){ht[0]=Math.floor((0.0005-pchi)*(200000/3))+211;}
if (pchi<=0.0002){ht[0]=Math.floor((0.0002-pchi)*(200000/1))+231;}
if (pchi<=0.0001){ht[0]=Math.floor((0.0001-pchi)*(2000000/5))+251;}
if (pchi<=0.00005){ht[0]=Math.floor((0.00005-pchi)*(2000000/3))+271;}
if (pchi<=0.00002){ht[0]=Math.floor((0.00002-pchi)*(2000000/1))+291;}
if (pchi<=0.00001){ht[0]=Math.floor((0.00001-pchi)*(20000000/5))+311;}
if (pchi<=0.000005){ht[0]=Math.floor((0.000005-pchi)*(20000000/3))+331;}
if (pchi<=0.000002){ht[0]=Math.floor((0.000002-pchi)*(20000000/1))+351;}
if (pchi<=0.000001){ht[0]=380;}

}

function disp(){

dispextra();

if(i==60){
document.forms.matrix.B60.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B60.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B60.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B60.style.backgroundColor="Lime";
}

if(i==59){
document.forms.matrix.B59.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B59.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B59.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B59.style.backgroundColor="Lime";
}

if(i==58){
document.forms.matrix.B58.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B58.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B58.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B58.style.backgroundColor="Lime";
}

if(i==57){
document.forms.matrix.B57.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B57.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B57.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B57.style.backgroundColor="Lime";
}

if(i==56){
document.forms.matrix.B56.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B56.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B56.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B56.style.backgroundColor="Lime";
}

if(i==55){
document.forms.matrix.B55.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B55.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B55.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B55.style.backgroundColor="Lime";
}

if(i==54){
document.forms.matrix.B54.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B54.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B54.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B54.style.backgroundColor="Lime";
}

if(i==53){
document.forms.matrix.B53.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B53.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B53.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B53.style.backgroundColor="Lime";
}

if(i==52){
document.forms.matrix.B52.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B52.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B52.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B52.style.backgroundColor="Lime";
}

if(i==51){
document.forms.matrix.B51.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B51.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B51.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B51.style.backgroundColor="Lime";
}

if(i==50){
document.forms.matrix.B50.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B50.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B50.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B50.style.backgroundColor="Lime";
}

if(i==49){
document.forms.matrix.B49.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B49.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B49.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B49.style.backgroundColor="Lime";
}

if(i==48){
document.forms.matrix.B48.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B48.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B48.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B48.style.backgroundColor="Lime";
}

if(i==47){
document.forms.matrix.B47.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B47.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B47.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B47.style.backgroundColor="Lime";
}

if(i==46){
document.forms.matrix.B46.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B46.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B46.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B46.style.backgroundColor="Lime";
}

if(i==45){
document.forms.matrix.B45.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B45.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B45.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B45.style.backgroundColor="Lime";
}

if(i==44){
document.forms.matrix.B44.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B44.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B44.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B44.style.backgroundColor="Lime";
}

if(i==43){
document.forms.matrix.B43.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B43.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B43.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B43.style.backgroundColor="Lime";
}

if(i==42){
document.forms.matrix.B42.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B42.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B42.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B42.style.backgroundColor="Lime";
}

if(i==41){
document.forms.matrix.B41.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B41.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B41.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B41.style.backgroundColor="Lime";
}

if(i==40){
document.forms.matrix.B40.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B40.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B40.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B40.style.backgroundColor="Lime";
}

if(i==39){
document.forms.matrix.B39.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B39.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B39.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B39.style.backgroundColor="Lime";
}

if(i==38){
document.forms.matrix.B38.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B38.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B38.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B38.style.backgroundColor="Lime";
}

if(i==37){
document.forms.matrix.B37.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B37.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B37.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B37.style.backgroundColor="Lime";
}

if(i==36){
document.forms.matrix.B36.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B36.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B36.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B36.style.backgroundColor="Lime";
}

if(i==35){
document.forms.matrix.B35.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B35.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B35.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B35.style.backgroundColor="Lime";
}

if(i==34){
document.forms.matrix.B34.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B34.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B34.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B34.style.backgroundColor="Lime";
}

if(i==33){
document.forms.matrix.B33.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B33.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B33.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B33.style.backgroundColor="Lime";
}

if(i==32){
document.forms.matrix.B32.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B32.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B32.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B32.style.backgroundColor="Lime";
}

if(i==31){
document.forms.matrix.B31.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B31.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B31.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B31.style.backgroundColor="Lime";
}

if(i==30){
document.forms.matrix.B30.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B30.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B30.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B30.style.backgroundColor="Lime";
}

if(i==29){
document.forms.matrix.B29.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B29.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B29.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B29.style.backgroundColor="Lime";
}
if(i==28){
document.forms.matrix.B28.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B28.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B28.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B28.style.backgroundColor="Lime";
}
if(i==27){
document.forms.matrix.B27.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B27.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B27.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B27.style.backgroundColor="Lime";
}
if(i==26){
document.forms.matrix.B26.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B26.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B26.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B26.style.backgroundColor="Lime";
}
if(i==25){
document.forms.matrix.B25.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B25.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B25.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B25.style.backgroundColor="Lime";
}
if(i==24){
document.forms.matrix.B24.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B24.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B24.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B24.style.backgroundColor="Lime";
}
if(i==23){
document.forms.matrix.B23.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B23.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B23.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B23.style.backgroundColor="Lime";
}
if(i==22){
document.forms.matrix.B22.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B22.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B22.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B22.style.backgroundColor="Lime";
}
if(i==21){
document.forms.matrix.B21.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B21.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B21.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B21.style.backgroundColor="Lime";
}
if(i==20){
document.forms.matrix.B20.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B20.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B20.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B20.style.backgroundColor="Lime";
}

if(i==19){
document.forms.matrix.B19.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B19.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B19.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B19.style.backgroundColor="Lime";
}

if(i==18){
document.forms.matrix.B18.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B18.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B18.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B18.style.backgroundColor="Lime";
}

if(i==17){
document.forms.matrix.B17.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B17.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B17.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B17.style.backgroundColor="Lime";
}

if(i==16){
document.forms.matrix.B16.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B16.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B16.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B16.style.backgroundColor="Lime";
}

if(i==15){
document.forms.matrix.B15.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B15.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B15.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B15.style.backgroundColor="Lime";
}

if(i==14){
document.forms.matrix.B14.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B14.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B14.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B14.style.backgroundColor="Lime";
}

if(i==13){
document.forms.matrix.B13.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B13.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B13.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B13.style.backgroundColor="Lime";
}

if(i==12){
document.forms.matrix.B12.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B12.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B12.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B12.style.backgroundColor="Lime";
}
if(i==11){
document.forms.matrix.B11.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B11.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B11.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B11.style.backgroundColor="Lime";
}
if(i==10){
document.forms.matrix.B10.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B10.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B10.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B10.style.backgroundColor="Lime";
}
if(i==9){
document.forms.matrix.B9.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B9.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B9.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B9.style.backgroundColor="Lime";
}
if(i==8){
document.forms.matrix.B8.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B8.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B8.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B8.style.backgroundColor="Lime";
}
if(i==7){
document.forms.matrix.B7.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B7.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B7.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B7.style.backgroundColor="Lime";
}
if(i==6){
document.forms.matrix.B6.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B6.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B6.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B6.style.backgroundColor="Lime";
}
if(i==5){
document.forms.matrix.B5.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B5.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B5.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B5.style.backgroundColor="Lime";
}
if(i==4){
document.forms.matrix.B4.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B4.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B4.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B4.style.backgroundColor="Lime";
}
if(i==3){
document.forms.matrix.B3.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B3.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B3.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B3.style.backgroundColor="Lime";
}
if(i==2){
document.forms.matrix.B2.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B2.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B2.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B2.style.backgroundColor="Lime";
}
if(i==1){
document.forms.matrix.B1.style.height=String(ht[i])+"px";
if (p<=0.001){document.forms.matrix.B1.style.backgroundColor="Red";addev();return;}
if (p<=0.05){document.forms.matrix.B1.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B1.style.backgroundColor="Lime";
}
}

function clearbars(){
document.forms.matrix.B0.style.backgroundColor="#FFFFFF";
document.forms.matrix.B1.style.backgroundColor="#FFFFFF";
document.forms.matrix.B2.style.backgroundColor="#FFFFFF";
document.forms.matrix.B3.style.backgroundColor="#FFFFFF";
document.forms.matrix.B4.style.backgroundColor="#FFFFFF";
document.forms.matrix.B5.style.backgroundColor="#FFFFFF";
document.forms.matrix.B6.style.backgroundColor="#FFFFFF";
document.forms.matrix.B7.style.backgroundColor="#FFFFFF";
document.forms.matrix.B8.style.backgroundColor="#FFFFFF";
document.forms.matrix.B9.style.backgroundColor="#FFFFFF";
document.forms.matrix.B10.style.backgroundColor="#FFFFFF";
document.forms.matrix.B11.style.backgroundColor="#FFFFFF";
document.forms.matrix.B12.style.backgroundColor="#FFFFFF";
document.forms.matrix.B13.style.backgroundColor="#FFFFFF";
document.forms.matrix.B14.style.backgroundColor="#FFFFFF";
document.forms.matrix.B15.style.backgroundColor="#FFFFFF";
document.forms.matrix.B16.style.backgroundColor="#FFFFFF";
document.forms.matrix.B17.style.backgroundColor="#FFFFFF";
document.forms.matrix.B18.style.backgroundColor="#FFFFFF";
document.forms.matrix.B19.style.backgroundColor="#FFFFFF";
document.forms.matrix.B20.style.backgroundColor="#FFFFFF";
document.forms.matrix.B21.style.backgroundColor="#FFFFFF";
document.forms.matrix.B22.style.backgroundColor="#FFFFFF";
document.forms.matrix.B23.style.backgroundColor="#FFFFFF";
document.forms.matrix.B24.style.backgroundColor="#FFFFFF";
document.forms.matrix.B25.style.backgroundColor="#FFFFFF";
document.forms.matrix.B26.style.backgroundColor="#FFFFFF";
document.forms.matrix.B27.style.backgroundColor="#FFFFFF";
document.forms.matrix.B28.style.backgroundColor="#FFFFFF";
document.forms.matrix.B29.style.backgroundColor="#FFFFFF";
document.forms.matrix.B30.style.backgroundColor="#FFFFFF";
document.forms.matrix.B31.style.backgroundColor="#FFFFFF";
document.forms.matrix.B32.style.backgroundColor="#FFFFFF";
document.forms.matrix.B33.style.backgroundColor="#FFFFFF";
document.forms.matrix.B34.style.backgroundColor="#FFFFFF";
document.forms.matrix.B35.style.backgroundColor="#FFFFFF";
document.forms.matrix.B36.style.backgroundColor="#FFFFFF";
document.forms.matrix.B37.style.backgroundColor="#FFFFFF";
document.forms.matrix.B38.style.backgroundColor="#FFFFFF";
document.forms.matrix.B39.style.backgroundColor="#FFFFFF";
document.forms.matrix.B40.style.backgroundColor="#FFFFFF";
document.forms.matrix.B41.style.backgroundColor="#FFFFFF";
document.forms.matrix.B42.style.backgroundColor="#FFFFFF";
document.forms.matrix.B43.style.backgroundColor="#FFFFFF";
document.forms.matrix.B44.style.backgroundColor="#FFFFFF";
document.forms.matrix.B45.style.backgroundColor="#FFFFFF";
document.forms.matrix.B46.style.backgroundColor="#FFFFFF";
document.forms.matrix.B47.style.backgroundColor="#FFFFFF";
document.forms.matrix.B48.style.backgroundColor="#FFFFFF";
document.forms.matrix.B49.style.backgroundColor="#FFFFFF";
document.forms.matrix.B50.style.backgroundColor="#FFFFFF";
document.forms.matrix.B51.style.backgroundColor="#FFFFFF";
document.forms.matrix.B52.style.backgroundColor="#FFFFFF";
document.forms.matrix.B53.style.backgroundColor="#FFFFFF";
document.forms.matrix.B54.style.backgroundColor="#FFFFFF";
document.forms.matrix.B55.style.backgroundColor="#FFFFFF";
document.forms.matrix.B56.style.backgroundColor="#FFFFFF";
document.forms.matrix.B57.style.backgroundColor="#FFFFFF";
document.forms.matrix.B58.style.backgroundColor="#FFFFFF";
document.forms.matrix.B59.style.backgroundColor="#FFFFFF";
document.forms.matrix.B60.style.backgroundColor="#FFFFFF";
}

function disptime(){
mydate= new Date();
theyear=mydate.getFullYear();
themonth=mydate.getMonth()+1;
theday=mydate.getDate();
thehour=mydate.getHours();
themin=mydate.getMinutes();
thesec=mydate.getSeconds();
mon$=monname[themonth];
document.forms.matrix.Year.value=mon$+" "+String(theday)+" "+String(theyear);

hr$=String(thehour);
if (thehour<10){hr$="0"+hr$;}

mn$=String(themin);
if (themin<10){mn$="0"+mn$;}

sc$=String(thesec);
if (thesec<10){sc$="0"+sc$;}

document.forms.matrix.Hour.value=hr$+":"+mn$+":"+sc$;
}

function calcchi(){
ChiSqP();
document.forms.matrix.TotTime.value=String(totseg)+" sec (df)";
document.forms.matrix.Chi.value="Chi-Sq. = "+String(chisq.toFixed(4));
document.forms.matrix.Probab.value="p = "+String(pchi.toFixed(7));
}

function ChiSqP() {
   if (totseg >= 50){ChiSqPN();return;}
   else {

      pchi = Math.exp(-chisq/2);

      if ((totseg & 1) > 0)
         pchi *= Math.sqrt((chisq+chisq)/Math.PI );

      kchi = totseg;
      while (kchi >= 2) {
         pchi *= chisq/kchi;
         kchi -= 2;
         }

      tchi=pchi;  achi = totseg;
      while (tchi > (1E-7 * pchi)) {
         achi += 2;
         tchi *= chisq / achi;
         pchi += tchi;
         }
      }
      pchi=1-pchi;
   }


function ChiSqPN() {
schi=totseg-1;
   if (Math.abs(chisq-schi) < 0.1) {
     zchi = (1/3) + (0.08/totseg);
     zchi = -z / Math.sqrt(schi+schi);
      }
   else {
     dchi = chisq - totseg + (2/3) - (0.08/totseg);
     zchi = Math.sqrt((schi * Math.log(schi/chisq)) + chisq - schi);
     zchi = (dchi * zchi) / Math.abs(chisq-schi);
     }
   ndistchi();
   }

function ndistchi(){
a=Math.abs(zchi);
b=1/(1+a*0.2316419);
c=(1/Math.sqrt((2*Math.PI)))*Math.exp(-Math.pow(a,2)/2);
pchi=1-c*(parseFloat(x1a*b+x2*Math.pow(b,2))+parseFloat(x3*Math.pow(b,3))+parseFloat(x4*Math.pow(b,4))+parseFloat(x5*Math.pow(b,5)))
if(chisq>=totseg){pchi=1-pchi;}
}   
   
function dispcomp(){
document.forms.matrix.B0.style.height=String(ht[0])+"px";
if (pchi<=0.001){document.forms.matrix.B0.style.backgroundColor="Red";return;}
if (pchi<=0.05){document.forms.matrix.B0.style.backgroundColor="#FF9900";return;}
document.forms.matrix.B0.style.backgroundColor="Lime";
}


function dispextra(){
calcnorm();
document.forms.matrix.Button13.value="Binary Split:  "+String(hits)+" / "+String(misses);
document.forms.matrix.Button15.value="z = "+String(Math.abs(z.toFixed(5)));
document.forms.matrix.Button17.value="p = "+String(p.toFixed(7));
dispnorm();
}

function addev(){
document.forms.matrix.Text1.value=document.forms.matrix.Text1.value+mon$+" "+String(theday)+" "+String(theyear)+"  "+hr$+":"+mn$+":"+sc$+"   Split: "+String(hits)+"/"+String(misses)+"   z = "+String(Math.abs(z.toFixed(5)))+"   p = "+String(p.toFixed(7))+"\n";
}

function calcnorm(){
normd[hits]++;
calcmax();
for(x=50;x<151;x++){
norm[x]=((normd[x])/maxh)*200;
}
}

function dispnorm(){

for (x=0;x<55;x++){neght=neght+normd[x];}
for (x=145;x<200;x++){posht=posht+normd[x];}

document.forms.matrix.Negext.style.height=String((neght/maxh)*200)+"px";
document.forms.matrix.Posext.style.height=String((posht/maxh)*200)+"px";

if(neght>0){document.forms.matrix.Negext.style.backgroundColor="red";}
if(posht>0){document.forms.matrix.Posext.style.backgroundColor="red";}

document.forms.matrix.NN46.style.height=String(norm[55])+"px";
if(norm[55]>0){document.forms.matrix.NN46.style.backgroundColor="red";}

document.forms.matrix.NN45.style.height=String(norm[56])+"px";
if(norm[56]>0){document.forms.matrix.NN45.style.backgroundColor="red";}

document.forms.matrix.NN44.style.height=String(norm[57])+"px";
if(norm[57]>0){document.forms.matrix.NN44.style.backgroundColor="red";}

document.forms.matrix.NN43.style.height=String(norm[58])+"px";
if(norm[58]>0){document.forms.matrix.NN43.style.backgroundColor="red";}

document.forms.matrix.NN42.style.height=String(norm[59])+"px";
if(norm[59]>0){document.forms.matrix.NN42.style.backgroundColor="red";}

document.forms.matrix.NN41.style.height=String(norm[60])+"px";
if(norm[60]>0){document.forms.matrix.NN41.style.backgroundColor="red";}

document.forms.matrix.NN40.style.height=String(norm[61])+"px";
if(norm[61]>0){document.forms.matrix.NN40.style.backgroundColor="red";}

document.forms.matrix.NN39.style.height=String(norm[62])+"px";
if(norm[62]>0){document.forms.matrix.NN39.style.backgroundColor="red";}

document.forms.matrix.NN38.style.height=String(norm[63])+"px";
if(norm[63]>0){document.forms.matrix.NN38.style.backgroundColor="red";}

document.forms.matrix.NN37.style.height=String(norm[64])+"px";
if(norm[64]>0){document.forms.matrix.NN37.style.backgroundColor="red";}

document.forms.matrix.NN36.style.height=String(norm[65])+"px";
if(norm[65]>0){document.forms.matrix.NN36.style.backgroundColor="red";}

document.forms.matrix.NN35.style.height=String(norm[66])+"px";
if(norm[66]>0){document.forms.matrix.NN35.style.backgroundColor="red";}

document.forms.matrix.NN34.style.height=String(norm[67])+"px";
if(norm[67]>0){document.forms.matrix.NN34.style.backgroundColor="red";}

document.forms.matrix.NN33.style.height=String(norm[68])+"px";
if(norm[68]>0){document.forms.matrix.NN33.style.backgroundColor="red";}

document.forms.matrix.NN32.style.height=String(norm[69])+"px";
if(norm[69]>0){document.forms.matrix.NN32.style.backgroundColor="red";}

document.forms.matrix.NN31.style.height=String(norm[70])+"px";
if(norm[70]>0){document.forms.matrix.NN31.style.backgroundColor="red";}

document.forms.matrix.NN30.style.height=String(norm[71])+"px";
if(norm[71]>0){document.forms.matrix.NN30.style.backgroundColor="red";}

document.forms.matrix.NN29.style.height=String(norm[72])+"px";
if(norm[72]>0){document.forms.matrix.NN29.style.backgroundColor="red";}

document.forms.matrix.NN28.style.height=String(norm[73])+"px";
if(norm[73]>0){document.forms.matrix.NN28.style.backgroundColor="red";}

document.forms.matrix.NN27.style.height=String(norm[74])+"px";
if(norm[74]>0){document.forms.matrix.NN27.style.backgroundColor="red";}

document.forms.matrix.NN26.style.height=String(norm[75])+"px";
if(norm[75]>0){document.forms.matrix.NN26.style.backgroundColor="red";}

document.forms.matrix.NN25.style.height=String(norm[76])+"px";
if(norm[76]>0){document.forms.matrix.NN25.style.backgroundColor="red";}

document.forms.matrix.NN24.style.height=String(norm[77])+"px";
if(norm[77]>0){document.forms.matrix.NN24.style.backgroundColor="#FF9900";}

document.forms.matrix.NN23.style.height=String(norm[78])+"px";
if(norm[78]>0){document.forms.matrix.NN23.style.backgroundColor="#FF9900";}

document.forms.matrix.NN22.style.height=String(norm[79])+"px";
if(norm[79]>0){document.forms.matrix.NN22.style.backgroundColor="#FF9900";}

document.forms.matrix.NN21.style.height=String(norm[80])+"px";
if(norm[80]>0){document.forms.matrix.NN21.style.backgroundColor="#FF9900";}

document.forms.matrix.NN20.style.height=String(norm[81])+"px";
if(norm[81]>0){document.forms.matrix.NN20.style.backgroundColor="#FF9900";}

document.forms.matrix.NN19.style.height=String(norm[82])+"px";
if(norm[82]>0){document.forms.matrix.NN19.style.backgroundColor="#FF9900";}

document.forms.matrix.NN18.style.height=String(norm[83])+"px";
if(norm[83]>0){document.forms.matrix.NN18.style.backgroundColor="#FF9900";}

document.forms.matrix.NN17.style.height=String(norm[84])+"px";
if(norm[84]>0){document.forms.matrix.NN17.style.backgroundColor="#FF9900";}

document.forms.matrix.NN16.style.height=String(norm[85])+"px";
if(norm[85]>0){document.forms.matrix.NN16.style.backgroundColor="#FF9900";}

document.forms.matrix.NN15.style.height=String(norm[86])+"px";
if(norm[86]>0){document.forms.matrix.NN15.style.backgroundColor="lime";}

document.forms.matrix.NN14.style.height=String(norm[87])+"px";
if(norm[87]>0){document.forms.matrix.NN14.style.backgroundColor="lime";}

document.forms.matrix.NN13.style.height=String(norm[88])+"px";
if(norm[88]>0){document.forms.matrix.NN13.style.backgroundColor="lime";}

document.forms.matrix.NN12.style.height=String(norm[89])+"px";
if(norm[89]>0){document.forms.matrix.NN12.style.backgroundColor="lime";}

document.forms.matrix.NN11.style.height=String(norm[90])+"px";
if(norm[90]>0){document.forms.matrix.NN11.style.backgroundColor="lime";}

document.forms.matrix.NN10.style.height=String(norm[91])+"px";
if(norm[91]>0){document.forms.matrix.NN10.style.backgroundColor="lime";}

document.forms.matrix.NN9.style.height=String(norm[92])+"px";
if(norm[92]>0){document.forms.matrix.NN9.style.backgroundColor="lime";}

document.forms.matrix.NN8.style.height=String(norm[93])+"px";
if(norm[93]>0){document.forms.matrix.NN8.style.backgroundColor="lime";}

document.forms.matrix.NN7.style.height=String(norm[94])+"px";
if(norm[94]>0){document.forms.matrix.NN7.style.backgroundColor="lime";}

document.forms.matrix.NN6.style.height=String(norm[95])+"px";
if(norm[95]>0){document.forms.matrix.NN6.style.backgroundColor="lime";}

document.forms.matrix.NN5.style.height=String(norm[96])+"px";
if(norm[96]>0){document.forms.matrix.NN5.style.backgroundColor="lime";}

document.forms.matrix.NN4.style.height=String(norm[97])+"px";
if(norm[97]>0){document.forms.matrix.NN4.style.backgroundColor="lime";}

document.forms.matrix.NN3.style.height=String(norm[98])+"px";
if(norm[98]>0){document.forms.matrix.NN3.style.backgroundColor="lime";}

document.forms.matrix.NN2.style.height=String(norm[99])+"px";
if(norm[99]>0){document.forms.matrix.NN2.style.backgroundColor="lime";}

document.forms.matrix.NN1.style.height=String(norm[100])+"px";
if(norm[100]>0){document.forms.matrix.NN1.style.backgroundColor="lime";}

document.forms.matrix.NP25.style.height=String(norm[125])+"px";
if(norm[125]>0){document.forms.matrix.NP25.style.backgroundColor="red";}

document.forms.matrix.NP24.style.height=String(norm[124])+"px";
if(norm[124]>0){document.forms.matrix.NP24.style.backgroundColor="red";}

document.forms.matrix.NP23.style.height=String(norm[123])+"px";
if(norm[123]>0){document.forms.matrix.NP23.style.backgroundColor="#FF9900";}

document.forms.matrix.NP22.style.height=String(norm[122])+"px";
if(norm[122]>0){document.forms.matrix.NP22.style.backgroundColor="#FF9900";}

document.forms.matrix.NP21.style.height=String(norm[121])+"px";
if(norm[121]>0){document.forms.matrix.NP21.style.backgroundColor="#FF9900";}

document.forms.matrix.NP20.style.height=String(norm[120])+"px";
if(norm[120]>0){document.forms.matrix.NP20.style.backgroundColor="#FF9900";}

document.forms.matrix.NP19.style.height=String(norm[119])+"px";
if(norm[119]>0){document.forms.matrix.NP19.style.backgroundColor="#FF9900";}

document.forms.matrix.NP18.style.height=String(norm[118])+"px";
if(norm[118]>0){document.forms.matrix.NP18.style.backgroundColor="#FF9900";}

document.forms.matrix.NP17.style.height=String(norm[117])+"px";
if(norm[117]>0){document.forms.matrix.NP17.style.backgroundColor="#FF9900";}

document.forms.matrix.NP16.style.height=String(norm[116])+"px";
if(norm[116]>0){document.forms.matrix.NP16.style.backgroundColor="#FF9900";}

document.forms.matrix.NP15.style.height=String(norm[115])+"px";
if(norm[115]>0){document.forms.matrix.NP15.style.backgroundColor="#FF9900";}

document.forms.matrix.NP14.style.height=String(norm[114])+"px";
if(norm[114]>0){document.forms.matrix.NP14.style.backgroundColor="lime";}

document.forms.matrix.NP13.style.height=String(norm[113])+"px";
if(norm[113]>0){document.forms.matrix.NP13.style.backgroundColor="lime";}

document.forms.matrix.NP12.style.height=String(norm[112])+"px";
if(norm[112]>0){document.forms.matrix.NP12.style.backgroundColor="lime";}

document.forms.matrix.NP11.style.height=String(norm[111])+"px";
if(norm[111]>0){document.forms.matrix.NP11.style.backgroundColor="lime";}

document.forms.matrix.NP10.style.height=String(norm[110])+"px";
if(norm[110]>0){document.forms.matrix.NP10.style.backgroundColor="lime";}

document.forms.matrix.NP9.style.height=String(norm[109])+"px";
if(norm[109]>0){document.forms.matrix.NP9.style.backgroundColor="lime";}

document.forms.matrix.NP8.style.height=String(norm[108])+"px";
if(norm[108]>0){document.forms.matrix.NP8.style.backgroundColor="lime";}

document.forms.matrix.NP7.style.height=String(norm[107])+"px";
if(norm[107]>0){document.forms.matrix.NP7.style.backgroundColor="lime";}

document.forms.matrix.NP6.style.height=String(norm[106])+"px";
if(norm[106]>0){document.forms.matrix.NP6.style.backgroundColor="lime";}

document.forms.matrix.NP5.style.height=String(norm[105])+"px";
if(norm[105]>0){document.forms.matrix.NP5.style.backgroundColor="lime";}

document.forms.matrix.NP4.style.height=String(norm[104])+"px";
if(norm[104]>0){document.forms.matrix.NP4.style.backgroundColor="lime";}

document.forms.matrix.NP3.style.height=String(norm[103])+"px";
if(norm[103]>0){document.forms.matrix.NP3.style.backgroundColor="lime";}

document.forms.matrix.NP2.style.height=String(norm[102])+"px";
if(norm[102]>0){document.forms.matrix.NP2.style.backgroundColor="lime";}

document.forms.matrix.NP1.style.height=String(norm[101])+"px";
if(norm[101]>0){document.forms.matrix.NP1.style.backgroundColor="lime";}


document.forms.matrix.NP26.style.height=String(norm[126])+"px";
if(norm[126]>0){document.forms.matrix.NP26.style.backgroundColor="red";}

document.forms.matrix.NP27.style.height=String(norm[127])+"px";
if(norm[127]>0){document.forms.matrix.NP27.style.backgroundColor="red";}

document.forms.matrix.NP28.style.height=String(norm[128])+"px";
if(norm[128]>0){document.forms.matrix.NP28.style.backgroundColor="red";}

document.forms.matrix.NP29.style.height=String(norm[129])+"px";
if(norm[129]>0){document.forms.matrix.NP29.style.backgroundColor="red";}

document.forms.matrix.NP30.style.height=String(norm[130])+"px";
if(norm[130]>0){document.forms.matrix.NP30.style.backgroundColor="red";}

document.forms.matrix.NP31.style.height=String(norm[131])+"px";
if(norm[131]>0){document.forms.matrix.NP31.style.backgroundColor="red";}

document.forms.matrix.NP32.style.height=String(norm[132])+"px";
if(norm[132]>0){document.forms.matrix.NP32.style.backgroundColor="red";}

document.forms.matrix.NP33.style.height=String(norm[133])+"px";
if(norm[133]>0){document.forms.matrix.NP33.style.backgroundColor="red";}

document.forms.matrix.NP34.style.height=String(norm[134])+"px";
if(norm[134]>0){document.forms.matrix.NP34.style.backgroundColor="red";}

document.forms.matrix.NP35.style.height=String(norm[135])+"px";
if(norm[135]>0){document.forms.matrix.NP35.style.backgroundColor="red";}

document.forms.matrix.NP36.style.height=String(norm[136])+"px";
if(norm[136]>0){document.forms.matrix.NP36.style.backgroundColor="red";}

document.forms.matrix.NP37.style.height=String(norm[137])+"px";
if(norm[137]>0){document.forms.matrix.NP37.style.backgroundColor="red";}

document.forms.matrix.NP38.style.height=String(norm[138])+"px";
if(norm[138]>0){document.forms.matrix.NP38.style.backgroundColor="red";}

document.forms.matrix.NP39.style.height=String(norm[139])+"px";
if(norm[139]>0){document.forms.matrix.NP39.style.backgroundColor="red";}

document.forms.matrix.NP40.style.height=String(norm[140])+"px";
if(norm[140]>0){document.forms.matrix.NP40.style.backgroundColor="red";}

document.forms.matrix.NP41.style.height=String(norm[141])+"px";
if(norm[141]>0){document.forms.matrix.NP41.style.backgroundColor="red";}

document.forms.matrix.NP42.style.height=String(norm[142])+"px";
if(norm[142]>0){document.forms.matrix.NP42.style.backgroundColor="red";}

document.forms.matrix.NP43.style.height=String(norm[143])+"px";
if(norm[143]>0){document.forms.matrix.NP43.style.backgroundColor="red";}

document.forms.matrix.NP44.style.height=String(norm[144])+"px";
if(norm[144]>0){document.forms.matrix.NP44.style.backgroundColor="red";}

document.forms.matrix.NP45.style.height=String(norm[145])+"px";
if(norm[145]>0){document.forms.matrix.NP45.style.backgroundColor="red";}

}

function calcmax(){
maxh=1;
for(x=1;x<201;x++){
if((normd[x])>maxh){maxh=normd[x];}
}
document.forms.matrix.Frq.value=String(maxh);
}

function dispfreq(){
freqtxt="Binary Split:               Frequency:\n\n";
for(x=1;x<202;x++){
if(x==101){freqtxt=freqtxt+"   "+String(x-1)+"/"+String(200-x+1)+"                      "+String(normd[x-1])+"\n";
}else{
if((x<11)||(x>191)){
freqtxt=freqtxt+"   "+String(x-1)+"/"+String(200-x+1)+"                        "+String(normd[x-1])+"\n";
}else{freqtxt=freqtxt+"   "+String(x-1)+"/"+String(200-x+1)+"                       "+String(normd[x-1])+"\n";
}
}
}
freqtxt=freqtxt+"\n   Total Secs:                  "+String(totseg-1)+"\n";
document.forms.matrix.Text2.value=freqtxt;
}