﻿// JScript File

function KrdCertificate_Execute() {
  var el = document.getElementById('bExecute');
  el.click();
}

function MerissaVerification(krs) {
    var path;

    path = "http://www.krs-online.com.pl/?p=6&look=" + krs;

    window.open(path, "", "");
}

function MerissaRules() {
    var path;

    path = "Code.aspx";

    window.open(path, "", "");
}

function MerissaCompanyPreview(banner) {
    var path;

    path = "CompanyPreview.aspx?Banner=" + banner;

    window.open(path, "", "");
}

function MerissaSearchBanner(banner) {
    var path;

    path = "Report.aspx?Banner=" + banner;

    var sOptions;
    sOptions = 'menubar=no,toolbar=no,location=no,resizable=yes,scrollbars=yes';
    sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString();
    sOptions = sOptions + ',height=' + (screen.availHeight - 30).toString();
    sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';

    var wOpen;
    wOpen = window.open(path, "", sOptions);
    wOpen.focus();
    wOpen.moveTo(0, 0);
    wOpen.resizeTo(screen.availWidth, screen.availHeight);

}

function MerissaSearchBannerECR(banner) {
    var path;

    path = "ReportECR.aspx?Banner=" + banner;

    var sOptions;
    sOptions = 'menubar=no,toolbar=no,location=no,resizable=yes,scrollbars=yes';
    sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString();
    sOptions = sOptions + ',height=' + (screen.availHeight - 30).toString();
    sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';

    var wOpen;
    wOpen = window.open(path, "", sOptions);
    wOpen.focus();
    wOpen.moveTo(0, 0);
    wOpen.resizeTo(screen.availWidth, screen.availHeight);
  }

function MerissaPutComment(banner) {
    var path;

    path = "PutComment.aspx?banner=" + banner;

    window.open(path, "", "");
}

function MerissaViewComments(banner) {
    var path;

    path = "ViewComments.aspx?banner=" + banner;

    window.open(path, "", "");
}

function MerissaSearchCertificate()
{
  var path, obj;
  obj = kc_findObj("ctl00_DefaultContent_certificateNumber");
    
  if (obj != null && obj.value.length != 0)
  {
    path = "Report.aspx?Certificate=" + obj.value;

    var sOptions;
    sOptions = 'menubar=no,toolbar=no,location=no,resizable=yes,scrollbars=yes';
    sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString();
    sOptions = sOptions + ',height=' + (screen.availHeight - 30).toString();
    sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';

    var wOpen;
    wOpen = window.open(path, "", sOptions);
    wOpen.focus();
    wOpen.moveTo(0, 0);
    wOpen.resizeTo(screen.availWidth, screen.availHeight);
  }
  
  return false;
}    

function MerissaSearchCardNumber()
{
  var path, obj, lang, langSymbol, i;
  obj = kc_findObj("ctl00_DefaultContent_certificateNumber");
  //lang = kc_findObj("ctl00_DefaultContent_rblLanguage");
  
  if (obj != null && obj.value.length != 0)
  {
    for (i=0; i < 10; i++) 
    {
      lang = kc_findObj("ctl00_DefaultContent_rblLanguage_" + i.toString());
      if (lang.checked)
      {
        langSymbol = lang.defaultValue;
        break;
      }
    }
  
    if (langSymbol == null)
      langSymbol = "PL";
    path = "Report.aspx?CardNumber=" + obj.value + "&language=" + langSymbol;

    var sOptions;
    sOptions = 'menubar=no,toolbar=no,location=no,resizable=yes,scrollbars=yes';
    sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString();
    sOptions = sOptions + ',height=' + (screen.availHeight - 30).toString();
    sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';

    window.open(path, "", sOptions);
  }
  
  return false;
}

/*
function DownloadCertificate(cardNumber)
{
  window.location.href = 'DownloadCertificate.aspx?CardNumber=' + cardNumber;
}
*/

function Resize(width, height)
{
  window.resizeTo(width, height);
}

function CloseWindow()
{
  window.close();
}

function kc_findObj(theObj, theDoc)
{
  var p, i, foundObj;
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = kc_findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  return foundObj;
}
