
//Electronics utility. Finds parallel resistor pairs to match close tolerance values.
//    based on the original:
//    Copyright (C) 2001 Dave Gough <dave at psand.net>
    
//    This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2. 
//    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 
//
//     You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc.,
//     675 Mass Ave, Cambridge, MA 02139, USA. 

//     COMPLETED IMPROVEMENT
//     Adding support for more than two paralleled. by JamesNewton@massmind.org 2005/06/09

//     POTENTIAL IMPROVEMENTS

//     Adding support for more resistance series.
//     Adding support for series connection & possibly more complicated networks
//     Adding result sort.



//     Set up arrays of answers
var aResult_t=new series(145,0);
var aResult_a=new series(145,0);
var aResult_b=new series(145,0);
var aResult_c=new series(145,0);
var aResult_percent=new series(145,100);

//     Set up list of percentage deviation

var isNav, isIe, isOther;

if (parseInt(navigator.appVersion)>=4){
	if (navigator.appName=="Netscape"){
		isNav=true;
		}
	else{
		isIe=true;
		}
	}

if (!isNav && !isIe) {
	isOther=true;
	}
	
function core_process (fTargetAmp,fTolerance) {
//     main number crunching routine
	var aVoltage = 1; //assume 1 volt for easy calculation
	var fTarget = aVoltage/fTargetAmp; // R = E/I
	var esqr = 1; //aVoltage ^ 2 //ready for P = E^2 * E
	var sOut='';
    var fUp_limit;
    var fLow_limit;        //upper&lower limits to target resistance
    var fRes;              //target resistance
    var fDiff_percent=null;
    var sPolarity_temp="";
    var isAnswer=false;    //has a match been found?
    var iAnswer_tally=null;
    var iBest_diff_index=null;
    var fBest_diff_value=100;  

    var win2=window.open("","","menubar,scrollbars,status");
    sOut = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
    sOut += '\n<html>\n';

    sOut+= '\<!-- Copyright Psand Ltd. 2002 Author: Spacepleb\nThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2.\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n-->\n';

    sOut+='<head><title>Resistor pairs which parallel to give '+fTarget+' Ohms</title>\n ';
    sOut+='</head>\n<body>\n';

    sOut+= '<h1>Results of resistor set search.</h1>';
    sOut+= '<p>Target Resistance for your current requirement of '+fTargetAmp+'&nbsp;Amps is '+fTarget+'&nbsp;Ohms\n';
//    sOut+= '<br>That resistance, at the full current, will result in a voltage of '+aVoltage+'&nbsp;Volts over all the resistors</p>\n';
// no point since it is always 1 volt.
    sOut +='<br>At the full current, this will dissipate a total of ' + Math.floor( ( fTargetAmp * aVoltage) * 1000 ) / 1000 + '&nbsp;Watts over all the resistors, but each resistor will dissipate a different amount, shown in (), depending on it\'s value. </p>\n';
    sOut+= '<p>Tolerance on search  = '+fTolerance+'%   ';
    win2.document.write(sOut);
	sOut = null;

    fUp_limit=(1.0*fTarget)+(fTarget*(fTolerance/100));
    fLow_limit=(1.0*fTarget)-(fTarget*(fTolerance/100));
    
//	Look for solutions with only one resistor.
	for (var iX = 1; iX <=aResistance_series.length; iX++) {
		if (aResistance_series[iX]>=fLow_limit & aResistance_series[iX]<=fUp_limit){ 
			isAnswer=true;
			iAnswer_tally++;  //Increment the quantity of answers found
			aResult_t[iAnswer_tally]=aResistance_series[iX]; 
			aResult_a[iAnswer_tally]=aResistance_series[iX]; //Add first resistor to answer list
			aResult_b[iAnswer_tally]=0;
			aResult_c[iAnswer_tally]=0;

			fDiff_percent=(((aResistance_series[iX]-fTarget)/fTarget)*100); //calculate the percentage difference between target and search result.

			aResult_percent[iAnswer_tally]=fDiff_percent;
			if (Math.abs(fDiff_percent)<Math.abs(fBest_diff_value)){
				iBest_diff_index=iAnswer_tally;
				fBest_diff_value=fDiff_percent;
				}
			}
		}


//	Look for solutions with only two resistors.
	for (var iX = 1; iX <=aResistance_series.length; iX++) {
		for (var iY = 1; iY <=aResistance_series.length; iY++) {


			fRes=paracalc_go(aResistance_series[iX],aResistance_series[iY]);

			if (fRes>=fLow_limit & fRes<=fUp_limit & aResistance_series[iX]!=fTarget & aResistance_series[iY]!=fTarget){ 
				//Check found pair within spec and not equal to the target resistance!
				if (aResistance_series[iX] > aResistance_series[iY]){
	//     Stop loop if repeat pairs found
					iX=aResistance_series.length;iY=iX;
					break
					break
					}
				isAnswer=true;
			
				iAnswer_tally++;  //Increment the quantity of answers found
				aResult_t[iAnswer_tally]=fRes;
				aResult_a[iAnswer_tally]=aResistance_series[iX]; //Add first resistor to answer list
				aResult_b[iAnswer_tally]=aResistance_series[iY]; //Add second resistor to answer list
				aResult_c[iAnswer_tally]=0;
				
				fDiff_percent=(((fRes-fTarget)/fTarget)*100); //calculate the percentage difference between target and search result.
				
				aResult_percent[iAnswer_tally]=fDiff_percent;
				if (Math.abs(fDiff_percent)<Math.abs(fBest_diff_value)){
					iBest_diff_index=iAnswer_tally;
					fBest_diff_value=fDiff_percent;
					}
						
		//					
				}
			}
		}

	for (var iX = 1; iX <=aResistance_series.length; iX++) {
		for (var iY = 1; iY <=aResistance_series.length; iY++) {
			for (var iZ = 1; iZ <=aResistance_series.length; iZ++) {

				fRes=para3calc_go(aResistance_series[iX],aResistance_series[iY],aResistance_series[iZ]);
	
				if (fRes>=fLow_limit & fRes<=fUp_limit & aResistance_series[iX]!=fTarget & aResistance_series[iY]!=fTarget & aResistance_series[iZ]!=fTarget){ 
					//Check found pair within spec and not equal to the target resistance!
					if (aResistance_series[iX] > aResistance_series[iY] || (aResistance_series[iX] > aResistance_series[iY] && aResistance_series[iY] > aResistance_series[iZ])) {
	//     Stop loop if repeat pairs found
						iX=aResistance_series.length;iY=iX;iZ=iY;
						break
						break
						break
						}
					isAnswer=true;
				
					iAnswer_tally++;  //Increment the quantity of answers found
					aResult_t[iAnswer_tally]=fRes;
					aResult_a[iAnswer_tally]=aResistance_series[iX]; //Add first resistor to answer list
					aResult_b[iAnswer_tally]=aResistance_series[iY]; //Add second resistor to answer list
					aResult_c[iAnswer_tally]=aResistance_series[iZ]; //Add second resistor to answer list
						 
					fDiff_percent=(((fRes-fTarget)/fTarget)*100); //calculate the percentage difference between target and search result.
					
					aResult_percent[iAnswer_tally]=fDiff_percent;
					if (Math.abs(fDiff_percent)<Math.abs(fBest_diff_value)){
						iBest_diff_index=iAnswer_tally;
						fBest_diff_value=fDiff_percent;
						}
						
			//					
					}
				}
			}
		}
 
    var fTemp_result=null;


    if (isAnswer!=true) {  //Check if any answers found
		sOut+='<p>Sorry, could not find a match for your target resistance.</p>';		
		if (fTarget>200000){
			sOut+='<p>This could be because your target resistance is very high.</p>';
			}
	
		if (fTarget<2) {
			sOut+='<p>This could be because your target resistance is very low.<br />You may need to parallel more than three resistors together.<br />This is more than the Linistepper is designed for.</p>';
			}
	
		}
	else {
 
		sOut +='\n  (Found '+(iAnswer_tally)+' sets within tolerance)<br />'
			+'The closest match is '+aResult_a[iBest_diff_index]+' Ohms @' + (Math.floor((esqr/aResult_a[iBest_diff_index])*1000)/1000) +  'W';
		if (aResult_b[iBest_diff_index]>0) sOut +=' paralleled with '+aResult_b[iBest_diff_index]+ ' Ohms @' + (Math.floor((esqr/aResult_b[iBest_diff_index])*1000)/1000) +  'W';
		if (aResult_c[iBest_diff_index]>0) sOut +=' paralleled with '+aResult_c[iBest_diff_index]+ ' Ohms @' + (Math.floor((esqr/aResult_c[iBest_diff_index])*1000)/1000) +  'W';
		if (aResult_percent[iBest_diff_index]==0){
			sOut += ' which is perfect.';
			}
		else { 
			sOut +='\n which is only '+is_positive(decimal(aResult_percent[iBest_diff_index]))+'% out';
			}
		sOut += '</p>';
		sOut +='<p><i>Please note: The component selected should aways be rated for double or more of the wattage it is expected to handle. For 1 Watt dissipation, please us 2 or 3 Watt rated resistors.</i></p>\n'

		sOut += '<table width="100%" border="3"><tr>'
			+'<td>First (Ohms)</td><td>Second (Ohms)</td><td>Third (Ohms)</td><td>Paralleled result (Ohms)</td><td>Deviation (%)</td></tr>';

		var bgcolor = "#FFFFFF";
		for (var iC = 1; iC <= iAnswer_tally; iC++){
			//the minus one is stop the first repeat
		
			sOut +='\n<tr bgcolor="' + bgcolor + '">';
			sOut +='<td>' + aResult_a[iC] + '&Omega; @' + (Math.floor((esqr / aResult_a[iC])*1000)/1000) +  'W </td>'
			if (aResult_b[iC]>0) sOut +='<td>' + aResult_b[iC] + '&Omega; @' + (Math.floor((esqr/aResult_b[iC])*1000)/1000) +  'W</td>'; else sOut +='<td>none</td>';
			if (aResult_c[iC]>0) sOut +='<td>' + aResult_c[iC] + '&Omega; @' + (Math.floor((esqr/aResult_c[iC])*1000)/1000) +  'W</td>'; else sOut +='<td>none</td>';
			sOut +='<td>'
				+Math.floor(aResult_t[iC]*1000)/1000
				+'&Omega;</td>'
				+'<td>' + is_positive(decimal(aResult_percent[iC])) + '</td>'
				+'</tr>'; 
			if (bgcolor == "#FFFFFF") { bgcolor="#F0F0F0"; } else { bgcolor = "#FFFFFF"; }
			}
    
		sOut +='\n</table>';
		}

    sOut+='<p><a href="#" onclick="window.close();return false;">Close this window</a></p>';

    sOut+='<h2>Release notes</h2>';

    sOut+='<p>Based on the parallel resistance finder from <a href="http://www.computertorture.com/noncompliant/parallel/index.html">http://www.computertorture.com/noncompliant/parallel/index.html</a></p>';

    sOut+= '<p>&copy; Copyright James Newton 2006<br />This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2.\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</p>\n';

    sOut+='\n</body>\n</html>\n\n';

    win2.document.write(sOut);
    win2.document.close();
    win2.status = 'done';
    return true;
    //     Calculation complete
	}

