// Density Calculator | RTP Logistics
			
    var HIGHLIGHT_CLASS = "highlight";
    var NORMAL_CLASS = "normal";

var fieldName = new Array();
fieldName[0] = "";
fieldName[1] = "nmfc1";
fieldName[2] = "nmfc2";
fieldName[3] = "nmfc3";
fieldName[4] = "nmfc4";
fieldName[5] = "nmfc5";
fieldName[6] = "nmfc6";
fieldName[7] = "nmfc7";
fieldName[8] = "nmfc8";
fieldName[9] = "nmfc9";
fieldName[10] = "nmfc10";
fieldName[11] = "nmfc11";
fieldName[12] = "nmfc12";
fieldName[13] = "nmfc13";
fieldName[14] = "nmfc14";
fieldName[15] = "nmfc15";
fieldName[16] = "nmfc16";
fieldName[17] = "nmfc17";
fieldName[18] = "nmfc18";

//Clears result boxes 
	function ClearBoxes() {
		document.calcform.txtCube.value="";
		document.calcform.txtCubeConvert.value="";
		document.calcform.txtWeight.value="";
		document.calcform.txtWeightConvert.value="";
		document.calcform.txtDensity.value="";
		document.calcform.txtDensityConvert.value="";
		document.calcform.txtClass.value="";	
		mySlide.slideOut()
	}

//Clears result boxes and sets unit value to '1'
	function ClearBoxesNrow1() {
		if (document.calcform.txtPallet1.value==""){
			document.calcform.txtPallet1.value=1;
		}
	}
	
//Clears result boxes and sets unit value to '1'
	function ClearBoxesNrow2() {
		if (document.calcform.txtPallet2.value==""){
			document.calcform.txtPallet2.value=1;
		}
	}
	
//Clears result boxes and sets unit value to '1'
	function ClearBoxesNrow3() {
		if (document.calcform.txtPallet3.value==""){
			document.calcform.txtPallet3.value=1;
		}
	}
	
//Clears result boxes and sets unit value to '1'
	function ClearBoxesNrow4() {
		if (document.calcform.txtPallet4.value==""){
			document.calcform.txtPallet4.value=1;
		}
	}
	
//Clears result boxes and sets unit value to '1'
	function ClearBoxesNrow5() {
		if (document.calcform.txtPallet5.value==""){
			document.calcform.txtPallet5.value=1;
		}
	}

//check all lines
function checkAll() {
	checkRow1();
	checkRow2();
	checkRow3();
	checkRow4();	
	checkRow5();
	CalcDensity();
}

