//========================================================================
// *** THIS FILE IS GENERATED-- DO NOT MODIFY ***
//
// commands.js
//
// Contains the JavaScript functions used by WebPub.
// WARNING: Do not modify this file!  Add your custom code to CUSTOM.JS
//
// Generated by: WebPub Generate Process HTML
//               Version 8.6.6
// Generated on: Friday, May 11, 2001
//
// Copyright © 1996-2000 Computer Associates International, inc.  All rights reserved.
//
//========================================================================

// Frames Generation: Called when F_ doc is fully loaded. Do init stuff here
function MainPageLoaded(obj) {
   if(window.name != TARGET_MAIN)
      window.name = TARGET_MAIN;
   FixupNavbarButtons(obj);
}

// NoFrames Generation: Called when A_ doc is fully loaded. Do init stuff here
function MainPageLoadedNoFrames(obj) {
   if(window.name != TARGET_MAIN)
      window.name = TARGET_MAIN;
   FixupNavbarButtons(obj);
}

// Technique Frames Generation: Called when F_ doc is fully loaded. Do init stuff here
function TechMainPageLoaded(obj) {
   if(window.name != TARGET_TECHNIQUE)
      window.name = TARGET_TECHNIQUE;
   FixupNavbarButtons(obj);
}

// Technique NoFrames Generation: Called when A_ doc is fully loaded. Do init stuff here
function TechMainPageLoadedNoFrames(obj) {
   if(window.name != TARGET_TECHNIQUE)
      window.name = TARGET_TECHNIQUE;
   FixupNavbarButtons(obj);
}


// Navbar: Enable/Disable navigation buttons based on link validity.
function FixupNavbarButtons(obj)
{
    var sip = GetImagePath();
    var sP  = sip + ((_sLinkParent != "") ? IMAGE_NAVBAR_PARENT : IMAGE_NAVBAR_PARENTX);
    var sPS = sip + ((_sPrevSib != "") ? IMAGE_NAVBAR_PREVSIB : IMAGE_NAVBAR_PREVSIBX);
    var sNS = sip +((_sNextSib != "") ? IMAGE_NAVBAR_NEXTSIB : IMAGE_NAVBAR_NEXTSIBX);
    var sPA = sip + ((_sPrevAct != "") ? IMAGE_NAVBAR_PREVACT : IMAGE_NAVBAR_PREVACTX);
    var sNA = sip + ((_sNextAct != "") ? IMAGE_NAVBAR_NEXTACT : IMAGE_NAVBAR_NEXTACTX);

    // update the navigation images.
    obj.document.Parent.src  = sP;  // gif- parent act
    obj.document.PrevSib.src = sPS; // gif- prev sibling
    obj.document.NextSib.src = sNS; // gif- next sibling
    obj.document.PrevAct.src = sPA; // gif- prev activity
    obj.document.NextAct.src = sNA; // gif- next activity
}

// Navbar: Process Nav button click.
// s = dest URL for the clicked Navbar button.  Does nothing if empty.
function NavbarClick(obj, s)
{
   if(s != "")
   {
      obj.href=s;
   }
}


// Get client browser Name and Version.
// Returns: "NS4"   - NetScape 4.x or greater
//          "NS"    - Netscape versions prior to 4
//          "IE4"   - Internet Explorer 4.x or greater
//          "IE"    - Internet Explorer versions prior to 4
//          "other" - All other browsers (Opera, Mosaic, etc.)
function CheckBrowser() {
  var sName = navigator.appName;
  var sVer  = parseInt(navigator.appVersion);
  var sRet  = "other";  // default retval
  //
  if (sName == "Netscape") {
    sRet = ((sVer<4) ? "NS" : "NS4");
  }
  else if (sName == "Microsoft Internet Explorer") {
    sRet = ((sVer<4) ? "IE" : "IE4");
  }
  return sRet;
}

// Open a child window.  Try to tell it who opened it.
// Currently just a wrapper for window.open().
function OpenNewWindow(windowURL,windowName,windowArgs,windowOrigin)
{
   var child;
   if(windowArgs != '')
      child = open(windowURL,windowName,windowArgs)
   else
      child = open(windowURL,windowName)
   if(child != null)  child.window.focus();  // bring to top
   //child.opener = window;
   //child.opener.name = windowOrigin;
   //return child;
}


