// Nicola Zordan
// Aggregate DMS clients data

// Work Clients retrieved via XML

//var ClientPerformancePage='/LANSAWEB?PROCFUN+ENROLL+PERFAN+PRD';
var ClientPerformancePage='/LANSAWEB?PROCFUN+ENROLL+PERFAN+PRD';

var Clients=new Array();
Clients=[
  ['Concho supply','http://66.179.164.71:91'],
  ['Star Sales','http://66.179.164.71:92'],
  ['Carter distributing','http://66.179.164.71:93'],
  ['Internal Engine Parts','http://66.179.164.71:94'],
  ['IEP2','http://iep.Qwik-Order.com'],
  //-['IEP ce','http://iep.Qwik-OrderDirect.com'],
  ['IEP ce','https://IEP.qwik-orderdirect.com/cgi-bin/lansaweb?procfun+ce_build+hompge1+cep'],
  //['IEP ce Maintenance <!--<a onClick="alert(\'iepadmin\')"><font color="#444477" style="{text-decoration: none}">-</font></a>-->','https://iep.qwik-orderdirect.com/cgi-bin/lansaweb?procfun+lw3gen+lw3gn21+cep'],
  //['Southern','http://66.179.164.71:'],
  ['Standard Parts','http://66.179.164.71:95'],
  //['Winhere','http://66.179.164.71:'],
  //['Parts Authority','http://66.179.164.71:'],
  ['Electric Motor Service','http://66.179.164.71:96'],
  ['EMS ce','https://EMS.qwik-orderdirect.com/cgi-bin/lansaweb?procfun+ce_build+hompge1+cep'],
  ['Wahlberg McCreary','http://66.179.164.71:97'],
  ['Vita Plate','http://66.179.164.71:98'],
  ['American Performance','http://66.179.164.71:99'],
  ['US Automotive AP2','http://66.179.164.71:100'],
  ['Foland','http://66.179.164.71:101'],
  ['FBM ce','https://FBM.qwik-orderdirect.com/cgi-bin/lansaweb?procfun+ce_build+hompge1+cep'],
  //['','http://66.179.164.71:'],

  //['','http://66.179.164.71:'],
  //['','http://66.179.164.68:'],

];

// load from XML
Clients=[['ERROR loading XML clients',''],[,]];


var Prospects=new Array();
Prospects=[
  //['IEP (old server)','http://66.179.164.68:94'],

  //['Customize OLD','http://66.179.164.68:89'],
  //['Customize','http://66.179.164.71:89'],
  //['Test','http://66.179.164.71:86'],

  //['Demo','http://66.179.164.71:90'],
  //['DEVelopment','http://66.179.164.71:85'],
  //['Demo OLD','http://66.179.164.68:90'],
  //['Demo','http://66.179.164.71:90'],
  //['DEVelopment','http://66.179.164.68:85'],

  //['','http://66.179.164.71:'],
  //['','http://66.179.164.68:'],

];


// - From XML links


// - For WorkClients

function GetBaseURL(url) {
  var baseURL='';
  if (url==null) return baseURL;
  //var rootSlash=url.indexOf('/',8);
  var rootSlash=url.indexOf('/',9);
  if (rootSlash>0) {
    baseURL=url.substring(0,rootSlash);
   } else {
    baseURL=url;
  };
  return baseURL;
};


var ClientsFromXML='ClientsTestAJAXlinks.xml';
function GetClientsFromTestLinks (mA) {
  var clients=[], cli=[], n, u, mAi;
  if (mA==null) return clients;
  for (var i=0;i<mA.length;i++) { 
    mAi=mA[i];
    //-n=mAi.Label;
    //-//u=mAi.URL;
    //-u=GetBaseURL(mAi.URL);
    //n=mAi[0]
    //cli=[n,u];
    cli=mAi.slice(); // Copies the array
    u=GetBaseURL(mAi[1]);
    cli[1]=u;
    if (cli[0]==null) cli[0]='';
    //alert(mAi+'\n'+cli);
    clients[clients.length]=cli;
  };
  clients[clients.length]=['','']; // add a separator
  return clients;
};



TestAJAXlinks=[];

// Get Links from XML

var ClientsTestPath;
if (ClientsTestPath==null) {
  ClientsTestPath='';
};
ClientsTestPath=ClientsTestPath+'ClientsSummary/';

//var ClientsTestPath='ClientsSummary/';
var ClientsTest2MenuXSL='ClientsTest2Menu.xsl';
var ClientsTestXML='ClientsTestAJAXlinks.xml';


function ClientsTest2Menu(url,pathIn) {
  var html='';
  var path=pathIn;
  if (path==null) path='';
// LOAD XML domains
  // Load XML 
  var xml = new ActiveXObject("Microsoft.XMLDOM");
  //-var xml = new ActiveXObject("Msxml2.DOMDocument.3.0");
  xml.async = false;
  xml.load(path+url);
  // Load XSL
  var xsl = new ActiveXObject("Microsoft.XMLDOM");
  //-var xsl = new ActiveXObject("Msxml2.DOMDocument.3.0");
  xsl.async = false;
  //alert(path+ClientsTest2MenuXSL);
  xsl.load(path+ClientsTest2MenuXSL);
  //alert(siteMap2MenuXSL+'\n'+xsl.text);
  //alert(domainsURL+'\n'+xml.xml);
  html=html+xml.transformNode(xsl);
  //alert(html);
  js='['+html+'[null,\'\']'+'];';
//alert(js);
  var array=eval(js);  
  //alert(array);
  return array;
};


// Execute

//TestAJAXlinks=SiteMap2Menu(domainsURL);

//TestAJAXlinks=SiteMap2Menu(ClientsTestXML);
TestAJAXlinks=ClientsTest2Menu(ClientsTestXML,ClientsTestPath);

Clients=GetClientsFromTestLinks(TestAJAXlinks);
ClientsN=Clients.length;



