/**
 * @author Microcraft eLearning
 * @version 1.0
 * @copyright Microcraft eLearning 2010
 */
/**
 * The lessonNode object.
 * This object abscracts the lesson options in Author. (Menu, sequence, and random)
 * It contains the information of the parent and children options for this option,
 * and also a list of all the elements that belong to it.
 *
 * Some other information:
 * - option start time
 * - option end time
 * - if the option will be seen in lesson reference
 * - to be continued...
 * @param {Object} nodeXML
 */
function LessonNode(nodeXML) {
    this.xml = nodeXML;
    this.type = nodeXML.getAttribute('type');
    this.id = nodeXML.getAttribute('id');
    this.parent = nodeXML.getAttribute('parent');
    this.name = nodeXML.getAttribute('name');
    this.scoring = false; // Indicates whether to score this option.
    this.optionStart = null; // The time when the option is statred.
    this.showInReference = true;
    this.endList = null;
    this.menuInteractionList = null;
    this.showEndOnCompletion = false;
    this.endListShown = false;
    this.noTick = false;
    // set proper values based on the option type.
    /*
     switch (this.type) {
     case "MENU":
     try {
     this.showInReference = (nodeXML.attributes[4].nodeValue.toLowerCase() == "true");
     this.showEndOnCompletion = (nodeXML.attributes[5].nodeValue.toLowerCase() == "true");
     }
     catch (err) {
     }
     break;
     case "SEQUENCE":
     this.scoring = (nodeXML.attributes[4].nodeValue.toLowerCase() == "true");
     try {
     this.showInReference = (nodeXML.attributes[5].nodeValue.toLowerCase() == "true");
     this.showEndOnCompletion = (nodeXML.attributes[6].nodeValue.toLowerCase() == "true");
     this.noTick = (nodeXML.attributes[7].nodeValue.toLowerCase() == "true");
     }
     catch (err) {
     }
     break;
     case "RANDOM":
     this.scoring = (nodeXML.attributes[8].nodeValue.toLowerCase() == "true");
     try {
     this.showInReference = (nodeXML.attributes[9].nodeValue.toLowerCase() == "true");
     this.showEndOnCompletion = (nodeXML.attributes[10].nodeValue.toLowerCase() == "true");
     this.noTick = (nodeXML.attributes[11].nodeValue.toLowerCase() == "true");
     }
     catch (err) {
     }
     break;
     }
     */
    var lists = this.xml.getElementsByTagName("list");
    for (var i = lists.length - 1; i >= 0; i--) {
        var listXML = lists[i];
        var listType = listXML.attributes[0].nodeValue;
        if (listType == "ENDLIST") {
            this.endList = listXML;
            //break;
        }
        if (listType == "MENUINTERACTION") {
            if (this.type == "MENU") {
                this.menuInteractionList = listXML;
                //break;
            }
        }
    }
    // The children options collection.
    this.children = new Ext.util.MixedCollection;
    if (this.parent != 0) {
        Author.lessonNodes.nodes.get(this.parent).children.add(this.id, this);
    }
    // Initialize the elements collection.
    this.elements = new Ext.util.MixedCollection;
    this.finished = false;
}
LessonNode.prototype.NodePath = function () {
    if (this.parent != 0) {
        var parentNodePath = Author.lessonNodes.nodes.get(this.parent).NodePath();
        return  parentNodePath + '|' + this.id;
    } else {
        return "0|" + this.id;
    }
}
LessonNode.prototype.LogicalOrder = function () {
    return new OrderClass(this.NodePath(), "LessonNode-" + this.type);
}
LessonNode.prototype.isNodeFinished = function () {
    switch (this.type) {
        case "MENU":
            var actions = this.menuInteractionList.getElementsByTagName("action");
            //alert("Checking: "+this.name+"\nInteractions:"+actions.length);
            var isFinished = true;
            var buttonCount = 0;
            var skippedCount = 0;
            for (var i = 0; i < actions.length; i++) {
                var a = actions[i];
                var aType = a.attributes[0].nodeValue;
                if (aType == "CUSTOMBUTTON") {
                    var aClick = "unknow";
                    try {
                        aClick = trim(a.getElementsByTagName("click")[0].childNodes[0].nodeValue);
                    }
                    catch (err) {
                    }
                    //If is a menu button.
                    if (aClick == "GOTOMENUOPTION") {
                        //Check Condition
                        buttonCount++;
                        if (!parserAndEvalActionCondition(a, false)) {
                            skippedCount++;
                            continue;
                        }
                        var theOptionFinished = true;
                        var nextOp = null;
                        try {
                            nextOp = parseInt(trim(a.getElementsByTagName("nextLessonNode")[0].childNodes[0].nodeValue));
                            var theOption = Author.lessonNodes.nodes.get(nextOp);
                            if (typeof(theOption) != 'undefined') {
                                if (theOption.noTick) {
                                    theOptionFinished = true;
                                }
                                else {
                                    theOptionFinished = theOption.isNodeFinished();
                                }
                            }
                            //alert(theOption.name +": "+theOptionFinished);
                        }
                        catch (err) {
                            //alert(err.description);
                        }
                        isFinished = isFinished && theOptionFinished;
                        if (!isFinished) {
                            return false;
                        }
                    }
                }
            }
            if (isFinished && (buttonCount == skippedCount)) {
                isFinished = false;
            }
            return isFinished;
        case "SEQUENCE":
            return this.finished;
        case "RANDOM":
            return this.finished;
    }
}
LessonNode.prototype.bookmarkString = function () {
    return "{[" + this.id + "]" + (this.finished ? "T" : "F") + "}";
}
/**
 * Reads the option status from cookie.
 */
LessonNode.prototype.readBookmark = function (bmString) {
    var vid = this.id;
    var regex = new RegExp("{(\\[" + vid + "\\][^}]*)}", "g");
    var regex2 = new RegExp("(\\[" + vid + "\\][^}]*)", "g");
    var chunk = bmString.match(regex);
    var value = "F";
    if (chunk != null) {
        chunk = chunk[0].match(regex2)[0];
        var partID = chunk.match(/(\[(\d+)\])/)[0];
        var vid = (partID.match(/(\d+)/)[0]);
        var value = chunk.replace(partID, "");
    }
    if (!this.finished) {
        this.finished = value.toLowerCase() == "t";
    }
}
/**
 * Add an element to the option.
 * @param {Object} element
 */
LessonNode.prototype.addElement = function (element) {
    this.elements.add(element.id, element);
}
/**
 * Calculate the Max Score in this option.
 * Every response have a score assigned to it. The max score of an element is the max score in all the responses.
 * The Max score of an option is the sum of all the max score of all the elements in the option.
 */
LessonNode.prototype.getOptionMaxScore = function () {
    if (!this.scoring)
        return 0;
    var totalMax = 0;
    for (var i = 0; i < this.elements.getCount(); i++) {
        totalMax += this.elements.itemAt(i).maxScore;
    }
    return totalMax;
}
/**
 * Calucate the score that the trainee achieved in the option.
 */
LessonNode.prototype.getOptionScore = function () {
    if (!this.scoring)
        return 0;
    var totalScore = 0;
    for (var i = 0; i < this.elements.getCount(); i++) {
        totalScore += this.elements.itemAt(i).scoreEarned;
    }
    return totalScore;
}
/**
 * The element object.
 * This object abstracts the element in Author.
 * @param {Object} elementXML
 * @param {Object} elementPos - the position in a option
 */
function Element(elementXML, elementPos, pNode) {
    this.xml = elementXML;
    this.pos = elementPos;
    this.type = this.xml.getAttribute('type');
    this.id = this.xml.getAttribute('id');
    this.name = this.xml.getAttribute('elementName');
    this.anyKey = (this.xml.attributes[3].nodeValue.toLowerCase() == "true"); // any keypress to skip the element.
    this.anyClick = (this.xml.attributes[4].nodeValue.toLowerCase() == "true"); // any mouse click to skip the element.
    this.maxScore = 0;
    this.timeout = false;
    this.timeoutValue = 0;
    this.scoreEarned = 0; // Score that the trainee got
    this.parentNode = (typeof(pNode) != 'undefined') ? pNode : null;
    try {
        this.showInReference = (this.xml.attributes[9].nodeValue.toLowerCase() == "true");
    }
    catch (err) {
        this.showInReference = true;
    }
    //var e =ElementHelper.loadElement(elementXML,this.LogicalOrder(),elementPos,{});
}
Element.prototype.setScore = function (score) {
    this.scoreEarned = score;
}
Element.prototype.LogicalOrder = function () {
    return (this.parentNode) ? new OrderClass(this.parentNode.NodePath(), "Element", this.pos) : null;
}
/**
 * Variable class
 * @param {Object} name
 * @param {Object} value - the initial value
 */
function Variable(name, value) {
    this.name = name;
    this.value = value;
    this.myValue = value;
    this.bookmark = false; // save this variable to cookie or not
    this.variableType = 0; //0 - numerical; 1 - string
    this.userVariable = false;
}
Variable.prototype.bookmarkString = function () {
    if (this.bookmark && Author.bookMark) {
        return "{[" + this.id.toString() + "]" + this.value.toString() + "}";
    }
    else {
        return "";
    }
}
Variable.prototype.readConfig = function (cfgXML) {
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    try {
        this.name = trim(cfgXML.getElementsByTagName("name")[0].childNodes[0].nodeValue).toUpperCase();
    }
    catch (err) {
        this.name = "";
        alert("Fail to load Uservarable: " + this.id + "\nPlease check it in the author lesson.");
    }
    this.value = null;
    this.variableType = parseInt(trim(cfgXML.getElementsByTagName("type")[0].childNodes[0].nodeValue));//0 - numerical; 1 - string
    this.userVariable = true;
    this.RTFName = "";
    try {
        this.RTFName = trim(cfgXML.getElementsByTagName("RTFName")[0].childNodes[0].nodeValue);
    }
    catch (err) {
    }
    this.myValue = null;
    this.bookmark = trim(cfgXML.getElementsByTagName("bookMark")[0].childNodes[0].nodeValue).toLowerCase() == "true";
    if (this.variableType == 0)
        this.value = 0;
    else
        this.value = "";
}
Variable.prototype.init = function (name, id) {
    this.id = trim(id);
    this.name = name;
    this.variableType = 0; //0 - numerical; 1 - string
    this.userVariable = false;
    this.RTFName = "";
    this.myValue = null;
    if (this.variableType == 0)
        this.value = 0;
    else
        this.value = "";
}
/**
 * Set value to a variable. Usually just update value and myvalue property of a variable, some scorm variable need to call the scorm api to set values.
 * @param {Object} value
 */
Variable.prototype.setValue = function (value) {
    switch (this.name) {
        case "USERID":
            this.value = value;
            this.myValue = value;
            Author.traineeID = value;
            break;
        case "SCORM_STUDENT_ID":
            break;
        case "SCORM_STUDENT_NAME":
            break;
        case "SCORM_LESSON_LOCATION": //
            if(Author.LessonManage.IsScorm){
                ScormProcessSetValue("cmi.core.lesson_location", value);
            }
            break;
        case "SCORM_CREDIT":
            break;
        case "SCORM_LESSON_STATUS": //
            if(Author.LessonManage.IsScorm){
                ScormProcessSetValue("cmi.core.lesson_status", value);
            }
            break;
        case "SCORM_ENTRY":
            break;
        case "SCORM_SCORE_RAW": //
            if(Author.LessonManage.IsScorm){
                ScormProcessSetValue("cmi.core.score.raw", value.toString());
            }
            Author.userDefinedScormResult = true;
            break;
        case "SCORM_TOTAL_TIME": //
            if(Author.LessonManage.IsScorm){
                ScormProcessSetValue("cmi.core.session_time", value);
            }
            break;
        case "SCORM_LESSON_MODE":
            if(Author.LessonManage.IsScorm){
                ScormProcessSetValue("cmi.core.lesson_mode", value);
            }
            break;
        case "SCORM_EXIT_REASON": //
            if(Author.LessonManage.IsScorm){
                ScormProcessSetValue("cmi.core.exit", value);
            }
            break;
        case "SCORM_COMMENTS": //
            if(Author.LessonManage.IsScorm){
                ScormProcessSetValue("cmi.coments", value);
            }
            break;
        case "SCORM_COMMENTS_FROM_LMS":
            if(Author.LessonManage.IsScorm){
                ScormProcessSetValue("cmi.comments_from_lms", value);
            }
            break;
        case "SCORM_MAX_TIME_ALLOWED":
            if(Author.LessonManage.IsScorm){
                ScormProcessSetValue("cmi.student_data.max_time_allowed", value);
            }
            break;
        case "SCORM_TIME_LIMIT_ACTION":
            if(Author.LessonManage.IsScorm){
                ScormProcessSetValue("cmi.student_data.time_limit_action", value);
            }
            break;
        case "SCORM_LANGUAGE": //
            if(Author.LessonManage.IsScorm){
                ScormProcessSetValue("cmi.student_preference.language", value);
            }
            break;
        case "SCORM_SERVERPATH":
            this.value = value;
            this.myValue = value;
            break;
        case "SCORM_EXECUTABLELESSON":
            this.value = value;
            this.myValue = value;
            break;
        default:
            this.value = value;
            this.myValue = value;
    }
}
/**
 * return the value of a variable.
 */
Variable.prototype.getValue = function () {
    switch (this.name) {
        case "BROWSERNAME":
            return BrowserDetect.browser;
        case "BROWSERVER":
            return BrowserDetect.version;
        case "OSNAME":
            return BrowserDetect.OS;
        case "OSVER":
            return "";
        case "HARDWARE":
            return BrowserDetect.hardware;
        case "ELEMENTNAME": // the name of the current element or lesson node.
            try {
                return Author.current.currentElement.name;
            }
            catch (err) {
                return Author.current.currentNode.name;
            }
        case "ELEMENTNUMBER": // the element position of the current element.
            return Author.current.currentElementPosition + 1;
        case "TIMEOUT": // the timeout value, set from a timedout element.
            return this.value;
        case "FIRSTNAME":
            return this.value;
        case "LASTNAME":
            return this.value;
        case "FULLNAME":
            return this.value;
        case "USERID":
            return this.value;
        case "SELECTEDVALUE": // the value name of the last selected action.
            return this.value;
        case "SELECTEDNAME": // the action name of the last selected action.
            return this.value;
        case "ANSWER", "ATTEMPT":
            return this.value;
        case "DATE": // get the current date.
            return Ext.util.Format.date(new Date());
        case "DAY":
            return new Date().getDate();
        case "MONTH":
            return new Date().getMonth();
        case "YEAR":
            return new Date().getYear();
        case "TIME":
            return Ext.util.Format.date(new Date(), "g:i:s A");
        case "COLOURS": // not really used in html. Just a system variable in author that tells how many colours the user's monitor have.
            return this.value;
        case "SCORE": // the score that a user gained. 
            return getLessonScore();
        case "TOTAL": // total score that the lesson have.
            return getLessonTotal();
        case "%SCORE": // percent score. 
            var total = getLessonTotal();
            if (total == 0) {
                return 0;
            }
            else {
                return parseInt(getLessonScore() * 100 / total);
            }
        case "CORRECTANSWER": //try to return the correct answer of an element. return -- if there is not a correct answer.
            try {
                var elementType = Author.current.currentElementXML.attributes[0].nodeValue;
            }
            catch (err) {
                return "--";
            }
            switch (elementType) {
                case "MULTIPLECHOICE":
                    var correctAnswers = Author.current.currentElementXML.getElementsByTagName("correctAnswer");
                    var count = correctAnswers.length;
                    var correctAnswer = "";
                    for (var index = 0; index < count; index++) {
                        var aAnswer = correctAnswers[index].childNodes[0].nodeValue.toUpperCase();
                        correctAnswer += (", " + aAnswer);
                    }
                    return correctAnswer.substr(2);
                    break;
                case "TRUEFALSE":
                    var correctAnswer = Author.current.currentElementXML.getElementsByTagName("correctAnswer")[0].childNodes[0].nodeValue.toLowerCase();
                    return (correctAnswer == "true") ? "True" : "False";
                    break;
                case "YESNO":
                    var correctAnswer = Author.current.currentElementXML.getElementsByTagName("correctAnswer")[0].childNodes[0].nodeValue.toLowerCase();
                    return (correctAnswer == "yes") ? "Yes" : "No";
                    break;
                case "SHORTANSWER":
                    var tempAnswer = Author.answers.shortAnswer;
                    var correctAnswers = Author.current.currentElementXML.getElementsByTagName("correctAnswer");
                    var count = correctAnswers.length;
                    var correctAnswer = "";
                    for (var index = 0; index < count; index++) {
                        var aAnswer = correctAnswers[index].childNodes[0].nodeValue.toUpperCase();
                        correctAnswer += (", " + aAnswer);
                    }
                    return correctAnswer.substr(2);
                    break;
            }
            return "--";
        case "QUESTIONANSWER": // not implemented.
            return this.name;
        case "RESOLUTION": // return the screen resolution, not implemented in html.
            return this.value;
        case "RESPONSETIME":
            return this.value;
        case "TIMER": // return the current system time as the value of a timer.
            return new Date().getTime();
        case "OPSCORE": // return how many scores the user gained in the current option.
            return Author.current.currentNode.getOptionScore();
        case "OPTOTAL": // return the total scores the current option have.
            return Author.current.currentNode.getOptionMaxScore();
        case "CHECKBOXES": // get the checkbox values if there is checkboxes on screen.
            return getCheckBoxValues();
        case "CORRECT": // check if answer is correct.
            return checkAnswer();
        case "INCORRECT":
            return !checkAnswer();
        case "ELAPSEDTIME": // return the time elapsed since the last user set starttime.
            return new Date() - Author.variables.get(variableName("STARTTIME")).value;
        case "INTELAPSEDTIME":
            //GetSystemValue = FindTimeDifference(Format(LastInteraction, "short time"), Format(Now, "short time"))
            return this.name;
        case "OPTIONTIME": // return the time spend in the current option.
            var opStart = Author.current.currentNode.optionStart;
            if (opStart != null) {
                return new Date() - opStart;
            }
            else {
                return 0;
            }
        case "RUNTOTAL": // same as lesson total
            return getLessonTotal();
        case "RUNOPTOTAL": // same as option total
            return Author.current.currentNode.getOptionMaxScore();
        case "RUN%SCORE":
            var total = getLessonTotal();
            if (total == 0) {
                return 0;
            }
            else {
                return parseInt(getLessonScore() * 100 / total);
            }
        case "SCORM_STUDENT_ID":
            return ScormProcessGetValue("cmi.core.student_id");
        case "SCORM_STUDENT_NAME":
            var scormName = ScormProcessGetValue("cmi.core.student_name");
            var nameS = scormName.split(",");
            var lastName = nameS[0];
            var firstName = trim(nameS[1]);
            return firstName + " " + lastName;
        case "SCORM_LESSON_LOCATION": //
            return ScormProcessGetValue("cmi.core.lesson_location");
        case "SCORM_CREDIT":
            return ScormProcessGetValue("cmi.core.credit");
        case "SCORM_LESSON_STATUS": //
            return ScormProcessGetValue("cmi.core.lesson_status");
        case "SCORM_ENTRY":
            return ScormProcessGetValue("cmi.core.entry");
        case "SCORM_SCORE_RAW": //
            return ScormProcessGetValue("cmi.core.score.raw");
        case "SCORM_TOTAL_TIME": //
            return ScormProcessGetValue("cmi.core.session_time");
        case "SCORM_LESSON_MODE":
            return ScormProcessGetValue("cmi.core.lesson_mode");
        case "SCORM_EXIT_REASON": //
            return ScormProcessGetValue("cmi.core.exit");
        case "SCORM_COMMENTS": //
            return ScormProcessGetValue("cmi.coments");
        case "SCORM_COMMENTS_FROM_LMS":
            return ScormProcessGetValue("cmi.comments_from_lms");
        case "SCORM_MAX_TIME_ALLOWED":
            return ScormProcessGetValue("cmi.student_data.max_time_allowed");
        case "SCORM_TIME_LIMIT_ACTION":
            return ScormProcessGetValue("cmi.student_data.time_limit_action");
        case "SCORM_LANGUAGE": //
            return ScormProcessGetValue("cmi.student_preference.language");
        case "SCORM_SERVERPATH":
            // alert("SCORM_SERVERPATH is not implemented.");
            return this.name;
        case "SCORM_EXECUTABLELESSON":
            alert("SCORM_EXECUTABLELESSON is not implemented");
            return this.name;
        default:
            return this.value;
    }
}
/**
 * Represent a response in author
 * @param {Object} condition
 * @param {Object} responseListXML
 */
function ResponseClass(condition, responseListXML) {
    this.doing = false;
    this.condition = condition;
    this.responseListXML = responseListXML;
    this.score = parseInt(this.responseListXML.getElementsByTagName("score")[0].childNodes[0].nodeValue);
    this.id = responseListXML.attributes[1].nodeValue;
}
/**
 * The Progressbar Class
 * @param {Object} body
 * @param {Object} cfgXML
 */
function ProgressbarClass(body, cfgXML, o) {
    this.objectType = "PROGRESSBAR";
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.width = parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue));
    this.height = parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue))
    this.left = parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue));
    this.top = parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue));
    this.borderWidth = parseInt(trim(cfgXML.getElementsByTagName("borderWidth")[0].childNodes[0].nodeValue));
    this.hide = trim(cfgXML.getElementsByTagName("hide")[0].childNodes[0].nodeValue).toLowerCase();
    this.visible = trim(cfgXML.getElementsByTagName("hide")[0].childNodes[0].nodeValue).toLowerCase() == "false";
    this.bgImage = Author.resourcePath + trim(cfgXML.getElementsByTagName("bgImage")[0].childNodes[0].nodeValue);
    this.barImage = Author.resourcePath + trim(cfgXML.getElementsByTagName("barImage")[0].childNodes[0].nodeValue);
    this.value = 50;
    this.content = body.createChild({
        tag: "div",
        style: "position:absolute;width:" + this.width + "px;height:" + this.height + "px;-moz-user-select: none;"
    });
    this.bg = this.content.createChild({
        tag: "img",
        alt: '',
        style: "position:absolute;left:0px;top:0px;width:" + this.width + "px;height:" + this.height + "px",
        src: this.bgImage
    })
    this.bar = this.content.createChild({
        tag: "img",
        alt: '',
        style: "position:absolute;left:" + this.borderWidth + "px;top:0px;height:" + this.height + "px",
        src: this.barImage
    })
    this.content.on("mouseDown", function (e) {
        e.stopEvent();
    })
}
ProgressbarClass.prototype.readConfig = function (cfgXML) {
    this.setLeft(this.left);
    this.setTop(this.top);
    this.setValue(this.value);
    this.setVisible(this.visible);
    return 0;
}
ProgressbarClass.prototype.setValue = function (value) {
    this.value = value;
    var barWidth = parseInt((this.width - this.borderWidth * 2) * value / 100);
    this.bar.setWidth(barWidth + "px");
}
ProgressbarClass.prototype.setTop = function (y) {
    this.content.setStyle("top", y + "px");
}
ProgressbarClass.prototype.setLeft = function (x) {
    this.content.setStyle("left", x + "px");
}
ProgressbarClass.prototype.setVisible = function (visible) {
    try {
        this.visible = visible;
        this.content.setVisible(visible);
    }
    catch (err) {
    }
}
ProgressbarClass.prototype.remove = function () {
    this.content.remove();
}
/**
 * Event handler of the dom onselectstart event.
 * Disable the onselect event so that the texts and images will not be selected.
 * BackgroundClass
 * @param {Object} documentBody
 */
function beselect() {
    try {
        var obj = Ext.get(event.srcElement.id);
        if (obj.dom.tagName == "INPUT" || obj.dom.tagName == "TEXTAREA") {
            event.returnValue = true;
        }
        else {
            event.returnValue = false;
        }
    }
    catch (err) {
        event.returnValue = false;
    }
}
/**
 * The background class.
 *
 * @param {Object} documentBody
 */
function BackgroundClass(documentBody) {
    this.objectType = "BACKGROUNDOBEJCT";
    var heightOffset = 0;
    if (Author.isHTML5) {
        if (Author.isIOS()) {
            heightOffset = 60;
        }
    }
    this.content = documentBody.createChild({
        tag: "div",
        tabindex: -1,
        style: "position:absolute;overflow:hidden;width:" + Author.lessonWidth + "px;height:" + (Author.lessonHeight + heightOffset) + "px;-moz-user-select:-moz-none;",
        onselectstart: "beselect();"
    });
    //if (Author.isIOS() == null){
    this.center();
    // }
}
;
BackgroundClass.prototype.readConfig = function (cfgXML) {
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.bgColor = "";
    this.bgImage = "";
    this.type = trim(cfgXML.getElementsByTagName("type")[0].childNodes[0].nodeValue);
    this.originalType = this.type;
    if (this.type == "color") {
        this.setBackgroundColor(trim(cfgXML.getElementsByTagName("background-color")[0].childNodes[0].nodeValue));
        this.originalColor = trim(cfgXML.getElementsByTagName("background-color")[0].childNodes[0].nodeValue);
        this.bgColor = this.originalColor;
    }
    else
    if (this.type == "image") {
        var imagePreLoad = new Image();
        imagePreLoad.src = Author.resourcePath + trim(cfgXML.getElementsByTagName("image")[0].childNodes[0].nodeValue);
        this.setBackgroundImage(Author.resourcePath + trim(cfgXML.getElementsByTagName("image")[0].childNodes[0].nodeValue));
        this.originalImage = Author.resourcePath + trim(cfgXML.getElementsByTagName("image")[0].childNodes[0].nodeValue);
        this.bgImage = trim(cfgXML.getElementsByTagName("image")[0].childNodes[0].nodeValue);
    }
    // If is IE and the lesson is zoomed down, don't use Fx effect.
    if (Ext.isIE && typeof(Author.autoZoom) != 'undefined' && Author.autoZoom && Author.zoomRatio < 1) {
        return 0;
    }
    else {
        return this.setFx(cfgXML);
    }
    //return 0;
}
BackgroundClass.prototype.setFx = function (cfgXML) {
    try {
        if (!Author.travellingList) {
            this.fxEffect = parseInt(trim(cfgXML.getElementsByTagName("FxEffect")[0].childNodes[0].nodeValue));
            this.fxDuration = parseInt(trim(cfgXML.getElementsByTagName("FxDuration")[0].childNodes[0].nodeValue)) / 1000;
            return setFxToElement(this, this.fxEffect, this.fxDuration);
        }
        else {
            return 0;
        }
    }
    catch (err) {
        return 0;
    }
}
/**
 * set the current lesson backgroud to the given bgObject
 * @param {Object} bgObject
 */
BackgroundClass.prototype.setBg = function (bgObject) {
    if (bgObject.type == "color") {
        this.type = "color";
        this.removeBackgroundImage();
        this.setBackgroundColor(bgObject.color);
        this.bgColor = bgObject.color;
        this.bgImage = "";
    }
    else
    if (bgObject.type == "image") {
        this.type = "image";
        this.setBackgroundImage(Author.resourcePath + bgObject.image);
        this.bgColor = "";
        this.bgImage = bgObject.image;
    }
}
/**
 * change the lesson background to the original bg.
 */
BackgroundClass.prototype.setOriginal = function () {
    if (this.originalType == "color") {
        this.removeBackgroundImage();
        this.setBackgroundColor(this.originalColor);
    }
    else
    if (this.originalType == "image") {
        this.setBackgroundImage(this.originalImage);
    }
}
/**
 * Implemetation of change background.
 * @param {Object} cfgXML
 */
BackgroundClass.prototype.change = function (cfgXML) {
    var changeBgObject = {
        epos: Author.current.currentElementPosition,
        type: this.type,
        color: this.bgColor,
        image: this.bgImage
    }
    var removeActions = true;
    try {
        removeActions = (cfgXML.attributes[2].nodeValue).toLowerCase() == "true";
    }
    catch (err) {
    }
    if (removeActions) {
        //alert(removeActions);
        clearScreen();
    }
    var bgType = trim(cfgXML.getElementsByTagName("type")[0].childNodes[0].nodeValue);
    if (bgType == "color") {
        this.setBackgroundColor(trim(cfgXML.getElementsByTagName("background-color")[0].childNodes[0].nodeValue));
        changeBgObject.epos = Author.current.currentElementPosition;
        this.type = "color";
        this.bgColor = trim(cfgXML.getElementsByTagName("background-color")[0].childNodes[0].nodeValue);
        this.bgImage = "";
    }
    if (bgType == "image") {
        var imagePreLoad = new Image();
        imagePreLoad.src = Author.resourcePath + trim(cfgXML.getElementsByTagName("image")[0].childNodes[0].nodeValue).toLowerCase();
        this.setBackgroundImage(Author.resourcePath + trim(cfgXML.getElementsByTagName("image")[0].childNodes[0].nodeValue).toLowerCase());
        changeBgObject.epos = Author.current.currentElementPosition;
        this.type = "image";
        this.bgColor = ""
        this.bgImage = trim(cfgXML.getElementsByTagName("image")[0].childNodes[0].nodeValue).toLowerCase();
    }
    else {
        this.removeBackgroundImage();
    }
    Author.current.currentBgStack.add(new String(Author.current.currentElementPosition), changeBgObject);
    var effectDuration;
    if (Ext.isIE && typeof(Author.autoZoom) != 'undefined' && Author.autoZoom && Author.zoomRatio < 1) {
        effectDuration = 0;
    }
    else {
        effectDuration = this.setFx(cfgXML);
    }
    if (!Author.travellingList) {
        /*  comment out @ 10/08/2011
         setTimeout(function(){
         orginalBG.remove();
         }, (effectDuration + 500));
         */
    }
    return 0;
}
BackgroundClass.prototype.setWidth = function (width) {
    this.content.setWidth(width);
    //if (Author.isIOS() == null){
    this.center();
    // }
}
BackgroundClass.prototype.setHeight = function (height) {
    this.content.setHeight(height);
    //  if (Author.isIOS() == null){
    this.center();
    //}
}
BackgroundClass.prototype.center = function () {
    var screenWidth = Ext.lib.Dom.getViewWidth();
    var screenHeight = Ext.lib.Dom.getViewHeight();
    //	alert(screenWidth+" x "+screenHeight);
    var left = 0;
    var top = 0;
    if (screenWidth > Author.lessonWidth) {
        left = (screenWidth - Author.lessonWidth) / 2;
    }
    if (screenHeight > Author.lessonHeight) {
        top = (screenHeight - Author.lessonHeight) / 2;
    }
    this.content.applyStyles("left:" + left + "px;top:" + top + "px");
    //this.content.center();
    if (Ext.isIE && typeof(Author.autoZoom) != 'undefined' && Author.autoZoom) {
        var screenWidth = Ext.lib.Dom.getViewWidth();
        var screenHeight = Ext.lib.Dom.getViewHeight();
        var ratioV = screenHeight / Author.lessonHeight
        var ratioW = screenWidth / Author.lessonWidth
        var ratio = Math.min(ratioV, ratioW, 1);
        Author.zoomRatio = ratio;
        this.zoomTo(ratio);
    }
}
BackgroundClass.prototype.zoomTo = function (zoomRate) {
    this.content.setStyle("zoom", zoomRate);
    var viewWidth = Ext.lib.Dom.getViewWidth();
    var viewHeight = Ext.lib.Dom.getViewHeight();
    this.content.setLeft((viewWidth - this.content.getWidth() * zoomRate) / 2);
    this.content.setTop((viewHeight - this.content.getHeight() * zoomRate) / 2);
}
BackgroundClass.prototype.setBackgroundColor = function (color) {
    this.content.setStyle("background-color", color);
}
BackgroundClass.prototype.removeBackgroundImage = function () {
    this.content.setStyle("background-image", "");
}
BackgroundClass.prototype.setBackgroundImage = function (url) {
    this.content.setStyle("background-image", "url(" + Ext.encode(url.toLowerCase()) + ")");
    this.content.setStyle("background-repeat", "no-repeat");
}
BackgroundClass.prototype.getContent = function () {
    return this.content;
}
/**
 * The Special Action
 * @param {Object} cfgXML
 */
function SpecialClass(cfgXML, o) {
    this.objectType = "SPECIAL";
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.specialType = parseInt(trim(cfgXML.getElementsByTagName("specialType")[0].childNodes[0].nodeValue));
    //  alert(this.specialType);
    switch (this.specialType) {
        case 0: // Exit lesson / option 
            this.specialExit = parseInt(trim(cfgXML.getElementsByTagName("specialExit")[0].childNodes[0].nodeValue));
            if (this.specialExit == 0) {
                // exit lesson and don not show the confirm dialog.
                if (Author.pause != null && Author.pause.cancelType != 0) {
                    Author.pause = null;
                    window.clearTimeout(Author.actionTimer);
                }
                endLesson(false);
            }
            else {
                // Exit the current option and return to the parent menu.
                Author.current.currentNode = Author.lessonNodes.nodes.get(getParentNode());
                Author.current.currentNode.endListShown = false;
                Author.goingUpperMenu = true;
                // need to reset the backgroud.
                while (Author.current.currentBgStack.getCount() > 0) {
                    var bgObject = Author.current.currentBgStack.last();
                    Author.current.currentBgStack.remove(bgObject);
                    if (Author.current.currentBgStack.getCount() == 0) {
                        Author.backgroundObject.setBg(bgObject);
                    }
                }
                // and reset current variable.
                Author.current.currentElementXML = null;
                Author.current.currentElement = null;
                Author.current.currentElementType = "";
                Author.current.currentElementResponses.clear();
                Author.current.currentElementPosition = -1;
                Author.current.currentListPosition = 0;
                Author.response.clear();
                Author.current.currentElementResponses.clear();
                Author.current.randomOptionsCollection.clear();
                Author.clearBackgroundObjects = true;
                Author.backToMenu = true;
                Author.responseEnd = true;
                Author.inResponse = false;
                showLessonNode();
            }
            break;
        case 3:
            // open a webpage from a given url. Note:going to user popup window here. Might be blocked by the user's browsers
            this.url = cfgXML.getElementsByTagName("URL")[0].childNodes[0].nodeValue;
            if (isUrl(this.url)) {
                logGoogleAnalytics("OpenURL", this.url);
                if (Author.isAuthorViewer()) {
                    //alert(this.url);
                    window.location = "author:OpenURL:" + this.url;
                }
                else {
                    myRef = window.open('' + this.url, 'win' + this.id);
                }
            }
            else {
                var pagePath = location.pathname.toString();
                //alert(pagePath);
                //	alert(pagePath.replace);
                // var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
                //alert(ie6);
                //  if (ie6) {
                pagePath = pagePath.replace(/\\/gi, "/");
                // }
                var base = location.href;
                //alert(pagePath +"\n"+base);
                if (base.search(".htm") > 0) {
                    var tail = base.substring(base.lastIndexOf('/') + 1);
                    // alert(tail +"\n"+base);
                    base = base.replace(tail, Author.resourcePath);
                }
                else {
                    base = base + Author.resourcePath;
                }
                var tryThis = eval(Ext.encode(base + this.url.toLowerCase()));
                logGoogleAnalytics("OpenURL", this.url);
                if (Author.isAuthorViewer()) {
                    window.location = "author:OpenURL:" + tryThis;
                }
                else {
                    //alert("openFile:"+tryThis);
                    myRef = window.open('' + tryThis, 'win' + this.id);
                }
            }
            break;
        case 4:
            this.innerHTML = cfgXML.getElementsByTagName("html")[0].childNodes[0].nodeValue;
            if (Ext.isIE) {
                Author.pause = {
                    cancelType: 9
                }
                printHidden(replaceVariableNameWithValue(this.innerHTML));
            }
            else {
                this.content = Author.backgroundObject.getContent().createChild({
                    tag: "iframe",
                    style: "position:absolute;overflow:auto;visible:none;"
                });
                this.content.setWidth(0);
                this.content.setHeight(0);
                this.content.setVisible(false);
                var ifrm = this.content.dom;
                ifrm = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument;
                ifrm.document.open();
                ifrm.document.write(replaceVariableNameWithValue(this.innerHTML));
                ifrm.document.close();
                ifrm.focus();
                ifrm.print();
                // this.content.remove();
            }
            break;
        case 11:
            this.specialID = parseInt(trim(cfgXML.getElementsByTagName("specialID")[0].childNodes[0].nodeValue));
            try {
                Author.current.currentNode = Author.lessonNodes.nodes.get(this.specialID);
                Author.current.currentNode.endListShown = false;
                Author.current.currentElementXML = null;
                Author.current.currentElement = null;
                Author.current.currentElementType = "";
                Author.current.currentElementResponses.clear();
                Author.current.currentElementPosition = -1;
                Author.current.currentListPosition = 0;
                Author.response.clear();
                Author.current.randomOptionsCollection.clear();
                Author.current.currentElementResponses.clear();
                Author.clearBackgroundObjects = true;
                Author.backToMenu = true;
                showLessonNode();
            }
            catch (err) {
                if (Author.Test.type == "selectedOnly") {
                    alert("Can't jump to option: " + this.specialID + ", because the testing mode is testing selected option/element only.");
                }
                else {
                    alert("Action: " + Author.current.currentListXML.getElementsByTagName("action")[Author.current.currentActionPosition - 1].attributes[0].nodeValue + " is not processed correctly.\nError description:" + err.description);
                }
            }
            break;
        case 12:

            /*
             Ext.state.Manager.setProvider(new Ext.state.CookieProvider({
             expires: new Date(new Date().getTime() + (1000 * 60 * 60 * 24 * 365))
             }));
             */
            var BMString = Get_Cookie(Author.projectName + "[" + Author.traineeID + "]", "");
            //alert(Author.projectName + "[" + Author.traineeID + "]\n"+BMString);
            if (BMString == null) {
                BMString = "";
            }
            if (BMString != "") {
                var bmStr = BMString.split("||");
                Author.optionBMString = bmStr[0];
                Author.variableBMString = bmStr[1];
            }
            if (Author.bookMark) {
                Author.lessonNodes.nodes.eachKey(function (key, object) {
                    object.readBookmark(Author.optionBMString);
                });
            }
            var lessonName = trim(cfgXML.getElementsByTagName("lessonName")[0].childNodes[0].nodeValue);
            var bmString = Author.variableBMString;
            var readAllBM = trim(cfgXML.getElementsByTagName("readALLBM")[0].childNodes[0].nodeValue).toLowerCase() == "true";
            if (readAllBM) {
                var regex = /{(\[(\d+)\][^}]*)}/g;
                var bookmarks = (bmString.match(regex));
                if (bookmarks != null) {
                    var bmCount = bookmarks.length;
                    for (var i = 0; i < bmCount; i++) {
                        var chunk = bookmarks[i].match(/(\[(\d+)\][^}]*)/)[0];
                        var partID = chunk.match(/(\[(\d+)\])/)[0];
                        var vid = (partID.match(/(\d+)/)[0]);
                        var value = chunk.replace(partID, "");
                        var theVar = getVariableByID(vid);
                        if (theVar != null) {
                            theVar.value = value;
                        }
                    }
                }
            }
            else {
                var vName = trim(cfgXML.getElementsByTagName("variableName")[0].childNodes[0].nodeValue).toUpperCase();
                var vid = variableName(vName);
                var theVar = getVariableByID(vid);
                if (theVar != null) {
                    var regex = new RegExp("{(\\[" + vid + "\\][^}]*)}", "g");
                    var regex2 = new RegExp("(\\[" + vid + "\\][^}]*)", "g");
                    var chunk = bmString.match(regex);
                    if (chunk == null) {
                        theVar.value = "";
                    }
                    else {
                        chunk = chunk[0].match(regex2)[0];
                        var partID = chunk.match(/(\[(\d+)\])/)[0];
                        var vid = (partID.match(/(\d+)/)[0]);
                        var value = chunk.replace(partID, "");
                        theVar.value = value;
                    }
                }
            }
            break;
        case 13:
            try {
                this.showElementCode = (trim(cfgXML.getElementsByTagName("showElementCode")[0].childNodes[0].nodeValue).toLowerCase() == "true");
                this.expandNode = (trim(cfgXML.getElementsByTagName("expandNode")[0].childNodes[0].nodeValue).toLowerCase() == "true");
            }
            catch (err) {
                this.showElementCode = false;
                this.expandNode = true;
            }
            try {
                this.showButtons = (trim(cfgXML.getElementsByTagName("showButtons")[0].childNodes[0].nodeValue).toLowerCase() == "true");
                this.windowTitle = cfgXML.getElementsByTagName("windowTitle")[0].childNodes[0].nodeValue;
            }
            catch (err) {
                this.showButtons = false;
                this.windowTitle = "Reference";
            }
            showLessonStructure(this.showElementCode, this.expandNode, this.showButtons, this.windowTitle);
            break;
        case 14:
            this.text = cfgXML.getElementsByTagName("text")[0].childNodes[0].nodeValue;
            this.waitUntilFinish = (trim(cfgXML.getElementsByTagName("wait")[0].childNodes[0].nodeValue).toLowerCase() == "true");
            break;
    }
}
SpecialClass.prototype.readConfig = function (cfgXML) {
    if (this.specialType == 14) {
        var textToSpeak = replaceVariableNameWithValue(this.text);
        //alert("speakText:"+textToSpeak);
        speakText(textToSpeak, this.id);
        if (this.waitUntilFinish) {
            Author.speech.id = this.id;
            return 3600 * 24 * 1000;
        }
        return 0;
    }
    if (this.specialType == 4) {
        if (Ext.isIE) {
            return 3600 * 24 * 1000;
        }
        else {
            return 1500;
        }
    }
    return 0;
}
SpecialClass.prototype.remove = function () {
    if (this.specialType == 4) {
        if (!Ext.isIE) {
            this.content.remove();
        }
    }
}
SpecialClass.prototype.setVisible = function (visible) {
}
function WebElementClass(bgObject, o) {
    this.objectType = "WEBBROWSEROBJECT";
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.content = bgObject.createChild({
        tag: "iframe",
        frameborder: Ext.isIE ? "0" : "1",
        style: "position:absolute;background-color:#fff;"
    })
}
WebElementClass.prototype.readConfig = function (cfgXML) {
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.content.setStyle("position", "absolute");
    this.setTop(parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue)));
    this.setLeft(parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue)));
    this.setWidth(parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue)));
    this.setHeight(parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue)));
    this.type = trim(cfgXML.getElementsByTagName("type")[0].childNodes[0].nodeValue);
    this.url = trim(cfgXML.getElementsByTagName("url")[0].childNodes[0].nodeValue);
    this.setURL(this.url);
    try {
        this.content.setStyle("border-style", trim(cfgXML.getElementsByTagName("borderStyle")[0].childNodes[0].nodeValue));
        this.content.setStyle("border-width", trim(cfgXML.getElementsByTagName("borderWidth")[0].childNodes[0].nodeValue));
        this.content.setStyle("border-color", trim(cfgXML.getElementsByTagName("borderColor")[0].childNodes[0].nodeValue));
    }
    catch (err) {
        alert("WebElement:\n" + err.description);
    }
    this.setVisible(true);
    return 0;
}
WebElementClass.prototype.toFront = function () {
    this.content.setStyle("z-index", 65);
}
WebElementClass.prototype.setURL = function (url) {
    try {
        if (this.type == "WWW")
            this.content.dom.src = url;//eval(Ext.encode(url.toLowerCase()));
        else {
            var pagePath = location.pathname.toString();
            pagePath = pagePath.replace(/\\/g, '/');
            var base = location.href;
            if (base.search(".htm") > 0) {
                var tail = base.substring(base.lastIndexOf('/') + 1);
                // alert(tail +"\n"+base);
                base = base.replace(tail, Author.resourcePath);
            }
            else {
                base = base + Author.resourcePath;
            }
            if (base.indexOf('?') > 0) {
                base = base.substring(0, base.indexOf('?'));
            }
            this.content.dom.src = eval(Ext.encode(base + url.toLowerCase()));
            // alert( this.content.dom.src);
        }
    }
    catch (err) {
    }
}
WebElementClass.prototype.setTop = function (y) {
    this.content.setStyle("top", y + "px");
}
WebElementClass.prototype.setLeft = function (x) {
    this.content.setStyle("left", x + "px");
}
WebElementClass.prototype.setWidth = function (width) {
    this.content.setWidth(width);
}
WebElementClass.prototype.setHeight = function (height) {
    this.content.setHeight(height);
}
WebElementClass.prototype.setVisible = function (visible) {
    this.visible = visible;
    this.content.setVisible(visible);
}
WebElementClass.prototype.remove = function () {
    this.content.remove();
}
/**
 * ImageClass
 * @param {Object} documentBody
 */
function ImageClass(bgObject, cfgXML, o) {
    this.objectType = "IMAGEOBEJCT";
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.changeByID = null;
    this.cfgXML = cfgXML;
    this.width = parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue));
    this.height = parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue))
    this.left = parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue));
    this.top = parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue));
    this.imageName = cfgXML.getElementsByTagName("image")[0].childNodes[0].nodeValue.toLowerCase();
    try {
        this.baseColor = trim(cfgXML.getElementsByTagName("borderColor")[0].childNodes[0].nodeValue);
    }
    catch (err) {
        this.baseColor = "#ff0000";
    }
    var imagePreLoad = new Image();
    imagePreLoad.src = Author.resourcePath + this.imageName;
    this.changeAction = trim(cfgXML.getElementsByTagName("changeAction")[0].childNodes[0].nodeValue).toLowerCase();
    this.hasShadow = trim(cfgXML.getElementsByTagName("shadow")[0].childNodes[0].nodeValue).toLowerCase();
    this.hide = trim(cfgXML.getElementsByTagName("hide")[0].childNodes[0].nodeValue).toLowerCase();
    this.addToBackground = (trim(cfgXML.getElementsByTagName("addToBackground")[0].childNodes[0].nodeValue).toLowerCase() == "true");
    // this.hasShadow="false";
    this.bgObject = bgObject;
    if (this.changeAction == "true") {
        this.originalID = trim(cfgXML.getElementsByTagName("originalID")[0].childNodes[0].nodeValue);
        this.changeID = trim(cfgXML.getElementsByTagName("changeID")[0].childNodes[0].nodeValue);
        try {
            this.addToBackground = Author.current.currentList.item(this.changeID).addToBackground;
        }
        catch (err) {
            this.addToBackground = false;
        }
    }
    else {
        if (this.hasShadow == "true") {
            this.content = bgObject.createChild({
                tag: "div",
                style: "overflow:hidden;background: url(lib/images/upperrightfade.png) right top no-repeat;position:absolute;left:" + (this.left) + "px;top:" + (this.top) + "px;width:" + (this.width + 8) + "px;height:" + (this.height + 8) + "px;"
            })
            var op2 = this.content.createChild({
                tag: "div",
                style: "overflow:hidden;background: url(lib/images/lowerleftfade.png) left bottom no-repeat; padding-top: 8px; padding-left: 8px;"
            })
            var shadowBox = op2.createChild({
                tag: "div",
                style: "background: url(lib/images/shadow.png) bottom right no-repeat;width:" + this.width + "px;height:" + this.height + "px;"
            })
            var innerBox = shadowBox.createChild({
                tag: "div",
                style: "overflow:hidden;position:relative;width:" + this.width + "px;height:" + this.height + "px; left: -8px; top: -8px;"
            })
            this.img = innerBox.createChild({
                tag: "img",
                alt: '',
                style: "position:absolute;left:" + (0) + "px;top:" + (0) + "px;width:" + this.width + "px;height:" + this.height + "px;"
            })
        }
        else {
            this.content = bgObject.createChild({
                tag: "div",
                width: this.width + "px",
                height: this.height + "px",
                style: "position:absolute;left:" + (this.left) + "px;top:" + (this.top) + "px;"
            });
            this.img = this.content.createChild({
                tag: "img",
                alt: '',
                width: this.width + "px",
                height: this.height + "px",
                style: "position:absolute;left:" + (0) + "px;top:" + (0) + "px"
            })
        }
        this.content.on("mouseDown", function (e) {
            e.stopEvent();
        })
        this.visible = true;
    }
}
;
ImageClass.prototype.toFront = function () {
    this.content.setStyle("z-index", 65);
}
ImageClass.prototype.change = function (cfgXML) {
    Author.current.currentList.item(this.changeID).changeByID = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    var animate = trim(cfgXML.getElementsByTagName("AnimateImage")[0].childNodes[0].nodeValue).toLowerCase() == "true";
    this.imageName = cfgXML.getElementsByTagName("image")[0].childNodes[0].nodeValue.toLowerCase();
    var changeObject = Author.current.currentList.item(this.changeID);
    // var pageXY1 = Author.backgroundObject.content.getXY();
    changeObject.content.applyStyles("position:absolute;left:" + changeObject.left + "px;top:" + changeObject.top + "px");
    var oldLeft = changeObject.content.getStyle("left");
    var oldTop = changeObject.content.getStyle("top");
    //  alert(oldLeft + ", " + oldTop);
    this.width = parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue));
    this.height = parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue))
    this.left = parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue));
    this.top = parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue));
    this.hasShadow = trim(cfgXML.getElementsByTagName("shadow")[0].childNodes[0].nodeValue).toLowerCase();
    if (!animate) {
        //alert("not animate");
        oldLeft = this.left;
        oldTop = this.top;
    }
    else {
        oldLeft = parseInt(oldLeft.replace("px", ""));
        oldTop = parseInt(oldTop.replace("px", ""));
    }
    if (this.hasShadow == "true") {
        this.content = this.bgObject.createChild({
            tag: "div",
            style: "background: url(lib/images/upperrightfade.png) right top no-repeat;position:absolute;left:" + (oldLeft) + "px;top:" + (oldTop) + "px;width:" + (this.width + 8) + "px;height:" + (this.height + 8) + "px"
        })
        var op2 = this.content.createChild({
            tag: "div",
            style: "background: url(lib/images/lowerleftfade.png) left bottom no-repeat; padding-top: 8px; padding-left: 8px;"
        })
        var shadowBox = op2.createChild({
            tag: "div",
            style: "background: url(lib/images/shadow.png) bottom right no-repeat;"
        })
        var innerBox = shadowBox.createChild({
            tag: "div",
            style: "position:relative;width:" + this.width + "px;height:" + this.height + "px; left: -8px; top: -8px;"
        })
        this.img = innerBox.createChild({
            tag: "img",
            style: "width:" + this.width + "px;height:" + this.height + "px"
        })
    }
    else {
        this.content = this.bgObject.createChild({
            tag: "div",
            width: this.width + "px",
            height: this.height + "px",
            style: "position:absolute;left:" + (oldLeft) + "px;top:" + (oldTop) + "px"
        });
        this.img = this.content.createChild({
            tag: "img",
            width: this.width + "px",
            height: this.height + "px",
            style: "position:absolute;left:" + (0) + "px;top:" + (0) + "px"
        })
    }
    var pageXY = Author.backgroundObject.getContent().getXY();
    var xy = this.content.getOffsetsTo(Author.backgroundObject.getContent());
    //alert(this.left-oldLeft1+"\n"+Author.zoomRatio);
    var xyOld = changeObject.content.getOffsetsTo(Author.backgroundObject.getContent());
    // this.x1 = pageXY[0] + xy[0] + (this.left - xyOld[0]);
    // this.y1 = pageXY[1] + xy[1] + (this.top - xyOld[1]);
    // alert(this.left - xyOld[0]+"\n"+Author.zoomRatio);
    this.x1 = pageXY[0] + xy[0] + this.left - xyOld[0] / Author.zoomRatio;
    this.y1 = pageXY[1] + xy[1] + this.top - xyOld[1] / Author.zoomRatio;
    this.imageName = cfgXML.getElementsByTagName("image")[0].childNodes[0].nodeValue.toLowerCase();
    this.addToBackground = Author.current.currentList.item(this.changeID).addToBackground;
    if (this.addToBackground) {
        this.addToBackgroundAtElementPosition = Author.current.currentList.item(this.changeID).addToBackgroundAtElementPosition;
        this.addElementPosition = Author.current.currentElementPosition;
        this.orginalListID = Author.current.currentListXML.attributes[1].nodeValue;
        Author.backgroundList.list.add(this.id, this);
    }
    this.setImage(Author.resourcePath + this.imageName);
    this.setVisible(true);
    this.setAnimation(cfgXML) + this.setFx(cfgXML);
    return 0;
}
ImageClass.prototype.setProperties = function (cfgXML) {
    this.imageName = cfgXML.getElementsByTagName("image")[0].childNodes[0].nodeValue.toLowerCase();
    this.setTop(parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue)));
    this.setLeft(parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue)));
    this.setWidth(parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue)));
    this.setHeight(parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue)));
    this.setImage(Author.resourcePath + this.imageName);
    this.setVisible(true);
    try {
        //   this.doRotationAndFlip(cfgXML);
    }
    catch (err) {
    }
}
/**
 * this is the code for doing the rotation and flipping and shadow of the image using the Raphael Library, unfortunately since it is not
 * quite compatible with the Opacity, we just forget it for the moment.
 *
 *
 * @param {Object} cfgXML
 */
ImageClass.prototype.doRotationAndFlip = function (cfgXML) {
    // resize the container
    // hide the current image
    this.img.setVisible(false);
    var flip = cfgXML.getElementsByTagName("flip")[0].childNodes[0].nodeValue;
    var rotation = parseInt(cfgXML.getElementsByTagName("rotation")[0].childNodes[0].nodeValue);
    // if (rotation > 0) {
    //calculate the smallest square that can contain the rotation of the image
    var r = parseInt(Math.sqrt(this.width * this.width + this.height * this.height));
    var newLeft = this.left - (r - this.width) / 2;
    var newTop = this.top - (r - this.height) / 2;
    //move the container to a proper location so that when drawing the image in the center, the position of the image will not change.
    this.content.applyStyles("position:absolute;left:" + newLeft + "px;top:" + newTop + "px;width:" + (r) + "px;height:" + (r) + "px");
    var imageContainer = Raphael(this.content.dom, r, r);
    //   }
    // else {
    //     var imageContainer = Raphael(this.content.dom, this.width, this.height);
    // }
    // only to match the 4 rotations in author. no need to do so ..
    var angle = 360 - 90 * rotation;
    if (rotation == 1) {
        angle = 270;
        var temp = this.height;
        this.height = this.width;
        this.width = temp;
        if (flip == "V") {
            flip = "H";
        }
        else
        if (flip == "H") {
            flip = "V";
        }
    }
    if (rotation == 3) {
        angle = 90;
        var temp = this.height;
        this.height = this.width;
        this.width = temp;
        if (flip == "V") {
            flip = "H";
        }
        else
        if (flip == "H") {
            flip = "V";
        }
    }
    // alert(angle +", "+flip);
    // this.RImage = imageContainer.set();
    // alert(this.hasShadow);
    if (this.hasShadow == "true") {

        // Draw the shadow.
        // Params: 	shadowR -shadow Size
        //			shadowColor 
        //			offsetX
        //			offsetY
        //			alpha
        try {
            this.RShadow = imageContainer.set();
            var shadowR = parseInt(cfgXML.getElementsByTagName("shadowSize")[0].childNodes[0].nodeValue);
            var shadowColor = cfgXML.getElementsByTagName("shadowColor")[0].childNodes[0].nodeValue;
            var offsetX = parseInt(cfgXML.getElementsByTagName("shadowX")[0].childNodes[0].nodeValue);
            var offsetY = parseInt(cfgXML.getElementsByTagName("shadowY")[0].childNodes[0].nodeValue);
            var alpha = parseInt(cfgXML.getElementsByTagName("shadowAlpha")[0].childNodes[0].nodeValue) / 255;
            var shadowWidth = this.width + shadowR * 2;
            var shadowHeight = this.height + shadowR * 2;
            shadowR = shadowR * 2;
            var rect = imageContainer.rect((r - shadowWidth) / 2 + shadowR, (r - shadowHeight) / 2 + shadowR, shadowWidth - shadowR * 2, shadowHeight - shadowR * 2);
            rect.attr({
                fill: shadowColor,
                stroke: 0,
                opacity: alpha
            })
            rect.translate(offsetX, offsetY);
            this.RShadow.push(rect);
            for (var i = 0; i < shadowR; i += Author.zoomRatio) {
                var rect = imageContainer.rect((r - shadowWidth) / 2 + shadowR - i, (r - shadowHeight) / 2 + shadowR - i, shadowWidth - (shadowR - i) * 2, shadowHeight - (shadowR - i) * 2, i);
                rect.attr({
                    stroke: shadowColor,
                    "stroke-opacity": curve((i / shadowR), 1.28) * alpha,
                    "stroke-width": Author.zoomRatio
                })
                rect.translate(offsetX, offsetY);
                this.RShadow.push(rect);
            }
        }
        catch (err) {
        }
    }
    // this.RImage=imageContainer.image(this.img.dom.src, (r - this.width) / 2, (r - this.height) / 2, this.width, this.height);
    // if (rotation > 0) {
    this.RImage = imageContainer.image(this.img.dom.src, (r - this.width) / 2, (r - this.height) / 2, this.width, this.height);
    this.rotate(angle);
    // }
    // else {
    //    this.RImage = imageContainer.image(this.img.dom.src, 0, 0, this.width, this.height);
    // }
    /*
     this.RImage.attr({
     stroke:"none",
     "stroke-width":0
     })
     */
    // alert(Author.zoomRatio);
    this.flip(flip);
}
/**
 * Rotate the image by angle degree
 * @param {Object} angle
 */
ImageClass.prototype.rotate = function (angle) {
    this.RImage.attr({
        rotation: angle
    });
    if (this.hasShadow == "true") {
        this.RShadow.attr({
            rotation: angle
        });
    }
}
/**
 * flip the image
 * @param {Object} type
 */
ImageClass.prototype.flip = function (type) {
    if (type == "V") {
        this.RImage.scale(1, -1);
    }
    if (type == "H") {
        this.RImage.scale(-1, 1);
    }
    if (type == "VH") {
        this.RImage.scale(-1, -1);
    }
}
/**
 * hide or show the shadow of the image
 * @param {Object} visible
 */
ImageClass.prototype.setShadowVisible = function (visible) {
    this.content.setVisible(visible);
    this.img.setVisible(true);
    /*
     try {
     if (visible) {
     this.RShadow.show();

     }
     else {
     this.RShadow.hide();
     }
     }
     catch (err) {
     }
     */
}
ImageClass.prototype.readConfig = function (cfgXML) {
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    if (this.changeAction == "true") {
        Author.current.currentList.item(this.changeID).setVisible(false);
        return this.change(cfgXML);
    }
    this.setProperties(cfgXML);
    this.addToBackground = (trim(cfgXML.getElementsByTagName("addToBackground")[0].childNodes[0].nodeValue).toLowerCase() == "true");
    if (this.addToBackground) {
        this.orginalListID = Author.current.currentListXML.attributes[1].nodeValue;
        // Author.backgroundList.list.add(this.id, this);
        this.addToBackgroundAtElementPosition = Author.current.currentElementPosition;
    }
    this.setFx(cfgXML);
    return 0;
}
ImageClass.prototype.setAnimation = function (cfgXML) {
    try {
        var animate = trim(cfgXML.getElementsByTagName("AnimateImage")[0].childNodes[0].nodeValue).toLowerCase();
        if (animate == "true") {
            var speed = parseInt(trim(cfgXML.getElementsByTagName("AnimateSpeed")[0].childNodes[0].nodeValue));
            var steps = parseInt(trim(cfgXML.getElementsByTagName("AnimateSteps")[0].childNodes[0].nodeValue));
            var fxElement = (this.hasShadow == "true") ? this.img : this.content;
            var duration = speed * steps * 20 / 1000
            fxElement.sequenceFx();
            fxElement.shift({
                width: this.width,
                height: this.height,
                x: this.x1,
                y: this.y1,
                duration: duration
            });
            return duration * 1000;
        }
        else {
            return 0;
        }
    }
    catch (err) {
        return 0;
    }
}
ImageClass.prototype.setFx = function (cfgXML) {
    this.fxEffect = 0;
    try {
        this.fxEffect = parseInt(trim(cfgXML.getElementsByTagName("FxEffect")[0].childNodes[0].nodeValue));
        this.fxDuration = parseInt(trim(cfgXML.getElementsByTagName("FxDuration")[0].childNodes[0].nodeValue)) / 1000;
        return setFxToElement(this, this.fxEffect, this.fxDuration);
    }
    catch (err) {
        return 0;
    }
}
ImageClass.prototype.setImage = function (url) {
    this.img.dom.src = eval(Ext.encode(url.toLowerCase()));
    this.fixPng();
}
ImageClass.prototype.fixPng = function () {
    var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
    var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
    if (Ext.isIE && (ie55 || ie6) && (this.imageName.indexOf(".png") >= 0)) {
        this.img.setStyle("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + Author.resourcePath + this.imageName + "',sizingMethod='image')");
        this.img.dom.src = "lib/images/blank.gif";
    }
}
ImageClass.prototype.setTop = function (y) {
    this.content.setStyle("top", y + "px");
}
ImageClass.prototype.setLeft = function (x) {
    this.content.setStyle("left", x + "px");
}
ImageClass.prototype.setWidth = function (width) {
    if (this.hasShadow == "true")
        width = width + 8;
    this.content.setWidth(width);
}
ImageClass.prototype.setHeight = function (height) {
    if (this.hasShadow == "true")
        height = height + 8;
    this.content.setHeight(height);
}
ImageClass.prototype.setVisible = function (visible) {
    /*
     if (visible == false) {
     alert(this.id + ", " + visible);
     }
     */
    this.visible = visible;
    if (this.changeByID != null) {
        Author.current.currentList.item(this.changeByID).setVisible(visible);
    }
    else {
        try {
            if (this.hasShadow == "true") {
                this.setShadowVisible(visible);
            }
            this.img.setVisible(visible);
        }
        catch (err) {
            //alert(err.description);
        }
    }
}
ImageClass.prototype.hide = function (visible) {
    if (this.changeByID != null) {
        Author.current.currentList.item(this.changeByID).setVisible(visible);
    }
    else {
        this.setVisible(visible);
    }
}
ImageClass.prototype.remove = function () {
    try {
        if (this.changeAction == "true") {
            Author.current.currentList.item(this.originalID).changeByID = null;
        }
        if (this.fxEffect != 0) {
            this.img.stopFx();
        }
        this.content.remove();
    }
    catch (err) {
    }
}
/**
 * MediaClass
 * @param {Object} documentBody
 */
function MediaClass(bgObject, cfgXML, o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.top = parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue));
    this.left = parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue));
    this.height = parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue));
    this.width = parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue))
    this.objectType = "MEDIAOBJECT";
    this.url = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("url")[0].childNodes[0].nodeValue))).toLowerCase();
    this.autoStart = trim(cfgXML.getElementsByTagName("autoStart")[0].childNodes[0].nodeValue).toLowerCase();
    this.playCount = trim(cfgXML.getElementsByTagName("playCount")[0].childNodes[0].nodeValue);
    this.uiMode = (trim(cfgXML.getElementsByTagName("uiMode")[0].childNodes[0].nodeValue));
    this.playSelection = (trim(cfgXML.getElementsByTagName("playSelection")[0].childNodes[0].nodeValue).toLowerCase() == "true");
    this.startPos = parseFloat(trim(cfgXML.getElementsByTagName("startPosition")[0].childNodes[0].nodeValue));
    this.endPos = parseFloat(trim(cfgXML.getElementsByTagName("endPosition")[0].childNodes[0].nodeValue))
    this.windowlessVideo = trim(cfgXML.getElementsByTagName("windowlessVideo")[0].childNodes[0].nodeValue).toLowerCase();
    this.visible = true;
    if (Author.isHTML5) {
        this.content = bgObject.createChild({
            tag: "div",
            style: "background-color:#000;position:absolute;left:" + this.left + "px;top:" + this.top + "px;width:" + this.width + "px;height:" + this.height + "px"

        });
        this.mediaID = this.content.dom.id + "-Media";
        Author.mediaList.eachKey(function (key, object) {
            try {
                if (object.objectType == "SOUNDOBJECT") {
                    object.audioObject.dom.pause();
                    object.audioObject.dom.volume = 0;
                }
                if (object.objectType == "MEDIAOBJECT") {
                    object.videoObject.dom.pause();
                    object.videoObject.dom.volume = 0;
                }
            }
            catch (err) {
            }
            try {
                var theAudioObject = document.getElementById(object.mediaID);
                theAudioObject.stop();
            }
            catch (err) {
            }
        });
        this.videoObject = this.content.createChild({
            tag: "Video",
            id: this.mediaID,
            controls: "controls",
            style: "position:absolute:left:0px;top:0px;width:100%;height:100%",
            ap: this.autoStart,
            "autobuffer": "autobuffer"
        })
        Author.mediaList.add(this.id, this);
        return;
    }
    if (Ext.isMac) {
        this.height = (this.height - (this.uiMode == "none" ? 0 : 65))
        this.mediaObject = bgObject.createChild({
            tag: "OBJECT",
            classid: "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B",
            codebase: "http://www.apple.com/qtactivex/qtplugin.cab",
            style: "position:absolute;left:" + this.left + "px;top:" + this.top + "px;width:" + this.width + "px;height:" + this.height + "px",
            children: [
                {
                    tag: "PARAM",
                    NAME: "src",
                    VALUE: this.url
                },
                {
                    tag: "PARAM",
                    NAME: "controller",
                    VALUE: "false"
                },
                {
                    tag: "PARAM",
                    NAME: "AUTOPLAY",
                    VALUE: this.autoStart
                },
                {
                    tag: "embed",
                    name: "quickTime" + this.id,
                    width: this.width + "px",
                    height: this.height + "px",
                    src: this.url,
                    enablejavascript: "true",
                    postdomevents: "True",
                    autoPlay: this.autoStart,
                    type: "video/quicktime",
                    controller: "false"
                }
            ]
        });
        this.qtObject = (Ext.isGecko ? this.mediaObject.dom.children[3] : this.mediaObject.dom);
        this.qtObject.uiMode = this.uiMode;
        Ext.EventManager.addListener(this.qtObject, "qt_pause", function (e) {
            var obj = e.getTarget();
            if (obj.uiMode != "none") {
                obj.controller.container.playing = false;
                obj.controller.container.stopped = true;
                obj.controller.container.playBtn.dom.src = "lib/images/" + (obj.controller.container.playing ? "pauseBtnNormal.jpg" : "playBtnNormal.jpg");
                obj.controller.container.stopBtn.dom.src = "lib/images/" + (obj.controller.container.stopped ? "stopBtnStopped.jpg" : "stopBtnNormal.jpg");
                obj.controller.container.statusSpan.dom.innerHTML = "Paused"
                obj.controller.container.timeSpan.dom.innerHTML = obj.controller.container.formatTime(obj.controller.container.qtObject.GetTime() * 1000 / obj.controller.container.qtObject.GetTimeScale());
            }
        })
        Ext.EventManager.addListener(this.qtObject, "qt_play", function () {
            var qtObject = Author.current.currentPlayingWMPObject;
            qtObject = (Ext.isGecko ? qtObject.dom.children[3] : qtObject.dom);
            var duration = qtObject.GetDuration();
            var timeEclipsed = qtObject.GetTime();
            var timeScaled = qtObject.GetTimeScale();
            var countDown = (duration - timeEclipsed) * 1000 / timeScaled;
            window.clearTimeout(Author.actionTimer);
            Author.pause = {
                cancelType: 1,
                startTime: new Date(),
                id: 0,
                key1: "none",
                key2: "none"
            }
            Author.pause.countDown = countDown;
            Author.actionTimer = setTimeout(showList, countDown);
        })
        this.mediaObject.checkStatus = function (object) {
            var quickTimeObject = (Ext.isGecko ? object.dom.children[3] : object.dom);
            try {
                var plugStatus = quickTimeObject.GetPluginStatus();
                if (plugStatus.indexOf("Error") > 0) {
                    alert(plugStatus);
                }
            }
            catch (err) {
                object.mediaTimer = setTimeout(object.checkStatus, 200, object);
            }
        }
        if (this.uiMode != "none") {
            this.controller = new MediaController(bgObject, this.left, this.width, this.height + this.top, this.qtObject, this.autoStart == "true");
            this.qtObject.controller = this.controller;
        }
        Author.mediaList.add(this.id, this);
        return;
    }
    else {
        if (Ext.isIE) {
            Author.mediaList.eachKey(function (key, object) {
                if (object.objectType == "MEDIAOBJECT") {
                    try {
                        object.mediaObject.dom.controls.stop();
                        object.mediaObject.dom.settings.mute = true;
                    }
                    catch (err) {
                    }
                }
                /*
                 if(object.objectType == "SOUNDOBJECT") {
                 if(!Author.useFlashInIE) {
                 try {
                 object.mediaObject.dom.controls.stop();
                 object.mediaObject.dom.settings.mute = true;
                 } catch (err) {
                 }
                 } else {
                 try {
                 object.stop();
                 } catch (err) {
                 //alert(err.description);
                 }
                 }
                 }*/
            });
            this.mediaObject = bgObject.createChild({
                tag: "OBJECT",
                CLASSID: "CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6",
                type: "application/x-oleobject",
                children: [
                    {
                        tag: "PARAM",
                        NAME: "URL",
                        VALUE: this.url
                    },
                    {
                        tag: "PARAM",
                        NAME: "stretchToFit",
                        VALUE: "true"
                    },
                    {
                        tag: "PARAM",
                        NAME: "windowlessVideo",
                        VALUE: "true"//this.windowlessVideo
                    },
                    {
                        tag: "PARAM",
                        NAME: "autoStart",
                        VALUE: "false"//this.autoStart
                    },
                    {
                        tag: "PARAM",
                        NAME: "uiMode",
                        VALUE: this.uiMode
                    },
                    {
                        tag: "PARAM",
                        NAME: "PlayCount",
                        VALUE: this.playCount
                    },
                    {
                        tag: "PARAM",
                        NAME: "SendPlayStateChangeEvents",
                        VALUE: "True"
                    }
                ],
                style: "position:absolute;left:" + this.left + "px;top:" + this.top + "px;width:" + this.width + "px;height:" + this.height + "px"

            });
            this.mediaObject.autoStart = this.autoStart;
            /*
             this.mediaObject.startPosition = this.startPos;
             this.mediaObject.endPosition = this.endPos;
             this.mediaObject.playSelection = this.playSelection;
             this.mediaObject.checkSelection = function(){
             // alert("checking");
             if (!Author.selectionMediaObject.playSelection) {
             return;
             }
             try {
             var wmpObject = Author.selectionMediaObject.dom.object;
             //window.status=wmpObject.controls.currentPosition +", "+wmpObject.controls.currentPositionString;
             if (wmpObject.controls.currentPosition < Author.selectionMediaObject.startPosition) {

             if ((wmpObject.controls.currentPositionString != "")) {
             wmpObject.controls.pause();
             }
             wmpObject.controls.currentPosition = Author.selectionMediaObject.startPosition;
             //wmpObject.controls.play();
             }

             if (wmpObject.controls.currentPosition > Author.selectionMediaObject.endPosition) {
             // wmpObject.controls.currentPosition = Author.selectionMediaObject.startPosition;
             wmpObject.controls.pause();
             }
             //  alert(Author.selectionMediaObject.firstPlay);

             if (Author.selectionMediaObject.firstPlay && (wmpObject.controls.currentPositionString != "") && (Math.abs(wmpObject.controls.currentPosition - parseFloat(Author.selectionMediaObject.startPosition)) < 0.4)) {
             // alert(wmpObject.controls.currentPosition+","+wmpObject.controls.currentPositionString+","+Math.abs(wmpObject.controls.currentPosition - parseFloat(Author.selectionMediaObject.startPosition)));
             if (Author.selectionMediaObject.autoStart == "true") {
             wmpObject.controls.play();
             }
             Author.selectionMediaObject.firstPlay = false;
             }
             //   else {
             Author.selectionMediaObject.selectionTimer = setTimeout(Author.selectionMediaObject.checkSelection, 100);
             //  }
             }
             catch (err) {
             //   alert(err.description);
             }
             }
             Author.selectionMediaObject = this.mediaObject;
             */
            Author.waitingMedia = true;
            Author.mediaList.add(this.id, this);
            return;
        }
        else {
            Author.mediaList.eachKey(function (key, object) {
                if (object.objectType == "MEDIAOBJECT") {
                    try {
                        object.mediaObject.dom.children[0].controls.stop();
                        object.mediaObject.dom.children[0].settings.mute = true;
                    }
                    catch (err) {
                    }
                }
                if (object.objectType == "SOUNDOBJECT") {
                    object.stop();
                }
            });
            this.mediaObject = bgObject.createChild({
                tag: "OBJECT",
                style: "position:absolute;left:" + this.left + "px;top:" + this.top + "px;width:" + this.width + "px;height:" + this.height + "px",
                children: [
                    {
                        tag: "embed",
                        height: this.height + "px",
                        width: this.width + "px",
                        name: "plugin",
                        src: this.url,
                        uiMode: this.uiMode,
                        autoStart: this.autoStart,
                        SendPlayStateChangeEvents: "true",
                        type: "application/x-ms-wmp"
                    }
                ]
            });
            this.mediaObject.checkStatus = function (object) {
                var wmpObject = object.dom.children[0];
                switch (wmpObject.playState) {
                    case 1:
                        Author.pause = null;
                        window.clearTimeout(Author.actionTimer);
                        showList();
                        break;
                    case 3:
                        var duration = wmpObject.currentMedia.duration;
                        var timeEclipsed = wmpObject.controls.currentPosition;
                        var countDown = (duration - timeEclipsed) * 1000;
                        window.clearTimeout(Author.actionTimer);
                        Author.pause = {
                            cancelType: 1,
                            startTime: new Date(),
                            id: 0,
                            key1: "none",
                            key2: "none"
                        }
                        Author.pause.countDown = countDown;
                        Author.actionTimer = setTimeout(showList, countDown);
                        object.mediaTimer = setTimeout(object.checkStatus, 200, object);
                        break;
                    case 8:
                        Author.pause = null;
                        window.clearTimeout(Author.actionTimer);
                        showList();
                        break;
                    default:
                        object.mediaTimer = setTimeout(object.checkStatus, 200, object);
                        break;
                }
            }
            this.mediaObject.autoStart = this.autoStart;
            /*
             this.mediaObject.startPosition = this.startPos;
             this.mediaObject.endPosition = this.endPos;
             this.mediaObject.playSelection = this.playSelection;
             this.mediaObject.checkSelection = function(theobject){
             //alert(theobject.playSelection);
             if (!theobject.playSelection) {
             //alert("why you are here "+Author.selectionMediaObject.playSelection);
             return;
             }
             try {
             var wmpObject = theobject.dom.children[0];

             // alert(wmpObject.controls.currentPosition +", " +theobject.startPosition+", "+theobject.endPosition+", "+wmpObject.controls.currentPositionString);
             if (wmpObject.controls.currentPosition < theobject.startPosition) {
             if ((wmpObject.controls.currentPositionString != "")) {
             wmpObject.controls.pause();
             }
             wmpObject.controls.currentPosition = theobject.startPosition;

             }

             if (wmpObject.controls.currentPosition > theobject.endPosition) {
             // wmpObject.controls.currentPosition = theobject.startPosition;
             wmpObject.controls.pause();
             }

             if (theobject.firstPlay && (wmpObject.controls.currentPositionString != "") && (Math.abs(wmpObject.controls.currentPosition - parseFloat(theobject.startPosition)) < 0.4)) {
             // alert(wmpObject.controls.currentPosition+","+wmpObject.controls.currentPositionString+","+Math.abs(wmpObject.controls.currentPosition - parseFloat(Author.selectionMediaObject.startPosition)));
             //alert(theobject.autoStart);
             if (theobject.autoStart == "true") {
             wmpObject.controls.play();
             }
             theobject.firstPlay = false;
             }
             //   else {
             theobject.selectionTimer = setTimeout(theobject.checkSelection, 100, theobject);
             //  }
             }
             catch (err) {
             alert(err.description);

             }
             }
             */
            Author.mediaList.add(this.id, this);
            return;
        }
    }
}
MediaClass.prototype.readConfig = function (cfgXML) {
    this.waitUntilComplete = trim(cfgXML.getElementsByTagName("waitUntilComplete")[0].childNodes[0].nodeValue).toLowerCase();
    this.cancelType = parseInt(trim(cfgXML.getElementsByTagName("cancelType")[0].childNodes[0].nodeValue));
    this.duration = parseFloat(trim(cfgXML.getElementsByTagName("duration")[0].childNodes[0].nodeValue));
    if (Author.isHTML5) {
        Author.listStarted = false;
        Author.current.currentPlayingWMPObject = this.videoObject;
        Author.waitAudioFinish = (this.waitUntilComplete == "true");
        this.videoObject.addListener('canplaythrough', function (e) {
            var video = e.target;
            var countDown = (video.duration - video.currentTime) * 1000;
            var autoPlay = (video.getAttribute('ap').toLowerCase() == 'true');
            if (autoPlay) {
                video.play();
            }
            if (Author.waitAudioFinish) {
                window.clearTimeout(Author.actionTimer);
                Author.pause = {
                    cancelType: 0,
                    startTime: new Date(),
                    id: 0,
                    key1: "none",
                    key2: "none"
                }
                Author.pause.countDown = countDown;
                //  alert("set sound countDown: " + countDown / 1000 + " secs.\nWait until finish: " + Author.waitAudioFinish);
                Author.actionTimer = setTimeout(showList, countDown);
            }
            else {
                if (!Author.listStarted) {
                    Author.listStarted = true;
                    Author.pause = null;
                    window.clearTimeout(Author.actionTimer);
                    Author.actionTimer = setTimeout(showList, 10);
                }
            }
        });
        this.videoObject.addListener('play', function (e) {
            var video = e.target;
            var countDown = (video.duration - video.currentTime) * 1000;
            if (Author.waitAudioFinish) {
                window.clearTimeout(Author.actionTimer);
                Author.pause = {
                    cancelType: 0,
                    startTime: new Date(),
                    id: 0,
                    key1: "none",
                    key2: "none"
                }
                Author.pause.countDown = countDown;
                // alert("set sound countDown: " + countDown / 1000 + " secs.\nWait until finish: " + Author.waitAudioFinish);
                Author.actionTimer = setTimeout(showList, countDown);
            }
        });
        this.videoObject.addListener('error', function (e) {
            alert("Can't play video[html5]: " + e.target.src);
            Author.listStarted = true;
            window.clearTimeout(Author.actionTimer);
            Author.actionTimer = setTimeout(showList, 10);
        })
        this.videoObject.set({
            src: this.url
        });
        var theAudioObject = document.getElementById(this.mediaID);
        setTimeout(function () {
            theAudioObject.load();
        }, 500);
        if (this.autoStart == 'true') {
            setTimeout(function () {
                theAudioObject.play();
            }, 500);
        }
        return 3600 * 24 * 1000;
    }
    if (this.waitUntilComplete == "true") {
        if (Ext.isMac) {
            Author.current.currentPlayingWMPObject = this.mediaObject;
            if (this.uiMode == "none")
                this.mediaObject.mediaTimer = setTimeout(this.mediaObject.checkStatus, 1000, this.mediaObject);
            return 3600 * 24 * 1000;
        }
        else {
            if (Ext.isIE) {
                if (this.uiMode.toLowerCase() == "none") {
                    Ext.getBody().setStyle("cursor", "wait");
                    var pageXY = Author.backgroundObject.getContent().getXY();
                    var xy = this.mediaObject.getOffsetsTo(Author.backgroundObject.getContent());
                    var t = parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue)) + xy[1] + pageXY[1] + 20;
                    var l = parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue)) / 2 + +xy[0] + pageXY[0];
                    var VE = Ext.get("videoLoading");
                    VE.setVisible(true);
                    VE.setLocation(t, l);
                }
                Author.current.currentPlayingWMPObject = this.mediaObject.dom.object;
                this.mediaObject.dom.attachEvent("playStateChange", function (status) {
                    var mediaObj = Author.current.currentPlayingWMPObject;
                    try {
                        var duration = mediaObj.controls.currentItem.duration;
                        var timeEclipsed = mediaObj.controls.currentPosition;
                        var countDown = (duration - timeEclipsed) * 1000;
                        if (status == 3) {



                            // mediaObj.controls.currentPosition = 2.5;
                            Ext.getBody().setStyle("cursor", "default");
                            Ext.get("videoLoading").setVisible(false);
                            window.clearTimeout(Author.actionTimer);
                            Author.pause = {
                                cancelType: 1,
                                startTime: new Date(),
                                id: 0,
                                key1: "none",
                                key2: "none"
                            }
                            Author.pause.countDown = countDown;
                            Author.actionTimer = setTimeout(showList, countDown);
                        }
                    }
                    catch (err) {
                    }
                });
                if (this.autoStart == "true") {
                    this.mediaObject.dom.object.controls.play();
                }
                /*
                 if (this.playSelection) {
                 this.mediaObject.selectionTimer = setTimeout(this.mediaObject.checkSelection, 100);
                 this.mediaObject.dom.object.controls.play();
                 Author.selectionMediaObject.firstPlay = true;
                 }
                 */
                return 3600 * 24 * 1000;
            }
            else {
                Author.current.currentPlayingWMPObject = this.mediaObject.dom.children[0];
                if (this.autoStart == "true") {
                    Author.current.currentPlayingWMPObject.controls.play();
                }
                this.mediaObject.mediaTimer = setTimeout(this.mediaObject.checkStatus, 200, this.mediaObject);
                /*
                 if (this.playSelection) {
                 this.mediaObject.selectionTimer = setTimeout(this.mediaObject.checkSelection, 100, this.mediaObject);
                 Author.current.currentPlayingWMPObject.controls.play();
                 this.mediaObject.firstPlay = true;
                 }
                 */
                return 3600 * 24 * 1000;
            }
        }
    }
    else {
        //  alert(this.playSelection);
        if (Ext.isMac) {
        }
        else
        if (Ext.isIE) {
            Author.current.currentPlayingWMPObject = this.mediaObject.dom.object;
            if (this.autoStart == "true") {
                this.mediaObject.dom.object.controls.play();
            }
            // if (this.playSelection) {
            //   this.mediaObject.selectionTimer = setTimeout(this.mediaObject.checkSelection, 100);
            //  this.mediaObject.dom.object.controls.currentPosition =this.mediaObject.startPosition;
            //  this.mediaObject.dom.object.controls.play();
            //  this.mediaObject.dom.object.controls.currentPosition =this.mediaObject.startPosition;
            //  Author.selectionMediaObject.firstPlay = true;
            // }
            this.mediaObject.dom.attachEvent("playStateChange", function (status) {
                if (status == 3) {
                    Author.mediaList.eachKey(function (key, object) {
                        if (object.objectType == "SOUNDOBJECT") {
                            //object.mediaObject.dom.controls.stop();
                            if (!Author.useFlashInIE) {
                                try {
                                    object.mediaObject.dom.controls.stop();
                                    object.mediaObject.dom.settings.mute = true;
                                }
                                catch (err) {
                                }
                            }
                            else {
                                try {
                                    object.stop();
                                }
                                catch (err) {
                                    //alert(err.description);
                                }
                            }
                        }
                    });
                }
            });
        }
        else {
            Author.current.currentPlayingWMPObject = this.mediaObject.dom.children[0];
            if (this.autoStart == "true") {
                Author.current.currentPlayingWMPObject.controls.play();
            }
            // if (this.playSelection) {
            //   this.mediaObject.selectionTimer = setTimeout(this.mediaObject.checkSelection, 100, this.mediaObject);
            //   Author.current.currentPlayingWMPObject.controls.play();
            //   this.mediaObject.firstPlay = true;
            // }
        }
        return 300;
    }
}
MediaClass.prototype.setVisible = function (visible) {
    this.visible = visible
    this.mediaObject.setVisible(visible);
}
MediaClass.prototype.setStyle = function (CSSStyle) {
    this.mediaObject.applyStyles(CSSStyle);
}
MediaClass.prototype.stop = function () {
    if (Ext.isIE) {
        if (!Author.isHTML5) {
            this.mediaObject.dom.controls.stop();
            this.mediaObject.dom.settings.mute = true;
        }
    }
    else
    if (Author.isHTML5) {
        try {
            var theAudioObject = document.getElementById(this.mediaID);
            theAudioObject.stop();
        }
        catch (err) {
        }
    }
}
MediaClass.prototype.remove = function () {
    if (Author.isHTML5) {
        Author.mediaList.removeKey(this.id);
        this.content.remove();
        return;
    }
    if (Ext.isMac) {
        if (this.uiMode != "none") {
            this.controller.remove();
        }
    }
    else {
        if (Ext.isIE) {
            try {
                this.mediaObject.applyStyles("top:-2000px");
                this.mediaObject.dom.object.controls.stop();
            }
            catch (err) {
            }
        }
        else {
            try {
                this.mediaObject.dom.children[0].controls.stop();
            }
            catch (err) {
            }
        }
    }
    Author.mediaList.removeKey(this.id);
    this.mediaObject.remove();
}
MediaController = function (body, left, width, height, qtObject, autoPlay) {
    this.width = Math.max(150, width);
    this.left = left;
    this.volumeBarWidth = Math.min(80, this.width / 3);
    this.container = body.createChild({
        tag: "div",
        style: "position:absolute;left:" + this.left + "px;top:" + height + "px;width:" + this.width + "px;height:65px;z-index:30;background-color:#000",
        children: [
            {
                tag: "img",
                style: "position:absolute;left:0px;top:0px;width:1px;height:65px",
                src: "lib/images/controllerBorder.jpg"
            },
            {
                tag: "img",
                style: "position:absolute;left:1px;top:0px;width:" + (this.width - 2) + "px;height:65px",
                src: "lib/images/controllerbg.jpg"
            },
            {
                tag: "img",
                style: "position:absolute;left:" + (this.width - 1) + "px;top:0px;width:1px;height:65px",
                src: "lib/images/controllerBorder.jpg"
            }
        ]
    });
    this.container.qtObject = qtObject;
    if (!autoPlay) {
        this.container.playing = false;
        this.container.stopped = true;
    }
    else {
        this.container.playing = true;
        this.container.stopped = false;
    }
    this.container.value = 0;
    this.container.mute = qtObject.GetMute() == "true";
    this.container.volume = parseInt(qtObject.GetVolume() * 100 / 256);
    this.container.on("mousedown", function (e) {
        e.stopEvent();
    })
    this.container.statusSpan = this.container.createChild({
        tag: "span",
        style: "position:absolute;left:14px;top:2px;width:" + (this.width * 2 / 3) + "px;height:18px;font-family:Courier New;color:#84C5FF;font-size:12px;z-index:30;background-color:#000",
        html: (autoPlay ? "Playing" : "Ready")
    })
    this.container.timeSpan = this.container.createChild({
        tag: "span",
        style: "position:absolute;width:35px;top:2px;left:" + (this.width - 40) + "px;height:18px;text-align:center;font-family:Courier New;color:#84C5FF;font-size:12px;z-index:30;background-color:#000",
        html: "00:00"
    })
    this.container.playBtn = this.container.createChild({
        tag: "img",
        style: "position:absolute;left:4px;top:33px;width:29px;height:29px",
        src: "lib/images/" + (this.container.playing ? "pauseBtnNormal.jpg" : "playBtnNormal.jpg")
    })
    this.container.playBtn.on("mouseover", function () {
        this.dom.src = "lib/images/" + (this.parent().playing ? "pauseBtnMouseOver.jpg" : "playBtnMouseOver.jpg");
    })
    this.container.playBtn.on("mouseout", function () {
        this.dom.src = "lib/images/" + (this.parent().playing ? "pauseBtnNormal.jpg" : "playBtnNormal.jpg");
    })
    this.container.playBtn.on("click", function (e) {
        e.stopEvent();
        this.parent().stopped = false;
        this.parent().playing = !this.parent().playing;
        this.parent().stopBtn.dom.src = "lib/images/" + (this.parent().stopped ? "stopBtnStopped.jpg" : "stopBtnNormal.jpg");
        this.dom.src = "lib/images/" + (this.parent().playing ? "pauseBtnNormal.jpg" : "playBtnNormal.jpg");
        if (this.parent().playing) {
            this.parent().qtObject.Play();
            this.parent().statusSpan.dom.innerHTML = "Playing";
            this.parent().timer = setTimeout(this.parent().updateBtnState, 200, this.parent());
        }
        else {
            this.parent().qtObject.Stop();
            this.parent().statusSpan.dom.innerHTML = "Paused";
        }
    })
    this.container.playBtn.on("mousedown", function (e) {
        e.stopEvent();
        this.dom.src = "lib/images/" + (this.parent().playing ? "pauseBtnMouseDown.jpg" : "playBtnMouseDown.jpg");
    })
    this.container.playBtn.on("mouseup", function (e) {
        e.stopEvent();
    })
    this.container.stopBtn = this.container.createChild({
        tag: "img",
        style: "position:absolute;left:35px;top:38px;width:19px;height:20px",
        src: "lib/images/" + (this.container.stopped ? "stopBtnStopped.jpg" : "stopBtnNormal.jpg")
    })
    this.container.stopBtn.on("click", function (e) {
        e.stopEvent();
    })
    this.container.stopBtn.on("mouseover", function () {
        this.dom.src = "lib/images/" + (this.parent().stopped ? "stopBtnStopped.jpg" : "stopBtnMouseOver.jpg");
    })
    this.container.stopBtn.on("mouseout", function () {
        this.dom.src = "lib/images/" + (this.parent().stopped ? "stopBtnStopped.jpg" : "stopBtnNormal.jpg");
    })
    this.container.stopBtn.on("mousedown", function (e) {
        e.stopEvent();
        this.parent().qtObject.Stop();
        this.parent().stopped = true;
        this.parent().playing = false;
        this.dom.src = "lib/images/" + (this.parent().stopped ? "stopBtnStopped.jpg" : "stopBtnMouseDown.jpg");
        this.parent().playBtn.dom.src = "lib/images/" + (this.parent().playing ? "pauseBtnNormal.jpg" : "playBtnNormal.jpg");
        this.parent().statusSpan.dom.innerHTML = "Stopped";
    })
    this.container.stopBtn.on("mouseup", function (e) {
        e.stopEvent();
        this.dom.src = "lib/images/" + (this.parent().stopped ? "stopBtnStopped.jpg" : "stopBtnNormal.jpg");
    })
    this.container.muteBtn = this.container.createChild({
        tag: "img",
        style: "position:absolute;left:64px;top:38px;width:20px;height:20px",
        src: "lib/images/" + (this.container.mute ? "muteBtnMuted.jpg" : "muteBtnNormal.jpg")
    })
    this.container.muteBtn.on("mouseover", function () {
        this.dom.src = "lib/images/" + (this.parent().mute ? "muteBtnMuted.jpg" : "muteBtnMouseOver.jpg");
    })
    this.container.muteBtn.on("mouseout", function () {
        this.dom.src = "lib/images/" + (this.parent().mute ? "muteBtnMuted.jpg" : "muteBtnNormal.jpg");
    })
    this.container.muteBtn.on("mousedown", function (e) {
        e.stopEvent();
    })
    this.container.muteBtn.on("mouseup", function () {
        this.dom.src = "lib/images/" + (this.parent().mute ? "muteBtnMuted.jpg" : "muteBtnMouseOver.jpg");
    })
    this.container.muteBtn.on("click", function (e) {
        e.stopEvent();
        this.parent().qtObject.SetMute(!eval(this.parent().qtObject.GetMute()));
        this.parent().mute = eval(this.parent().qtObject.GetMute());
        this.dom.src = "lib/images/" + (this.parent().mute ? "muteBtnMuted.jpg" : "muteBtnMouseOver.jpg");
    })
    this.container.tracker = this.container.createChild({
        tag: "div",
        style: "position:absolute;left:14px;top:21px;width:" + (this.width - 28) + "px;height:10px;cursor:pointer;cursor:hand",
        children: [
            {
                tag: "img",
                style: "position:absolute;left:0px;top:0px;width:1px;height:10px",
                src: "lib/images/pBorder.jpg"
            },
            {
                tag: "img",
                style: "position:absolute;left:1px;top:0px;width:" + (this.width - 28 - 2) + "px;height:10px",
                src: "lib/images/pBg.jpg"
            },
            {
                tag: "img",
                style: "position:absolute;left:" + (this.width - 28 - 1) + "px;top:0px;width:1px;height:10px",
                src: "lib/images/pBorder.jpg"
            }
        ]
    })
    this.container.tracker.fill = this.container.tracker.createChild({
        tag: "img",
        style: "position:absolute;left:1px;top:0px;width:" + ((this.width - 28 - 2) * this.container.value / 100) + "px;height:10px",
        src: "lib/images/pFill.jpg"
    })
    this.container.tracker.fill.setValue = function (value) {
        this.setStyle("width", parseInt((this.parent().getWidth() - 2) * value / 100) + "px");
    }
    this.container.tracker.on("click", function (e) {
        e.stopEvent();
        tracker = Ext.get(e.getTarget()).parent();
        var value = parseInt((e.getPageX() - tracker.getLeft()) * 100 / (tracker.getWidth() - 2));
        this.fill.setValue(value);
        var duration = this.parent().qtObject.GetDuration();
        this.parent().qtObject.SetTime(value / 100 * duration);
        this.parent().value = value;
    })
    this.container.tracker.on("mousedown", function (e) {
        e.stopEvent();
    })
    this.container.volumeBar = this.container.createChild({
        tag: "div",
        style: "position:absolute;left:88px;top:43px;width:" + (this.volumeBarWidth) + "px;height:10px;cursor:pointer;cursor:hand",
        children: [
            {
                tag: "img",
                style: "position:absolute;left:0px;top:0px;width:1px;height:10px",
                src: "lib/images/vBorder.jpg"
            },
            {
                tag: "img",
                style: "position:absolute;left:1px;top:0px;width:" + (this.volumeBarWidth - 2) + "px;height:10px",
                src: "lib/images/vBg.jpg"
            },
            {
                tag: "img",
                style: "position:absolute;left:" + (this.volumeBarWidth - 1) + "px;top:0px;width:1px;height:10px",
                src: "lib/images/vBorder.jpg"
            }
        ]
    })
    this.container.volumeBar.fill = this.container.volumeBar.createChild({
        tag: "img",
        alt: '',
        style: "position:absolute;left:1px;top:0px;width:" + ((this.volumeBarWidth - 2) * this.container.volume / 100) + "px;height:10px",
        src: "lib/images/vFill.jpg"
    })
    this.container.volumeBar.fill.setValue = function (value) {
        this.setStyle("width", ((this.parent().getWidth() - 2) * value / 100) + "px");
    }
    this.container.volumeBar.on("click", function (e) {
        e.stopEvent();
        volume = Ext.get(e.getTarget()).parent();
        var value = parseInt((e.getPageX() - volume.getLeft()) * 100 / (volume.getWidth() - 2));
        this.fill.setValue(value);
        this.parent().qtObject.SetVolume(value * 256 / 100);
    })
    this.container.volumeBar.on("mousedown", function (e) {
        e.stopEvent();
    })
    this.container.formatTime = function (milisecond) {
        if (typeof(milisecond) == 'undefined')
            milisecond = 0;
        var second = parseInt(milisecond / 1000);
        var minutes = Math.floor(second / 60);
        second = second - minutes * 60;
        return (minutes < 10 ? "0" : "") + minutes + ":" + (second < 10 ? "0" : "") + second;
    }
    this.container.updateBtnState = function (container) {
        try {
            container.value = parseInt(container.qtObject.GetTime() * 100 / container.qtObject.GetDuration());
            container.volume = parseInt(container.qtObject.GetVolume() * 100 / 256);
            container.tracker.fill.setValue(container.value);
            container.volumeBar.fill.setValue(container.volume);
            container.timeSpan.dom.innerHTML = container.formatTime(container.qtObject.GetTime() * 1000 / container.qtObject.GetTimeScale());
        }
        catch (err) {
        }
        container.timer = setTimeout(container.updateBtnState, 200, container);
    }
    if (autoPlay)
        this.container.timer = setTimeout(this.container.updateBtnState, 200, this.container);
}
MediaController.prototype.remove = function () {
    this.container.remove();
}
/**
 * SoundClass
 * For IE, SoundClass uses windows media player to play mp3 files,
 * for other browsers, SoundClass uses a flash mp3 player.
 *
 * When Author start to play a audio, it cancels all the previous audioes.
 * @param {Object} documentBody
 */
function SoundClass(bgObject, cfgXML, o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    Author.waitAudioFinish = false;
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.objectType = "SOUNDOBJECT";
    this.url = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("url")[0].childNodes[0].nodeValue))).toLowerCase();
    this.waitUntilComplete = trim(cfgXML.getElementsByTagName("waitUntilComplete")[0].childNodes[0].nodeValue).toLowerCase();
    try {
        this.isCancelable = (trim(cfgXML.getElementsByTagName("isCancelable")[0].childNodes[0].nodeValue).toLowerCase() == 'true');
    }
    catch (err) {
        this.isCancelable = false;
    }
    this.duration = parseFloat(trim(cfgXML.getElementsByTagName("duration")[0].childNodes[0].nodeValue));
    this.playCount = trim(cfgXML.getElementsByTagName("playCount")[0].childNodes[0].nodeValue);
    this.badAudio = false;
    this.content = bgObject.createChild({
        tag: "div",
        style: "position:absolute;top:-2000px;" //+ ((Ext.isIE) ? "display:none" : "")
        // style: "position:absolute;top:20px;width:600px;height:60px"
    });
    this.mediaID = this.content.dom.id + "-Media";
    if (Author.isHTML5 && !Author.isFlash9) {
        Author.mediaList.eachKey(function (key, object) {
            if (object.objectType == "SOUNDOBJECT") {
                try {
                    var theAudioObject = document.getElementById(object.mediaID);
                    theAudioObject.pause();
                }
                catch (err) {
                    //alert(err);
                }
            }
        });
        if (Author.isIOS()) {
            this.content.applyStyles("position:absolute;background-color:#000;left:0px;top:" + (Author.lessonHeight) + "px;width:" + Author.lessonWidth + "px;height:60px;z-index:999");
            this.audioObject = this.content.createChild({
                tag: "audio",
                id: this.mediaID,
                "type": "audio/mpeg",
                "autobuffer": "autobuffer",
                "controls": "controls",
                style: "position:absolute;width:100%;height:100%;left:0px;top:0px"

            })
        }
        else {
            this.audioObject = this.content.createChild({
                tag: "audio",
                id: this.mediaID,
                "hidden": "true",
                "type": "audio/mpeg",
                "autobuffer": "autobuffer"
            })
        }
        Author.currentSoundID = this.mediaID;
        Author.mediaList.add(this.id, this);
        return;
    }
    if (Ext.isIE && !Author.useFlashInIE) {
        Author.mediaList.eachKey(function (key, object) {
            if (object.objectType == "SOUNDOBJECT") {
                object.mediaObject.dom.controls.stop();
                object.mediaObject.dom.settings.mute = true;
            }
        });
        this.mediaObject = this.content.createChild({
            tag: "OBJECT",
            id: this.mediaID,
            CLASSID: "CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6",
            type: "application/x-oleobject",
            children: [
                {
                    tag: "PARAM",
                    NAME: "URL",
                    VALUE: this.url
                },
                {
                    tag: "PARAM",
                    NAME: "autoStart",
                    VALUE: "False"
                },
                {
                    tag: "PARAM",
                    NAME: "uiMode",
                    VALUE: "none"
                },
                {
                    tag: "PARAM",
                    NAME: "PlayCount",
                    VALUE: this.playCount
                },
                {
                    tag: "PARAM",
                    NAME: "SendPlayStateChangeEvents",
                    VALUE: "True"
                },
                {
                    tag: "PARAM",
                    NAME: "SendOpenStateChangeEvents",
                    VALUE: "True"
                }
            ]
        });
        this.mediaObject.dom.settings.mute = false;
        Author.mediaList.add(this.id, this);
    }
    else {
        Author.mediaList.eachKey(function (key, object) {
            if (object.objectType == "SOUNDOBJECT") {
                try {
                    object.stop();
                }
                catch (err) {
                    //alert(err.description);
                }
            }
        });
        Author.currentSoundID = this.mediaID;
        Author.mediaList.add(this.id, this);
        try {
            Author.AudioManager.play(this);
        }
        catch (err) {
            this.badAudio = true;
            Author.pause = {
                cancelType: 1,
                startTime: new Date(),
                id: 0,
                key1: "none",
                key2: "none"
            }
            Author.pause.countDown = this.duration * 1000;
            //alert(Author.AudioManager.play);
            //alert("SoundClass: Flash player does not have the permission to load file on the local file system.");
        }
    }
}
function movebars() {
    //  alert("sound playing");
}
SoundClass.prototype.readConfig = function (cfgXML) {
    if (Author.isHTML5 && !Author.isFlash9) {
        Author.listStarted = false;
        Author.current.currentPlayingWMPObject = this.audioObject;
        Author.waitAudioFinish = (this.waitUntilComplete == "true");
        var cancelable = this.isCancelable;
        // alert("cancelable:"+cancelable);
        this.audioObject.addListener('canplaythrough', function (e) {
            var audio = e.target;
            //audio.loop=false;
            var countDown = (audio.duration - audio.currentTime) * 1000;
            if (Author.waitAudioFinish) {
                window.clearTimeout(Author.actionTimer);
                Author.pause = {
                    cancelType: (cancelable ? 1 : 0),
                    startTime: new Date(),
                    id: 0,
                    key1: "none",
                    key2: "none"
                }
                Author.pause.countDown = countDown;
                // alert("set sound countDown: " + countDown / 1000 + " secs.\nWait until finish: " + Author.waitAudioFinish);
                Author.actionTimer = setTimeout(showList, countDown);
            }
            else {
                if (!Author.listStarted) {
                    Author.listStarted = true;
                    Author.pause = null;
                    window.clearTimeout(Author.actionTimer);
                    Author.actionTimer = setTimeout(showList, 10);
                }
            }
        });
        this.audioObject.addListener('play', function (e) {
            var audio = e.target;
            //alert(audio.id + ","+Author.currentSoundID);
            if (Author.currentSoundID != audio.id) {
                audio.pause();
            }
            var countDown = (audio.duration - audio.currentTime) * 1000;
            if (Author.waitAudioFinish) {
                window.clearTimeout(Author.actionTimer);
                //alert("cancelable:"+cancelable);
                Author.pause = {
                    cancelType: (cancelable ? 1 : 0),
                    startTime: new Date(),
                    id: 0,
                    key1: "none",
                    key2: "none"
                }
                Author.pause.countDown = countDown;
                // alert("set sound countDown: " + countDown / 1000 + " secs.\nWait until finish: " + Author.waitAudioFinish);
                Author.actionTimer = setTimeout(showList, countDown);
            }
            else {
                if (!Author.listStarted) {
                    Author.listStarted = true;
                    window.clearTimeout(Author.actionTimer);
                    Author.actionTimer = setTimeout(showList, 10);
                }
            }
        });
        this.audioObject.addListener('error', function (e) {
            var msg = "Can't play audio[html5]: " + e.target.src;
            var infoDiv = Author.backgroundObject.getContent().createChild({
                tag: 'div',
                html: '<p style="font-size:10pt;">HTML5 auido can\'t play this sound:</p><p style="font-weight:bold;font-family:trebuchet ms">Url: ' + e.target.src + '</p><p style="margin-top:5px;font-size:10pt;font-style:italic">The format of the auido file is not acceptable, or the audio file does\'t exist.</p>',
                style: 'background-color:#FFD213;width:80%;text-alignment:center;padding:4px;opacity:0;filter: alpha(opacity=0);z-index:9999;'
            });
            infoDiv.center();
            infoDiv.fadeIn({
                duration: 0.5,
                endOpacity: 0.80,
                easing: 'easeOut',
                callback: function () {
                    setTimeout(function () {
                        infoDiv.remove();
                    }, 1500);
                }
            });
            Author.listStarted = true;
            window.clearTimeout(Author.actionTimer);
            Author.actionTimer = setTimeout(showList, 10);
        });
        this.audioObject.set({
            src: this.url

        });
        if (Author.isIOS()) {
            return 0;
        }
        var theAudioObject = document.getElementById(this.mediaID);
        //alert(theAudioObject.loop);
        setTimeout(function () {
            //theAudioObject.loop=false;
            theAudioObject.load();
            setTimeout(function () {
                theAudioObject.play();
                //theAudioObject.loop = false;
                //alert(theAudioObject.loop);
            }, 500)
        }, 500);
        return 3600 * 24 * 1000;
    }
    if (Ext.isIE && !Author.useFlashInIE) {
        Author.listStarted = false;
        Author.current.currentPlayingWMPObject = this.mediaObject;
        Author.waitAudioFinish = (this.waitUntilComplete == "true");
        this.mediaObject.dom.attachEvent("playStateChange", function (status) {
            // alert(status);
            try {
                var mediaObj = Author.current.currentPlayingWMPObject.dom.object;
            }
            catch (err) {
                //alert(Author.current.currentPlayingWMPObject);
                //  alert(err.description);
                return;
            }
            //  alert(mediaObj);
            // alert(mediaObj.controls.currentItem.duration);
            var duration = mediaObj.controls.currentItem.duration;
            if (duration == 0)
                return;
            var timeEclipsed = mediaObj.controls.currentPosition;
            var countDown = (duration - timeEclipsed) * 1000;
            if (status == 3) {
                if (Author.waitAudioFinish) {
                    window.clearTimeout(Author.actionTimer);
                    Author.pause = {
                        cancelType: 0,
                        startTime: new Date(),
                        id: 0,
                        key1: "none",
                        key2: "none"
                    }
                    Author.pause.countDown = countDown;
                    //alert("set sound countDown: " + countDown / 1000 + " secs.\nWait until finish: " + Author.waitAudioFinish);
                    Author.actionTimer = setTimeout(showList, countDown);
                }
                else {
                    if (!Author.listStarted) {
                        Author.listStarted = true;
                        window.clearTimeout(Author.actionTimer);
                        Author.actionTimer = setTimeout(showList, 10);
                    }
                }
            }
        });
        this.mediaObject.dom.attachEvent("openStateChange", function (status) {
            if (status == 6) {
                // Ext.MessageBox.alert('Codec missing', "Windows media player can\'t play the audio.<br/>URL: " + Author.current.currentPlayingWMPObject.dom.object.url, function(){
                if (!Author.listStarted) {
                    Author.listStarted = true;
                    window.clearTimeout(Author.actionTimer);
                    Author.actionTimer = setTimeout(showList, 10);
                }
                // });
            }
        });
        this.mediaObject.dom.controls.play();
        //	alert("play");
        return 3600 * 24 * 1000;
    }
    //  alert("wait");
    return 3600 * 24 * 1000;
}
SoundClass.prototype.stop = function () {
    if (Ext.isIE && !Author.useFlashInIE) {
        if (!Author.isHTML5) {
            this.mediaObject.dom.controls.stop();
            this.mediaObject.dom.settings.mute = true;
        }
    }
    else
    if (Author.isHTML5 && !Author.isFlash9) {
        try {
            var theAudioObject = document.getElementById(this.mediaID);
            theAudioObject.stop();
        }
        catch (err) {
        }
    }
    else {
        Author.AudioManager.stop();
    }
};
SoundClass.prototype.remove = function () {
    //alert("remove:" +Author.isHTML5);
    if (Author.isHTML5 && !Author.isFlash9) {
        Author.mediaList.removeKey(this.id);
        if (Author.currentSoundID == this.mediaID) {
            Author.currentSoundID = "";
        }
        this.audioObject.dom.pause();
        this.content.remove();
        return;
    }
    try {
        //alert("remove");
        if (Ext.isIE && !Author.useFlashInIE) {
            this.mediaObject.dom.controls.stop()
        }
        else {
            this.stop();
        }
        //this.stop();
        // alert("Before remove: "+Author.mediaList.getCount())
        Author.mediaList.removeKey(this.id);
        //s  alert("after remove: "+Author.mediaList.getCount())
        this.content.remove();
    }
    catch (err) {
        //	alert(err.description);
    }
    if (Author.currentSoundID == this.mediaID) {
        Author.currentSoundID = "";
    }
}
function TXTextClass(bgObject, cfgXML, o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.objectType = "TXTEXTOBJECT";
    this.addToBackground = (trim(cfgXML.getElementsByTagName("addToBackground")[0].childNodes[0].nodeValue) == "True");
    this.hide = trim(cfgXML.getElementsByTagName("hide")[0].childNodes[0].nodeValue).toLowerCase();
    this.borderWidth = parseInt(trim(cfgXML.getElementsByTagName("borderWidth")[0].childNodes[0].nodeValue));
    this.autoScroll = false;
    try {
        this.autoScroll = (trim(cfgXML.getElementsByTagName("autoScroll")[0].childNodes[0].nodeValue).toLowerCase() == "true");
    }
    catch (err) {
    }
    this.scrollSpeed = 10.0; //pixel per second
    try {
        this.scrollSpeed = parseFloat(trim(cfgXML.getElementsByTagName("scrollSpeed")[0].childNodes[0].nodeValue));
    }
    catch (err) {
    }
    this.scrollTimerInterval = 100;
    try {
        this.imageSrc = trim(cfgXML.getElementsByTagName("picture")[0].childNodes[0].nodeValue).toLowerCase();
        var img = new Image();
        img.src = Author.resourcePath + this.imageSrc;
        this.imageX = parseInt(trim(cfgXML.getElementsByTagName("pictureX")[0].childNodes[0].nodeValue));
        this.imageY = parseInt(trim(cfgXML.getElementsByTagName("pictureY")[0].childNodes[0].nodeValue));
        var pictureNode = cfgXML.getElementsByTagName("picture")[0];
        var tmpWidth = pictureNode.getAttribute("iWidth");
        if (tmpWidth) {
            this.imageWidth = parseInt(pictureNode.getAttribute("iWidth"));
            this.imageHeight = parseInt(pictureNode.getAttribute("iHeight"));
        }
        else {
            this.imageWidth = -1;
            this.imageHeight = -1;
        }
        //alert(this.imageWidth +","+this.imageHeight);
        this.imageVisible = trim(cfgXML.getElementsByTagName("pictureVisible")[0].childNodes[0].nodeValue).toLowerCase();
    }
    catch (err) {
        //alert(err.description);
        this.imageSrc = "";
    }
    this.width = parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue));
    this.height = parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue));
    this.changeAction = trim(cfgXML.getElementsByTagName("changeAction")[0].childNodes[0].nodeValue).toLowerCase();
    if (this.changeAction == "true") {
        this.originalID = trim(cfgXML.getElementsByTagName("originalID")[0].childNodes[0].nodeValue);
        this.changeID = trim(cfgXML.getElementsByTagName("changeID")[0].childNodes[0].nodeValue);
        try {
            this.addToBackground = Author.current.currentList.item(this.changeID).addToBackground;
        }
        catch (err) {
            this.addToBackground = false;
        }
    }
    try {
        this.textStr = (cfgXML.getElementsByTagName("html")[0].childNodes[0].nodeValue);
    }
    catch (err) {
        this.textStr = "";
    }
    this.textStr = this.textStr.replace(/ {2}/g, " &nbsp;");
    this.content = bgObject.createChild({
        tag: "div",
        style: "position:absolute;overflow:hidden;cursor:default;"

    });
    if (this.imageSrc != "" && this.imageVisible == "true") {
        var imagePreLoad = new Image();
        imagePreLoad.src = Author.resourcePath + this.imageSrc;
        this.image = this.content.createChild({
            tag: "img",
            style: "position:absolute;alt:''"
        });
        this.image.dom.src = Author.resourcePath + this.imageSrc;
        this.fixPng();
    }
    var scroll = "visible";
    if (cfgXML.getElementsByTagName("scrollBar")[0].childNodes[0].nodeValue.toLowerCase() == "true")
        scroll = "scroll";
    scroll = "overflow:visible;overflow-x:visible;overflow-y:" + scroll;
    this.text = this.content.createChild({
        tag: "div",
        style: "position:absolute;left:0px;top:0px;width:" + this.width + "px;height:" + this.height + "px;"
    });
    var replaceStyle = "class='normalul'";
    if (Ext.isChrome) {
        //  replaceStyle = "style='margin:0px 0px 0px 19px;padding:0px 0px 0px 0px;';list-style:disk;";
    }
    this.p = this.text.createChild({
        tag: "div",
        //id:'txtframe'+this.id,
        //frameborder: Ext.isIE ? "0" : "1",
        style: "position:absolute;left:" + (this.borderWidth) + "px;top:" + (this.borderWidth) + "px;width: " + (this.width - this.borderWidth * 2) + "px; height: " + (this.height - this.borderWidth * 2) + "px;" + scroll,
        // style: "position:absolute;left:"+(this.borderWidth)+"px;top:"+(this.borderWidth)+"px;width:100%;height:100%;" + scroll,
        //src:eval(Ext.encode(base + this.textStr))
        //  html: replaceVariableNameWithValue(this.textStr).replace(/type="disc"/gi, "class='normalul'" )
        html: replaceVariableNameWithValue(this.textStr).replace(/type="disc"/gi, replaceStyle)
        // html: (this.textStr)
    });
}
TXTextClass.prototype.setFx = function (cfgXML) {
    this.fxEffect = 0;
    try {
        this.fxEffect = parseInt(trim(cfgXML.getElementsByTagName("FxEffect")[0].childNodes[0].nodeValue));
        this.fxDuration = parseInt(trim(cfgXML.getElementsByTagName("FxDuration")[0].childNodes[0].nodeValue)) / 1000;
        return setFxToElement(this, this.fxEffect, this.fxDuration);
    }
    catch (err) {
        return 0;
    }
}
TXTextClass.prototype.toFront = function () {
    //alert("txtToFront");
    this.content.setStyle("z-index", 65);
}
TXTextClass.prototype.fixPng = function () {
    var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
    var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
    if (Ext.isIE && (ie55 || ie6) && (this.imageSrc.indexOf(".png") >= 0)) {
        this.image.setStyle("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + Author.resourcePath + this.imageSrc + "',sizingMethod='image')");
        this.image.dom.src = "lib/images/blank.gif";
    }
}
TXTextClass.prototype.change = function (cfgXML) {
    Author.current.currentList.item(this.changeID).changeByID = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.setProperties(cfgXML);
    this.addToBackground = Author.current.currentList.item(this.changeID).addToBackground;
    if (this.addToBackground) {
        this.addToBackgroundAtElementPosition = Author.current.currentList.item(this.changeID).addToBackgroundAtElementPosition;
        this.addElementPosition = Author.current.currentElementPosition;
        this.orginalListID = Author.current.currentListXML.attributes[1].nodeValue;
        // Author.backgroundList.list.add(this.id, this);
    }
    this.setFx(cfgXML); //1.2 seconds
    return 0;
}
TXTextClass.prototype.setProperties = function (cfgXML) {
    this.setTop(parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue)));
    this.setLeft(parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue)));
    this.setWidth(this.width);
    this.setHeight(this.height);
    this.baseColor = trim(cfgXML.getElementsByTagName("borderColor")[0].childNodes[0].nodeValue);
    // this.content.setStyle("border-width", this.borderWidth);
    // this.content.setStyle("border-color", trim(cfgXML.getElementsByTagName("borderColor")[0].childNodes[0].nodeValue));
    //  this.content.setStyle("border-style", trim(cfgXML.getElementsByTagName("borderStyle")[0].childNodes[0].nodeValue));
    //  this.content.applyStyles("position: absolute; width: " + (this.width - this.borderWidth * 2) + "px; height: " + (this.height - this.borderWidth * 2) + "px");
    // this.text.applyStyles("position: absolute; width: " + (this.width - this.borderWidth * 2) + "px; height: " + (this.height - this.borderWidth * 2) + "px");
    try {
        if (this.imageSrc != "" && this.imageVisible == "true")
            this.setImagePosition(parseInt(trim(cfgXML.getElementsByTagName("pictureAlign")[0].childNodes[0].nodeValue)));
    }
    catch (err) {
        //  alert("TXTextClass:" + err);
    }
    this.setBackground(cfgXML);
    /*
     try {
     this.setHTML(cfgXML.getElementsByTagName("html")[0].childNodes[0].nodeValue);
     }
     catch (err) {
     displayError("TXTCLASSOBJECT[id:" + this.id + "] doesn't have any text, please check it in the orginal lesson.");
     }
     */
    if (this.autoScroll) {
        if (Author.isIOS()) {
            //this.scrollTimerInterval = 500;
            //this.scrollSpeed = parseFloat(this.scrollSpeed)/5.0;
        }
        this.scrollInterval = parseFloat(this.scrollSpeed) * this.scrollTimerInterval / 1000;
        this.scrollTimer = setTimeout(this.doAutoScroll, this.scrollTimerInterval, this);
    }
}
TXTextClass.prototype.doAutoScroll = function (txTextObject) {
    //alert(arguments.length);
    //alert(txTextObject.id);
    //alert(txTextObject.scrollInterval); 
    //alert(txTextObject.scrollTop + ","+txTextObject.scrollInterval);
    txTextObject.p.dom.scrollTop = txTextObject.p.dom.scrollTop + txTextObject.scrollInterval;
    //if (txTextObject.p.dom.scrollTop < (txTextObject.p.dom.scrollHeight - txTextObject.height)){
    txTextObject.scrollTimer = setTimeout(txTextObject.doAutoScroll, txTextObject.scrollTimerInterval, txTextObject);
    //}
}
TXTextClass.prototype.backgroundFadein = function (duration) {
    this.bg.attr({
        opacity: 0
    })
    this.bg.animate({
        opacity: (this.backStyle == 2 || this.backStyle == 4) ? 0.5 : 1
    }, duration);
}
TXTextClass.prototype.setBgNoShape = function (cfgXML) {
    this.backStyle = parseInt(trim(cfgXML.getElementsByTagName("backStyle")[0].childNodes[0].nodeValue));
    var shape = parseInt(trim(cfgXML.getElementsByTagName("shape")[0].childNodes[0].nodeValue));
    var bgColorStr = trim(cfgXML.getElementsByTagName("backgroundColor")[0].childNodes[0].nodeValue);
    var gradientType = parseInt(trim(cfgXML.getElementsByTagName("gradientType")[0].childNodes[0].nodeValue));
    var startColorStr = trim(cfgXML.getElementsByTagName("startColorStr")[0].childNodes[0].nodeValue);
    var endColorStr = trim(cfgXML.getElementsByTagName("endColorStr")[0].childNodes[0].nodeValue);
    switch (this.backStyle) {
        case 1:
        case 2:
        case 3: //Gradient
        case 4:
            this.content.setStyle("background-color", bgColorStr);
            if (this.backStyle == 2 || this.backStyle == 4) {
            }
            break;
        default:
    }
};
TXTextClass.prototype.setBackground = function (cfgXML) {
    this.backStyle = parseInt(trim(cfgXML.getElementsByTagName("backStyle")[0].childNodes[0].nodeValue));
    var bgColorStr = trim(cfgXML.getElementsByTagName("backgroundColor")[0].childNodes[0].nodeValue);
    var gradientType = parseInt(trim(cfgXML.getElementsByTagName("gradientType")[0].childNodes[0].nodeValue));
    var startColorStr = trim(cfgXML.getElementsByTagName("startColorStr")[0].childNodes[0].nodeValue);
    var endColorStr = trim(cfgXML.getElementsByTagName("endColorStr")[0].childNodes[0].nodeValue);
    if (Author.isAndroid() || (Author.isIEMobile() && parseFloat(BrowserDetect.version) <= 7)) {
        if (parseFloat(BrowserDetect.version) < 3.1) {
            switch (this.backStyle) {
                case 1:
                case 2:
                    this.content.setStyle("background-color", bgColorStr);
                    break;
                case 3: //Gradient
                case 4:
                    this.content.setStyle("background-color", startColorStr);
                    break;
                default:
            }
            return;
        }
    }
    var bgContainer = Raphael(this.content.dom, this.width, this.height);
    //  alert("backStyle: "+backStyle+"\ngradientType: "+gradientType);
    var shape = parseInt(trim(cfgXML.getElementsByTagName("shape")[0].childNodes[0].nodeValue));
    // var r = roundCorner ? Math.min(this.width, this.height) / 10 : 0;
    // this.bg = bgContainer.rect(0, 0, this.width - 1, this.height - 1, r);
    // this.bg = bgContainer.rect(0, 0, this.width - 1, this.height - 1, 0);
    switch (shape) {
        case 1://square
            var l = Math.min(this.width, this.height);
            this.bg = bgContainer.rect((this.width - l) / 2, (this.height - l) / 2, l - 1, l - 1, 0);
            break;
        case 2://Oval
            this.bg = bgContainer.ellipse((this.width) / 2, (this.height) / 2, (this.width) / 2 - 1, (this.height) / 2 - 1);
            break;
        case 3://circle
            var l = Math.min(this.width, this.height);
            this.bg = bgContainer.circle((this.width) / 2, (this.height) / 2, l / 2 - 1);
            break;
        case 4://Rounded Rect
            var r = Math.min(this.width, this.height) / 10;
            this.bg = bgContainer.rect(0, 0, this.width - 1, this.height - 1, r);
            break;
        case 5: //Rounded Square
            var l = Math.min(this.width, this.height);
            this.bg = bgContainer.rect((this.width - l) / 2, (this.height - l) / 2, l - 1, l - 1, l / 10);
            break;
        case 6://Octagon
            var l = Math.min(this.width, this.height) / 2;
            var cx = (this.width) / 2;
            var cy = (this.height) / 2;
            var pathStr = "M" + (cx + l * ccos(45 - 22.5)) + " " + (cy + l * ssin(45 - 22.5));
            pathStr += "L" + (cx + l * ccos(45 * 2 - 22.5)) + " " + (cy + l * ssin(45 * 2 - 22.5));
            pathStr += "L" + (cx + l * ccos(45 * 3 - 22.5)) + " " + (cy + l * ssin(45 * 3 - 22.5));
            pathStr += "L" + (cx + l * ccos(45 * 4 - 22.5)) + " " + (cy + l * ssin(45 * 4 - 22.5));
            pathStr += "L" + (cx + l * ccos(45 * 5 - 22.5)) + " " + (cy + l * ssin(45 * 5 - 22.5));
            pathStr += "L" + (cx + l * ccos(45 * 6 - 22.5)) + " " + (cy + l * ssin(45 * 6 - 22.5));
            pathStr += "L" + (cx + l * ccos(45 * 7 - 22.5)) + " " + (cy + l * ssin(45 * 7 - 22.5));
            pathStr += "L" + (cx + l * ccos(45 * 8 - 22.5)) + " " + (cy + l * ssin(45 * 8 - 22.5));
            pathStr += " Z";
            this.bg = bgContainer.path(pathStr);
            break;
        case 7://Star
            var l = Math.min(this.width, this.height) / 2;
            var r = l * 0.618 / 1.618;
            var cx = (this.width) / 2;
            var cy = (this.height) / 2;
            var pathStr = "M" + (cx) + " " + (cy - l);
            pathStr += "L" + (cx + r * ccos(-54)) + " " + (cy + r * ssin(-54));
            pathStr += "L" + (cx + l * ccos(72 * 1 - 90)) + " " + (cy + l * ssin(72 * 1 - 90));
            pathStr += "L" + (cx + r * ccos(72 * 1 - 54)) + " " + (cy + r * ssin(72 * 1 - 54));
            pathStr += "L" + (cx + l * ccos(72 * 2 - 90)) + " " + (cy + l * ssin(72 * 2 - 90));
            pathStr += "L" + (cx + r * ccos(72 * 2 - 54)) + " " + (cy + r * ssin(72 * 2 - 54));
            pathStr += "L" + (cx + l * ccos(72 * 3 - 90)) + " " + (cy + l * ssin(72 * 3 - 90));
            pathStr += "L" + (cx + r * ccos(72 * 3 - 54)) + " " + (cy + r * ssin(72 * 3 - 54));
            pathStr += "L" + (cx + l * ccos(72 * 4 - 90)) + " " + (cy + l * ssin(72 * 4 - 90));
            pathStr += "L" + (cx + r * ccos(72 * 4 - 54)) + " " + (cy + r * ssin(72 * 4 - 54));
            pathStr += " Z";
            this.bg = bgContainer.path(pathStr);
            break;
        case 8://Equilateral Trangle
            var l = Math.min(this.width, this.height) / 2;
            var ll = 1.732 / 2 * l;
            var cx = (this.width) / 2;
            var cy = (this.height) / 2;
            var pathStr = "M" + (cx) + " " + (cy - l);
            pathStr += "L" + (cx - ll) + " " + (cy + l / 2);
            pathStr += "L" + (cx + ll) + " " + (cy + l / 2);
            pathStr += " Z";
            this.bg = bgContainer.path(pathStr);
            break;
        case 9://Triangle-Right
            this.bg = bgContainer.path("M0 0L" + (this.width - 1) + " " + this.height / 2 + "L0 " + this.height + " Z");
            break;
        case 10://Triangle-Up
            this.bg = bgContainer.path("M" + (this.width) / 2 + " 0L" + (this.width - 1) + " " + (this.height - 1) + "L0 " + (this.height - 1) + " Z");
            break;
        case 11://Triangle-Left
            this.bg = bgContainer.path("M0 " + (this.height) / 2 + "L" + (this.width - 1) + " 0L" + (this.width - 1) + " " + (this.height - 1) + " Z");
            break;
        case 12://Triangle-Down
            this.bg = bgContainer.path("M0 0L" + (this.width - 1) + " 0L" + (this.width / 2) + " " + (this.height - 1) + " Z");
            break;
        case 13://Diamond
            var l = Math.min(this.width, this.height) / 2;
            var cx = (this.width) / 2;
            var cy = (this.height) / 2;
            this.bg = bgContainer.path("M" + cx + " " + (cy - l) + "L" + (cx + l) + " " + (cy) + "L" + (cx) + " " + (cy + l) + "L" + (cx - l) + " " + (cy) + " Z");
            break;
        case 14://Pentagon
            var l = Math.min(this.width, this.height) / 2;
            var cx = (this.width) / 2;
            var cy = (this.height) / 2;
            var pathStr = "M" + (cx) + " " + (cy - l);
            pathStr += "L" + (cx + l * ccos(72 - 90)) + " " + (cy + l * ssin(72 - 90));
            pathStr += "L" + (cx + l * ccos(72 * 2 - 90)) + " " + (cy + l * ssin(72 * 2 - 90));
            pathStr += "L" + (cx + l * ccos(72 * 3 - 90)) + " " + (cy + l * ssin(72 * 3 - 90));
            pathStr += "L" + (cx + l * ccos(72 * 4 - 90)) + " " + (cy + l * ssin(72 * 4 - 90));
            pathStr += " Z";
            this.bg = bgContainer.path(pathStr);
            break;
        case 15://Hexagon
            var l = Math.min(this.width, this.height) / 2;
            var ll = 1.732 / 2 * l;
            var cx = (this.width) / 2;
            var cy = (this.height) / 2;
            var pathStr = "M" + (cx - l) + " " + cy;
            pathStr += "L" + (cx - l / 2) + " " + (cy - ll);
            pathStr += "L" + (cx + l / 2) + " " + (cy - ll);
            pathStr += "L" + (cx + l) + " " + (cy);
            pathStr += "L" + (cx + l / 2) + " " + (cy + ll);
            pathStr += "L" + (cx - l / 2) + " " + (cy + ll);
            pathStr += " Z";
            this.bg = bgContainer.path(pathStr);
            break;
        default://Rect
            this.bg = bgContainer.rect(0, 0, this.width - 1, this.height - 1, 0);
            break;
    }
    switch (this.backStyle) {
        case 1:
        case 2:
            this.bg.attr({
                "fill": bgColorStr
            })
            if (this.backStyle == 2) {
                this.bg.attr({
                    opacity: .5
                })
            }
            break;
        case 3: //Gradient
        case 4:
            switch (gradientType) {
                case 1: // Right to Left
                    this.bg.attr({
                        gradient: "180-" + startColorStr + "-" + endColorStr
                    })
                    break;
                case 2: // Top to bottom
                    this.bg.attr({
                        gradient: "270-" + startColorStr + "-" + endColorStr
                    })
                    break;
                case 3: // Bottom to Top
                    this.bg.attr({
                        gradient: "90-" + startColorStr + "-" + endColorStr
                    })
                    break;
                case 6: // tl-br
                    this.bg.attr({
                        gradient: "315-" + startColorStr + "-" + endColorStr
                    })
                    break;
                case 7: // br-tl
                    this.bg.attr({
                        gradient: "135-" + startColorStr + "-" + endColorStr
                    })
                    break;
                case 8: //tr-bl
                    this.bg.attr({
                        gradient: "225-" + startColorStr + "-" + endColorStr
                    })
                    break;
                case 9: //bl-tr
                    this.bg.attr({
                        gradient: "45-" + startColorStr + "-" + endColorStr
                    })
                    break;
                case 10: //tl br c
                    this.bg.attr({
                        gradient: "315-" + startColorStr + "-" + endColorStr + ":50" + "-" + startColorStr
                    })
                    break;
                case 11: //tl br c
                    this.bg.attr({
                        gradient: "315-" + endColorStr + "-" + startColorStr + ":50" + "-" + endColorStr
                    })
                    break;
                case 12: //tl br c
                    this.bg.attr({
                        gradient: "225-" + startColorStr + "-" + endColorStr + ":50" + "-" + startColorStr
                    })
                    break;
                case 13: //tl br c
                    this.bg.attr({
                        gradient: "225-" + endColorStr + "-" + startColorStr + ":50" + "-" + endColorStr
                    })
                    break;
                case 16: //tl br c
                    this.bg.attr({
                        gradient: "0-" + startColorStr + "-" + endColorStr + ":50" + "-" + startColorStr
                    })
                    break;
                case 17: //tl br c
                    this.bg.attr({
                        gradient: "0-" + endColorStr + "-" + startColorStr + ":50" + "-" + endColorStr
                    })
                    break;
                case 18: //tl br c
                    this.bg.attr({
                        gradient: "90-" + startColorStr + "-" + endColorStr + ":50" + "-" + startColorStr
                    })
                    break;
                case 19: //tl br c
                    this.bg.attr({
                        gradient: "90-" + endColorStr + "-" + startColorStr + ":50" + "-" + endColorStr
                    })
                    break;
                default:
                    this.bg.attr({
                        gradient: "0-" + startColorStr + "-" + endColorStr
                    })
                    break;
            }
            if (this.backStyle == 4) {
                this.bg.attr({
                    opacity: .5
                })
            }
            break;
        default:
    }
    //alert("borderColor: " + trim(cfgXML.getElementsByTagName("borderColor")[0].childNodes[0].nodeValue) + "\nWidth: " + this.borderWidth);
    this.bg.attr({
        stroke: trim(cfgXML.getElementsByTagName("borderColor")[0].childNodes[0].nodeValue),
        "stroke-width": this.borderWidth
    })
    if (this.borderWidth == 0) {
        this.bg.attr({
            "stroke-opacity": 0
        })
    }
    // this.content.setStyle("border-width", this.borderWidth + "px");
    // this.content.setStyle("border-color", trim(cfgXML.getElementsByTagName("borderColor")[0].childNodes[0].nodeValue));
    // this.content.setStyle("border-style", trim(cfgXML.getElementsByTagName("borderStyle")[0].childNodes[0].nodeValue));
}
TXTextClass.prototype.readConfig = function (cfgXML) {
    this.changeByID = null;
    if (this.changeAction == "true") {
        Author.current.currentList.item(this.changeID).setVisible(false);
        return this.change(cfgXML);
    }
    this.setProperties(cfgXML);
    this.addToBackground = (trim(cfgXML.getElementsByTagName("addToBackground")[0].childNodes[0].nodeValue).toLowerCase() == "true");
    if (this.addToBackground) {
        this.orginalListID = Author.current.currentListXML.attributes[1].nodeValue;
        Author.backgroundList.list.add(this.id, this);
        this.addToBackgroundAtElementPosition = Author.current.currentElementPosition;
    }
    this.setFx(cfgXML); //1.2 seconds
    return 0;
}
TXTextClass.prototype.setImagePosition = function (index) {
    var imageWidth = (this.imageWidth == -1) ? this.image.getWidth() : this.imageWidth;
    var imageHeight = (this.imageHeight == -1) ? this.image.getHeight() : this.imageHeight;
    var bgWidth = this.content.getWidth();
    var bgHeight = this.content.getHeight();
    switch (index) {
        case 0:
            this.image.setLeft(this.imageX);
            this.image.setTop(this.imageY);
            break;
        case 1:
            this.image.setLeft(this.imageX);
            this.image.setTop(this.imageY + (bgHeight - imageHeight) / 2);
            break;
        case 2:
            this.image.setLeft(this.imageX);
            this.image.setTop(this.imageY + (bgHeight - imageHeight));
            break;
        case 3:
            this.image.setLeft(this.imageX + (bgWidth - imageWidth));
            this.image.setTop(this.imageY);
            break;
        case 4:
            this.image.setLeft(this.imageX + (bgWidth - imageWidth));
            this.image.setTop(this.imageY + (bgHeight - imageHeight) / 2);
            break;
        case 5:
            this.image.setLeft(this.imageX + (bgWidth - imageWidth));
            this.image.setTop(this.imageY + (bgHeight - imageHeight));
            break;
        case 6:
            this.image.setLeft(this.imageX + (bgWidth - imageWidth) / 2);
            this.image.setTop(this.imageY);
            break;
            break;
        case 7:
            this.image.setLeft(this.imageX + (bgWidth - imageWidth) / 2);
            this.image.setTop(this.imageY + (bgHeight - imageHeight) / 2);
            break;
        case 8:
            this.image.setLeft(this.imageX + (bgWidth - imageWidth) / 2);
            this.image.setTop(this.imageY + (bgHeight - imageHeight));
            break;
    }
}
TXTextClass.prototype.setHTML = function (htmlContent) {
    // this.p.dom.innerHTML = replaceVariableNameWithValue(htmlContent);
    this.p.dom.innerHTML = htmlContent;
}
TXTextClass.prototype.setTop = function (y) {
    this.content.setStyle("top", y + "px");
}
TXTextClass.prototype.setLeft = function (x) {
    this.content.setStyle("left", x + "px");
}
TXTextClass.prototype.setWidth = function (width) {
    this.width = width;
    this.content.setWidth(width);
}
TXTextClass.prototype.setHeight = function (height) {
    this.height = height;
    this.content.setHeight(height);
}
TXTextClass.prototype.setVisible = function (visible) {
    this.visible = visible;
    if (this.changeByID != null) {
        Author.current.currentList.item(this.changeByID).setVisible(visible);
    }
    else {
        try {
            this.content.setVisible(visible);
        }
        catch (err) {
        }
    }
}
TXTextClass.prototype.remove = function () {
    try {
        if (this.changeAction == "true") {
            Author.current.currentList.item(this.originalID).changeByID = null;
        }
        if (this.autoScroll) {
            window.clearTimeout(this.scrollTimer);
        }
        this.content.remove();
    }
    catch (err) {
    }
}
TXTextClass.prototype.setStyle = function (CSSStyle) {
    this.content.applyStyles(CSSStyle);
}
/**
 * TextClass
 * @param {Object} bgObject
 */
function TextClass(bgObject, cfgXML, o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.objectType = "TEXTOBJECT";
    this.imageVisible = "false";
    this.changeByID = null;
    this.hide = trim(cfgXML.getElementsByTagName("hide")[0].childNodes[0].nodeValue).toLowerCase();
    this.addToBackground = (trim(cfgXML.getElementsByTagName("addToBackground")[0].childNodes[0].nodeValue) == "True");
    try {
        this.imageSrc = trim(cfgXML.getElementsByTagName("picture")[0].childNodes[0].nodeValue).toLowerCase();
        var img = new Image();
        img.src = Author.resourcePath + this.imageSrc;
        this.imageX = parseInt(trim(cfgXML.getElementsByTagName("pictureX")[0].childNodes[0].nodeValue));
        this.imageY = parseInt(trim(cfgXML.getElementsByTagName("pictureY")[0].childNodes[0].nodeValue));
        this.imageVisible = trim(cfgXML.getElementsByTagName("pictureVisible")[0].childNodes[0].nodeValue).toLowerCase();
    }
    catch (err) {
        this.imageSrc = "";
    }
    this.width = parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue));
    this.height = parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue));
    this.textX = parseInt(trim(cfgXML.getElementsByTagName("textX")[0].childNodes[0].nodeValue));
    this.textY = parseInt(trim(cfgXML.getElementsByTagName("textY")[0].childNodes[0].nodeValue));
    this.textPosition = parseInt(trim(cfgXML.getElementsByTagName("textPosition")[0].childNodes[0].nodeValue));
    this.changeAction = trim(cfgXML.getElementsByTagName("changeAction")[0].childNodes[0].nodeValue).toLowerCase();
    if (this.changeAction == "true") {
        this.originalID = trim(cfgXML.getElementsByTagName("originalID")[0].childNodes[0].nodeValue);
        this.changeID = trim(cfgXML.getElementsByTagName("changeID")[0].childNodes[0].nodeValue);
        try {
            this.addToBackground = Author.current.currentList.item(this.changeID).addToBackground;
        }
        catch (err) {
            this.addToBackground = false;
        }
    }
    this.content = bgObject.createChild({
        tag: "div",
        style: "overflow:hidden;position:absolute;cursor:default;"

    });
    if (this.imageSrc != "" && this.imageVisible == "true") {
        var imagePreLoad = new Image();
        imagePreLoad.src = Author.resourcePath + this.imageSrc;
        var iWidth = parseInt(cfgXML.getElementsByTagName("picture")[0].attributes[0].nodeValue);
        var iHeight = parseInt(cfgXML.getElementsByTagName("picture")[0].attributes[1].nodeValue);
        this.image = this.content.createChild({
            tag: "img",
            width: iWidth,
            height: iHeight,
            style: "position:absolute;alt:''"
        });
        this.image.dom.src = Author.resourcePath + this.imageSrc;
        this.fixPng();
    }
    ;
    this.text = this.content.createChild({
        tag: "div",
        style: "position:absolute"
    });
    var textStyle = "font-family:" + trim(cfgXML.getElementsByTagName("font-family")[0].childNodes[0].nodeValue) + ";";
    textStyle = textStyle + "font-size:" + trim(cfgXML.getElementsByTagName("font-size")[0].childNodes[0].nodeValue) + "pt;";
    textStyle = textStyle + "font-style:" + trim(cfgXML.getElementsByTagName("font-style")[0].childNodes[0].nodeValue) + ";";
    textStyle = textStyle + "font-weight:" + trim(cfgXML.getElementsByTagName("font-weight")[0].childNodes[0].nodeValue) + ";";
    textStyle = textStyle + "text-decoration:" + trim(cfgXML.getElementsByTagName("text-decoration")[0].childNodes[0].nodeValue) + ";";
    textStyle = textStyle + "color:" + trim(cfgXML.getElementsByTagName("color")[0].childNodes[0].nodeValue);// + ";padding:1px 1px 1px 1px";
    try {
        this.textStr = (cfgXML.getElementsByTagName("text")[0].childNodes[0].nodeValue);
    }
    catch (err) {
        this.textStr = "";
    }
    this.textStr = this.textStr.replace(/\&\&/g, "_*_");
    this.textStr = this.textStr.replace(/\&/g, "");
    this.textStr = this.textStr.replace(/_\*_/g, "&");
    this.textStr = this.textStr.replace(/ {2}/g, " &nbsp;");
    /*
     this.textStr = this.textStr.replace(/( {2,})/g, function(name, variableName){
     return name.replace(/ /g, "&nbsp;");
     });
     */
    var replacedText = replaceVariableNameWithValue(this.textStr);
    this.p = this.text.createChild({
        tag: "div",
        style: "position:absolute;" + textStyle,
        html: replacedText
    });
    this.visible = true;
    //speakTextUsingGoogleTTS(replacedText);
    //speakNumbers(replacedText);
}
TextClass.prototype.toFront = function () {
    this.content.setStyle("z-index", 65);
}
TextClass.prototype.setFx = function (cfgXML) {
    this.fxEffect = 0;
    try {
        this.fxEffect = parseInt(trim(cfgXML.getElementsByTagName("FxEffect")[0].childNodes[0].nodeValue));
        this.fxDuration = parseInt(trim(cfgXML.getElementsByTagName("FxDuration")[0].childNodes[0].nodeValue)) / 1000;
        return setFxToElement(this, this.fxEffect, this.fxDuration);
    }
    catch (err) {
        return 0;
    }
}
TextClass.prototype.fixPng = function () {
    var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
    var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
    if (Ext.isIE && (ie55 || ie6) && (this.imageSrc.indexOf(".png") >= 0)) {
        this.image.setStyle("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + Author.resourcePath + this.imageSrc + "',sizingMethod='image')");
        this.image.dom.src = "lib/images/blank.gif";
    }
}
TextClass.prototype.change = function (cfgXML) {
    Author.current.currentList.item(this.changeID).changeByID = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.setProperties(cfgXML);
    this.addToBackground = Author.current.currentList.item(this.changeID).addToBackground;
    if (this.addToBackground) {
        this.addToBackgroundAtElementPosition = Author.current.currentList.item(this.changeID).addToBackgroundAtElementPosition;
        this.addElementPosition = Author.current.currentElementPosition;
        this.orginalListID = Author.current.currentListXML.attributes[1].nodeValue;
        // Author.backgroundList.list.add(this.id, this);
    }
    this.setFx(cfgXML); //1.2 seconds
    // alert("changed text");
    return 0;
}
TextClass.prototype.setProperties = function (cfgXML) {
    this.top = parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue));
    this.left = parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue));
    this.width = parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue));
    this.height = parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue));
    this.borderWidth = parseInt(trim(cfgXML.getElementsByTagName("borderWidth")[0].childNodes[0].nodeValue));
    this.baseColor = trim(cfgXML.getElementsByTagName("borderColor")[0].childNodes[0].nodeValue);
    this.content.setStyle("border-width", "0px");
    //this.content.setStyle("border-width", this.borderWidth+"px");
    //this.content.setStyle("border-color", this.baseColor);
    //this.content.setStyle("border-style", trim(cfgXML.getElementsByTagName("borderStyle")[0].childNodes[0].nodeValue));
    //this.content.setStyle("border-style","ridge");
    this.setTop(this.top);
    this.setLeft(this.left);
    this.setWidth(this.width);
    this.setHeight(this.height);
    try {
        this.text.applyStyles("position: absolute; width: " + (this.width - this.borderWidth * 2) + "px; height: " + (this.height - this.borderWidth * 2) + "px");
    }
    catch (err) {
    }
    try {
        this.setTextPosition(parseInt(trim(cfgXML.getElementsByTagName("textPosition")[0].childNodes[0].nodeValue)));
        if (this.imageSrc != "" && this.imageVisible == "true")
            this.setImagePosition(parseInt(trim(cfgXML.getElementsByTagName("pictureAlign")[0].childNodes[0].nodeValue)));
    }
    catch (err) {
        //   alert("TextClass:" + err);
    }
    try {
        this.font3d = parseInt(trim(cfgXML.getElementsByTagName("font3d")[0].childNodes[0].nodeValue));
        this.f3dSize = parseInt(trim(cfgXML.getElementsByTagName("fontBlockSize")[0].childNodes[0].nodeValue));
        try {
            this.fontShadowColor = trim(cfgXML.getElementsByTagName("fontShadowColor")[0].childNodes[0].nodeValue);
            this.fontOutlineColor = trim(cfgXML.getElementsByTagName("fontOutlineColor")[0].childNodes[0].nodeValue);
            this.fontDropX = parseInt(cfgXML.getElementsByTagName("fontDropX")[0].childNodes[0].nodeValue);
            this.fontDropY = parseInt(cfgXML.getElementsByTagName("fontDropY")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.fontShadowColor = "black";
            this.fontOutlineColor = "black";
            this.fontDropX = 0;
            this.fontDropY = 0;
        }
        switch (this.font3d) {
            case 0, 1, 2, 3, 4:
                break;
            case 5:
                this.p.setStyle("filter", "Dropshadow(offx=" + this.fontDropX + ",offy=" + this.fontDropY + ",color=" + this.fontShadowColor + ")");
                if (!Ext.isIE) {
                    this.p.setStyle("text-shadow", this.fontDropX + "px " + this.fontDropY + "px 1px " + this.fontShadowColor);
                }
                break;
            case 6:
                var sProperty = "";
                for (var ii = 1; ii <= this.f3dSize; ii++) {
                    sProperty += "Dropshadow(offx=1,offy=1,color=" + this.fontShadowColor + ") ";
                }
                this.p.setStyle("filter", sProperty);
                if (!Ext.isIE) {
                    this.p.setStyle("text-shadow", this.f3dSize + "px " + this.f3dSize + "px 1px " + this.fontShadowColor);
                }
                break;
            case 7:
                var sProperty = "";
                for (var ii = 1; ii <= this.f3dSize; ii++) {
                    sProperty += "Dropshadow(offx=1,offy=1,color=" + this.fontShadowColor + ") ";
                }
                this.p.setStyle("filter", "Dropshadow(offx=1,offy=0,color=" + this.fontOutlineColor + ")Dropshadow(offx=0,offy=1,color=" + this.fontOutlineColor + ")Dropshadow(offx=0,offy=-1,color=" + this.fontOutlineColor + ") Dropshadow(offx=-1,offy=0,color=" + this.fontOutlineColor + ")" + sProperty);
                if (!Ext.isIE) {
                    this.p.setStyle("text-shadow", this.f3dSize + "px " + this.f3dSize + "px 1px " + this.fontShadowColor);
                }
                break;
            default:
                break;
        }
    }
    catch (err) {
        // alert("Error in draw text edge at LINE 951\n" + err.description);
    }
    this.setBackground(cfgXML);
}
TextClass.prototype.backgroundFadein = function (duration) {
    this.bg.attr({
        opacity: 0
    })
    this.bg.animate({
        opacity: (this.backStyle == 2 || this.backStyle == 4) ? 0.5 : 1
    }, duration);
}
TextClass.prototype.setBgNoShape = function (cfgXML) {
    this.backStyle = parseInt(trim(cfgXML.getElementsByTagName("backStyle")[0].childNodes[0].nodeValue));
    var shape = parseInt(trim(cfgXML.getElementsByTagName("shape")[0].childNodes[0].nodeValue));
    var bgColorStr = trim(cfgXML.getElementsByTagName("backgroundColor")[0].childNodes[0].nodeValue);
    var gradientType = parseInt(trim(cfgXML.getElementsByTagName("gradientType")[0].childNodes[0].nodeValue));
    var startColorStr = trim(cfgXML.getElementsByTagName("startColorStr")[0].childNodes[0].nodeValue);
    var endColorStr = trim(cfgXML.getElementsByTagName("endColorStr")[0].childNodes[0].nodeValue);
    switch (this.backStyle) {
        case 1:
        case 2:
        case 3: //Gradient
        case 4:
            this.content.setStyle("background-color", bgColorStr);
            if (this.backStyle == 2 || this.backStyle == 4) {
            }
            break;
        default:
    }
};
TextClass.prototype.setBackground = function (cfgXML) {
    this.backStyle = parseInt(trim(cfgXML.getElementsByTagName("backStyle")[0].childNodes[0].nodeValue));
    var shape = parseInt(trim(cfgXML.getElementsByTagName("shape")[0].childNodes[0].nodeValue));
    var bgColorStr = trim(cfgXML.getElementsByTagName("backgroundColor")[0].childNodes[0].nodeValue);
    var gradientType = parseInt(trim(cfgXML.getElementsByTagName("gradientType")[0].childNodes[0].nodeValue));
    var startColorStr = trim(cfgXML.getElementsByTagName("startColorStr")[0].childNodes[0].nodeValue);
    var endColorStr = trim(cfgXML.getElementsByTagName("endColorStr")[0].childNodes[0].nodeValue);
    if (Author.isAndroid() || (Author.isIEMobile() && parseFloat(BrowserDetect.version) <= 7)) {
        if (parseFloat(BrowserDetect.version) < 3.1) {
            switch (this.backStyle) {
                case 1:
                case 2:
                    this.content.setStyle("background-color", bgColorStr);
                    break;
                case 3: //Gradient
                case 4:
                    this.content.setStyle("background-color", startColorStr);
                    break;
                default:
            }
            return;
        }
    }
    var bgContainer = Raphael(this.content.dom, this.width, this.height);
    // alert(bgContainer);
    switch (shape) {
        case 1://square
            var l = Math.min(this.width, this.height) - this.borderWidth;
            this.bg = bgContainer.rect((this.width - l + this.borderWidth) / 2, (this.height - l + this.borderWidth) / 2, l - 1, l - 1, 0);
            break;
        case 2://Oval
            this.bg = bgContainer.ellipse((this.width) / 2 + this.borderWidth / 2, (this.height) / 2 + this.borderWidth / 2, (this.width) / 2 - 1 - this.borderWidth, (this.height) / 2 - 1 - this.borderWidth);
            break;
        case 3://circle
            var l = Math.min(this.width, this.height) - this.borderWidth * 2;
            this.bg = bgContainer.circle((this.width) / 2 + this.borderWidth / 2, (this.height) / 2 + this.borderWidth / 2, l / 2 - 1);
            break;
        case 4://Rounded Rect
            var r = Math.min(this.width, this.height) / 10;
            this.bg = bgContainer.rect(this.borderWidth / 2, this.borderWidth / 2, this.width - this.borderWidth - 1, this.height - this.borderWidth - 1, r);
            break;
        case 5: //Rounded Square
            var l = Math.min(this.width, this.height) - this.borderWidth;
            this.bg = bgContainer.rect((this.width - l + this.borderWidth) / 2, (this.height - l + this.borderWidth / 2) / 2, l - 1, l - 1, l / 10);
            break;
        case 6://Octagon
            var l = Math.min(this.width, this.height) / 2;
            var cx = (this.width) / 2;
            var cy = (this.height) / 2;
            var pathStr = "M" + (cx + l * ccos(45 - 22.5)) + " " + (cy + l * ssin(45 - 22.5));
            pathStr += "L" + (cx + l * ccos(45 * 2 - 22.5)) + " " + (cy + l * ssin(45 * 2 - 22.5));
            pathStr += "L" + (cx + l * ccos(45 * 3 - 22.5)) + " " + (cy + l * ssin(45 * 3 - 22.5));
            pathStr += "L" + (cx + l * ccos(45 * 4 - 22.5)) + " " + (cy + l * ssin(45 * 4 - 22.5));
            pathStr += "L" + (cx + l * ccos(45 * 5 - 22.5)) + " " + (cy + l * ssin(45 * 5 - 22.5));
            pathStr += "L" + (cx + l * ccos(45 * 6 - 22.5)) + " " + (cy + l * ssin(45 * 6 - 22.5));
            pathStr += "L" + (cx + l * ccos(45 * 7 - 22.5)) + " " + (cy + l * ssin(45 * 7 - 22.5));
            pathStr += "L" + (cx + l * ccos(45 * 8 - 22.5)) + " " + (cy + l * ssin(45 * 8 - 22.5));
            pathStr += " Z";
            this.bg = bgContainer.path(pathStr);
            break;
        case 7://Star
            var l = Math.min(this.width, this.height) / 2;
            var r = l * 0.618 / 1.618;
            var cx = (this.width) / 2;
            var cy = (this.height) / 2;
            var pathStr = "M" + (cx) + " " + (cy - l);
            pathStr += "L" + (cx + r * ccos(-54)) + " " + (cy + r * ssin(-54));
            pathStr += "L" + (cx + l * ccos(72 * 1 - 90)) + " " + (cy + l * ssin(72 * 1 - 90));
            pathStr += "L" + (cx + r * ccos(72 * 1 - 54)) + " " + (cy + r * ssin(72 * 1 - 54));
            pathStr += "L" + (cx + l * ccos(72 * 2 - 90)) + " " + (cy + l * ssin(72 * 2 - 90));
            pathStr += "L" + (cx + r * ccos(72 * 2 - 54)) + " " + (cy + r * ssin(72 * 2 - 54));
            pathStr += "L" + (cx + l * ccos(72 * 3 - 90)) + " " + (cy + l * ssin(72 * 3 - 90));
            pathStr += "L" + (cx + r * ccos(72 * 3 - 54)) + " " + (cy + r * ssin(72 * 3 - 54));
            pathStr += "L" + (cx + l * ccos(72 * 4 - 90)) + " " + (cy + l * ssin(72 * 4 - 90));
            pathStr += "L" + (cx + r * ccos(72 * 4 - 54)) + " " + (cy + r * ssin(72 * 4 - 54));
            pathStr += " Z";
            this.bg = bgContainer.path(pathStr);
            break;
        case 8://Equilateral Trangle
            var l = Math.min(this.width, this.height) / 2 - this.borderWidth / 2;
            var ll = 1.732 / 2 * l;
            var cx = (this.width + this.borderWidth) / 2;
            var cy = (this.height + this.borderWidth) / 2;
            var pathStr = "M" + (cx) + " " + (cy - l);
            pathStr += "L" + (cx - ll) + " " + (cy + l / 2);
            pathStr += "L" + (cx + ll) + " " + (cy + l / 2);
            pathStr += " Z";
            this.bg = bgContainer.path(pathStr);
            break;
        case 9://Triangle-Right
            this.bg = bgContainer.path("M" + (this.borderWidth / 2) + " " + (this.borderWidth / 2) + " L" + (this.width - 1 - this.borderWidth / 2) + " " + (this.height / 2 + this.borderWidth / 2) + "L" + (this.borderWidth / 2) + " " + (this.height - this.borderWidth / 2) + " Z");
            break;
        case 10://Triangle-Up
            this.bg = bgContainer.path("M" + (this.width + this.borderWidth) / 2 + " " + (this.borderWidth / 2) + "L" + (this.width - 1 - this.borderWidth / 2) + " " + (this.height - 1 - this.borderWidth / 2) + "L" + (this.borderWidth / 2) + " " + (this.height - 1 - this.borderWidth / 2) + " Z");
            break;
        case 11://Triangle-Left
            this.bg = bgContainer.path("M" + (this.borderWidth / 2) + " " + (this.height + this.borderWidth) / 2 + "L" + (this.width - 1 - this.borderWidth / 2) + " " + (this.borderWidth / 2) + "L" + (this.width - 1 - this.borderWidth / 2) + " " + (this.height - 1 - this.borderWidth / 2) + " Z");
            break;
        case 12://Triangle-Down
            this.bg = bgContainer.path("M" + (this.borderWidth / 2) + " " + (this.borderWidth / 2) + " L" + (this.width - 1 - this.borderWidth / 2) + " " + (this.borderWidth / 2) + "L" + (this.width / 2 - this.borderWidth / 2) + " " + (this.height - 1 - this.borderWidth / 2) + " Z");
            break;
        case 13://Diamond
            var l = Math.min(this.width, this.height) / 2 - this.borderWidth;
            var cx = (this.width + this.borderWidth) / 2;
            var cy = (this.height + this.borderWidth) / 2;
            this.bg = bgContainer.path("M" + cx + " " + (cy - l) + "L" + (cx + l) + " " + (cy) + "L" + (cx) + " " + (cy + l) + "L" + (cx - l) + " " + (cy) + " Z");
            break;
        case 14://Pentagon
            var l = Math.min(this.width, this.height) / 2 - this.borderWidth / 2;
            var cx = (this.width) / 2 + this.borderWidth;
            var cy = (this.height) / 2 + this.borderWidth;
            var pathStr = "M" + (cx) + " " + (cy - l);
            pathStr += "L" + (cx + l * ccos(72 - 90)) + " " + (cy + l * ssin(72 - 90));
            pathStr += "L" + (cx + l * ccos(72 * 2 - 90)) + " " + (cy + l * ssin(72 * 2 - 90));
            pathStr += "L" + (cx + l * ccos(72 * 3 - 90)) + " " + (cy + l * ssin(72 * 3 - 90));
            pathStr += "L" + (cx + l * ccos(72 * 4 - 90)) + " " + (cy + l * ssin(72 * 4 - 90));
            pathStr += " Z";
            this.bg = bgContainer.path(pathStr);
            break;
        case 15://Hexagon
            var l = Math.min(this.width, this.height) / 2;
            var ll = 1.732 / 2 * l;
            var cx = (this.width + this.borderWidth) / 2;
            var cy = (this.height + this.borderWidth) / 2;
            var pathStr = "M" + (cx - l) + " " + cy;
            pathStr += "L" + (cx - l / 2) + " " + (cy - ll);
            pathStr += "L" + (cx + l / 2) + " " + (cy - ll);
            pathStr += "L" + (cx + l) + " " + (cy);
            pathStr += "L" + (cx + l / 2) + " " + (cy + ll);
            pathStr += "L" + (cx - l / 2) + " " + (cy + ll);
            pathStr += " Z";
            this.bg = bgContainer.path(pathStr);
            break;
        default://Rect
            this.bg = bgContainer.rect(this.borderWidth / 2, this.borderWidth / 2, this.width - this.borderWidth - 1, this.height - this.borderWidth - 1, 0);
            break;
    }
    this.bg.attr({
        "stroke": trim(cfgXML.getElementsByTagName("borderColor")[0].childNodes[0].nodeValue),
        "stroke-width": this.borderWidth
    })
    if (this.borderWidth == 0) {
        this.bg.attr({
            "stroke-opacity": 0
        })
    }
    switch (this.backStyle) {
        case 1:
        case 2:
            this.bg.attr({
                "fill": bgColorStr
            })
            if (this.backStyle == 2) {
                this.bg.attr({
                    opacity: .5
                })
            }
            break;
        case 3: //Gradient
        case 4:
            switch (gradientType) {
                case 1: // Right to Left
                    this.bg.attr({
                        gradient: "180-" + startColorStr + "-" + endColorStr
                    })
                    break;
                case 2: // Top to bottom
                    this.bg.attr({
                        gradient: "270-" + startColorStr + "-" + endColorStr
                    })
                    break;
                case 3: // Bottom to Top
                    this.bg.attr({
                        gradient: "90-" + startColorStr + "-" + endColorStr
                    })
                    break;
                case 6: // tl-br
                    this.bg.attr({
                        gradient: "315-" + startColorStr + "-" + endColorStr
                    })
                    break;
                case 7: // br-tl
                    this.bg.attr({
                        gradient: "135-" + startColorStr + "-" + endColorStr
                    })
                    break;
                case 8: //tr-bl
                    this.bg.attr({
                        gradient: "225-" + startColorStr + "-" + endColorStr
                    })
                    break;
                case 9: //bl-tr
                    this.bg.attr({
                        gradient: "45-" + startColorStr + "-" + endColorStr
                    })
                    break;
                case 10: //tl br c
                    this.bg.attr({
                        gradient: "315-" + startColorStr + "-" + endColorStr + ":50" + "-" + startColorStr
                    })
                    break;
                case 11: //tl br c
                    this.bg.attr({
                        gradient: "315-" + endColorStr + "-" + startColorStr + ":50" + "-" + endColorStr
                    })
                    break;
                case 12: //tl br c
                    this.bg.attr({
                        gradient: "225-" + startColorStr + "-" + endColorStr + ":50" + "-" + startColorStr
                    })
                    break;
                case 13: //tl br c
                    this.bg.attr({
                        gradient: "225-" + endColorStr + "-" + startColorStr + ":50" + "-" + endColorStr
                    })
                    break;
                case 16: //tl br c
                    this.bg.attr({
                        gradient: "0-" + startColorStr + "-" + endColorStr + ":50" + "-" + startColorStr
                    })
                    break;
                case 17: //tl br c
                    this.bg.attr({
                        gradient: "0-" + endColorStr + "-" + startColorStr + ":50" + "-" + endColorStr
                    })
                    break;
                case 18: //tl br c
                    this.bg.attr({
                        gradient: "90-" + startColorStr + "-" + endColorStr + ":50" + "-" + startColorStr
                    })
                    break;
                case 19: //tl br c
                    this.bg.attr({
                        gradient: "90-" + endColorStr + "-" + startColorStr + ":50" + "-" + endColorStr
                    })
                    break;
                default:
                    this.bg.attr({
                        gradient: "0-" + startColorStr + "-" + endColorStr
                    })
                    break;
            }
            if (this.backStyle == 4) {
                this.bg.attr({
                    opacity: .5
                })
            }
            break;
        default:
    }
    //alert("borderColor: " + trim(cfgXML.getElementsByTagName("borderColor")[0].childNodes[0].nodeValue) + "\nWidth: " + this.borderWidth);
    // this.content.setStyle("border-width", this.borderWidth + "px");
    // this.content.setStyle("border-color", trim(cfgXML.getElementsByTagName("borderColor")[0].childNodes[0].nodeValue));
    // this.content.setStyle("border-style", trim(cfgXML.getElementsByTagName("borderStyle")[0].childNodes[0].nodeValue));
}
TextClass.prototype.setTextPosition = function (index) {
    //start tochange..
    switch (index) {
        case 0: //left
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            //this.text.setLeft(0);
            //this.text.setTop(0);
            this.p.setStyle("text-align", "left");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop(0);
            this.p.setLeft(0);
            break;
        case 1:
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            this.p.setStyle("text-align", "left");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop((this.text.getHeight() - this.p.getHeight()) / 2);
            this.p.setLeft(0);
            break;
        case 2:
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            this.p.setStyle("text-align", "left");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop((this.text.getHeight() - this.p.getHeight()));
            this.p.setLeft(0);
            break;
        case 3: //right
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            //this.text.setLeft(0);
            // this.text.setTop(0);
            this.p.setStyle("text-align", "right");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop(0);
            // this.p.setLeft(this.text.getWidth() - this.p.getWidth());
            this.p.setLeft(0);
            break;
        case 4:
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            this.p.setStyle("text-align", "right");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop((this.text.getHeight() - this.p.getHeight()) / 2);
            // this.p.setLeft(this.text.getWidth() - this.p.getWidth());
            this.p.setLeft(0);
            break;
        case 5:
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            this.p.setStyle("text-align", "right");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop((this.text.getHeight() - this.p.getHeight()));
            // this.p.setLeft(this.text.getWidth() - this.p.getWidth());
            this.p.setLeft(0);
            break;
        case 6://center
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            // this.text.setLeft(0);
            // this.text.setTop(0);
            this.p.setStyle("text-align", "center");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop(0);
            //this.p.setLeft((this.text.getWidth() - this.p.getWidth()) / 2);
            this.p.setLeft(0);
            break;
        case 7:
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            this.p.setStyle("text-align", "center");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop((this.text.getHeight() - this.p.getHeight()) / 2);
            // this.p.setLeft((this.text.getWidth() - this.p.getWidth()) / 2);
            this.p.setLeft(0);
            break;
        case 8:
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            this.p.setStyle("text-align", "center");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop((this.text.getHeight() - this.p.getHeight()));
            //this.p.setLeft((this.text.getWidth() - this.p.getWidth()) / 2);
            this.p.setLeft(0);
            break;
    }
}
TextClass.prototype.setImagePosition = function (index) {
    var imageWidth = this.image.getWidth();
    var imageHeight = this.image.getHeight();
    var bgWidth = this.content.getWidth();
    var bgHeight = this.content.getHeight();
    switch (index) {
        case 0:
            this.image.setLeft(this.imageX);
            this.image.setTop(this.imageY);
            break;
        case 1:
            this.image.setLeft(this.imageX);
            this.image.setTop(this.imageY + (bgHeight - imageHeight) / 2);
            break;
        case 2:
            this.image.setLeft(this.imageX);
            this.image.setTop(this.imageY + (bgHeight - imageHeight));
            break;
        case 3:
            this.image.setLeft(this.imageX + (bgWidth - imageWidth));
            this.image.setTop(this.imageY);
            break;
        case 4:
            this.image.setLeft(this.imageX + (bgWidth - imageWidth));
            this.image.setTop(this.imageY + (bgHeight - imageHeight) / 2);
            break;
        case 5:
            this.image.setLeft(this.imageX + (bgWidth - imageWidth));
            this.image.setTop(this.imageY + (bgHeight - imageHeight));
            break;
        case 6:
            this.image.setLeft(this.imageX + (bgWidth - imageWidth) / 2);
            this.image.setTop(this.imageY);
            break;
            break;
        case 7:
            this.image.setLeft(this.imageX + (bgWidth - imageWidth) / 2);
            this.image.setTop(this.imageY + (bgHeight - imageHeight) / 2);
            break;
        case 8:
            this.image.setLeft(this.imageX + (bgWidth - imageWidth) / 2);
            this.image.setTop(this.imageY + (bgHeight - imageHeight));
            break;
    }
}
TextClass.prototype.readConfig = function (cfgXML) {
    if (this.changeAction == "true") {
        Author.current.currentList.item(this.changeID).setVisible(false);
        return this.change(cfgXML);
    }
    this.setProperties(cfgXML);
    this.addToBackground = (trim(cfgXML.getElementsByTagName("addToBackground")[0].childNodes[0].nodeValue).toLowerCase() == "true");
    if (this.addToBackground) {
        this.orginalListID = Author.current.currentListXML.attributes[1].nodeValue;
        Author.backgroundList.list.add(this.id, this);
        this.addToBackgroundAtElementPosition = Author.current.currentElementPosition;
    }
    this.setFx(cfgXML); //1.2 seconds
    return 0;
}
TextClass.prototype.setText = function (textHTML) {
    this.p.dom.innerText = replaceVariableNameWithValue(textHTML);
}
TextClass.prototype.setTop = function (y) {
    this.content.setStyle("top", y + "px");
}
TextClass.prototype.setLeft = function (x) {
    this.content.setStyle("left", x + "px");
}
TextClass.prototype.setWidth = function (width) {
    this.content.setWidth(width);
}
TextClass.prototype.setHeight = function (height) {
    this.content.setHeight(height);
}
TextClass.prototype.setVisible = function (visible) {
    this.visible = visible;
    //  alert(this.id +","+visible);
    if (this.changeByID != null) {
        Author.current.currentList.item(this.changeByID).setVisible(visible);
    }
    else {
        try {
            //alert(this.content +","+this.text);
            this.content.setVisible(visible);
            this.text.setVisible(visible);
        }
        catch (err) {
            //alert("setVisible:"+err.description);
        }
    }
}
TextClass.prototype.setStyle = function (CSSStyle) {
    this.content.applyStyles(CSSStyle);
}
TextClass.prototype.remove = function () {
    try {
        if (this.changeAction == "true") {
            Author.current.currentList.item(this.originalID).changeByID = null;
        }
        if (this.fxEffect != 0)
            this.content.stopFx();
        this.content.remove();
    }
    catch (err) {
    }
}
function ImageButtonClass(bgObject, cfgXML, o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.addToForeground = false;
    this.changedByVisibleAction = false;
    this.isPrecedent = false;
    this.objectType = "IMAGEBUTTONOBJECT";
    this.buttonType = trim(cfgXML.getElementsByTagName("buttonType")[0].childNodes[0].nodeValue);
    this.name = trim(cfgXML.getElementsByTagName("name")[0].childNodes[0].nodeValue);
    this.value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
    this.top = parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue));
    this.left = parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue));
    this.width = parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue));
    this.height = parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue));
    this.toggleBtn = false;
    this.mouseOutImage = trim(cfgXML.getElementsByTagName("mouseOutImage")[0].childNodes[0].nodeValue).toLowerCase();
    try {
        this.mouseOverImage = trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase();
    }
    catch (err) {
        this.mouseOverImage = this.mouseOutImage;
    }
    this.type = "unknow";
    this.click = "unknow";
    try {
        this.click = trim(cfgXML.getElementsByTagName("click")[0].childNodes[0].nodeValue);
    }
    catch (err) {
    }
    this.buttonType = parseInt(trim(cfgXML.getElementsByTagName("buttonClickType")[0].childNodes[0].nodeValue).toLowerCase());
    this.toggleBtn = (this.buttonType == 1);
    this.content = bgObject.createChild({
        tag: "div",
        style: "position:absolute;overflow:hidden"
    });
    var img = new Image();
    img.src = Author.resourcePath + eval(Ext.encode(this.mouseOutImage));
    img.src = Author.resourcePath + eval(Ext.encode(this.mouseOverImage));
    this.image = this.content.createChild({
        tag: "img",
        alt: '',
        style: "position:absolute;",
        src: Author.resourcePath + eval(Ext.encode(this.mouseOutImage)),
        width: this.width,
        height: this.height,
        containerID: this.content.id
    });
    this.content.set({
        "imageID": this.image.id
    });
    this.hasMouseOverResponse = trim(cfgXML.getElementsByTagName("hasMouseOverResponse")[0].childNodes[0].nodeValue).toLowerCase();
    this.mouseOverResponseValue = trim(cfgXML.getElementsByTagName("mouseOverResponseValue")[0].childNodes[0].nodeValue);
    this.content.set({
        "containerID": this.content.id,
        "toggleBtn": this.toggleBtn,
        "toggled": false,
        "name": this.name.toLowerCase(),
        "value": this.value,
        "mouseOverResponse": this.hasMouseOverResponse,
        "mouseOverResponseValue": this.mouseOverResponseValue
    });
    this.visible = true;
}
ImageButtonClass.prototype.zorder = function (index) {
    this.content.setStyle("z-index", index);
}
ImageButtonClass.prototype.checkPrecedence = function () {
    var listType = Author.current.currentListXML.attributes[0].nodeValue;
    if (listType == "INTERACTION") {
        Author.current.precedentObject = this.objectType;
        this.isPrecedent = true;
    }
}
ImageButtonClass.prototype.readConfig = function (cfgXML) {
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.content.setStyle("cursor", "pointer");
    this.setTop(parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue)));
    this.setLeft(parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue)));
    this.setWidth(parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue)));
    this.setHeight(parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue)));
    this.hide = trim(cfgXML.getElementsByTagName("hide")[0].childNodes[0].nodeValue).toLowerCase();
    try {
        this.addToForeground = trim(cfgXML.getElementsByTagName("addToForeground")[0].childNodes[0].nodeValue).toLowerCase() == "true";
    }
    catch (err) {
        this.addToForeground = false;
    }
    this.setMouseDownEvent(function (e) {
        e.stopEvent();
        var target = Ext.get(e.getTarget());
        var container = Ext.get(target.dom.containerID);
        if (container.dom.getAttribute("toggleBtn").toString() == true) {
            if (container.dom.getAttribute("toggled").toString() == true) {
                container.dom.setAttribute("toggled", false);
                try {
                    var elementType = Author.current.currentElementXML.attributes[0].nodeValue;
                    if (elementType == "MULTIPLECHOICE") {
                        Author.answers.multipleChoice.removeKey(container.dom.getAttribute("value").toUpperCase());
                    }
                }
                catch (err) {
                    //  alert("mouseDown::toggle=false::" + err);
                }
                try {
                    container.setStyle("color", trim(cfgXML.getElementsByTagName("mouseOutColor")[0].childNodes[0].nodeValue));
                }
                catch (err) {
                }
                try {
                    var img = new Image();
                    img.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOutImage")[0].childNodes[0].nodeValue).toLowerCase()));
                    Ext.get(container.dom.getAttribute("imageID").toString()).dom.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOutImage")[0].childNodes[0].nodeValue).toLowerCase()));
                }
                catch (err) {
                }
            }
            else {
                container.dom.setAttribute("toggled", true);
                try {
                    var elementType = Author.current.currentElementXML.attributes[0].nodeValue;
                    Author.variables.get(variableName('ANSWER')).setValue("ANSWER");
                    if (elementType == "MULTIPLECHOICE") {
                        Author.answers.multipleChoice.add(container.dom.getAttribute("value").toUpperCase(), container.dom.getAttribute("toggled").toString());
                    }
                }
                catch (err) {
                    // alert("mouseDown::toggle=true::" + err);
                }
                try {
                    container.setStyle("color", trim(cfgXML.getElementsByTagName("mouseOverColor")[0].childNodes[0].nodeValue));
                }
                catch (err) {
                }
                try {
                    var img = new Image();
                    img.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase()));
                    Ext.get(container.dom.getAttribute("imageID")).dom.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase()));
                }
                catch (err) {
                }
            }
        }
    });
    this.setMouseOverEvent(function (e) {
        e.stopEvent();
        var target = Ext.get(e.getTarget());
        try {
            var container = Ext.get(target.dom.getAttribute("containerID").toString());
            if (container.dom.getAttribute("toggleBtn").toString() == "false")
                Ext.get(container.dom.getAttribute("textID")).setStyle("color", trim(cfgXML.getElementsByTagName("mouseOverColor")[0].childNodes[0].nodeValue));
        }
        catch (err) {
        }
        try {
            if (container.dom.getAttribute("toggleBtn").toString() == "false") {
                var img = new Image();
                img.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase()));
                Ext.get(container.dom.getAttribute("imageID")).dom.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase()));
            }
        }
        catch (err) {
        }
        if (container.dom.getAttribute("mouseOverResponse").toString() == "true") {
            Author.variables.get(variableName('ANSWER')).setValue(container.dom.getAttribute("mouseOverResponseValue"));
            checkResponse();
        }
    });
    this.setMouseOutEvent(function (e) {
        e.stopEvent();
        var target = Ext.get(e.getTarget());
        var container = Ext.get(target.dom.getAttribute("containerID"));
        try {
            if (container.dom.getAttribute("toggleBtn").toString() == "false")
                Ext.get(container.dom.getAttribute("textID")).setStyle("color", trim(cfgXML.getElementsByTagName("mouseOutColor")[0].childNodes[0].nodeValue));
        }
        catch (err) {
        }
        try {
            if (container.dom.getAttribute("toggleBtn").toString() == "false") {
                var img = new Image();
                img.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOutImage")[0].childNodes[0].nodeValue).toLowerCase()));
                Ext.get(container.dom.getAttribute("imageID")).dom.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOutImage")[0].childNodes[0].nodeValue).toLowerCase()));
            }
        }
        catch (err) {
        }
    });
    if (this.click == "GOTOMENUOPTION") {
        this.setOnClickEvent(function (e) {
            e.stopEvent();
            // alert("GOTOMENUOPTION Clicked");
            Author.current.currentElementXML = null;
            Author.current.currentElement = null;
            Author.current.currentElementType = "";
            Author.current.currentElementResponses.clear();
            Author.current.currentElementPosition = -1;
            Author.current.currentListPosition = 0;
            Author.response.clear();
            Author.current.randomOptionsCollection.clear();
            Author.current.currentElementResponses.clear();
            Author.clearBackgroundObjects = true;
            var tempNode = Author.lessonNodes.nodes.get(nextOptionID);
            if (typeof(tempNode) != 'undefined' && tempNode.id.toString() == nextOptionID.toString()) {
                Author.current.currentNode = Author.lessonNodes.nodes.get(nextOptionID);
                Author.current.currentNode.endListShown = false;
            }
            Author.goingToSubMenu = true;
            showLessonNode();
        })
    }
    if (this.click == "SKIP") {
        this.setOnClickEvent(function (e) {
            e.stopEvent();
            Author.variables.get(variableName('SELECTEDVALUE')).setValue("SKIP");
            Author.variables.get(variableName('SELECTEDNAME')).setValue("SKIP");
            if (Author.pause != null && Author.pause.cancelType != 0) {
                Author.pause = null;
                //  pauseVideoes();
                window.clearTimeout(Author.actionTimer);
            }
            var listType = Author.current.currentListXML.attributes[0].nodeValue;
            if (listType == "INTRODUCTION") {
                var actions = Author.current.currentListXML.getElementsByTagName("action");
                Author.current.currentActionPosition = actions.length;
                showList();
                return;
            }
            else {
                if (Author.current.currentNode.type != "MENU") {
                    Author.current.currentElementXML = null;
                    Author.current.currentElement = null;
                    Author.current.currentElementType = "";
                    Author.current.currentElementResponses.clear();
                    Author.current.currentElementPosition++;
                    Author.response.clear();
                    showLessonNode();
                    return;
                }
            }
        })
    }
    if (this.click == "TOUPPERMENU") {
        this.setOnClickEvent(function (e) {
            // if (Author.waitingMedia) 
            // return;
            e.stopEvent();
            // alert("TOUPPERMENU Clicked");
            Author.variables.get(variableName('SELECTEDVALUE')).setValue("TOUPPERMENU");
            Author.variables.get(variableName('SELECTEDNAME')).setValue("TOUPPERMENU");
            while (Author.current.currentBgStack.getCount() > 0) {
                var bgObject = Author.current.currentBgStack.last();
                Author.current.currentBgStack.remove(bgObject);
                if (Author.current.currentBgStack.getCount() == 0) {
                    Author.backgroundObject.setBg(bgObject);
                }
            }
            //  Author.backgroundObject.setOriginal();
            Author.current.currentNode = Author.lessonNodes.nodes.get(getParentNode());
            Author.goingUpperMenu = true;
            Author.current.currentNode.endListShown = false;
            Author.current.currentElementXML = null;
            Author.current.currentElement = null;
            Author.current.currentElementType = "";
            Author.current.currentElementResponses.clear();
            Author.current.currentElementPosition = -1;
            Author.current.currentListPosition = 0;
            Author.response.clear();
            Author.current.currentElementResponses.clear();
            Author.clearBackgroundObjects = true;
            Author.current.randomOptionsCollection.clear();
            Author.backToMenu = true;
            showLessonNode();
        })
    }
    if (this.click == "TOMAINMENU") {
        this.setOnClickEvent(function (e) {
            //   if (Author.waitingMedia) 
            //  return;
            e.stopEvent();
            //  alert("TOMAINMENU Clicked");
            Author.variables.get(variableName('SELECTEDVALUE')).setValue("TOMAINMENU");
            Author.variables.get(variableName('SELECTEDNAME')).setValue("TOMAINMENU");
            Author.backgroundObject.setOriginal();
            do {
                Author.current.currentNode = Author.lessonNodes.nodes.get(getParentNode());
                Author.current.currentNode.endListShown = false;
                Author.goingUpperMenu = true;
            }
            while (Author.current.currentNode.parent != 0)
            Author.current.currentElementXML = null;
            Author.current.currentElement = null;
            Author.current.currentElementType = "";
            Author.current.currentElementResponses.clear();
            Author.current.currentElementPosition = -1;
            Author.current.currentListPosition = 0;
            Author.response.clear();
            Author.current.currentElementResponses.clear();
            Author.clearBackgroundObjects = true;
            Author.backToMenu = true;
            Author.current.randomOptionsCollection.clear();
            showLessonNode();
        })
    }
    if (this.click == "NEXT") {
        this.setOnClickEvent(function (e) {
            if (Author.lessonFinished) {
                return;
            }
            // if (Author.waitingMedia)
            //  return;
            e.stopEvent();
            Author.variables.get(variableName('SELECTEDVALUE')).setValue("NEXT");
            Author.variables.get(variableName('SELECTEDNAME')).setValue("NEXT");
            //  alert("Next Clicked");
            if (Author.pause != null) {//&& Author.pause.cancelType != 0
                Author.pause = null;
                // pauseVideoes();
                window.clearTimeout(Author.actionTimer);
                showList();
            }
            else
            if (Author.responseEnd && Author.lessonFlow == "continue") {
                Author.responseEnd = false;
                showLessonNode();
            }
            else
            if (Author.current.currentListXML.attributes[0].nodeValue == "INTERACTION" || Author.lessonFlow == "repeat") {
                makeAnswerVariable();
                if (Author.variables.get(variableName('ANSWER')).getValue() == null || Author.variables.get(variableName('ANSWER')).getValue() == "")
                    Author.variables.get(variableName('ANSWER')).setValue("NEXT");
                checkResponse();
            }
        })
    }
    if (this.click == "BACK") {
        this.setOnClickEvent(function (e) {
            // if (Author.waitingMedia) 
            //  return;
            e.stopEvent();
            //  alert("BACK Clicked");
            Author.goingBack = true;
            Author.variables.get(variableName('SELECTEDVALUE')).setValue("BACK");
            Author.variables.get(variableName('SELECTEDNAME')).setValue("BACK");
            if (Author.pause != null && Author.pause.cancelType != 0) {
                Author.pause = null;
                window.clearTimeout(Author.actionTimer);
            }
            if (Author.current.currentElementXML != null) {
                Author.current.currentElementPosition -= 1
                Author.current.currentElementXML = null;
                Author.current.currentElement = null;
                if (Author.current.currentElementPosition < 0) {
                    Author.current.currentNode = Author.lessonNodes.nodes.get(getParentNode());
                    Author.goingUpperMenu = true;
                    Author.current.currentNode.endListShown = false;
                    while (Author.current.currentBgStack.getCount() > 0) {
                        var bgObject = Author.current.currentBgStack.last();
                        Author.current.currentBgStack.remove(bgObject);
                        if (Author.current.currentBgStack.getCount() == 0) {
                            Author.backgroundObject.setBg(bgObject);
                        }
                    }
                    // Author.backgroundObject.setOriginal();
                    Author.current.currentElementXML = null;
                    Author.current.currentElement = null;
                    Author.current.currentElementType = "";
                    Author.current.currentElementResponses.clear();
                    Author.current.currentElementPosition = -1;
                    Author.current.currentListPosition = 0;
                    Author.clearBackgroundObjects = true;
                    Author.backToMenu = true;
                    Author.current.randomOptionsCollection.clear();
                }
            }
            else {
                Author.current.currentListPosition -= 1;
                if (Author.current.currentListPosition < 0) {
                    if (getParentNode() == 0)
                        return;
                    Author.current.currentNode = Author.lessonNodes.nodes.get(getParentNode());
                    Author.goingUpperMenu = true;
                    Author.current.currentNode.endListShown = false;
                    Author.current.currentListPosition = 0;
                    Author.clearBackgroundObjects = true;
                    Author.current.currentElementResponses.clear();
                }
            }
            Author.responseEnd = true;
            Author.inResponse = false;
            Author.response.clear();
            showLessonNode();
            return;
        })
    }
    if (this.click == "SYNCHONOFF") {
        this.setOnClickEvent(function (e) {
            if (Author.inResponse || Author.lessonFinished)
                return;
            Author.isSynch = !Author.isSynch;
            if (Author.isSynch) {
                e.stopEvent();
            }
            return;
        })
    }
    if (this.click == "AUDIOONOFF") {
        this.setOnClickEvent(function (e) {
            if (Author.inResponse || Author.lessonFinished)
                return;
            e.stopEvent();
            Author.isAudioOn = !Author.isAudioOn;
            if (!Author.isAudioOn) {
                if (Ext.isIE && !Author.useFlashInIE) {
                    Author.mediaList.eachKey(function (key, object) {
                        if (object.objectType == "SOUNDOBJECT") {
                            // object.mediaObject.dom.controls.stop();
                            object.mediaObject.dom.settings.mute = true;
                        }
                    });
                }
            }
            return;
        })
    }
    if (this.click == "TORESPONSE") {
        this.setOnClickEvent(function (e) {
            if (Author.response.removeType == "BEFORENEXT") {
                stopCurrentResponse();
            }
            else {
                if (Author.inResponse || Author.lessonFinished)
                    return;
            }
            e.stopEvent();
            // alert("toResponse");
            var target = Ext.get(e.getTarget());
            var container = Ext.get(target.dom.getAttribute("containerID"));
            var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
            Author.variables.get(variableName('SELECTEDVALUE')).setValue(value);
            Author.variables.get(variableName('SELECTEDNAME')).setValue(container.dom.getAttribute("name"));
            //alert(value+", "+ container.dom.getAttribute("name"));
            //var variable = trim(cfgXML.getElementsByTagName("variable")[0].childNodes[0].nodeValue);
            //var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
            Author.variables.get(variableName('ANSWER')).setValue(value);
            checkResponse();
            return;
        })
    }
    if (this.click == "EXITLESSON") {
        this.setOnClickEvent(function (e) {
            e.stopEvent();
            if (Author.pause != null && Author.pause.cancelType != 0) {
                Author.pause = null;
                window.clearTimeout(Author.actionTimer);
            }
            if (Author.exitConfirm) {
                Ext.MessageBox.confirm('Exit the lesson', 'Do you really want to exit this lesson?', function (btn) {
                    if (btn == "yes") {
                        endLesson();
                    }
                });
            }
            else {
                endLesson();
            }
        })
    }
    if (this.click == "CHECKRESPONSE" && this.toggleBtn == false) {
        this.setOnClickEvent(function (e) {
            //  if (Author.waitingMedia) 
            //   return;
            if (Author.response.removeType == "BEFORENEXT") {
                stopCurrentResponse();
            }
            else {
                if (Author.inResponse || Author.lessonFinished)
                    return;
            }
            e.stopEvent();
            var target = Ext.get(e.getTarget());
            var container = Ext.get(target.dom.getAttribute("containerID"));
            var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
            Author.variables.get(variableName('SELECTEDVALUE')).setValue(value);
            Author.variables.get(variableName('SELECTEDNAME')).setValue(container.dom.getAttribute("name"));
            try {
                var elementType = Author.current.currentElementXML.attributes[0].nodeValue;
                if (elementType == "MULTIPLECHOICE") {
                    //   var target = Ext.get(e.getTarget());
                    //  var container = Ext.get(target.dom.containerID);
                    //  var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
                    Author.variables.get(variableName('ANSWER')).setValue(value);
                    var regex = /^[A|B|C|D|E|F|G|H]{1}$/;
                    var answer = container.dom.getAttribute("value").toUpperCase();
                    if (regex.test(answer) == true) {
                        Author.answers.multipleChoice.add(container.dom.getAttribute("value").toUpperCase(), container.dom.getAttribute("toggled"));
                    }
                    checkResponse();
                }
                else
                if (elementType == "YESNO") {
                    //  var target = Ext.get(e.getTarget());
                    //   var container = Ext.get(target.dom.containerID);
                    //  var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
                    Author.variables.get(variableName('ANSWER')).setValue(value);
                    Author.answers.yesNo = value.toLowerCase();
                    checkResponse();
                }
                else
                if (elementType == "TRUEFALSE") {
                    Author.variables.get(variableName('ANSWER')).setValue(value);
                    Author.answers.trueFalse = value.toLowerCase();
                    checkResponse();
                }
                else {
                    // var variable = trim(cfgXML.getElementsByTagName("variable")[0].childNodes[0].nodeValue);
                    //  var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
                    Author.variables.get(variableName('ANSWER')).setValue(value);
                    checkResponse();
                }
                return;
            }
            catch (err) {
                //  alert("mouseDown::toggle=true::" + err);
            }
            var variable = trim(cfgXML.getElementsByTagName("variable")[0].childNodes[0].nodeValue);
            var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
            Author.variables.get(variableName('ANSWER')).setValue(value);
            checkResponse();
            return;
        })
    }
    if (this.addToForeground == false && this.toggleBtn)
        this.checkPrecedence();
    if (this.addToForeground == true) {
        this.setVisible(this.hide == "false");
        Author.foregroundList.list.add(this.id, this);
        this.addToForegroundAtElementPosition = Author.current.currentElementPosition;
        this.zorder(100);
    }
    this.key1 = "none";
    this.key2 = "none";
    try {
        this.key1 = trim(cfgXML.getElementsByTagName("key1")[0].childNodes[0].nodeValue);
        this.key2 = trim(cfgXML.getElementsByTagName("key2")[0].childNodes[0].nodeValue);
        if (this.key1 != "none")
            Author.actionKeyMap.add(this.key1, this);
        if (this.key2 != "none")
            Author.actionKeyMap.add(this.key2, this);
    }
    catch (err) {
    }
    return 0;
}
ImageButtonClass.prototype.setTop = function (y) {
    this.content.setStyle("top", y + "px");
}
ImageButtonClass.prototype.setLeft = function (x) {
    this.content.setStyle("left", x + "px");
}
ImageButtonClass.prototype.setWidth = function (width) {
    this.width = width;
    this.content.setWidth(width);
}
ImageButtonClass.prototype.setHeight = function (height) {
    this.height = height;
    this.content.setHeight(height);
}
ImageButtonClass.prototype.setVisible = function (visible) {
    this.visible = visible;
    this.content.setVisible(visible);
}
ImageButtonClass.prototype.setStyle = function (CSSStyle) {
    this.content.applyStyles(CSSStyle);
}
ImageButtonClass.prototype.setMouseDownEvent = function (mouseDownEventHandler) {
    this.content.on("mousedown", eval(mouseDownEventHandler));
}
ImageButtonClass.prototype.setMouseUpEvent = function (mouseUpEventHandler) {
    this.content.on("mouseup", eval(mouseUpEventHandler));
}
ImageButtonClass.prototype.setMouseOverEvent = function (mouseOverEventHandler) {
    this.content.on("mouseover", eval(mouseOverEventHandler));
}
ImageButtonClass.prototype.setMouseOutEvent = function (mouseOutEventHandler) {
    this.content.on("mouseout", eval(mouseOutEventHandler));
}
ImageButtonClass.prototype.setOnClickEvent = function (onClickEventHandler) {
    this.content.on("click", eval(onClickEventHandler));
}
ImageButtonClass.prototype.remove = function () {
    if (this.key1 != "none")
        Author.actionKeyMap.removeKey(this.key1);
    if (this.key2 != "none")
        Author.actionKeyMap.removeKey(this.key2);
    this.content.remove();
}
/**
 * CustomButtonClass
 * @param {Object} bgObject
 */
function CustomButtonClass(bgObject, cfgXML, o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    try {
        this.addToForeground = trim(cfgXML.getElementsByTagName("addToForeground")[0].childNodes[0].nodeValue).toLowerCase() == "true";
    }
    catch (err) {
        this.addToForeground = false;
    }
    //alert(this.addToForeground);
    this.addToBackground = false;
    this.changedByVisibleAction = false;
    this.isPrecedent = false;
    this.textPosition = trim(cfgXML.getElementsByTagName("textPosition")[0].childNodes[0].nodeValue);
    this.objectType = "CUSTOMBUTTONOBJECT";
    this.buttonType = trim(cfgXML.getElementsByTagName("buttonType")[0].childNodes[0].nodeValue);
    this.name = trim(cfgXML.getElementsByTagName("name")[0].childNodes[0].nodeValue);
    this.value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
    this.borderWidth = 0;
    this.top = parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue));
    this.left = parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue));
    this.width = parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue));
    this.height = parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue));
    this.toggleBtn = false;
    this.cycle = trim(cfgXML.getElementsByTagName("cycle")[0].childNodes[0].nodeValue);
    this.textX = trim(cfgXML.getElementsByTagName("textX")[0].childNodes[0].nodeValue);
    this.textY = trim(cfgXML.getElementsByTagName("textY")[0].childNodes[0].nodeValue);
    this.responseToClick = trim(cfgXML.getElementsByTagName("responseToClick")[0].childNodes[0].nodeValue).toLowerCase() == "true";
    try {
        this.tickColor = trim(cfgXML.getElementsByTagName("tickColor")[0].childNodes[0].nodeValue).toLowerCase();
        if (this.tickColor == "none") {
            this.tickColor = trim(cfgXML.getElementsByTagName("mouseOutColor")[0].childNodes[0].nodeValue);
        }
    }
    catch (err) {
        this.tickColor = trim(cfgXML.getElementsByTagName("mouseOutColor")[0].childNodes[0].nodeValue);
    }
    var tempValue = replaceVariableNameWithValue(this.value);
    var toggleStatus = false;
    this.pictureDrawMode = trim(cfgXML.getElementsByTagName("pictureDrawMode")[0].childNodes[0].nodeValue);
    this.pictureX = trim(cfgXML.getElementsByTagName("pictureX")[0].childNodes[0].nodeValue);
    this.pictureY = trim(cfgXML.getElementsByTagName("pictureY")[0].childNodes[0].nodeValue);
    this.textMoveX = trim(cfgXML.getElementsByTagName("textMoveX")[0].childNodes[0].nodeValue);
    this.textMoveY = trim(cfgXML.getElementsByTagName("textMoveY")[0].childNodes[0].nodeValue);
    this.imageMoveX = trim(cfgXML.getElementsByTagName("imageMoveX")[0].childNodes[0].nodeValue);
    this.imageMoveY = trim(cfgXML.getElementsByTagName("imageMoveY")[0].childNodes[0].nodeValue);
    this.framesCount = cfgXML.getElementsByTagName("frames")[0].childNodes.length;
    this.frames = new Array(this.framesCount);
    this.iWidthes = new Array(this.framesCount);
    this.iHeights = new Array(this.framesCount);
    for (var i = 0; i < this.framesCount; i++) {
        this.frames[i] = trim(cfgXML.getElementsByTagName("frames")[0].childNodes[i].childNodes[0].nodeValue).toLowerCase();
        this.iWidthes[i] = parseInt(trim(cfgXML.getElementsByTagName("frames")[0].childNodes[i].attributes[0].nodeValue).toLowerCase());
        this.iHeights[i] = parseInt(trim(cfgXML.getElementsByTagName("frames")[0].childNodes[i].attributes[1].nodeValue).toLowerCase());
    }
    this.type = "unknow";
    this.click = "unknow";
    try {
        this.click = trim(cfgXML.getElementsByTagName("click")[0].childNodes[0].nodeValue);
    }
    catch (err) {
    }
    this.nextOptionID = null;
    this.theOptionFinished = false;
    if (this.click == "GOTOMENUOPTION") {
        try {
            this.nextOptionID = parseInt(trim(cfgXML.getElementsByTagName("nextLessonNode")[0].childNodes[0].nodeValue));
            var theOption = Author.lessonNodes.nodes.get(this.nextOptionID);
            if (typeof(theOption) == 'undefined') {
                this.theOptionFinished = true;
            }
            else {
                this.theOptionFinished = theOption.isNodeFinished();
            }
        }
        catch (err) {
        }
    }
    //alert(this.name + ", "+ this.theOptionFinished);
    if (this.cycle == "6" || this.cycle == "7") {
        this.toggleBtn = true;
    }
    this.content = bgObject.createChild({
        tag: "div",
        style: "position:absolute;overflow:hidden;"
    });
    // alert(this.pictureDrawMode+"\n"+this.width+" X "+this.height);
    if (this.framesCount > 0) {
        var img = new Image();
        var imageName = "";
        try {
            img.src = Author.resourcePath + this.frames[0];
            imageName = Author.resourcePath + this.frames[0];
            this.mouseOutImageSrc = trim(cfgXML.getElementsByTagName("mouseOutImage")[0].childNodes[0].nodeValue).toLowerCase();
            this.mouseOverImageSrc = trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase();
        }
        catch (err) {
            this.mouseOutImageSrc = "";
            this.mouseOverImageSrc = "";
        }
        if (this.click == "AUDIOONOFF") {
            try {
                var mouseOutImage = trim(cfgXML.getElementsByTagName("mouseOutImage")[0].childNodes[0].nodeValue).toLowerCase();
                var mouseOverImage = trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase();
                imageName = Author.resourcePath + (Author.isAudioOn ? mouseOutImage : mouseOverImage);
            }
            catch (err) {
            }
        }
        if (this.click == "SYNCHONOFF") {
            try {
                var mouseOutImage = trim(cfgXML.getElementsByTagName("mouseOutImage")[0].childNodes[0].nodeValue).toLowerCase();
                var mouseOverImage = trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase();
                imageName = Author.resourcePath + (Author.isSynch ? mouseOutImage : mouseOverImage);
            }
            catch (err) {
            }
        }
        if (this.toggleBtn) {
            var tempV = tempValue.toString().toLowerCase();
            if (tempV == "false" || tempV == "0" || this.value.toLowerCase() == tempV || tempV == "") {
                toggleStatus = false;
            }
            else {
                toggleStatus = true;
            }
            try {
                var mouseOutImage = trim(cfgXML.getElementsByTagName("mouseOutImage")[0].childNodes[0].nodeValue).toLowerCase();
                var mouseOverImage = trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase();
                imageName = Author.resourcePath + (!toggleStatus ? mouseOutImage : mouseOverImage);
            }
            catch (err) {
            }
        }
        var menuTickImage = "none";
        try {
            menuTickImage = trim(cfgXML.getElementsByTagName("menuTickImage")[0].childNodes[0].nodeValue).toLowerCase();
        }
        catch (err) {
        }
        if (this.theOptionFinished && menuTickImage != "none") {
            imageName = Author.resourcePath + menuTickImage;
        }
        this.image = this.content.createChild({
            tag: "img",
            alt: '',
            style: "position:absolute;",
            width: (this.pictureDrawMode == "2") ? this.width : this.iWidthes[0],
            height: (this.pictureDrawMode == "2") ? this.height : this.iHeights[0],
            src: imageName,
            containerID: this.content.id
        });
        this.image.dom.src = imageName;
        if (this.pictureDrawMode == "2")
            this.setImagePosition(this.width, this.height);
        else
            this.setImagePosition(this.iWidthes[0], this.iHeights[0]);
        this.content.set({
            "imageID": this.image.id
        });
    }
    else {
        this.iWidthes[0] = 0;
        this.iHeights[0] = 0;
    }
    //  else {
    try {
        this.backColor = trim(cfgXML.getElementsByTagName("backColor")[0].childNodes[0].nodeValue);
        this.borderWidth = parseInt(trim(cfgXML.getElementsByTagName("borderWidth")[0].childNodes[0].nodeValue));
    }
    catch (err) {
        this.backColor = "#ccc";
        this.borderWidth = 0;
    }
    // if (this.framesCount > 0 && (this.imageMoveX > 0 || this.imageMoveY > 0)) {
    //  this.content.setStyle("background-color", "transparent");
    // }
    // else {
    this.content.setStyle("background-color", this.backColor);
    // }
    this.content.setStyle("border-width", this.borderWidth + "px");
    this.content.setStyle("border-color", this.backColor);
    this.content.setStyle("border-style", "outset");
    this.content.setStyle("cursor", "pointer");
    this.setTop(this.top);
    this.setLeft(this.left);
    this.setWidth(this.width);
    this.setHeight(this.height);
    // }
    var x, y;
    var width = this.width;
    var height = this.height;
    var textStyle = "font-family:" + trim(cfgXML.getElementsByTagName("font-family")[0].childNodes[0].nodeValue) + ";";
    textStyle = textStyle + "font-size:" + trim(cfgXML.getElementsByTagName("font-size")[0].childNodes[0].nodeValue) + "pt;";
    textStyle = textStyle + "font-style:" + trim(cfgXML.getElementsByTagName("font-style")[0].childNodes[0].nodeValue) + ";";
    textStyle = textStyle + "font-weight:" + trim(cfgXML.getElementsByTagName("font-weight")[0].childNodes[0].nodeValue) + ";";
    textStyle = textStyle + "color:" + (this.theOptionFinished ? this.tickColor : trim(cfgXML.getElementsByTagName("mouseOutColor")[0].childNodes[0].nodeValue)) + ";";
    //  alert(textStyle);
    switch (this.textPosition) {
        case "left":
            width = this.width - this.iWidthes[0];
            height = this.height;
            x = 0;
            y = 0;
            break;
        case "right":
            width = this.width - this.iWidthes[0];
            height = this.height;
            x = this.iWidthes[0];
            y = 0;
            break;
        case "top":
            x = 0;
            y = 0;
            width = this.width;
            height = this.height - this.iHeights[0];
            break;
        case "down":
            y = this.iHeights[0];
            x = 0;
            width = this.width;
            height = this.height - this.iHeights[0];
            break;
        case "center":
            y = 0;
            x = 0;
            width = this.width;
            height = this.height;
            break;
    }
    width = width - this.borderWidth * 2;
    height = height - this.borderWidth * 2;
    this.text = this.content.createChild({
        tag: "div",
        style: "position:absolute;left:" + x + "px;top:" + y + "px;width:" + (width) + "px;height:" + (height) + "px;",
        containerID: this.content.id
    });
    try {
        this.textStr = (cfgXML.getElementsByTagName("text")[0].childNodes[0].nodeValue);
        if (this.click == "AUDIOONOFF") {
            if (this.textStr.indexOf("|") >= 0) {
                var caps = this.textStr.split("|");
                this.textStr = (Author.isAudioOn ? caps[0] : caps[1]);
            }
        }
        if (this.click == "SYNCHONOFF") {
            if (this.textStr.indexOf("|") >= 0) {
                var caps = this.textStr.split("|");
                this.textStr = (Author.isSynch ? caps[0] : caps[1]);
            }
        }
    }
    catch (err) {
        this.textStr = "";
    }
    this.textStr = this.textStr.replace(/\&\&/g, "_*_");
    this.textStr = this.textStr.replace(/\&(.){1}/g, function (name, variableName) {
        return "<font style='text-decoration: underline' [#CONTAINERID#]>" + variableName + "</font>";
    });
    this.textStr = this.textStr.replace("[#CONTAINERID#]", "containerID='" + this.content.id + "'");
    this.textStr = this.textStr.replace(/_\*_/g, "&");
    this.textStr = this.textStr.replace(/ {2}/g, " &nbsp;");
    /*
     this.textStr = this.textStr.replace(/( {2,})/g, function(name, variableName){
     return name.replace(/ /g, "&nbsp;");
     });
     */
    var txtalign = "left";
    if (this.textX > 45)
        txtalign = "center"
    if (this.textX > 90)
        txtalign = "right"
    textStyle = textStyle + "text-align:" + txtalign + ";";
    this.p = this.text.createChild({
        tag: "div",
        style: "position:absolute;" + textStyle + ";", // border-style:solid;border-width:2px",
        html: this.textStr,
        containerID: this.content.id
    });
    //alert(width+","+this.p.getWidth() +","+ this.textX );
    this.p.setLeft((width - this.p.getWidth()) * this.textX / 100);
    this.p.setTop((height - this.p.getHeight()) * this.textY / 100);
    this.p.setHeight(this.p.getHeight());
    // this.p.setWidth(this.width);
    this.hasMouseOverResponse = trim(cfgXML.getElementsByTagName("hasMouseOverResponse")[0].childNodes[0].nodeValue).toLowerCase();
    this.mouseOverResponseValue = trim(cfgXML.getElementsByTagName("mouseOverResponseValue")[0].childNodes[0].nodeValue);
    try {
        this.changeMouseOverImage = trim(cfgXML.getElementsByTagName("changeMouseOverImage")[0].childNodes[0].nodeValue);
        this.changeMouseDownImage = trim(cfgXML.getElementsByTagName("changeMouseDownImage")[0].childNodes[0].nodeValue).toLowerCase();
    }
    catch (err) {
        this.changeMouseOverImage = "0";
        this.changeMouseDownImage = "true";
    }
    try {
        this.resetStr = trim(cfgXML.getElementsByTagName("reset")[0].childNodes[0].nodeValue);
    }
    catch (err) {
        this.resetStr = "[NULL]";
    }
    this.content.set({
        "textID": this.p.id,
        "imageID": (this.framesCount > 0 ? this.image.id : 0),
        "containerID": this.content.id,
        "toggleBtn": this.toggleBtn.toString(),
        "toggled": toggleStatus.toString().toLowerCase(),
        "name": this.name.toLowerCase(),
        "value": tempValue,
        "mouseOverResponse": this.hasMouseOverResponse,
        "mouseOverResponseValue": this.mouseOverResponseValue,
        "optionFinished": this.theOptionFinished,
        "resetStr": this.resetStr,
        "textMoveX": this.textMoveX,
        "textMoveY": this.textMoveY,
        "imageMoveX": this.imageMoveX,
        "imageMoveY": this.imageMoveY,
        "responseToClick": this.responseToClick,
        "clickHandler": this.click,
        "mouseDownImage": this.changeMouseDownImage,
        "mouseOverImage": this.changeMouseOverImage,
        "mouseOutImageSrc": this.mouseOutImageSrc,
        "mouseOverImageSrc": this.mouseOverImageSrc,
        "preventMO": "false"
    });
    try {
        this.feedBackText = trim(cfgXML.getElementsByTagName("feedBackText")[0].childNodes[0].nodeValue);
    }
    catch (err) {
        this.feedBackText = "NOTOOLTIP";
        this.feedBackDelay = 0;
    }
    if (this.feedBackText != "NOTOOLTIP") {
        this.feedBackDelay = parseFloat(trim(cfgXML.getElementsByTagName("feedBackDelay")[0].childNodes[0].nodeValue));
        var screenWidth = Ext.lib.Dom.getViewWidth();
        var screenHeight = Ext.lib.Dom.getViewHeight();
        var xy = this.content.getXY();
        var maxWidth = Math.min(280, (screenWidth - xy[0] - 25));
        var tWidth = Math.min(maxWidth, this.feedBackText.length * 8);
        //var maxHeight=(screenHeight-xy[1]-25);
        this.toolTip = new Ext.ToolTip({
            target: this.content.dom.id,
            shadow: 'drop',
            showDelay: this.feedBackDelay * 1000,
            dismissDelay: 0,
            mouseOffset: [0, -15],
            //anchorToTarget:true,
            maxWidth: maxWidth,
            minWidth: 60,
            //maxHeight:maxHeight,
            trackMouse: true,
            width: tWidth,
            bodyStyle: "text-align:" + ((tWidth < maxWidth) ? "center" : "left"),
            html: this.feedBackText,
            listeners: {
                'show': function (tip) {
                    if (Ext.get(tip.initialConfig.target) == null) {
                        tip.hide();
                    }
                }
            }
        });
    }
    //  alert(this.name + ", "+ this.theOptionFinished);
    this.visible = true;
}
CustomButtonClass.prototype.setImagePosition = function (iWidth, iHeight) {
    var x = (this.width - iWidth) * this.pictureX / 100;
    var y = (this.height - iHeight) * this.pictureY / 100;
    switch (this.textPosition) {
        case "left":
            x = this.width - iWidth;
            break;
        case "right":
            x = 0;
            break;
        case "top":
            y = this.height - iHeight;
            break;
        case "down":
            y = 0;
            break;
    }
    this.image.setLeft(x);
    this.image.setTop(y);
}
CustomButtonClass.prototype.zorder = function (index) {
    this.content.setStyle("z-index", index);
}
CustomButtonClass.prototype.checkPrecedence = function () {
    var listType = Author.current.currentListXML.attributes[0].nodeValue;
    if (listType == "INTERACTION") {
        Author.current.precedentObject = this.objectType;
        this.isPrecedent = true;
    }
}
CustomButtonClass.prototype.readConfig = function (cfgXML) {
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.hide = trim(cfgXML.getElementsByTagName("hide")[0].childNodes[0].nodeValue).toLowerCase();
    this.setMouseDownEvent(function (e) {
        e.stopEvent();
        var target = Ext.get(e.getTarget());
        //<label class=" x-box-item" id="audioLabel" style="top: 0px; left: 231px;">
        var container = Ext.get(target.dom.getAttribute("containerID"));
        var imageTagID = container.dom.getAttribute("imageID");
        if (imageTagID.toString() != "0") {
            var imageDiv = Ext.get(imageTagID);
            var imX = parseInt(container.dom.getAttribute("imageMoveX"));
            var imY = parseInt(container.dom.getAttribute("imageMoveY"));
            imageDiv.applyStyles("margin-left:" + imX + "px;margin-top:" + imY + "px");
        }
        // mouse down image
        var mouseDownImage = (container.dom.getAttribute("mouseDownImage").toLowerCase() == "true");
        if (mouseDownImage) {
            try {
                if (container.dom.getAttribute("toggleBtn") == "false") {
                    var img = new Image();
                    img.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase()));
                    Ext.get(container.dom.getAttribute("imageID")).dom.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase()));
                }
            }
            catch (err) {
                //alert(err.description);
            }
        }
        else {
            var optionFinished = container.dom.getAttribute("optionFinished").toString() == "true";
            try {
                if (container.dom.getAttribute("toggleBtn") == "false") {
                    var menuTickImage = "none";
                    try {
                        menuTickImage = trim(cfgXML.getElementsByTagName("menuTickImage")[0].childNodes[0].nodeValue).toLowerCase();
                    }
                    catch (err) {
                    }
                    var imgSrc = trim(cfgXML.getElementsByTagName("mouseOutImage")[0].childNodes[0].nodeValue).toLowerCase();
                    if (optionFinished && menuTickImage != "none") {
                        imgSrc = menuTickImage;
                    }
                    //alert(imgSrc);
                    Ext.get(container.dom.getAttribute("imageID")).dom.src = eval(Ext.encode(Author.resourcePath + imgSrc));
                }
            }
            catch (err) {
                //alert(err.description);
            }
        }
        var textDiv = Ext.get(container.dom.getAttribute("textID"));
        var tmX = parseInt(container.dom.getAttribute("textMoveX"));
        var tmY = parseInt(container.dom.getAttribute("textMoveY"));
        textDiv.applyStyles("margin-left:" + tmX + "px;margin-top:" + tmY + "px");
        if (container.dom.getAttribute("toggleBtn").toString() == "true") {
            if (container.dom.getAttribute("toggled").toString() == "true") {
                container.dom.setAttribute("toggled", "false");
                try {
                    var elementType = Author.current.currentElementXML.attributes[0].nodeValue;
                    if (elementType == "MULTIPLECHOICE") {
                        Author.answers.multipleChoice.removeKey(container.dom.getAttribute("value").toUpperCase());
                    }
                }
                catch (err) {
                    //  alert("mouseDown::toggle=false::" + err);
                }
                try {
                    container.setStyle("color", trim(cfgXML.getElementsByTagName("mouseOutColor")[0].childNodes[0].nodeValue));
                }
                catch (err) {
                }
                try {
                    var img = new Image();
                    img.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOutImage")[0].childNodes[0].nodeValue).toLowerCase()));
                    Ext.get(container.dom.getAttribute("imageID")).dom.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOutImage")[0].childNodes[0].nodeValue).toLowerCase()));
                }
                catch (err) {
                }
            }
            else {
                if (container.dom.getAttribute("resetStr") != "[NULL]") {
                    for (var index = Author.interactionList.startIndex; index <= Author.interactionList.endIndex; index++) {
                        var action = Author.current.currentList.itemAt(index);
                        if (action.objectType == "CUSTOMBUTTONOBJECT") {
                            //alert(action.name + " VS " + container.dom.getAttribute("resetStr") + " : " + (action.name.indexOf(container.dom.getAttribute("resetStr")) >= 0));
                            if (action.name.toLowerCase().indexOf(container.dom.getAttribute("resetStr").toLowerCase()) >= 0) {
                                action.content.dom.setAttribute("toggled", "false");
                                try {
                                    action.image.dom.src = eval(Ext.encode(Author.resourcePath + action.mouseOutImageSrc).toLowerCase());
                                }
                                catch (err) {
                                }
                                if (elementType == "MULTIPLECHOICE") {
                                    Author.answers.multipleChoice.removeKey(action.container.dom.getAttribute("value").toUpperCase());
                                }
                            }
                        }
                    }
                }
                container.dom.setAttribute("toggled", "true");
                try {
                    var elementType = Author.current.currentElementXML.attributes[0].nodeValue;
                    Author.variables.get(variableName('ANSWER')).setValue("ANSWER");
                    if (elementType == "MULTIPLECHOICE") {
                        Author.answers.multipleChoice.add(container.dom.getAttribute("value").toUpperCase(), container.dom.getAttribute("toggled"));
                    }
                }
                catch (err) {
                    //   alert("mouseDown::toggle=true::" + err);
                }
                try {
                    container.setStyle("color", trim(cfgXML.getElementsByTagName("mouseOverColor")[0].childNodes[0].nodeValue));
                }
                catch (err) {
                }
                try {
                    var img = new Image();
                    img.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase()));
                    Ext.get(container.dom.getAttribute("imageID")).dom.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase()));
                }
                catch (err) {
                }
            }
            var clickHdl = container.dom.getAttribute("clickHandler")
            var responseToClick = container.dom.getAttribute("responseToClick")
            // alert(clickHdl +"\n"+responseToClick+"\n"+((clickHdl == "CHECKRESPONSE") && responseToClick));
            if ((clickHdl == "CHECKRESPONSE") && (responseToClick.toString().toLowerCase() == 'true')) {
                var value = container.dom.getAttribute("value");
                // alert("mousedown:"+value);
                Author.variables.get(variableName('SELECTEDVALUE')).setValue(value);
                Author.variables.get(variableName('SELECTEDNAME')).setValue(container.dom.getAttribute("name"));
                try {
                    var elementType = Author.current.currentElementXML.attributes[0].nodeValue;
                    if (elementType == "MULTIPLECHOICE") {
                        //   var target = Ext.get(e.getTarget());
                        //  var container = Ext.get(target.dom.containerID);
                        //  var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
                        Author.variables.get(variableName('ANSWER')).setValue(value);
                        var regex = /^[A|B|C|D|E|F|G|H]{1}$/;
                        var answer = container.dom.getAttribute("value").toUpperCase();
                        if (regex.test(answer) == true) {
                            Author.answers.multipleChoice.add(container.dom.getAttribute("value").toUpperCase(), container.dom.getAttribute("toggled"));
                        }
                        checkResponse();
                    }
                    else
                    if (elementType == "YESNO") {
                        //  var target = Ext.get(e.getTarget());
                        //   var container = Ext.get(target.dom.containerID);
                        //  var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
                        Author.variables.get(variableName('ANSWER')).setValue(value);
                        Author.answers.yesNo = value.toLowerCase();
                        checkResponse();
                    }
                    else
                    if (elementType == "TRUEFALSE") {
                        Author.variables.get(variableName('ANSWER')).setValue(value);
                        Author.answers.trueFalse = value.toLowerCase();
                        checkResponse();
                    }
                    else {
                        // var variable = trim(cfgXML.getElementsByTagName("variable")[0].childNodes[0].nodeValue);
                        //  var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
                        Author.variables.get(variableName('ANSWER')).setValue(value);
                        //alert(Author.variables.get(variableName('ANSWER')).getValue());
                        checkResponse();
                    }
                    return;
                }
                catch (err) {
                    //   alert("mouseDown::toggle=true::" + err);
                }
                var variable = trim(cfgXML.getElementsByTagName("variable")[0].childNodes[0].nodeValue);
                var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
                //alert(value);
                Author.variables.get(variableName('ANSWER')).setValue(value);
                checkResponse();
                return;
            }
        }
    });
    this.setMouseUpEvent(function (e) {
        e.preventDefault();
        e.stopEvent();//
        var target = Ext.get(e.getTarget());
        var container = Ext.get(target.dom.containerID);
        if (container == null)
            return;
        var textDiv = Ext.get(container.dom.getAttribute("textID"));
        var imageTagID = container.dom.getAttribute("imageID");
        if (container.dom.getAttribute("toggled").toString() != "true") {
            textDiv.applyStyles("margin-left:" + 0 + "px;margin-top:" + 0 + "px");
            if (imageTagID.toString() != "0") {
                var imageDiv = Ext.get(imageTagID);
                imageDiv.applyStyles("margin-left:" + 0 + "px;margin-top:" + 0 + "px");
            }
        }
        var mouseDownImage = (container.dom.getAttribute("mouseDownImage").toLowerCase() == "true");
        if (mouseDownImage) {
            var optionFinished = container.dom.getAttribute("optionFinished").toString() == "true";
            try {
                if (container.dom.getAttribute("toggleBtn") == "false") {
                    var menuTickImage = "none";
                    try {
                        menuTickImage = trim(cfgXML.getElementsByTagName("menuTickImage")[0].childNodes[0].nodeValue).toLowerCase();
                    }
                    catch (err) {
                    }
                    var imgSrc = trim(cfgXML.getElementsByTagName("mouseOutImage")[0].childNodes[0].nodeValue).toLowerCase();
                    if (optionFinished && menuTickImage != "none") {
                        imgSrc = menuTickImage;
                    }
                    //alert(imgSrc);
                    Ext.get(container.dom.getAttribute("imageID")).dom.src = eval(Ext.encode(Author.resourcePath + imgSrc));
                }
            }
            catch (err) {
                //alert(err.description);
            }
        }
        var mouseOverImage = (container.dom.getAttribute("mouseOverImage").toLowerCase() != "0");
        if (mouseOverImage) {
            try {
                if (container.dom.getAttribute("toggleBtn") == "false") {
                    var img = new Image();
                    img.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase()));
                    Ext.get(container.dom.getAttribute("imageID")).dom.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase()));
                }
            }
            catch (err) {
                //alert(err.description);
            }
        }
    });
    this.setMouseOverEvent(function (e) {
        e.stopEvent();
        var target = Ext.get(e.getTarget());
        // alert("mouseOver");
        var container = Ext.get(target.dom.getAttribute("containerID"));
        var textDiv = Ext.get(container.dom.getAttribute("textID"));
        var imageTagID = container.dom.getAttribute("imageID");
        if (container.dom.getAttribute("toggled").toString() != "true") {
            textDiv.applyStyles("margin-left:" + 0 + "px;margin-top:" + 0 + "px");
            if (imageTagID.toString() != "0") {
                var imageDiv = Ext.get(imageTagID);
                imageDiv.applyStyles("margin-left:" + 0 + "px;margin-top:" + 0 + "px");
            }
        }
        try {
            if (container.dom.getAttribute("clickHandler") == "AUDIOONOFF" || container.dom.getAttribute("clickHandler") == "SYNCHONOFF") {
                return;
            }
            ;
        }
        catch (err) {
            return;
        }
        try {
            if (container.dom.getAttribute("toggleBtn") == "false")
                Ext.get(container.dom.getAttribute("textID")).setStyle("color", trim(cfgXML.getElementsByTagName("mouseOverColor")[0].childNodes[0].nodeValue));
        }
        catch (err) {
            //alert(err.description);
        }
        //set mouse over image
        var mouseOverImage = (container.dom.getAttribute("mouseOverImage").toLowerCase() != "0");
        if (mouseOverImage) {
            try {
                if (container.dom.getAttribute("toggleBtn") == "false") {
                    var img = new Image();
                    img.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase()));
                    Ext.get(container.dom.getAttribute("imageID")).dom.src = eval(Ext.encode(Author.resourcePath + trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase()));
                }
            }
            catch (err) {
                //alert(err.description);
            }
        }
        try {
            if (container.dom.getAttribute("mouseOverResponse") == "true") {
                //	alert(container.dom.getAttribute("preventMO"));
                if (target.id == textDiv.id) {
                    container.dom.setAttribute("preventMO", "true")
                    //alert(container.dom.getAttribute("preventMO"));
                    return;
                }
                else {
                    if (container.dom.getAttribute("preventMO") == "true") {
                        container.dom.setAttribute("preventMO", "false");
                        return;
                    }
                }
                Author.variables.get(variableName('ANSWER')).setValue(container.dom.getAttribute("mouseOverResponseValue"));
                checkResponse();
            }
        }
        catch (err) {
            //alert(err.description);
        }
    });
    this.setMouseOutEvent(function (e) {
        e.stopEvent();
        var target = Ext.get(e.getTarget());
        //alert("mouseOUt");
        var container = Ext.get(target.dom.getAttribute("containerID"));
        if (container.dom.getAttribute("clickHandler") == "AUDIOONOFF" || container.dom.getAttribute("clickHandler") == "SYNCHONOFF") {
            return;
        }
        ;
        var textDiv = Ext.get(container.dom.getAttribute("textID"));
        var imageTagID = container.dom.getAttribute("imageID");
        if (container.dom.getAttribute("toggled").toString() != "true") {
            textDiv.applyStyles("margin-left:" + 0 + "px;margin-top:" + 0 + "px");
            if (imageTagID.toString() != "0") {
                var imageDiv = Ext.get(imageTagID);
                imageDiv.applyStyles("margin-left:" + 0 + "px;margin-top:" + 0 + "px");
            }
        }
        var optionFinished = container.dom.getAttribute("optionFinished").toString() == "true";
        var tickColor = "#000";
        try {
            tickColor = trim(cfgXML.getElementsByTagName("tickColor")[0].childNodes[0].nodeValue).toLowerCase();
            if (tickColor == "none") {
                tickColor = trim(cfgXML.getElementsByTagName("mouseOutColor")[0].childNodes[0].nodeValue);
            }
        }
        catch (err) {
            tickColor = trim(cfgXML.getElementsByTagName("mouseOutColor")[0].childNodes[0].nodeValue);
        }
        try {
            if (container.dom.getAttribute("toggleBtn") == "false") {
                Ext.get(container.dom.getAttribute("textID")).setStyle("color", (optionFinished ? tickColor : trim(cfgXML.getElementsByTagName("mouseOutColor")[0].childNodes[0].nodeValue)));
            }
        }
        catch (err) {
            //alert(err.description);
        }
        var mouseOverImage = (container.dom.getAttribute("mouseOverImage").toLowerCase() != "0");
        if (mouseOverImage) {
            try {
                if (container.dom.getAttribute("toggleBtn") == "false") {
                    var menuTickImage = "none";
                    try {
                        menuTickImage = trim(cfgXML.getElementsByTagName("menuTickImage")[0].childNodes[0].nodeValue).toLowerCase();
                    }
                    catch (err) {
                    }
                    var imgSrc = trim(cfgXML.getElementsByTagName("mouseOutImage")[0].childNodes[0].nodeValue).toLowerCase();
                    if (optionFinished && menuTickImage != "none") {
                        imgSrc = menuTickImage;
                    }
                    //alert(imgSrc);
                    Ext.get(container.dom.getAttribute("imageID")).dom.src = eval(Ext.encode(Author.resourcePath + imgSrc));
                }
            }
            catch (err) {
                //alert(err.description);
            }
        }
        var mouseDownImage = (container.dom.getAttribute("mouseDownImage").toLowerCase() == "true");
        if (mouseDownImage) {
            var optionFinished = container.dom.getAttribute("optionFinished").toString() == "true";
            try {
                if (container.dom.getAttribute("toggleBtn") == "false") {
                    var menuTickImage = "none";
                    try {
                        menuTickImage = trim(cfgXML.getElementsByTagName("menuTickImage")[0].childNodes[0].nodeValue).toLowerCase();
                    }
                    catch (err) {
                    }
                    var imgSrc = trim(cfgXML.getElementsByTagName("mouseOutImage")[0].childNodes[0].nodeValue).toLowerCase();
                    if (optionFinished && menuTickImage != "none") {
                        imgSrc = menuTickImage;
                    }
                    //alert(imgSrc);
                    Ext.get(container.dom.getAttribute("imageID")).dom.src = eval(Ext.encode(Author.resourcePath + imgSrc));
                }
            }
            catch (err) {
                //alert(err.description);
            }
        }
    });
    if (this.click == "GOTOMENUOPTION") {
        this.setOnClickEvent(function (e) {
            // if (Author.waitingMedia) 
            //  return;
            Author.Test.startAtRandom = false;
            e.stopEvent();
            // alert("GOTOMENUOPTION Clicked");
            var nextOptionID = parseInt(trim(cfgXML.getElementsByTagName("nextLessonNode")[0].childNodes[0].nodeValue));
            //  alert("nextOptionID: "+nextOptionID);
            Author.current.currentElementXML = null;
            Author.current.currentElement = null;
            Author.current.currentElementType = "";
            Author.current.currentElementResponses.clear();
            Author.current.currentElementPosition = -1;
            Author.current.currentListPosition = 0;
            Author.response.clear();
            var tempNode = Author.lessonNodes.nodes.get(nextOptionID);
            if (typeof(tempNode) != 'undefined' && tempNode.id.toString() == nextOptionID.toString()) {
                Author.current.currentNode = Author.lessonNodes.nodes.get(nextOptionID);
                Author.current.currentNode.endListShown = false;
            }
            //  Author.current.currentElementResponses.clear();
            //Author.clearBackgroundObjects = true;
            Author.goingToSubMenu = true;
            showLessonNode();
        })
    }
    ;
    //alert(this.click);
    if (this.click == "SYNCHONOFF") {
        this.setOnClickEvent(function (e) {
            if (Author.response.removeType == "BEFORENEXT") {
                stopCurrentResponse();
            }
            else {
                if (Author.inResponse || Author.lessonFinished)
                    return;
            }
            var target = Ext.get(e.getTarget());
            var container = Ext.get(target.dom.getAttribute("containerID"));
            Author.isSynch = !Author.isSynch;
            var textStr = (cfgXML.getElementsByTagName("text")[0].childNodes[0].nodeValue);
            if (textStr.indexOf("|") >= 0) {
                var caps = textStr.split("|");
                textStr = (Author.isSynch ? caps[0] : caps[1]);
            }
            Ext.get(container.dom.getAttribute("textID")).dom.innerHTML = textStr;
            try {
                var mouseOutImage = trim(cfgXML.getElementsByTagName("mouseOutImage")[0].childNodes[0].nodeValue).toLowerCase();
                var mouseOverImage = trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase();
                Ext.get(container.dom.getAttribute("imageID")).dom.src = eval(Ext.encode(Author.resourcePath + (Author.isSynch ? mouseOutImage : mouseOverImage)));
            }
            catch (err) {
            }
            if (Author.isSynch) {
                e.stopEvent();
            }
            //alert(Author.isSynch);
            return;
        })
    }
    if (this.click == "AUDIOONOFF") {
        this.setOnClickEvent(function (e) {
            if (Author.response.removeType == "BEFORENEXT") {
                stopCurrentResponse();
            }
            else {
                if (Author.inResponse || Author.lessonFinished)
                    return;
            }
            var target = Ext.get(e.getTarget());
            var container = Ext.get(target.dom.getAttribute("containerID"));
            e.stopEvent();
            Author.isAudioOn = !Author.isAudioOn;
            if (!Author.isAudioOn) {
                Author.mediaList.eachKey(function (key, object) {
                    if (object.objectType == "SOUNDOBJECT") {
                        if (Ext.isIE && !Author.useFlashInIE) {
                            // object.mediaObject.dom.controls.stop();
                            object.mediaObject.dom.settings.mute = true;
                        }
                    }
                });
            }
            var textStr = (cfgXML.getElementsByTagName("text")[0].childNodes[0].nodeValue);
            if (textStr.indexOf("|") >= 0) {
                var caps = textStr.split("|");
                textStr = (Author.isAudioOn ? caps[0] : caps[1]);
            }
            Ext.get(container.dom.getAttribute("textID")).dom.innerHTML = textStr;
            try {
                var mouseOutImage = trim(cfgXML.getElementsByTagName("mouseOutImage")[0].childNodes[0].nodeValue).toLowerCase();
                var mouseOverImage = trim(cfgXML.getElementsByTagName("mouseOverImage")[0].childNodes[0].nodeValue).toLowerCase();
                Ext.get(container.dom.getAttribute("imageID")).dom.src = eval(Ext.encode(Author.resourcePath + (Author.isAudioOn ? mouseOutImage : mouseOverImage)));
            }
            catch (err) {
            }
            return;
        })
    }
    if (this.click == "TORESPONSE") {
        this.setOnClickEvent(function (e) {
            if (Author.response.removeType == "BEFORENEXT") {
                stopCurrentResponse();
            }
            else {
                if (Author.inResponse || Author.lessonFinished)
                    return;
            }
            e.stopEvent();
            // alert("toResponse");
            var target = Ext.get(e.getTarget());
            var container = Ext.get(target.dom.getAttribute("containerID"));
            var value = container.dom.getAttribute("value");
            Author.variables.get(variableName('SELECTEDVALUE')).setValue(value);
            Author.variables.get(variableName('SELECTEDNAME')).setValue(container.dom.getAttribute("name"));
            //alert(value+", "+ container.dom.getAttribute("name"));
            //var variable = trim(cfgXML.getElementsByTagName("variable")[0].childNodes[0].nodeValue);
            //var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
            Author.variables.get(variableName('ANSWER')).setValue(value);
            checkResponse();
            return;
        })
    }
    if (this.click == "SKIP") {
        this.setOnClickEvent(function (e) {
            e.stopEvent();
            Author.variables.get(variableName('SELECTEDVALUE')).setValue("SKIP");
            Author.variables.get(variableName('SELECTEDNAME')).setValue("SKIP");
            if (Author.pause != null && Author.pause.cancelType != 0) {
                Author.pause = null;
                // pauseVideoes();
                window.clearTimeout(Author.actionTimer);
            }
            var listType = Author.current.currentListXML.attributes[0].nodeValue;
            if (listType == "INTRODUCTION") {
                var actions = Author.current.currentListXML.getElementsByTagName("action");
                Author.current.currentActionPosition = actions.length;
                showList();
                return;
            }
            else {
                if (Author.current.currentNode.type != "MENU") {
                    Author.current.currentElementXML = null;
                    Author.current.currentElement = null;
                    Author.current.currentElementType = "";
                    Author.current.currentElementResponses.clear();
                    Author.response.clear();
                    Author.current.currentElementPosition++;
                    showLessonNode();
                    return;
                }
            }
        })
    }
    if (this.click == "TOUPPERMENU") {
        this.setOnClickEvent(function (e) {
            // if (Author.waitingMedia) 
            // return;
            Author.Test.startAtRandom = false;
            e.stopEvent();
            // alert("TOUPPERMENU Clicked");
            Author.variables.get(variableName('SELECTEDVALUE')).setValue("TOUPPERMENU");
            Author.variables.get(variableName('SELECTEDNAME')).setValue("TOUPPERMENU");
            if (getParentNode() == 0)
                return;
            Author.goingUpperMenu = true;
            while (Author.current.currentBgStack.getCount() > 0) {
                var bgObject = Author.current.currentBgStack.last();
                Author.current.currentBgStack.remove(bgObject);
                if (Author.current.currentBgStack.getCount() == 0) {
                    Author.backgroundObject.setBg(bgObject);
                }
            }
            //  Author.backgroundObject.setOriginal();
            Author.current.currentNode = Author.lessonNodes.nodes.get(getParentNode());
            Author.current.currentNode.endListShown = false;
            Author.current.currentElementXML = null;
            Author.current.currentElement = null;
            Author.current.currentElementType = "";
            Author.current.currentElementResponses.clear();
            Author.current.currentElementPosition = -1;
            Author.current.currentListPosition = 0;
            Author.response.clear();
            Author.current.currentElementResponses.clear();
            Author.clearBackgroundObjects = true;
            Author.backToMenu = true;
            showLessonNode();
        })
    }
    if (this.click == "TOMAINMENU") {
        this.setOnClickEvent(function (e) {
            //   if (Author.waitingMedia) 
            //  return;
            Author.Test.startAtRandom = false;
            e.stopEvent();
            // alert("TOMAINMENU Clicked");
            Author.variables.get(variableName('SELECTEDVALUE')).setValue("TOMAINMENU");
            Author.variables.get(variableName('SELECTEDNAME')).setValue("TOMAINMENU");
            Author.backgroundObject.setOriginal();
            Author.goingUpperMenu = true;
            if (Author.current.currentNode.parent != 0) {
                do {
                    Author.current.currentNode = Author.lessonNodes.nodes.get(getParentNode());
                    Author.current.currentNode.endListShown = false;
                    Author.goingUpperMenu = true;
                }
                while (Author.current.currentNode.parent != 0)
            }
            else {
                showLessonNode();
            }
            Author.current.currentElementXML = null;
            Author.current.currentElement = null;
            Author.current.currentElementType = "";
            Author.current.currentElementResponses.clear();
            Author.current.currentElementPosition = -1;
            Author.current.currentListPosition = 0;
            Author.response.clear();
            Author.current.currentElementResponses.clear();
            Author.clearBackgroundObjects = true;
            Author.backToMenu = true;
            showLessonNode();
        })
    }
    if (this.click == "NEXT") {
        this.setOnClickEvent(function (e) {
            if (Author.lessonFinished) {
                return;
            }
            e.stopEvent();
            Author.variables.get(variableName('SELECTEDVALUE')).setValue("NEXT");
            Author.variables.get(variableName('SELECTEDNAME')).setValue("NEXT");
            if (Author.pause != null) {//&& Author.pause.cancelType != 0
                Author.pause = null;
                // pauseVideoes();
                window.clearTimeout(Author.actionTimer);
                showList();
            }
            else {
                if (Author.enableNextBtn == false)
                    return;
                //alert("Next: "+ Author.variables.get(variableName('ANSWER')).value);
                if (Author.current.currentListXML.attributes[0].nodeValue == "INTERACTION" || Author.lessonFlow == "repeat") {
                    makeAnswerVariable();
                }
                //alert("Next2: "+ Author.variables.get(variableName('ANSWER')).value);
                if (Author.variables.get(variableName('ANSWER')).getValue() == null || Author.variables.get(variableName('ANSWER')).getValue() == "")
                    Author.variables.get(variableName('ANSWER')).setValue("NEXT");
                //  alert("Next CLicked inner");
                checkResponse();
            }
            //alert("Next CLicked");
        })
    }
    if (this.click == "BACK") {
        this.setOnClickEvent(function (e) {
            // if (Author.waitingMedia) 
            //  return;
            e.stopEvent();
            //  alert("BACK Clicked");
            Author.goingBack = true;
            Author.variables.get(variableName('SELECTEDVALUE')).setValue("BACK");
            Author.variables.get(variableName('SELECTEDNAME')).setValue("BACK");
            if (Author.pause != null && Author.pause.cancelType != 0) {
                Author.pause = null;
                window.clearTimeout(Author.actionTimer);
            }
            if (Author.current.currentElementXML != null) {
                Author.current.currentElementPosition -= 1
                Author.current.currentElementXML = null;
                Author.current.currentElement = null;
                if (Author.current.currentElementPosition < 0) {
                    Author.Test.startAtRandom = false;
                    if (getParentNode() == 0)
                        return;
                    Author.goingUpperMenu = true;
                    Author.current.currentNode = Author.lessonNodes.nodes.get(getParentNode());
                    Author.current.currentNode.endListShown = false;
                    while (Author.current.currentBgStack.getCount() > 0) {
                        var bgObject = Author.current.currentBgStack.last();
                        Author.current.currentBgStack.remove(bgObject);
                        if (Author.current.currentBgStack.getCount() == 0) {
                            Author.backgroundObject.setBg(bgObject);
                        }
                    }
                    //  Author.backgroundObject.setOriginal();
                    Author.current.currentElementXML = null;
                    Author.current.currentElement = null;
                    Author.current.currentElementType = "";
                    Author.current.currentElementResponses.clear();
                    Author.current.currentElementPosition = -1;
                    Author.current.currentListPosition = 0;
                    Author.clearBackgroundObjects = true;
                    Author.backToMenu = true;
                }
            }
            else {
                Author.current.currentListPosition -= 1;
                if (Author.current.currentListPosition < 0) {
                    Author.current.currentNode = Author.lessonNodes.nodes.get(getParentNode());
                    Author.goingUpperMenu = true;
                    Author.current.currentNode.endListShown = false;
                    Author.current.currentListPosition = 0;
                    Author.clearBackgroundObjects = true;
                }
            }
            Author.responseEnd = true;
            Author.inResponse = false;
            Author.response.clear();
            Author.current.currentElementResponses.clear();
            showLessonNode();
            return;
        })
    }
    if (this.click == "REPEAT") {
        this.setOnClickEvent(function (e) {
            e.stopEvent();
            Author.variables.get(variableName('SELECTEDVALUE')).setValue("REPEAT");
            Author.variables.get(variableName('SELECTEDNAME')).setValue("REPEAT");
            if (Author.pause != null && Author.pause.cancelType != 0) {
                Author.pause = null;
                //  pauseVideoes();
                window.clearTimeout(Author.actionTimer);
            }
            if (Author.current.currentElementXML != null) {
                // Author.current.currentElementPosition -= 1
                Author.current.currentElementXML = null;
                Author.current.currentElement = null;
            }
            else {
                if (Author.current.currentNode.type == "MENU") {
                    Author.current.currentElementXML = null;
                    Author.current.currentElement = null;
                    Author.current.currentElementType = "";
                    Author.current.currentElementResponses.clear();
                    Author.response.clear();
                    Author.current.currentListPosition = 0;
                    Author.clearBackgroundObjects = true;
                    Author.goingUpperMenu = true;
                    //alert("Menu");
                    showLessonNode();
                    return;
                }
            }
            Author.responseEnd = true;
            Author.inResponse = false;
            Author.response.clear();
            Author.current.currentElementResponses.clear();
            showLessonNode();
            return;
        })
    }
    if (this.click == "EXITLESSON") {
        this.setOnClickEvent(function (e) {
            e.stopEvent();
            if (Author.pause != null && Author.pause.cancelType != 0) {
                Author.pause = null;
                window.clearTimeout(Author.actionTimer);
            }
            Author.mediaList.eachKey(function (key, object) {
                if (Ext.isIE) {
                    try {
                        object.mediaObject.dom.controls.stop();
                        object.mediaObject.dom.settings.mute = true;
                    }
                    catch (err) {
                    }
                }
            });
            if (Author.exitConfirm) {
                Ext.MessageBox.confirm('Exit the lesson', 'Do you really want to exit this lesson?', function (btn) {
                    if (btn == "yes") {
                        endLesson();
                    }
                });
            }
            else {
                endLesson();
            }
        })
    }
    if ((this.click == "CHECKRESPONSE" && this.toggleBtn == false)) {
        this.setOnClickEvent(function (e) {
            //  if (Author.waitingMedia) 
            //   return;
            //alert(Author.response.removeType );
            if (Author.response.removeType == "BEFORENEXT") {
                stopCurrentResponse();
            }
            else {
                if (Author.inResponse || Author.lessonFinished)
                    return;
            }
            e.stopEvent();
            var listType = Author.current.currentListXML.attributes[0].nodeValue;
            //if (!(listType == "MENUINTERACTION" || listType == "INTERACTION" || (Author.current.currentNode.type == "MENU" && listType == "RESPONSE"))) {
            //   return;
            //}
            var target = Ext.get(e.getTarget());
            var container = Ext.get(target.dom.getAttribute("containerID"));
            var value = container.dom.getAttribute("value");
            Author.variables.get(variableName('SELECTEDVALUE')).setValue(value);
            Author.variables.get(variableName('SELECTEDNAME')).setValue(container.dom.getAttribute("name"));
            // alert("ResponseToClick: " + container.dom.getAttribute("responseToClick"));
            try {
                var elementType = Author.current.currentElementXML.attributes[0].nodeValue;
                if (elementType == "MULTIPLECHOICE") {
                    //   var target = Ext.get(e.getTarget());
                    //  var container = Ext.get(target.dom.containerID);
                    //  var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
                    Author.variables.get(variableName('ANSWER')).setValue(value);
                    var regex = /^[A|B|C|D|E|F|G|H]{1}$/;
                    var answer = container.dom.getAttribute("name").toUpperCase();
                    if (regex.test(answer) == true) {
                        Author.answers.multipleChoice.add(container.dom.getAttribute("value").toUpperCase(), container.dom.getAttribute("toggled"));
                    }
                    checkResponse();
                }
                else
                if (elementType == "YESNO") {
                    //  var target = Ext.get(e.getTarget());
                    //   var container = Ext.get(target.dom.containerID);
                    //  var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
                    Author.variables.get(variableName('ANSWER')).setValue(value);
                    Author.answers.yesNo = value.toLowerCase();
                    checkResponse();
                }
                else
                if (elementType == "TRUEFALSE") {
                    Author.variables.get(variableName('ANSWER')).setValue(value);
                    Author.answers.trueFalse = value.toLowerCase();
                    checkResponse();
                }
                else {
                    // var variable = trim(cfgXML.getElementsByTagName("variable")[0].childNodes[0].nodeValue);
                    //  var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
                    Author.variables.get(variableName('ANSWER')).setValue(value);
                    // makeAnswerVariable();
                    checkResponse();
                }
                return;
            }
            catch (err) {
                // alert("MouseClick::" + err.description);
            }
            var variable = trim(cfgXML.getElementsByTagName("variable")[0].childNodes[0].nodeValue);
            var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
            Author.variables.get(variableName('ANSWER')).setValue(value);
            checkResponse();
            return;
        })
    }
    if (this.addToForeground == false && this.toggleBtn)
        this.checkPrecedence();
    //this.addToForeground=true;
    //alert(this.addToForeground);
    if (this.addToForeground == true) {
        this.setVisible(this.hide == "false");
        Author.foregroundList.list.add(this.id, this);
        //	alert(this.addToForeground);
        this.addToForegroundAtElementPosition = Author.current.currentElementPosition;
        this.zorder(100);
    }
    this.key1 = "none";
    this.key2 = "none";
    try {
        this.key1 = trim(cfgXML.getElementsByTagName("key1")[0].childNodes[0].nodeValue);
        this.key2 = trim(cfgXML.getElementsByTagName("key2")[0].childNodes[0].nodeValue);
        if (this.key1 != "none")
            Author.actionKeyMap.add(this.key1, this);
        if (this.key2 != "none")
            Author.actionKeyMap.add(this.key2, this);
    }
    catch (err) {
    }
    return 0;
}
CustomButtonClass.prototype.setText = function (textHTML) {
    if (this.textPosition != "center") {
        this.p.dom.innerText = textHTML;
    }
    else {
        this.p.dom.innerText = textHTML;
    }
}
CustomButtonClass.prototype.setImage = function (url) {
    if (this.textPosition != "center") {
        this.image.dom.src = eval(Ext.encode(url));
    }
    else {
        this.content.setStyle("background-image", "url(" + Ext.encode(url.toLowerCase()) + ")");
    }
}
CustomButtonClass.prototype.setTop = function (y) {
    this.content.setStyle("top", y + "px");
}
CustomButtonClass.prototype.setLeft = function (x) {
    this.content.setStyle("left", x + "px");
}
CustomButtonClass.prototype.setWidth = function (width) {
    this.width = width;
    this.content.setWidth(width);
}
CustomButtonClass.prototype.setHeight = function (height) {
    this.height = height;
    this.content.setHeight(height);
}
CustomButtonClass.prototype.setVisible = function (visible) {
    this.visible = visible;
    try {
        this.content.setVisible(visible);
        if (visible) {
            try {
                if (this.key1 != "none")
                    Author.actionKeyMap.add(this.key1, this);
                if (this.key2 != "none")
                    Author.actionKeyMap.add(this.key2, this);
            }
            catch (err) {
            }
        }
    }
    catch (err) {
        //alert(this.name+","+this.id);
    }
}
CustomButtonClass.prototype.setAlignmentH = function (alignment) {
    this.content.setStyle("text-align", alignment);
}
CustomButtonClass.prototype.setStyle = function (CSSStyle) {
    this.content.applyStyles(CSSStyle);
}
CustomButtonClass.prototype.setMouseDownEvent = function (mouseDownEventHandler) {
    this.content.on("mousedown", eval(mouseDownEventHandler));
}
CustomButtonClass.prototype.setMouseUpEvent = function (mouseUpEventHandler) {
    this.content.on("mouseup", eval(mouseUpEventHandler));
}
CustomButtonClass.prototype.setMouseOverEvent = function (mouseOverEventHandler) {
    this.content.on("mouseover", eval(mouseOverEventHandler));
}
CustomButtonClass.prototype.setMouseOutEvent = function (mouseOutEventHandler) {
    this.content.on("mouseout", eval(mouseOutEventHandler));
}
CustomButtonClass.prototype.setOnClickEvent = function (onClickEventHandler) {
    this.content.on("click", eval(onClickEventHandler));
}
CustomButtonClass.prototype.remove = function () {
    if (this.feedBackText != "NOTOOLTIP") {
        this.toolTip.hide();
    }
    if (this.key1 != "none")
        Author.actionKeyMap.removeKey(this.key1);
    if (this.key2 != "none")
        Author.actionKeyMap.removeKey(this.key2);
    this.content.remove();
}
function VariableClass(o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
}
VariableClass.prototype.processAction = function (cfgXML) {
    this.objectType = "VariableClass"
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    //alert("Variable :"+this.id);
    var expressions = cfgXML.getElementsByTagName("expressions")[0].childNodes;
    this.numExpressions = expressions.length;
    for (var i = 0; i < this.numExpressions; i++) {
        var expression = new String(expressions[i].childNodes[0].nodeValue);
        var equPos = expression.indexOf("=");
        var vID = trim(expression.substring(1, equPos - 2));
        var valueExpression = expression.substring(equPos + 1, expression.length);
        // alert(Author.variables.containsKey(vID));
        if (Author.variables.containsKey(vID)) {
            valueExpression = replaceVariableNameWithValue(valueExpression);
            //  alert(valueExpression);
            var thisVar = Author.variables.get(vID);
            // alert(thisVar.variableType);
            if (thisVar.variableType == 0) {
                // alert(valueExpression +" >> "+evalExpression(valueExpression));
                thisVar.setValue(eval(evalExpression(valueExpression)));
                //alert(valueExpression +" >> "+evalExpression(valueExpression)+" >> "+thisVar.getValue());
            }
            else {
                // alert(valueExpression +" >> "+evalExpression(valueExpression));
                thisVar.setValue(evalExpression(valueExpression));
                //alert(valueExpression);
            }
        }
        else {
            //  alert(vID + " doesn't exist!");
        }
    }
    return 0;
}
VariableClass.prototype.remove = function () {
}
VariableClass.prototype.setVisible = function (visible) {
}
function PauseClass(o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.objectType = "PAUSEOBJECT";
}
;
PauseClass.prototype.readConfig = function (cfgXML) {
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    var pauseType = trim(cfgXML.getElementsByTagName("type")[0].childNodes[0].nodeValue);
    var cancel = parseInt((trim(cfgXML.getElementsByTagName("cancelType")[0].childNodes[0].nodeValue)));
    this.key1 = "none";
    this.key2 = "none";
    try {
        this.key1 = trim(cfgXML.getElementsByTagName("key1")[0].childNodes[0].nodeValue);
        this.key2 = trim(cfgXML.getElementsByTagName("key2")[0].childNodes[0].nodeValue);
    }
    catch (err) {
    }
    Author.pause = {
        cancelType: cancel,
        startTime: new Date(),
        id: this.id,
        key1: this.key1,
        key2: this.key2
    }
    if (pauseType == "time") {
        var countDown = eval((trim(cfgXML.getElementsByTagName("time")[0].childNodes[0].nodeValue)) * 1000);
        //  alert(countDown);
        var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
        if (Ext.isIE && ie6) {
            countDown -= Author.processTime * 5;
            if (countDown < 10) {
                countDown = 10;
            }
        }
        Author.processTime = 0;
        Author.pause.countDown = countDown;
        return countDown;
    }
    if (pauseType == "waitForUser") {
        Author.processTime = 0;
        return 3600 * 24 * 1000;
    }
}
PauseClass.prototype.remove = function () {
}
PauseClass.prototype.setVisible = function (visible) {
}
function DividerClass(o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.objectType = "DIVIDER";
}
DividerClass.prototype.readConfig = function (cfgXML) {
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.backMarker = trim(cfgXML.getElementsByTagName("backMarker")[0].childNodes[0].nodeValue).toLowerCase();
    this.listPosition = Author.current.currentListPosition - 1;
    this.actionPosition = Author.current.currentActionPosition - 1;
    this.currentListPosition = Author.current.currentList.getCount();
    if (this.backMarker == "true") {
        Author.dividers.add(this.id, this);
    }
}
DividerClass.prototype.setVisible = function (visible) {
}
DividerClass.prototype.remove = function () {
}
function VisibleClass(o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.objectType = "VISIBLEOBJECT";
}
VisibleClass.prototype.readConfig = function (cfgXML, travelling) {
    if (typeof(travelling) == 'undefined') {
        travelling = false;
    }
    else {
        travelling = travelling === true;
    }
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    var show, hide, index;
    var currentList = cfgXML.getElementsByTagName("currentList")[0];
    if (currentList.childNodes.length > 0) {
        show = currentList.getElementsByTagName("show");
        for (index = 0; index < show.length; index++) {
            try {

                // alert("Show: " + show[index].childNodes[0].nodeValue);
                // showCurrentList();
                var action = Author.current.currentList.item(show[index].childNodes[0].nodeValue);
                var effect = parseInt(show[index].attributes[0].nodeValue);
                var duration = parseFloat(show[index].attributes[1].nodeValue);
                //alert("Show:\neffect: "+effect +", duration: "+duration);
                //alert(action);
                if (typeof(action) == 'undefined')
                    continue;
                if (action.objectType == "CUSTOMBUTTONOBJECT")
                    action.changedByVisibleAction = true;
                action.setVisible(true);
                if (!travelling)
                    setFxToElement(action, effect, duration);
                //alert("after visible");
            }
            catch (err) {
                // displayError("Visible Action:\nVisible Action seems to trying to show an action that doesn't exist.\nActionID: " + this.id + "\nObjectID: " + hide[index].childNodes[0].nodeValue);
            }
        }
        hide = currentList.getElementsByTagName("hide");
        // Author.current.currentList.each(function(item,index,length){
        //	alert(index+", "+item.id);
        //})
        for (index = 0; index < hide.length; index++) {
            try {

                // alert("hide: " + hide[index].childNodes[0].nodeValue);
                var action = Author.current.currentList.item(hide[index].childNodes[0].nodeValue);
                var effect = parseInt(hide[index].attributes[0].nodeValue);
                var duration = parseFloat(hide[index].attributes[1].nodeValue);
                // alert("Hide:"+ hide[index].childNodes[0].nodeValue+"\neffect: "+effect +", duration: "+duration);
                if (action.objectType == "CUSTOMBUTTONOBJECT")
                    action.changedByVisibleAction = true;
                if (travelling)
                    action.setVisible(false);
                else
                    setHideFxToElement(action, effect, duration);
            }
            catch (err) {
                //   if (!travelling) 
                //displayError("Visible Action:\nVisible Action seems to trying to hide an action that doesn't exist.\nActionID: " + this.id + "\nObjectID: " + hide[index].childNodes[0].nodeValue);
            }
        }
    }
    return 0;
}
VisibleClass.prototype.setVisible = function (visible) {
}
VisibleClass.prototype.remove = function () {
}
/**
 * TextFieldClass
 * @param {Object} bgObject
 * @param {Object} cfgXML
 */
function TextFieldClass(bgObject, cfgXML, o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.multiline = trim(cfgXML.getElementsByTagName("multiline")[0].childNodes[0].nodeValue).toLowerCase();
    this.objectType = "TEXTFIELDOBJECT";
    try {
        this.maskStr = trim(cfgXML.getElementsByTagName("maskStr")[0].childNodes[0].nodeValue);
    }
    catch (err) {
        this.maskStr = "";
    }
    try {
        this.inputType = trim(cfgXML.getElementsByTagName("inputType")[0].childNodes[0].nodeValue);
    }
    catch (err) {
        this.inputType = "normal";
    }
    try {
        this.prompt = trim(cfgXML.getElementsByTagName("promptChar")[0].childNodes[0].nodeValue);
    }
    catch (err) {
        this.prompt = "_";
    }
    this.isPrecedent = false;
    try {
        this.passwordMask = trim(cfgXML.getElementsByTagName("passwordMask")[0].childNodes[0].nodeValue);
    }
    catch (err) {
        this.passwordMask = "";
    }
    this.name = trim(cfgXML.getElementsByTagName("name")[0].childNodes[0].nodeValue);
    try {
        this.validationChars = trim(cfgXML.getElementsByTagName("validationChars")[0].childNodes[0].nodeValue);
    }
    catch (err) {
        this.validationChars = "";
    }
    try {
        this.maxLength = parseInt(trim(cfgXML.getElementsByTagName("maxLength")[0].childNodes[0].nodeValue));
    }
    catch (err) {
        this.maxLength = -1;
    }
    if (this.inputType == "currency") {
        this.maskStr = "$!.##";
    }
    this.audioFile = "";
    this.readContentOnFocused = false;
    try {
        this.audioFile = trim(cfgXML.getElementsByTagName("audioFile")[0].childNodes[0].nodeValue);
    }
    catch (err) {
    }
    try {
        this.readContentOnFocused = trim(cfgXML.getElementsByTagName("audioFile")[0].childNodes[0].nodeValue).toLowerCase() == 'true';
    }
    catch (err) {
    }
    // alert(this.audioFile+","+this.readContentOnFocused);
    this.content = bgObject.createChild({
        objectType: "TEXTFIELDOBJECT",
        tag: (this.multiline == "true") ? "textarea" : "input",
        name: this.name,
        type: (this.multiline == "true") ? "" : ((this.passwordMask != "") ? "password" : "text"),
        style: "position:absolute;z-index:60;padding-right:2px;padding-left:2px",
        validationChars: this.validationChars,
        maxLength: this.maxLength,
        maskStr: this.maskStr,
        prompt: this.prompt,
        inputType: this.inputType,
        integerPart: "",
        hasDot: "false",
        dotPart: "",
        //initValue: getInitRealValue(this.maskStr),
        realValue: "",
        value: (this.inputType == "currency" ? "$0.00" : getFilledMask(this.maskStr, "", this.prompt)),
        audioFile: this.audioFile,
        readContent: this.readContentOnFocused,
        tabindex: "1"

    });
    this.visible = true;
}
TextFieldClass.prototype.checkPrecedence = function () {
    var listType = Author.current.currentListXML.attributes[0].nodeValue;
    if (listType == "INTERACTION") {
        Author.current.precedentObject = this.objectType;
        this.isPrecedent = true;
    }
}
TextFieldClass.prototype.setText = function (text) {
    if (text.length == 0)
        return;
    if (this.multiline == "true") {
        this.content.dom.innerHTML = replaceVariableNameWithValue(text);
    }
    else {
        this.content.dom.value = replaceVariableNameWithValue(text);
    }
}
TextFieldClass.prototype.readConfig = function (cfgXML) {
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.setAlignmentH(trim(cfgXML.getElementsByTagName("textAlignmentH")[0].childNodes[0].nodeValue));
    this.content.setStyle("border-width", trim(cfgXML.getElementsByTagName("borderWidth")[0].childNodes[0].nodeValue));
    this.content.setStyle("border-color", trim(cfgXML.getElementsByTagName("borderColor")[0].childNodes[0].nodeValue));
    this.content.setStyle("border-style", trim(cfgXML.getElementsByTagName("borderStyle")[0].childNodes[0].nodeValue));
    this.setTop(parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue)));
    this.setLeft(parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue)));
    this.setWidth(parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue)));
    this.setHeight(parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue)));
    this.content.setStyle("font-family", trim(cfgXML.getElementsByTagName("font-family")[0].childNodes[0].nodeValue));
    this.content.setStyle("font-size", trim(cfgXML.getElementsByTagName("font-size")[0].childNodes[0].nodeValue) + "pt");
    this.content.setStyle("font-style", trim(cfgXML.getElementsByTagName("font-style")[0].childNodes[0].nodeValue));
    this.content.setStyle("font-weight", trim(cfgXML.getElementsByTagName("font-weight")[0].childNodes[0].nodeValue));
    this.content.setStyle("color", trim(cfgXML.getElementsByTagName("color")[0].childNodes[0].nodeValue));
    this.content.setStyle("background-color", trim(cfgXML.getElementsByTagName("backColor")[0].childNodes[0].nodeValue));
    try {
        this.text = trim(cfgXML.getElementsByTagName("text")[0].childNodes[0].nodeValue);
    }
    catch (err) {
        this.text = "";
    }
    this.setText(this.text);
    this.content.on("change", function (e) {
        if (Author.inResponse || Author.lessonFinished)
            return;
        var target = Ext.get(e.getTarget());
        try {
            var elementType = Author.current.currentElementXML.attributes[0].nodeValue;
            if (elementType == "SHORTANSWER") {
                Author.answers.shortAnswer = target.dom.value.toLowerCase();
                //alert(Author.answers.shortAnswer);
            }
        }
        catch (err) {
        }
        //this.focus();
        // checkInstantResponse("var " + target.dom.name + " = \"" + target.dom.value + "\";");
        return;
    });
    this.content.on("focus", function (e) {
        Author.doingInteraction = true;
        var target = Ext.get(e.getTarget());
        var maskStr = target.dom.getAttribute("maskStr");
        if (this.inputType == "currency") {
            var pos = 2;
            if (target.dom.setSelectionRange) {
                target.dom.focus();
                target.dom.setSelectionRange(pos, pos);
            }
            else
            if (target.dom.createTextRange) {
                var r = target.dom.createTextRange();
                r.moveStart('character', pos);
                r.collapse(true);
                r.select();
            }
            return;
        }
        if (maskStr.length == 0) {
            target.dom.select();
        }
        else {
            var realValue = target.dom.getAttribute("realValue");
            var maskStr = target.dom.getAttribute("maskStr");
            setInputCurPos(target, maskStr, realValue);
        }
        var audioFile = target.dom.getAttribute("audioFile");
        var readContent = target.dom.getAttribute("readContent");
        var vd = Author.variables.get(variableName("VISUALDISABLED")).value;
        //Actions for visiual disabled lesson.
        if (vd != "") {

            // play attached mp3
            if (audioFile.length > 0) {
                audioFile = eval(Ext.encode(Author.resourcePath + audioFile));
                playMp3(audioFile);
            }
            // read content 
            if (readContent) {
            }
        }
        return;
    });
    this.content.on("blur", function (e) {
        Author.doingInteraction = false;
        try {
            var elementType = Author.current.currentElementXML.attributes[0].nodeValue;
            if (elementType == "SHORTANSWER") {
                Author.answers.shortAnswer = target.dom.value.toLowerCase();
            }
        }
        catch (err) {
        }
        //	this.focus();
        return;
    });
    this.checkPrecedence();
    Author.inputFieldsInList.add(this.id, this);
    //alert("setFocus");
    //this.content.focus();
    return 0;
}
TextFieldClass.prototype.setTop = function (y) {
    this.content.setStyle("top", y + "px");
}
TextFieldClass.prototype.setLeft = function (x) {
    this.content.setStyle("left", x + "px");
}
TextFieldClass.prototype.setWidth = function (width) {
    this.content.setWidth(width);
}
TextFieldClass.prototype.setHeight = function (height) {
    this.content.setHeight(height);
}
TextFieldClass.prototype.setVisible = function (visible) {
    this.visible = visible;
    this.content.setVisible(visible);
}
TextFieldClass.prototype.setBackgroundColor = function (color) {
    this.content.setStyle("background-color", color);
}
TextFieldClass.prototype.setForegroundColor = function (color) {
    this.content.setStyle("color", color);
}
TextFieldClass.prototype.setAlignmentH = function (alignment) {
    //center,left,right
    this.content.setStyle("text-align", alignment);
}
TextFieldClass.prototype.setStyle = function (CSSStyle) {
    this.content.applyStyles(CSSStyle);
}
TextFieldClass.prototype.remove = function () {
    this.content.remove();
}
/**
 * RadioButtonClass
 * @param {Object} bgObject
 * @param {Object} cfgXML
 */
function RadioButtonClass(bgObject, cfgXML, o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.objectType = "RADIOBUTTONOBJECT";
    this.text = null;
    this.isPrecedent = false;
    this.name = trim(cfgXML.getElementsByTagName("name")[0].childNodes[0].nodeValue);
    this.width = parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue));
    this.height = parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue));
    this.generateResponse = trim(cfgXML.getElementsByTagName("generateResponse")[0].childNodes[0].nodeValue).toLowerCase() == "true";
    this.content = bgObject.createChild({
        tag: "div",
        style: "position:absolute;"
    });
    this.value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
    var buttonValue = replaceVariableNameWithValue(this.value).toString().toLowerCase();
    //alert(buttonValue);
    if (buttonValue == "false" || buttonValue == "0" || buttonValue == this.Value.toLowerCase() || buttonValue == "") {
        buttonValue = false;
    }
    else {
        buttonValue = true;
    }
    this.setTop(parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue)));
    this.setLeft(parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue)));
    this.setWidth(this.width);
    this.setHeight(this.height);
    this.button = this.content.createChild({
        objectType: "RADIOBUTTONOBJECT",
        tag: "input",
        name: this.name,
        generateResponse: this.generateResponse,
        type: "radio",
        style: "position:absolute;top:" + (this.height - 12) / 2 + "px"
    });
    //alert(buttonValue);
    if (buttonValue) {
        this.button.set({
            "checked": buttonValue
        });
    }
    this.visible = true;
}
RadioButtonClass.prototype.checkPrecedence = function () {
    var listType = Author.current.currentListXML.attributes[0].nodeValue;
    if (listType == "INTERACTION") {
        Author.current.precedentObject = this.objectType;
        this.isPrecedent = true;
    }
}
RadioButtonClass.prototype.readConfig = function (cfgXML) {
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.textStr = "";
    try {
        this.textStr = trim(cfgXML.getElementsByTagName("text")[0].childNodes[0].nodeValue);
    }
    catch (err) {
    }
    this.setText(this.textStr);
    this.setAlignmentH(trim(cfgXML.getElementsByTagName("textAlignmentH")[0].childNodes[0].nodeValue));
    this.content.setStyle("font-family", trim(cfgXML.getElementsByTagName("font-family")[0].childNodes[0].nodeValue));
    this.content.setStyle("font-size", trim(cfgXML.getElementsByTagName("font-size")[0].childNodes[0].nodeValue) + "pt");
    this.content.setStyle("font-style", trim(cfgXML.getElementsByTagName("font-style")[0].childNodes[0].nodeValue));
    this.content.setStyle("font-weight", trim(cfgXML.getElementsByTagName("font-weight")[0].childNodes[0].nodeValue));
    this.content.setStyle("color", trim(cfgXML.getElementsByTagName("color")[0].childNodes[0].nodeValue));
    this.button.on("click", function (e) {
        var elementType = Author.current.currentElementXML.attributes[0].nodeValue;
        Author.current.currentList.each(function (item, index, length) {
            if (item.objectType == "RADIOBUTTONOBJECT") {
                item.button.dom.checked = false;
                if (elementType == "MULTIPLECHOICE") {
                    Author.answers.multipleChoice.removeKey(item.button.dom.getAttribute("name").toUpperCase());
                }
            }
        });
        var target = Ext.get(e.getTarget());
        target.dom.checked = true;
        if (Author.response.removeType == "BEFORENEXT") {
            stopCurrentResponse();
        }
        else {
            if (Author.inResponse || Author.lessonFinished)
                return;
        }
        e.stopPropagation();
        Author.variables.get(variableName('ANSWER')).setValue("ANSWER");
        if (elementType == "MULTIPLECHOICE") {
            Author.answers.multipleChoice.add(target.dom.getAttribute("name").toUpperCase(), target.dom.checked);
        }
        //alert(target.dom.getAttribute("generateResponse").toString().toLowerCase());
        if (target.dom.getAttribute("generateResponse").toString().toLowerCase() == "true") {
            Author.variables.get(variableName('ANSWER')).setValue(target.dom.getAttribute("name"));
            Author.variables.get(variableName('SELECTEDVALUE')).setValue(target.dom.checked.toString());
            Author.variables.get(variableName('SELECTEDNAME')).setValue(target.dom.getAttribute("name"));
            checkResponse();
        }
        return;
    });
    this.checkPrecedence();
    return 0;
}
RadioButtonClass.prototype.setText = function (text) {
    text = text.replace(/\&\&/g, "_*_");
    text = text.replace(/\&(.){1}/g, function (name, variableName) {
        return "<font style='text-decoration: underline' [#CONTAINERID#]>" + variableName + "</font>";
    });
    text = text.replace("[#CONTAINERID#]", "containerID='" + this.content.id + "'");
    text = text.replace(/_\*_/g, "&");
    if (this.text == null) {
        this.text = this.content.createChild({
            tag: "label",
            'for': this.button.id,
            html: text,
            style: "position:absolute;left:20px;padding-left:2px"
        });
        this.text.setStyle("top", (this.height - this.text.getHeight()) / 2 + "px");
        this.text.on("click", function (e) {
            if (Author.response.removeType == "BEFORENEXT") {
                stopCurrentResponse();
            }
            else {
                if (Author.inResponse || Author.lessonFinished)
                    return;
            }
            e.stopPropagation();
        });
    }
}
RadioButtonClass.prototype.setTop = function (y) {
    this.content.setStyle("top", y + "px");
}
RadioButtonClass.prototype.setLeft = function (x) {
    this.content.setStyle("left", x + "px");
}
RadioButtonClass.prototype.setWidth = function (width) {
    this.content.setWidth(width);
}
RadioButtonClass.prototype.setHeight = function (height) {
    this.content.setHeight(height);
}
RadioButtonClass.prototype.setVisible = function (visible) {
    this.visible = visible;
    this.content.setVisible(visible);
}
RadioButtonClass.prototype.setBackgroundColor = function (color) {
    this.content.setStyle("background-color", color);
}
RadioButtonClass.prototype.setForegroundColor = function (color) {
    this.content.setStyle("color", color);
}
RadioButtonClass.prototype.setAlignmentH = function (alignment) {
    this.text.setStyle("text-align", alignment);
}
RadioButtonClass.prototype.setStyle = function (CSSStyle) {
    this.content.applyStyles(CSSStyle);
}
RadioButtonClass.prototype.remove = function () {
    this.content.remove();
}
function ComboboxClass(bgObject, cfgXML, o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.objectType = "COMBOBOXOBJECT";
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.text = null;
    this.name = trim(cfgXML.getElementsByTagName("name")[0].childNodes[0].nodeValue);
    this.isPrecedent = false;
    this.width = parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue));
    this.height = parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue));
    this.top = parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue));
    this.left = parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue));
    this.generateResponse = trim(cfgXML.getElementsByTagName("generateResponse")[0].childNodes[0].nodeValue).toLowerCase() == "true";
    this.allowUserInput = trim(cfgXML.getElementsByTagName("allowUserInput")[0].childNodes[0].nodeValue).toLowerCase() == "true";
    this.valuesString = cfgXML.getElementsByTagName("valuesString")[0].childNodes[0].nodeValue;
    try {
        this.text = cfgXML.getElementsByTagName("text")[0].childNodes[0].nodeValue;
    }
    catch (err) {
        this.text = "";
    }
    this.content = bgObject.createChild({
        tag: "div",
        style: "position:absolute;left:" + (this.left) + "px;top:" + (this.top) + "px;width:" + this.width + "px;height:" + this.height + "px"
    });
    var optionStr = "";
    var values = this.valuesString.split("|");
    for (var i = 0; i < values.length; i++) {
        optionStr += "<option value='" + values[i] + "'>" + values[i] + "</option>\n";
    }
    if (!this.allowUserInput) {
        var regex = /\[([%|&|\w|\s]+)\]/gi;
        if (this.text.search(regex) < 0) {
            this.text = values[0];
        }
        else {
            var textValue = replaceVariableNameWithValue(this.text).toString();
            if (textValue.length == 0) {
                this.text = values[0];
            }
        }
    }
    this.selectionBox = this.content.createChild({
        objectType: "COMBOBOXOBJECT",
        tag: "select",
        name: this.name,
        html: optionStr,
        style: "width:100%;height:100%"
    });
    var styleStr = "";
    try {
        styleStr = 'font-size:' + trim(cfgXML.getElementsByTagName("font-size")[0].childNodes[0].nodeValue) + "pt;";
        styleStr += 'font-style:' + trim(cfgXML.getElementsByTagName("font-style")[0].childNodes[0].nodeValue) + ";";
        styleStr += 'font-weight:' + trim(cfgXML.getElementsByTagName("font-weight")[0].childNodes[0].nodeValue) + ";";
        styleStr += 'color:' + trim(cfgXML.getElementsByTagName("color")[0].childNodes[0].nodeValue) + ";";
    }
    catch (err) {
    }
    this.combobox = new Ext.form.ComboBox({
        name: this.name,
        generateResponse: this.generateResponse,
        allowUserInput: this.allowUserInput,
        forceSelection: !this.allowUserInput,
        validateOnBlur: false,
        listWidth: this.width,
        width: this.width,
        height: this.height,
        typeAhead: true,
        triggerAction: 'all',
        transform: this.selectionBox,
        style: styleStr
    });
    this.visible = true;
}
ComboboxClass.prototype.setVisible = function (visible) {
    this.visible = visible;
    this.content.setVisible(visible);
}
ComboboxClass.prototype.remove = function () {
    this.combobox.collapse();
    this.content.remove();
}
ComboboxClass.prototype.checkPrecedence = function () {
    var listType = Author.current.currentListXML.attributes[0].nodeValue;
    if (listType == "INTERACTION") {
        Author.current.precedentObject = this.objectType;
        this.isPrecedent = true;
    }
}
ComboboxClass.prototype.readConfig = function (cfgXML) {
    var textValue = replaceVariableNameWithValue(this.text).toString();
    this.combobox.setValue(textValue);
    this.combobox.on("focus", function (e) {
        if (e.allowUserInput) {
            Author.doingInteraction = true;
        }
    });
    this.combobox.on("blur", function (e) {
        if (e.allowUserInput) {
            Author.doingInteraction = false;
        }
        return;
    });
    this.combobox.on("select", function (combo, record, index) {
        if (combo.generateResponse) {
            if (Author.response.removeType == "BEFORENEXT") {
                stopCurrentResponse();
            }
            else {
                if (Author.inResponse || Author.lessonFinished)
                    return;
            }
            var value = record.data.value;
            Author.variables.get(variableName('SELECTEDVALUE')).setValue(value);
            Author.variables.get(variableName('SELECTEDNAME')).setValue(combo.name);
            Author.variables.get(variableName('ANSWER')).setValue(value);
            checkResponse();
        }
    })
    this.checkPrecedence();
    return 0;
}
/**
 * CheckButtonClass
 * @param {Object} bgObject
 * @param {Object} cfgXML
 */
function CheckboxClass(bgObject, cfgXML, o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.objectType = "CHECKBOXOBJECT";
    this.text = null;
    this.name = trim(cfgXML.getElementsByTagName("name")[0].childNodes[0].nodeValue);
    this.isPrecedent = false;
    this.width = parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue));
    this.height = parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue));
    this.top = parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue));
    this.left = parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue));
    this.generateResponse = trim(cfgXML.getElementsByTagName("generateResponse")[0].childNodes[0].nodeValue).toLowerCase() == "true";
    this.content = bgObject.createChild({
        tag: "div",
        style: "position:absolute;left:" + (this.left) + "px;top:" + (this.top) + "px;width:" + this.width + "px;height:" + this.height + "px"
    });
    this.value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
    var buttonValue = replaceVariableNameWithValue(this.value).toString().toLowerCase();
    //alert(buttonValue+","+this.value.toLowerCase());
    if (buttonValue == "false" || buttonValue == "0" || buttonValue == this.value.toLowerCase() || buttonValue == "") {
        buttonValue = false;
    }
    else {
        buttonValue = true;
    }
    //alert(buttonValue);
    this.setWidth(this.width);
    this.setHeight(this.height);
    this.button = this.content.createChild({
        objectType: "CHECKBOXOBJECT",
        tag: "input",
        name: this.name,
        generateResponse: this.generateResponse,
        type: "checkbox",
        style: "position:absolute;top:" + (this.height - 12) / 2 + "px;width:13px;height:13px;left:0px"
    });
    //alert(buttonValue);
    if (buttonValue) {
        this.button.set({
            "checked": buttonValue
        });
    }
    this.visible = true;
}
CheckboxClass.prototype.checkPrecedence = function () {
    var listType = Author.current.currentListXML.attributes[0].nodeValue;
    if (listType == "INTERACTION") {
        Author.current.precedentObject = this.objectType;
        this.isPrecedent = true;
    }
}
CheckboxClass.prototype.readConfig = function (cfgXML) {
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.content.setStyle("font-family", trim(cfgXML.getElementsByTagName("font-family")[0].childNodes[0].nodeValue));
    this.content.setStyle("font-size", trim(cfgXML.getElementsByTagName("font-size")[0].childNodes[0].nodeValue) + "pt");
    this.content.setStyle("font-style", trim(cfgXML.getElementsByTagName("font-style")[0].childNodes[0].nodeValue));
    this.content.setStyle("font-weight", trim(cfgXML.getElementsByTagName("font-weight")[0].childNodes[0].nodeValue));
    this.content.setStyle("color", trim(cfgXML.getElementsByTagName("color")[0].childNodes[0].nodeValue));
    try {
        this.setText(trim(cfgXML.getElementsByTagName("text")[0].childNodes[0].nodeValue));
        this.setAlignmentH(trim(cfgXML.getElementsByTagName("textAlignmentH")[0].childNodes[0].nodeValue));
    }
    catch (err) {
    }
    var elementType = Author.current.currentElementXML.attributes[0].nodeValue;
    this.button.on("click", function (e) {
        if (Author.response.removeType == "BEFORENEXT") {
            stopCurrentResponse();
        }
        else {
            if (Author.inResponse || Author.lessonFinished)
                return;
        }
        e.stopPropagation();
        var target = Ext.get(e.getTarget());
        var elementType = Author.current.currentElementXML.attributes[0].nodeValue;
        if (target.dom.checked) {
            Author.variables.get(variableName('ANSWER')).setValue("ANSWER");
            //alert( Author.variables.get(variableName('ANSWER')).value);
            if (elementType == "MULTIPLECHOICE") {
                Author.answers.multipleChoice.add(target.dom.getAttribute("name").toUpperCase(), target.dom.checked);
            }
        }
        else {
            if (elementType == "MULTIPLECHOICE") {
                Author.answers.multipleChoice.removeKey(target.dom.getAttribute("name").toUpperCase());
            }
        }
        if (target.dom.getAttribute("generateResponse").toString().toLowerCase() == "true") {
            Author.variables.get(variableName('ANSWER')).setValue(target.dom.checked.toString());
            Author.variables.get(variableName('SELECTEDVALUE')).setValue(target.dom.checked.toString());
            Author.variables.get(variableName('SELECTEDNAME')).setValue(target.dom.getAttribute("name"));
            checkResponse();
        }
        return;
    });
    this.checkPrecedence();
    return 0;
}
CheckboxClass.prototype.setText = function (text) {
    text = text.replace(/\&\&/g, "_*_");
    text = text.replace(/\&(.){1}/g, function (name, variableName) {
        return "<font style='text-decoration: underline' [#CONTAINERID#]>" + variableName + "</font>";
    });
    text = text.replace("[#CONTAINERID#]", "containerID='" + this.content.id + "'");
    text = text.replace(/_\*_/g, "&");
    if (this.text == null) {
        this.text = this.content.createChild({
            tag: "label",
            'for': this.button.id,
            style: "position:absolute;left:20px;padding-left:2px",
            html: text
        });
        this.text.applyStyles("top:" + (this.height - this.text.getHeight()) / 2 + "px;");
        this.text.applyStyles("width:" + ((this.text.getWidth()) + 2) + "px;");
        this.text.on("click", function (e) {
            if (Author.response.removeType == "BEFORENEXT") {
                stopCurrentResponse();
            }
            else {
                if (Author.inResponse || Author.lessonFinished)
                    return;
            }
            e.stopPropagation();
        });
    }
    //this.text.dom.innerHTML = text;
}
CheckboxClass.prototype.setTop = function (y) {
    this.content.setStyle("top", y + "px");
}
CheckboxClass.prototype.setLeft = function (x) {
    this.content.setStyle("left", x + "px");
}
CheckboxClass.prototype.setWidth = function (width) {
    this.content.setWidth(width);
}
CheckboxClass.prototype.setHeight = function (height) {
    this.content.setHeight(height);
}
CheckboxClass.prototype.setVisible = function (visible) {
    this.visible = visible;
    this.content.setVisible(visible);
}
CheckboxClass.prototype.setBackgroundColor = function (color) {
    this.content.setStyle("background-color", color);
}
CheckboxClass.prototype.setForegroundColor = function (color) {
    this.content.setStyle("color", color);
}
CheckboxClass.prototype.setAlignmentH = function (alignment) {
    //center,left,right
    this.text.setStyle("text-align", alignment);
}
CheckboxClass.prototype.setStyle = function (CSSStyle) {
    this.content.applyStyles(CSSStyle);
}
CheckboxClass.prototype.remove = function () {
    this.content.remove();
}
/**
 * HotSpotClass
 * @param {Object} bgObject
 * @param {Object} cfgXML
 */
function HotSpotClass(bgObject, cfgXML, o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.objectType = "HOTSPOTOBJECT";
    this.isPrecedent = false;
    this.buttonType = trim(cfgXML.getElementsByTagName("buttonType")[0].childNodes[0].nodeValue);
    this.name = trim(cfgXML.getElementsByTagName("name")[0].childNodes[0].nodeValue);
    this.ddTarget = trim(cfgXML.getElementsByTagName("DDTarget")[0].childNodes[0].nodeValue).toLowerCase();
    this.responseTrigger = trim(cfgXML.getElementsByTagName("responseTrigger")[0].childNodes[0].nodeValue);
    this.value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
    try {
        this.generateFeedback = (trim(cfgXML.getElementsByTagName("generateFeedback")[0].childNodes[0].nodeValue).toLowerCase() == "true");
    }
    catch (err) {
        this.generateFeedback = false;
    }
    this.click = "unknow";
    try {
        this.click = trim(cfgXML.getElementsByTagName("click")[0].childNodes[0].nodeValue);
    }
    catch (err) {
    }
    try {
        this.dropMoveToX = parseInt(trim(cfgXML.getElementsByTagName("dropMoveToX")[0].childNodes[0].nodeValue));
        this.dropMoveToY = parseInt(trim(cfgXML.getElementsByTagName("dropMoveToY")[0].childNodes[0].nodeValue));
    }
    catch (err) {
        this.dropMoveToX = 0;
        this.dropMoveToY = 0;
    }
    this.respondToDrop = trim(cfgXML.getElementsByTagName("respondToDrop")[0].childNodes[0].nodeValue).toLowerCase();
    this.respondToMouseOver = trim(cfgXML.getElementsByTagName("respondToMouseOver")[0].childNodes[0].nodeValue).toLowerCase();
    this.responseValue = "nothing";
    if (this.respondToMouseOver == "true") {
        try {
            this.responseValue = trim(cfgXML.getElementsByTagName("responseValue")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.responseValue = "";
        }
    }
    this.content = bgObject.createChild({
        tag: "div",
        name: this.name,
        orginalValue: trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue),
        value: trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue),
        responseValue: this.responseValue,
        respondToDrop: this.respondToDrop,
        type: "HOTSPOT",
        style: "position:absolute;"
    });
    if (this.generateFeedback)
        this.content.setStyle("cursor", "pointer");
    //  addCondition(this.content.dom.name, this.content.dom.value);
    this.setStyle("position:absolute;display:block;background-color:#0c0;border:none;border-color:#000;opacity:0; filter: alpha(opacity=0);");
    this.visible = true;
}
HotSpotClass.prototype.setOnClickEvent = function (onClickEventHandler) {
    this.content.on("click", eval(onClickEventHandler));
}
HotSpotClass.prototype.checkPrecedence = function () {
    var listType = Author.current.currentListXML.attributes[0].nodeValue;
    if (listType == "INTERACTION") {
        if (this.ddTarget == "true" && this.respondToDrop == "false" && this.responseTrigger == "none") {
            this.isPrecedent = true;
            Author.current.precedentObject = this.objectType;
        }
    }
}
HotSpotClass.prototype.zorder = function (index) {
    this.content.setStyle("z-index", index);
}
HotSpotClass.prototype.readConfig = function (cfgXML) {
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.setTop(parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue)));
    this.setLeft(parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue)));
    this.setWidth(parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue)));
    this.setHeight(parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue)));
    this.hide = trim(cfgXML.getElementsByTagName("hide")[0].childNodes[0].nodeValue).toLowerCase();
    try {
        this.addToForeground = trim(cfgXML.getElementsByTagName("addToForeground")[0].childNodes[0].nodeValue).toLowerCase() == "true";
    }
    catch (err) {
        this.addToForeground = false;
    }
    if (this.buttonType != 0) {
        if (this.click == "GOTOMENUOPTION") {
            this.setOnClickEvent(function (e) {
                // if (Author.waitingMedia) 
                //  return;
                Author.Test.startAtRandom = false;
                e.stopEvent();
                // alert("GOTOMENUOPTION Clicked");
                var nextOptionID = parseInt(trim(cfgXML.getElementsByTagName("nextLessonNode")[0].childNodes[0].nodeValue));
                //alert("nextOptionID: "+nextOptionID);
                Author.current.currentElementXML = null;
                Author.current.currentElement = null;
                Author.current.currentElementType = "";
                Author.current.currentElementResponses.clear();
                Author.current.currentElementPosition = -1;
                Author.current.currentListPosition = 0;
                Author.response.clear();
                var tempNode = Author.lessonNodes.nodes.get(nextOptionID);
                if (typeof(tempNode) != 'undefined' && tempNode.id.toString() == nextOptionID.toString()) {
                    Author.current.currentNode = Author.lessonNodes.nodes.get(nextOptionID);
                    Author.current.currentNode.endListShown = false;
                }
                Author.goingToSubMenu = true;
                //  Author.current.currentElementResponses.clear();
                //Author.clearBackgroundObjects = true;
                showLessonNode();
            });
            if (this.respondToMouseOver == "true") {
                this.content.on("mouseover", function (e) {
                    if (Author.response.removeType == "BEFORENEXT") {
                        stopCurrentResponse();
                    }
                    else {
                        if (Author.inResponse || Author.lessonFinished)
                            return;
                    }
                    e.stopEvent();
                    var target = Ext.get(e.getTarget());
                    // alert(target.dom.name + " : " + target.dom.value);
                    var variable = target.dom.getAttribute("name");
                    var value = target.dom.getAttribute("responseValue");
                    //addCondition("ANSWER", "USERSELECT");
                    Author.variables.get(variableName('ANSWER')).setValue(value);
                    // alert(Author.current.currentElementType);
                    // Author.answers.multipleChoice.add(variable, value);
                    //alert("intoResponseFromMouseOver");
                    checkResponse();
                    return;
                });
            }
        }
        ;
        if (this.click == "TORESPONSE") {
            this.setOnClickEvent(function (e) {
                if (Author.response.removeType == "BEFORENEXT") {
                    stopCurrentResponse();
                }
                else {
                    if (Author.inResponse || Author.lessonFinished)
                        return;
                }
                e.stopEvent();
                // alert("toResponse");
                var target = Ext.get(e.getTarget());
                var container = Ext.get(target.dom.getAttribute("containerID"));
                var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
                Author.variables.get(variableName('SELECTEDVALUE')).setValue(value);
                Author.variables.get(variableName('SELECTEDNAME')).setValue(container.dom.getAttribute("name"));
                //alert(value+", "+ container.dom.getAttribute("name"));
                //var variable = trim(cfgXML.getElementsByTagName("variable")[0].childNodes[0].nodeValue);
                //var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
                Author.variables.get(variableName('ANSWER')).setValue(value);
                checkResponse();
                return;
            })
        }
        if (this.click == "SKIP") {
            this.setOnClickEvent(function (e) {
                e.stopEvent();
                Author.variables.get(variableName('SELECTEDVALUE')).setValue("SKIP");
                Author.variables.get(variableName('SELECTEDNAME')).setValue("SKIP");
                if (Author.pause != null && Author.pause.cancelType != 0) {
                    Author.pause = null;
                    //pauseVideoes();
                    window.clearTimeout(Author.actionTimer);
                }
                var listType = Author.current.currentListXML.attributes[0].nodeValue;
                if (listType == "INTRODUCTION") {
                    var actions = Author.current.currentListXML.getElementsByTagName("action");
                    Author.current.currentActionPosition = actions.length;
                    showList();
                    return;
                }
                else {
                    if (Author.current.currentNode.type != "MENU") {
                        Author.current.currentElementXML = null;
                        Author.current.currentElement = null;
                        Author.current.currentElementType = "";
                        Author.current.currentElementResponses.clear();
                        Author.response.clear();
                        Author.current.currentElementPosition++;
                        showLessonNode();
                        return;
                    }
                }
            })
        }
        if (this.click == "TOUPPERMENU") {
            this.setOnClickEvent(function (e) {
                // if (Author.waitingMedia) 
                // return;
                Author.Test.startAtRandom = false;
                e.stopEvent();
                // alert("TOUPPERMENU Clicked");
                Author.variables.get(variableName('SELECTEDVALUE')).setValue("TOUPPERMENU");
                Author.variables.get(variableName('SELECTEDNAME')).setValue("TOUPPERMENU");
                if (getParentNode() == 0)
                    return;
                Author.goingUpperMenu = true;
                while (Author.current.currentBgStack.getCount() > 0) {
                    var bgObject = Author.current.currentBgStack.last();
                    Author.current.currentBgStack.remove(bgObject);
                    if (Author.current.currentBgStack.getCount() == 0) {
                        Author.backgroundObject.setBg(bgObject);
                    }
                }
                //  Author.backgroundObject.setOriginal();
                Author.current.currentNode = Author.lessonNodes.nodes.get(getParentNode());
                Author.current.currentNode.endListShown = false;
                Author.current.currentElementXML = null;
                Author.current.currentElement = null;
                Author.current.currentElementType = "";
                Author.current.currentElementResponses.clear();
                Author.current.currentElementPosition = -1;
                Author.current.currentListPosition = 0;
                Author.response.clear();
                Author.current.currentElementResponses.clear();
                Author.clearBackgroundObjects = true;
                Author.backToMenu = true;
                showLessonNode();
            })
        }
        if (this.click == "TOMAINMENU") {
            this.setOnClickEvent(function (e) {
                //   if (Author.waitingMedia) 
                //  return;
                Author.Test.startAtRandom = false;
                e.stopEvent();
                Author.variables.get(variableName('SELECTEDVALUE')).setValue("TOMAINMENU");
                Author.variables.get(variableName('SELECTEDNAME')).setValue("TOMAINMENU");
                Author.backgroundObject.setOriginal();
                if (Author.current.currentNode.parent != 0) {
                    do {
                        Author.current.currentNode = Author.lessonNodes.nodes.get(getParentNode());
                        Author.current.currentNode.endListShown = false;
                        Author.goingUpperMenu = true;
                    }
                    while (Author.current.currentNode.parent != 0)
                }
                else {
                    showLessonNode();
                }
                Author.current.currentElementXML = null;
                Author.current.currentElement = null;
                Author.current.currentElementType = "";
                Author.current.currentElementResponses.clear();
                Author.current.currentElementPosition = -1;
                Author.current.currentListPosition = 0;
                Author.response.clear();
                Author.current.currentElementResponses.clear();
                Author.clearBackgroundObjects = true;
                Author.backToMenu = true;
                Author.goingUpperMenu = true;
                showLessonNode();
            })
        }
        if (this.click == "NEXT") {
            this.setOnClickEvent(function (e) {
                if (Author.lessonFinished) {
                    return;
                }
                e.stopEvent();
                Author.variables.get(variableName('SELECTEDVALUE')).setValue("NEXT");
                Author.variables.get(variableName('SELECTEDNAME')).setValue("NEXT");
                if (Author.pause != null) {//&& Author.pause.cancelType != 0
                    Author.pause = null;
                    // pauseVideoes();
                    window.clearTimeout(Author.actionTimer);
                    showList();
                }
                else {
                    if (Author.enableNextBtn == false)
                        return;
                    //alert("Next: "+ Author.variables.get(variableName('ANSWER')).value);
                    if (Author.current.currentListXML.attributes[0].nodeValue == "INTERACTION" || Author.lessonFlow == "repeat") {
                        makeAnswerVariable();
                    }
                    //alert("Next2: "+ Author.variables.get(variableName('ANSWER')).value);
                    if (Author.variables.get(variableName('ANSWER')).getValue() == null || Author.variables.get(variableName('ANSWER')).getValue() == "")
                        Author.variables.get(variableName('ANSWER')).setValue("NEXT");
                    //  alert("Next CLicked inner");
                    checkResponse();
                }
                //alert("Next CLicked");
            })
        }
        if (this.click == "BACK") {
            this.setOnClickEvent(function (e) {
                // if (Author.waitingMedia) 
                //  return;
                e.stopEvent();
                //  alert("BACK Clicked");
                Author.goingBack = true;
                Author.variables.get(variableName('SELECTEDVALUE')).setValue("BACK");
                Author.variables.get(variableName('SELECTEDNAME')).setValue("BACK");
                if (Author.pause != null && Author.pause.cancelType != 0) {
                    Author.pause = null;
                    window.clearTimeout(Author.actionTimer);
                }
                if (Author.current.currentElementXML != null) {
                    Author.current.currentElementPosition -= 1
                    Author.current.currentElementXML = null;
                    Author.current.currentElement = null;
                    if (Author.current.currentElementPosition < 0) {
                        Author.Test.startAtRandom = false;
                        if (getParentNode() == 0)
                            return;
                        Author.goingUpperMenu = true;
                        Author.current.currentNode = Author.lessonNodes.nodes.get(getParentNode());
                        Author.current.currentNode.endListShown = false;
                        while (Author.current.currentBgStack.getCount() > 0) {
                            var bgObject = Author.current.currentBgStack.last();
                            Author.current.currentBgStack.remove(bgObject);
                            if (Author.current.currentBgStack.getCount() == 0) {
                                Author.backgroundObject.setBg(bgObject);
                            }
                        }
                        //  Author.backgroundObject.setOriginal();
                        Author.current.currentElementXML = null;
                        Author.current.currentElement = null;
                        Author.current.currentElementType = "";
                        Author.current.currentElementResponses.clear();
                        Author.current.currentElementPosition = -1;
                        Author.current.currentListPosition = 0;
                        Author.clearBackgroundObjects = true;
                        Author.backToMenu = true;
                    }
                }
                else {
                    Author.current.currentListPosition -= 1;
                    if (Author.current.currentListPosition < 0) {
                        Author.current.currentNode = Author.lessonNodes.nodes.get(getParentNode());
                        Author.current.currentNode.endListShown = false;
                        Author.current.currentListPosition = 0;
                        Author.clearBackgroundObjects = true;
                    }
                }
                Author.responseEnd = true;
                Author.inResponse = false;
                Author.response.clear();
                Author.current.currentElementResponses.clear();
                showLessonNode();
                return;
            })
        }
        if (this.click == "EXITLESSON") {
            this.setOnClickEvent(function (e) {
                e.stopEvent();
                if (Author.pause != null && Author.pause.cancelType != 0) {
                    Author.pause = null;
                    window.clearTimeout(Author.actionTimer);
                }
                Author.mediaList.eachKey(function (key, object) {
                    if (Ext.isIE) {
                        try {
                            object.mediaObject.dom.controls.stop();
                            object.mediaObject.dom.settings.mute = true;
                        }
                        catch (err) {
                        }
                        ;
                    }
                });
                if (Author.exitConfirm) {
                    Ext.MessageBox.confirm('Exit the lesson', 'Do you really want to exit this lesson?', function (btn) {
                        if (btn == "yes") {
                            endLesson();
                        }
                    });
                }
                else {
                    endLesson();
                }
            })
        }
        if ((this.click == "CHECKRESPONSE")) {
            this.setOnClickEvent(function (e) {
                //  if (Author.waitingMedia) 
                //   return;
                if (Author.response.removeType == "BEFORENEXT") {
                    stopCurrentResponse();
                }
                else {
                    if (Author.inResponse || Author.lessonFinished)
                        return;
                }
                e.stopEvent();
                var listType = Author.current.currentListXML.attributes[0].nodeValue;
                if (!(listType == "MENUINTERACTION" || listType == "INTERACTION" || (Author.current.currentNode.type == "MENU" && listType == "RESPONSE"))) {
                    return;
                }
                var target = Ext.get(e.getTarget());
                var container = Ext.get(target.dom.getAttribute("containerID"));
                var value = trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue);
                Author.variables.get(variableName('SELECTEDVALUE')).setValue(value);
                Author.variables.get(variableName('SELECTEDNAME')).setValue(trim(cfgXML.getElementsByTagName("name")[0].childNodes[0].nodeValue));
                Author.variables.get(variableName('ANSWER')).setValue(value);
                checkResponse();
                return;
            });
            if (this.respondToMouseOver == "true") {
                this.content.on("mouseover", function (e) {
                    if (Author.response.removeType == "BEFORENEXT") {
                        stopCurrentResponse();
                    }
                    else {
                        if (Author.inResponse || Author.lessonFinished)
                            return;
                    }
                    e.stopEvent();
                    var target = Ext.get(e.getTarget());
                    // alert(target.dom.name + " : " + target.dom.value);
                    var variable = target.dom.getAttribute("name");
                    var value = target.dom.getAttribute("responseValue");
                    //addCondition("ANSWER", "USERSELECT");
                    Author.variables.get(variableName('ANSWER')).setValue(value);
                    // alert(Author.current.currentElementType);
                    // Author.answers.multipleChoice.add(variable, value);
                    //alert("intoResponseFromMouseOver");
                    checkResponse();
                    return;
                });
            }
        }
    }
    else {
        if (this.responseTrigger != "none") {
            this.content.on(this.responseTrigger, function (e) {
                if (Author.response.removeType == "BEFORENEXT") {
                    stopCurrentResponse();
                }
                else {
                    if (Author.inResponse || Author.lessonFinished)
                        return;
                }
                e.stopEvent();
                var target = Ext.get(e.getTarget());
                //   alert(target.dom.name + " : " + target.dom.value);
                var variable = target.dom.getAttribute("name");
                var value = target.dom.getAttribute("value");
                // alert(variable+ " : " + value);
                Author.variables.get(variableName('ANSWER')).setValue(value);
                Author.variables.get(variableName('SELECTEDVALUE')).setValue(value);
                Author.variables.get(variableName('SELECTEDNAME')).setValue(variable);
                // alert(Author.current.currentElementType);
                // Author.answers.multipleChoice.add(variable, value);
                var elementType = Author.current.currentElementXML.attributes[0].nodeValue;
                if (elementType == "MULTIPLECHOICE") {
                    var regex = /^[A|B|C|D|E|F|G|H]{1}$/;
                    var answer = value.toUpperCase();
                    if (regex.test(answer) == true) {
                        Author.answers.multipleChoice.add(answer, variable.toLowerCase());
                    }
                }
                else
                if (elementType == "YESNO") {
                    Author.answers.yesNo = value.toLowerCase();
                }
                else
                if (elementType == "TRUEFALSE") {
                    Author.answers.trueFalse = value.toLowerCase();
                }
                else {
                    //  makeAnswerVariable();
                }
                //alert("before hs check response");
                checkResponse();
                return;
            });
        }
        if (this.respondToMouseOver == "true") {
            this.content.on("mouseover", function (e) {
                if (Author.response.removeType == "BEFORENEXT") {
                    stopCurrentResponse();
                }
                else {
                    if (Author.inResponse || Author.lessonFinished)
                        return;
                }
                e.stopEvent();
                /*
                 if (Author.inResponse || Author.lessonFinished) {
                 stopCurrentResponse()

                 //alert("currentResponseiscanceled");
                 //return;
                 }
                 */
                var target = Ext.get(e.getTarget());
                // alert(target.dom.name + " : " + target.dom.value);
                var variable = target.dom.getAttribute("name");
                var value = target.dom.getAttribute("responseValue");
                //addCondition("ANSWER", "USERSELECT");
                Author.variables.get(variableName('ANSWER')).setValue(value);
                // alert(Author.current.currentElementType);
                // Author.answers.multipleChoice.add(variable, value);
                //alert("intoResponseFromMouseOver");
                checkResponse();
                return;
            });
        }
    }
    if (this.ddTarget == "true") {
        this.dropZone = new Ext.dd.DropZone(this.content.id, {
            ddGroup: 'group'
        });
        this.content.set({
            "content": "NOTHING",
            "dropMoveToX": this.dropMoveToX,
            "dropMoveToY": this.dropMoveToY
        });
    }
    if (this.buttonType == 0) {
        this.checkPrecedence();
    }
    if (this.addToForeground == true) {
        this.setVisible(this.hide == "false");
        Author.foregroundList.list.add(this.id, this);
        this.addToForegroundAtElementPosition = Author.current.currentElementPosition;
        this.zorder(100);
    }
    else {
        // this.zorder(70);
    }
    this.key1 = "none";
    this.key2 = "none";
    try {
        this.key1 = trim(cfgXML.getElementsByTagName("key1")[0].childNodes[0].nodeValue);
        this.key2 = trim(cfgXML.getElementsByTagName("key2")[0].childNodes[0].nodeValue);
        if (this.key1 != "none")
            Author.actionKeyMap.add(this.key1, this);
        if (this.key2 != "none")
            Author.actionKeyMap.add(this.key2, this);
    }
    catch (err) {
    }
    return 0;
}
HotSpotClass.prototype.setTop = function (y) {
    this.content.setStyle("top", y + "px");
}
HotSpotClass.prototype.setLeft = function (x) {
    this.content.setStyle("left", x + "px");
}
HotSpotClass.prototype.setWidth = function (width) {
    this.content.setWidth(width);
}
HotSpotClass.prototype.setHeight = function (height) {
    this.content.setHeight(height);
}
HotSpotClass.prototype.setVisible = function (visible) {
    this.visible = visible;
    this.content.setVisible(visible);
    if (visible) {
        try {
            if (this.key1 != "none")
                Author.actionKeyMap.add(this.key1, this);
            if (this.key2 != "none")
                Author.actionKeyMap.add(this.key2, this);
        }
        catch (err) {
        }
    }
}
HotSpotClass.prototype.setStyle = function (CSSStyle) {
    this.content.applyStyles(CSSStyle);
}
HotSpotClass.prototype.remove = function () {
    if (this.key1 != "none")
        Author.actionKeyMap.removeKey(this.key1);
    if (this.key2 != "none")
        Author.actionKeyMap.removeKey(this.key2);
    this.content.remove();
}
/**
 * DDButtonClass
 * @param {Object} bgObject
 */
function DDButtonClass(bgObject, cfgXML, o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.objectType = "DDUTTONOBJECT";
    this.imageName = trim(cfgXML.getElementsByTagName("image")[0].childNodes[0].nodeValue).toLowerCase();
    this.width = parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue));
    this.height = parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue));
    this.name = trim(cfgXML.getElementsByTagName("name")[0].childNodes[0].nodeValue);
    this.content = bgObject.createChild({
        tag: "div",
        name: this.name,
        value: trim(cfgXML.getElementsByTagName("value")[0].childNodes[0].nodeValue),
        miss: trim(cfgXML.getElementsByTagName("miss")[0].childNodes[0].nodeValue),
        style: "position:absolute"
    });
    try {
        this.hasText = trim(cfgXML.getElementsByTagName("hasText")[0].childNodes[0].nodeValue).toLowerCase() == "true";
    }
    catch (err) {
        this.hasText = false;
    }
    if (this.hasText) {
        try {
            this.textStr = trim(cfgXML.getElementsByTagName("text")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.textStr = "";
        }
        this.textStr = this.textStr.replace(/\&\&/g, "_*_");
        this.textStr = this.textStr.replace(/\&/g, "");
        this.textStr = this.textStr.replace(/_\*_/g, "&");
        this.textStr = this.textStr.replace(/ {2}/g, " &nbsp;");
        this.fontName = trim(cfgXML.getElementsByTagName("fontName")[0].childNodes[0].nodeValue);
        this.foreColor = trim(cfgXML.getElementsByTagName("foreColor")[0].childNodes[0].nodeValue);
        this.fontBold = trim(cfgXML.getElementsByTagName("fontBold")[0].childNodes[0].nodeValue).toLowerCase() == "true";
        this.fontItalic = trim(cfgXML.getElementsByTagName("fontItalic")[0].childNodes[0].nodeValue).toLowerCase() == "true";
        this.fontUnderline = trim(cfgXML.getElementsByTagName("fontUnderline")[0].childNodes[0].nodeValue).toLowerCase() == "true";
        this.fontSize = parseInt(trim(cfgXML.getElementsByTagName("fontSize")[0].childNodes[0].nodeValue));
        this.textAlignment = parseInt(trim(cfgXML.getElementsByTagName("textAlignment")[0].childNodes[0].nodeValue));
        this.textX = parseInt(trim(cfgXML.getElementsByTagName("textX")[0].childNodes[0].nodeValue));
        this.textY = parseInt(trim(cfgXML.getElementsByTagName("textY")[0].childNodes[0].nodeValue));
        var textStyle = "font-family:" + this.fontName + ";";
        textStyle = textStyle + "font-size:" + this.fontSize + "pt;";
        textStyle = textStyle + "font-style:" + (this.fontItalic ? "italic" : "normal") + ";";
        textStyle = textStyle + "font-weight:" + (this.fontBold ? "bold" : "normal") + ";";
        textStyle = textStyle + "text-decoration:" + (this.fontUnderline ? "underline" : "none") + ";";
        textStyle = textStyle + "color:" + this.foreColor// + ";padding:1px 1px 1px 1px";
        this.textStyle = textStyle;
        this.text = this.content.createChild({
            tag: "div",
            style: "position:absolute"
        });
        this.p = this.text.createChild({
            tag: "div",
            style: "position:absolute;" + textStyle,
            html: replaceVariableNameWithValue(this.textStr)
        });
    }
    this.content.setStyle("z-index", 75);
    this.image = null;
    this.visible = true;
}
DDButtonClass.prototype.readConfig = function (cfgXML) {
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.setImage(Author.resourcePath + this.imageName);
    this.content.setStyle("cursor", "pointer");
    this.top = parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue))
    this.setTop(this.top);
    this.left = parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue));
    this.setLeft(this.left);
    this.setWidth(this.width);
    this.setHeight(this.height);
    if (this.hasText && this.textStr != "") {
        this.setTextPosition(this.textAlignment);
    }
    this.content.set({
        "orginalX": parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue)),
        "orginalY": parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue))
    });
    this.content.dd = new Ext.dd.DDProxy(this.content, 'group');
    //set the drag constraints so that the dragging object will not go off screen.
    this.content.dd.setXConstraint(this.left, Author.lessonWidth - this.width - this.left);
    this.content.dd.setYConstraint(this.top, Author.lessonHeight - this.height - this.top);
    return 0;
}
DDButtonClass.prototype.setTextPosition = function (index) {
    //start tochange..
    switch (index) {
        case 0: //left
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            //this.text.setLeft(0);
            //this.text.setTop(0);
            this.p.setStyle("text-align", "left");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop(0);
            this.p.setLeft(0);
            break;
        case 1:
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            this.p.setStyle("text-align", "left");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop((this.text.getHeight() - this.p.getHeight()) / 2);
            this.p.setLeft(0);
            break;
        case 2:
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            this.p.setStyle("text-align", "left");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop((this.text.getHeight() - this.p.getHeight()));
            this.p.setLeft(0);
            break;
        case 3: //right
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            //this.text.setLeft(0);
            // this.text.setTop(0);
            this.p.setStyle("text-align", "right");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop(0);
            // this.p.setLeft(this.text.getWidth() - this.p.getWidth());
            this.p.setLeft(0);
            break;
        case 4:
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            this.p.setStyle("text-align", "right");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop((this.text.getHeight() - this.p.getHeight()) / 2);
            // this.p.setLeft(this.text.getWidth() - this.p.getWidth());
            this.p.setLeft(0);
            break;
        case 5:
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            this.p.setStyle("text-align", "right");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop((this.text.getHeight() - this.p.getHeight()));
            // this.p.setLeft(this.text.getWidth() - this.p.getWidth());
            this.p.setLeft(0);
            break;
        case 6://center
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            // this.text.setLeft(0);
            // this.text.setTop(0);
            this.p.setStyle("text-align", "center");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop(0);
            //this.p.setLeft((this.text.getWidth() - this.p.getWidth()) / 2);
            this.p.setLeft(0);
            break;
        case 7:
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            this.p.setStyle("text-align", "center");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop((this.text.getHeight() - this.p.getHeight()) / 2);
            // this.p.setLeft((this.text.getWidth() - this.p.getWidth()) / 2);
            this.p.setLeft(0);
            break;
        case 8:
            this.text.setLeft(this.textX);
            this.text.setTop(this.textY);
            this.p.setStyle("text-align", "center");
            this.text.setWidth(this.content.getWidth() - (this.text.getLeft() - this.content.getLeft()));
            this.text.setHeight(this.content.getHeight() - (this.text.getTop() - this.content.getTop()));
            this.p.setWidth(this.text.getWidth() - (this.text.getLeft() - this.content.getLeft() - this.textX));
            this.p.setTop((this.text.getHeight() - this.p.getHeight()));
            //this.p.setLeft((this.text.getWidth() - this.p.getWidth()) / 2);
            this.p.setLeft(0);
            break;
    }
}
DDButtonClass.prototype.setImage = function (url) {
    if (this.image == null) {
        this.image = this.content.createChild({
            id: "buttonImage",
            tag: "img",
            alt: '',
            width: this.width,
            height: this.height
            //  style: "alt:''"
        });
    }
    this.image.dom.src = eval(Ext.encode(url));
    this.fixPng();
}
DDButtonClass.prototype.fixPng = function () {
    var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
    var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
    if (Ext.isIE && (ie55 || ie6) && (this.imageName.indexOf(".png") >= 0)) {
        this.image.setStyle("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + Author.resourcePath + this.imageName + "',sizingMethod='image')");
        this.image.dom.src = "lib/images/blank.gif";
    }
}
DDButtonClass.prototype.setTop = function (y) {
    this.content.setStyle("top", y + "px");
}
DDButtonClass.prototype.setLeft = function (x) {
    this.content.setStyle("left", x + "px");
}
DDButtonClass.prototype.setWidth = function (width) {
    this.content.setWidth(width);
}
DDButtonClass.prototype.setHeight = function (height) {
    this.content.setHeight(height);
}
DDButtonClass.prototype.setVisible = function (visible) {
    this.visible = visible;
    this.content.setVisible(visible);
}
DDButtonClass.prototype.setStyle = function (CSSStyle) {
    this.content.applyStyles(CSSStyle);
}
DDButtonClass.prototype.setMouseOverEvent = function (mouseOverEventHandler) {
    this.content.on("mouseover", mouseOverEventHandler);
}
DDButtonClass.prototype.setMouseOutEvent = function (mouseOutEventHandler) {
    this.content.on("mouseout", eval(mouseOutEventHandler));
}
DDButtonClass.prototype.setOnClickEvent = function (onClickEventHandler) {
    this.content.on("click", onClickEventHandler);
}
DDButtonClass.prototype.remove = function () {
    this.content.remove();
}
function FlashClass(bgObject, cfgXML, o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.objectType = "FLASHOBJECT";
    this.width = parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue));
    this.height = parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue));
    this.url = trim(cfgXML.getElementsByTagName("movie")[0].childNodes[0].nodeValue);
    this.type = trim(cfgXML.getElementsByTagName("type")[0].childNodes[0].nodeValue);
    try {
        this.flashVars = this.parseFlashVars(trim(cfgXML.getElementsByTagName("flashVars")[0].childNodes[0].nodeValue));
        this.checkResponse = (trim(cfgXML.getElementsByTagName("checkResponse")[0].childNodes[0].nodeValue)).toLowerCase() == true;
        Author.doFlashResponse = function (param) {
            Author.variables.get(variableName('FLASHRESULT')).setValue(param);
            //  Author.doFlashResponse.check = ((trim(cfgXML.getElementsByTagName("checkResponse")[0].childNodes[0].nodeValue)).toLowerCase() == "true");
            if (((trim(cfgXML.getElementsByTagName("checkResponse")[0].childNodes[0].nodeValue)).toLowerCase() == "true")) {
                checkResponse();
            }
            //Author.doFlashResponse = null;
        }
    }
    catch (err) {
        this.flashVars = "";
    }
    if (this.type == "WWW")
        this.url = eval(Ext.encode(this.url.toLowerCase()));
    else {
        this.url = eval(Ext.encode(Author.resourcePath + this.url.toLowerCase()));
    }
    this.content = bgObject.createChild({
        tag: "div",
        style: "position:absolute;"
    });
    this.mediaID = this.content.dom.id + "-Flash";
    try {
        this.flashObject = this.content.createChild({
            tag: "OBJECT",
            objectType: "FlashObject",
            classid: "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
            codebase: "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0",
            width: this.width,
            height: this.height,
            align: "",
            children: [
                {
                    tag: "PARAM",
                    NAME: "movie",
                    VALUE: this.url
                },
                {
                    tag: "PARAM",
                    NAME: "WMODE",
                    VALUE: "opaque"
                },
                {
                    tag: "PARAM",
                    NAME: "AllowScriptAccess",
                    VALUE: "always"
                },
                {
                    tag: "PARAM",
                    NAME: "FlashVars",
                    VALUE: this.flashVars
                },
                {
                    tag: "embed",
                    src: this.url,
                    WMODE: "opaque",
                    width: this.width,
                    height: this.height,
                    type: "application/x-shockwave-flash",
                    AllowScriptAccess: "always",
                    swLiveConnect: "true",
                    FlashVars: this.flashVars,
                    pluginspage: "http://www.macromedia.com/go/getflashplayer"
                }
            ]
        });
    }
    catch (err) {
        alert(err.description);
    }
}
FlashClass.prototype.parseFlashVars = function (varIDs) {
    var flashVars = "";
    var ids = varIDs.split("|");
    for (var i = 0; i < ids.length; i++) {
        var aID = "0000".substr(0, 4 - ids[i].length) + ids[i];
        var vName = Author.variables.get(aID).name;
        flashVars += "&" + (vName) + "=" + getVariableValueByName(vName);
    }
    return (flashVars.substr(1));
}
FlashClass.prototype.readConfig = function (cfgXML) {
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.content.setStyle("position", "absolute");
    this.setTop(parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue)));
    this.setLeft(parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue)));
    this.setWidth(parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue)));
    this.setHeight(parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue)));
    try {
        this.content.setStyle("border-style", trim(cfgXML.getElementsByTagName("borderStyle")[0].childNodes[0].nodeValue));
        this.content.setStyle("border-width", trim(cfgXML.getElementsByTagName("borderWidth")[0].childNodes[0].nodeValue));
        this.content.setStyle("border-color", trim(cfgXML.getElementsByTagName("borderColor")[0].childNodes[0].nodeValue));
    }
    catch (err) {
        alert("FlashElement:\n" + err.description);
    }
    this.setVisible(true);
    return 0;
}
FlashClass.prototype.toFront = function () {
    this.content.setStyle("z-index", 65);
}
FlashClass.prototype.setTop = function (y) {
    this.content.setStyle("top", y + "px");
}
FlashClass.prototype.setLeft = function (x) {
    this.content.setStyle("left", x + "px");
}
FlashClass.prototype.setWidth = function (width) {
    this.content.setWidth(width);
}
FlashClass.prototype.setHeight = function (height) {
    this.content.setHeight(height);
}
FlashClass.prototype.setVisible = function (visible) {
    this.visible = visible;
    this.content.setVisible(visible);
}
FlashClass.prototype.remove = function () {
    this.content.remove();
}
function FLVVideoClass(bgObject, cfgXML, o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.objectType = "FLVVideo";
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.width = parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue));
    this.height = parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue));
    this.top = parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue));
    this.left = parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue));
    this.flv = trim(cfgXML.getElementsByTagName("flv")[0].childNodes[0].nodeValue);
    this.autoStart = (trim(cfgXML.getElementsByTagName("autoStart")[0].childNodes[0].nodeValue).toLowerCase() == "true");
    this.showController = (trim(cfgXML.getElementsByTagName("showController")[0].childNodes[0].nodeValue).toLowerCase() == "true");
    try {
        this.stopsPreviousAudio = (trim(cfgXML.getElementsByTagName("stopsPreviousAudio")[0].childNodes[0].nodeValue).toLowerCase() == "true");
    }
    catch (err) {
        this.stopsPreviousAudio = false;
    }
    try {
        this.hideUntilClicked = (trim(cfgXML.getElementsByTagName("hideUntilClicked")[0].childNodes[0].nodeValue).toLowerCase() == "true");
    }
    catch (err) {
        this.hideUntilClicked = false;
    }
    this.cancelType = parseInt(cfgXML.getElementsByTagName("cancelType")[0].childNodes[0].nodeValue);
    this.waitUntilFinish = (trim(cfgXML.getElementsByTagName("waitUntilFinish")[0].childNodes[0].nodeValue).toLowerCase() == "true");
    this.type = trim(cfgXML.getElementsByTagName("type")[0].childNodes[0].nodeValue);
    this.flashVars = "";
    if (this.type == "WWW")
        this.flv = eval(Ext.encode(this.flv.toLowerCase()));
    else {
        this.flv = eval(Ext.encode(Author.resourcePath + this.flv.toLowerCase()));
    }
    this.HTASettings = {
        firstPlay: false
    };
    //	alert(Author.isHTML5 +", "+Author.isFlash9);
    if (Author.isHTML5 && !Author.isFlash9) {
        this.content = bgObject.createChild({
            tag: "div",
            style: "background-color:#000;position:absolute;left:" + this.left + "px;top:" + this.top + "px;width:" + this.width + "px;height:" + this.height + "px"

        });
        this.mediaID = this.content.dom.id + "-Media";
        Author.mediaList.eachKey(function (key, object) {
            try {
                if (object.objectType == "SOUNDOBJECT") {
                    if (this.stopsPreviousAudio) {
                        var theAudioObject = document.getElementById(object.mediaID);
                        theAudioObject.pause();
                    }
                }
            }
            catch (err) {
            }
            try {
                var theAudioObject = document.getElementById(object.mediaID);
                theAudioObject.stop();
            }
            catch (err) {
            }
        });
        this.videoObject = this.content.createChild({
            tag: "Video",
            id: this.mediaID,
            controls: "controls",
            style: "position:absolute:left:0px;top:0px;width:100%;height:100%",
            ap: this.autoStart,
            "autobuffer": "autobuffer"
        })
        Author.mediaList.add(this.id, this);
        return;
    }
    Author.mediaList.eachKey(function (key, object) {
        if (object.objectType == "FLVVideo") {
            object.stopVideo();
        }
    });
    this.content = bgObject.createChild({
        tag: "div",
        style: "position:absolute;"
    });
    this.content.setStyle("position", "absolute");
    this.setTop(this.top);
    this.setLeft(this.left);
    this.setWidth(this.width);
    this.setHeight(this.height);
    this.mediaID = this.content.dom.id + "-FLVVideo";
    //  Author.soundObjIDMap.add(this.content.dom.id, this.id);
    // alert(this.flv);
    if (this.type == "WWW") {
        this.flashVars = 'file=' + this.flv + '&id=' + this.mediaID + '&autostart=' + this.autoStart + '&showcontroller=' + this.showController + '&playerready=flvReady&completed=' + (this.waitUntilFinish ? 'flvFinished' : '');
    }
    else {
        this.flashVars = 'file=../../' + this.flv + '&id=' + this.mediaID + '&autostart=' + this.autoStart + '&showcontroller=' + this.showController + '&playerready=flvReady&completed=' + (this.waitUntilFinish ? 'flvFinished' : '');
    }
    this.flashVars = this.flashVars + "&alwayshidecontroller=" + this.hideUntilClicked;
    Author.mediaList.add(this.id, this);
    Author.flvIDMap.add(this.mediaID, this.id);
}
FLVVideoClass.prototype.stop = function () {
    this.stopVideo();
}
FLVVideoClass.prototype.stopVideo = function () {
    var player = this.FlvPlayer();
    try {
        player.stopVideo();
    }
    catch (err) {
    }
}
FLVVideoClass.prototype.readConfig = function (cfgXML) {
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    if (Author.isHTML5 && !Author.isFlash9) {
        Author.listStarted = false;
        Author.current.currentPlayingWMPObject = this.videoObject;
        Author.waitAudioFinish = (this.waitUntilFinish);
        this.videoObject.addListener('canplaythrough', function (e) {
            //  alert("canplaythrough");
            var video = e.target;
            var countDown = (video.duration - video.currentTime) * 1000;
            var autoPlay = (video.getAttribute('ap').toLowerCase() == 'true');
            if (autoPlay) {
                video.play();
            }
            if (Author.waitAudioFinish) {
                window.clearTimeout(Author.actionTimer);
                Author.pause = {
                    cancelType: 0,
                    startTime: new Date(),
                    id: 0,
                    key1: "none",
                    key2: "none"
                }
                Author.pause.countDown = countDown;
                // alert("set sound countDown: " + countDown / 1000 + " secs.\nWait until finish: " + Author.waitAudioFinish);
                Author.actionTimer = setTimeout(showList, countDown);
            }
            else {
                if (!Author.listStarted) {
                    Author.listStarted = true;
                    Author.pause = null;
                    window.clearTimeout(Author.actionTimer);
                    Author.actionTimer = setTimeout(showList, 10);
                }
            }
        });
        this.videoObject.addListener('play', function (e) {
            // alert("play");
            var video = e.target;
            var countDown = (video.duration - video.currentTime) * 1000;
            if (Author.waitAudioFinish) {
                window.clearTimeout(Author.actionTimer);
                Author.pause = {
                    cancelType: 0,
                    startTime: new Date(),
                    id: 0,
                    key1: "none",
                    key2: "none"
                }
                Author.pause.countDown = countDown;
                //  alert("set sound countDown: " + countDown / 1000 + " secs.\nWait until finish: " + Author.waitAudioFinish);
                Author.actionTimer = setTimeout(showList, countDown);
            }
            else {
                if (!Author.listStarted) {
                    Author.listStarted = true;
                    Author.pause = null;
                    window.clearTimeout(Author.actionTimer);
                    Author.actionTimer = setTimeout(showList, 10);
                }
            }
        });
        this.videoObject.addListener('error', function (e) {
            alert("Can't play video[html5]: " + e.target.src);
            Author.listStarted = true;
            window.clearTimeout(Author.actionTimer);
            Author.actionTimer = setTimeout(showList, 10);
        })
        this.flv = this.flv.replace(/\.flv/i, ".mp4");
        this.videoObject.set({
            src: this.flv
        });
        var theAudioObject = document.getElementById(this.mediaID);
        var autoStart = this.autoStart;
        setTimeout(function () {
            //theAudioObject.loop=false;
            theAudioObject.load();
            if (autoStart == 'true') {
                setTimeout(function () {
                    theAudioObject.play();
                    //theAudioObject.loop = false;
                    //alert(theAudioObject.loop);
                }, 500)
            }
        }, 500);
        if (Author.isAuthorViewer() && !this.waitUntilFinish) {
            Author.listStarted = true;
            return 10;
        }
        /*
         setTimeout(function(){
         theAudioObject.load();
         }, 500);
         if (this.autoStart == 'true') {
         setTimeout(function(){
         theAudioObject.play();
         }, 500);
         }
         */
        return 3600 * 24 * 1000;
    }
    try {
        this.flashObject = this.content.createChild({
            tag: "OBJECT",
            id: this.mediaID,
            name: this.mediaID,
            objectType: "FlashObject",
            classid: "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
            codebase: "http://download.macromedia.com/pub/shockwave /cabs/flash/swflash.cab#version=9,0,115,0",
            width: this.width,
            height: this.height,
            align: "",
            children: [
                {
                    tag: "PARAM",
                    NAME: "movie",
                    VALUE: "lib/media/videoPlayer.swf"
                },
                {
                    tag: "PARAM",
                    NAME: "WMODE",
                    VALUE: "opaque"
                },
                {
                    tag: "PARAM",
                    NAME: "AllowScriptAccess",
                    VALUE: "always"
                },
                {
                    tag: "PARAM",
                    NAME: "Allowfullscreen",
                    VALUE: "true"
                },
                {
                    tag: "PARAM",
                    NAME: "FlashVars",
                    VALUE: this.flashVars
                },
                {
                    tag: "embed",
                    src: "lib/media/videoPlayer.swf",
                    name: this.mediaID,
                    id: this.mediaID,
                    WMODE: "opaque",
                    width: this.width,
                    height: this.height,
                    type: "application/x-shockwave-flash",
                    AllowScriptAccess: "always",
                    Allowfullscreen: "true",
                    swLiveConnect: "true",
                    FlashVars: this.flashVars,
                    pluginspage: "http://www.macromedia.com/go/getflashplayer"
                }
            ]
        });
    }
    catch (err) {
    }
    Author.mediaList.add(this.id, this);
    Author.flvIDMap.add(this.mediaID, this.id);
    this.setVisible(true);
    if (document.URL.search("file://") >= 0) {
        if (Author.isHTA) {
            return 3600 * 24 * 1000;
        }
        else {
            //alert("000");
            //simulate a pause if run from local file system.
            if (this.waitUntilFinish) {
                var cancelType;
                switch (this.cancelType) {
                    case 0:
                        //mouse only
                        cancelType = 3;
                        break;
                    case 1:
                        //anykey
                        cancelType = 2;
                        break;
                    case 2:
                        //key or mouse
                        cancelType = 1;
                        break;
                    case 3:
                        //nothing
                        cancelType = 0;
                        break;
                }
                var countDown = 3600 * 24 * 365;
                window.clearTimeout(Author.actionTimer);
                Author.pause = {
                    cancelType: cancelType,
                    startTime: new Date(),
                    id: -2,
                    key1: "none",
                    key2: "none"
                }
                Author.pause.countDown = countDown;
                //alert(Author.pause);
                //Author.actionTimer = setTimeout(showList, countDown);
                return 3600 * 24 * 365;
            }
            else {
                return 0;
            }
        }
    }
    else {
        return 3600 * 24 * 1000;
    }
}
function flvPlayerStateChange(e) {
    var flvObjectID = Author.flvIDMap.get(e.id);
    var flvObject = Author.mediaList.get(flvObjectID);
    // flvObject.stopsPreviousAudio=true;
    if (Ext.isIE) {
        //alert("setFocus");
        Author.backgroundObject.getContent().focus();
    }
    switch (e.newstate) {
        case "PLAYING":
            // alert(Author.isHTA);
            if (Ext.isIE && !Author.isFlash9) {
                Author.mediaList.eachKey(function (key, object) {
                    if (object.objectType == "MEDIAOBJECT") {
                        try {
                            object.mediaObject.dom.controls.stop();
                            object.mediaObject.dom.settings.mute = true;
                        }
                        catch (err) {
                        }
                    }
                    if (object.objectType == "SOUNDOBJECT") {
                        if (flvObject.stopsPreviousAudio) {
                            object.stop();
                        }
                    }
                });
                //alert(Author.isHTA);
                if (Author.isHTA) {
                    //alert("htaPlay");
                    if (flvObject.HTASettings.firstPlay) {
                        flvObject.HTASettings.firstPlay = false;
                        window.clearTimeout(Author.actionTimer);
                        setTimeout(function () {
                            showList();
                        }, 10);
                    }
                }
            }
            else {
                Author.mediaList.eachKey(function (key, object) {
                    if (object.objectType == "MEDIAOBJECT") {
                        try {
                            object.mediaObject.dom.children[0].controls.stop();
                            object.mediaObject.dom.children[0].settings.mute = true;
                        }
                        catch (err) {
                        }
                    }
                    if (object.objectType == "SOUNDOBJECT") {
                        if (flvObject.stopsPreviousAudio) {
                            object.stop();
                        }
                    }
                });
                if (Author.isHTA) {
                    //alert("htaPlay");
                    if (flvObject.HTASettings.firstPlay) {
                        flvObject.HTASettings.firstPlay = false;
                        window.clearTimeout(Author.actionTimer);
                        setTimeout(function () {
                            showList();
                        }, 10);
                    }
                }
            }
            break;
    }
}
function flvReady(evt) {
    var flvObjectID = Author.flvIDMap.get(evt.id);
    var flvObject = Author.mediaList.get(flvObjectID);
    if (flvObject.waitUntilFinish) {
        var cancelType;
        switch (flvObject.cancelType) {
            case 0://mouse only
                cancelType = 3;
                break;
            case 1://anykey
                cancelType = 2;
                break;
            case 2://key or mouse
                cancelType = 1;
                break;
            case 3://nothing
                cancelType = 0;
                break;
        }
        var countDown = 3600 * 24 * 365;
        window.clearTimeout(Author.actionTimer);
        Author.pause = {
            cancelType: cancelType,
            startTime: new Date(),
            id: -2,
            key1: "none",
            key2: "none"
        }
        Author.pause.countDown = countDown;
        //alert(Author.pause);
        Author.actionTimer = setTimeout(showList, countDown);
    }
    else {
        // alert("ready");
        if (document.URL.search("file://") >= 0) {
            if (Author.isHTA) {
                if (flvObject.autoStart) {
                    flvObject.HTASettings.firstPlay = true;
                    return;
                }
                window.clearTimeout(Author.actionTimer);
                setTimeout(function () {
                    showList();
                }, 10);
            }
            else {
                return;
            }
        }
        else {
            window.clearTimeout(Author.actionTimer);
            setTimeout(function () {
                showList();
            }, 10);
        }
    }
}
function flvFinished(evt) {
    if (Author.pause != null && Author.pause.id == -2) {
        Author.pause = null;
        window.clearTimeout(Author.actionTimer);
        showList();
    }
}
FLVVideoClass.prototype.setTop = function (y) {
    this.content.setStyle("top", y + "px");
}
FLVVideoClass.prototype.setLeft = function (x) {
    this.content.setStyle("left", x + "px");
}
FLVVideoClass.prototype.setWidth = function (width) {
    this.content.setWidth(width);
}
FLVVideoClass.prototype.setHeight = function (height) {
    this.content.setHeight(height);
}
FLVVideoClass.prototype.setVisible = function (visible) {
    this.visible = visible;
    this.content.setVisible(visible);
}
FLVVideoClass.prototype.toFront = function () {
    //alert("ToFront");
    this.content.setStyle("z-index", 65);
}
FLVVideoClass.prototype.remove = function () {
    if (Author.isHTML5) {
        Author.mediaList.removeKey(this.id);
        this.content.remove();
        return;
    }
    try {
        Author.flvIDMap.removeKey(this.mediaID);
        this.stopVideo();
        Author.mediaList.removeKey(this.id);
        this.content.remove();
    }
    catch (err) {
        //alert(err.description);
    }
}
FLVVideoClass.prototype.FlvPlayer = function () {
    if (Ext.isIE)
        return Ext.getDom(this.mediaID);
    else {
        try {
            return Ext.getDom(this.mediaID).children[5];
        }
        catch (err) {
            return null;
        }
    }
}
function flvDebug(test) {
}
function DrawingClass(bgObject, cfgXML, o) {
    this.LogicalOrder = (typeof(o) != 'undefined') ? o : null;
    this.objectType = "Drawing";
    this.id = trim(cfgXML.getElementsByTagName("id")[0].childNodes[0].nodeValue);
    this.width = parseInt(trim(cfgXML.getElementsByTagName("width")[0].childNodes[0].nodeValue));
    this.height = parseInt(trim(cfgXML.getElementsByTagName("height")[0].childNodes[0].nodeValue));
    this.top = parseInt(trim(cfgXML.getElementsByTagName("top")[0].childNodes[0].nodeValue));
    this.left = parseInt(trim(cfgXML.getElementsByTagName("left")[0].childNodes[0].nodeValue));
    this.newVersion = false;
    try {
        this.newVersion = (trim(cfgXML.getElementsByTagName("isNewGraphic")[0].childNodes[0].nodeValue).toLowerCase() == "true");
    }
    catch (err) {
        this.newVersion = false;
    }
    this.newVersion = false; //For CFA only.... 
    this.shapeType = parseInt(trim(cfgXML.getElementsByTagName("shapeType")[0].childNodes[0].nodeValue));
    if (this.newVersion) {
        try {
            this.LX1V = trim(cfgXML.getElementsByTagName("LX1V")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.LX1V = "";
        }
        try {
            this.LY1V = trim(cfgXML.getElementsByTagName("LY1V")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.LY1V = "";
        }
        try {
            this.LX2V = trim(cfgXML.getElementsByTagName("LX2V")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.LX2V = "";
        }
        try {
            this.LY2V = trim(cfgXML.getElementsByTagName("LY2V")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.LY2V = "";
        }
        try {
            this.RXV = trim(cfgXML.getElementsByTagName("RXV")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.RXV = "";
        }
        try {
            this.RYV = trim(cfgXML.getElementsByTagName("RYV")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.RYV = "";
        }
        try {
            this.RWV = trim(cfgXML.getElementsByTagName("RWV")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.RWV = "";
        }
        try {
            this.RHV = trim(cfgXML.getElementsByTagName("RHV")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.RHV = "";
        }
        try {
            this.ECXV = trim(cfgXML.getElementsByTagName("ECXV")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.ECXV = "";
        }
        try {
            this.ECYV = trim(cfgXML.getElementsByTagName("ECYV")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.ECYV = "";
        }
        try {
            this.ERXV = trim(cfgXML.getElementsByTagName("ERXV")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.ERXV = "";
        }
        try {
            this.ERYV = trim(cfgXML.getElementsByTagName("ERYV")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.ERYV = "";
        }
        try {
            this.SCXV = trim(cfgXML.getElementsByTagName("SCXV")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.SCXV = "";
        }
        try {
            this.SCYV = trim(cfgXML.getElementsByTagName("SCYV")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.SCYV = "";
        }
        try {
            this.SRXV = trim(cfgXML.getElementsByTagName("SRXV")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.SRXV = "";
        }
        try {
            this.SRYV = trim(cfgXML.getElementsByTagName("SRYV")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.SRYV = "";
        }
        try {
            this.SAV = trim(cfgXML.getElementsByTagName("SAV")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.SAV = "";
        }
        try {
            this.EAV = trim(cfgXML.getElementsByTagName("EAV")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.EAV = "";
        }
        ///////
        try {
            this.LX1N = trim(cfgXML.getElementsByTagName("LX1N")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.LX1N = "";
        }
        try {
            this.LY1N = trim(cfgXML.getElementsByTagName("LY1N")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.LY1N = "";
        }
        try {
            this.LX2N = trim(cfgXML.getElementsByTagName("LX2N")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.LX2N = "";
        }
        try {
            this.LY2N = trim(cfgXML.getElementsByTagName("LY2N")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.LY2N = "";
        }
        try {
            this.RXN = trim(cfgXML.getElementsByTagName("RXN")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.RXN = "";
        }
        try {
            this.RYN = trim(cfgXML.getElementsByTagName("RYN")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.RYN = "";
        }
        try {
            this.RWN = trim(cfgXML.getElementsByTagName("RWN")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.RWN = "";
        }
        try {
            this.RHN = trim(cfgXML.getElementsByTagName("RHN")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.RHN = "";
        }
        try {
            this.ECXN = trim(cfgXML.getElementsByTagName("ECXN")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.ECXN = "";
        }
        try {
            this.ECYN = trim(cfgXML.getElementsByTagName("ECYN")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.ECYN = "";
        }
        try {
            this.ERXN = trim(cfgXML.getElementsByTagName("ERXN")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.ERXN = "";
        }
        try {
            this.ERYN = trim(cfgXML.getElementsByTagName("ERYN")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.ERYN = "";
        }
        try {
            this.SCXN = trim(cfgXML.getElementsByTagName("SCXN")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.SCXN = "";
        }
        try {
            this.SCYN = trim(cfgXML.getElementsByTagName("SCYN")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.SCYN = "";
        }
        try {
            this.SRXN = trim(cfgXML.getElementsByTagName("SRXN")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.SRXN = "";
        }
        try {
            this.SRYN = trim(cfgXML.getElementsByTagName("SRYN")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.SRYN = "";
        }
        try {
            this.SAN = trim(cfgXML.getElementsByTagName("SAN")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.SAN = "";
        }
        try {
            this.EAN = trim(cfgXML.getElementsByTagName("EAN")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.EAN = "";
        }
        this.content = bgObject.createChild({
            tag: "div",
            style: "position:absolute;left:0px;top:0px;width:" + Author.lessonWidth + "px;height:" + Author.lessonHeight + "px;"//border: solid 1px #dddddd"
        });
        this.paper = Raphael(this.content.dom, Author.lessonWidth, Author.lessonHeight);
        //this.setSize();
    }
    else {
        this.content = bgObject.createChild({
            tag: "div",
            style: "position:absolute;left:" + this.left + "px;top:" + this.top + "px;width:" + this.width + "px;height:" + this.height + "px;"//border: solid 1px #dddddd"
        });
        this.paper = Raphael(this.content.dom, this.width, this.height);
        try {
            this.X1 = trim(cfgXML.getElementsByTagName("X1")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.X1 = 1;
        }
        try {
            this.Y1 = trim(cfgXML.getElementsByTagName("Y1")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.Y1 = 1;
        }
        try {
            this.X2 = trim(cfgXML.getElementsByTagName("X2")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.X2 = this.width - 1;
        }
        try {
            this.Y2 = trim(cfgXML.getElementsByTagName("Y2")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.Y2 = this.height - 1;
        }
        try {
            this.CX = trim(cfgXML.getElementsByTagName("CX")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.CX = this.width / 2 - 1;
        }
        try {
            this.CY = trim(cfgXML.getElementsByTagName("CY")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.CY = this.height / 2 - 1;
        }
        try {
            this.RX = trim(cfgXML.getElementsByTagName("RX")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.RX = this.width / 2 - 1;
        }
        try {
            this.RY = trim(cfgXML.getElementsByTagName("RY")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.RY = this.height / 2 - 1;
        }
        try {
            this.SA = trim(cfgXML.getElementsByTagName("SA")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.sa = 0;
        }
        try {
            this.EA = trim(cfgXML.getElementsByTagName("EA")[0].childNodes[0].nodeValue);
        }
        catch (err) {
            this.EA = 360;
        }
    }
    this.visible = true;
}
DrawingClass.prototype.toFront = function () {
    this.content.setStyle("z-index", 65);
}
DrawingClass.prototype.readConfig = function (cfgXML) {
    this.color = trim(cfgXML.getElementsByTagName("color")[0].childNodes[0].nodeValue);
    this.fillColor = trim(cfgXML.getElementsByTagName("fillColor")[0].childNodes[0].nodeValue);
    this.lineWidth = parseInt(trim(cfgXML.getElementsByTagName("lineWidth")[0].childNodes[0].nodeValue));
    this.fill = (trim(cfgXML.getElementsByTagName("fill")[0].childNodes[0].nodeValue).toLowerCase() == "true");
    this.fillOpacity = trim(cfgXML.getElementsByTagName("fillOpactiy")[0].childNodes[0].nodeValue);
    if (this.newVersion) {
        this.shape = this.drawShapeNew();
    }
    else {
        this.shape = this.drawShape();
    }
    this.shape.attr({
        stroke: this.color,
        "stroke-width": this.lineWidth
    })
    if (this.fill) {
        this.shape.attr({
            fill: this.fillColor,
            "fill-opacity": this.fillOpacity
        })
    }
    return 0;
}
DrawingClass.prototype.drawShapeNew = function () {
    switch (this.shapeType) {
        case 0:
            var p1, q1, p2, q2;
            if (this.LX1V.length > 0) {
                p1 = parseFloat(replaceVariableNameWithValue(this.LX1V));
            }
            else {
                p1 = parseFloat(this.LX1N);
            }
            if (this.LY1V.length > 0) {
                q1 = parseFloat(replaceVariableNameWithValue(this.LY1V));
            }
            else {
                q1 = parseFloat(this.LY1N);
            }
            if (this.LX2V.length > 0) {
                p2 = parseFloat(replaceVariableNameWithValue(this.LX2V));
            }
            else {
                p2 = parseFloat(this.LX2N);
            }
            if (this.LY2V.length > 0) {
                q2 = parseFloat(replaceVariableNameWithValue(this.LY2V));
            }
            else {
                q2 = parseFloat(this.LY2N);
            }
            return this.line(p1, q1, p2, q2);
            break;
        case 1:
            var x, y, w, h;
            if (this.RXV.length > 0) {
                x = parseFloat(replaceVariableNameWithValue(this.RXV));
            }
            else {
                x = parseFloat(this.RXN);
            }
            if (this.RYV.length > 0) {
                y = parseFloat(replaceVariableNameWithValue(this.RYV));
            }
            else {
                y = parseFloat(this.RYN);
            }
            if (this.RWV.length > 0) {
                w = parseFloat(replaceVariableNameWithValue(this.RWV));
            }
            else {
                w = parseFloat(this.RWN);
            }
            if (this.RHV.length > 0) {
                h = parseFloat(replaceVariableNameWithValue(this.RHV));
            }
            else {
                h = parseFloat(this.RHN);
            }
            return this.rect(x, y, w, h);
            break;
        case 2:
            var cx, cy, rx, ry;
            if (this.ECXV.length > 0) {
                cx = parseFloat(replaceVariableNameWithValue(this.ECXV));
            }
            else {
                cx = parseFloat(this.ECXN);
            }
            if (this.ECYV.length > 0) {
                cy = parseFloat(replaceVariableNameWithValue(this.ECYV));
            }
            else {
                cy = parseFloat(this.ECYN);
            }
            if (this.ERXV.length > 0) {
                rx = parseFloat(replaceVariableNameWithValue(this.ERXV));
            }
            else {
                rx = parseFloat(this.ERXN);
            }
            if (this.ERYV.length > 0) {
                ry = parseFloat(replaceVariableNameWithValue(this.ERYV));
            }
            else {
                ry = parseFloat(this.ERYN);
            }
            return this.ellipse(cx, cy, rx, ry);
            break;
        case 3:
            var cx, cy, rx, ry, sa, ea;
            if (this.SCXV.length > 0) {
                cx = parseFloat(replaceVariableNameWithValue(this.SCXV));
            }
            else {
                cx = parseFloat(this.SCXN);
            }
            if (this.SCYV.length > 0) {
                cy = parseFloat(replaceVariableNameWithValue(thisSCYV));
            }
            else {
                cy = parseFloat(this.SCYN);
            }
            if (this.SRXV.length > 0) {
                rx = parseFloat(replaceVariableNameWithValue(this.SRXV));
            }
            else {
                rx = parseFloat(this.SRXN);
            }
            if (this.SRYV.length > 0) {
                ry = parseFloat(replaceVariableNameWithValue(this.SRYV));
            }
            else {
                ry = parseFloat(this.SRYN);
            }
            if (this.SAV.length > 0) {
                sa = parseFloat(replaceVariableNameWithValue(this.SAV));
            }
            else {
                sa = parseFloat(this.SAN);
            }
            if (this.EAV.length > 0) {
                ea = parseFloat(replaceVariableNameWithValue(this.EAV));
            }
            else {
                ea = parseFloat(this.EAN);
            }
            return this.sector(cx, cy, rx, ry, sa, ea);
            break;
    }
}
DrawingClass.prototype.drawShape = function () {
    switch (this.shapeType) {
        case 0:
            var x1 = parseFloat(replaceVariableNameWithValue(this.X1));
            var y1 = parseFloat(replaceVariableNameWithValue(this.Y1));
            var x2 = parseFloat(replaceVariableNameWithValue(this.X2));
            var y2 = parseFloat(replaceVariableNameWithValue(this.Y2));
            return this.line(x1, y1, x2, y2);
            break;
        case 1:
            var x1 = parseFloat(replaceVariableNameWithValue(this.X1));
            var y1 = parseFloat(replaceVariableNameWithValue(this.Y1));
            var x2 = parseFloat(replaceVariableNameWithValue(this.X2));
            var y2 = parseFloat(replaceVariableNameWithValue(this.Y2));
            return this.rect(x1, y1, x2 - x1, y2 - y1);
            break;
        case 2:
            var cx = parseFloat(replaceVariableNameWithValue(this.CX));
            var cy = parseFloat(replaceVariableNameWithValue(this.CY));
            var rx = parseFloat(replaceVariableNameWithValue(this.RX));
            var ry = parseFloat(replaceVariableNameWithValue(this.RY));
            return this.ellipse(cx, cy, rx, ry);
            break;
        case 3:
            var cx = parseFloat(replaceVariableNameWithValue(this.CX));
            var cy = parseFloat(replaceVariableNameWithValue(this.CY));
            var rx = parseFloat(replaceVariableNameWithValue(this.RX));
            var ry = parseFloat(replaceVariableNameWithValue(this.RY));
            var sa = parseFloat(replaceVariableNameWithValue(this.SA));
            while (sa > 360) {
                sa -= 360;
            }
            var ea = parseFloat(replaceVariableNameWithValue(this.EA));
            while (ea > 360) {
                ea -= 360;
            }
            return this.sector(cx, cy, rx, ry, sa, ea);
            break;
    }
}
DrawingClass.prototype.line = function (x1, y1, x2, y2) {
    var path = "M" + x1 + " " + y1 + "L" + x2 + " " + y2;
    var shape = this.paper.path(path);
    return shape;
}
DrawingClass.prototype.rect = function (x1, y1, x2, y2) {
    var shape = this.paper.rect(x1, y1, x2, y2);
    return shape;
}
DrawingClass.prototype.ellipse = function (cx, cy, rx, ry) {
    var shape = this.paper.ellipse(cx, cy, rx, ry);
    return shape;
}
DrawingClass.prototype.sector = function (cx, cy, rx, ry, startAngle, endAngle) {
    var rad = Math.PI / 180;
    var x1 = cx + rx * Math.cos(-startAngle * rad);
    var x2 = cx + rx * Math.cos(-endAngle * rad);
    var y1 = cy + ry * Math.sin(-startAngle * rad);
    var y2 = cy + ry * Math.sin(-endAngle * rad);
    //alert("CX:"+cx+"\nCY:"+cy+"\nX1:"+x1+"\nY1:"+y1+"\nX2:"+x2+"\nY2:"+y2+"\nRX:"+rx+"\nRY:"+ry);
    //var shape = this.paper.path(["M",x1,y1,"L",x2,y2]);
    var shape = this.paper.path(["M", cx, cy, "L", x1, y1, "A", rx, ry, 0, +(endAngle - startAngle > 180), 0, x2, y2, "z"]);
    return shape;
}
DrawingClass.prototype.sectorR = function (cx, cy, startRad, endRad, startAngle, endAngle) {
    var rad = Math.PI / 180;
    var x1 = cx + startRad * Math.cos(-startAngle * rad);
    var x2 = cx + startRad * Math.cos(-endAngle * rad);
    var y1 = cy + startRad * Math.sin(-startAngle * rad);
    var y2 = cy + startRad * Math.sin(-endAngle * rad);
    var x3 = cx + endRad * Math.cos(-startAngle * rad);
    var x4 = cx + endRad * Math.cos(-endAngle * rad);
    var y3 = cy + endRad * Math.sin(-startAngle * rad);
    var y4 = cy + endRad * Math.sin(-endAngle * rad);
    return this.paper.path(["M", x1, y1, "A", startRad, startRad, 0, +(endAngle - startAngle > 180), 0, x2, y2, "L", x4, y4, "A", endRad, endRad, 0, +(endAngle - startAngle > 180), 1, x3, y3, "Z"]);
}
DrawingClass.prototype.setVisible = function (visible) {
    this.visible = visible;
    this.content.setVisible(visible);
}
DrawingClass.prototype.remove = function () {
    this.content.remove();
}

