
function getDefReleaseParams() {

  var params = new Array();
  params[0] = "";
  params[1] = "";
  params[2] = "";
  params[3] = getChoice();
  params[4] = "all";
  params[5] = "NGN";
  
  return params;
}

function getChoice() {

  var xml;
  if (window.ActiveXObject) {
    xml = new ActiveXObject("MSXML2.DOMDocument");
    xml.async = false;
    xml.load(getControlFile());
    //return xml.getElementsByTagName("CHOICE").item(0).text;
    var choice = xml.getElementsByTagName("CHOICE");
    return choice[0].firstChild.nodeValue;
  }
  // code for Mozilla, Firefox, Opera, etc.
  else if (document.implementation && document.implementation.createDocument) {
    xml = document.implementation.createDocument("","",null);
    xml.async = false;
    xml.load(getControlFile());
    var choice = xml.getElementsByTagName("CHOICE");
    return choice[0].firstChild.nodeValue;
  }
  else {
    alert('Your browser cannot handle this script');
  }
}

function getControlFile() {
	return "BTS-Product.xml";
}

function getStylesheetForControlFile() {
	return "../Stylesheet/BTS-Release.xsl";
}
 
function getParameters() {

  var params = new Array();
  params[0] = document.select.module[document.select.module.selectedIndex].value;
  params[1] = document.select.myRel[document.select.myRel.selectedIndex].value;
  params[2] = document.select.oldRel[document.select.oldRel.selectedIndex].value;
  params[3] = document.select.component[document.select.component.selectedIndex].value;
  params[4] = document.select.xmlFile.value;
  params[5] = document.select.mDescFile.value;
  params[6] = document.select.oDescFile.value;
  params[7] = document.select.upgradeFile.value;
  params[8] = document.select.xslFile.value;
  if (document.select.hasCategory.value) {
    params[9] = document.select.category[document.select.category.selectedIndex].value;
  }
  else {
    params[9] = "";
  }
  params[10] = document.select.product[document.select.product.selectedIndex].value;
  return params;
}

function showComponent(params) {

  if (window.ActiveXObject) {
    showComponentInIE(params);
  }
  // code for Mozilla, Firefox, Opera, etc.
  else if (document.implementation && document.implementation.createDocument) {
    showComponentInFirefox(params);
  }
  else {
    alert('Your browser cannot handle this script');
  }
}

function showComponentInIE(params) {

  var module = params[0];
  var myRel = params[1];
  var oldRel = params[2];
  var component = params[3];
  var xmlFile = params[4];
  var mDescFile = params[5];
  var oDescFile = params[6];
  var upgradeFile = params[7];
  var xslFile = params[8];
  var category = params[9];

  var xml = new ActiveXObject("MSXML2.DOMDocument");
  xml.async = false;
  xml.load(xmlFile);

  var xsl = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
  xsl.async = false;
  xsl.load(xslFile);

  var template = new ActiveXObject("MSXML2.XSLTemplate");
  template.stylesheet = xsl;
  processor = template.createProcessor();
  processor.input = xml;
  processor.addParameter("xmlFile",xmlFile);
  processor.addParameter("component",component);
  processor.addParameter("mDescFile",mDescFile);
  processor.addParameter("oDescFile",oDescFile);
  processor.addParameter("upgradeFile",upgradeFile);
  processor.addParameter("category",category);
  processor.transform();

  // parent.main.document.write(processor.output);
  // parent.main.document.close();
  var target = parent.main.document.getElementById("BTS-main");
  target.innerHTML = processor.output;
}

function getProductParams() {

  var params = new Array();
  params[0] = "";
  params[1] = "";
  params[2] = "";
  params[3] = document.select.choice.value;
  params[4] = "all";
  params[5] = document.select.product[document.select.product.selectedIndex].value;
  return params;
}

function getModuleParams() {

  var params = new Array();
  params[0] = document.select.module[document.select.module.selectedIndex].value;
  params[1] = "";
  params[2] = "";
  params[3] = document.select.choice.value;
  params[4] = "all";
  params[5] = document.select.product[document.select.product.selectedIndex].value;
  return params;
}
function getMyReleaseParams() {

  var params = new Array();
  params[0] = document.select.module[document.select.module.selectedIndex].value;
  params[1] = document.select.myRel[document.select.myRel.selectedIndex].value;
  params[2] = "";
  params[3] = document.select.choice.value;
  params[4] = "all";
  params[5] = document.select.product[document.select.product.selectedIndex].value;
  return params;
}

