function isEmpty(theField)
{
    //trim leading spaces
    var ret=true;
    var i,len,temp;

    if (theField == null) return true;
    
    if ((theField.value == "") || (theField.value.length == 0))
    {
        return true;
    }
    else
    {
        len = theField.value.length;
        for (i=0; i<len; i++)
        {
            temp = theField.value.substr(i, 1);
            if (temp!=" " && temp!="\t")
            {
                ret = false;
                break;
            }
        }
        return ret;
    }
}

function Open()
{
  if(isEmpty(checkusage.userId) || isEmpty(checkusage.passWord))
  {
    alert("Invalid Userid or Password entered. Please ensure your password do not contain |, @, %, &, #. Otherwise, please change your password before trying again.");
    return false;
  }

  scrWidth = screen.availWidth*0.9;
  scrHeight = screen.availHeight*0.9;

  win=window.open('','CheckConnectionUsage','width='+scrWidth+',height='+scrHeight+',toolbar=no,menubar=no,resizable=no,location=no,directories=no,scrollbars=yes,status=yes,top=0,left=0');
  win.focus();
}

function Logout()
{
    if(win && win.open && !win.closed) win.close();
    window.location='mya_logout.jsp';
    window.reload();
}

function StaffOpen()
{
  if(isEmpty(checkusage.userId))
  {
    alert("Invalid Userid or Password entered. Please ensure your password do not contain |, @, %, &, #. Otherwise, please change your password before trying again.");
    return false;
  }

  scrWidth = screen.availWidth*0.9;
  scrHeight = screen.availHeight*0.8;
  
  var win=window.open('','CheckConnectionUsage','width='+scrWidth+',height='+scrHeight+',toolbar=yes,menubar=yes,resizable=no,location=no,directories=no,scrollbars=yes,status=yes,top=0,left=0');
  win.focus();
}

function SessionLogout()
{
  window.open("sessioninvalidate.jsp","CheckConnectionUsage");
}

function SaveFrame(name)
{
  name.document.execCommand('SaveAs',true,'');
}

function PrintFrame(name)
{
  name.focus();
  name.print();
}