<!--Begin

//Copyright © 2004 Global Aircraft

function readState() {
if (document.Calulator.altOne.value == 'exit') {
document.Calulator.xToy.value=">Func";
document.Calulator.screen.value="y=";}
}

var graphImOn=1;
var graphEqs = new Array();

function funcPolar() {
if (document.Calulator.xToy.value == ">Para") {
	graphEqs=[];
	document.Calulator.store.disabled=true;
	document.Calulator.recall.disabled=true;
	document.Calulator.cot.disabled=true;
	document.Calulator.xToy.value=">Polar";
	document.Calulator.screen.value="r=";}
else if (document.Calulator.xToy.value == ">Polar") {
	graphEqs=[];
	document.Calulator.store.value="Select";
	document.Calulator.recall.value="View";
	document.Calulator.store.disabled=false;
	document.Calulator.recall.disabled=false;
	document.Calulator.cot.disabled=false;
	document.Calulator.xToy.value=">Func";
	if (graphEqs[graphImOn] == undefined) {graphEqs[graphImOn] = "y=";}
	document.Calulator.screen.value=graphEqs[graphImOn]+"";
}
else {
	graphEqs=[];
	document.Calulator.store.value="X";
	document.Calulator.recall.value="Y";
	document.Calulator.cot.disabled=true;
	document.Calulator.store.disabled=false;
	document.Calulator.recall.disabled=false;
	document.Calulator.xToy.value=">Para";
	document.Calulator.screen.value="x=";
}
}


function viewEquations() { //Y
if (document.Calulator.xToy.value == ">Para") {
	if (document.Calulator.screen.value.indexOf("y=") < 0) {
		graphEqs[0]=document.Calulator.screen.value+"";
		if (graphEqs[1] == undefined || graphEqs[1] == "y=") {document.Calulator.screen.value="y=";}
		else {document.Calulator.screen.value=graphEqs[1];}
	}
} else {
var stoGraphEqs="";
graphEqs[graphImOn]=document.Calulator.screen.value+"";
for (var yx = 0;yx < graphEqs.length;yx++) {if (graphEqs[yx] == undefined) {continue;}stoGraphEqs += yx+": "+graphEqs[yx]+"\n\r";}
alert(stoGraphEqs);
}}


function selectEquation() { //X
if (document.Calulator.xToy.value == ">Para") {
	if (document.Calulator.screen.value.indexOf("x=") < 0) {
		graphEqs[1]=document.Calulator.screen.value+"";
		if (graphEqs[0] == undefined || graphEqs[0] == "x=") {document.Calulator.screen.value="x=";}
		else {document.Calulator.screen.value=graphEqs[0];}
	}
} else {
var gimmeGraph = window.prompt("Please enter a graph equation to edit (1-10)",eval(graphImOn+1));
if ((isNaN(gimmeGraph)) || gimmeGraph == null || gimmeGraph == '') {gimmeGraph = 1;}else {gimmeGraph=eval(gimmeGraph);}
graphEqs[graphImOn]=document.Calulator.screen.value+"";
if (graphEqs[gimmeGraph] == undefined) {graphEqs[gimmeGraph] = "y=";}
document.Calulator.screen.value=graphEqs[gimmeGraph]+"";
graphImOn=gimmeGraph;}}



function execCross() {
graphEqs[graphImOn]=document.Calulator.screen.value+"";

if (!(confirm("The Cross function is used to determine either an intersection of a graph and an axis or the intersection point of two graphs. Continue?"))) {return false;}

var typeCross = window.prompt("Please choose a cross method:  1=intersection point of two graphs, 2=intersection of a single graph and an axis",1);
if ((isNaN(typeCross)) || typeCross == null || typeCross == '') {typeCross = 1;}else {typeCross=eval(typeCross);}


// TWO GRAPHS
if (typeCross == 1) {

var graph1 = window.prompt("Please enter the number of the first equation",1);
if ((isNaN(graph1)) || graph1 == null || graph1 == '') {graph1 = 1;}else {graph1=eval(graph1);}
///
var graph2 = window.prompt("Please enter the number of the second equation",2);
if ((isNaN(graph2)) || graph2 == null || graph2 == '') {graph2 = 2;}else {graph2=eval(graph2);}
///
var leftbound = window.prompt("Please enter a leftbound x-value (if they cross multiple times, the cross closest to the right of the leftbound will be used)",0);
if ((isNaN(leftbound)) || leftbound == null || leftbound == '') {leftbound = 2;}else {leftbound=eval(leftbound);}

alert("Finding intersection point between graph "+graph1+" ("+graphEqs[graph1]+") and graph "+graph2+" ("+graphEqs[graph2]+").   It may take a few seconds ...");

graph1 = graphEqs[graph1].replace(/y\=/, '');
graph2 = graphEqs[graph2].replace(/y\=/, '');
var eqtn = graph1+"="+graph2;
eqtn=graphFuncToJS(eqtn);

var xCross = doItDoItDoIt(eqtn,"t",leftbound);
var crossBreak = new Array();
crossBreak = xCross.split(': ');
xCross = eval(crossBreak[1]*1);
eqtn2=graphFuncToJS(graph1);
eqtn2 = eqtn2.replace(/x/g, xCross);
var yCross = eval(eqtn2);

yCross = (Math.round(yCross*1000)/1000);

if (isNaN(xCross) || isNaN(yCross)) {alert("I couldn't find the intersection with what you gave me.");}
else {alert("The equations cross at ("+xCross+","+yCross+") radians while "+leftbound+" is leftbound");}


} else {

var graph1 = window.prompt("Please enter the number of the equation",1);
if ((isNaN(graph1)) || graph1 == null || graph1 == '') {graph1 = 1;}else {graph1=eval(graph1);}
///
var typexCross = window.prompt("Please choose a cross method:  1=intersects y-axis, 2=intersects x-axis",1);
if ((isNaN(typexCross)) || typexCross == null || typexCross == '') {typexCross = 1;}else {typexCross=eval(typexCross);}
///

if (typexCross == 1) {
graph1 = graphEqs[graph1].replace(/y\=/, '');
eqtn=graphFuncToJS(graph1);
eqtn = eqtn.replace(/x/g, 0);
var yCross = eval(eqtn);
if (isNaN(yCross)) {alert("I couldn't find the intersection with what you gave me.");}
else {alert("The equation crosses the y-axis at (0,"+yCross+")");}
} else {
var leftbound = window.prompt("Please enter a leftbound x-value (if it crosses multiple times, the cross closest to the right of the leftbound will be used)",0);
if ((isNaN(leftbound)) || leftbound == null || leftbound == '') {leftbound = 2;}else {leftbound=eval(leftbound);}
alert("Finding intersection point between graph "+graph1+" ("+graphEqs[graph1]+") and the x-axis.   It may take a few seconds ...");
graph1 = graphEqs[graph1].replace(/y\=/, '');
eqtn=graphFuncToJS(graph1);
eqtn = "0="+eqtn;

var xCross = doItDoItDoIt(eqtn,"t",leftbound);
var crossBreak = new Array();
crossBreak = xCross.split(': ');
xCross = eval(crossBreak[1]*1);

if (isNaN(xCross)) {alert("I couldn't find the intersection with what you gave me.");}
else {alert("The equation cross the x-axis at ("+xCross+",0) while "+leftbound+" is leftbound");}


}



}}


