var i,arg;
social1 = new String();
social2 = new String();
age = new String();
id = new String();
pw2 = new String();
functions = new Array();
funcnames = new Array();

functions[0] = function(x,y) {return Math.pow(x,2);}
functions[1] = function(x,y) {return Math.pow(x,3);}
functions[2] = function(x,y) {return Math.pow(x,4);}
functions[3] = function(x,y) {return Math.pow(x,5);}
functions[4] = function(x,y) {return Math.pow(x,y);}
functions[5] = function(x,y) {u=Math.pow(x,y); return 4*Math.atan(1);}
functions[6] = function(x,y) {return Math.tan(x);}
functions[7] = function(x,y) {return Math.exp(x);}
functions[8] = function(x,y) {return Math.log(x);}


funcnames[0] = "NAME SQUARED";
funcnames[1] = "NAME CUBED";
funcnames[2] = "NAME TO THE FOURTH";
funcnames[3] = "NAME TO THE FIFTH";
funcnames[4] = "NAME TO THE FAME";
funcnames[5] = "PI";
funcnames[6] = "TAN OF NAME";
funcnames[7] = "e TO THE NAME";
funcnames[8] = "LN OF NAME";

function hello()
{
   window.alert("hello() FUNCTION IN head.js CALLED FROM body.js");
   document.myform.name.value= 2;
   document.myform.fame.value= 3;
}

//play selected sound:
function playsound(){
        //window.alert("PLAYING SOUND "+document.myform.alarmsound.value);
        document.all.sound.src=document.myform.alarmsound.value;
}

//SHOW RESULT OF SELECTION OBJECT:
function doselect(){
        arg = document.myform.selection.value;   //GET FUNCTION NUMBER
        document.myform.convert.value=arg + ": " + funcnames[arg];  //DISPLAY FUNC # AND NAME
        document.myform.output.value=functions[arg](document.myform.name.value,
                                                        document.myform.fame.value); //SHOW FUNC RETURN
}

//COPY OUTPUT TO NAME :
function rename(){
        document.myform.name.value=document.myform.output.value;
}

function multiply(){
        age =  document.myform.name.value;
        id  =  document.myform.fame.value;
        i = age*id;
        //window.alert("MULT = "+i);
        document.myform.output.value = i;
}

function errortalk(msg,url,lineNo)
{
  window.alert("ERROR: "+msg+" AT LINE "+lineNo );
}

onerror=errortalk;