var xmlhttp;
function reset()
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
	var input1 = document.getElementById("value1");
	var input2 = document.getElementById("value2");
	var input3 = document.getElementById("value3");
	input1.value = "";	input2.value = "";	input3.value = "";
	document.getElementById("Answer").value = "";
	document.getElementById("Density").value = "";
	document.getElementById("Weight").value = "";
	input1.focus();
}

function a_reset()
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
	var input1 = document.getElementById("a_value1");
	var input2 = document.getElementById("a_value2");
	var input3 = document.getElementById("a_value3");
	var input4 = document.getElementById("a_value4");
	input1.value = "";	input2.value = "";	input3.value = ""; input4.value = "";
	document.getElementById("a_Answer").value = "";
	input1.focus();
}

function calculate()
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
	var reset = document.getElementById("reset");
	var x1 = document.getElementById("value1").value;
	var x2 = document.getElementById("value2").value;
	var x3 = document.getElementById("value3").value;
	var density = document.getElementById("Density").value;
	var selPicture = document.getElementById("Volume").value;
	x1 = x1 * 1.0; x2 = x2 * 1.0; x3 = x3 * 1.0; 
	var PI = Math.PI;
	var volume = 0.0;
	if (selPicture == "Barrel") { 	volume=1.*PI*x3*(2.*x1*x1+x2*x2)/12.	}
	if (selPicture == "ElipsoidRevolution") { volume=4.0/3.0*PI*x1*x1*x2;	}
	if (selPicture == "ParaboloidRevolution") { 	volume=PI/2.*x1*x1*x2;	}
	if (selPicture == "Paralelipiped") { volume=x1*x2*x3; }
	if (selPicture == "PipesTubes") { volume=1.*PI*x3*(x1*x1-x2*x2);	}
	if (selPicture == "RightPrism") { volume=x1*x2;}
	if (selPicture == "RightPyramid") { volume=1.*x1*x2/3.	}
	if (selPicture == "RightCylinder") { volume=1.*x2*PI*x1*x1;	}
	if (selPicture == "RightCone") { volume=PI/3.*x2*x1*x1;	}
	if (selPicture == "Sphere") { volume=4.0*PI/3.*x1*x1*x1;}
	if (selPicture == "HollowSphere") { volume=4.0/3.0*PI*(x1*x1*x1-x2*x2*x2);	}
	if (selPicture == "SphericalSector") { volume=2.0*PI/3*x1*x1*x2;	}
	if (selPicture == "SphericalSegment") { 	volume=PI/3.0*x2*x2*(3*x1-x2);}
	if (selPicture == "SphericalZone") { volume=PI/6.0*x3*(3.*x1*x1+3.*x2*x2+x3*x3);}
	if (selPicture == "Torus") { 	volume=2.*PI*PI*x1*x2*x2;	}
	if (selPicture == "TruncatedCone") { volume=PI/3.*x3*(x1*x1+x2*x2+x1*x2);	}
	if (selPicture == "TruncatedPyramid") { 	volume=1.*x3/3.*(x1+x2+Math.sqrt(x1*x2));}
	weight = volume * density;
	volume = volume.toFixed(3);	volume = addCommas(volume); 
	weight = weight.toFixed(3);	weight = addCommas(weight); 
	document.getElementById("Answer").value = volume;
	document.getElementById("Weight").value = weight;
	reset.focus();
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function vpreload_image()
 {
     var picture = document.getElementById("Picture");
	picture.src = "images/ajaxLoad.gif";
	}

function vpicture()
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support HTTP Request");
  return;
  }
	var selPicture = document.getElementById("Volume").value;
     var picture = document.getElementById("Picture");
	var input1 = document.getElementById("value1");
	var input2 = document.getElementById("value2");
	var input3 = document.getElementById("value3");
	input1.value = "";	input2.value = "";	input3.value = "";
	document.getElementById("Answer").value = "";
