// JavaScript Document
// check for privacy settings 
var ewwsetp = "notset"; // declare variable so test can fail if it was not set correctly in the ewws.js include file

//get current page name into thispagename
var thispgname = new String(window.location.href);
if( thispgname.lastIndexOf( "/" ) != -1 ) {
  thispgname = thispgname.substring( thispgname.lastIndexOf( "/" ) + 1, thispgname.length );
  }
if( thispgname == "") thispgname = "index"; // in case called from root page
  
function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

//set up a variable with the include filename to look for based on current page name
var includename = replace(thispgname, '.htm', '');
includename = includename + ".js";
document.write("<script src=\"./cjs/" + includename + "\"></script>");