// builds an array...
function CreateArray()
{
var intCount;

this.length = CreateArray.arguments.length
for (var intCount = 0; intCount< this.length; intCount++){
  this[intCount+1] = CreateArray.arguments[intCount];
  }
}


//Returns the number of chars in a string.
function Len(string1)
{
  var iLen
  iLen=string1.length;
  return iLen;
}


//Returns specified number of chars from left side of string.
function Left(string1,stringlen)
{
  var string2
  string2=string1.substr(0,stringlen);
  return string2;
}


//Returns specified number of chars from right side of string.
function Right(string1,stringlen)
{
  var string2
  string2=string1.substr(-stringlen,stringlen);
  return string2;
}


//Returns position of first occurrence of one string within another.
function InStr(start,string1,string2)
{
  var string3=""
  if (start > 0)     //start should never be null
  {
    if (start <= string1.length)
    string3 = string1.slice(start-1,string1.length);
  }
  if (string3 != "")
  {
    //trap for dots \'cause they don\'t work otherwise
    if (string2 == ".")
      return string3.search(/\./);
    else
      return string3.search(string2);
  }
  else return "";
}


//Returns just the path of an URL
function fnGetPath(strPath)
{
  iStart=1;
  do
  {
    iLast=InStr(iStart,strPath,"/")+1;
    iStart=iStart+iLast;
  }
  while (iLast !=0);
  iLast=iStart-1;
  return strPath.slice(0,iLast);
}


//---------------------------------------------------------------
// For MVB Replacement.
// Usage: <SCRIPT>IR(\'myimage.gif\')</SCRIPT>
//
// Write an IMG tag with specified image name.
// IN:
//    strImage:  Contains an image name (GIF file name)
//---------------------------------------------------------------
function IR(strImage)
{
  document.writeln("<CENTER><IMG SRC='",GetImagePath(),strImage,"' BORDER=0 ALT='",strImage,"'></CENTER>");
}


//---------------------------------------------------------------
// For MVB Replacement.
// Usage: <SCRIPT>IRE(\'myimage.gif\',\'alt=hi\')</SCRIPT>
//
// Write an IMG tag with specified image name and properties.
// IN:
//    strImage:  Contains an image name (GIF file name)
//    strExtra:  Can be an empty string or image tags,
//               i.e., width,alt.
// ALT and BORDER will be set to defaults unless overriden  in strExtra
//---------------------------------------------------------------
function IRE(strImage,strExtra)
{
  var s = "";
  var sTest = strExtra.toLowerCase();
  if(sTest.indexOf("alt") == -1)
    s = s+" ALT='"+strImage+"'";
  if(sTest.indexOf("border") == -1)
    s = s+" BORDER=0 ";
  document.writeln("<CENTER><IMG SRC='",GetImagePath(),strImage,"' ",s,strExtra,"></CENTER>");
}