function getOldReleaseParams() {

  var params = new Array();
  params[0] = document.select.module[document.select.module.selectedIndex].value;
  params[1] = document.select.myRel[document.select.myRel.selectedIndex].value;
  params[2] = document.select.oldRel[document.select.oldRel.selectedIndex].value;
  params[3] = document.select.choice.value;
  params[4] = "all";
  params[5] = document.select.product[document.select.product.selectedIndex].value;
  return params;
}

function getCategoryParams() {

  var params = new Array();
  params[0] = document.select.module[document.select.module.selectedIndex].value;
  params[1] = document.select.myRel[document.select.myRel.selectedIndex].value;
  params[2] = document.select.oldRel[document.select.oldRel.selectedIndex].value;
  params[3] = document.select.choice.value;
  params[4] = document.select.category[document.select.category.selectedIndex].value;
  params[5] = document.select.product[document.select.product.selectedIndex].value;
  return params;
}

function showRelease(params) {

  if (window.ActiveXObject) {
    showReleaseInIE(params);
  }
  // code for Mozilla, Firefox, Opera, etc.
  else if (document.implementation && document.implementation.createDocument) {
    showReleaseInFirefox(params);
  }
  else {
    alert('Your browser cannot handle this script');
  }
}

function showReleaseInIE(params) {

  var module = params[0]
  var myRel = params[1];
  var oldRel = params[2];
  var choice = params[3];
  var category = params[4];
  var product = params[5];
  var xmlRelFile = getControlFile();
  var xslRelFile = getStylesheetForControlFile();

  //  var xml = new ActiveXObject("Microsoft.XMLDOM");
  var xml = new ActiveXObject("MSXML2.DOMDocument");
  xml.async = false;
  xml.load(xmlRelFile);

  var xsl = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
  xsl.async = false;
  xsl.load(xslRelFile);

  var template = new ActiveXObject("MSXML2.XSLTemplate");
  template.stylesheet = xsl;
  processor = template.createProcessor();
  processor.input = xml;
  processor.addParameter("product",product);
  processor.addParameter("module",module);
  processor.addParameter("myRel",myRel);
  processor.addParameter("oldRel",oldRel);
  processor.addParameter("choice",choice);
  processor.addParameter("category",category);
  processor.transform();

  // document.write(processor.output);
  // document.close();
  var target = document.getElementById("BTS-select");
  target.innerHTML = processor.output;
}

function popup(mylink, windowname) {

  if (!window.focus) return true;
  var href;
  if (typeof(mylink) == 'string')
     href=mylink;
  else
   href=mylink.href;
  window.open(href, windowname, 'width=600,height=600,scrollbars=yes,resizable=yes');
  return false;
}

function showComponentInFirefox(params) {

  var module = params[0];
  var myRel = params[1];
  var oldRel = params[2];
  var component = params[3];
  var xmlFile = params[4];
  var mDescFile = params[5];
  var oDescFile = params[6];
  var upgradeFile = params[7];
  var xslFile = params[8];
  var category = params[9];

  xml = document.implementation.createDocument("","",null);
  xml.async = false;
  xml.load(xmlFile);
  xsl = document.implementation.createDocument("","",null);
  xsl.async = false;
  xsl.load(xslFile);
  var processor = new XSLTProcessor();
  processor.importStylesheet(xsl);
  processor.setParameter(null,"xmlFile",xmlFile);
  processor.setParameter(null,"component",component);
  processor.setParameter(null,"mDescFile",mDescFile);
  processor.setParameter(null,"oDescFile",oDescFile);
  processor.setParameter(null,"upgradeFile",upgradeFile);
  processor.setParameter(null,"category",category);
  var rltHtml = processor.transformToFragment(xml,document);
  var target = parent.main.document.getElementById("BTS-main");
  while (target.hasChildNodes())
    target.removeChild(target.childNodes[0]);
  target.appendChild(rltHtml);
}

