rootPath = "http://www.livemanuals.com/packages/";
VsimWidth = 775;
VsimHeight = 550;
HsimWidth = 450;
HsimHeight = 700;
manualWidth = 620;
manualHeight = 620;
showLocationBar = 'no';
allowScrollBars = 'no';
showStatusBar = 'yes';
showStatusBarManual = 'no';

pid = '';
ptid = '';
imgLoc = '';
imgLink = '';
sPageLoading = false;



// PARTNERS MANUAL WINDOW FUNCTION

function openManualWindow()  {

  // INPUT VARIABLES
  // **********************************
  // arguments[0] = Product Path   OBSOLETE
  // arguments[1] = Product ID
  // arguments[2] = Chapter
  // arguments[3] = Anchor
  // arguments[4] = Partner ID
  // arguments[5] = Logo Image URL
  // arguments[6] = Logo Image Link
  // arguments[7] = Same Page Loading
  
  prodPath=arguments[0]?arguments[0]:'';
  pid=arguments[1]?arguments[1]:'';
  chapter=arguments[2]?arguments[2]:'';
  anchor=arguments[3]?arguments[3]:'';
  ptid=arguments[4]?arguments[4]:'';
  imgLoc=arguments[5]?escape(escape(arguments[5])):'';
  imgLink=arguments[6]?escape(escape(arguments[6])):'';
  sPageLoading=arguments[7]?true:false;
  
  imgLoc = escape(imgLoc);
  imgLink = escape(imgLink);
  
  sPageLoading = eval(sPageLoading);
  
  if (!sPageLoading) {
    if (window.top.name == 'VSimWindow') {
      // check to see if this is a call from the question and answer search results page
      if (((chapter == null) || (chapter == "")) && ((anchor == null) || (anchor == "")))
        qaHelp = false;
      else
        qaHelp = true;
      // make sure the manual window is open
      
      if ((window.manualHandler) && (!window.manualHandler.closed)) {
        // if the wrong product manual is in the window,
        // reload it to the correct product manual
        if ((manualHandler.window.top.location.href.toLowerCase().indexOf("loadmanual.cfm?") == -1) || (manualHandler.window.top.location.href.toLowerCase().indexOf("pid=" + pid.toLowerCase()) == -1) || (manualHandler.window.top.location.href.toLowerCase().indexOf("ptid=" + ptid.toLowerCase()) == -1)) {
          window.manualHandler.close();
          window.manualHandler=window.open(rootPath+'products/common/loadManual.cfm?ptid='+ptid+'&pid='+pid+'&chapter='+chapter+'&anchor='+anchor+'&imgLoc='+imgLoc+'&imgLink='+imgLink,'manualWindow','location='+showLocationBar+',height='+manualHeight+',width='+manualWidth+',toolbar=no,status='+showStatusBarManual+',top=0,left=0,screenx=0,screeny=0,resizable=yes,scrollbars='+allowScrollBars);
          (!manualHandler.opener)?manualHandler.opener=self:dVar=null;
        }
        // if it is the correct product manual, focus the window
        else {
          // load the appropriate qa help pages within the manual
          if (qaHelp) {
            theProdPath = getParameter(window.manualHandler.top.BOTTOM.document.location.href.toLowerCase(), "prodpath");
            if (theProdPath != null) {
              window.manualHandler.top.TREE.document.location.href = rootPath + "products/" + theProdPath + "/manual/" + chapter + "nav.html#" + anchor;
              window.manualHandler.top.WORK.document.location.href = rootPath + "products/" + theProdPath + "/manual/" + chapter + ".html#" + anchor;
            }
          }
          // focus window
          manualHandler.window.focus();
        }
      }
      else {
        window.manualHandler=window.open(rootPath+'products/common/loadManual.cfm?ptid='+ptid+'&pid='+pid+'&chapter='+chapter+'&anchor='+anchor+'&imgLoc='+imgLoc+'&imgLink='+imgLink,'manualWindow','location='+showLocationBar+',height='+manualHeight+',width='+manualWidth+',toolbar=no,status='+showStatusBarManual+',top=0,left=0,screenx=0,screeny=0,resizable=yes,scrollbars='+allowScrollBars);
        (!manualHandler.opener)?manualHandler.opener=self:dVar=null;
      }
    }
    else {
      window.manualHandler=window.open(rootPath+'products/common/loadManual.cfm?ptid='+ptid+'&pid='+pid+'&chapter='+chapter+'&anchor='+anchor+'&imgLoc='+imgLoc+'&imgLink='+imgLink,'manualWindow','location='+showLocationBar+',height='+manualHeight+',width='+manualWidth+',toolbar=no,status='+showStatusBarManual+',top=0,left=0,screenx=0,screeny=0,resizable=yes,scrollbars='+allowScrollBars);
      (!manualHandler.opener)?manualHandler.opener=self:dVar=null;
    }
  }
  else {
    window.top.location.href = rootPath+'products/common/loadManual.cfm?ptid='+ptid+'&pid='+pid+'&chapter='+chapter+'&anchor='+anchor+'&sPage=true&imgLoc='+imgLoc+'&imgLink='+imgLink;
    window.name = 'mainWindow';
  }
  
  
  
  
  imgLoc = '';
  imgLink = '';

}



// PARTNERS VERTICAL SIMULATION WINDOW FUNCTION

