function OnOCXError ()
{
  document.location.href = "../../Files/OCXError.htm";
}

/* This function returns default WebSignature object */
function GetWebSign()
{
  var oSD;
  oSD = WebSignature;
  if (oSD == null)
    oSD = document.getElementById("WebSignature")
  return oSD;
}

/* We call this function as a test to verify control is properly loaded and working */
function OnPageLoad ()
{
  try
  {
    OnClear();
  }
  catch(e)
  {
    /* If the control has not been loaded - we open ActiveX installation page */
    document.location.href = "../../Files/PPCInstall.htm";
  }
}

function InsertWebSign(sAttrs, sParams)
{
  document.writeln('<OBJECT id="WebSignature" name="WebSignature" ' + sAttrs);
  document.write('onerror="OnOCXError()"');
  document.write('classid="clsid:4E534257-3000-4E22-83A5-AD614CB96642"');
  try
  {
    if (window.navigator.platform == "Win64")
      document.write('CODEBASE="../../Files/WebSign.x64.CAB#version=1,0,16">');
    else
      document.write('CODEBASE="../../Files/WebSign.x86.CAB#version=1,0,16">');
  }
  catch(e)
  {
    document.write('CODEBASE="../../Files/WebSign.i386.CAB#version=1,0,16">');
  }
  document.write(sParams);
  document.writeln('</OBJECT>');
}

/* Clear default WebSignature content */
function OnClear ()
{
  GetWebSign().Clear();
}

/* Submit the content of default WebSignature object to the specified URL */
function OnSubmit (sURL, sPar)
{
  GetWebSign().Submit(sURL, sPar);
}