//	picture.onload = vpreload_image();
	if (selPicture == "Barrel") { 
		picture.src = "images/v9.bmp"; picture.alt = "Barrel"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'visible'; input3.style.visibility = 'visible';
		document.getElementById("label1").value = "Diameter D"; document.getElementById("label2").value = "Diameter d"; document.getElementById("label3").value = "Height h";
				}
	if (selPicture == "ElipsoidRevolution") { 
		picture.src = "images/v6.bmp"; picture.alt = "Elipsoid of Revolution"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'visible'; input3.style.visibility = 'hidden';
		document.getElementById("label1").value = "Diameter D"; document.getElementById("label2").value = "Height h"; document.getElementById("label3").value = "";
			}
	if (selPicture == "ParaboloidRevolution") { 
		picture.src = "images/v7.bmp"; picture.alt = "Paraboloid of Revolution"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'visible'; input3.style.visibility = 'hidden';
		document.getElementById("label1").value = "Radius r"; document.getElementById("label2").value = "Height h"; document.getElementById("label3").value = "";
			}
	if (selPicture == "Paralelipiped") { 
		picture.src = "images/v2.bmp"; picture.alt = "Paralelipiped"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'visible'; input3.style.visibility = 'visible';
		document.getElementById("label1").value = "Length a"; document.getElementById("label2").value = "Width b"; document.getElementById("label3").value = "Height c";
			}
	if (selPicture == "PipesTubes") { 
		picture.src = "images/v11.bmp"; picture.alt = "Pipes"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'visible'; input3.style.visibility = 'visible';
		document.getElementById("label1").value = "Radius Ro"; document.getElementById("label2").value = "Radius R1"; document.getElementById("label3").value = "Length L";
			}
	if (selPicture == "RightPrism") { 
		picture.src = "images/v1.bmp"; picture.alt = "Right Prism"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'visible'; input3.style.visibility = 'hidden';
		document.getElementById("label1").value = "Area S1"; document.getElementById("label2").value = "Height h"; document.getElementById("label3").value = "";
			}
	if (selPicture == "RightPyramid") { 
		picture.src = "images/v3.bmp"; picture.alt = "Right Pyramid"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'visible'; input3.style.visibility = 'hidden';
		document.getElementById("label1").value = "Area S1"; document.getElementById("label2").value = "Height h"; document.getElementById("label3").value = "";
			}
	if (selPicture == "RightCylinder") { 
		picture.src = "images/v10.bmp"; picture.alt = "Right Cylinder"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'visible'; input3.style.visibility = 'hidden';
		document.getElementById("label1").value = "Radius r"; document.getElementById("label2").value = "Height h"; document.getElementById("label3").value = "";
			}
	if (selPicture == "RightCone") { 
		picture.src = "images/v12.bmp"; picture.alt = "Right Cone"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'visible'; input3.style.visibility = 'hidden';
		document.getElementById("label1").value = "Radius r"; document.getElementById("label2").value = "Height h"; document.getElementById("label3").value = "";
			}
	if (selPicture == "Sphere") { 
		picture.src = "images/v14.bmp"; picture.alt = "Sphere"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'hidden'; input3.style.visibility = 'hidden';
		document.getElementById("label1").value = "Radius R"; document.getElementById("label2").value = ""; document.getElementById("label3").value = "";
			}
	if (selPicture == "HollowSphere") { 
		picture.src = "images/v15.bmp"; picture.alt = "Sphere - Hollow"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'visible'; input3.style.visibility = 'hidden';
		document.getElementById("label1").value = "Radius R"; document.getElementById("label2").value = "Radius r"; document.getElementById("label3").value = "";
			}
	if (selPicture == "SphericalSector") { 
		picture.src = "images/v18.bmp"; picture.alt = "Spherical Sector"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'visible'; input3.style.visibility = 'hidden';
		document.getElementById("label1").value = "Radius R"; document.getElementById("label2").value = "Height h"; document.getElementById("label3").value = "";
			}
	if (selPicture == "SphericalSegment") { 
		picture.src = "images/v16.bmp"; picture.alt = "Spherical Segment"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'visible'; input3.style.visibility = 'hidden';
		document.getElementById("label1").value = "Radius r"; document.getElementById("label2").value = "Height h"; document.getElementById("label3").value = "";
			}
	if (selPicture == "SphericalZone") { 
		picture.src = "images/v17.bmp"; picture.alt = "Spherical Zone"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'visible'; input3.style.visibility = 'visible';
		document.getElementById("label1").value = "Radius r1"; document.getElementById("label2").value = "Radius r2"; document.getElementById("label3").value = "Height h";
			}
	if (selPicture == "Torus") { 
		picture.src = "images/v8.bmp"; picture.alt = "Torus"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'visible'; input3.style.visibility = 'hidden';
		document.getElementById("label1").value = "Radius R"; document.getElementById("label2").value = "Radius r"; document.getElementById("label3").value = "";
			}
	if (selPicture == "TruncatedCone") { 
		picture.src = "images/v13.bmp"; picture.alt = "Truncated Cone"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'visible'; input3.style.visibility = 'visible';
		document.getElementById("label1").value = "Radius R"; document.getElementById("label2").value = "Radius r"; document.getElementById("label3").value = "Height h";
			}
	if (selPicture == "TruncatedPyramid") { 
		picture.src = "images/v4.bmp"; picture.alt = "Truncated Pyramid"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'visible'; input3.style.visibility = 'visible';
		document.getElementById("label1").value = "Area S1"; document.getElementById("label2").value = "Area S2"; document.getElementById("label3").value = "Height h";
			}
	if (selPicture == "PipesTubes") { 
		picture.src = "images/v11.bmp"; picture.alt = "Tubes"; 
		input1.style.visibility = 'visible';  input2.style.visibility = 'visible'; input3.style.visibility = 'visible';
		document.getElementById("label1").value = "Radius Ro"; document.getElementById("label2").value = "Radius R1"; document.getElementById("label3").value = "Length L";
			}
