// Identify Products
var IsAuthoring          = window.location.href.indexOf("/Authoring/") != -1;
var IsDefaultData        = window.location.href.indexOf("/DefaultData/") != -1;
var IsDGS                = window.location.href.indexOf("/DGS/") != -1;
var IsDocViewer          = window.location.href.indexOf("/DocViewer/") != -1;
var IsEDP                = window.location.href.indexOf("/DocumentPortal/") != -1;
var IsEDS                = window.location.href.indexOf("/WK-Hosted-Expere/") != -1;
var IseOriginal          = window.location.href.indexOf("/eOriginal/") != -1;
var IsESign              = window.location.href.indexOf("/WoltersKluwer_E-Sign/") != -1;
var IsEZGateway          = window.location.href.indexOf("/ExpereEZConfig/EZGateway/") != -1;
var IsEngine             = window.location.href.indexOf("/Engine/") != -1;
var IsI32                = window.location.href.indexOf("/I-32/") != -1;
var IsOPPSA              = window.location.href.indexOf("/OPPSA/") != -1;
var IsPackagesAndPackets = window.location.href.indexOf("/ExpereEZConfig/PackagesAndPackets/") != -1;
var IsWKIS               = window.location.href.indexOf("/WK-IntegratedSolutions/") != -1;
var IsHosted             = window.location.href.indexOf("audience=hosted") != -1;
var IsInstalled          = window.location.href.indexOf("audience=installed") != -1;

// Generic variables
var ProductLandingPage = "";
var ProductName = "";
var IsRN = "";
var IncRNLink = '';
var ChangelogLink = "";

if (IsAuthoring){   //if Expere Authoring then
    ProductName             = "Expere Authoring";
    ProductLandingPage      = "/Expere/Authoring/index.html";
    IncRNLink               = "yes";
    ChangelogLink           = "/Expere/Authoring/ReleaseNotes/webhelp/index.html";
    // Changelogs
    IsRN                    = ChangelogLink;
    // User Guides
    var IsReUG 	            = window.location.href.indexOf("Authoring/RequirementsEditor") != -1;
    var IsAdminUG 			= window.location.href.indexOf("Authoring/AdministrationTool/webhelp") != -1;
    var IsDdvUG 	   		= window.location.href.indexOf("Authoring/DDV") != -1;
    var IsAuthInstallUG     = window.location.href.indexOf("Authoring/EngineInstallation") != -1;
}

if (IsDefaultData){ //if Default Data then
    ProductName             = "Default Data";
    if(IsHosted){
        console.log("IsHosted = " + IsHosted);
        ProductLandingPage  = "/WK-Hosted-Expere/";
    }
    if(IsInstalled){
        console.log("IsInstalled = " + IsInstalled);
        ProductLandingPage  = "/DGS/";
    }
    IncRNLink               = "yes";
    ChangelogLink           = "/ExpereEZConfig/DefaultData/Changelogs/index.html";
    IsRN                    = window.location.href.indexOf("/DefaultData/Changelogs") != -1;
    // User Guides
    var IsDD_InstallGuide   = window.location.href.indexOf("/DefaultData/InstallationGuide") != -1;
    var IsDD_UpgradeGuide   = window.location.href.indexOf("/DefaultData/UpgradeGuide") != -1;
    var IsDD_USerGuide      = window.location.href.indexOf("/DefaultData/UserGuide") != -1;
    var IsDD_WebServGuide   = window.location.href.indexOf("/DefaultData/WebServicesGuide") != -1;
}

if (IsPackagesAndPackets){ //if Packages and Packets then
    ProductName             = "Packages and Packets";
    if(IsHosted){
        console.log("IsHosted = " + IsHosted);
        ProductLandingPage  = "/WK-Hosted-Expere/";
    }
    if(IsInstalled){
        console.log("IsInstalled = " + IsInstalled);
        ProductLandingPage  = "/DGS/";
    }
    IncRNLink               = "yes";
    ChangelogLink           = "/ExpereEZConfig/PackagesAndPackets/Changelog/index.html";
    IsRN                    = window.location.href.indexOf("/PackagesAndPackets/Changelog") != -1;
    // User Guides
    var IsPnP_InstallGuide   = window.location.href.indexOf("/ExpereEZConfig/InstallGuide") != -1;
    var IsPnP_UpgradeGuide   = window.location.href.indexOf("/PackagesAndPackets/UpgradeGuide") != -1;
    var IsPnP_USerGuide      = window.location.href.indexOf("/PackagesAndPackets/UserGuide") != -1;
    var IsPnP_WebServGuide   = window.location.href.indexOf("/ExpereEZConfig//WebservicesGuide") != -1;
}

if (IsDGS){         //if DGS then
    ProductName             = "Document Generation Services";
    ProductLandingPage      = "/DGS/";
    IncRNLink               = "yes";
    ChangelogLink           = "/DGS/Change-Log/index.html";
    // Changelogs
    IsRN                    = window.location.href.indexOf("/DGS/Change-Log") != -1;
    // User Guides
    var IsDGS_Changelog     = window.location.href.indexOf("/DGS/Change-Log/") != -1;
}