function resetGraph() {
document.getElementById('graphSTD').width=250;
document.getElementById('graphSTD').height=176;
graphSTD.document.write("<html><head><meta http-equiv='Pragma' Content='no-cache'>");
graphSTD.document.write("<meta http-equiv='Expires' Content='-1'>");
graphSTD.document.write("<link rel='stylesheet' href='http://www.globalaircraft.org/default.css' type='text/css'>");
graphSTD.document.write("<style type='text/css'>BODY{scrollbar-face-color:#666666;scrollbar-arrow-color:#FFFFFF;");
graphSTD.document.write("scrollbar-track-color:#eeeeee;background-repeat:no-repeat;}</style></head>");
graphSTD.document.write("<body scroll='no' style='overflow:hidden;' topmargin='0' leftmargin='0' background='http://www.globalaircraft.org/photos/graphBG.gif' marginheight='0' marginwidth='0' onselectstart='return false;'>");
graphSTD.document.write("&nbsp;</body></html>");
graphSTD.document.close();
}

function iAmGraphIt() {

if (document.Calulator.altOne.value != 'exit') {
graphController.style.display = "block";
resetGraph();
swapup();
document.Calulator.type[0].checked = true;
document.Calulator.type[0].disabled = true;
document.Calulator.type[1].disabled = true;
document.Calulator.secondBtn.disabled=true;
document.Calulator.enterMem.disabled=true;
//document.Calulator.sqrt.disabled=true;
document.Calulator.posneg.value="x";
document.Calulator.posneg.title="Variable X";
document.Calulator.lastAns.disabled=true;
//document.Calulator.cubed.disabled=true;
//document.Calulator.nlog.disabled=true;
document.Calulator.xToy.value=">Polar";
//document.Calulator.log.disabled=true;
//document.Calulator.atan.disabled=true;
//document.Calulator.cot.disabled=true;
document.Calulator.cot.value="Cross";
//document.Calulator.tan.disabled=true;
//document.Calulator.asin.disabled=true;
document.Calulator.csc.disabled=true;
//document.Calulator.sin.disabled=true;
//document.Calulator.acos.disabled=true;
document.Calulator.sec.disabled=true;
//document.Calulator.cos.disabled=true;
//document.Calulator.e.disabled=true;
//document.Calulator.pi.disabled=true;
document.Calulator.lastAns.disabled=true;
//document.Calulator.store.disabled=true;
document.Calulator.store.value="Select";
//document.Calulator.recall.disabled=true;
document.Calulator.recall.value="View";
document.Calulator.equals.value="graph";
document.Calulator.sq.value='^(';
document.Calulator.sq.style.backgroundColor='#AAAAAA';
document.Calulator.sq.title='square';
document.Calulator.altOne.value='exit';
document.Calulator.altTwo.disabled=true;
document.Calulator.altThree.disabled=true;
document.Calulator.altFour.disabled=true;
document.Calulator.altFive.disabled=true;
document.Calulator.altSix.disabled=true;
document.Calulator.altSeven.disabled=true;

if (navigator.appName != "Microsoft Internet Explorer" && navigator.appName != "Opera") {alert("WARNING: The techniques required to draw graphs on your browser are very memory-intensive.  Your browser may stop responding when creating complex graphs.");}

document.Calulator.screen.value="GAC GraphIt v2.0\n\nUse the minus sign for negative numbers.\n\n                Click to continue\n\n\n         Copyright © 2005 Global Aircraft";
//var ready=setTimeout("readState()",30000);
}
else if (document.Calulator.altOne.value == 'exit') {
graphController.style.display = "none";
graphOpts.style.display = "none";
document.getElementById('graphSTD').width=0;
document.getElementById('graphSTD').height=0;
document.getElementById('graphSTD').src='';
document.Calulator.type[0].disabled = false;
document.Calulator.type[1].disabled = false;
document.Calulator.type[1].checked = true;
document.Calulator.secondBtn.disabled=false;
document.Calulator.enterMem.disabled=false;
document.Calulator.sqrt.disabled=false;
document.Calulator.clear.disabled=false;
document.Calulator.lastAns.disabled=false;
document.Calulator.cubed.disabled=false;
document.Calulator.nlog.disabled=false;
document.Calulator.xToy.value="x^y";
document.Calulator.log.disabled=false;
document.Calulator.atan.disabled=false;
document.Calulator.cot.disabled=false;
document.Calulator.cot.value="cot";
document.Calulator.tan.disabled=false;
document.Calulator.asin.disabled=false;
document.Calulator.csc.disabled=false;
document.Calulator.sin.disabled=false;
document.Calulator.acos.disabled=false;
document.Calulator.sec.disabled=false;
document.Calulator.cos.disabled=false;
document.Calulator.e.disabled=false;
document.Calulator.pi.disabled=false;
document.Calulator.lastAns.disabled=false;
document.Calulator.store.disabled=false;
document.Calulator.store.value="sto";
document.Calulator.recall.disabled=false;
document.Calulator.recall.value="rcl";
document.Calulator.equals.value="solve";
document.Calulator.posneg.value="+/-";
document.Calulator.posneg.title="positive / negative";
document.Calulator.sq.value='x^2';
document.Calulator.sq.style.backgroundColor='#AAAAAA';
document.Calulator.sq.title='square';
document.Calulator.altOne.value='1';
document.Calulator.altTwo.disabled=false;
document.Calulator.altThree.disabled=false;
document.Calulator.altFour.disabled=false;
document.Calulator.altFive.disabled=false;
document.Calulator.altSix.disabled=false;
document.Calulator.altSeven.disabled=false;
document.Calulator.screen.value="0";
enterPrgms();
iWorkNow();
}
else {}


}