function showReleaseInFirefox(params) {

  var module = params[0]
  var myRel = params[1];
  var oldRel = params[2];
  var choice = params[3];
  var category = params[4];
  var product = params[5];
  var xmlRelFile = getControlFile();
  var xslRelFile = getStylesheetForControlFile();

  xml = document.implementation.createDocument("","",null);
  xml.async = false;
  xml.load(xmlRelFile);
  xsl = document.implementation.createDocument("","",null);
  xsl.async = false;
  xsl.load(xslRelFile);
  var processor = new XSLTProcessor();
  processor.importStylesheet(xsl);
  processor.setParameter(null,"product",product);
  processor.setParameter(null,"module",module);
  processor.setParameter(null,"myRel",myRel);
  processor.setParameter(null,"oldRel",oldRel);
  processor.setParameter(null,"choice",choice);
  processor.setParameter(null,"category",category);
  var rltHtml = processor.transformToFragment(xml,document);
  var target = document.getElementById("BTS-select");
  while (target.hasChildNodes())
    target.removeChild(target.childNodes[0]);
  target.appendChild(rltHtml);
}

function loadXml(xmlFile, xslFile, targetId) {

  if (window.ActiveXObject) {
    loadXmlInIE(xmlFile,xslFile,targetId);
  }
  // code for Mozilla, Firefox, Opera, etc.
  else if (document.implementation && document.implementation.createDocument) {
    loadXmlInFirefox(xmlFile,xslFile,targetId);
  }
  else {
    alert('Your browser cannot handle this script');
  }
}

function loadXmlInIE(xmlFile, xslFile, targetId) {

  var xml = new ActiveXObject("MSXML2.DOMDocument");
  xml.async = false;
  xml.load(xmlFile);

  var xsl = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
  xsl.async = false;
  xsl.load(xslFile);

  var template = new ActiveXObject("MSXML2.XSLTemplate");
  template.stylesheet = xsl;
  processor = template.createProcessor();
  processor.input = xml;
  processor.transform();

  // document.write(processor.output);
  // document.close();
  var target = document.getElementById(targetId);
  target.innerHTML = processor.output;
}

function loadXmlInFirefox(xmlFile, xslFile, targetId) {

  xml = document.implementation.createDocument("","",null);
  xml.async = false;
  xml.load(xmlFile);
  xsl = document.implementation.createDocument("","",null);
  xsl.async = false;
  xsl.load(xslFile);
  var processor = new XSLTProcessor();
  processor.importStylesheet(xsl);
  var rltHtml = processor.transformToFragment(xml,document);
  var target = document.getElementById(targetId);
  while (target.hasChildNodes())
    target.removeChild(target.childNodes[0]);
  target.appendChild(rltHtml);
}

function getCaConfigParameters() {

  var params = new Array();
  params[0] = document.select.xmlFile.value;
  params[1] = "../Stylesheet/BTS-CaConfigGenerateCode.xsl";
  params[2] = document.select.component.value;
  return params;
}

function getSCSCFConfigParameters() {

  var params = new Array();
  params[0] = document.select.xmlFile.value;
  params[1] = "../Stylesheet/BTS-SCSCFConfigGenerateCode.xsl";
  params[2] = document.select.component.value;
  return params;
}

function getH248GWPParameters() {

  var params = new Array();
  params[0] = document.select.xmlFile.value;
  params[1] = "../Stylesheet/BTS-H248GWPGenerateCode.xsl";
  params[2] = document.select.component.value;
  return params;
}

function getFeatureParameters() {

  var params = new Array();
  params[0] = document.select.xmlFile.value;
  params[1] = "../Stylesheet/BTS-FeatureGenerateCode.xsl";
  params[2] = document.select.component.value;
  return params;
}

function generateCode(params) {

  if (window.ActiveXObject) {
    generateCodeInIE(params,'BTS-main');
  }
  // code for Mozilla, Firefox, Opera, etc.
  else if (document.implementation && document.implementation.createDocument) {
    generateCodeInfirefox(params,'BTS-main');
  }
  else {
    alert('Your browser cannot handle this script');
  }
}

function generateCodeInIE(params, targetId) {

  var xmlFile = params[0]
  var xslFile = params[1];
  var component = params[2];
  var xml = new ActiveXObject("MSXML2.DOMDocument");
  xml.async = false;
  xml.load(xmlFile);

  var xsl = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
  xsl.async = false;
  xsl.load(xslFile);

  var template = new ActiveXObject("MSXML2.XSLTemplate");
  template.stylesheet = xsl;
  processor = template.createProcessor();
  processor.input = xml;
  processor.addParameter("component",component);
  processor.transform();

  // document.write(processor.output);
  // document.close();
  var target = document.getElementById(targetId);
  target.innerHTML = processor.output;
}

