
// Build flags indicating browser-client object model.

docDom = (document.getElementById ? true : false) ;
docLay = (document.layers ? true : false) ;
docAll = (document.all ? true : false) ;

// Used for NN4.7. NN won't set the event handlers correctly for onkeypress.
if (docLay) 
{
  document.captureEvents (Event.KEYPRESS) ;
  document.onkeypress = docLay_CheckEnter ;
}

function getObject (name)
{
  if (docLay)
    return document [name] ;
  else
    if (docAll)
      return document.all (name) ;
    else
      if (docDom)
        return document.getElementById (name) ;
}

function docLay_CheckEnter (event)
{
  if (event.which == 13)
  {
    if (event.target.form)
      event.target.form.submit () ;
    
    return false ;
  }
  
  return true ;
}

function checkEnter (e)
{
  var key = e.keyCode || e.which ;
  
  if (key == 13)
    if (docAll)
    {
      e.cancelBubble = true ;
      e.returnValue = false ;
        
      if (e.srcElement.form)
        e.srcElement.form.submit () ;
    }
    else
      if (e.target.form)
        e.target.form.submit () ;
}

function numbersOnly (e)
{
  // if NS this propery is called 'which'
  // not 'keyCode'
  
  var key = e.keyCode || e.which ;

  if (key == 13)
  {
    if (docLay)
      docLay_CheckEnter (e) ;
    else
      checkEnter (e) ;
  }
  else
    if (key < 48 || key > 57)
    {
      // this is for IE
      if (e.keyCode)
        e.keyCode = 0 ;
  
      // this is for NS6
      if (e.preventDefault)  
        e.preventDefault () ;
    
      // this is for NS4
      return false ;
    }

  return true ;
}

function changeImage (name, 
                      src)
{
  getObject (name).src = src ;
}

function submitForm (formName)
{
  getObject (formName).submit () ;
}

function launchPrintableWindow (URL)
{
  window.open (URL) ;
}

function openPopUp(url) {
	window.open(url,'popup','status=0,toolbar=0,menubar=0,scrollbars=0,height=400,width=400,resizable=1');
}
