﻿function checkTextAreaMaxLength(textBox, e, length) {
  var mLen = textBox["MaxLength"];
  if (null == mLen)
    mLen = length;

  var maxLength = parseInt(mLen);
  if (!checkSpecialKeys(e)) {
    if (textBox.value.length > maxLength - 1) {
      if (window.event)//IE
        e.returnValue = false;
      else//Firefox
        e.preventDefault();
    }
  }
}

function checkSpecialKeys(e) {
  if (e.keyCode != 8 && e.keyCode != 46 && e.keyCode != 37 && e.keyCode != 38 && e.keyCode != 39 && e.keyCode != 40)
    return false;
  else
    return true;
}

/***************************************** Reports *************************************************/

function CallPrint(strid, title, printBtn, closeBtn) 
{
  var prtContent = document.getElementById(strid);
  var WinPrint = window.open('', '', 'letf=0,top=0');

  //Adding HTML opening tag with <HEAD> … </HEAD> portion 
  WinPrint.document.writeln('<html>');
  WinPrint.document.writeln('<head>');
  WinPrint.document.writeln('<title>' + title + '');
  WinPrint.document.writeln('</title>');
  WinPrint.document.writeln('</head>');

  //Adding Body Tag
  WinPrint.document.writeln('<body>');

  //Adding form Tag
  WinPrint.document.writeln('<form method="post">');

  //Creating two buttons Print and Close within a HTML table 
  WinPrint.document.writeln('<table width=100%><tr><td></td></tr><tr><td align=right>');
  WinPrint.document.writeln('<input id="PRINT" class="btnbg" style="width:90px; height:22px; background-color:Transparent;" type="button" value="' + printBtn + '" ');
  WinPrint.document.writeln('onclick="javascript:location.reload(true);window.print();">');
  WinPrint.document.writeln('<input id="CLOSE" class="btnbg" style="width:90px; height:22px; background-color:Transparent;" type="button" ' + 'value="' + closeBtn + '" onclick="window.close();">');
  WinPrint.document.writeln('</td></tr><tr><td></td></tr></TABLE>');

  //Writing print area of the calling page
  WinPrint.document.writeln(prtContent.innerHTML);
  WinPrint.document.writeln('</body>');
  WinPrint.document.writeln('</html>');
  WinPrint.document.close();
  WinPrint.focus();
}

/***************************************** End Reports *************************************************/

function ShowLoading(id) 
{
  try 
  {
    var loader = document.getElementById(id);
    if (loader) 
    {
      loader.style.visibility = "visible";
      loader.style.display = "block";
    }
  }
  catch (e) { }
}

function keyDown(id) {
    var KeyID = event.keyCode;
    if (KeyID == 46) {
        try {
            __doPostBack(id, "");
        }
        catch (e) { }
    }
}