function graphFunc(equation,magni,magni2) {
var magni;
document.getElementById('graphSTD').src='';

// WE ASK THE USER 6 QUESTIONS //

if (isNaN(magni)) {var magni = document.Calulator.graphXMag.value;
magni=eval(magni);
if ((isNaN(magni)) || magni == null || magni == '' || magni == 0) {magni = 1;}}
if (isNaN(magni2)) {var magni2 = document.Calulator.graphYMag.value;
magni2=eval(magni2);
if ((isNaN(magni2)) || magni2 == null || magni2 == '' || magni2 == 0) {magni2 = 1;}}

if (equation == null || equation == 'undefined' || equation == '') {var thisIsIt = document.Calulator.screen.value.substring(2, document.Calulator.screen.value.length);
var typeOf = document.Calulator.screen.value.substring(0, 1);
	if (graphEqs[0]) {var xxxxxxxy=graphEqs[0];if (xxxxxxxy.indexOf("x=") > -1) {typeOf="x";}}
}
else {var thisIsIt = equation;var typeOf="y";}


precise = document.Calulator.graphQuality.value;
if ((isNaN(precise)) || precise == null || precise == '') {precise = 0;}

var thisColor = document.Calulator.graphColor.value;
if (thisColor == null || thisColor == '') {thisColor = "black";}

//document.Calulator.eq.value=thisIsIt;  -- <input type="hidden" name="eq" value="">



if (typeOf == "r") {
var intTop = document.Calulator.graphPiRange.value;
if ((isNaN(intTop)) || intTop == null || intTop == '') {intTop = 400;}
else {intTop=eval(intTop*(180));}}
////////////////// OR ////////////////////
if (typeOf == "y" || typeOf == "x") {
var modGraph = document.Calulator.graphMod.value;
if ((isNaN(modGraph)) || modGraph == null || modGraph == '') {modGraph = 1;}else {modGraph=eval(modGraph);}}

//var graphName = window.prompt("Please enter a window name to map this graph to","Graph1");
//var config = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,scroll=no,width=250,height=176";
//xxxx = window.open ("",graphName,config);
//var output = xxxx.document;

var output = graphSTD;
output.document.write("<html><head><meta http-equiv='Pragma' Content='no-cache'>");
output.document.write("<meta http-equiv='Expires' Content='-1'>");
output.document.write("<link rel='stylesheet' href='http://www.globalaircraft.org/default.css' type='text/css'>");
output.document.write("<style type='text/css'>BODY{scrollbar-face-color:#666666;scrollbar-arrow-color:#FFFFFF;");
output.document.write("scrollbar-track-color:#eeeeee;background-repeat:no-repeat;}</style></head>");
output.document.write("<body scroll='no' style='overflow:hidden;' topmargin='0' leftmargin='0' background='http://www.globalaircraft.org/photos/graphBG.gif' marginheight='0' marginwidth='0' onselectstart='return false;'>");
output.document.write("<!--<img src='http://www.globalaircraft.org/photos/blank.gif' name='blankOver' id='blankOver' width='100%' height='100%' style='position:absolute;left:0;top:0;'>-->");
//onclick=\"alert('y="+thisIsIt+" on window "+graphName+"')\" 

/* Two techniques are implemented below: one for Mozilla (Netscape) and the other for all other browsers.  It seems that Mozilla has a problem with 
memory stack management and will severely slow down when graphing anything complex (like sin, cos, tan).  MSIE and Opera seem to keep up 
just fine, so they get the full version.  Mozilla/Netscape will get a connect-the-dots version of the graph using a JS Graphics module.  MSIE can't 
use this method because the graphs 'drip' occasionally, so we need a separate method for MSIE. The results between the two methods vary, 
especially with graphing tangent! Also, the coordinates aren't implemented with the Mozilla version.  Ton pis! */

if (navigator.appName != "Microsoft Internet Explorer" && navigator.appName != "Opera" && (typeOf == "y" || typeOf == "x")) {
output.document.write("<script language='JavaScript' src='http://www.globalaircraft.org/wz_jsgraphics.js'></script>");
output.document.write("<div style='position:relative;width:250px;height:176px;'><table cellpadding='0' cellspacing='0'><tr><td>");
output.document.write("<script>var jg = new jsGraphics();jg.setStroke(1);jg.setColor('"+thisColor+"');");}

var dontUseCPU=1;

thisIsIt = thisIsIt.replace(/([0-9])x/g, "$1*x");
thisIsIt = thisIsIt.replace(/x([0-9])/g, "x*$1");

if (typeOf == "x") {
var raise=1;

if (document.Calulator.screen.value.indexOf("y=") > -1) {graphEqs[1]=document.Calulator.screen.value+"";}
if (document.Calulator.screen.value.indexOf("x=") > -1) {graphEqs[0]=document.Calulator.screen.value+"";}

var xEQ = graphEqs[0]+"";
var yEQ = graphEqs[1]+"";

var xEQ = xEQ.substring(2, xEQ.length);
var yEQ = yEQ.substring(2, yEQ.length);

var xEQ = removeCommas(xEQ);
var xEQ = replaceLetters(xEQ);
////
var yEQ = removeCommas(yEQ);
var yEQ = replaceLetters(yEQ);

yEQ = yEQ.replace(/([0-9])x/g, "$1*x");
yEQ = yEQ.replace(/x([0-9])/g, "x*$1");
////
xEQ = xEQ.replace(/([0-9])x/g, "$1*x");
xEQ = xEQ.replace(/x([0-9])/g, "x*$1");


if (xEQ.indexOf("ASIN(") != -1 || xEQ.indexOf("ACOS(") != -1 || xEQ.indexOf("ATAN(") != -1) {
xEQ = xEQ.replace(/asin/g, "ASIN");
xEQ = xEQ.replace(/acos/g, "ACOS");
xEQ = xEQ.replace(/atan/g, "ATAN");
}
////
if (yEQ.indexOf("ASIN(") != -1 || yEQ.indexOf("ACOS(") != -1 || yEQ.indexOf("ATAN(") != -1) {
yEQ = yEQ.replace(/asin/g, "ASIN");
yEQ = yEQ.replace(/acos/g, "ACOS");
yEQ = yEQ.replace(/atan/g, "ATAN");
}


if (xEQ.indexOf(")^(") != -1) {
xEQ = xEQ.replace(/\(([^\)]*)\)\^\(([^\)]*)\)/gi, "Math.pow($1,$2)");
}
if (yEQ.indexOf(")^(") != -1) {
yEQ = yEQ.replace(/\(([^\)]*)\)\^\(([^\)]*)\)/gi, "Math.pow($1,$2)");
}

