 // JavaScript Document
				
						
	
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&                                                                                  &&
  &&                                                                                  &&
  &&                    2nd level math functions                                      &&
  &&                                                                                  &&
  &&                                                                                  &&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/


//function calculates the reciprocal of a number in the X register by calling
//the prober function based on the type of number
//11 oct 2009 0723
function It_reciprocal()
{
	switch(numberArray[0].type)
	{
		case 'fraction': It_reciprocal_fraction();
		break;
		default: It_reciprocal_decimal();
	}//end switch
}
						
	
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/



function It_reciprocal_decimal()
{
	numberArray[0].decimalValue = 1/numberArray[0].decimalValue;
	operations_2nd_level();
}
						
	
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/


//function calculates the square of a number in the X register by calling
//the prober function based on the type of number
//11 oct 2009 0723
function It_squared()
{
	switch(numberArray[0].type)
	{
		case 'fraction': It_squared_fraction();
		break;
		default: It_squared_decimal();
	}//end switch
}
						
	
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/

  
function It_squared_decimal()
{
	numberArray[0].decimalValue = Math.pow(numberArray[0].decimalValue,2);
	operations_2nd_level();
}
						

/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/


//function calculates the square root of a number in the X register by calling
//the prober function based on the type of number
//11 oct 2009 0723
function It_sqrRoot()
{
	switch(numberArray[0].type)
	{
		case 'fraction': It_sqrRoot_fraction();
		break;
		default: It_sqrRoot_decimal();
	}//end switch
}

/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/

  
function It_sqrRoot_decimal()
{
	numberArray[0].decimalValue = Math.sqrt(numberArray[0].decimalValue);
	operations_2nd_level();
}
						

/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/


//function calculates the the number in the Y register raised to the power
//of the number in the X register
//by calling the prober function based on the type of base and exponent
//11 oct 2009 0723
function It_power()
{
	//analyze_type() is found in combos.js
	var operands_type = analyze_type();
	
	//if is to ensure that exponent is integer otherwise decimal is required
	if(numberArray[0].decimalValue % 1 == 0)
	{
		switch(operands_type)
		{
			case 'fraction': It_power_fraction();
			break;
			default: It_power_decimal();
		}//end switch
	}//end if
	else
	{
		It_power_decimal();	
	}//end else
}//end function
	
	
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/


//function calculates the the number in the Y register raised to the power
//of the number in the X register if type is decimal for either the base or exponent
//11 oct 2009 0723
function It_power_decimal()
{
	numberArray[0].decimalValue = Math.pow(numberArray[1].decimalValue,numberArray[0].decimalValue);
	operations_2nd_level();
	drop();
}
						
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/


//function calculates the the number in the X register raised to the power
//of the number in the Y register
//by calling the prober function based on the type of base and exponent
//11 oct 2009 0723
function It_power_reverse()
{
	//analyze_type() is found in combos.js
	var operands_type = analyze_type();
	
	//if is to ensure that exponent is integer otherwise decimal is required
	if(numberArray[1].decimalValue % 1 == 0)
	{
		switch(operands_type)
		{
			case 'fraction': It_power_reverse_fraction();
			break;
			default: It_power_reverse_decimal();
		}//end switch
	}//end if
	else
	{
		It_power_reverse_decimal();	
	}//end else
}//end function
	
	
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/


//function calculates the the number in the X register raised to the power
//of the number in the Y register if type is decimal for either the base or exponent
//11 oct 2009 0723
function It_power_reverse_decimal()
{
	numberArray[0].decimalValue = Math.pow(numberArray[0].decimalValue,numberArray[1].decimalValue);
	operations_2nd_level();
	drop();
}
						

/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/