if (IsDocViewer){   //if DocViewer then
    ProductName             = "DocViewer";
    if(IsHosted){
        ProductLandingPage  = "/WK-Hosted-Expere/";
    }
    if(IsInstalled){
        ProductLandingPage  = "/DGS/";
    }
    IncRNLink               = "yes";
    ChangelogLink           = "/DocViewer/ReleaseNotes/index.html";
    // Changelogs
    IsRN                    = window.location.href.indexOf("/DocViewer/ReleaseNotes") != -1;
    // User Guides
    
}

if (IsEDP){         //if EDP then
    ProductName             = "Document Portal";
    if(IsHosted){
        ProductLandingPage  = "/WK-Hosted-Expere/";
    }
    if(IsInstalled){
        ProductLandingPage  = "/DGS/";
    }
    IncRNLink               = "yes";
    ChangelogLink           = "/DocumentPortal/UserGuide/index.html";
    // Changelogs
    IsRN                    = window.location.href.indexOf("/DocumentPortal/UserGuide/topics/edp_Change-Log-Overview.html") != -1;
    // User Guides
    var IsUserGuide         = window.location.href.indexOf("DocumentPortal/UserGuide") != -1;

}

if (IsEngine){      //if Expere Engine then
    ProductName             = "Expere Engine";
    ProductLandingPage      = "/Expere/Engine/";
    IncRNLink               = "yes";
    ChangelogLink           = "/Expere/Engine/Change-Log";
    // Changelogs
    IsRN                    = window.location.href.indexOf("Engine/Change-Log") != -1;
    // User Guides
    // Install and Upgrade Guides
    // OD-Related Install Guides
}

if (IseOriginal){   //if eOriginal then
    console.log("IseOriginal = " + IseOriginal);
    ProductName             = "eOriginal";
    if(IsHosted){
        ProductLandingPage  = "/WK-Hosted-Expere/";
    }
    if(IsInstalled){
        ProductLandingPage  = "/DGS/";
    }
    IncRNLink               = "yes";
    ChangelogLink           = "/WK-Hosted-Expere/Change-Log/index.html";
    // Changelogs
    IsRN                    = window.location.href.indexOf("/WK-Hosted-Expere/Change-Log") != -1;
    // User Guides
    var IsQuickGuide     = window.location.href.indexOf("eOriginal/QuickGuide") != -1;

}

if (IsEZGateway){   //if EZGateway then
    ProductName             = "EZGateway";
    ChangelogLink           = "/ExpereEZConfig/EZGateway/Changelogs/index.html";
    IsRN                    = window.location.href.indexOf("/EZGateway/ChangeLogs") != -1;
    if (IsRN){
        IncRNLink = "no";
    }
    else{
        IncRNLink = "yes";
    }
    if(IsHosted){
        console.log("IsHosted = " + IsHosted);
        ProductLandingPage  = "/WK-Hosted-Expere/";
    }
    if(IsInstalled){
        console.log("IsInstalled = " + IsInstalled);
        ProductLandingPage  = "/DGS/";
    }
}

if (IsI32){         //if I-32 then
    ProductName             = "I-32";
    ProductLandingPage      = "/I-32/";
    IncRNLink               = "yes";
    ChangelogLink           = "/I-32/Changelog/index.html";
    // Changelogs
    IsRN                    = ChangelogLink;
    // User Guides
    var IsFormsDesignUG     = window.location.href.indexOf("I-32/FormsDesignUserGuide") != -1;
    var IsImageUpdateUG     = window.location.href.indexOf("I-32/ImageUpdate") != -1;
    // Install and Upgrade Guides
    // OD-Related Install Guides
}

if (IsOPPSA){       //if OPPSA then
    ProductName             = "OPPSA";
    ProductLandingPage      = "/DGS/";
    IncRNLink               = "yes";
    ChangelogLink           = "/OPPSA/ChangeLog/index.html";
    // Changelogs
    IsRN                    = window.location.href.indexOf("/OPPSA/ChangeLog") != -1;
    // User Guides
    var IsOPPSA_UserGuide   = window.location.href.indexOf("/OPPSA/UserGuide/") != -1;
}

//
// TECH SHARE - FILL OUTWHIS TO FINALIZE THIS PAGE
//
if (IsWKIS){       //if WKIS  then
    ProductName             = "OPPSA";
    ProductLandingPage      = "/DGS/";
    IncRNLink               = "yes";
    ChangelogLink           = "/OPPSA/ChangeLog/index.html";
    // Changelogs
    IsRN                    = window.location.href.indexOf("/OPPSA/ChangeLog") != -1;
    // User Guides
    var IsOPPSA_UserGuide   = window.location.href.indexOf("/OPPSA/UserGuide/") != -1;
}



// console.log("ProductName = " + ProductName + "\n" +
//             "ProductLandingPage = " + ProductLandingPage + "\n" +
//             "ChangelogLink = " + ChangelogLink  + "\n" +
//             "isRN " + IsRN + "\n");

$('#searchForm').append('<div class="ChangelogLink"><a href="' + ProductLandingPage + '" index.html" target="_blank">View ' + ProductName + ' Documentation Page</a>');

$('.ChangelogLink').css({
    'display':'block',
    'position':'absolute',
    'text-align':'end',
    'right':'-25px',
    'top':'40px',
    'font-size':'1.5rem'
});

if (IncRNLink == "yes" && !(IsRN) ){
    $('.ChangelogLink').append(' <span style="color: black">   |   </span> '  +
        '<a href="' + ChangelogLink + '" target="_blank">View Changelog</a></div>');
};