if (xEQ.indexOf("^(") != -1) {
xEQ = xEQ.replace(/([0-9\.a-z]*)\^\(([^\)]*)\)/gi, "Math.pow($1,$2)");
}
if (yEQ.indexOf("^(") != -1) {
yEQ = yEQ.replace(/([0-9\.a-z]*)\^\(([^\)]*)\)/gi, "Math.pow($1,$2)");
}

if (xEQ.indexOf("x^3") != -1) {
xEQ = xEQ.replace(/x\^3/g, "x*x*x");
}
if (yEQ.indexOf("x^3") != -1) {
yEQ = yEQ.replace(/x\^3/g, "x*x*x");
}

if (xEQ.indexOf("x^2") != -1) {
xEQ = xEQ.replace(/x\^2/g, "x*x");
}
if (yEQ.indexOf("x^2") != -1) {
yEQ = yEQ.replace(/x\^2/g, "x*x");
}

if (xEQ.indexOf("sin(") != -1 || xEQ.indexOf("cos(") != -1) {
xEQ = xEQ.replace(/x/g, "(x*3*(Math.PI/180))");
xEQ = xEQ.replace(/sin/g, "Math.sin");
xEQ = xEQ.replace(/cos/g, "Math.cos");
}
////
if (yEQ.indexOf("sin(") != -1 || yEQ.indexOf("cos(") != -1) {
yEQ = yEQ.replace(/x/g, "(x*3*(Math.PI/180))");
yEQ = yEQ.replace(/sin/g, "Math.sin");
yEQ = yEQ.replace(/cos/g, "Math.cos");
}

if (xEQ.indexOf("tan(") != -1) {
xEQ = xEQ.replace(/x/g, "(x*3*(Math.PI/180))");
xEQ = xEQ.replace(/tan/g, "Math.tan");
////
}
if (yEQ.indexOf("tan(") != -1) {
yEQ = yEQ.replace(/x/g, "(x*3*(Math.PI/180))");
yEQ = yEQ.replace(/tan/g, "Math.tan");
}