function lgenerateCodeInfirefox(params, targetId) {

  var xmlFile = params[0]
  var xslFile = params[1];
  var component = params[2];
  xml = document.implementation.createDocument("","",null);
  xml.async = false;
  xml.load(xmlFile);
  xsl = document.implementation.createDocument("","",null);
  xsl.async = false;
  xsl.load(xslFile);
  var processor = new XSLTProcessor();
  processor.importStylesheet(xsl);
  processor.setParameter(null,"component",component);
  var rltHtml = processor.transformToFragment(xml,document);
  var target = document.getElementById(targetId);
  while (target.hasChildNodes())
    target.removeChild(target.childNodes[0]);
  target.appendChild(rltHtml);
}

function pleasewait() {
  
  var subWin = null;
  // subWin = window.open('BTS-progressIndicator.html','pWin','height=100,width=280,left=400,top=400');
  subWin = window.open('','pWin','height=100,width=280,left=400,top=400');
  subWin.document.open();
  subWin.document.write('<html><body><div align=center>');
  subWin.document.write('<h4>Loading document, please wait...</h4>');
  subWin.document.write('<img src="pleasewait.gif"/>');
  subWin.document.write('</div></body></html>');
  subWin.document.close()
  return subWin;
}

function showDocument() {
  
  if (window.ActiveXObject) {
    var subWin = pleasewait();
    showComponent(getParameters());
    subWin.close();
  }
  // code for Mozilla, Firefox, Opera, etc.
  else if (document.implementation && document.implementation.createDocument) {
    showComponent(getParameters());
  }
  else {
    alert('Your browser cannot handle this script');
  }
}

function displayMainPage() {

  var choice = getChoice();

  if (choice == 'external') {
	parent.main.document.writeln('<li><b>CLI Database</b> - The complete CLI commands</li>');
	parent.main.document.writeln('<li><b>CLI Database [Provisioning Only]</b> - The complete CLI Call Processing provisioning commands only. OAM commands, Measurement, Billing commands are not included. Tokens not needed for provisioning are excluded.</li>');
	parent.main.document.writeln('<li><b>Call Agent Configurable Parameters</b> - Call Agent configurable parameters</li>');
	parent.main.document.writeln('<li><b>Feature Matrix</b> - BTS supported Features with their configuration such as Feature Profile, Subscriber Feature Data, Feature Configuration, etc</li>');
	parent.main.document.writeln('<li><b>Feature Matrix [By Table]</b> - BTS supported Features grouped by Table with their configuration such as Feature Profile, Subscriber Feature Data, Feature Configuration, etc</li>');
	parent.main.document.writeln('<li><b>Table Sizing Configuration</b> - Maximum table size of the memory configuration</li>');
  }
  else {
	parent.main.document.writeln('<li><b>CLI Database</b> - The complete CLI commands</li>');
	parent.main.document.writeln('<li><b>CLI Database [Provisioning Only]</b> - The complete CLI Call Processing provisioning commands only. OAM commands, Measurement, Billing commands are not included. Tokens not needed for provisioning are excluded.</li>');
	parent.main.document.writeln('<li><b>Database Schema Document</b> -  The complete Database Schema including Call Processing, OAMP, and Billing schema</li>');
	parent.main.document.writeln('<li><b>Call Agent Configurable Parameters</b> - Call Agent configurable parameters</li>');
	parent.main.document.writeln('<li><b>Feature Matrix</b> - BTS supported Features with their configuration such as Feature Profile, Subscriber Feature Data, Feature Configuration, etc</li>');
	parent.main.document.writeln('<li><b>Feature Matrix [By Table]</b> - BTS supported Features grouped by Table with their configuration such as Feature Profile, Subscriber Feature Data, Feature Configuration, etc</li>');
	parent.main.document.writeln('<li><b>Table Sizing Configuration</b> - Maximum table size of the memory configuration</li>');
	parent.main.document.writeln('<li><b>Upgrade Impact for Data Migration</b> - Upgrade Impact for Data Migration resulted from Database Schema Change Request</li>');
	parent.main.document.writeln('<li><b>Change Request: CLI and Database Schema Changes</b> - Collection of change requests for CLI and Database Schema Changes</li>');
	parent.main.document.writeln('<li><b>Change Request: Call Agent Configuration Parameters</b> - Collection of change requests for Call Agent Configuration Parameters</li>');
	parent.main.document.writeln('<li><b>Change Request: Feature Matrix</b> - Collection of change requests for Feature Matrix</li>');
	parent.main.document.writeln('<li><b>Change Request: H248 Gateway Properties</b> - Collection of change requests for H248 Gateway Properties</li>');
  }
}


