function objectReference(id)	
{
  isDOM = (document.getElementById ? true : false);
  isIE4 = ((document.all && !isDOM) ? true : false);
  isNS4 = (document.layers ? true : false);

  if (isDOM) result = document.getElementById(id);
    else if (isIE4) result = document.all[id];
      else if (isNS4) result = document.layers[id];
  return result;
}

function Round(value, offset)
{
  return Math.round(value*Math.pow(10, offset))/Math.pow(10, offset);
}

function FormatFloat(value, fixed)
{
  if (!value) return '';
  value = Math.round(value, fixed);
  if (Number(value).toFixed) return Number(value).toFixed(fixed); else return value;
}

function RadioValue(radio_object)
{
  for ( var i = 0; i < radio_object.length; i++ )
    if ( radio_object[i].checked === true ) return radio_object[i].value; 
  return ''; 
}


function popupForm(form, url)
{
  var action=form.action;
  form.target='_blank';
  form.action=url;
  form.submit();
  form.target='_self';
  form.action=action;
  return false;
}

function getAmpersand()
{
  return '&';
}

function getLineBreak()
{
  return '\n';
}

function isset( ) 
{
  var a=arguments; var l=a.length; var i=0;
    
  if (l==0) throw new Error('Empty isset'); 
    
  while (i!=l) 
    if (typeof(a[i])=='undefined' || a[i]===null) return false; else i++; 

  return true;
}

function selectOption(options, value)
{
  for(i=0; i<options.length; i++)
  {
    if (options[i].value == value)  
    {
      options[i].selected = true;
      return;
    }
  }
}

function getSelection(objSel)
{
  return objSel.options[objSel.selectedIndex].value;
}

function getCheckedValue(radioObj) 
{
  if(!radioObj)	return "";
  var radioLength = radioObj.length;

  if(radioLength == undefined)
  {
    if(radioObj.checked) return radioObj.value;	else return "";
  }
  
  for(var i = 0; i < radioLength; i++) 
    if(radioObj[i].checked) return radioObj[i].value;

  return "";
}

function setCheckedValue(radioObj, newValue) 
{
  if(!radioObj) return;

  var radioLength = radioObj.length;
  if(radioLength == undefined) 
  {
    radioObj.checked = (radioObj.value == newValue.toString());
    return;
  }

  for(var i = 0; i < radioLength; i++) 
  {
    radioObj[i].checked = false;
    if(radioObj[i].value == newValue.toString()) radioObj[i].checked = true;
  }
}

function setIFrameAutoHeight(e)
{
  if(e.contentDocument) e.height = e.contentDocument.body.offsetHeight;
    else e.height = e.contentWindow.document.body.scrollHeight;
}

function currencyTransformer(amount)
{
  amount = amount.replace(',', '.');
  if (!isFloat(amount))
  {
    var newAmount = '';
    var commaFound = false;
    for(i=0; i<amount.length; i++)
    {
      if (amount.charAt(i) == '.')
      {
        if (!commaFound)
        {
          commaFound = true;
          newAmount += amount.charAt(i);
        }
      }
      else if (isInteger(amount.charAt(i))) newAmount += amount.charAt(i);
    }
    amount = newAmount;
  }        

  if (!isFloat(amount)) return "";

  var roundValue = Math.floor(amount*100+0.001) / 100;
  if (roundValue != amount) amount = roundValue;

  return amount;
}