function openVSimWindow()  {

  // INPUT VARIABLES
  // **********************************
  // arguments[0] = Product Path   OBSOLETE
  // arguments[1] = Product ID
  // arguments[2] = Application Name
  // arguments[3] = Scenario Name
  // arguments[4] = Scenario Number
  // arguments[5] = Partner ID
  // arguments[6] = Logo Image URL
  // arguments[7] = Logo Image Link
  // arguments[8] = Same Page Loading
  
  prodPath=arguments[0]?arguments[0]:'';
  pid=arguments[1]?arguments[1]:'';
  aName=arguments[2]?arguments[2]:'';
  sName=arguments[3]?arguments[3]:'';
  sNum=arguments[4]?arguments[4]:'';
  ptid=arguments[5]?arguments[5]:'';
  imgLoc=arguments[6]?escape(arguments[6]):'';
  imgLink=arguments[7]?escape(arguments[7]):'';
  if (!sPageLoading)
    sPageLoading=arguments[8]?true:false;
  
  imgLoc = escape(imgLoc);
  imgLink = escape(imgLink);
  
  sPageLoading = eval(sPageLoading);
  
  if (!sPageLoading) {
    if (window.top.name == 'manualWindow') {
      // make sure the simulation window is open
      if ((window.VsimHandler) && (!window.VsimHandler.closed)) {
        // if the wrong product is in the window, reload it to the correct product
        if ((VsimHandler.window.top.location.href.toLowerCase().indexOf("loadvsim.cfm?") == -1) || (VsimHandler.window.top.location.href.toLowerCase().indexOf("pid=" + pid.toLowerCase()) == -1) || (VsimHandler.window.top.location.href.toLowerCase().indexOf("ptid=" + ptid.toLowerCase()) == -1)) {
          window.VsimHandler.close();
          window.VsimHandler=window.open(rootPath+'install/loader.cfm?simType=V&ptid='+ptid+'&pid='+pid+'&applicationName='+aName.toLowerCase()+'&scenarioName='+sName.toLowerCase()+'&scenarioNumber='+sNum+'&imgLoc='+imgLoc+'&imgLink='+imgLink,'VSimWindow','height='+VsimHeight+',width='+VsimWidth+',toolbar=no,status='+showStatusBar+',location='+showLocationBar+',top=0,left=0,screenx=0,screeny=0,resizable=yes,scrollbars='+allowScrollBars);
          (!VsimHandler.opener)?VsimHandler.opener=self:dVar=null;
        }
        // if it is the correct product, load scenario if requested and focus the window
        else {
          // load scenario if requested
          if (scenarioFromManual(aName, sName, sNum)) {
            if (VsimHandler.window.nav) {
              VsimHandler.window.nav.scenarioLoader(aName.toLowerCase(), sName.toLowerCase(), sNum);
            }
            else {
              VsimHandler.window.scenarioLoader(aName.toLowerCase(), sName.toLowerCase(), sNum);
            }
          }
          // focus window
          VsimHandler.window.focus();
        }
      }
      // if simulation window is not open, open up a new window with
      // the proper product and url variables
      else {
        window.VsimHandler=window.open(rootPath+'install/loader.cfm?simType=V&ptid='+ptid+'&pid='+pid+'&applicationName='+aName.toLowerCase()+'&scenarioName='+sName.toLowerCase()+'&scenarioNumber='+sNum+'&imgLoc='+imgLoc+'&imgLink='+imgLink,'VSimWindow','height='+VsimHeight+',width='+VsimWidth+',toolbar=no,status='+showStatusBar+',location='+showLocationBar+',top=0,left=0,screenx=0,screeny=0,resizable=yes,scrollbars='+allowScrollBars);
        (!VsimHandler.opener)?VsimHandler.opener=self:dVar=null;
      }
    }
    else {
      window.VsimHandler=window.open(rootPath+'install/loader.cfm?simType=V&ptid='+ptid+'&pid='+pid+'&applicationName='+aName.toLowerCase()+'&scenarioName='+sName.toLowerCase()+'&scenarioNumber='+sNum+'&imgLoc='+imgLoc+'&imgLink='+imgLink,'VSimWindow','height='+VsimHeight+',width='+VsimWidth+',toolbar=no,status='+showStatusBar+',location='+showLocationBar+',top=0,left=0,screenx=0,screeny=0,resizable=yes,scrollbars='+allowScrollBars);
      (!VsimHandler.opener)?VsimHandler.opener=self:dVar=null;
    }
  }
  else {
    window.top.location.href = rootPath+'install/loader.cfm?simType=V&ptid='+ptid+'&pid='+pid+'&applicationName='+aName.toLowerCase()+'&scenarioName='+sName.toLowerCase()+'&scenarioNumber='+sNum+'&sPage=true&imgLoc='+imgLoc+'&imgLink='+imgLink;
    window.name = 'mainWindow';
  }
  
  
  
  imgLoc = '';
  imgLink = '';
  
}















// SCENARIO VARIABLES CHECKER

function scenarioFromManual(applicationName, scenarioName, scenarioNumber) {
  // make sure that all variables for loading scenario exist
  if ((applicationName != null) && (applicationName.length != 0)) {
    if ((scenarioName != null) && (scenarioName.length != 0)) {
      if ((scenarioNumber != null) && (scenarioNumber.length != 0)) {
        return true;
      }
    }
  }
  // one or more of the variables are missing or null
  return false;
}

// gets the value of a parameter from a URL
// URL is written in the standard query format: http://site/page?param1=value1&param2=value2&...
// returns null if the parameter was not found in the URL

function getParameter(url, name) {
    // get the parameters(query) portion of the URL
    var i = url.lastIndexOf("?");
    if(i==-1)
       return null;
    var paramStr = url.substring(i+1, url.length); // can't use substr - JavaScript 1.2+
    var params = paramStr.split("&");

    // scan all parameters for the specified parameter name
    for(i=0; i<params.length; i++) {
       var nv = params[i].split("=", 2);
       if(nv[0] == name)
          return (nv.length>1) ? nv[1] : "";
    }
    return null; // parameter was not found
}

