document.onclick = function(e)
{
  var target = e ? e.target : window.event.srcElement;

  while (target && !/^(a|body)$/i.test(target.nodeName))
  {
    target = target.parentNode;
  }

  if (target && target.getAttribute('rel')
      && target.rel == 'external')
  {
    var external = window.open(target.href);

    return external.closed;
  }
  
}



function fieldFocus(field) {
if(document.oml){
        document.oml.elements[field].focus();
        }
}


function doDecimals(val) {
ttl = "" + parseInt(val * 100)/100;
dec1 = ttl.substring(ttl.length-3, ttl.length-2);
dec2 = ttl.substring(ttl.length-2, ttl.length-1);
if (dec1 != '.') { // adds trailing zeroes if necessary
        if (dec2 == '.') {ttl += "0"}   else {ttl += ".00"}
        if (ttl == ".00") {ttl = "0.00"}
        }
return ttl
}



// POP-UP for Help
function NewHelpWindow(mypage) {
win = window.open(mypage, "help", 'height=300,width=550,top=10,left=10,scrollbars=1,resizable');
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

//  POP-UP for Use form
function NewUserWindow(mypage) {
win = window.open(mypage, "profile", 'height=700,width=600,top=10,left=10,scrollbars=1,resizable');
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}



//======================
// WARN settings 
//======================
var $text = new Array();

function warn($rectype) {
        if(document.oml.deleteme && document.oml.deleteme.checked == true  ){
        		
        	$record = $text[$rectype];
        	if(!$record){$record = "permanently delete this record";}
        	
                if(window.confirm("WARNING!\n\nThis will " + $record + ".\n\nAre you sure you want to continue?")){
                          return true;
                          }
                else {	
                	$ready = 0;
                          return false;
                          }
          }
}