//function calculates the the number in the Y register raised to the power
//of the reciprocal of the number in the X register
//by calling the prober function based on the type of base and exponent
//11 oct 2009 0723
function It_shiftPower()
{
	//analyze_type() is found in combos.js
	var operands_type = analyze_type();
	
	//if is to ensure that exponent is integer otherwise decimal is required
	if((1 / numberArray[0].decimalValue) % 1 == 0)
	{
		switch(operands_type)
		{
			case 'fraction': It_shiftPower_fraction();
			break;
			default: It_shiftPower_decimal();
		}//end switch
	}//end if
	else
	{
		It_shiftPower_decimal();	
	}//end else
}//end function
	
	
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/


//function calculates the the number in the Y register raised to the power
//of the reciprocal of the number in the X register if type is decimal for either the base or exponent
//11 oct 2009 0723
function It_shiftPower_decimal()
{
	numberArray[0].decimalValue = Math.pow(numberArray[1].decimalValue,(1/numberArray[0].decimalValue));
	operations_2nd_level();
	drop();
}

/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/

 
//function calculates the the number in the X register raised to the power
//of the reciprocal of the number in the Y register
//by calling the prober function based on the type of base and exponent
//11 oct 2009 0723
function It_shiftPower_reverse()
{
	//analyze_type is found in combos.js
	var operands_type = analyze_type();
	
	//if is to ensure that exponent is integer otherwise decimal is required
	if((1 / numberArray[1].decimalValue) % 1 == 0)
	{
		switch(operands_type)
		{
			case 'fraction': It_shiftPower_reverse_fraction();
			break;
			default: It_shiftPower_reverse_decimal();
		}//end switch
	}//end if
	else
	{
		It_shiftPower_reverse_decimal();	
	}//end else
}//end function
	
	
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/


//function calculates the the number in the X register raised to the power
//of the reciprocal of the number in the Y register if type is decimal for either the base or exponent
//11 oct 2009 0723
function It_shiftPower_reverse_decimal()
{
	numberArray[0].decimalValue = Math.pow(numberArray[0].decimalValue,(1/numberArray[1].decimalValue));
	operations_2nd_level();
	drop();
}
	
	
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
  
  
//displays the decimal value of pi in the x register
function It_pi()
{
	lift();
	numberArray[0].decimalValue = Math.PI;
	operations_2nd_level();
}
						

/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/


//this function allows user to enter a number in scientific notation
function It_exponential()
{

	if(numberArray[0].decimalValue != 0)
	{
		numberArray[0].coefficient = numberArray[0].decimalValue;
		numberArray[0].exponent = '';
		numberArray[0].stringValue = numberArray[0].decimalValue + "e";
		numberArray[0].flag = 'EE';
		document.stackForm.rowX.value = numberArray[0].stringValue;
		document.faceForm.enter.disabled = true;	
	}//end if

}//end function


/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/


function operations_2nd_level()
{
	numberArray[0].stringValue = numberArray[0].decimalValue + '';
	document.stackForm.rowX.value = numberArray[0].stringValue;

	reset_2nd_level_functions();
	
	if(numberArray[0].decimalValue % 1 == 0)
	{
		numberArray[0].type = 'whole';
	}
}


/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/


//function changes sign of X register
function changeSign()
{
	if(numberArray[0].flag == 'EE')
	{
		numberArray[0].exponent = -1 * numberArray[0].exponent; 
		
		numberArray[0].stringValue = numberArray[0].coefficient + 'e' + numberArray[0].exponent;	
		
		numberArray[0].decimalValue = numberArray[0].coefficient * Math.pow(10,numberArray[0].exponent);
		
		document.stackForm.rowX.value = numberArray[0].stringValue;
	}
	else
	{
		numberArray[0].decimalValue = parseFloat(numberArray[0].stringValue);	//converts decimal value back to float
		
		numberArray[0].decimalValue = -1 * numberArray[0].decimalValue;			//changes sign
		
		numberArray[0].stringValue = numberArray[0].decimalValue + '';			//converts string value back to string
		
		document.stackForm.rowX.value = numberArray[0].stringValue;				//display string
	}
	
}////end function
						
						
