//This script is subject to copyright law.
//This script may not be copied or used in any way without permission
//from mhSoft, Amsterdam (The Netherlands).
//
//Copyright 1998 mhSoft
//berechne frequenzkurve closed box
//
function cboxfreq()
	{

	arr=new Array(99);


	if((eval(document.berS.vb.value.length) == 0 ) ||
      (eval(document.berS.qts.value.length) == 0 ) || 
      (eval(document.berS.fs.value.length) == 0 ) || 
      (eval(document.berS.vas.value.length) == 0 ))
       { alert("een van de velden is niet ingevuld...");
 	}
	else

	{
	fvas = eval(document.berS.vas.value);
	fvb = eval(document.berS.vb.value);
	fqts = (eval(document.berS.qts.value));
 	ffs = (eval(document.berS.fs.value));
 	

	start = 10;
	stop = 205; 
 	stap = 5;
	ffb = 0.001;
	fql = 100000;

	a = (ffb / ffs) * (ffb / ffs);
	b = (a / fqts) + (ffb / (fql * ffs));
	c = 1 + a +(ffb / (fql * (ffs * fqts))) + (fvas / fvb)
	d = (1 / fqts) + (ffb / (fql * ffs));


	i = 1;
	for (var zaehler=start/stap; zaehler <=stop/stap; zaehler++) 
	{
		ffs2=ffs;
		w = zaehler*stap / ffs2; 
		u = w * w;
		x = u * u;
		e = x / Math.sqrt((x - c * u + a) * (x - c * u + a) + (b * w - d * u * w) * (b * w - d 		* u *	w));
		e = 20 * Math.log(e)/Math.LN10;
		db = e;
		freq = zaehler*stap;

		//convert num to string
		freq = freq.toString();
		freq = freq.substring(0,5);
		tekst = e;
		tekst = tekst.toString();
		tekst = tekst.substring(0,5);
		e = tekst;

		arr[i]=e;
 
		i = i + 1;
		
		}

		breite = screen.width;
		hoehe  = screen.height;	
		xpos = ((breite - 640)/2);
		ypos = ((hoehe - 320)/2);
			
	Para = 'WIDTH=800,HEIGHT=560,screenX='+xpos+',screenY='+ypos+',status=0,toolbar=0,menubar=0,scrollbars=0,titlebar=0';

		myWin=open('','newWindow',Para);
		myWin.document.open();
		myWin.document.write('<html><head><title>Java - Applet  Frequency Response</title></head>');
		myWin.document.write('<body bgcolor="#000000" text="#ffffff">');

		myWin.document.write('<center>');
  	      myWin.document.write('<applet  code="test.class" width=100% height=100%>');
            
		myWin.document.write('<param name=freq value="'+arr[1]);
		for(i=2; i<arr.length; i++) 
		{
			myWin.document.write(","+arr[i]);
 		}
	     myWin.document.write('">');
		myWin.document.write('</applet>');
		myWin.document.write('<a href=javascript:window.close() style=width:19em; border:solid 1px #f69f0a; display:block; font-family:Verdana, Helvetica, sans-serif; font-size:8pt; color:#ffffff; padding-left:2px; padding-right:2px; padding-top:1px; padding-bottom:1px; text-decoration:none;>Close</a>');
		myWin.document.write('<br><br></center>');
		myWin.document.write('</body>');
		myWin.document.write('</HTML>');
}
}