if (xEQ.indexOf("ASIN(") != -1 || xEQ.indexOf("ACOS(") != -1 || xEQ.indexOf("ATAN(") != -1) {
xEQ = xEQ.replace(/x/g, "(x*3*(Math.PI/180))");
xEQ = xEQ.replace(/ASIN/g, "Math.asin");
xEQ = xEQ.replace(/ACOS/g, "Math.acos");
xEQ = xEQ.replace(/ATAN/g, "Math.atan");
}
////
if (yEQ.indexOf("ASIN(") != -1 || yEQ.indexOf("ACOS(") != -1 || yEQ.indexOf("ATAN(") != -1) {
yEQ = yEQ.replace(/x/g, "(x*3*(Math.PI/180))");
yEQ = yEQ.replace(/ASIN/g, "Math.asin");
yEQ = yEQ.replace(/ACOS/g, "Math.acos");
yEQ = yEQ.replace(/ATAN/g, "Math.atan");
}

if (xEQ.indexOf("log(") != -1) {
xEQ = xEQ.replace(/log/g, "Math.log");
xEQ = "("+xEQ+")/(Math.log(10))";
}
if (yEQ.indexOf("log(") != -1) {
yEQ = yEQ.replace(/log/g, "Math.log");
yEQ = "("+yEQ+")/(Math.log(10))";
}

if (xEQ.indexOf("ln(") != -1) {
xEQ = xEQ.replace(/ln/g, "Math.log");
}
if (yEQ.indexOf("ln(") != -1) {
yEQ = yEQ.replace(/ln/g, "Math.log");
}

if (xEQ.indexOf("sqrt(") != -1) {
xEQ = xEQ.replace(/sqrt/g, "Math.sqrt");
}
if (yEQ.indexOf("sqrt(") != -1) {
yEQ = yEQ.replace(/sqrt/g, "Math.sqrt");
}

if (precise > 0) {raise = eval(precise/10);}


if (navigator.appName != "Microsoft Internet Explorer" && navigator.appName != "Opera" && (typeOf == "y" || typeOf == "x")) {var xPos2;var yPos2;if (precise == 0) {raise=6;}else {raise=(precise*1)+3;}}


for (var tPos=0;tPos <= 250;tPos=tPos+raise) {

var equation2=yEQ;
equation2 = equation2.replace(/x/g, "("+tPos+")");
equation2 = eval(equation2);
if (modGraph) {var yPos=eval(-1.0*((equation2*25*magni2)-88));}
else {var yPos=eval(-1.0*((equation2*magni2)-88));}

var equation3=xEQ;
equation3 = equation3.replace(/x/g, "("+tPos+")");
equation3 = eval(equation3);
if (modGraph) {var xPos=eval((equation3*25*magni)+125);}
else {var xPos=eval((equation3*magni)+125);}



if (navigator.appName != "Microsoft Internet Explorer" && navigator.appName != "Opera") {
if (xPos2 >=0 && yPos > -500 && yPos2 > -500){output.document.write("jg.drawLine("+xPos+", "+yPos+", "+xPos2+", "+yPos2+");jg.paint();");}
xPos2=xPos;yPos2=yPos;
}
else {
if (yPos >= 0 && yPos <= 176){
output.document.write("<div style='overflow:hidden;position:absolute;background-color:"+thisColor+";left:"+xPos+";top:"+yPos+";width:"+1+";height:"+2+";'></div>");
}
}


}




}


else if (typeOf == "y") {
var raise=1;

// IF YOU UPDATE THIS REMEMBER TO UPDATE THE funcToJS ISLAND!! //

var done2X="x";
var equation3=thisIsIt;
var equation3 = removeCommas(equation3);
var equation3 = replaceLetters(equation3);
var equation4=equation3;

if (equation3.indexOf("x*x*x") != -1) {
if (modGraph) {equation3 = "("+equation3+")/100";}
raise=0.15;} else if (equation3.indexOf("x*x") != -1) {
if (modGraph) {equation3 = "("+equation3+")/10";}
raise=0.2;} else {}

equation3 = equation3.replace(/asin/g, "ASIN");
equation3 = equation3.replace(/acos/g, "ACOS");
equation3 = equation3.replace(/atan/g, "ATAN");
////
equation4 = equation4.replace(/asin/g, "ASIN");
equation4 = equation4.replace(/acos/g, "ACOS");
equation4 = equation4.replace(/atan/g, "ATAN");

if (equation3.indexOf(")^(") != -1) {
equation3 = equation3.replace(/\(([^\)]*)\)\^\(([^\)]*)\)/gi, "Math.pow($1,$2)");
equation4 = equation4.replace(/\(([^\)]*)\)\^\(([^\)]*)\)/gi, "Math.pow($1,$2)");
if (modGraph) {equation3 = "("+equation3+")/10";}raise=0.2;}

if (equation3.indexOf("^(") != -1) {
equation3 = equation3.replace(/([0-9\.a-z]*)\^\(([^\)]*)\)/gi, "Math.pow($1,$2)");
equation4 = equation4.replace(/([0-9\.a-z]*)\^\(([^\)]*)\)/gi, "Math.pow($1,$2)");
if (modGraph) {equation3 = "("+equation3+")/10";}raise=0.2;}

if (equation3.indexOf("x^3") != -1) {
equation3 = equation3.replace(/x\^3/g, "x*x*x");
equation4 = equation4.replace(/x\^3/g, "x*x*x");
if (modGraph) {equation3 = "("+equation3+")/100";}raise=0.15;}

if (equation3.indexOf("x^2") != -1) {
equation3 = equation3.replace(/x\^2/g, "x*x");
equation4 = equation4.replace(/x\^2/g, "x*x");
if (modGraph) {equation3 = "("+equation3+")/10";}raise=0.2;}