function old_core_process (fTarget,fTolerance){
//     main number crunching routine
	
	var sOut='';
    var fUp_limit;
    var fLow_limit;        //upper&lower limits to target resistance
    var fRes;              //target resistance
    var fDiff_percent=null;
    var sPolarity_temp="";
    var isAnswer=false;    //has a match been found?
    var iAnswer_tally=null;
    var iBest_diff_index=null;
    var fBest_diff_value=100;  

    fUp_limit=(1.0*fTarget)+(fTarget*(fTolerance/100));
    fLow_limit=(1.0*fTarget)-(fTarget*(fTolerance/100));

	for (var iX = 1; iX <=aResistance_series.length; iX++) {
		for (var iY = 1; iY <=aResistance_series.length; iY++) {

			fRes=paracalc_go(aResistance_series[iX],aResistance_series[iY]);

			if (fRes>=fLow_limit & fRes<=fUp_limit & aResistance_series[iX]!=fTarget & aResistance_series[iY]!=fTarget){ 
				//Check found pair within spec and not equal to the target resistance!
				isAnswer=true;
			
				iAnswer_tally++;  //Increment the quantity of answers found
				aResult_a[iAnswer_tally]=aResistance_series[iX]; //Add first resistor to answer list
				aResult_b[iAnswer_tally]=aResistance_series[iY]; //Add second resistor to answer list
					 
				fDiff_percent=(((fRes-fTarget)/fTarget)*100); //calculate the percentage difference between target and search result.
				
				aResult_percent[iAnswer_tally]=fDiff_percent;
				if (Math.abs(fDiff_percent)<Math.abs(fBest_diff_value)){
					iBest_diff_index=iAnswer_tally;
					fBest_diff_value=fDiff_percent;
					}
						
				if (aResistance_series[iX]>aResistance_series[iX]){
//     Stop loop if repeat pairs found
					iX=aResistance_series.length;iY=iX;
					break
					break
					}
		//					
				}
			}
		}
 
    var fTemp_result=null;
    sOut = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
    sOut += '\n<html>\n';

    sOut+= '\<!-- Copyright Psand Ltd. 2002 Author: Spacepleb\nThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2.\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n-->\n';

    sOut+='<head><title>Resistor pairs which parallel to give '+fTarget+' Ohms</title>\n ';
    sOut+='<link rel="stylesheet" type="text/css" href="/style/style.css">\n';
    sOut+='</head>\n<body>\n';

    sOut+= '<h1>Results of resistor pair search.</h1>';
    sOut+= '<p>Target Resistance&nbsp;=&nbsp;'+fTarget+'&nbsp;Ohms</p>\n';
    sOut+= '<p>Tolerance on search  = '+fTolerance+'%   ';


    if (isAnswer!=true) {  //Check if any answers found
		sOut+='<p>Sorry, could not find a match for your target resistance.</p>';		
		if (fTarget>200000){
			sOut+='<p>This could be because your target resistance is very high.</p>';
			}
	
		if (fTarget<2) {
			sOut+='<p>This could be because your target resistance is very low.<br />You may need to parallel more resistors together.<br />Please do not ask me to do it. I cannot be bothered.</p>';
			}
	
		}
	else {
 
		sOut +='\n  (Found '+(iAnswer_tally-2)+' pairs within tolerance)<br />'
			+'The closest match is '+aResult_a[iBest_diff_index]
			+' Ohms paralleled with '+aResult_b[iBest_diff_index]+ ' Ohms';

		if (aResult_percent[iBest_diff_index]==0){
			sOut += ' which is perfect.';
			}
		else { 
			sOut +='\n at only '+is_positive(decimal(aResult_percent[iBest_diff_index]))+'% out';
			}
		sOut += '</p>';


		sOut += '<table width="100%" border="3"><tr>'
			+'<td>First (Ohms)</td><td>Second (Ohms)</td><td>Paralleled result (Ohms)</td><td>Deviation (%)</td></tr>';

		for (var iC = 1; iC < iAnswer_tally-1; iC++){
			//the minus one is stop the first repeat
		
			fTemp_result=decimal(paracalc_go(aResult_a[iC],aResult_b[iC]));
	
			sOut +='\n<tr>'
				+'<td>' + aResult_a[iC] + '</td>'
				+'<td>' + aResult_b[iC] + '</td>'
				+'<td>'
				+fTemp_result
				+'</td>'
				+'<td>' + is_positive(decimal(aResult_percent[iC])) + '</td>'
				+'</tr>'; 
			}
    
		sOut +='\n</table>';
		}

    sOut+='<p><a href="#" onclick="window.close();return false;">Close this window</a></p>';

    sOut+='<h2>Release notes</h2>';

    sOut+='<p>The latest version of this utility can be found at <a href="http://www.computertorture.com/noncompliant/parallel/index.html">http://www.computertorture.com/noncompliant/parallel/index.html</a></p>';

    sOut+= '<p>&copy; Copyright Dave Gough 2001<br />This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2.\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</p>\n';

    sOut+='<p><a href="http://validator.w3.org/check/referer"><img border="0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" height="31" width="88"></a></p>';
			
    sOut+='\n</body>\n</html>\n\n';

    var win2=window.open("","","menubar,scrollbars");
    win2.document.write(sOut);
    win2.document.close();

    return true;
    //     Calculation complete
	}

