function in_array(a,b){
variablelength = b.length;
ii=0;

while(ii<variablelength){
		
	if (a == b[ii]){
	return '1';
	}
ii++
}
return '0';
}

//////////////////////////////////
// Begin Drawing Function
//////////////////////////////////
function create_border(){
b_ctx = canvas.getContext('2d');
b_ctx.lineWidth = 2;
b_ctx.beginPath();
b_ctx.moveTo(0,0);

b_ctx.lineTo(0,height);
b_ctx.lineTo(width,height);
b_ctx.lineTo(width,0);
b_ctx.lineTo(0,0);
b_ctx.stroke();
}

function create_axis(){
a_ctx = canvas.getContext('2d');
a_ctx.lineWidth = .5;
a_ctx.beginPath();
a_ctx.moveTo(width/2,height/2);a_ctx.lineTo(0,height/2);
a_ctx.moveTo(width/2,height/2);a_ctx.lineTo(width,height/2);
a_ctx.moveTo(width/2,height/2);a_ctx.lineTo(width/2,0);
a_ctx.moveTo(width/2,height/2);a_ctx.lineTo(width/2,height);
a_ctx.stroke();
}

function label_axis(){
c_ctx = canvas.getContext('2d');
CanvasTextFunctions.enable(c_ctx);
c_ctx.strokeStyle = "rgba(0,0,1,10)";
//the negitives throw it off
//negitive fix... convert to normal numbers
//subtract 5 from x coordinate to compensate for start location

//c_ctx.drawText(1, 10, 5, 110, '9'); // x value -1
//c_ctx.drawText(1, 10, 15, 110, '8'); // x value -2
//c_ctx.drawText(1, 10, 25, 110, '7'); // x value -3
//c_ctx.drawText(1, 10, 35, 110, '6'); // x value -4
//c_ctx.drawText(1, 10, 45, 110, '5'); // x value -5
//c_ctx.drawText(1, 10, 55, 110, '4'); // x value -6
//c_ctx.drawText(1, 10, 65, 110, '3'); // x value -7
//c_ctx.drawText(1, 10, 75, 110, '2'); // x value -8
//c_ctx.drawText(1, 10, 85, 110, '1'); // x value -9

//c_ctx.drawText(1, 10, 105, 110, '1'); // x value 1
//c_ctx.drawText(1, 10, 115, 110, '2'); // x value 2
//c_ctx.drawText(1, 10, 125, 110, '3'); // x value 3
//c_ctx.drawText(1, 10, 135, 110, '4'); // x value 4
//c_ctx.drawText(1, 10, 145, 110, '5'); // x value 5
//c_ctx.drawText(1, 10, 155, 110, '6'); // x value 6
//c_ctx.drawText(1, 10, 165, 110, '7'); // x value 7
//c_ctx.drawText(1, 10, 175, 110, '8'); // x value 8
//c_ctx.drawText(1, 10, 185, 110, '9'); // x value 9
}
//********************************
// End Drawing Functions
//********************************


//////////////////////////////////
// Begin Degree/Radian fix
//////////////////////////////////

function degree(){

degreev=1;/*
document.eq.options[0].checked='true';
document.eq.options[1].checked='false';*/
solve();
}

function radian(){

degreev=0;/*
document.eq.options[0].checked='false';
document.eq.options[1].checked='true';*/
solve();
}

//********************************
// End Degree/Radian fix
//********************************

//////////////////////////////////
// Begin math functions
//////////////////////////////////

function gcd(a,b){  //gcf and gcd are same thing
m=1;
if(a>b){a=a+b; b=a-b; a=a-b;}
if((b==(Math.round(b/a))*a)){m=a}
else{
for(i = Math.round(a/2); i>1; i=i-1){
if((a==(Math.round(a/i))*i))
if((b==(Math.round(b/i))*i)){m=i; i=-1;}
}}
return m;
}

function gcf(a,b){  //gcf and gcd are same thing
m=1;
if(a>b){a=a+b; b=a-b; a=a-b;}
if((b==(Math.round(b/a))*a)){m=a}
else{
for(i = Math.round(a/2); i>1; i=i-1){
if((a==(Math.round(a/i))*i))
if((b==(Math.round(b/i))*i)){m=i; i=-1;}
}}
return m;
}

function lcm(a,b){
return a*b/(gcd(a,b))
}

function max(a,b){
return Math.max(a,b)
}

function min(a,b){
return Math.min(a,b)
}

function abs(a){
return Math.abs(a)
}

function ln(a){
return Math.log(a)
}

function log(a){
return Math.log(a) / Math.log(10)
}

function sqrt(a){
return Math.sqrt(a)
}

function cos(a){
if(document.eq.options[0].checked==true){
return Math.cos(a*Math.PI/180)
}
else{
return Math.cos(a)
}
}

function sec(a){
if(document.eq.options[0].checked==true){
return 1/Math.cos(a*Math.PI/180)
}
else{
return 1/Math.cos(a)
}
}

function acos(a){
if(document.eq.options[0].checked==true){
return Math.acos(a)/Math.PI*180
}
else{
return Math.acos(a)
}
}

function sin(a){
//document.eq.fineness.value=95;
if(document.eq.options[0].checked==true){
return Math.sin(a*Math.PI/180)
}
else{
return Math.sin(a)
}
}

function csc(a){
if(document.eq.options[0].checked==true){
return 1/Math.sin(a*Math.PI/180)
}
else{
return 1/Math.sin(a)
}
}

function asin(a){
if(document.eq.options[0].checked==true){
return Math.asin(a)/Math.PI*180
}
else{
return Math.asin(a)
}
}

function tan(a){
//document.eq.fineness.value=200;
if(document.eq.options[0].checked==true){
return Math.tan(a*Math.PI/180)
}
else{
return Math.tan(a)
}
}

function cot(a){
if(document.eq.options[0].checked==true){
return 1/Math.tan(a*Math.PI/180)
}
else{
return 1/Math.tan(a)
}
}

function atan(a){
if(document.eq.options[0].checked==true){
return Math.atan(a)/Math.PI*180
}
else{
return Math.atan(a)
}
}

function ceil(a){
return Math.ceil(a)
}

function floor(a){
return Math.floor(a)
}

function round(a){
return Math.round(a)
}

function random(a){
return Math.random(a)
}

// End math functions