if (equation3.indexOf("sin(") != -1 || equation3.indexOf("cos(") != -1) {
equation3 = equation3.replace(/x/g, "(x*3*(Math.PI/180))");
done2X = done2X.replace(/x/g, "(x*3*(Math.PI/180))");
equation3 = equation3.replace(/sin/g, "Math.sin");
equation3 = equation3.replace(/cos/g, "Math.cos");
////
equation4 = equation4.replace(/x/g, "(x*3*(Math.PI/180))");
equation4 = equation4.replace(/sin/g, "Math.sin");
equation4 = equation4.replace(/cos/g, "Math.cos");
if (modGraph) {equation3 = "50*("+equation3+")";}raise=0.3;}

if (equation3.indexOf("tan(") != -1) {
equation3 = equation3.replace(/x/g, "(x*3*(Math.PI/180))");
done2X = done2X.replace(/x/g, "(x*3*(Math.PI/180))");
equation3 = equation3.replace(/tan/g, "Math.tan");
////
equation4 = equation4.replace(/x/g, "(x*3*(Math.PI/180))");
equation4 = equation4.replace(/tan/g, "Math.tan");
if (modGraph) {equation3 = "50*("+equation3+")";}raise=0.2;}

if (equation3.indexOf("ASIN(") != -1 || equation3.indexOf("ACOS(") != -1 || equation3.indexOf("ATAN(") != -1) {
equation3 = equation3.replace(/x/g, "(x*3*(Math.PI/180))");
done2X = done2X.replace(/x/g, "(x*3*(Math.PI/180))");
equation3 = equation3.replace(/ASIN/g, "Math.asin");
equation3 = equation3.replace(/ACOS/g, "Math.acos");
equation3 = equation3.replace(/ATAN/g, "Math.atan");
////
equation4 = equation4.replace(/x/g, "(x*3*(Math.PI/180))");
equation4 = equation4.replace(/ASIN/g, "Math.asin");
equation4 = equation4.replace(/ACOS/g, "Math.acos");
equation4 = equation4.replace(/ATAN/g, "Math.atan");
if (modGraph) {equation3 = "10*("+equation3+")";}raise=0.5;}

if (equation3.indexOf("log(") != -1) {
if (modGraph) {equation3 = equation3.replace(/x/g, "(x/15)");done2X = done2X.replace(/x/g, "(x/15)");}
equation3 = equation3.replace(/log/g, "Math.log");
equation4 = equation4.replace(/log/g, "Math.log");
if (modGraph) {equation3 = "15*("+equation3+")/(Math.log(10))";}
else {equation3 = "("+equation3+")/(Math.log(10))";equation4 = "("+equation4+")/(Math.log(10))";}
raise=0.4;}

if (equation3.indexOf("ln(") != -1) {
if (modGraph) {equation3 = equation3.replace(/x/g, "(x/15)");done2X = done2X.replace(/x/g, "(x/15)");}
equation3 = equation3.replace(/ln/g, "Math.log");
equation4 = equation4.replace(/ln/g, "Math.log");
if (modGraph) {equation3 = "15*("+equation3+")";}
else {equation3 = "("+equation3+")";equation4 = "("+equation4+")";}
raise=0.4;}

if (equation3.indexOf("sqrt(") != -1) {
if (modGraph) {equation3 = equation3.replace(/x/g, "(x*5)");done2X = done2X.replace(/x/g, "(x*5)");}
equation3 = equation3.replace(/sqrt/g, "Math.sqrt");
equation4 = equation4.replace(/sqrt/g, "Math.sqrt");raise=0.4;}

if (precise > 0) {raise = eval(precise/10);}


if (navigator.appName != "Microsoft Internet Explorer" && navigator.appName != "Opera" && typeOf == "y") {var xPos2;var yPos2;if (precise == 0) {raise=6;}else {raise=(precise*1)+3;}}


for (var xPos=0;xPos <= 250;xPos=xPos+raise) {

var xPlug = eval((xPos-125)/magni);
var equation2=equation3;
equation2 = equation2.replace(/x/g, "("+xPlug+")");
equation2 = eval(equation2);
var yPos=eval(-1.0*((equation2*magni2)-88));

var equationX=equation4;
equationX = equationX.replace(/x/g, "("+xPlug+")");
equationX = eval(equationX);

var xCoord = eval(done2X.replace(/x/g, "("+xPlug+")"));

if (navigator.appName != "Microsoft Internet Explorer" && navigator.appName != "Opera") {
if (xPos2 >=0 && yPos > -500 && yPos2 > -500){output.document.write("jg.drawLine("+xPos+", "+yPos+", "+xPos2+", "+yPos2+");jg.paint();");}
xPos2=xPos;yPos2=yPos;
}
else {
if (yPos >= 0 && yPos <= 176){
//output.write("<img src='http://www.globalaircraft.org/photos/black.gif' width='1' height='1' style='position:absolute;left:"+xPos+";top:"+yPos+";'>");
output.document.write("<div onclick=\"alert('y="+thisIsIt+"\\n\\r("+(Math.round(xCoord*100)/100)+", "+(Math.round(equationX*100)/100)+")')\"  title='y="+thisIsIt+"\n\r("+(Math.round(xCoord*100)/100)+", "+(Math.round(equationX*100)/100)+")' style='overflow:hidden;position:absolute;background-color:"+thisColor+";left:"+xPos+";top:"+yPos+";width:"+1+";height:"+2+";'></div>");}
}


}




}