input1.focus();
}

function apreload_image()
 {
     var picture = document.getElementById("a_Picture");
	picture.src = "images/ajaxLoad.gif";
	}
function a_picture()
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support HTTP Request");
  return;
  }
	var i = 0;
	var selPicture = document.getElementById("Area").value;
     var picture = document.getElementById("a_Picture");
	var a_input1 = document.getElementById("a_value1");
	var a_input2 = document.getElementById("a_value2");
	var a_input3 = document.getElementById("a_value3");
	var a_input4 = document.getElementById("a_value4");
	a_input1.value = "";	a_input2.value = "";	a_input3.value = ""; a_input4.value = "";
//	picture.onload = apreload_image();
	document.getElementById("a_Answer").value = "";
	if (selPicture == "Circle") { 
		picture.src = "images/s10.bmp"; picture.alt = "Circle"; 
		a_input1.style.visibility = 'visible';  a_input2.style.visibility = 'hidden'; a_input3.style.visibility = 'hidden'; a_input4.style.visibility = 'hidden';
		document.getElementById("a_label1").value = "Radius R"; document.getElementById("a_label2").value = ""; document.getElementById("a_label3").value = "";  document.getElementById("a_label4").value = "";
		i = 0;	}
	if (selPicture == "CircularSector") { 
		picture.src = "images/s13.bmp"; picture.alt = "Circular Sector"; 
		a_input1.style.visibility = 'visible';  a_input2.style.visibility = 'visible'; a_input3.style.visibility = 'hidden'; a_input4.style.visibility = 'hidden';
		document.getElementById("a_label1").value = "Radius R"; document.getElementById("a_label2").value = "Length l"; document.getElementById("a_label3").value = "";  document.getElementById("a_label4").value = "";
		i = 1;	}
	if (selPicture == "CircularSegment") { 
		picture.src = "images/s12.bmp"; picture.alt = "Circular Segment"; 
		a_input1.style.visibility = 'visible';  a_input2.style.visibility = 'visible'; a_input3.style.visibility = 'hidden'; a_input4.style.visibility = 'hidden';
		document.getElementById("a_label1").value = "Radius R"; document.getElementById("a_label2").value = "Angle O"; document.getElementById("a_label3").value = "";  document.getElementById("a_label4").value = "";
		i = 2;	}
	if (selPicture == "CircularZone") { 
		picture.src = "images/s11.bmp"; picture.alt = "Circular Zone"; 
		a_input1.style.visibility = 'visible';  a_input2.style.visibility = 'visible'; a_input3.style.visibility = 'visible'; a_input4.style.visibility = 'hidden';
		document.getElementById("a_label1").value = "Radius R"; document.getElementById("a_label2").value = "Radius r"; document.getElementById("a_label3").value = "Angle O";  document.getElementById("a_label4").value = "";
		i = 3;	}
	if (selPicture == "Parallelogram") { 
		picture.src = "images/s7.bmp"; picture.alt = "Parallelogram"; 
		a_input1.style.visibility = 'visible';  a_input2.style.visibility = 'visible'; a_input3.style.visibility = 'hidden'; a_input4.style.visibility = 'hidden';
		document.getElementById("a_label1").value = "Side a"; document.getElementById("a_label2").value = "Height h"; document.getElementById("a_label3").value = "";  document.getElementById("a_label4").value = "";
		i = 4;	}
	if (selPicture == "PolygonRegular") { 
		picture.src = "images/s9.bmp"; picture.alt = "Polygon Regular"; 
		a_input1.style.visibility = 'visible';  a_input2.style.visibility = 'visible'; a_input3.style.visibility = 'hidden'; a_input4.style.visibility = 'hidden';
		document.getElementById("a_label1").value = "No. of sides n"; document.getElementById("a_label2").value = "Side a"; document.getElementById("a_label3").value = "";  document.getElementById("a_label4").value = "";
		i = 5;	}
	if (selPicture == "QuadrilateralGeneral") { 
		picture.src = "images/bmp00002.bmp"; picture.alt = "Quadrilateral General"; 
		a_input1.style.visibility = 'visible';  a_input2.style.visibility = 'visible'; a_input3.style.visibility = 'visible'; a_input4.style.visibility = 'hidden';
		document.getElementById("a_label1").value = "Height h1"; document.getElementById("a_label2").value = "Height h2"; document.getElementById("a_label3").value = "Diagonal D1";  document.getElementById("a_label4").value = "";
		i = 6;	}
	if (selPicture == "Square") { 
		picture.src = "images/s5.bmp"; picture.alt = "Square"; 
		a_input1.style.visibility = 'visible';  a_input2.style.visibility = 'hidden'; a_input3.style.visibility = 'hidden'; a_input4.style.visibility = 'hidden';
		document.getElementById("a_label1").value = "Side l4"; document.getElementById("a_label2").value = ""; document.getElementById("a_label3").value = "";  document.getElementById("a_label4").value = "";
		i = 7;	}
	if (selPicture == "Rectangle") { 
		picture.src = "images/s6.bmp"; picture.alt = "Rectangle"; 
		a_input1.style.visibility = 'visible';  a_input2.style.visibility = 'visible'; a_input3.style.visibility = 'hidden'; a_input4.style.visibility = 'hidden';
		document.getElementById("a_label1").value = "Side a"; document.getElementById("a_label2").value = "Side b"; document.getElementById("a_label3").value = "";  document.getElementById("a_label4").value = "";
		i = 8;	}
	if (selPicture == "Rombus") { 
		picture.src = "images/s8.bmp"; picture.alt = "Rombus"; 
		a_input1.style.visibility = 'visible';  a_input2.style.visibility = 'visible'; a_input3.style.visibility = 'hidden'; a_input4.style.visibility = 'hidden';
		document.getElementById("a_label1").value = "Side a"; document.getElementById("a_label2").value = "Angle A"; document.getElementById("a_label3").value = "";  document.getElementById("a_label4").value = "";
		i = 9;	}
	if (selPicture == "TriangleScalene") { 
		picture.src = "images/s1.bmp"; picture.alt = "Triangle - Scalene"; 
		a_input1.style.visibility = 'visible';  a_input2.style.visibility = 'visible'; a_input3.style.visibility = 'hidden'; a_input4.style.visibility = 'hidden';
		document.getElementById("a_label1").value = "Side a"; document.getElementById("a_label2").value = "Height h1"; document.getElementById("a_label3").value = "";  document.getElementById("a_label4").value = "";
		i = 10;	}
	if (selPicture == "TriangleRight") { 
		picture.src = "images/s2.bmp"; picture.alt = "Triangle - Right"; 
		a_input1.style.visibility = 'visible';  a_input2.style.visibility = 'visible'; a_input3.style.visibility = 'hidden'; a_input4.style.visibility = 'hidden';
		document.getElementById("a_label1").value = "Side b"; document.getElementById("a_label2").value = "Side c"; document.getElementById("a_label3").value = "";  document.getElementById("a_label4").value = "";
		i = 11;	}
	if (selPicture == "TriangleEquilateral") { 
		picture.src = "images/s3.bmp"; picture.alt = "Triangle - Equilateral"; 
		a_input1.style.visibility = 'visible';  a_input2.style.visibility = 'hidden'; a_input3.style.visibility = 'hidden'; a_input4.style.visibility = 'hidden';
		document.getElementById("a_label1").value = "Side l3"; document.getElementById("a_label2").value = ""; document.getElementById("a_label3").value = "";  document.getElementById("a_label4").value = "";
		i = 12;	}

	var options1 = document.getElementById("Options");
	options1.options.length=0;
	switch(i)
	{
	case 0: // circle
		options1.options[0] =new Option('R','option0');
		options1.options[1] =new Option('D','option1');
		options1.options[2] =new Option('l','option2');
		break;
	case 1: // circular sector
		options1.options[0] =new Option('R, l','option0');
		options1.options[1] =new Option('R, O','option1');
		break;
	case 2: // circular segment
		options1.options[0] =new Option('R, O','option0');
		options1.options[1] =new Option('R, l','option1');
		options1.options[2] =new Option('R, d','option2');
		options1.options[3] =new Option('R, h','option3');
		break;
	case 3: //circular zone
		options1.options[0] =new Option('R, r, O','option0');
		options1.options[1] =new Option('D, d, O','option1');
		options1.options[2] =new Option('Rm, g, O','option2');
		break;
	case 4: // parallelogram
		options1.options[0] =new Option('a, h','option0');
		options1.options[1] =new Option('a, b, A','option1');
		options1.options[2] =new Option('D1, D2, O','option2');
		break;
	case 5: // polygon
		options1.options[0] =new Option('n, a','option0');
		options1.options[1] =new Option('n, R','option1');
		options1.options[2] =new Option('n, r','option2');
		break;
	case 6: // quadrilateral 
		options1.options[0] =new Option('h1, h2, D1','option0');
		options1.options[1] =new Option('D1, D2, O','option1');
		options1.options[2] =new Option('a, b, c, d','option2');
		break;
	case 7: // square
		options1.options[0] =new Option('l4','option0');
		options1.options[1] =new Option('D','option1');
		options1.options[2] =new Option('R','option2');
		break;
	case 8:  // rectangle
		options1.options[0] =new Option('a, b','option0');
		options1.options[1] =new Option('D, O','option1');
		break;
	case 9: // rombus
		options1.options[0] =new Option('a, A','option0');
		options1.options[1] =new Option('D1, D2','option1');
		break;
	case 10: //triangle scalene
		options1.options[0] =new Option('a, h1','option0');
		options1.options[1] =new Option('R, A, B, C','option1');
		options1.options[2] =new Option('R, a, b, c','option2');
		options1.options[3] =new Option('r, A, B, C','option3');
		options1.options[4] =new Option('r, a, b, c','option4');
		options1.options[5] =new Option('a, A, B, C','option5');
		options1.options[6] =new Option('a, b, c','option6');
		options1.options[7] =new Option('A, b, c','option7');
		options1.options[8] =new Option('B, c, a','option8');
		options1.options[9] =new Option('C, a, b','option9');
		break;
	case 11: // triangle right
		options1.options[0] =new Option('b, c','option0');
		options1.options[1] =new Option('a, B','option1');
		options1.options[2] =new Option('a, C','option2');
		break;
	case 12: // triangle equilateral
		options1.options[0] =new Option('l3','option0');
		options1.options[1] =new Option('R','option1');
		options1.options[2] =new Option('r','option2');
		options1.options[3] =new Option('a','option3');
		break;
		}
