  var CONVstrs = new Array('0','X','K','I','4','Z','R','7','8','Y');

  /*
  function hidestatus(){
    window.status='';
    return true
  }

  if (document.layers) document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)
  document.onmouseover=hidestatus
  document.onmouseout=hidestatus

  */

  function form2url(form){
    var i=0;
    var newURL = document.forms[form].action;
    for(i=0; i<document.forms[form].elements.length; i++){
      if (i==0){newURL = newURL + '?m:';}else{newURL = newURL + '*';}
      newURL = newURL + hexcode(document.forms[form].elements[i].name) + '|' + hexcode(document.forms[form].elements[i].value);
    }
    return newURL;
  }

  function JavaScriptSubmitForm(form) {
    //window.location = form2url(form);
    document.forms[form].submit()
  }

  function hexnib(d) {
    if(d<10) {
      return CONVstrs[d];
    }else{
      return String.fromCharCode(65+d-10);
    }
  }

  function hexcode(textCONV) {
     var result="";
     for(var i=0;i<textCONV.length;i++) {
        var cc=textCONV.charCodeAt(i);
        var hex=hexnib((cc&240)>>4)+""+hexnib(cc&15);
        result+=hex;
     }
     return result;
  }

  function form_submit(){
    var ii=1;
    var form = '';
    if (arguments.length>1){form=arguments[0];}
    while (ii < arguments.length){
      document.forms[form].elements[arguments[ii]].value=arguments[ii+1];
      ii=ii+2;
    }
    JavaScriptSubmitForm(form);
    return false;
  }

  function submit_popup(form,w,h){
     //var theUnique = (new Date()).getTime() % 1000000000;
     var ii=3;
     var newURL = document.forms[form].action;
     while (ii < arguments.length){
       document.forms[form].elements[arguments[ii]].value=arguments[ii+1];
       ii=ii+2;
     }

     var theUnique = document.forms[form].action.value;
     document.forms[form].target = 'popupWND'+theUnique;
     var OPWND = NewCenterWindow('about:blank','popupWND'+theUnique,w,h,'yes');

     document.forms[form].submit();
     //OPWND.location = form2url(form);
     return false;
  }

  function submit_menu_popup(form,w,h){
     //var theUnique = (new Date()).getTime() % 1000000000;
     var ii=3;
     var newURL = document.forms[form].action;
     while (ii < arguments.length){
       document.forms[form].elements[arguments[ii]].value=arguments[ii+1];
       ii=ii+2;
     }

     var theUnique = document.forms[form].action.value;
     document.forms[form].target = 'popupWND'+theUnique;
     var OPWND = NewCenterWindow('about:blank','popupWND'+theUnique,w,h,'yes');
     //alert(document.forms[form].target)

     document.forms[form].submit();
  }

  function submit_popupWND(form,wnd,w,h){
     //var theUnique = (new Date()).getTime() % 1000000000;
     var ii=4;
     var newURL = document.forms[form].action;
     while (ii < arguments.length){
       document.forms[form].elements[arguments[ii]].value=arguments[ii+1];
       ii=ii+2;
     }

     var theUnique = document.forms[form].action.value;
     if (theUnique=='user_options_menu'){theUnique='usrOptMenu';}
     //alert(theUnique);
     var OPWND = NewCenterWindow('about:blank',wnd+theUnique,w,h,'yes');
     document.forms[form].target = wnd+theUnique;
     //alert(OPWND);

     document.forms[form].submit();
     //OPWND.location = form2url(form);
     return false;
  }


  function Set_Cookie(name,value,expires) {
    var today = new Date();
    if (expires.indexOf('y') != -1) today.setFullYear(today.getFullYear()+eval(expires.substr(0,expires.indexOf('y'))));
    if (expires.indexOf('h') != -1) today.setHours(today.getHours()+eval(expires.substr(0,expires.indexOf('h'))));
    if (expires.indexOf('m') != -1) today.setMonth(today.getMonth()+eval(expires.substr(0,expires.indexOf('m'))));
    var exp_date = today.toUTCString();
    var domain   = ""+document.location;
    var secure   = '';
    var path     = '/';
    if (domain.indexOf('https://') != -1) secure=";secure";
    domain = document.domain;
    document.cookie = name  + "="+escape(value) +
                      ";expires="+exp_date      +
                      ";path="   +path          +
                      ";domain=" + domain       +
                      secure;
  }

  function NewCenterWindow(mypage,myname,w,h,scroll){
    var winl = (screen.width-w)/2;
    var wint = (screen.height-h)/2 - 20;
    var settings  ='height='+h+',';
       settings +='width='+w+',';
       settings +='top='+wint+',';
       settings +='left='+winl+',';
       settings +='scrollbars='+scroll+',';
       settings +='resizable=yes';
    opened=window.open(mypage,myname,settings);
    opened.opener=window;
    if(parseInt(navigator.appVersion) >= 4){opened.window.focus();}
    newwindowWIDTH  = w;
    newwindowHEIGHT = h;
    newwindowTOP    = wint;
    newwindowLEFT   = winl;
    setWindowProps(document);
    return opened;
  }

  function setWindowProps(doc) {
    //alert('SetDoc'+doc);
    if (doc.informationFORM)
      if (doc.informationFORM.lastwnd) {
        doc.informationFORM.lastwnd.value = newwindowWIDTH+'|'+newwindowHEIGHT+'|'+newwindowTOP+'|'+newwindowLEFT;
        //if (doc.parent) setWindowProps(doc.parent);
      }
    //alert('EndDoc'+doc);
  }

  function changePerPage() {
    document.PAGESform.SQL_START.value='0';
    document.PAGESform.SQL_PAGE.value=document.TEMPperpageFORM.perPage.options[document.TEMPperpageFORM.perPage.selectedIndex].value;
    JavaScriptSubmitForm('PAGESform');
    return true;
  }

  ///////////////////////////////////////////////////
  // XP
  ///////////////////////////////////////////////////
  // Manage "display" style property.
  function setDisplayProperty(labels,state) {
   if(!document.all) return(true);
   var a = new Array();
   var i,label;
   if(typeof(labels) == "string") a[0] = labels;
   else a = labels;
   for(i=0;i<a.length;i++)
    {
     label = a[i];
     var obj = new getObjectBy_ID(label);
     if(obj.obj != 'undefined')
      {
       if(typeof(obj.style.display) != "undefined") obj.style.display = state;
      }
    }
  }

  // Change Text Area size (number of rows)
  function changeTASize(sisa,n,s) {
   if(typeof(sisa) != "undefined" && typeof(sisa.rows) != "undefined")
    {
     var str = new String(sisa.value);
     var ind = str.split("\n");
     var cnt = ind.length;
     for(var i=0;i<ind.length;i++)
      {
       var v = new String(ind[i]);
       if(v.length > 0) { var c = parseInt(v.length/(sisa.cols+1)); cnt += c; }
      }
     ind = cnt;
     if(ind > 1 && ind < s) n = ind;
     else if(n < s && sisa.value != "" && ind > 1) return(true);  
     sisa.rows = n;
    }
  }

  // Makes some form field readonly and disabled on/off.
  function makesReadOnly(fields,bool,color,f) {
   var a = new Array();
   var i,sisa;
   if(typeof(fields.length) == "undefined") a[0] = fields;
   else a = fields;
   for(i=0;i<a.length;i++)
    {
     sisa = a[i];
     if(typeof(sisa) != "undefined")
      {
       if(typeof(sisa.disabled) != "undefined") sisa.disabled = bool;
       if(typeof(sisa.readOnly) != "undefined") sisa.readOnly = bool;
       if(typeof(sisa.style) != "undefined") sisa.style.background = color;
       else if(typeof(sisa.background) != "undefined") sisa.background = color;
      }
    }
   if(f) a[0].focus();
  }

  function getObjectBy_ID(id) {
   this.obj   = 'undefined';
   this.style = 'undefined';
   this.browser = 'undefined';
   this.visible = 'undefined';
   this.hidden  = 'undefined';
   var object;
   if(id == "") return("");
   if(document.getElementById)
    {
     this.browser = "DOM";
     this.visible = "visible";
     this.hidden  = "hidden";
     object = document.getElementById(id);
     if(object)
      {
       this.obj     = object;
       this.style   = object.style;
      }
    }
   else if(document.all)
    {
     this.browser = "IE4x";
     this.visible = "visible";
     this.hidden  = "hidden";
     object = document.all[id];
     if(object)
      {
       this.obj     = object;
       this.style   = object.style;
      }
    }
   else if(document.layers)
    {
     this.browser = "NS4x";
     this.visible = "show";
     this.hidden  = "hide";
     var layer_obj;
     var all_layers = new Array();
     layer_obj = document.layers;
     all_layers = ArrayPush(layer_obj,all_layers);
     while(all_layers.length)
      {
       next_layers = all_layers[0];
       all_layers = ArrayShift(all_layers);
       for (i=0; i< next_layers.length; i++)
        {
         if(next_layers[i].id == id)
          {
           this.obj     = next_layers[i];
           this.style   = next_layers[i];
           return("");
          }
         if(next_layers[i].layers)
          {
           if(next_layers[i].layers.length)
            {
             all_layers[all_layers.length] = next_layers[i].layers;
            }
          }
        }
      }
    }
   return(true);
  }

  function TABLEColorChange(tblid) {
    var TABLECOLOR  = '#D0D0FF';
    document.getElementById(tblid).style.backgroundColor=TABLECOLOR;
  }
  function TABLEColorClear(tblid) {
    document.getElementById(tblid).style.backgroundColor='';
  }

  function pause(Amount) {
    d = new Date() //today's date
    while (1) {
      mill=new Date() // Date Now
      diff = mill-d //difference in milliseconds
      if( diff > Amount ) {break;}
    }
  }

  function printIt(st) {
    if (st) {
      factory.printing.header = st;
    }else{
      /*
      if (document.title){
        factory.printing.header = document.title
      }else{
        factory.printing.header = "Alpha Security";
      }
      */
      factory.printing.header = "";
    }
    factory.printing.footer = "";
    factory.printing.portrait = false;
    factory.printing.Preview();
    window.onerror = onerr;
  }


  getObjectBy_ID.prototype.getObjectBy_ID = getObjectBy_ID;