else {

var raise=0.5;

var equation3=thisIsIt;
var equation3 = removeCommas(equation3);
var equation3 = replaceLetters(equation3);

equation3 = equation3.replace(/asin/g, "ASIN");
equation3 = equation3.replace(/acos/g, "ACOS");
equation3 = equation3.replace(/atan/g, "ATAN");

if (equation3.indexOf(")^(") != -1) {
equation3 = equation3.replace(/\(([^\)]*)\)\^\(([^\)]*)\)/gi, "Math.pow($1,$2)");
equation3 = "("+equation3+")";}

if (equation3.indexOf("^(") != -1) {
equation3 = equation3.replace(/([0-9\.a-z]*)\^\(([^\)]*)\)/gi, "Math.pow($1,$2)");
equation3 = "("+equation3+")";}

if (equation3.indexOf("x^3") != -1) {
equation3 = equation3.replace(/x\^3/g, "x*x*x");
equation3 = "("+equation3+")";}

if (equation3.indexOf("x^2") != -1) {
equation3 = equation3.replace(/x\^2/g, "x*x");
equation3 = "("+equation3+")";}

if (equation3.indexOf("sin(") != -1 || equation3.indexOf("cos(") != -1 || equation3.indexOf("tan(") != -1) {
equation3 = equation3.replace(/sin/g, "Math.sin");
equation3 = equation3.replace(/cos/g, "Math.cos");
equation3 = equation3.replace(/tan/g, "Math.tan");
equation3 = "("+equation3+")";}

if (equation3.indexOf("ASIN(") != -1 || equation3.indexOf("ACOS(") != -1 || equation3.indexOf("ATAN(") != -1) {
equation3 = equation3.replace(/ASIN/g, "Math.asin");
equation3 = equation3.replace(/ACOS/g, "Math.acos");
equation3 = equation3.replace(/ATAN/g, "Math.atan");
equation3 = "("+equation3+")";}

if (equation3.indexOf("log(") != -1) {
equation3 = equation3.replace(/x/g, "x");
equation3 = equation3.replace(/log/g, "Math.log");
equation3 = "("+equation3+")/(Math.log(10))";}

if (equation3.indexOf("ln(") != -1) {
equation3 = equation3.replace(/x/g, "x");
equation3 = equation3.replace(/ln/g, "Math.log");
equation3 = "("+equation3+")";}

if (equation3.indexOf("sqrt(") != -1) {
equation3 = equation3.replace(/x/g, "x");
equation3 = equation3.replace(/sqrt/g, "Math.sqrt");}

if (precise == 0) {
var min = Math.min(magni,magni2);
var max = Math.max(magni,magni2);
if ((max/3) > 1) {raise=eval(raise/(max/3));}
if (min < 1) {raise=eval(raise/((1-min)*2.5));}
if (raise <= 0.09) {raise=0.1;}if (raise >= 0.6) {raise=0.5;}}

if (precise > 0 || precise < 0) {raise = eval(precise/10);}

if (navigator.appName != "Microsoft Internet Explorer" && navigator.appName != "Opera") {precise=precise*10;}

magni2*=25;
magni*=25;