function is_positive(fQuery){

    var sQuery=null;
    var isPos=true;
	
    /*
      if(isNav){
      //     Explicit branching used to circumvent the lack of zero's in NN decimal numbers...		
      if (fQuery>=0){
      //     Adds a plus sign to positive percentage deviation 
      if (fQuery<1){
      if (fQuery>0.1){
      sQuery='+0'+decimal(fQuery);
      }else{
      sQuery='+'+decimal(fQuery);
      }
      }else{
      sQuery='+'+decimal(fQuery);
      }
      }else{
      sQuery=Math.abs(decimal(fQuery));
      if (fQuery>-1){			
      if (fQuery>=-0.1){
      sQuery='-0'+decimal(fQuery);
      }else{
      sQuery='-'+decimal(fQuery);
      }
      }else{
      sQuery='-'+sQuery;
      }
      }
      }else{
      if (fQuery>=0){
      //     Adds a plus sign to positive percentage deviation 
      if (fQuery<1){
      sQuery='+'+decimal(fQuery);
      }else{
      sQuery='+'+decimal(fQuery);
      }
      }else{
      sQuery=Math.abs(decimal(fQuery));
      if (fQuery>-1){			
      sQuery='-'+sQuery;
      }else{
      sQuery='-'+sQuery;
      }
      }
      }
    */
    fQuery=decimal(fQuery);
    if (fQuery>0){
	sQuery='+'+fQuery;
    }else{
	sQuery=fQuery;
    }
	
    return sQuery;
}

	
function series(iHow_many, sInitial) {
    //     Sets array values to sInitial   

    this.length = iHow_many;
    for( var i = 1; i <= iHow_many; i++ ) {
		this[i] = sInitial;                 
	    }
	}

