﻿// JScript File

function encyclopedia(definitionId, openNewWindow)
{
    // redirect and pull the correct definition
    //#1. check for integer
    var returnURL = null;
    var encyclopediaURL = "http://healthlibrary.epnet.com/GetContent.aspx?token=1edc3d6e-4fec-4b20-baca-795e48830daa&chunkiid=";
    // validating whether the user passes in an integer.  user can pass in a url by accident or something else
    var isInteger =  /^-?\d+$/.test(definitionId);
    if(isInteger)
    {
        returnURL = encyclopediaURL + definitionId;
    }
    else
    {
        returnURL = definitionId;
    }
    
    if (openNewWindow)
        window.open(returnURL);
    else
        window.location.href = returnURL;
    
}