var intBot = 0;var count=0;
var Match1=0;var Match2 = 0;var Match3=0;var Match4=0;var Match5=0;
var Match6=0;var Match7 = 0;var Match8=0;var Match9=0;var Match10=0;
for (IndpV=intBot;IndpV <= intTop;IndpV=IndpV+raise) {count++;

var equation2=equation3;
equation2 = equation2.replace(/x/g, "("+eval(IndpV*(Math.PI/180))+")");
equation2 = eval(equation2);
var rVal=equation2;

var yPos=eval(-1.0*(((rVal*Math.sin(eval(IndpV*(Math.PI/180))))*magni2)-88));
var x2=eval(((rVal*Math.cos(eval(IndpV*(Math.PI/180))))*magni)+125);

if (count == 1) {var CoordX1 = Math.round((x2*100000)/100000);var CoordY1=Math.round((yPos*100000)/100000);}
else if (count == 2) {var CoordX2 = Math.round((x2*100000)/100000);var CoordY2=Math.round((yPos*100000)/100000);;}
else if (count == 3) {var CoordX3 = Math.round((x2*100000)/100000);var CoordY3=Math.round((yPos*100000)/100000);;}
else if (count == 4) {var CoordX4 = Math.round((x2*100000)/100000);var CoordY4=Math.round((yPos*100000)/100000);;}
else if (count == 5) {var CoordX5 = Math.round((x2*100000)/100000);var CoordY5=Math.round((yPos*100000)/100000);;}
else if (count == 6) {var CoordX6 = Math.round((x2*100000)/100000);var CoordY6=Math.round((yPos*100000)/100000);}
else if (count == 7) {var CoordX7 = Math.round((x2*100000)/100000);var CoordY7=Math.round((yPos*100000)/100000);;}
else if (count == 8) {var CoordX8 = Math.round((x2*100000)/100000);var CoordY8=Math.round((yPos*100000)/100000);;}
else if (count == 9) {var CoordX9 = Math.round((x2*100000)/100000);var CoordY9=Math.round((yPos*100000)/100000);;}
else if (count == 10) {var CoordX10 = Math.round((x2*100000)/100000);var CoordY10=Math.round((yPos*100000)/100000);;}
else {
if (Math.round((x2*100000)/100000) == CoordX10 && Math.round((yPos*100000)/100000) == CoordY10 && Match1 == 1 && Match2 == 1 &&  Match3 == 1 && Match4 == 1 && Match5 == 1 && Match6 == 1 && Match7 == 1 && Match8 == 1 && Match9 == 1) {if (confirm("The graph appears to be repeating itself. Would you like to stop graphing early?")) {break;}else {Match1=0;}}
else if (Math.round((x2*100000)/100000) == CoordX9 && Math.round((yPos*100000)/100000) == CoordY9 && Match1 == 1 && Match2 == 1 &&  Match3 == 1 && Match4 == 1 && Match5 == 1 && Match6 == 1 && Match7 == 1 && Match8 == 1) {Match9=1;}
else if (Math.round((x2*100000)/100000) == CoordX8 && Math.round((yPos*100000)/100000) == CoordY8 && Match1 == 1 && Match2 == 1 &&  Match3 == 1 && Match4 == 1 && Match5 == 1 && Match6 == 1 && Match7 == 1) {Match8=1;}
else if (Math.round((x2*100000)/100000) == CoordX7 && Math.round((yPos*100000)/100000) == CoordY7 && Match1 == 1 && Match2 == 1 &&  Match3 == 1 && Match4 == 1 && Match5 == 1 && Match6 == 1) {Match7=1;}
else if (Math.round((x2*100000)/100000) == CoordX6 && Math.round((yPos*100000)/100000) == CoordY6 && Match1 == 1 && Match2 == 1 &&  Match3 == 1 && Match4 == 1 && Match5 == 1) {Match6=1;}
else if (Math.round((x2*100000)/100000) == CoordX5 && Math.round((yPos*100000)/100000) == CoordY5 && Match1 == 1 && Match2 == 1 &&  Match3 == 1 &&  Match4 == 1) {Match5=1;}
else if (Math.round((x2*100000)/100000) == CoordX4 && Math.round((yPos*100000)/100000) == CoordY4 && Match1 == 1 && Match2 == 1 &&  Match3 == 1) {Match4=1;}
else if (Math.round((x2*100000)/100000) == CoordX3 && Math.round((yPos*100000)/100000) == CoordY3 && Match1 == 1 && Match2 == 1) {Match3=1;}
else if (Math.round((x2*100000)/100000) == CoordX2 && Math.round((yPos*100000)/100000) == CoordY2 && Match1 == 1) {Match2=1;}
else if (Math.round((x2*100000)/100000) == CoordX1 && Math.round((yPos*100000)/100000) == CoordY1) {Match1=1;}
else {Match1=0;}
}

if (yPos >= 0 && yPos <= 176 && x2 >= 0 && x2 <= 250){
//if (dontUseCPU > 10) {break;}alert("("+x2+","+yPos+")");
//output.write("<img src='http://www.globalaircraft.org/photos/black.gif' style='position:absolute;left:"+x2+";top:"+yPos+";'>");
output.document.write("<div style='overflow:hidden;position:absolute;background-color:"+thisColor+";left:"+x2+";top:"+yPos+";width:"+1+";height:"+1+";'></div>");
dontUseCPU++;
}
}

}


if (navigator.appName != "Microsoft Internet Explorer" && navigator.appName != "Opera" && (typeOf == "y" || typeOf == "x")) {output.document.write("</script><\/td><\/tr><\/table><\/div>");}

output.document.write("</body></html>");
alert('Graph Finished -- completed range.');
output.document.close();
}




function graphFuncToJS(eqtn) {
var thisIsIt = eqtn+'';
thisIsIt = thisIsIt.replace(/([0-9])x/g, "$1*x");
thisIsIt = thisIsIt.replace(/x([0-9])/g, "x*$1");
var equation4=thisIsIt;
equation4 = equation4.replace(/asin/g, "ASIN");
equation4 = equation4.replace(/acos/g, "ACOS");
equation4 = equation4.replace(/atan/g, "ATAN");
if (equation4.indexOf(")^(") != -1) {equation4 = equation4.replace(/\(([^\)]*)\)\^\(([^\)]*)\)/gi, "Math.pow($1,$2)");}
if (equation4.indexOf("^(") != -1) {equation4 = equation4.replace(/([0-9\.a-z]*)\^\(([^\)]*)\)/gi, "Math.pow($1,$2)");}
if (equation4.indexOf("x^3") != -1) {equation4 = equation4.replace(/x\^3/g, "x*x*x");}
if (equation4.indexOf("x^2") != -1) {equation4 = equation4.replace(/x\^2/g, "x*x");}
if (equation4.indexOf("sin(") != -1 || equation4.indexOf("cos(") != -1) {
equation4 = equation4.replace(/sin/g, "Math.sin");
equation4 = equation4.replace(/cos/g, "Math.cos");}
if (equation4.indexOf("tan(") != -1) {equation4 = equation4.replace(/tan/g, "Math.tan");}
if (equation4.indexOf("ASIN(") != -1 || equation4.indexOf("ACOS(") != -1 || equation4.indexOf("ATAN(") != -1) {
equation4 = equation4.replace(/ASIN/g, "Math.asin");
equation4 = equation4.replace(/ACOS/g, "Math.acos");
equation4 = equation4.replace(/ATAN/g, "Math.atan");}
if (equation4.indexOf("log(") != -1) {
equation4 = equation4.replace(/log/g, "Math.log");
equation4 = "("+equation4+")/(Math.log(10))";}
if (equation4.indexOf("ln(") != -1) {
equation4 = equation4.replace(/ln/g, "Math.log");
equation4 = "("+equation4+")";}
if (equation4.indexOf("sqrt(") != -1) {equation4 = equation4.replace(/sqrt/g, "Math.sqrt");}
return equation4;}


window.defaultStatus="GlobalAircraft.org";


// END -->
