<?xml version="1.0" encoding="UTF-8" ?> 
<Module>
  <ModulePrefs title="quadradic formula"/> 
  <Content type="html">
  <![CDATA[
     <script type="text/javascript">

       // lets see if I can do a quadradic formula
       function decodeMessage (form) {
          var a = form.a.value ? form.a.value : 1;
          var b = form.b.value ? form.b.value : 1;
          var c = form.c.value ? form.c.value : 1;
          var root1 = 0;
          var root2 = 0;
          var sqrt = (b*b)-(4*a*c);

          _gel('content_div').innerHTML = "";
          //_gel('content_div').innerHTML += "<b>sqrt = " + sqrt + "<br>"; 

          if (sqrt >= 0) {
             root1 = (-b+Math.sqrt(sqrt)) / (2*a);
             root2 = (-b-Math.sqrt(sqrt)) / (2*a);
             _gel('content_div').innerHTML += "The roots are: " + root1 + " and " + root2 + "<br>";
             if (a != 1)
                _gel('content_div').innerHTML += a + "x<sup>2</sup> + ";
             else 
                _gel('content_div').innerHTML += "x<sup>2</sup> + ";
             if (b != 1)
                _gel('content_div').innerHTML += b + "x + "; 
             else
                _gel('content_div').innerHTML += " x + ";
             _gel('content_div').innerHTML += c + "</b>";
             _gel('content_div').innerHTML += " = " + "(x + " + -root1 + ")( x + " + -root2 + ")";
          } else {
             root1 = "(" + (-b/(2*a)) + " + " + Math.sqrt(-sqrt)/(2*a) + "i)"; 
             root2 = "(" + (-b/(2*a)) + " - " + Math.sqrt(-sqrt)/(2*a) + "i)";
             _gel('content_div').innerHTML += "The roots are imaginary: <br>" + root1 + "<br>" + root2 + "<br>";
          } 
         
     }
     </script>
     Try to find the roots for any quadradic equation.
     <p>
     <FORM NAME="myform" ACTION="" METHOD="GET">Enter factors: 
     <INPUT TYPE="text" NAME="a" VALUE="" SIZE="1">x<sup>2</sup> + 
     <INPUT TYPE="text" NAME="b" VALUE="" SIZE="1">x + 
     <INPUT TYPE="text" NAME="c" VALUE="" SIZE="1">= 0
     <INPUT TYPE="button" NAME="button" Value="Find roots" onClick="decodeMessage(this.form)">
     </FORM>
     <div id="content_div"></div>
  ]]>
  </Content>
</Module>