//Check first row for valid input to perform calculation
function checkRow1() {
	var fillCheck = true;

	if (isNaN(document.calcform.txtPallet1.value) || (document.calcform.txtPallet1.value == "")){
		setStyle('txtPallet1', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtPallet1', 'color', '#000')
		}

	if (isNaN(document.calcform.txtLength1.value) || (document.calcform.txtLength1.value == "")){
		setStyle('txtLength1', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtLength1', 'color', '#000')
		}

	if (isNaN(document.calcform.txtWidth1.value) || (document.calcform.txtWidth1.value == "")){
		setStyle('txtWidth1', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtWidth1', 'color', '#000')
		}

	if (isNaN(document.calcform.txtHeight1.value) || (document.calcform.txtHeight1.value == "")){
		setStyle('txtHeight1', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtHeight1', 'color', '#000')
		}

	if (isNaN(document.calcform.txtWeight1.value) || (document.calcform.txtWeight1.value == "")){
		setStyle('txtWeight1', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtWeight1', 'color', '#000')
		}

if (fillCheck){
	CalcDensity();
	return true;
	}
	mySlide.slideOut()
}

//Check second row for valid input to perform calculation
function checkRow2() {
	var fillCheck = true;

	if (isNaN(document.calcform.txtPallet2.value) || (document.calcform.txtPallet2.value == "")){
		setStyle('txtPallet2', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtPallet2', 'color', '#000')
		}

	if (isNaN(document.calcform.txtLength2.value) || (document.calcform.txtLength2.value == "")){
		setStyle('txtLength2', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtLength2', 'color', '#000')
		}

	if (isNaN(document.calcform.txtWidth2.value) || (document.calcform.txtWidth2.value == "")){
		setStyle('txtWidth2', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtWidth2', 'color', '#000')
		}

	if (isNaN(document.calcform.txtHeight2.value) || (document.calcform.txtHeight2.value == "")){
		setStyle('txtHeight2', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtHeight2', 'color', '#000')
		}

	if (isNaN(document.calcform.txtWeight2.value) || (document.calcform.txtWeight2.value == "")){
		setStyle('txtWeight2', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtWeight2', 'color', '#000')
		}

if (fillCheck){
	CalcDensity();
	return true;
	}
}

//Check third row for valid input to perform calculation
function checkRow3() {
	var fillCheck = true;

	if (isNaN(document.calcform.txtPallet3.value) || (document.calcform.txtPallet3.value == "")){
		setStyle('txtPallet3', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtPallet3', 'color', '#000')
		}

	if (isNaN(document.calcform.txtLength3.value) || (document.calcform.txtLength3.value == "")){
		setStyle('txtLength3', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtLength3', 'color', '#000')
		}

	if (isNaN(document.calcform.txtWidth3.value) || (document.calcform.txtWidth3.value == "")){
		setStyle('txtWidth3', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtWidth3', 'color', '#000')
		}

	if (isNaN(document.calcform.txtHeight3.value) || (document.calcform.txtHeight3.value == "")){
		setStyle('txtHeight3', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtHeight3', 'color', '#000')
		}

	if (isNaN(document.calcform.txtWeight3.value) || (document.calcform.txtWeight3.value == "")){
		setStyle('txtWeight3', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtWeight3', 'color', '#000')
		}

if (fillCheck){
	CalcDensity();
	return true;
	}
}

//Check forth row for valid input to perform calculation
function checkRow4() {
	var fillCheck = true;

	if (isNaN(document.calcform.txtPallet4.value) || (document.calcform.txtPallet4.value == "")){
		setStyle('txtPallet4', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtPallet4', 'color', '#000')
		}

	if (isNaN(document.calcform.txtLength4.value) || (document.calcform.txtLength4.value == "")){
		setStyle('txtLength4', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtLength4', 'color', '#000')
		}

	if (isNaN(document.calcform.txtWidth4.value) || (document.calcform.txtWidth4.value == "")){
		setStyle('txtWidth4', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtWidth4', 'color', '#000')
		}

	if (isNaN(document.calcform.txtHeight4.value) || (document.calcform.txtHeight4.value == "")){
		setStyle('txtHeight4', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtHeight4', 'color', '#000')
		}

	if (isNaN(document.calcform.txtWeight4.value) || (document.calcform.txtWeight4.value == "")){
		setStyle('txtWeight4', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtWeight4', 'color', '#000')
		}

if (fillCheck){
	CalcDensity();
	return true;
	}
}
//Check fifth row for valid input to perform calculation
function checkRow5() {
	var fillCheck = true;

	if (isNaN(document.calcform.txtPallet5.value) || (document.calcform.txtPallet5.value == "")){
		setStyle('txtPallet5', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtPallet5', 'color', '#000')
		}

	if (isNaN(document.calcform.txtLength5.value) || (document.calcform.txtLength5.value == "")){
		setStyle('txtLength5', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtLength5', 'color', '#000')
		}

	if (isNaN(document.calcform.txtWidth5.value) || (document.calcform.txtWidth5.value == "")){
		setStyle('txtWidth5', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtWidth5', 'color', '#000')
		}

	if (isNaN(document.calcform.txtHeight5.value) || (document.calcform.txtHeight5.value == "")){
		setStyle('txtHeight5', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtHeight5', 'color', '#000')
		}

	if (isNaN(document.calcform.txtWeight5.value) || (document.calcform.txtWeight5.value == "")){
		setStyle('txtWeight5', 'color', '#FF0000');
		fillCheck=false;
		ClearBoxes();
		}else{
		setStyle('txtWeight5', 'color', '#000')
		}

if (fillCheck){
	CalcDensity();
	return true;
	}
}


	function validVal(length,height,width,weight)
	{
		var result = true;
		if ((length == "")||(height == "")||(width == "")||(weight == ""))
		{
			result = false;
		}	
		if (result)
 		{
 			var result1 = allDigits(length);
 			var result2 = allDigits(height);
 			var result3 = allDigits(width);
 			var result4 = allDigits(weight); 	
 			if (!result1 || !result2 || !result3 || !result4 )
 			{ 			
 				result = false;
			}
		}	
		return result;
	}

	function validInt(length,height,width,weight)
	{
		var result = true;
		if ((length == "")||(height == "")||(width == "")||(weight == ""))
		{
			result = false;
		}	
 		if (result)
 		{
 			var num1 = parseInt(length,10);
 			var num2 = parseInt(height,10);
 			var num3 = parseInt(width,10);
 			var num4 = parseInt(weight,10);
 			if (isNaN(num1)||isNaN(num2)||isNaN(num3)||isNaN(num4))
 			{
 				result = false;
			}
		}		
		return result;
	}

	function allDigits(str)
	{
		return inValidCharSet(str,".0123456789");
	}

	function inValidCharSet(str,charset)
	{
		var result = true;
		for (var i=0;i<str.length;i++)
			if (charset.indexOf(str.substr(i,1))<0)
			{
				result = false;
				break;
			}	
		return result;
	}

	function validRequired(formField)
	{
		var result = true;
		if (formField.value == "")
		{
			//alert('Please enter a value for the "' + fieldLabel +'" field.');
			//formField.focus();
			result = false;
		}	
		return result;
	}
	
	function clearForm() {		
		clearNmfcTable();		
		ClearBoxesNrow1();
		document.calcform.txtLength1.value="";
		document.calcform.txtWidth1.value="";
		document.calcform.txtHeight1.value="";
		document.calcform.txtWeight1.value="";
		document.calcform.txtPallet1.value="";
		ClearBoxesNrow2();
		document.calcform.txtLength2.value="";
		document.calcform.txtWidth2.value="";
		document.calcform.txtHeight2.value="";
		document.calcform.txtWeight2.value="";
		document.calcform.txtPallet2.value="";
		ClearBoxesNrow3();
		document.calcform.txtLength3.value="";
		document.calcform.txtWidth3.value="";
		document.calcform.txtHeight3.value="";
		document.calcform.txtWeight3.value="";
		document.calcform.txtPallet3.value="";
		ClearBoxesNrow4();
		document.calcform.txtLength4.value="";
		document.calcform.txtWidth4.value="";
		document.calcform.txtHeight4.value="";
		document.calcform.txtWeight4.value="";
		document.calcform.txtPallet4.value="";
		ClearBoxesNrow5();
		document.calcform.txtLength5.value="";
		document.calcform.txtWidth5.value="";
		document.calcform.txtHeight5.value="";
		document.calcform.txtWeight5.value="";
		document.calcform.txtPallet5.value="";			
	}
	
	function clearNmfcTable() {
		//Reset Background Color
//		var tmpString;
//		for (var i=1;i<19;i++) {
//			tmpString=i+'';
//			document.getElementById('nmfc'+tmpString).className=NORMAL_CLASS;
//		}
	}

	function GetClassVal(TotalDensity){
		var ClassVal=0;
		var TD = TotalDensity;
		var steps=document.calcform.steps.value;

		clearNmfcTable();
		
		//Check to see if US Measure radio button is checked
		if (document.getElementById('radioMeasure1').checked) {
			//US Measure
			TD=TD;
		} else {
			//Metric Measure
			TD=TD/16.0184634; // 1 lb/cu.ft = 16.0184634 kg/cu.mtr
		}
		
		if(TD<1){
		ClassVal=500;
		step=18;
		}
		if((TD>=1) && (TD<2)){
		ClassVal=400;
		step=17;
		}
		if((TD>=2) && (TD<3)){
		ClassVal=300;
		step=16;
		}
		if((TD>=3) && (TD<4)){
		ClassVal=250;
		step=15;
		}
		if((TD>=4) && (TD<5)){
		ClassVal=200;
		step=14;
		}
		if((TD>=5) && (TD<6)){
		ClassVal=175;
		step=13;
		}
		if((TD>=6) && (TD<7)){
		ClassVal=150;
		step=12;		
		}
		if((TD>=7) && (TD<8)){
		ClassVal=125;
		step=11;
		}
		if((TD>=8) && (TD<9)){
		ClassVal=110;
		step=10;		
		}
		if((TD>=9) && (TD<10.5)){
		ClassVal=100;
		step=9;
		}
		if((TD>=10.5) && (TD<12)){
		ClassVal=92;
		step=8;
		}
		if((TD>=12) && (TD<13.5)){
		ClassVal=85;
		step=7;
		}	
		if((TD>=13.5) && (TD<15)){
		ClassVal=77;
		step=6;
		}	
		if((TD>=15) && (TD<22.5)){
		ClassVal=70;
		step=5;
		}	
		if((TD>=22.5) && (TD<30)){
		ClassVal=65;
		step=4;
		}	
		if((TD>=30) && (TD<35)){
		ClassVal=60;
		step=3;
		}	
		if((TD>=35) && (TD<50)){
		ClassVal=55;
		step=2;
		}
		if(TD>=50){
		ClassVal=50;
		step=1;
		}		
		
		var i=0;
		var x=1;
		if (steps=="" || steps==step){steps=1;}
// 		alert("steps:" + steps + " / Step: " + step + " / x: " + x);
	
	if (steps<=step){
				for (i=steps;i<=step;i++){
					if (i!=steps){
						document.getElementById(fieldName[i-x]).className=NORMAL_CLASS;
					}
						document.getElementById(fieldName[i]).className=HIGHLIGHT_CLASS;	
				}}else{
				for (i=steps;i>=step;i--){
					if (i!=steps){
						document.getElementById(fieldName[i+x]).className=NORMAL_CLASS;
					}
						document.getElementById(fieldName[i]).className=HIGHLIGHT_CLASS;			
					}}
					

		document.calcform.steps.value=step;
		return ClassVal;
	}

	function CalcDensity ()
	{
		var unitMeasure;
		var TotalWeight=0;
		var TotalVolume=0;
		var TotalDensity=0;
		
		var Volume1=0;
		var Volume2=0;
		var Volume3=0;
		var Volume4=0;
		var Volume5=0;
		
		var Weight1=0;
		var Weight2=0;
		var Weight3=0;
		var Weight4=0;
		var Weight5=0;
		
		var Pallet1=0;
		var Pallet2=0;
		var Pallet3=0;
		var Pallet4=0;
		var Pallet5=0;
		
		//Check to see if US Measure radio button is checked
		if (document.getElementById('radioMeasure1').checked) {
			//US Measure
			unitMeasure='us';
		} else {
			//Metric Measure
			unitMeasure='metric';
		}
		
		var pLength1 = document.calcform.txtLength1.value;
		var pLength2 = document.calcform.txtLength2.value;
		var pLength3 = document.calcform.txtLength3.value;
		var pLength4 = document.calcform.txtLength4.value;
		var pLength5 = document.calcform.txtLength5.value;
		
		var pWidth1 = document.calcform.txtWidth1.value;
		var pWidth2 = document.calcform.txtWidth2.value;
		var pWidth3 = document.calcform.txtWidth3.value;
		var pWidth4 = document.calcform.txtWidth4.value;
		var pWidth5 = document.calcform.txtWidth5.value;
		
		var pHeight1 = document.calcform.txtHeight1.value;
		var pHeight2 = document.calcform.txtHeight2.value;
		var pHeight3 = document.calcform.txtHeight3.value;
		var pHeight4 = document.calcform.txtHeight4.value;
		var pHeight5 = document.calcform.txtHeight5.value; 
		
		var pWeight1 = document.calcform.txtWeight1.value;
		var pWeight2 = document.calcform.txtWeight2.value;
		var pWeight3 = document.calcform.txtWeight3.value;
		var pWeight4 = document.calcform.txtWeight4.value;
		var pWeight5 = document.calcform.txtWeight5.value;
		
		var pPallet1 = document.calcform.txtPallet1.value;
		var pPallet2 = document.calcform.txtPallet2.value;
		var pPallet3 = document.calcform.txtPallet3.value;
		var pPallet4 = document.calcform.txtPallet4.value;
		var pPallet5 = document.calcform.txtPallet5.value;
		
		if (pPallet1==""){
			pPallet1=1;
		}
		if (pPallet2==""){
			pPallet2=1;
		}	
		if (pPallet3==""){
			pPallet3=1;
		}	
		if (pPallet4==""){
			pPallet4=1;
		}	
		if (pPallet5==""){
			pPallet5=1;
		}					

		if (validVal(pLength1,pWidth1,pHeight1,pWeight1)){		
			Volume1 = (pLength1*(pWidth1*pHeight1))*pPallet1;
			Weight1=(Math.abs(pWeight1))*pPallet1;	
		}else{	
			document.calcform.txtLength1.value="";
			document.calcform.txtWidth1.value="";
			document.calcform.txtHeight1.value="";
			document.calcform.txtWeight1.value="";
			document.calcform.txtPallet1.value="";
		}					
		
		if (validVal(pLength2,pWidth2,pHeight2,pWeight2)){
			Volume2=(pLength2*(pWidth2*pHeight2))*pPallet2;
			Weight2=(Math.abs(pWeight2))*pPallet2;							
		}else{
			document.calcform.txtLength2.value="";
			document.calcform.txtWidth2.value="";
			document.calcform.txtHeight2.value="";
			document.calcform.txtWeight2.value="";
			document.calcform.txtPallet2.value="";
		}
		
		if (validVal(pLength3,pWidth3,pHeight3,pWeight3)){
			Volume3=(pLength3*(pWidth3*pHeight3))*pPallet3;
			Weight3=(Math.abs(pWeight3))*pPallet3;						
		}else{
			document.calcform.txtLength3.value="";
			document.calcform.txtWidth3.value="";
			document.calcform.txtHeight3.value="";
			document.calcform.txtWeight3.value="";
			document.calcform.txtPallet3.value="";
		}
		
		if (validVal(pLength4,pWidth4,pHeight4,pWeight4)){
			Volume4 =(pLength4*(pWidth4*pHeight4))*pPallet4;
			Weight4 = (Math.abs(pWeight4))*pPallet4;						
		}else{
			document.calcform.txtLength4.value="";
			document.calcform.txtWidth4.value="";
			document.calcform.txtHeight4.value="";
			document.calcform.txtWeight4.value="";
			document.calcform.txtPallet4.value="";
		}
		
		if (validVal(pLength5,pWidth5,pHeight5,pWeight5)){
			Volume5=(pLength5*(pWidth5*pHeight5))*pPallet5;
			Weight5=(Math.abs(pWeight5))*pPallet5;						
		}else{
			document.calcform.txtLength5.value="";
			document.calcform.txtWidth5.value="";
			document.calcform.txtHeight5.value="";
			document.calcform.txtWeight5.value="";
			document.calcform.txtPallet5.value="";
		}
		
		if (unitMeasure=='us') {
			TotalVolume = (Volume1 + Volume2 + Volume3 + Volume4 + Volume5) / 1728; //12in * 12in * 12in = 1728 cu.in
			TotalWeight = Weight1 + Weight2 + Weight3 + Weight4 + Weight5;
			TotalDensity = TotalWeight / TotalVolume;
			if (isNaN(TotalDensity)) {
				document.calcform.txtDensity.value = '0 lbs/cu.ft.';
				document.calcform.txtDensityConvert.value = '0 kgs/cu.m.';
			} else {
				document.calcform.txtDensity.value = (Math.round(TotalDensity*100)/100) + ' lbs/cu.ft.';
				document.calcform.txtDensityConvert.value = (Math.round((TotalDensity*16.0184634)*100)/100) + ' kgs/cu.m.';
			}
			document.calcform.txtClass.value = GetClassVal(TotalDensity);
			document.calcform.txtWeight.value = (Math.round(TotalWeight*100)/100) + ' lbs';
			document.calcform.txtWeightConvert.value = (Math.round((TotalWeight*0.45359237)*100)/100) + ' kgs';
			document.calcform.txtCube.value = (Math.round(TotalVolume*100)/100) + ' cu.ft.';
			document.calcform.txtCubeConvert.value = (Math.round((TotalVolume*0.0283168466)*100)/100) + ' cu.m.';
		} else {
			TotalVolume = (Volume1 + Volume2 + Volume3 + Volume4 + Volume5) / 1000000; //100cm * 100cm * 100cm = 1000000 cu.cm
			TotalWeight = Weight1 + Weight2 + Weight3 + Weight4 + Weight5;
			TotalDensity = TotalWeight / TotalVolume;
			if (isNaN(TotalDensity)) {
				document.calcform.txtDensity.value = '0 kgs/cu.m.';
				document.calcform.txtDensityConvert.value = '0 lbs/cu.ft.';
			} else {
				document.calcform.txtDensity.value = (Math.round(TotalDensity*100)/100) + ' kgs/cu.m.';
				document.calcform.txtDensityConvert.value = (Math.round((TotalDensity/16.0184634)*100)/100) + ' lbs/cu.ft.';
			}
			document.calcform.txtClass.value = GetClassVal(TotalDensity);
			document.calcform.txtWeight.value = (Math.round(TotalWeight*100)/100) + ' kgs';
			document.calcform.txtWeightConvert.value = (Math.round((TotalWeight/0.45359237)*100)/100) + ' lbs';
			document.calcform.txtCube.value = (Math.round(TotalVolume*100)/100) + ' cu.mtr.';
			document.calcform.txtCubeConvert.value = (Math.round((TotalVolume/0.0283168466)*100)/100) + ' cu.ft.';			
		}
		mySlide.slideIn()
	}
	
	function changeMeasure(unit)
	{
	    if (unit && typeof(unit) == "string")
	    {
	        var measureUnit = "??";
	        var weightUnit = "??";
	        switch (unit)
	        {
	            case "us":
	                measureUnit = "in";
	                weightUnit = "lbs";
	                break;
	            case "metric":
	                measureUnit = "cm";
	                weightUnit = "kgs";
	                break;
	        }
	        var measureUnits = document.calcform.getElementsByTagName("span");
	        if (measureUnits && measureUnits.length > 0)
	        {
	            var count = measureUnits.length;
	            var span = null;
	            for (var i=0; i<count; i++)
	            {
	                span = measureUnits[i];
	                if (span.className == "measureUnit")
	                {
	                    span.innerHTML = measureUnit;
	                }
	                else if (span.className == "weightUnit")
	                {
	                    span.innerHTML = weightUnit;
	                }
	            }
	        }
	    } 
	}
	
	function displayCalc()
	{
	    var calculator = document.getElementById("calculator");
	    if (calculator)
	    {
	        calculator.style.display = "block";
	    }
	}
	
function setStyle(objId, style, value){
   document.getElementById(objId).style[style]= value;
}
/* USAGE:
 * objId    = element id.
 * style    = the style to be changed.
 * value    = the value assigned to the style.
*/ 