function button1_onclick() {
    //     Validate values before processing request

    var sOut='';
	
    if (document.calc.target_amperage.value<0.001 || document.calc.target_amperage.value>10 ) {
		alert("Target amperage must be between 0.001 and 10 amps, please change and try again.");
		return false;
	    }
	else {
	
		if (isNaN(document.calc.target_amperage.value)) {
		    alert('Could not recognise the format of your target amperage. Please try again.');
		    return false;
			}
	
		if (isNaN(document.calc.tolerance_percent.value)) {
		    alert('Could not recognise the format of search tolerance. Please try again.');
		    return false;
			}
	
		core_process (document.calc.target_amperage.value,document.calc.tolerance_percent.value); 
		//call main function passing target amperage and tolerance percentage
	    }
	
	}

function window_onload() {
    //     Initialises resistance series

//    aResistance_series=new series(145,4.0);
    aResistance_series=new series(48,4.0);
    //     following fills resistor values
    aResistance_series[1]=1;aResistance_series[2]=1.1;aResistance_series[3]=1.2;aResistance_series[4]=1.3;
    aResistance_series[5]=1.5;aResistance_series[6]=1.6;aResistance_series[7]=1.8;aResistance_series[8]=2;
    aResistance_series[9]=2.2;aResistance_series[10]=2.4;aResistance_series[11]=2.7;aResistance_series[12]=3;
    aResistance_series[13]=3.3;aResistance_series[14]=3.6;aResistance_series[15]=3.9;aResistance_series[16]=4.3;
    aResistance_series[17]=4.7;aResistance_series[18]=5.1;aResistance_series[19]=5.6;aResistance_series[20]=6.2;
    aResistance_series[21]=6.8;aResistance_series[22]=7.5;aResistance_series[23]=8.2;aResistance_series[24]=9.1;
	
    for (var i=1;i<=24;i++){
		aResistance_series[i+24]=(aResistance_series[i]*10);
	
//		aResistance_series[i+48]=(aResistance_series[i]*100);
//		aResistance_series[i+72]=(aResistance_series[i]*1000);
//		aResistance_series[i+96]=(aResistance_series[i]*10000);
//		aResistance_series[i+120]=(aResistance_series[i]*100000);
	    }

//	aResistance_series[145]=1000000
//	aResistance_series[50]=110;aResistance_series[57]=220;aResistance_series[66]=510;aResistance_series[71]=820;
//	aResistance_series[122]=110000;aResistance_series[129]=220000;aResistance_series[138]=560000;aResistance_series[143]=820000;
	return true;
	}

