﻿var aryEvt = new Array();
var aryBdy = new Array('initBody');
var aryCtl = new Array('initXML', 'initEditor');
var aryLbx = new Array('showLightbox', 'getXML');
var aryMdl = new Array('showModal', 'getXML');
var aryPop = new Array('showPop', 'getXML');
var aryCtb = new Array('changeTab');
var aryCpd = new Array('changePad');
var arySck = new Array('saveCookie', 'setCookie');
var aryRsp = new Array('sendRsp', 'soapRsp', 'soapRspRqt');
var aryReq = new Array('sendRqt', 'soapRqt', 'soapRspRqt');
var strAry = '';
var strEvt = '';
var strDbg = 'green';

function proTest() {
    //--- Concat calls
    aryBdy = aryBdy.concat(aryCtl);
    aryLbx = aryLbx.concat(aryRsp);
    aryCtb = aryCtb.concat(aryRsp);
    aryCpd = aryCpd.concat(aryRsp);
}
proTest.prototype.addEvent = function(strEvent, strLine, strArray) {
    //--- Add events
    if (!blnDebug) { return ''; }
    if (isNOE(strArray)) { strArray = ''; }
    if (isNOE(strLine)) { strLine = '1'; }
    strEvt = strEvent + ' Line: ' + strLine
    switch (strDbg) {
        case 'yellow':
            if (strAry == '' && strArray != '') {
                if (confirm('Test ' + strArray)) { strAry = strArray; };
            } break;
        case 'red':
            alert(strEvt); break;
    }
    if (!isNOE(strAry)) { aryEvt.push(strEvent); }
    return strEvent;
}
proTest.prototype.showResult = function() {
    //--- Show test results
    switch (strAry) {
        case 'Bdy':
            this.getResult(aryBdy); break;
        case 'Ctl':
            this.getResult(aryCtl); break;
        case 'Lbx':
            this.getResult(aryLbx); break;
        case 'Mdl':
            this.getResult(aryMdl); break;
        case 'Pop':
            this.getResult(aryPop); break;
        case 'Ctb':
            this.getResult(aryCtb); break;
        case 'Cpd':
            this.getResult(aryCpd); break;
        case 'Sck':
            this.getResult(arySck); break;
    }
    strAry = ''; // Init
    aryEvt = new Array();
}
proTest.prototype.getResult = function(aryTest) {
    //--- Get test results
    var strMsg = '';
    for (var idx = 0; idx < aryTest.length; idx++) {
        var blnFound = false;
        for (var idx2 = 0; idx2 < aryEvt.length && !blnFound; idx2++) {
            blnFound = (aryEvt[idx2].indexOf(aryTest[idx]) >= 0)
        }
        if (blnFound) {
            strMsg += 'x - ' + aryEvt[idx2] + '\n'; // Found
        } else {
            strMsg += 'n - ' + aryTest[idx] + '\n'; // Not found
        }
    }
    alert(strMsg);
}
proTest.prototype.showIssue = function(err) {
    //--- Show issue
    if (!err) { return ''; }
    objTest.showResult();
    var strXML = '<Issue><Issue>';
    if (err.name) { strXML = strXML + '<IssueName>' + err.name + '</IssueName>'; }
    strXML = strXML + '<IssueDesc>';
    if (err.number) { strXML = strXML + ' Number: ' + err.number; }
    if (err.message) { strXML = strXML + ' Message: ' + err.message; }
    if (err.description) { strXML = strXML + ' Description:' + err.description; }
    strXML = strXML + '</IssueDesc><StackTrace>[JavaScript]';
    strXML = strXML + ' Event: ' + strEvt; 
    strXML = strXML + '</StackTrace></Issue></Issue>';
    if (blnDebug) {
        alert(strXML);
    } else {
        soapRqt('', '', '', 'Issue', 'insAllIssue', strXML, '');
    }
}
proTest.prototype.setDebug = function(elmDiv) {
    switch (elmDiv.style.backgroundColor) {
        case 'green':
            elmDiv.style.backgroundColor = 'yellow'; break; //*** need bgColor defense
        case 'yellow':
            elmDiv.style.backgroundColor = 'red'; break;
        case 'red':
            elmDiv.style.backgroundColor = 'green'; break;
    }
    strDbg = elmDiv.style.backgroundColor;
}
