<!--
var calculator = new Object; 

function doOp(operation) { 
  if(operation == '') { 
    alert("Null Op"); 
  } 
  if(operation == 'clear') { 
    calculator.clearOnInput = true; 
    calculator.previous = '0'; 
    document.calculator.thevalue.value = '0'; 
    <!-- document.calculator.BGL.value = '0'; --> 
    calculator.op = ''; 
    return; 
  } 
  if(operation == 'invert') { 
    var calcval = document.calculator.thevalue; 
    if(calcval.value.charAt(0) == '-') { 
      calcval.value = calcval.value.substr(1, calcval.value.length); 
    } else { 
      if(calcval.value != '0') { 
	calcval.value = '-' + calcval.value; 
      } 
    } 
    return; 
  } 
  if(calculator.op == '') {  
    if(operation == 'equals') { 
      calculator.clearOnInput = true; 
    } else { 
      calculator.op = operation; 
      calculator.clearOnInput = true; 
      calculator.previous = document.calculator.thevalue.value; 
    } 
  } else {  
    var result = doEquals();  
    calculator.previous = document.calculator.thevalue.value; 
    document.calculator.thevalue.value = result; 
  <!-- document.calculator.BGL.value = document.calculator.thevalue.value; --> 
    if(operation != 'equals') { 
      calculator.op = operation; 
    } else { 
      calculator.op = '';  
    } 
  } 
} 

function doEquals() { 
  calculator.clearOnInput = true; 
  if (calculator.op == 'clear') { 
    alert("op = clear"); 
    return 0; 
  } 
  if(calculator.op == 'equals') { 
    alert("op = equals"); 
    return 0; 
  } 
  if(calculator.op == '') { 
    calculator.previous = '0'; 
    return document.calculator.thevalue.value; 
  } 
  if (calculator.op == 'plus') { 
    calculator.op = ''; 
    return parseFloat(calculator.previous) + parseFloat(document.calculator.thevalue.value); 
  } 
  if (calculator.op == 'minus') { 
    calculator.op = ''; 
    return parseFloat(calculator.previous) - parseFloat(document.calculator.thevalue.value); 
  } 
  if (calculator.op == 'times') { 
    calculator.op = ''; 
    return parseFloat(calculator.previous) * parseFloat(document.calculator.thevalue.value); 
  } 
  if (calculator.op == 'divide') { 
    calculator.op = ''; 
    return parseFloat(calculator.previous) / parseFloat(document.calculator.thevalue.value); 
  } 
  alert("unknown Op"); 
  return -1; 
} 

function eN(number) { 
  if(calculator.clearOnInput) { 
     calculator.previous = document.calculator.thevalue.value; 
     document.calculator.thevalue.value = number; 
     calculator.clearOnInput = false; 
  } else { 
    if(document.calculator.thevalue.value == '0') { 
      document.calculator.thevalue.value = number; 
    } else { 
      document.calculator.thevalue.value = document.calculator.thevalue.value + number; 
    } 
  } 
} 

function excalc(operator) { 
  if(operator == '') { 
    alert("Null Op"); 
  } 
  if(operator == 'BGLex') { 
    document.calculator.BGL.value = document.calculator.thevalue.value; 
    document.calculator.EUR.value = document.calculator.BGL.value / eur; 
    document.calculator.USD.value = document.calculator.BGL.value / usd; 
    document.calculator.GBP.value = document.calculator.BGL.value / gbp; 
    document.calculator.CHF.value = document.calculator.BGL.value / chf; 
    return; 
  } 
  if(operator == 'EURex') { 
    document.calculator.EUR.value = document.calculator.thevalue.value; 
    document.calculator.BGL.value = document.calculator.EUR.value * eur; 
    document.calculator.USD.value = document.calculator.BGL.value / usd; 
    document.calculator.GBP.value = document.calculator.BGL.value / gbp; 
    document.calculator.CHF.value = document.calculator.BGL.value / chf; 
    return; 
  } 
  if(operator == 'USDex') { 
    document.calculator.USD.value = document.calculator.thevalue.value; 
    document.calculator.BGL.value = document.calculator.USD.value * usd; 
    document.calculator.EUR.value = document.calculator.BGL.value / eur; 
    document.calculator.GBP.value = document.calculator.BGL.value / gbp; 
    document.calculator.CHF.value = document.calculator.BGL.value / chf; 
    return; 
  } 
  if(operator == 'GBPex') { 
    document.calculator.GBP.value = document.calculator.thevalue.value; 
    document.calculator.BGL.value = document.calculator.GBP.value * gbp; 
    document.calculator.EUR.value = document.calculator.BGL.value / eur; 
    document.calculator.USD.value = document.calculator.BGL.value / usd; 
    document.calculator.CHF.value = document.calculator.BGL.value / chf; 
    return; 
  } 
  if(operator == 'CHFex') { 
    document.calculator.CHF.value = document.calculator.thevalue.value; 
    document.calculator.BGL.value = document.calculator.CHF.value * chf; 
    document.calculator.EUR.value = document.calculator.BGL.value / eur; 
    document.calculator.USD.value = document.calculator.BGL.value / usd; 
    document.calculator.GBP.value = document.calculator.BGL.value / gbp; 
    return; 
  } 
  if(operator == 'clear') { 
    document.calculator.BGL.value = ''; 
    document.calculator.EUR.value = eur; 
    document.calculator.USD.value = usd; 
    document.calculator.GBP.value = gbp; 
    document.calculator.CHF.value = chf; 
    return; 
  } 
  if(operator == 'empty') { 
    document.calculator.BGL.value = ''; 
    document.calculator.EUR.value = ''; 
    document.calculator.USD.value = ''; 
    document.calculator.GBP.value = ''; 
    document.calculator.CHF.value = ''; 
    return; 
  } 
  if(operator == 'exBGL') { 
    document.calculator.EUR.value = document.calculator.BGL.value / eur; 
    document.calculator.USD.value = document.calculator.BGL.value / usd; 
    document.calculator.GBP.value = document.calculator.BGL.value / gbp; 
    document.calculator.CHF.value = document.calculator.BGL.value / chf; 
    return; 
  } 
  if(operator == 'exEUR') { 
    document.calculator.BGL.value = document.calculator.EUR.value * eur; 
    document.calculator.USD.value = document.calculator.BGL.value / usd; 
    document.calculator.GBP.value = document.calculator.BGL.value / gbp; 
    document.calculator.CHF.value = document.calculator.BGL.value / chf; 
    return; 
  } 
  if(operator == 'exUSD') { 
    document.calculator.BGL.value = document.calculator.USD.value * usd; 
    document.calculator.EUR.value = document.calculator.BGL.value / eur; 
    document.calculator.GBP.value = document.calculator.BGL.value / gbp; 
    document.calculator.CHF.value = document.calculator.BGL.value / chf; 
    return; 
  } 
  if(operator == 'exGBP') { 
    document.calculator.BGL.value = document.calculator.GBP.value * gbp; 
    document.calculator.EUR.value = document.calculator.BGL.value / eur; 
    document.calculator.USD.value = document.calculator.BGL.value / usd; 
    document.calculator.CHF.value = document.calculator.BGL.value / chf; 
    return; 
  } 
  if(operator == 'exCHF') { 
    document.calculator.BGL.value = document.calculator.CHF.value * chf; 
    document.calculator.EUR.value = document.calculator.BGL.value / eur; 
    document.calculator.USD.value = document.calculator.BGL.value / usd; 
    document.calculator.GBP.value = document.calculator.BGL.value / gbp; 
    return; 
  } 
} 

doOp('clear');
//excalc('clear');
//-->