a_input1.focus();
}

function a_options()
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support HTTP Request");
  return;
  }
	var selPicture = document.getElementById("Area").value;
	var selOptions = document.getElementById("Options").value;
	var input1 = document.getElementById("a_value1");
	var input2 = document.getElementById("a_value2");
	var input3 = document.getElementById("a_value3");
	var input4 = document.getElementById("a_value4");
	input1.value = "";	input2.value = "";	input3.value = ""; input4.value = "";	document.getElementById("a_Answer").value = "";
	if (selPicture == "Circle") { 
		if (selOptions == "option0") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Radius R"; 
			input2.style.visibility = 'hidden';  document.getElementById("a_label2").value = ""; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option1") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Diameter D"; 
			input2.style.visibility = 'hidden';  document.getElementById("a_label2").value = ""; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option2") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Length l"; 
			input2.style.visibility = 'hidden';  document.getElementById("a_label2").value = ""; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
			}
	if (selPicture == "CircularSector") { 
		if (selOptions == "option0") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Radius R"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Length l"; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option1") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Radius R"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Angle O"; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
			}
	if (selPicture == "CircularSegment") { 
		if (selOptions == "option0") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Radius R"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Angle O"; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option1") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Radius R"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Length l"; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option2") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Radius R"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Length d"; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option3") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Radius R"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Height h";
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
			}
	if (selPicture == "CircularZone") { 
		if (selOptions == "option0") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Radius R"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Radius r";
			input3.style.visibility = 'visible'; document.getElementById("a_label3").value = "Angle O";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option1") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Diameter D"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Diameter d"; 
			input3.style.visibility = 'visible'; document.getElementById("a_label3").value = "Angle O";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option2") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Radius Rm"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Length g"; 
			input3.style.visibility = 'visible'; document.getElementById("a_label3").value = "Angle O";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
			}
	if (selPicture == "Parallelogram") { 
		if (selOptions == "option0") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Length a"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Height h"; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option1") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Length a"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Length b"; 
			input3.style.visibility = 'visible'; document.getElementById("a_label3").value = "Angle A";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option2") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Diagonal D1"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Diagonal D2"; 
			input3.style.visibility = 'visible'; document.getElementById("a_label3").value = "Angle A";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
			}
	if (selPicture == "PolygonRegular") { 
		if (selOptions == "option0") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "No. of sides n"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Side a"; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option1") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "No. of sides n"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Radius R"; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option2") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "No. of sides n"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Radius r"; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
			}
	if (selPicture == "QuadrilateralGeneral") { 
		if (selOptions == "option0") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Height h1"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Height h2"; 
			input3.style.visibility = 'visible'; document.getElementById("a_label3").value = "Diagonal D1";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option1") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Diagonal D1"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Diagonal D2"; 
			input3.style.visibility = 'visible'; document.getElementById("a_label3").value = "Angle O";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option2") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Side a"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Side b"; 
			input3.style.visibility = 'visible'; document.getElementById("a_label3").value = "Side c";  
			input4.style.visibility = 'visible'; document.getElementById("a_label4").value = "Side d";
				}
			}
	if (selPicture == "Square") { 
		if (selOptions == "option0") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Side l4"; 
			input2.style.visibility = 'hidden';  document.getElementById("a_label2").value = ""; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option1") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Diagonal D"; 
			input2.style.visibility = 'hidden';  document.getElementById("a_label2").value = ""; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option2") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Radius R"; 
			input2.style.visibility = 'hidden';  document.getElementById("a_label2").value = ""; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
			}
	if (selPicture == "Rectangle") { 
		if (selOptions == "option0") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Side a"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Side b"; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option1") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Diagonal D"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Angle O"; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
			}
	if (selPicture == "Rombus") { 
		if (selOptions == "option0") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Side a"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Angle A"; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option1") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Diagonal D1"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Diagonal D2"; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
			}
	if (selPicture == "TriangleScalene") { 
		if (selOptions == "option0") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Side a"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Height h1"; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option1") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Radius R"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Angle A"; 
			input3.style.visibility = 'visible'; document.getElementById("a_label3").value = "Angle B";  
			input4.style.visibility = 'visible'; document.getElementById("a_label4").value = "Angle C";
				}
		if (selOptions == "option2") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Radius R"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Side a"; 
			input3.style.visibility = 'visible'; document.getElementById("a_label3").value = "Side b";  
			input4.style.visibility = 'visible'; document.getElementById("a_label4").value = "Side c";
				}
		if (selOptions == "option3") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Radius r"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Angle A"; 
			input3.style.visibility = 'visible'; document.getElementById("a_label3").value = "Angle B";  
			input4.style.visibility = 'visible'; document.getElementById("a_label4").value = "Angle C";
				}
		if (selOptions == "option4") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Radius r"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Side a"; 
			input3.style.visibility = 'visible'; document.getElementById("a_label3").value = "Side b";  
			input4.style.visibility = 'visible'; document.getElementById("a_label4").value = "Side c";
				}
		if (selOptions == "option5") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Side a"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Angle A"; 
			input3.style.visibility = 'visible'; document.getElementById("a_label3").value = "Angle B";  
			input4.style.visibility = 'visible'; document.getElementById("a_label4").value = "Angle C";
				}
		if (selOptions == "option6") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Side a"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Side b"; 
			input3.style.visibility = 'visible'; document.getElementById("a_label3").value = "Side c";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option7") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Angle A"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Side b"; 
			input3.style.visibility = 'visible'; document.getElementById("a_label3").value = "Side c";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option8") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Angle B"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Side c"; 
			input3.style.visibility = 'visible'; document.getElementById("a_label3").value = "Side a";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option9") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Angle C"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Side a"; 
			input3.style.visibility = 'visible'; document.getElementById("a_label3").value = "Side b";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
			}
	if (selPicture == "TriangleRight") { 
		if (selOptions == "option0") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Side b"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Side c"; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option1") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Side a"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Angle B"; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option2") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Side a"; 
			input2.style.visibility = 'visible';  document.getElementById("a_label2").value = "Angle C"; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
			}
	if (selPicture == "TriangleEquilateral") { 
		if (selOptions == "option0") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Side l3"; 
			input2.style.visibility = 'hidden';  document.getElementById("a_label2").value = ""; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option1") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Radius R"; 
			input2.style.visibility = 'hidden';  document.getElementById("a_label2").value = ""; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option2") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Radius r"; 
			input2.style.visibility = 'hidden';  document.getElementById("a_label2").value = ""; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
		if (selOptions == "option3") { 
			input1.style.visibility = 'visible';  document.getElementById("a_label1").value = "Altitude a"; 
			input2.style.visibility = 'hidden';  document.getElementById("a_label2").value = ""; 
			input3.style.visibility = 'hidden'; document.getElementById("a_label3").value = "";  
			input4.style.visibility = 'hidden'; document.getElementById("a_label4").value = "";
				}
			}
