// ---------------------------------------------------------------------
//
// Copyright(c) 2001-2009, BrainStorm Business Resources, Inc.
//
// All Rights Reserved.  Derechos Reservados.
//
// BBR Systems(r) is a division of BrainStorm Business Resources, Inc.
// This software is the intellectual property of BBR Systems(r).
//
// BBR Systems(r) es una division de BrainStorm Business Resources, Inc.
// Este software es la propiedad intellectual de BBR Systems(r).
//
// ---------------------------------------------------------------------

var ultimo = 'HOME';

function getElement(aID)
{ 
  return (document.getElementById ? document.getElementById(aID)
                                   : document.all[aID]);
} 

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}


function init()
{
	 display(ultimo);
}

function display(id)
{
	if (getElement(ultimo))
	{
		getElement(ultimo).style.display='none';
		getElement(id).style.display='inline';
		ultimo=id;
	}
}

/*
 * ASN.1 GeneralizedTime syntax
 * Type GeneralizedTime takes values of the year, month, day, hour, time, minute,second, and second fraction in any of three forms. 
 * 
 * Local time only. ``YYYYMMDDHHMMSS.fff'', where the optional fff is accurate to three decimal places. 
 * Universal time (UTC time) only. ``YYMMDDHHMMSS.fffZ''. 
 * Difference between local and UTC times. ``YYYYMMDDHHMMSS.fff+-HHMM''. 
 * 
 */
function toZuluGeneralizedTime(dt)
{
	var str = dt.getUTCFullYear();
	str+=dt.getUTCMonth()<10?"0":"";
	str+=dt.getUTCMonth();
	str+=dt.getUTCDate()<10?"0":"";
	str+=dt.getUTCDate();
	str+=dt.getUTCHours()<10?"0":"";
	str+=dt.getUTCHours();
	str+=dt.getUTCMinutes()<10?"0":"";
	str+=dt.getUTCMinutes();
	str+=dt.getUTCSeconds()<10?"0":"";
	str+=dt.getUTCSeconds();
	str+="."
	str+=dt.getUTCMilliseconds()<10?"0":"";
	str+=dt.getUTCMilliseconds()<100?"0":"";
	str+=dt.getUTCMilliseconds();
	str+="Z";
	return str;
}


function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

