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
  {
    if (GetWebSign().Version < 20000)
    {
      /* Old version of WebSignature is already installed */
      document.location.href = "../../Files/PPCUpdate.htm";
      return;
    }
    GetWebSign().Clear();
  }
  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=2,0,3">');
    else
      document.write('CODEBASE="../../Files/WebSign.x86.CAB#version=2,0,3">');
  }
  catch(e)
  {
    document.write('CODEBASE="../../Files/WebSign.i386.CAB#version=2,0,3">');
  }
  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)
{

  objWebSignature = GetWebSign();

  if  ( objWebSignature.valid== true ) 
  {  
     objWebSignature.Submit(sURL, sPar) ;      
  }
  else
  {  
     alert("You must sign before hitting submit ") ;  
  }

}