//---------------------------------------------------------------
// Launches files from user-defined text fields based on prefixes.
//
// This function is passed a filename, which it links to,
// based on the filename prefix.
//
//---------------------------------------------------------------
function ShowThis(strFileName)
{
  var strPrefix;
  var strPath;
  var strSuffix;
  var strArgs;
  var iDot;
  var iExtLen;

  //Get the extension plus the dot
  iDot=InStr(1,strFileName,".");
  if (iDot > 0)
    iExtLen=strFileName.length - iDot;
  else
    iExtLen=0;

  strSuffix = strFileName.substr((strFileName.length-iExtLen),iExtLen);
  strSuffix = strSuffix.toLowerCase();
  strFileName = strFileName.toLowerCase();

  //If the extension is null, default to htm and add to filename
  if (strSuffix == "")
  {
    strSuffix = ".htm";
    strFileName = strFileName.substr(0,strFileName.length) + ".htm";
  }

  //If the extension is mvb, replace it with htm
  if (strSuffix.toLowerCase() == ".mvb")
  {
    strFileName = strFileName.substr(0,strFileName.length -4) + ".htm";
    strSuffix = ".htm";
  }

  strPrefix = strFileName.substr(0,2);
  switch (strPrefix.toLowerCase())
  {
  case "a_":        //Adapting
    strPath=GetOtherPath() + strFileName;
    strTarget=TARGET_OTHER;
    strArgs=ATTR_EXTERNAL;
    fFoundIt=true;
    break;
  case "t_":        //Template
    strFileName = strFileName.substr(0,strFileName.length-strSuffix.length);
    strPath=GetTemplatePath() + strFileName + "/index.htm";
    strTarget=TARGET_TEMPLATE;
    strArgs="";
    fFoundIt=true;
    break;
  case "k_":          //Kernel
    strFileName = strFileName.substr(0,strFileName.length-strSuffix.length);
    strPath=GetKernelPath() + strFileName + "/index.htm";
    strTarget=TARGET_KERNEL;
    strArgs="";
    fFoundIt=true;
    break;
  case "q_":          //Technique
    strPath=GetTechniquePath() + strFileName;
    strTarget=TARGET_TECHNIQUE;
    strArgs=ATTR_EXTERNAL;
    fFoundIt=true;
    break;
  case "c_":          //Concept
    strPath=GetOtherPath() + strFileName;
    strTarget=TARGET_OTHER;
    strArgs=ATTR_EXTERNAL;
    fFoundIt=true;
    break;
  default:
    strPath=GetOtherPath() + strFileName;
    strTarget=TARGET_OTHER;
    strArgs=ATTR_EXTERNAL;
  }

  // Look for items with two chars as prefix
  strPrefix = strFileName.substr(0,3);
  switch (strPrefix.toLowerCase())
  {
  case "ad_":       //Active Deliverable
    strPath=GetAdPath() + strFileName;
    strTarget=TARGET_OTHER;
    strArgs=ATTR_EXTERNAL;
    break;
  case "gd_":       //Guidelines
    strPath=GetOtherPath() + strFileName;
    strTarget=TARGET_OTHER;
    strArgs=ATTR_EXTERNAL;
    break;
  case "wp_":       //white paper
    strPath=GetAdPath() + strFileName;
    strTarget=TARGET_OTHER;
    strArgs=ATTR_EXTERNAL;
    break;
  }

  //Based on the suffix, determine how to launch item
  switch (strSuffix.toLowerCase())
  {
  case ".htm":
    if(strArgs != "")
      child=window.open(strPath, strTarget,strArgs);
    else
      child=window.open(strPath, strTarget);
    if(child != null)  child.window.focus();  // bring to top
    break;
  case ".html":
    if(strArgs != "")
      child=window.open(strPath, strTarget,strArgs);
    else
      child=window.open(strPath, strTarget);
    if(child != null)  child.window.focus();  // bring to top
    break;
  default:
    window.location.href=strPath;
  }
}


//---------------------------------------------------------------
// Launches Products from input/output activity properties.
//
//---------------------------------------------------------------
function ShowDocument(strFileName)
{
  var strPrefix;
  var strPath;
  var strSuffix;
  var strArgs;
  var iDot;
  var iExtLen;

  //Get the extension plus the dot
  iDot=InStr(1,strFileName,".");
  if (iDot > 0)
    iExtLen=strFileName.length - iDot;
  else
    iExtLen=0;

  strSuffix = strFileName.substr((strFileName.length-iExtLen),iExtLen);
  strSuffix = strSuffix.toLowerCase();
  strFileName = strFileName.toLowerCase();

  //If the extension is null, default to htm and add to filename
  if (strSuffix == "")
  {
    strSuffix = ".htm";
    strFileName = strFileName.substr(0,strFileName.length) + ".htm";
  }
  //If the extension is mvb, replace it with htm
  //strSuffix = strFileName.substr(-4,4);
  if (strSuffix.toLowerCase() == ".mvb")
  {
    strFileName = strFileName.substr(0,strFileName.length -4) + ".htm";
    strSuffix = ".htm";
  }

  strPrefix = strFileName.substr(0,2);
  switch (strPrefix.toLowerCase())
  {
  case "q_":          //Technique
    strPath=GetTechniquePath() + strFileName;
    strTarget=TARGET_TECHNIQUE;
    strArgs=ATTR_EXTERNAL;
    fFoundIt=true;
    break;
  default:
    strPath=GetAdPath() + strFileName;

    strTarget=TARGET_OTHER;
    strArgs=ATTR_EXTERNAL;
  }


  //Based on the suffix, determine how to launch item
  switch (strSuffix.toLowerCase())
  {
  case ".htm":
    if(strArgs != "")
      child=window.open(strPath, strTarget,strArgs);
    else
      child=window.open(strPath, strTarget);
    if(child != null)  child.window.focus();  // bring to top
    break;
  case ".html":
    if(strArgs != "")
      child=window.open(strPath, strTarget,strArgs);
    else
      child=window.open(strPath, strTarget);
    if(child != null)  child.window.focus();  // bring to top
    break;
  default:
    window.location.href=strPath;  //open in place
  }
}


