//
// Copyright C 1998 by 17 Web Place, all rights reserved 
// this may not be used without written permission
//
//window globals
     var aNoteWin
	var dia=1.0;
  	var inc=1.0;
	var height=1.0;
	var tall=1.0;
	var striker=0;
	var len=0.0;
	var err_msg="no msg";
	var company_name="Stanwade Metal Products, Inc.";

function tankcalc (radio_array)
{
        dia = parseFloat (document.tankspec.dia.value);
        height = parseFloat (document.tankspec.height.value);
        tall = parseFloat (document.tankspec.tall.value);
        orientation = "vertical";

        if (isNaN (dia)) 
		{
			dia=1.0;
			tankspec.dia.value=dia;
		}
        if (isNaN (height)) 
		{
			height=1.0;
			tankspec.height.value=height;
		}
        if (isNaN (tall)) 
		{
			tall=1.0;
			tankspec.tall.value=tall;
		}
	len=height;
	for (i = 0; i < radio_array . length; ++ i)
		{
		 if (radio_array [i].checked) orientation=radio_array [i].value;
		}
	if (document.tankspec.striker.checked) striker=1;
	if (document.tankspec.increment.selectedIndex==0) inc=1;
	if (document.tankspec.increment.selectedIndex==1) inc=.5;
	if (document.tankspec.increment.selectedIndex==2) inc=.25;
	if (document.tankspec.increment.selectedIndex==3) inc=.125;
	if (orientation=="vertical") vertical();
	if (orientation=="horizontal") horizontal();
	if (orientation=="rectangular") rectangular();
}

function rectangular()
{
	var ctot=(tall * dia * height)/231.
	var max=Math.round(tall/inc)

     aPopUp= window.open('','Note','toolbar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=500')
     ndoc= aPopUp.document;
     astr ='<HTML><HEAD><BR><TITLE>Tank Calculation results </TITLE>'
     astr +='</HEAD>'
     astr +='<body>'
     astr +='<center><h1>'+company_name+'</h1></center>'
     astr +="<center>For rectangular tank of width "+dia+", length "+
		height+", and height "+tall+"</center>";
     astr +="<br><table border cellpadding=3><tr>"
     astr +="<tr><td>INCHES</td><td>GALLONS</td><td>INCHES</td><td>GALLONS</td><td>INCHES</td><td>GALLONS</td><td>INCHES</td><td>GALLONS</td></tr><tr>"
	for(i=1; i<max+1; i++)
	{
	 tall=(i * inc)
	 cap = Math.round(1000* (tall * dia * height)/231.5)/1000
	 astr +="<td><center>"+tall+"</center></td><td><center>"+cap+"&nbsp&nbsp</center></td>"
         if (i/4 ==Math.round(i/4)) 
		{
		 astr +="</tr><tr>"
		}
	}
	astr +="</tr></table>"
	astr +="<p>&copy;1998 <a href=http://www.17webplace.com>17 Web Place</a> all rights reserved, used here by license"
	astr +="</body></html>"
     ndoc.write(astr)
     ndoc.close()
     self.aNoteWin = aPopUp
}
function vertical()
{
	var rad=dia / 2.0
	var ctot=(Math.PI * (rad*rad) * height)/231.
	var max=Math.round(height/inc)

     aPopUp= window.open('','Note','toolbar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=500')
     ndoc= aPopUp.document;
     astr ='<HTML><HEAD><BR><TITLE>Tank Calculation results </TITLE>'
     astr +='</HEAD>'
     astr +='<body>'
     astr +='<center><h1>'+company_name+'</h1></center>'
     astr +="<center>Vertical tank of diameter "+dia+" and length "+
		height+"</center>";
     astr +="<br><table border><tr>"
     astr +="<tr><td>INCHES</td><td>GALLONS</td><td>INCHES</td><td>GALLONS</td><td>INCHES</td><td>GALLONS</td><td>INCHES</td><td>GALLONS</td></tr><tr>"
	for(i=1; i<max+1; i++)
	{
	 height=(i * inc)
	 cap = Math.round(1000* (Math.PI * (rad*rad) * height)/231)/1000
	 astr +="<td><center>"+height+"</center></td><td><center>"+cap+"&nbsp&nbsp</center></td>"
         if (i/4 ==Math.round(i/4)) 
		{
		 astr +="</tr><tr>"
		}
	}
	astr +="</tr></table>"
	astr +="<p><H6>&copy;1997 <a href=http://www.17webplace.com>17 Web Place</a> all rights reserved, used here by license</H6>"
	astr +="</body></html>"
     ndoc.write(astr)
     ndoc.close()
     self.aNoteWin = aPopUp
}
function horizontal()
{
  var hght=0.0;
  var full=0.0;
  var temp=0.0;
  var air=0.0;
  var rad=dia / 2.0;
  var ctot=(Math.PI * (rad*rad) * height)/231.

  max=Math.round(dia/inc);
     aPopUp= window.open('','Note','toolbar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=500')
     ndoc= aPopUp.document
     astr ='<HTML><HEAD><BR><TITLE>Tank Calculation results </TITLE>'
     astr +='</HEAD>'
     astr +='<body>'
     astr +='<center><h1>'+company_name+'</h1></center>'
     astr +="<center>Horizontal tank of diameter "+dia+" and length "+
		height;
     if (striker==1)
	{
	 astr +=' with striker panels</center>'
	}
     astr +="<br><table border><tr>"
     astr +="<tr><td>INCHES</td><td>GALLONS</td><td>INCHES</td><td>GALLONS</td><td>INCHES</td><td>GALLONS</td><td>INCHES</td><td>GALLONS</td></tr><tr>"
  for(i=1; i<max+1; i++)
	{
	 height=(i * inc);
	 if (striker==1)
		{
                 hght= height + 0.250;
                 full= dia -0.250;
		}
       else hght= height;
	 if (hght < rad)
		{
		cap= len*(((rad*rad)*Math.atan((Math.sqrt(hght*(2*rad-hght)))/(rad-hght)))-
				((rad-hght)*Math.sqrt(hght*(2*rad-hght))))/ 231;
		}
     if (hght == rad) cap= ctot/2.0;
	 if ((hght > rad) && (hght <= dia))
		{
	       air = dia - hght;
	       temp = len*(((rad*rad) * Math.atan((Math.sqrt(air*(2*rad-air)))/(rad-air)))-
				((rad-air)*Math.sqrt(air*(2*rad-air))))/ 231;
	       cap = ctot - temp;
		}
	 if (hght > dia) cap=0.00;
	 if (cap!=0)
		{
		 cap=Math.round(cap*1000)/1000
		 astr +="<td><center>"+height+"</center></td><td><center>"+cap+"&nbsp&nbsp</center></td>"
		}
         if (i/4 ==Math.round(i/4)) 
		{
		 astr +="</tr><tr>"
		}
	}
	astr +="</tr></table>"
	astr +="<p>&copy;1998 <a href=http://www.17webplace.com>17 Web Place</a> all rights reserved, used here by license"
	astr +="</body></html>"
     ndoc.write(astr)
     ndoc.close()
     self.aNoteWin = aPopUp
}
function closeNote(which)
{
     self.aNoteWin.close()
}