function resistname_convert( sResistance ) {					//Converts named resistance to float
	
    var iDecimal_position=null;   //where in string the decimal point is
    var iMultiplier_position=-2;  //where in the string the multiplier is
    var iMultiplier_value=1;	  //multiplier value
    var iDecimal_part=0;	  //Decimal part of resistance
    var iMajor_part=0;		  //Most significant part of resistance

    iDecimal_position=sResistance.indexOf(".");	//find decimal if there is one

    if (sResistance.indexOf("R")!=-1) {iMultiplier_value=1; iMultiplier_position=sResistance.indexOf("R");} //find multiplier
    if (sResistance.indexOf("r")!=-1) {iMultiplier_value=1; iMultiplier_position=sResistance.indexOf("r");}
    if (sResistance.indexOf("K")!=-1) {iMultiplier_value=1000; iMultiplier_position=sResistance.indexOf("K");}
    if (sResistance.indexOf("k")!=-1) {iMultiplier_value=1000; iMultiplier_position=sResistance.indexOf("k");}
    if (sResistance.indexOf("M")!=-1) {iMultiplier_value=1000000; iMultiplier_position=sResistance.indexOf("M");}
    if (sResistance.indexOf("m")!=-1) {iMultiplier_value=1000000; iMultiplier_position=sResistance.indexOf("m");}

    if (iDecimal_position>-1) {iMultiplier_position=iDecimal_position;} //if decimal prescent put multiplier there numerilogically

    if (iMultiplier_position < -1.5) {
	iMultiplier_position=sResistance.length;
    }
 
    if (iDecimal_position=-1) {iDecimal_position=iMultiplier_position;}//if no decimal then make multiplier position

    iMajor_part=sResistance.substring(0,iDecimal_position);				//find bit before decimal point 
    iDecimal_part=sResistance.substring((iDecimal_position+1),sResistance.length);		//find bit after decimal
    sResistance=((iMajor_part+"."+iDecimal_part)*iMultiplier_value);	//produce numerical version of resistance

    return sResistance;
}

function para3calc_go (fResistance_one,fResistance_two, fResistance_three) {
    //     Calculates parallel resistance of three values
	return 1/((1.0/fResistance_one)+(1.0/fResistance_two)+(1.0/fResistance_three));
	}


function paracalc_go (fResistance_one,fResistance_two) {
    //     Calculates parallel resistance of two values

	var fProduct;
	var fResult;
	var fSum;
	
	fProduct = fResistance_one*fResistance_two;
	fSum =((1.0*fResistance_one)+(1.0*fResistance_two));
	fResult=fProduct/fSum;

	return fResult;
	}

function decimal(fFloat) {
    //converts float value to 2 figure decimal

    var fStripped=null;

    fStripped=Math.floor(fFloat*100);
    fStripped=(fStripped/100);

    return fStripped;
	}