//---------------------------------------------------------------
// Launches Techniques from technique activity property.
//
//---------------------------------------------------------------
function ShowTechnique(strFileName)
{
  var strSuffix;

  //If the extension is mvb, replace it with htm
  strSuffix = strFileName.substr((strFileName.length-4),4);
  if (strSuffix.toLowerCase() == ".mvb")
  {
    strFileName = strFileName.substr(0,strFileName.length -4) + ".htm"
    strSuffix = ".htm"
  }

   if(strFileName.indexOf("/") == -1)    // trap for paths already on name
      strPath=GetTechniquePath() + strFileName;
   else
      strPath=strFileName;
   
   strTarget=TARGET_TECHNIQUE;
   strArgs=ATTR_EXTERNAL;

  //based on the suffix, determine what to do
  switch (strSuffix.toLowerCase())
  {
  case ".htm":
    if(strArgs != "")
      child=window.open(strPath, strTarget,strArgs);
    else
      child=window.open(strPath, strTarget);
    if(child != null)  child.window.focus();  // bring to top
    break;
  case "html":
    if(strArgs != "")
      child=window.open(strPath, strTarget,strArgs);
    else
      child=window.open(strPath, strTarget);
    if(child != null)  child.window.focus();  // bring to top
    break;
  default:
    window.location.href=strPath;  //open in place
  }
}

//---------------------------------------------------------------
//true if this current object is a JTech, false if not
function IsJTech() { return( ((parent._sObType == "jtech") ? true : false)); }

//---------------------------------------------------------------
// nesting level for this object- true if 2 deep (kern/temp)
function IsTwoDeep()
{
   var bRet = true;  // default
   if((parent._sObType == "jtech")||(parent._sObType == "technq")) bRet = false;
   return(bRet);
}

//---------------------------------
// Get various paths.
function GetImagePath() {return( (IsTwoDeep()) ? PATH_IMAGE : PATH_EXT_IMAGE);}
function GetTechniquePath() {return( (IsTwoDeep()) ? PATH_TECHNIQUE : PATH_EXT_TECHNIQUE);}
function GetTemplatePath() {return( (IsTwoDeep()) ? PATH_TEMPLATE : PATH_EXT_TEMPLATE);}
function GetKernelPath() {return( (IsTwoDeep()) ? PATH_KERNEL : PATH_EXT_KERNEL);}
function GetOtherPath() {return( (IsTwoDeep()) ? PATH_OTHER : PATH_EXT_OTHER);}
function GetAdPath() {return( (IsTwoDeep()) ? PATH_AD : PATH_EXT_AD);}
function GetScriptsPath() {return( (IsTwoDeep()) ? PATH_SCRIPTS : PATH_EXT_SCRIPTS);}
function GetGlossaryPath() {return( (IsTwoDeep()) ? PATH_GLOSSARY : PATH_EXT_GLOSSARY);}
function GetHelpPath() {return( (IsTwoDeep()) ? PATH_HELP : PATH_EXT_HELP);}
function GetRootPath() {return( (IsTwoDeep()) ? PATH_ROOT : PATH_EXT_ROOT);}

//======[ end of file    lcl,twg ]======//