input1.focus();
}

function a_calculate()
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
	var reset = document.getElementById("a_reset");
	var x1 = document.getElementById("a_value1").value;
	var x2 = document.getElementById("a_value2").value;
	var x3 = document.getElementById("a_value3").value;
	var x4 = document.getElementById("a_value4").value;
	var selPicture = document.getElementById("Area").value;
	var selOptions = document.getElementById("Options").value;
	x1 = x1 * 1.0; x2 = x2 * 1.0; x3 = x3 * 1.0;  x4 = x4 * 1.0;  
	var PI = Math.PI;
	var area = 0.0;
	var s =0;
	if (selPicture == "Circle") { 
		if (selOptions == "option0") {    area=Math.PI*x1*x1; 	}
		if (selOptions == "option1") {   area=Math.PI*x1*x1/4.0; }
		if (selOptions == "option2") {   area=x1*x1/Math.PI/4.0;}
			}
	if (selPicture == "CircularSector") { 
		if (selOptions == "option0") { area=x1*x2/2.0; 	}
		if (selOptions == "option1") { area=Math.PI*x1*x1*x2/360.0;	}
			}
	if (selPicture == "CircularSegment") { 
		if (selOptions == "option0") { area=1/2.0*x1*x1*(Math.PI*x2/180.0-Math.sin(Math.PI/180.0*x2)); }
		if (selOptions == "option1") { s=x2/x1;area=1/2.0*x1*x1*(s-Math.sin(s));	}
		if (selOptions == "option2") { area=x1*x1*Math.acos(x2/x1)-x2*Math.sqrt(x1*x1-x2*x2);}
		if (selOptions == "option3") { area=x1*x1*Math.acos((x1-x2)/x1)-(x1-x2)*Math.sqrt(2*x1*x2-x2*x2);}
			}
	if (selPicture == "CircularZone") { 
		if (selOptions == "option0") { area=Math.PI*(x1*x1-x2*x2)*x3/360.0;; 	}
		if (selOptions == "option1") { area=Math.PI*(x1*x1-x2*x2)*x3/360.0/4.0;}
		if (selOptions == "option2") { area=Math.PI*x1*x2*x3/180.0;	}
			}
	if (selPicture == "PolygonRegular") { 
		if (selOptions == "option0") { area=1/4.0*x1*x2*x2/Math.tan(Math.PI/x1); }
		if (selOptions == "option1") { area=1/2.0*x1*x2*x2*Math.sin(2*Math.PI/x1);}
		if (selOptions == "option2") { area=x1*x2*x2*Math.tan(Math.PI/x1);	}
			}
	if (selPicture == "QuadrilateralGeneral") { 
		if (selOptions == "option0") { area=(x1+x2)*x3/2.0; }
		if (selOptions == "option1") { area=x1*x2*Math.sin(Math.PI/180.0*x3)/2.0;	}
		if (selOptions == "option2") { s=(x1+x2+x3+x4)/2.0;area=Math.sqrt((s-x1)*(s-x2)*(s-x3)*(s-x4));}
			}
	if (selPicture == "Square") { 
		if (selOptions == "option0") { area= x1*x1; 	}
		if (selOptions == "option1") { area= x1*x1/2.0;	}
		if (selOptions == "option2") { area= x1*x1*2.0;}
			}
	if (selPicture == "Rectangle") { 
		if (selOptions == "option0") { area=x1*x2; }
		if (selOptions == "option1") { area=x1*x1*Math.sin(Math.PI/180.0*x2)/2.0;}
			}
	if (selPicture == "Rombus") { 
		if (selOptions == "option0") { area=x1*x1*Math.sin(Math.PI/180.0*x2); }
		if (selOptions == "option1") {area=x1*x2/2.0;}
			}
	if (selPicture == "TriangleScalene") { 
		if (selOptions == "option0") { area=x1*x2/2.0;	}
		if (selOptions == "option1") { area=2 * x1 * x1 * Math.sin(Math.PI/180.0*x2)* Math.sin(Math.PI/180.0*x3) * Math.sin(Math.PI/180.0*x4); }
		if (selOptions == "option2") { area = x2*x3*x4/4.0/x1;}
		if (selOptions == "option3") { area= x1*x1/Math.tan(Math.PI/180.0*x2/2.0)/Math.tan(Math.PI/180.0*x3/2.0)/Math.tan(Math.PI/180.0*x4/2.0); }
		if (selOptions == "option4") { s= (x2+x3+x4) / 2.0; area = x1 * s; 	}
		if (selOptions == "option5") { area = x1*x1 * Math.sin(x3*Math.PI/180.0)*Math.sin(x4*Math.PI/180.0)/(2 * Math.sin(x2*Math.PI/180.0)); }
		if (selOptions == "option6") { s= (x1+x2+x3) / 2.0; area=Math.sqrt(s*(s-x1)*(s-x2)*(s-x3)); }
		if (selOptions == "option7") { area = (x2 * x3 * Math.sin(x1*Math.PI/180.0))/2.0 ; }
		if (selOptions == "option8") { area = (x2 * x3 * Math.sin(x1*Math.PI/180.0))/2.0 ; }
		if (selOptions == "option9") { area = (x2 * x3 * Math.sin(x1*Math.PI/180.0))/2.0 ; }
			}
	if (selPicture == "TriangleRight") { 
		if (selOptions == "option0") { area=x1*x2/2.0; }
		if (selOptions == "option1") { area=x1*x1/2.0*Math.sin(Math.PI/180.0*x2)*Math.cos(Math.PI/180.0*x2); }
		if (selOptions == "option2") { area=x1*x1/2.0*Math.sin(Math.PI/180.0*(90.0-x2))*Math.cos(Math.PI/180.0*(90.0-x2));}
			}
	if (selPicture == "TriangleEquilateral") { 
		if (selOptions == "option0") { area=x1*x1/4.0*Math.sqrt(3.0);}
		if (selOptions == "option1") { area=x1*x1*3/4.0*Math.sqrt(3.0);}
		if (selOptions == "option2") { area=x1*x1*3.0*Math.sqrt(3.0);}
		if (selOptions == "option3") { area=x1*x1*3.0*Math.sqrt(3.0);}
			}
	area = area.toFixed(3);	area = addCommas(area); 
	document.getElementById("a_Answer").value = area;
	reset.focus();
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
