
/* global _object */

var loadBitmapObject = null;
var loadBitmapObject2 = null;

var _SlideImageCatalog = '';
var tabImage = [],noLastImage = -1;

var _TObjectIdentifier = 0;
var alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
var randomAlphabet = alphabet;

var timeOutList = [];

function SizeTable(ar){
    if (typeof ar === 'string')
	return 0;
    if (typeof ar.length === 'undefined' || ar.length === null)
	return 0;
    if (typeof ar[0].length === 'undefined' || ar[0].length === null)
	return 1;
    if (typeof ar[0][0].length === 'undefined' || ar[0][0].length === null)
	return 2;
    if (typeof ar[0][0][0].length === 'undefined' || ar[0][0][0].length === null)
	return 3;
    return 0;
}

function TableToString(tab){
    if (typeof tab !== 'undefined' && tab !== null)
    {
	var n = SizeTable(tab);
	var txt = '[]',i,j,k;
	if (n == 0)
	{
	    if (typeof tab === 'string' && tab.length === 0)
		tab = '[]';
	    else
		txt = tab;
	}
	if (n == 1)
	{
	    txt = '[' + tab + ']';
	}
	if (n == 2)
	{
	    txt = '[';
	    for (i = 0;i < tab.length;i++)
	    {
		if (i > 0)
		    txt = txt + ',';
	        txt = txt + '[';
		for (j = 0;j < tab[0].length;j++)
		{
		    if (j > 0)
			txt = txt + ',';    
		    txt = txt + tab[i][j];
		}
	        txt = txt + ']';		
	    }
	    txt = txt + ']';
	}
	if (n == 3)
	{
	    txt = '[';
	    for (i = 0;i < tab.length;i++)
	    {
		if (i > 0)
		    txt = txt + ',';
	        txt = txt + '[';
		for (j = 0;j < tab[i].length;j++)
		{
		    if (j > 0)
			txt = txt + ',';    
	 	    txt = txt + '[';
		    for (k = 0;k < tab[i][j].length;k++)
		    {
			if (k > 0)
			    txt = txt + ',';    
			txt = txt + tab[i][j][k];
		    }
	 	    txt = txt + ']';
		}
	        txt = txt + ']';		
	    }
	    txt = txt + ']';
	}
    }
    return txt;
}


function GetFontNumner(font,style,weight)
{
    var i,n = fontsThreePointer.length;
    
    for (i = 0;i < n;i++)
    {
        if (fontsThreePointer[i].data.familyName === font && fontsThreePointer[i].data.cssFontStyle === style && fontsThreePointer[i].data.cssFontWeight === weight)
            return i;
   }
   return 0;

}

function AddTimeOut(pointer)
{
    var i,n = timeOutList.length;
    for (i = 0;i < n;i++)
    {
        if (timeOutList[i] === null)
        {
            timeOutList[i] = pointer;
            return i;
        }
    }
    timeOutList[n] = pointer;
    return n;
}

function RemoveTimeOut(number)
{
    if (typeof number !== 'undefined' && number !== null)
    {
        if (number >= 0 && number < timeOutList.length)
            timeOutList[number] = null;
    }
}

function RemoveAllTimeOut()
{
    var i,n = timeOutList.length;
    for (i = 0;i < n;i++)
    {
        if (timeOutList[i] !== null)
        {
            clearTimeout(timeOutList[i]);
        }
    }
    timeOutList = [];
}

function IsInt(n) {
    if(!isNaN(parseInt(n)))
    {
        var tmp = parseFloat(n);
        if (tmp === Math.round(tmp))
            return true;
    }
    return false;
}

function FindTag(tags)
{
    if (tags !== null)
    {
        var i;
        for (i = 0;i < tags.length;i++)
        {
            if (tags[i] !== null);
                return tags[i];
        }
    }
    return null;
}

function FindTags(tags)
{
    if (tags !== null)
    {
        var i,tags_ = [],j=0;
        for (i = 0;i < tags.length;i++)
        {
            if (tags[i] !== null);
                tags_[j++] = tags[i];
        }
        return tags_;
    }
    return null;
}

function RandomString(number)
{
    var txt = '',i;
    for (i = 0;i < number;i++)
    {
        txt = txt + randomAlphabet[Math.floor(Math.random() * randomAlphabet.length)];
    }
    return txt;
}

function TObject(){

    TObject.prototype.InitConstructor = function(){
        
        this.type = 'TObject';
        this.objectManager = null;
        this.identifier = _TObjectIdentifier++;
        this.parent = null;
    };
    this.InitConstructor();

    
    TObject.prototype.InitConstructor2 = function(){
    };
    
    TObject.prototype.Init = function(_object){
        this.SetType(_object.GetType());
        if (typeof _object !== 'undefined' && _object !== null)
        {
            if (typeof _object.objectManager !== 'undefined' && _object.objectManager !== null && _object.objectManager.IsType('TObjectManager'))
                this.objectManager = _object.objectManager;
            if (typeof _object.parent !== 'undefined' && _object.parent !== null && _object.parent.IsType('TObject'))
                this.parent = _object.parent;
        }
    };


    TObject.prototype.SetType = function(_type){
        if (typeof _type === 'undefined' && _type !== null)
            return;
        this.type = new String(_type).toString();
    };


    TObject.prototype.GetType = function(){
        if (typeof this.type !== 'undefined' && this.type !== null)
            return new String(this.type).toString();
        else
            return null;
    };


    TObject.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === 'TObject')
                return true;
            else
                return false;
        }else
            return false;
    };


    TObject.prototype.GetIdentifier = function(){
       if (typeof this.identifier !== 'undefined' && this.identifier !== null)
            return this.identifier;
        else
            return -1;
    };

    TObject.prototype.SetObjectManager = function(objManager){
       if (typeof objManager !== 'undefined')
            this.objectManager = objManager;
        else
            this.objectManager =  null;
    };

    TObject.prototype.GetObjectManager = function(){
       if (typeof this.objectManager !== 'undefined')
            return this.objectManager;
        else
            return null;
    };

    TObject.prototype.SetParent = function(parent_){
        if (typeof parent_ !== 'undefined' && parent_ !== null && parent_.IsType('TObject'))
        {
            this.parent = parent_;
        }
    };

    TObject.prototype.GetParent= function(){
        return this.parent;
    };

}

function TObjectMultilanguage(){
    
    var type = 'TObjectMultilanguage';
    TObjectMultilanguage.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        
        this.SetType(type);
        this.languageManager = null;
        this.defaultLanguage = null;
            
    };
    this.InitConstructor();



    TObjectMultilanguage.prototype.Init = function(_object){
        TObject.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TObjectMultilanguage'))
        {
            if (typeof _object.languageManager !== 'undefined' && _object.languageManager !== null && _object.languageManager.IsType('TMultilanguageManager'))
                this.languageManager = _object.languageManager;
            if (typeof _object.defaultLanguage !== 'undefined' && _object.defaultLanguage !== null)
            {
                this.defaultLanguage = new String(_object.defaultLanguage);
                this.defaultLanguage = this.defaultLanguage.toString();
            }   
        }
    };

    TObjectMultilanguage.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };

    TObjectMultilanguage.prototype.SetLanguageManager = function(manager){
        if (typeof manager !== 'undefined' && manager !== null && manager.IsType('TMultilanguageManager'))
        {
            this.languageManager = manager;
        }
        if (manager === null)
            this.languageManager = null;
    };

    TObjectMultilanguage.prototype.NumberLanguage = function(language){
        if (this.languageManager !== null)
        {
            return this.languageManager.NumberLanguage(language);
        }
        return null;
    };

    TObjectMultilanguage.prototype.ChangeCurrentLanguageNumber = function(_language){
    };

    TObjectMultilanguage.prototype.SetDefaultLanguage = function(_language){
        if (typeof _language !== 'undefined' && _language !== null)
        {
            this.defaultLanguage = new String(_language);
            this.defaultLanguage = this.defaultLanguage.toString();
        }   
        if (_language === null)
            this.defaultLanguage = null;
    };

    TObjectMultilanguage.prototype.GetDefaultLanguage = function(){
        return this.defaultLanguage;
    };

    TObjectMultilanguage.prototype.GetCurrentLanguage = function(){
        if (typeof this.languageManager !== 'undefined' && this.languageManager !== null && this.languageManager.IsType('TMultilanguageManager'))
            return this.languageManager.GetCurrentLanguage();
        else
            return null;
    };
    
    TObjectMultilanguage.prototype.GetCurrentNameLanguage = function(){
        if (typeof this.languageManager !== 'undefined' && this.languageManager !== null && this.languageManager.IsType('TMultilanguageManager'))
            return this.languageManager.GetCurrentNameLanguage();
        else
            return null;
    };

}

TObjectMultilanguage.prototype = new TObject();

function TListElement(){
    var type = 'TListElement';
    TListElement.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        
        this.object = null;
        this.nextElement = null;
        this.prevElement = null;
        this.SetType(type);
            
    };
    this.InitConstructor();

    TListElement.prototype.Init = function(_object){
        //TODO: Implement Me 
        TObject.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TListElement') && objM !== null)
        {
            this.object = objM.copy(_object.object);
            this.nextElement = null;
            this.prevElement = null;
        }
    };


    TListElement.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };

    TListElement.prototype.AddObject = function(ob){
        if (typeof ob !== 'undefined')
        {
            if (ob === null)
                this.object = null;
            else
            {
                if (ob.IsType('TObject'))
                    this.object = ob;
            }
        }
    };

    TListElement.prototype.GetObject = function(){
        return this.object;
    };

}

TListElement.prototype = new TObject();


function TList(){
    var type = 'TList';
    TList.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        
        this.lastElement = null;
        this.firstElement = null;
        this.currentElement = null;
        this.SetType(type);
            
    };
    this.InitConstructor();

    TList.prototype.Init = function(_object){
        TObject.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TList'))
        {
            this.lastElement = null;
            this.firstElement = null;
            this.currentElement = null;
        }
    };

    TList.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };

    TList.prototype.Add = function(ob){
        var objM = this.GetObjectManager();
        if (typeof objM !== 'undefined' && objM !== null)
        {
            var element = objM.newObject('TListElement');
            if (element !== null)
            {
                element.AddObject(ob);
                if (this.firstElement === null)
                {
                    this.firstElement = element;
                    this.lastElement = element;
                }else
                {
                    if (this.currentElement === null)
                        this.currentElement = this.firstElement;
                    
                    element.prevElement = this.currentElement;
                    if (this.currentElement.nextElement === null)
                    {
                        this.lastElement = element;
                    }else
                    {
                        element.nextElement = this.currentElement.nextElement;
                        if (this.currentElement.nextElement !== null)
                            this.currentElement.nextElement.prevElement = element;
                    }
                    this.currentElement.nextElement = element;
                }
                this.currentElement = element;
            }
        }
    };

    TList.prototype.GetData = function(){
        if (this.currentElement !== null)
        {
            return this.currentElement.GetObject();
        }
        return null;
    };

    TList.prototype.First = function(){
        this.currentElement = this.firstElement;
        return this.currentElement;
    };

    TList.prototype.Last = function(){
        this.currentElement = this.lastElement;
        return this.currentElement;
    };

    TList.prototype.Next = function(){
        if (this.currentElement !== null)
            this.currentElement = this.currentElement.nextElement;
        return this.currentElement;
    };

    TList.prototype.Previous = function(){
        if (this.currentElement !== null)
            this.currentElement = this.currentElement.prevElement;
        return this.currentElement;
    };
}

TList.prototype = new TObject();

function TSynchronization(){

    var type = 'TSynchronization';
    TSynchronization.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        
        this.table = [];
        this.counter = 0;
        this.fun = null;
        this.SetType(type);
    };
    this.InitConstructor();
    
    TSynchronization.prototype.Init = function(_object){
        TObject.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TStringData'))
        {
            var i;
            if (typeof _object.table !== 'undefined' && _object.table !== null)
            {
                for (i = 0;i < _object.table.length;i++)
                    this.table[i] = _object.table[i];
            }
            if (typeof _object.counter !== 'undefined' && _object.counter !== null && IsInt(_object.counter))
                this.counter = _object.counter;
            if (typeof _object.fun !== 'undefined' && _object.fun !== null)
                this.fun = _object.fun;
        }
    };

    TSynchronization.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };

    TSynchronization.prototype.SetTrue = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0)
        {
            this.table[number] = true;
            return number;
        }else
        {
            number = this.table.length;
            this.table[number] = true;
            return number;
        }
    };

    TSynchronization.prototype.SetFalse = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0)
            this.table[number] = false;
    };

    TSynchronization.prototype.Get = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0 && number < this.table.length)
            return this.table[number];
        var i;
        for (i = 0;i < this.table.length;i++)
        {
            if (typeof this.table[i] !== 'undefined' && this.table[i] !== null && this.table[i] === true)
                return true;
        }
        return false;
    };

    TSynchronization.prototype.IncCounter = function(){
        this.counter++;
    };

    TSynchronization.prototype.DecCounter = function(){
        this.counter--;
        if (this.counter === 0 && this.fun !== null)
            this.fun();
        if (this.counter < 0)
            this.counter = 0;
    };

    TSynchronization.prototype.IsZero = function(){
        if (this.counter <= 0)
            return true;
        else
            return false;
    };

    TSynchronization.prototype.SetFun = function(fun_){
        if (typeof fun_ !== 'undefined')
            this.fun = fun_;
    };

}

TSynchronization.prototype = new TObject();

function TStringData(){

    var type = 'TStringData';
    TStringData.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        
        this.data = null;
        this.SetType(type);
    };
    this.InitConstructor();
    
    TStringData.prototype.Init = function(_object){
        TObject.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TStringData'))
        {
            if (typeof _object.data !== 'undefined' && _object.data !== null)
                this.data = _object.GetStringData();
        }
    };

    TStringData.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };

    TStringData.prototype.SetStringData = function(_data){
        if (typeof _data === 'undefined')
            return;
        this.data = new String(_data);
        this.data = this.data.toString();
    };

    TStringData.prototype.GetStringData = function(){
        return new String(this.data).toString();
    };

}

TStringData.prototype = new TObject();

function TMultilanguageStringData(){

    var type = 'TMultilanguageStringData';
    TMultilanguageStringData.prototype.InitConstructor = function(){
        TObjectMultilanguage.prototype.InitConstructor.call(this);
        
        this.data = null;
        this.languageData = [];
        this.SetType(type);
    };
    this.InitConstructor();
    
    TMultilanguageStringData.prototype.Init = function(_object){
        TObjectMultilanguage.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TMultilanguageStringData'))
        {
            if (typeof _object.data !== 'undefined' && _object.data !== null && _object.data.IsType('TStringData'))
                this.data = objM.copy(_object.data);
            if (typeof _object.languageData !== 'undefined' && _object.languageData !== null)
            {
                var i;            
                this.languageData = [];
                for (i = 0;i < _object.languageData.length;i++)
                    this.languageData[i] = objM.copy(_object.languageData[i]);
            }
        }
    };

    TMultilanguageStringData.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectMultilanguage.prototype.IsType.call(this,_type);
    };

    TMultilanguageStringData.prototype.SetStringData = function(_data,_language){
        if (typeof _data === 'undefined')
            return;
        var objM = this.GetObjectManager();
        var lang = _language;
        if (typeof lang === 'undefined' || lang === null)
        {
            lang = this.GetCurrentNameLanguage();
        }
        if (typeof lang !== 'undefined' && lang !== null)
        {           
            var number = this.NumberLanguage(lang);
            if (number === null && this.GetDefaultLanguage() !== null)
                number = this.NumberLanguage(this.GetDefaultLanguage());
            if (number !== null && IsInt(number) && number >= 0)
            {
                if (objM !== null)
                {
                    this.languageData[number] =  objM.newObject('TStringData');
                    if (this.languageData[number] !== null)
                        this.languageData[number].SetStringData(_data);
                    var number2 = this.NumberLanguage();
                    if (number2 < 0 || number === number2)
                        this.data = this.languageData[number];
                }
            }
        }
    };

    TMultilanguageStringData.prototype.GetStringData = function(_language){
        if (typeof _language !== 'undefined' && _language !== null)
        {           
            var number = this.NumberLanguage(_language);
            if (number !== null && IsInt(number) && number >= 0)
                if (this.languageData !== null && this.languageData.length > number)
                    return this.languageData[number].GetStringData();
        }else
        {
            if (typeof this.data !== 'undefined' && this.data !== null)
                return this.data.GetStringData();
            else
                return null;
        }
        return null;
    };

    TMultilanguageStringData.prototype.GetData = function(_language){
        if (typeof _language !== 'undefined' && _language !== null)
        {           
            var number = this.NumberLanguage(_language);
            if (number !== null && IsInt(number) && number >= 0)
                if (this.languageData !== null && this.languageData.length > number)
                    return this.languageData[number];
        }else
        {
            if (this.data !== null)
                return this.data;
            else
                return null;
        }
        return null;
    };

    TMultilanguageStringData.prototype.ChangeCurrentLanguageNumber = function(_language){
        if (typeof _language !== 'undefined' && _language !== null && IsInt(_language) && _language >= 0 && this.languageData.length > _language)
        {           
            this.data = this.languageData[_language];
        }
    };
};

TMultilanguageStringData.prototype = new TObjectMultilanguage();

function TListString(){
    var type = 'TListString';
    TListString.prototype.InitConstructor = function(){
        TList.prototype.InitConstructor.call(this);
        this.SetType(type);            
    };
    this.InitConstructor();

    TListString.prototype.Init = function(_object){
        TList.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TListString'))
        {
        }
    };

    TListString.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TList.prototype.IsType.call(this,_type);
    };

    TListString.prototype.AddString = function(str){
        if (typeof str !== 'undefined' && str !== null)
        {
            var objM = this.GetObjectManager();
            if (objM !== null)
            {   
                var tmp = objM.newObject('TStringData');
                tmp.SetStringData(str);
                TList.prototype.Add.call(this,tmp);
            }
        }
    };
}

TListString.prototype = new TList();

function TListMultilanguageObject(){
    var type = 'TListMultilanguageObject';
    TListMultilanguageObject.prototype.InitConstructor = function(){
        TList.prototype.InitConstructor.call(this);
        this.SetType(type);            
    };
    this.InitConstructor();

    TListMultilanguageObject.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TList.prototype.IsType.call(this,_type);
    };

    TListMultilanguageObject.prototype.Init = function(_object){
        TList.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TListMultilanguageObject'))
        {
        }
    };

    TListMultilanguageObject.prototype.ChangeCurrentLanguageNumber = function(_language){
        if (typeof _language !== 'undefined')
        {
            var elem,object;
            for (elem = this.First();elem !== null;elem = this.Next())
            {
                if(elem !== null)
                {
                    object = elem.GetObject();
                    if (typeof object !== 'undefined' && object !== null && object.IsType('TObjectMultilanguage'))
                    {
                        object.ChangeCurrentLanguageNumber(_language);
                    }
                }
            }
           
        }
    };

}

TListMultilanguageObject.prototype = new TList();



function TVariable(){
    var type = 'TVariable';
    TVariable.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        this.SetType(type);   
        this.name = null;
        this.id = null;
        this.width = -1;
        this.valueEquation = null;
        this.calculate = false;
    };
    this.InitConstructor();

    TVariable.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };

    TVariable.prototype.Init = function(_object){
        TObject.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TVariable'))
        {
            if (typeof _object.calculate !== 'undefined' && _object.calculate !== null)
                this.calculate = _object.calculate;
            if (typeof _object.name !== 'undefined' && _object.name !== null)
            {
                this.name = new String(_object.name);
                if (this.name !== null)
                    this.name = this.name.toString();
            }
            if (typeof _object.id !== 'undefined' && _object.id !== null)
            {
                this.id = new String(_object.id);
                if (this.id !== null)
                    this.id = this.id.toString();
            }
            if (typeof _object.width !== 'undefined' && _object.width !== null && IsInt(_object.width))
                this.width = _object.width;
            if (typeof _object.valueEquation !== 'undefined' && _object.valueEquation !== null)
            {
                this.valueEquation = new String(_object.valueEquation);
                if (this.valueEquation !== null)
                    this.valueEquation = this.valueEquation.toString();
            }
        }
    };


    TVariable.prototype.ReadXML = function(tag,fun){
        if (typeof tag !== 'undefined' && tag !== null)
        {
            var tmp = tag.getAttribute('name');
            if (typeof tmp !== 'undefined' && tmp !== null)
                this.name = tmp;
//            tmp = tag.getAttribute('id');
//            if (typeof tmp !== 'undefined' && tmp !== null)
//                this.id = tmp;
            tmp = tag.getAttribute('width');
            if (typeof tmp !== 'undefined' && tmp !== null && IsInt(tmp))
                this.width = parseInt(tmp);
            tmp = tag.getAttribute('calculate');
            if (typeof tmp !== 'undefined' && tmp !== null && tmp === "True")
            {
                this.calculate = true;
                tmp = tag.getAttribute('value');
                if (typeof tmp !== 'undefined' && tmp !== null)
                    this.valueEquation = tmp;
	    }else
                this.calculate = false;
        }
    };

    TVariable.prototype.SetName = function(name_){
        if (typeof name_ !== 'undefined' && name_ !== null)
        {
            this.name = new String(name_);
            if (this.name !== null)
                this.name = this.name.toString();
        }
    };

    TVariable.prototype.GetName = function(){
        var  tmp = new String(this.name);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TVariable.prototype.GetId = function(){
        var tmp = new String(this.id);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TVariable.prototype.GetWidth = function(){
        return this.width;
    };

    TVariable.prototype.GetValue = function(){
        return null;
    };

    TVariable.prototype.GetValueString = function(){
        return this.GetValue();
    };

    TVariable.prototype.SetValue= function(value_){
/*        if (typeof value_ !== 'undefined' && value_ !== null)
        {
            var tmp = new String(value_);
            if (tmp !== null)
                this.valueEquation = tmp.toString();
        }
        if (value_ === null)
            this.valueEquation = null;*/
    };

    TVariable.prototype.SetEquation = function(eq){
        if (typeof eq !== 'undefined' && eq !== null)
        {
            this.valueEquation = new String(eq);
            if (this.valueEquation !== null)
                this.valueEquation = this.valueEquation.toString();
        }
    };

    TVariable.prototype.GetEquation = function(){
        var tmp = new String(this.valueEquation);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

}

TVariable.prototype = new TObject();

function TVariableNumeric(){
    var type = 'TVariableNumeric';
    TVariableNumeric.prototype.InitConstructor = function(){
        TVariable.prototype.InitConstructor.call(this);
        this.SetType(type);  
    };
    this.InitConstructor();

    TVariableNumeric.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TVariable.prototype.IsType.call(this,_type);
    };

    TVariableNumeric.prototype.Init = function(_object){
        TVariable.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TVariableNumeric'))
        {
        }
    };

    TVariableNumeric.prototype.ReadXML = function(tag,fun){
        TVariable.prototype.ReadXML.call(this,tag,fun);
        if (typeof tag !== 'undefined' && tag !== null)
        {
        }
    };
    
}

TVariableNumeric.prototype = new TVariable();

function TVariableInt(){
    var type = 'TVariableInt';
    TVariableInt.prototype.InitConstructor = function(){
        TVariableNumeric.prototype.InitConstructor.call(this);
        this.SetType(type);   
        this.value = null;
    };
    this.InitConstructor();

    TVariableInt.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TVariableNumeric.prototype.IsType.call(this,_type);
    };

    TVariableInt.prototype.Init = function(_object){
        TVariableNumeric.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TVariableInt'))
        {
            if (typeof _object.value !== 'undefined' && _object.value !== null && IsInt(_object.value))
                this.value = _object.value;
        }
    };


    TVariableInt.prototype.ReadXML = function(tag,fun){
        TVariableNumeric.prototype.ReadXML.call(this,tag,fun);
        if (typeof tag !== 'undefined' && tag !== null)
        {
            var tmp = tag.getAttribute('value');
            if (tmp !== null && IsInt(tmp))
                this.value = parseInt(tmp);
        }
    };
    
    TVariableInt.prototype.SetValue= function(value_){
        TVariableNumeric.prototype.SetValue.call(this,value_);
        if (typeof value_ !== 'undefined' && value_ !== null && IsNumeric(value_))
        {
            this.value = value_;
        }
    };

    TVariableInt.prototype.GetValue= function(){
        return this.value;
    };

}

TVariableInt.prototype = new TVariableNumeric();


function TVariableDouble(){
    var type = 'TVariableDouble';
    TVariableDouble.prototype.InitConstructor = function(){
        TVariableNumeric.prototype.InitConstructor.call(this);
        this.SetType(type);   
        this.value = null;
    };
    this.InitConstructor();

    TVariableDouble.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TVariableNumeric.prototype.IsType.call(this,_type);
    };

    TVariableDouble.prototype.Init = function(_object){
        TVariableNumeric.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TVariableDouble'))
        {
            if (typeof _object.value !== 'undefined' && _object.value !== null && IsNumeric(_object.value))
                this.value = _object.value;
        }
    };


    TVariableDouble.prototype.ReadXML = function(tag,fun){
        TVariableNumeric.prototype.ReadXML.call(this,tag,fun);
        if (typeof tag !== 'undefined' && tag !== null)
        {
            var tmp = tag.getAttribute('value');
            if (tmp !== null && IsNumeric(tmp))
                this.value = parseFloat(tmp);
        }
    };
    
    TVariableDouble.prototype.SetValue= function(value_){
        TVariableNumeric.prototype.SetValue.call(this,value_);
        if (typeof value_ !== 'undefined' && value_ !== null && IsNumeric(value_))
        {
            this.value = value_;
        }
        if (value_ === null)
            this.value = null;
    };

    TVariableDouble.prototype.GetValue= function(){
        return this.value;
    };


}

TVariableDouble.prototype = new TVariableNumeric();


function TVariableString(){
    var type = 'TVariableString';
    TVariableString.prototype.InitConstructor = function(){
        TVariable.prototype.InitConstructor.call(this);
        this.SetType(type);   
        this.value = null;
    };
    this.InitConstructor();

    TVariableString.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TVariable.prototype.IsType.call(this,_type);
    };

    TVariableString.prototype.Init = function(_object){
        TVariable.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TVariableString'))
        {
            if (typeof _object.value !== 'undefined' && _object.value !== null)
            {
                this.value = new String (_object.value);
                if (this.value !== null)
                    this.value = this.value.toString();
            }
        }
    };


    TVariableString.prototype.ReadXML = function(tag,fun){
        TVariable.prototype.ReadXML.call(this,tag,fun);
        if (typeof tag !== 'undefined' && tag !== null)
        {
            var tmp = tag.getAttribute('value');
            this.value = tmp;
        }
    };
    
    TVariableString.prototype.SetValue= function(value_){
        TVariable.prototype.SetValue.call(this,value_);
        if (typeof value_ !== 'undefined' && value_ !== null)
        {
            var tmp = new String(value_);
            if (tmp !== null)
                this.value = tmp.toString();
        }
        if (value_ === null)
            this.value = null;
    };

    TVariableString.prototype.GetValue= function(){
        if (this.value === null)
            return null;
        var tmp = new String(this.value);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };
}

TVariableString.prototype = new TVariable();

function TVariableFunction(){
    var type = 'TVariableFunction';
    TVariableFunction.prototype.InitConstructor = function(){
        TVariable.prototype.InitConstructor.call(this);
        this.SetType(type);   
        this.value = null;
    };
    this.InitConstructor();

    TVariableFunction.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TVariable.prototype.IsType.call(this,_type);
    };

    TVariableFunction.prototype.Init = function(_object){
        TVariable.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TVariableString'))
        {
            if (typeof _object.value !== 'undefined' && _object.value !== null)
            {
                this.value = new String (_object.value);
                if (this.value !== null)
                    this.value = this.value.toString();
            }
        }
    };


    TVariableFunction.prototype.ReadXML = function(tag,fun){
        TVariable.prototype.ReadXML.call(this,tag,fun);
        if (typeof tag !== 'undefined' && tag !== null)
        {
            var tmp = tag.getAttribute('function');
            this.value = tmp;
        }
    };
    
    TVariableFunction.prototype.SetValue= function(value_){
        TVariable.prototype.SetValue.call(this,value_);
        if (typeof value_ !== 'undefined' && value_ !== null)
        {
            var tmp = new String(value_);
            if (tmp !== null)
                this.value = tmp.toString();
        }
        if (value_ === null)
            this.value = null;
    };

    TVariableFunction.prototype.GetValue= function(){
        if (this.value === null)
            return null;
        var tmp = new String(this.value);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };
}

TVariableFunction.prototype = new TVariable();


function TVariableVoidTXT(){
    var type = 'TVariableVoidTXT';
    TVariableVoidTXT.prototype.InitConstructor = function(){
        TVariable.prototype.InitConstructor.call(this);
        this.SetType(type);
	this.recalculateYN = false;
	this.valueStr = null;
        this.value = null;
    };
    this.InitConstructor();

    TVariableVoidTXT.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TVariable.prototype.IsType.call(this,_type);
    };

    TVariableVoidTXT.prototype.Init = function(_object){
        TVariable.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TVariableVoidTXT'))
        {
            if (typeof _object.value !== 'undefined' && _object.value !== null)
            {
		if (_object.recalculateYN == true)
		    this.value = _object.value;
		else
		{
		    this.value = new String (_object.value);
		    if (this.value !== null)
			this.value = this.value.toString();
		}
            }
            if (typeof _object.valueStr !== 'undefined' && _object.valueStr !== null)
            {
                this.valueStr = new String (_object.valueStr);
                if (this.valueStr !== null)
                    this.valueStr = this.valueStr.toString();
            }
            if (typeof _object.recalculateYN !== 'undefined' && _object.recalculateYN !== null)
                this.recalculateYN = _object.recalculateYN;
        }
    };


    TVariableVoidTXT.prototype.ReadXML = function(tag,fun){
        TVariable.prototype.ReadXML.call(this,tag,fun);
        if (typeof tag !== 'undefined' && tag !== null)
        {
            var tmp = tag.getAttribute('value');
            if (typeof tmp !== 'undefined' && tmp !== null)
            {
                this.value = tmp;
                this.SetEquation(tmp);
                this.SetValue(tmp);
            }
        }
    };
    
    TVariableVoidTXT.prototype.SetValue= function(value_){
        TVariable.prototype.SetValue.call(this,value_);
        if (typeof value_ !== 'undefined' && value_ !== null)
        {
	    if (this.recalculateYN == true)
	    {
		this.value = value_;
		this.valueStr = TableToString(value_);
	    }else
	    {
		var tmp = new String(value_);
		if (tmp !== null)
		    this.value = tmp.toString();
	    }
        }
        if (value_ === null)
            this.value = null;
    };

    TVariableVoidTXT.prototype.GetValueString = function(){
	if (this.recalculateYN == true)
	{
	    if (this.valueStr == null)
		return this.GetValue();
	    else
	    	return this.valueStr;
	}else
	    return this.GetValue();
    };

    TVariableVoidTXT.prototype.GetValue= function(){
        if (this.value === null)
            return null;
	if (this.recalculateYN == true)
	    return TableToString(this.value);
        var tmp = new String(this.value);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TVariableVoidTXT.prototype.SetRecalculate= function(value_){
        if (typeof value_ !== 'undefined' && value_ !== null)
        {
            this.recalculateYN = value_;
        }
    };

    TVariableVoidTXT.prototype.GetEquation = function(rec){
	if (typeof rec === 'undefined' || rec === null)
	    rec = this.recalculateYN;
	if (rec == true)
	{
	    return this.GetValue();
	}else
	    return TVariable.prototype.GetEquation.call(this);
    };


}

TVariableVoidTXT.prototype = new TVariable();


function TVariableImage(){
    var type = 'TVariableImage';
    TVariableImage.prototype.InitConstructor = function(){
        TVariableNumeric.prototype.InitConstructor.call(this);
        this.SetType(type);   
        this.width_ = 0;
        this.height = 0;
        this.noImage = -1;
        noLastImage++;
        this.noImage = noLastImage;
        this.naturalSize = false;
        tabImage[this.noImage] = [];
    };
    this.InitConstructor();

    TVariableImage.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TVariableNumeric.prototype.IsType.call(this,_type);
    };

    TVariableImage.prototype.Init = function(_object){
        TVariableNumeric.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TVariableDouble'))
        {
            if (typeof _object.width_ !== 'undefined' && _object.width_ !== null && IsNumeric(_object.width_))
                this.width_ = _object.width_;
            if (typeof _object.height !== 'undefined' && _object.height !== null && IsNumeric(_object.height))
                this.height = _object.height;
            if (typeof _object.noImage !== 'undefined' && _object.noImage !== null && IsNumeric(_object.noImage))
                this.noImage = _object.noImage;
            if (typeof _object.naturalSize !== 'undefined' && _object.naturalSize !== null)
                this.naturalSize = _object.naturalSize;
        }
    };


    TVariableImage.prototype.ReadXML = function(tag,fun){
        TVariableNumeric.prototype.ReadXML.call(this,tag,fun);
        if (typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('naturalSize');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                if ((attr === 'Yes' || attr === 'yes' || attr === 'True' || attr === 'true'))
                    this.naturalSize = true;
                else
                    this.naturalSize = false;
            }
            
            //            
//            var tmp = tag.getAttribute('value');
//            this.SetValueString(tmp);
        }
    };
    
    TVariableImage.prototype.SetValue = function(value_){
        if (typeof value_ !== 'undefined' && value_ !== null && typeof value_.data !== 'undefined' && value_.data !== null)
        {
            var i,j,k,tmp,v;
            v = [];
            var w,h;
            w = value_.width;                
            h = value_.height;
            this.height = h;
            this.width_ = w;
            var n = value_.data.length/(this.height*this.width_);
/*            for (i = 0;i < value_.data.length;i++)
            {
                if (typeof value_.data[i] !== 'undefined' && value_.data[i] !== null && IsNumeric(value_.data[i]))
                    this.value[i] = value_.data[i];                    
            }*/
            tmp = n*w;
            for (i = 0;i < h;i++)
            {
                v[i] = [];
                for (j = 0;j < w;j++)
                {
                    v[i][j] = [];
                    for (k = 0;k < n;k++)
                        v[i][j][k] = value_.data[k + j*n + i*tmp];
                }
            }
            tabImage[this.noImage] = v;
        }
    };

    TVariableImage.prototype.GetValue= function(){
/*        var res ='[';
        if (typeof this.value !== 'undefined' && this.value !== null)
        {
            var i;
            for (i = 0;i < this.value.length;i++)
            {
                if (i > 0)
                    res = res + ',';
                res = res + this.value[i].toString();                    
            }
        }
        return res + ']';*/
        if (this.noImage >= 0)
            return 'tabImage[' + this.noImage.toString() + ']';
        else return '[]';
    };

    TVariableImage.prototype.GetTable= function(){
        if (this.noImage >= 0)
            return tabImage[this.noImage];
        else return [];
    }

    TVariableImage.prototype.GetNaturalSize= function(){
        return this.naturalSize;
    }

    TVariableImage.prototype.GetHeight= function(){
        return this.height;
    }

    TVariableImage.prototype.GetWidth_= function(){
        return this.width_;
    }

}

TVariableImage.prototype = new TVariableNumeric();


function TVariables(){
    var type = 'TVariables';
    TVariables.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        this.SetType(type);   
        this.variables = [];
    };
    this.InitConstructor();

    TVariables.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };

    TVariables.prototype.Init = function(_object){
        TObject.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TVariables'))
        {
            if (typeof _object.variables !== 'undefined' && _object.variables !== null)
            {
                var i;            
                this.variables = [];
                for (i = 0;i < _object.variables.length;i++)
                    this.variables[i] = _object.variables[i];
            }
        }
    };

    TVariables.prototype.ActualizeVariables = function()
    {
	var i;
	for (i=0;i<this.variables.length;i++)
	{
	    if (typeof this.variables[i] !== 'undefined' &&  this.variables[i] !== null && this.variables[i].IsType('TVariable'))
	    {
		if (this.variables[i].IsType('TVariableVoidTXT') && this.variables[i].recalculateYN)
		{
		    this.variables[i].SetValue(this.CalculateValue(this.variables[i].GetEquation(false)));
		}
	    }
	}
    };

    TVariables.prototype.CalculateValue = function(value_){
        if (typeof value_ !== 'undefined' && value_ !== null)
        {
            var a132532 = null,i;
            var txt = '{',tmp1,tmp2;
            for (i=0;i<this.variables.length;i++)
            {
                if (typeof this.variables[i] !== 'undefined' &&  this.variables[i] !== null && this.variables[i].IsType('TVariable'))
                {
                    if (!this.variables[i].IsType('TVariableString'))
                    {
                        if (this.variables[i].IsType('TVariableFunction'))
                        {
                            tmp2 = this.variables[i].GetValue();                            
                            if (tmp2 !== null)
                            {
                                txt = txt + tmp2 + ';';
                            }
                        }else
                        {
                            tmp1 = this.variables[i].GetName();
                            if (this.variables[i].calculate === true)
// ???????????????????????????
                                tmp2 = this.variables[i].GetEquation();
                            else
                                tmp2 = this.variables[i].GetValueString();
                            if (tmp1 !== null && tmp2 !== null)
                            {
                                txt = txt + 'var ' + tmp1 + '=' + tmp2 + ';';
                            }
                        }
                    }
                }
            }
            txt = txt + 'a132532=' + value_ + ';';
            txt = txt + '}';
            try{
                eval(txt);
            }catch(e)
            {
                if (e instanceof SyntaxError)
                {
                    
                }
            }
            return a132532;
        }
        return null;
    };

    TVariables.prototype.FindVariable = function(name_){
        if (typeof name_ !== 'undefined' && name_ !== null)
        {
            var i;
            for (i = 0;i < this.variables.length;i++)
            {
                if (this.variables[i].GetName() === name_)
                {
                    return this.variables[i];
                }
            }
        }
        return null;
    };


    TVariables.prototype.SetVariable = function(var_,name_){
        if (typeof var_ !== 'undefined' && var_ !== null && var_.IsType('TVariable'))
        {
            var obj;
            if (typeof name_ === 'undefined' || name_ === null)
                obj = this.FindVariable(var_.GetName());
            else
                obj = this.FindVariable(name_);
            if (obj === null)
                this.variables[this.variables.length] = var_;               
//            else
//                obj.SetValue(var_);
        }
    };

    TVariables.prototype.SetVariables = function(var_){
        if (typeof var_ !== 'undefined' && var_ !== null)
        {
            var i;
            for (i = 0;i < var_.length;i++)
            {
                this.SetVariable(var_[i]);
            }
        }
    };

    TVariables.prototype.GetVariables = function(){
        return this.variables;
    };

    TVariables.prototype.GetValueVariable = function(name_){
        var variable = this.FindVariable(name_);
        if (variable === null)
            return null;
        return variable.GetValue();
/*        var value = variable.GetValue();
        if (value === null)
            return null;
        return this.CalculateValue(value);*/
    };

    TVariables.prototype.SetValueVariable = function(name_,value){
        var variable = this.FindVariable(name_);
        if (variable === null)
            return;
        variable.SetValue(value);
        variable.SetEquation(value);
    };


}

TVariables.prototype = new TObject();


function TAction(){
    var type = 'TAction';
    TAction.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        this.SetType(type);   
        this.id = [];
        this.typeAction = '';
        this.tagName = null;
        this.object = null;
        this.idEventObject = null;
        this.idAction = null;
    };
    this.InitConstructor();

    TAction.prototype.Init = function(_object){
        TObject.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TAction'))
        {
            var i;
            if (typeof _object.typeAction !== 'undefined' && _object.typeAction !== null)
            {
                this.typeAction = new String(_object.typeAction);
                if (this.typeAction !== null)
                    this.typeAction = this.typeAction.toString();
            }
            if (typeof _object.id !== 'undefined' && _object.id !== null)
            {
                for (i = 0;i < _object.id.length;i++)
                {
                    this.id[i] = new String(_object.id[i]);
                    if (this.id[i] !== null)
                        this.id[i] = this.id[i].toString();                    
                }
            }            
            if (typeof _object.tagName !== 'undefined' && _object.tagName !== null)
            {
                this.tagName = new String(_object.tagName);
                if (this.tagName !== null)
                    this.tagName = this.tagName.toString();
            }
            if (typeof _object.object !== 'undefined' && _object.object !== null && _object.object.IsType('TObject'))
            {
                this.object = _object.object;
            }
            if (typeof _object.idEventObject !== 'undefined' && _object.idEventObject !== null)
            {
                this.idEventObject = new String(_object.idEventObject);
                if (this.idEventObject !== null)
                    this.idEventObject = this.idEventObject.toString();
            }
            if (typeof _object.idAction !== 'undefined' && _object.idAction !== null)
            {
                this.idAction = new String(_object.idAction);
                if (this.idAction !== null)
                    this.idAction = this.idAction.toString();
            }
        }
    };
    
    TAction.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };

    TAction.prototype.SetId= function(id_,number){
        if (typeof id_ !== 'undefined' && id_ !== null)
        {
            if (typeof number === 'undefined' || number === null || !IsInt(number))
            {
                this.idEventObject = new String(id_);
                if (this.idEventObject !== null)
                    this.idEventObject = this.idEventObject.toString();                    
            }else
            {
                this.id[number] = new String(id_);
                if (this.id[number] !== null)
                    this.id[number] = this.id[number].toString();                    
            }
        }
    };

    TAction.prototype.GetId= function(number){
        if (typeof number === 'undefined' || number === null || !IsInt(number))
        {
            var tmp = new String(this.idEventObject);
            if (tmp !== null)
                return tmp.toString();
        }else
        {
            var tmp = new String(this.id[number]);
            if (tmp !== null)
                return tmp.toString();
        }
        return null;
    };

    TAction.prototype.SetActionType= function(type_){
        if (typeof type_ !== 'undefined' && type_ !== null)
        {
            this.typeAction = new String(type_);
            if (this.typeAction !== null)
                this.typeAction = this.typeAction.toString();                    
        }
    };

    TAction.prototype.GetActionType= function(){
        var tmp = new String(this.typeAction);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TAction.prototype.SetTagName = function(name_){
        if (typeof name_ !== 'undefined' && name_ !== null)
        {
            this.tagName = new String(name_);
            if (this.tagName !== null)
                this.tagName = this.tagName.toString();                    
        }
    };

    TAction.prototype.GetTagName = function(){
        var tmp = new String(this.tagName);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TAction.prototype.Interaction = function(object){
    };

    TAction.prototype.SetObject = function(obj){
        if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObject'))
            this.object = obj;         
        if (obj === null)
            this.object = null;
    };

    TAction.prototype.GetObject = function(){
        return this.object;
    };

    TAction.prototype.GetNId= function(){
        if (this.id !== null)
            return this.id.length;
        return 0;
    };

    TAction.prototype.SetIdAction= function(id_){
        if (typeof id_ !== 'undefined' && id_ !== null)
        {
            this.idAction = new String(id_);
            if (this.idAction !== null)
                this.idAction = this.idAction.toString();                    
        }
    };

    TAction.prototype.GetIdAction= function(){
        var tmp = new String(this.idAction);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TAction.prototype.ReadXML = function(tag){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr;
            var attr = tag.getAttribute('id');
            if (typeof attr !== 'undefined' && attr !== null)
                this.SetIdAction(attr);
                            
        }
    };


}

TAction.prototype = new TObject();

function TArrayActions(){
    var type = 'TArrayActions';
    TArrayActions.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        this.SetType(type);   
        this.actions = [];
        this.id = null;
    };
    this.InitConstructor();

    TArrayActions.prototype.Init = function(_object){
        TObject.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TAction'))
        {
            var i;
            if (typeof _object.typeFunction !== 'undefined' && _object.typeFunction !== null)
            {
                this.typeFunction = new String(_object.typeFunction);
                if (this.typeFunction !== null)
                    this.typeFunction = this.typeFunction.toString();
            }
            if (typeof _object.actions !== 'undefined' && _object.actions !== null)
            {
                for (i = 0;i < _object.actions.length;i++)
                {
                    if (typeof _object.actions[i] !== 'undefined' && _object.actions[i] !== null && _object.actions[i].IsType('TAction'))
                        this.actions[i] = objM.copy(_object.actions[i]);                    
                }
            }            
            if (typeof _object.id !== 'undefined' && _object.id !== null)
            {
                this.id = new String(_object.id);
                if (this.id !== null)
                    this.id = this.id.toString();
            }
        }
    };
    
    TArrayActions.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };

    TArrayActions.prototype.SetId= function(id_){
        if (typeof id_ !== 'undefined' && id_ !== null)
        {
            this.id = new String(id_);
            if (this.id !== null)
                this.id = this.id.toString();                    
        }
    };

    TArrayActions.prototype.GetId= function(){
        var tmp = new String(this.id);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TArrayActions.prototype.SetAction= function(act,number){
        if (typeof act !== 'undefined' && act !== null && act.IsType('TAction'))
        {
            if (typeof number === 'undefined' || number === null || !IsInt(number))
                number = this.actions.length;
            this.actions[number] = act;
        }
    };

    TArrayActions.prototype.GetAction= function(number){
        if (typeof number === 'undefined' || number === null || !IsInt(number))
            number = 0;
        return this.actions[number];
    };

    TArrayActions.prototype.GetNActions= function(){
        return this.actions.length;
    };

    TArrayActions.prototype.InteractionOnClick = function(){
        var obj = document.getElementById(this.actionObject.GetId());
        if (this.actionObject !== null)
        {
            var i,n = this.actionObject.GetNActions(),obj2;
            this.typeInteraction = 'OnClick';
            for(i = 0;i < n;i++)
            {
                obj2 = this.actionObject.GetAction(i);
                if (typeof obj2 !== 'undefined' && obj2 !== null && obj2.IsType('TAction'))
                    obj2.Interaction(this);
            }
        }
    };

    TArrayActions.prototype.InteractionOnChange = function(){
        var obj = document.getElementById(this.actionObject.GetId());
        if (this.actionObject !== null)
        {
            var i,n = this.actionObject.GetNActions(),obj2;
            this.typeInteraction = 'OnChange';
            for(i = 0;i < n;i++)
            {
                obj2 = this.actionObject.GetAction(i);
                if (typeof obj2 !== 'undefined' && obj2 !== null && obj2.IsType('TAction'))
                    obj2.Interaction(this);
            }
        }
    };

    TArrayActions.prototype.InteractionOnKeyUp = function(){
        var obj = document.getElementById(this.actionObject.GetId());
        if (this.actionObject !== null)
        {
            var i,n = this.actionObject.GetNActions(),obj2;
            this.typeInteraction = 'OnKeyUp';
            for(i = 0;i < n;i++)
            {
                obj2 = this.actionObject.GetAction(i);
                if (typeof obj2 !== 'undefined' && obj2 !== null && obj2.IsType('TAction'))
                    obj2.Interaction(this);
            }
        }
    };

    TArrayActions.prototype.InteractionOnLoad = function(){
        var obj = document.getElementById(this.actionObject.GetId());
        if (this.actionObject !== null)
        {
            var i,n = this.actionObject.GetNActions(),obj2;
            this.typeInteraction = 'OnLoad';
            for(i = 0;i < n;i++)
            {
                obj2 = this.actionObject.GetAction(i);
                if (typeof obj2 !== 'undefined' && obj2 !== null && obj2.IsType('TAction'))
                    obj2.Interaction(this);
            }
        }
    };

}

TArrayActions.prototype = new TObject();


function TActionEdit(){
    var type = 'TActionEdit';
    TActionEdit.prototype.InitConstructor = function(){
        TAction.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetTagName('input');
    };
    this.InitConstructor();

    TActionEdit.prototype.Init = function(_object){
        TAction.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionEdit'))
        {
        }
    };
    
    TActionEdit.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TAction.prototype.IsType.call(this,_type);
    };

}

TActionEdit.prototype = new TAction();


function TActionEditError(){
    var type = 'TActionEditError';
    TActionEditError.prototype.InitConstructor = function(){
        TActionEdit.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TActionEditError.prototype.Init = function(_object){
        TActionEdit.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionEditError'))
        {
        }
    };
    
    TActionEditError.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TActionEdit.prototype.IsType.call(this,_type);
    };

    TActionEditError.prototype.Interaction = function(object){
        var obj = document.getElementById(this.GetId());
//        if (this.actionObject !== null)
        {
            var objEdit = this.GetObject();
            if (typeof obj !== 'undefined' && obj !== null && typeof objEdit !== 'undefined' && objEdit !== null && objEdit.IsType('TEdit'))
            {
                var tmp = objEdit.GetVariable();
		if (tmp !== null)
		{
                    if (tmp.IsType('TVariableNumeric'))
                    {
                        var value_ = parseFloat(obj.value);
                        if (value_ !== null )
                        {
                            var colTextError = objEdit.GetColourTextError();
                            var colText = objEdit.GetColourText();
                            var colBackgroundError = objEdit.GetColourBackgroundError();
                            var colBackground = objEdit.GetColourBackground();

                            if ((colTextError !== null && colText !== null) || (colBackgroundError !== null && colBackground !== null))
                            {
                                if (!IsNumeric(obj.value))
                                {
                                    if (colText !== null)
                                        obj.style.color = '#' + colTextError.Get24bitColourHex();
                                    if (colBackground !== null)
                                        obj.style.background = '#' + colBackgroundError.Get24bitColourHex();
                                }else
                                {
                                    if (objEdit.GetNonZero() && value_ === 0)
                                    {
                                        if (colText !== null)
                                            obj.style.color = '#' + colTextError.Get24bitColourHex();
                                        if (colBackground !== null)
                                            obj.style.background = '#' + colBackgroundError.Get24bitColourHex();                                
                                    }else
                                    {
                                        var YN = false,YN2 = false,var_ = objEdit.GetTypeVariable();
                                        if (typeof var_ !== 'undefined' && var_ !== null && var_ === 'int')
                                        {
                                            YN2 = true;
                                            if (IsInt(value_))
                                                YN = true;
                                        }
                                
                                        if (!YN || YN2)
                                        {
                                            if ((objEdit.GetMin() === null || value_ >= objEdit.GetMin()) && (objEdit.GetMax() === null || value_ <= objEdit.GetMax()))
                                            {
                                                if (colText !== null)
                                                    obj.style.color = '#' + colText.Get24bitColourHex();
                                                if (colBackground !== null)
                                                    obj.style.background = '#' + colBackground.Get24bitColourHex();
                                                var var_ = objEdit.GetVariable();
                                                if (typeof var_ !== 'undefined' && var_ !== null && var_.IsType('TVariable'))
                                                {
                                                    var_.SetValue(value_);
                                                    var_.SetEquation(value_);
                                                }
                                                YN = true;
                                            }else
                                                YN = false;
                                        }
                                        if (!YN) 
                                        {
                                            if (colText !== null)
                                                obj.style.color = '#' + colTextError.Get24bitColourHex();
                                            if (colBackground !== null)
                                                obj.style.background = '#' + colBackgroundError.Get24bitColourHex();                                    
                                        }
				    }
                                }
                            }
                        }
        //            alert('!');
                    }
                    if (tmp.IsType('TVariableString'))
                    {
                        var var_ = objEdit.GetVariable();
                        if (typeof var_ !== 'undefined' && var_ !== null && var_.IsType('TVariable'))
                        {
                            var_.SetValue(obj.value);
//                            var_.SetEquation(obj.value);
                        }
		    }
                }

            }
        }
    };

}

TActionEditError.prototype = new TActionEdit();


function TActionEditRecalculate(){
    var type = 'TActionEditRecalculate';
    TActionEditRecalculate.prototype.InitConstructor = function(){
        TActionEdit.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TActionEditRecalculate.prototype.Init = function(_object){
        TActionEdit.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionEditRecalculate'))
        {
        }
    };
    
    TActionEditRecalculate.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TActionEdit.prototype.IsType.call(this,_type);
    };

    TActionEditRecalculate.prototype.Interaction = function(object){
        var obj = document.getElementById(this.GetId()),scene,context;
        var objM = this.GetObjectManager();
        if (objM !== null && this.actionObject !== null)
        {
            var i,n = this.GetNId(),id_,obj2,scene_,k,tabObj,obj3;
            for(i = 0;i < n;i++)
            {
                id_ = this.GetId(i);
                if (typeof id_ !== 'undefined' && id_ !== null)
                {
                    obj2 = document.getElementById(id_);
                    if (typeof obj2 !== 'undefined' && obj2 !== null)
                    {
                        if (typeof obj2.thisObject !== 'undefined' && obj2.thisObject !== null)
                        {
                            if (obj2.thisObject.IsType('TParagraphElement'))
                                obj2.thisObject.Refresh();
                            if (obj2.thisObject.IsType('TPageElement'))
                                obj2.thisObject.Refresh();
                        }
                        if (obj2.typeDraw === 'three')
                        {
                            if (typeof obj2.camera !== 'undefined' && obj2.camera !== null && typeof obj2.renderer !== 'undefined' && obj2.renderer !== null && typeof obj2.scene !== 'undefined' && obj2.scene !== null)
                            {
                                scene = obj2.scene;
                                scene_ = scene.GetScene();
                                if (scene_ !== null)
                                {
                                    for (k = scene_.children.length - 1;k >= 0;k--)
                                    {
                                        obj3 = scene_.children[k];
                                        scene_.remove(obj3);
                                    }
                                }
                                tabObj = obj2.tabObj;
                                if (typeof tabObj !== 'undefined' && tabObj !== null)
                                {
                                    for (k = 0;k < tabObj.length;k++)
                                    {
                                        obj = tabObj[k];
                                        if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                        {
                                            obj.DrawFigure(scene);
                                        }
                                    }
                                }
                                obj2.renderer.render(scene_, obj2.camera.GetCamera());                         
                            }
                        }
                        if (obj2.typeDraw === 'canvas')
                        {
                            tabObj = obj2.tabObj;
                            var ctx_ = obj2.getContext('2d');
                            scene = objM.newObject('TCanvasScene');
                            scene.SetScale(1);
//                            var matrix = objM.newObject('TMatrixTransformation3D');
//                            matrix.SetTranslationMatrix(0,0,0);

//                            scene.SetTransformation(matrix);
//                            scene.SetContext(ctx_);
                            if (typeof obj2.scene !== 'undefined' && obj2.scene !== null)
                            {
                                scene.SetContext(ctx_);
                                scene.SetTransformation(obj2.transformationMatrix);
//                                scene.SetTransformationMatrix(obj2.scene.GetTransformationMatrix());
//                                obj2.scene.context.fillText('aaaaaa',0,0)
                                if (typeof tabObj !== 'undefined' && tabObj !== null)
                                {
 //                                   context = scene.GetContext();
                                    context = ctx_;
                                    if (typeof context !== 'undefined' && context !== null)
                                    {
                                        context.clearRect(0, 0, context.canvas.width, context.canvas.height);
                                        for (k = 0;k < tabObj.length;k++)
                                        {
                                            obj = tabObj[k];
                                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                            {
                                                obj.DrawFigure(scene);
                                            }
                                        }
                                    }
                                }
                            }                            
                        }
                        
                    }
                }
            }

        }
    };

}

TActionEditRecalculate.prototype = new TActionEdit();


function TActionInput(){
    var type = 'TActionInput';
    TActionInput.prototype.InitConstructor = function(){
        TAction.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetTagName('input');
    };
    this.InitConstructor();

    TActionInput.prototype.Init = function(_object){
        TAction.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionInput'))
        {
        }
    };
    
    TActionInput.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TAction.prototype.IsType.call(this,_type);
    };

    TActionInput.prototype.Interaction = function(object){
        var obj = document.getElementById(this.GetId()),scene,context;
        var objM = this.GetObjectManager();
        var obj2 = this.GetObject();
        if (typeof obj !== 'undefined' && obj !== null && typeof obj2 !== 'undefined' && obj2 !== null && (obj2.IsType('TParagraphRadioButton') || obj2.IsType('TParagraphCheckBox') || obj2.IsType('TParagraphSelectStart')))
        {
            var txt = obj2.GetFunctionName();
            if (typeof txt !== 'undefiend' && txt !== null)
            {
                window[txt](obj,'click',obj2.GetValue());
            }
        }
        if (objM !== null && this.actionObject !== null)
        {
            var i,n = this.GetNId(),id_,obj2,scene_,k,tabObj,obj3;
            for(i = 0;i < n;i++)
            {
                id_ = this.GetId(i);
                if (typeof id_ !== 'undefined' && id_ !== null)
                {
                    obj2 = document.getElementById(id_);
                    if (typeof obj2 !== 'undefined' && obj2 !== null)
                    {
                        if (typeof obj2.typeDraw === 'undefined' || obj2.typeDraw === null)
                            if (typeof obj2.thisObject !== 'undefined' && obj2.thisObject !== null)
                            {
                                if (obj2.thisObject.IsType('TTableShow'))
                                {
                                    obj2.thisObject.Refresh();
                                }else
                                    if (obj2.thisObject.IsType('TTableEdit'))
                                        obj2.thisObject.RefreshTable();
                                    else
                                    {
										if (obj2.thisObject.IsType('TParagraphElement'))
											obj2.thisObject.Refresh();
                                        if (obj2.thisObject.IsType('TPageElement'))
                                            obj2.thisObject.Refresh();
                                    }
                            }
                        if (obj2.typeDraw === 'three')
                        {
                            if (typeof obj2.camera !== 'undefined' && obj2.camera !== null && typeof obj2.renderer !== 'undefined' && obj2.renderer !== null && typeof obj2.scene !== 'undefined' && obj2.scene !== null)
                            {
                                scene = obj2.scene;
                                scene_ = scene.GetScene();
                                if (scene_ !== null)
                                {
                                    for (k = scene_.children.length - 1;k >= 0;k--)
                                    {
                                        obj3 = scene_.children[k];
                                        scene_.remove(obj3);
                                    }
                                }
                                tabObj = obj2.tabObj;
                                if (typeof tabObj !== 'undefined' && tabObj !== null)
                                {
                                    for (k = 0;k < tabObj.length;k++)
                                    {
                                        obj = tabObj[k];
                                        if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                        {
                                            obj.DrawFigure(scene);
                                        }
                                    }
                                }
                                obj2.renderer.render(scene_, obj2.camera.GetCamera());                         
                            }
                        }
                        if (obj2.typeDraw === 'canvas')
                        {
                            tabObj = obj2.tabObj;
                            var ctx_ = obj2.getContext('2d');
                            scene = objM.newObject('TCanvasScene');
                            scene.SetScale(1);
//                            var matrix = objM.newObject('TMatrixTransformation3D');
//                            matrix.SetTranslationMatrix(0,0,0);

//                            scene.SetTransformation(matrix);
//                            scene.SetContext(ctx_);
                            if (typeof obj2.scene !== 'undefined' && obj2.scene !== null)
                            {
                                scene.SetContext(ctx_);
                                scene.SetTransformation(obj2.transformationMatrix);
//                                scene.SetTransformationMatrix(obj2.scene.GetTransformationMatrix());
//                                obj2.scene.context.fillText('aaaaaa',0,0)
                                if (typeof tabObj !== 'undefined' && tabObj !== null)
                                {
 //                                   context = scene.GetContext();
                                    context = ctx_;
                                    if (typeof context !== 'undefined' && context !== null)
                                    {
                                        context.clearRect(0, 0, context.canvas.width, context.canvas.height);
                                        for (k = 0;k < tabObj.length;k++)
                                        {
                                            obj = tabObj[k];
                                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                            {
                                                obj.DrawFigure(scene);
                                            }
                                        }
                                    }
                                }
                            }                            
                        }
                        
                    }
                }
            }

        }
    };


}

TActionInput.prototype = new TAction();


function TActionInputRecalculate(){
    var type = 'TActionInputRecalculate';
    TActionInputRecalculate.prototype.InitConstructor = function(){
        TActionInput.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetTagName('input');
    };
    this.InitConstructor();

    TActionInputRecalculate.prototype.Init = function(_object){
        TActionInput.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionInputRecalculate'))
        {
        }
    };
    
    TActionInputRecalculate.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TActionInput.prototype.IsType.call(this,_type);
    };

    TActionInputRecalculate.prototype.Interaction = function(object){
        var obj = document.getElementById(this.GetId());
//        if (this.actionObject !== null)
        {
            var obj2 = this.GetObject();
            if (typeof obj !== 'undefined' && obj !== null && typeof obj2 !== 'undefined' && obj2 !== null && (obj2.IsType('TParagraphRadioButton') || obj2.IsType('TParagraphCheckBox')))
            {
                var tmp = obj2.GetVariable();
                if (tmp.IsType('TVariableString'))
                    tmp.SetValue(obj2.GetValue());
                else
                {
                    var tmp2 = obj2.CalculateValue(obj2.GetValue());
                    if (tmp2 !== null)
                    {
                        tmp.SetValue(tmp2);
                    }else
                    {
                        tmp.SetValue(obj2.GetValue());
                    }


    //                tmp.SetValue(obj2.GetValue());
                    tmp.SetEquation(obj2.GetValue());
                }
            }
        }
        TActionInput.prototype.Interaction.call(this,object);
    };

}

TActionInputRecalculate.prototype = new TActionInput();


function TActionRadioInput(){
    var type = 'TActionRadioInput';
    TActionRadioInput.prototype.InitConstructor = function(){
        TActionInputRecalculate.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetTagName('input');
    };
    this.InitConstructor();

    TActionRadioInput.prototype.Init = function(_object){
        TActionInputRecalculate.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionRadioInput'))
        {
        }
    };
    
    TActionRadioInput.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TActionInputRecalculate.prototype.IsType.call(this,_type);
    };

}

TActionRadioInput.prototype = new TActionInputRecalculate();


function TActionCheckBoxInput(){
    var type = 'TActionCheckBoxInput';
    TActionCheckBoxInput.prototype.InitConstructor = function(){
        TActionInputRecalculate.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetTagName('input');
    };
    this.InitConstructor();

    TActionCheckBoxInput.prototype.Init = function(_object){
        TActionInputRecalculate.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionCheckBoxInput'))
        {
        }
    };
    
    TActionCheckBoxInput.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TActionInputRecalculate.prototype.IsType.call(this,_type);
    };

}

TActionCheckBoxInput.prototype = new TActionInputRecalculate();



function TActionSelectRecalculate(){
    var type = 'TActionSelectRecalculate';
    TActionInputRecalculate.prototype.InitConstructor = function(){
        TActionInput.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetTagName('select');
    };
    this.InitConstructor();

    TActionSelectRecalculate.prototype.Init = function(_object){
        TActionInput.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionInputRecalculate'))
        {
        }
    };
    
    TActionSelectRecalculate.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TActionInput.prototype.IsType.call(this,_type);
    };

    TActionSelectRecalculate.prototype.Interaction = function(object){
        var obj = document.getElementById(this.GetId());
//        if (this.actionObject !== null)
        {
            var obj2 = this.GetObject();
            if (typeof obj !== 'undefined' && obj !== null && typeof obj2 !== 'undefined' && obj2 !== null && obj2.IsType('TParagraphSelectStart'))
            {
                var tmp = obj2.GetVariable();
                if (tmp.IsType('TVariableString'))
                    tmp.SetValue(obj.value);
                else
                {
                    var tmp2 = obj2.CalculateValue(obj.value);
                    if (tmp2 !== null)
                    {
                        tmp.SetValue(tmp2);
                    }else
                    {
                        tmp.SetValue(obj.value);
                    }


    //                tmp.SetValue(obj2.GetValue());
                    tmp.SetEquation(obj.value);
                }
            }
        }
        TActionInput.prototype.Interaction.call(this,object);
    };

}

TActionSelectRecalculate.prototype = new TActionInput();



function TActionButton(){
    var type = 'TActionButton';
    TActionButton.prototype.InitConstructor = function(){
        TAction.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetTagName('button');
    };
    this.InitConstructor();

    TActionButton.prototype.Init = function(_object){
        TAction.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionButton'))
        {
        }
    };
    
    TActionButton.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TAction.prototype.IsType.call(this,_type);
    };

    TActionButton.prototype.Interaction = function(object){
        var obj = document.getElementById(this.GetId()),scene,context;
        var objM = this.GetObjectManager();
        
        if (objM !== null && this.actionObject !== null)
        {
            var i,n = this.GetNId(),id_,obj2,scene_,k,tabObj,obj3;
            for(i = 0;i < n;i++)
            {
                id_ = this.GetId(i);
                if (typeof id_ !== 'undefined' && id_ !== null)
                {
                    obj2 = document.getElementById(id_);
                    if (typeof obj2 !== 'undefined' && obj2 !== null)
                    {
                        if (typeof obj2.typeDraw === 'undefined' || obj2.typeDraw === null)
                            if (obj2.thisObject.IsType('TTableShow'))
                            {
                                obj2.thisObject.Refresh();
                            }else
                                if (obj2.thisObject.IsType('TTableEdit'))
                                    obj2.thisObject.RefreshTable();
                        if (obj2.typeDraw === 'three')
                        {
                            if (typeof obj2.camera !== 'undefined' && obj2.camera !== null && typeof obj2.renderer !== 'undefined' && obj2.renderer !== null && typeof obj2.scene !== 'undefined' && obj2.scene !== null)
                            {
                                scene = obj2.scene;
                                scene_ = scene.GetScene();
                                if (scene_ !== null)
                                {
                                    for (k = scene_.children.length - 1;k >= 0;k--)
                                    {
                                        obj3 = scene_.children[k];
                                        scene_.remove(obj3);
                                    }
                                }
                                tabObj = obj2.tabObj;
                                if (typeof tabObj !== 'undefined' && tabObj !== null)
                                {
                                    for (k = 0;k < tabObj.length;k++)
                                    {
                                        obj = tabObj[k];
                                        if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                        {
                                            obj.DrawFigure(scene);
                                        }
                                    }
                                }
                                obj2.renderer.render(scene_, obj2.camera.GetCamera());                         
                            }
                        }
                        if (obj2.typeDraw === 'canvas')
                        {
                            tabObj = obj2.tabObj;
                            var ctx_ = obj2.getContext('2d');
                            scene = objM.newObject('TCanvasScene');
                            scene.SetScale(1);
//                            var matrix = objM.newObject('TMatrixTransformation3D');
//                            matrix.SetTranslationMatrix(0,0,0);

//                            scene.SetTransformation(matrix);
//                            scene.SetContext(ctx_);
                            if (typeof obj2.scene !== 'undefined' && obj2.scene !== null)
                            {
                                scene.SetContext(ctx_);
                                scene.SetTransformation(obj2.transformationMatrix);
//                                scene.SetTransformationMatrix(obj2.scene.GetTransformationMatrix());
//                                obj2.scene.context.fillText('aaaaaa',0,0)
                                if (typeof tabObj !== 'undefined' && tabObj !== null)
                                {
 //                                   context = scene.GetContext();
                                    context = ctx_;
                                    if (typeof context !== 'undefined' && context !== null)
                                    {
                                        context.clearRect(0, 0, context.canvas.width, context.canvas.height);
                                        for (k = 0;k < tabObj.length;k++)
                                        {
                                            obj = tabObj[k];
                                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                            {
                                                obj.DrawFigure(scene);
                                            }
                                        }
                                    }
                                }
                            }                            
                        }
                        
                    }
                }
            }

        }
    };


}

TActionButton.prototype = new TAction();

function TActionButtonRecalculate(){
    var type = 'TActionButtonRecalculate';
    TActionButtonRecalculate.prototype.InitConstructor = function(){
        TActionInput.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetTagName('button');
    };
    this.InitConstructor();

    TActionButtonRecalculate.prototype.Init = function(_object){
        TActionInput.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionButtonRecalculate'))
        {
        }
    };
    
    TActionButtonRecalculate.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TActionInput.prototype.IsType.call(this,_type);
    };

    TActionButtonRecalculate.prototype.Interaction = function(object){
        var obj = document.getElementById(this.GetId());
//        if (this.actionObject !== null)
        {
            var obj2 = this.GetObject();
            if (typeof obj !== 'undefined' && obj !== null && typeof obj2 !== 'undefined' && obj2 !== null && obj2.IsType('TButton'))
            {
                var txt = obj2.GetFunctionName();
                if (typeof txt !== 'undefiend' && txt !== null)
                {
                    window[txt](obj);
                }
                
/*                var tmp = obj2.GetVariable();
                if (tmp.IsType('TVariableString'))
                    tmp.SetValue(obj2.GetValue());
                else
                {
                    var tmp2 = obj2.CalculateValue(obj2.GetValue());
                    if (tmp2 !== null)
                    {
                        tmp.SetValue(tmp2);
                    }else
                    {
                        tmp.SetValue(obj2.GetValue());
                    }


    //                tmp.SetValue(obj2.GetValue());
                    tmp.SetEquation(obj2.GetValue());
                }*/
                var j,m = obj2.GetNActions(),act;
                for(j = 0;j < m;j++)
                {
                    act = obj2.GetAction(j);
                    if (act !== null)
                    {
                        var i,n = act.GetNId(),id_,obj2_,scene_,k,tabObj,obj3;
                        for(i = 0;i < n;i++)
                        {
                            id_ = act.GetId(i);
                            if (typeof id_ !== 'undefined' && id_ !== null)
                            {
                                obj2_ = document.getElementById(id_);
                                if (typeof obj2_ !== 'undefined' && obj2_ !== null)
                                {
                                    if (typeof obj2_.thisObject !== 'undefined' && obj2_.thisObject !== null)
                                    {
                                        if (obj2_.thisObject.IsType('TParagraphElement'))
                                            obj2_.thisObject.Refresh();
                                        if (obj2_.thisObject.IsType('TPageElement'))
                                            obj2_.thisObject.Refresh();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        TActionInput.prototype.Interaction.call(this,object);
    };

}

TActionButtonRecalculate.prototype = new TActionInput();

function TActionButtonLoadImageRecalculate(){
    var type = 'TActionButtonLoadImageRecalculate';
    TActionButtonLoadImageRecalculate.prototype.InitConstructor = function(){
        TActionButtonRecalculate.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetTagName('button');
        this.idComponentImage = null;
        this.currentFile = null;
    };
    this.InitConstructor();

    TActionButtonLoadImageRecalculate.prototype.Init = function(_object){
        TActionButtonRecalculate.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionButtonLoadImageRecalculate'))
        {
            if (typeof _object.idComponentImage !== 'undefined' && _object.idComponentImage !== null)
            {
                this.idComponentImage = new String(_object.idComponentImage);
                if (this.idComponentImage !== null)
                    this.idComponentImage = this.idComponentImage.toString();
            }
        }
    };
    
    TActionButtonLoadImageRecalculate.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TActionButtonRecalculate.prototype.IsType.call(this,_type);
    };

    TActionButtonLoadImageRecalculate.prototype.Interaction = function(object){
        var obj = document.getElementById(this.GetId());
//        if (this.actionObject !== null)
        {
            var obj2 = this.GetObject();
            if (typeof obj !== 'undefined' && obj !== null && typeof obj2 !== 'undefined' && obj2 !== null && obj2.IsType('TButton'))
            {
//                object.onchange = this.DropChangeHandlerLoadFile;
                $('#' + this.GetId()).on('change', this.DropChangeHandlerLoadFile);
//                this.resultComponent = $('#' + this.idComponentImage);
//                obj.resultComponent = $('#' + this.idComponentImage);
                obj.thisObject = this;
                this.currentFile = null;
 //               this.idComponentImage = 
            }
                
        }
        TActionButtonRecalculate.prototype.Interaction.call(this,object);
    };

    TActionButtonLoadImageRecalculate.prototype.Interaction2 = function(object){
        var obj = document.getElementById(this.GetId()),scene,context;
        var objM = this.GetObjectManager();
        
        if (objM !== null && this.actionObject !== null)
        {
            var i,n = this.GetNId(),id_,obj2,scene_,k,tabObj,obj3;
            for(i = 0;i < n;i++)
            {
                id_ = this.GetId(i);
                if (typeof id_ !== 'undefined' && id_ !== null)
                {
                    obj2 = document.getElementById(id_);
                    if (typeof obj2 !== 'undefined' && obj2 !== null)
                    {
                        if (typeof obj2.typeDraw === 'undefined' || obj2.typeDraw === null)
                            if (obj2.thisObject.IsType('TTableShow'))
                            {
                                obj2.thisObject.Refresh();
                            }else
                                if (obj2.thisObject.IsType('TTableEdit'))
                                    obj2.thisObject.RefreshTable();
                                else
                                {
                                    if (obj2.thisObject.IsType('TInteractiveImageBitmap'))
                                        obj2.thisObject.Refresh();                                    
                                }
                        if (obj2.typeDraw === 'three')
                        {
                            if (typeof obj2.camera !== 'undefined' && obj2.camera !== null && typeof obj2.renderer !== 'undefined' && obj2.renderer !== null && typeof obj2.scene !== 'undefined' && obj2.scene !== null)
                            {
                                scene = obj2.scene;
                                scene_ = scene.GetScene();
                                if (scene_ !== null)
                                {
                                    for (k = scene_.children.length - 1;k >= 0;k--)
                                    {
                                        obj3 = scene_.children[k];
                                        scene_.remove(obj3);
                                    }
                                }
                                tabObj = obj2.tabObj;
                                if (typeof tabObj !== 'undefined' && tabObj !== null)
                                {
                                    for (k = 0;k < tabObj.length;k++)
                                    {
                                        obj = tabObj[k];
                                        if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                        {
                                            obj.DrawFigure(scene);
                                        }
                                    }
                                }
                                obj2.renderer.render(scene_, obj2.camera.GetCamera());                         
                            }
                        }
                        if (obj2.typeDraw === 'canvas')
                        {
                            tabObj = obj2.tabObj;
                            var ctx_ = obj2.getContext('2d');
                            scene = objM.newObject('TCanvasScene');
                            scene.SetScale(1);
//                            var matrix = objM.newObject('TMatrixTransformation3D');
//                            matrix.SetTranslationMatrix(0,0,0);

//                            scene.SetTransformation(matrix);
//                            scene.SetContext(ctx_);
                            if (typeof obj2.scene !== 'undefined' && obj2.scene !== null)
                            {
                                scene.SetContext(ctx_);
                                scene.SetTransformation(obj2.transformationMatrix);
//                                scene.SetTransformationMatrix(obj2.scene.GetTransformationMatrix());
//                                obj2.scene.context.fillText('aaaaaa',0,0)
                                if (typeof tabObj !== 'undefined' && tabObj !== null)
                                {
 //                                   context = scene.GetContext();
                                    context = ctx_;
                                    if (typeof context !== 'undefined' && context !== null)
                                    {
                                        context.clearRect(0, 0, context.canvas.width, context.canvas.height);
                                        for (k = 0;k < tabObj.length;k++)
                                        {
                                            obj = tabObj[k];
                                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                            {
                                                obj.DrawFigure(scene);
                                            }
                                        }
                                    }
                                }
                            }                            
                        }
                        
                    }
                }
            }

        }
    }

    TActionButtonLoadImageRecalculate.prototype.DropChangeHandlerLoadFile = function(e){
        e.preventDefault();
        e = e.originalEvent;
        var v = this.thisObject.object.FindVariable(this.thisObject.object.GetVariableName());
        var target = e.dataTransfer || e.target;
        var file = target && target.files && target.files[0];
        if (!file) {
            return;
        }
        var options;
        if (v !== null)
        {
            options = {
                maxWidth: v.GetWidth_(),
                maxHeight: v.GetHeight(),
                canvas: true,
                pixelRatio: window.devicePixelRatio,
                downsamplingRatio: 0.5,
                orientation: true
            }
            this.thisObject.DisplayImage(file, options);
        }else
        {
/*            options = {
    //            maxWidth: this.resultComponent.width(),
                canvas: true,
                pixelRatio: window.devicePixelRatio,
                downsamplingRatio: 0.5,
                orientation: true
            }*/
        }
        var options2;
        v = this.thisObject.object.FindVariable(this.thisObject.object.GetVariable2Name());
        if (v !== null)
        {
            options2 = {
//                maxWidth: v.GetWidth_(),
                canvas: true,
                pixelRatio: window.devicePixelRatio,
                downsamplingRatio: 0.5,
                orientation: true
            }
            this.thisObject.DisplayImage2(file, options2);
        }
    //    exifNode.hide()
    //    thumbNode.hide()
    }

    TActionButtonLoadImageRecalculate.prototype.SetIdComponentImage = function(id_){
        if (typeof id_ !== 'undefined' && id_ !== null)
        {
            this.idComponentImage = new String(id_);
            if (this.idComponentImage !== null)
                this.idComponentImage = this.idComponentImage.toString();
        }
        if (id_ === null)
            this.idComponentImage = null;
    };

    TActionButtonLoadImageRecalculate.prototype.DisplayImage = function(file, options){
        this.currentFile = file;
        loadBitmapObject = this;
        if (!loadImage(
            file,
            this.UpdateResults,
            options
        )) {
            this.resultComponent.children().replaceWith(
                $('<span>' +
                    'Your browser does not support the URL or FileReader API.' +
                '</span>')
                )
            }
    }

    TActionButtonLoadImageRecalculate.prototype.DisplayImage2 = function(file, options){
        this.currentFile = file;
        loadBitmapObject2 = this;
        if (!loadImage(
            file,
            this.UpdateResults2,
            options
        )) {
            this.resultComponent.children().replaceWith(
                $('<span>' +
                    'Your browser does not support the URL or FileReader API.' +
                '</span>')
                )
            }
    }

    TActionButtonLoadImageRecalculate.prototype.UpdateResults = function(img, data){
/*        var fileName = loadBitmapObject.currentFile.name;
        var href = img.src
        var dataURLStart
        var content
        if (!(img.src || img instanceof HTMLCanvasElement)) {
            content = $('<span>Loading image file failed</span>')
        } else {
            if (!href) {
                href = img.toDataURL(loadBitmapObject.currentFile.type + 'REMOVEME')
            // Check if file type is supported for the dataURL export:
                dataURLStart = 'data:' + loadBitmapObject.currentFile.type
                if (href.slice(0, dataURLStart.length) !== dataURLStart) {
                    fileName = fileName.replace(/\.\w+$/, '.png')
                }
            }
            content = $('<a target="_blank">').append(img)
//                .attr('download', fileName)
//                .attr('href', href)
        }
        loadBitmapObject.resultComponent.children().replaceWith(content);*/
        if (typeof loadBitmapObject !== 'undefined' && loadBitmapObject !== null)
        {
            var obj = document.getElementById(loadBitmapObject.GetId());
            if (typeof obj !== 'undefined' && obj !== null)
            {
                var v = obj.thisObject.object.FindVariable(obj.thisObject.object.GetVariableName());
                if (typeof v !== 'undefined' && v !== null)
                {
                    var ctx=img.getContext("2d");
                    if (typeof ctx !== 'undefined' && ctx !== null)
                    {
                        var d = ctx.getImageData(0,0,img.width,img.height);
                        v.SetValue(d);
                        if (typeof loadBitmapObject2 !== 'undefined' && loadBitmapObject2 !== null)
                        {
                            loadBitmapObject.Interaction2(obj);
                        }
                    }
                }
            }
        }        
/*        if (img.getContext) {
            actionsNode.show()
        }
        if (data && data.exif) {
            displayExifData(data.exif)
        }*/
    }

    TActionButtonLoadImageRecalculate.prototype.UpdateResults2 = function(img, data){
        if (typeof loadBitmapObject !== 'undefined' && loadBitmapObject !== null)
        {
            var obj = document.getElementById(loadBitmapObject.GetId());
            if (typeof obj !== 'undefined' && obj !== null)
            {
                var v = obj.thisObject.object.FindVariable(obj.thisObject.object.GetVariable2Name());
                if (typeof v !== 'undefined' && v !== null)
                {
                    var ctx=img.getContext("2d");
                    if (typeof ctx !== 'undefined' && ctx !== null)
                    {
                        var d = ctx.getImageData(0,0,img.width,img.height);
                        v.SetValue(d);
                        if (typeof loadBitmapObject2 !== 'undefined' && loadBitmapObject2 !== null)
                        {
                            loadBitmapObject2.Interaction2(obj);
                        }
                    }
                }
            }
        }
    }

}

TActionButtonLoadImageRecalculate.prototype = new TActionButtonRecalculate();

function TActionButtonSaveImageRecalculate(){
    var type = 'TActionButtonSaveImageRecalculate';
    TActionButtonSaveImageRecalculate.prototype.InitConstructor = function(){
        TActionButtonRecalculate.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetTagName('button');
    };
    this.InitConstructor();

    TActionButtonSaveImageRecalculate.prototype.Init = function(_object){
        TActionButtonRecalculate.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionButtonSaveImageRecalculate'))
        {
        }
    };
    
    TActionButtonSaveImageRecalculate.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TActionButtonRecalculate.prototype.IsType.call(this,_type);
    };

    TActionButtonSaveImageRecalculate.prototype.Table2Image = function(tab,context){
        var imgData = null;
        if (typeof tab !== 'undefined' && tab !== null && typeof context !== 'undefined' && context !== null)
        {
            if (tab.length > 0)
            {
                var i,j,k,tmp;
                imgData=context.createImageData(tab[0].length,tab.length);
                var n = imgData.data.length/(imgData.height*imgData.width);
                tmp = n*imgData.width;
                for (i = 0;i < imgData.height;i++)
                {
                    for (j = 0;j < imgData.width;j++)
                    {
                        for (k = 0;k < n;k++)
                            imgData.data[k + j*n + i*tmp] = tab[i][j][k];
                    }
                }
            }
        }
        return imgData;
    };


    TActionButtonSaveImageRecalculate.prototype.Interaction = function(object){
        var obj = document.getElementById(this.GetId());
        var obj2 = this.GetObject();
        if (typeof obj !== 'undefined' && obj !== null && typeof obj2 !== 'undefined' && obj2 !== null && obj2.IsType('TButtonSaveImage'))
        {
//            var v = obj2.FindVariable(obj2.GetVariableName());
            var v = obj2.CalculateValue(obj2.GetVariableName());

            if (typeof v !== 'undefined' && v !== null)
            {
//                var tab = v.GetTable();
                var tab = v;
                var canvas = document.createElement('canvas');

                //                var ctx=img.getContext("2d");
                if (typeof canvas !== 'undefined' && canvas !== null && typeof tab !== 'undefined' && tab !== null && tab.length > 0)
                {
                    canvas.width = tab[0].length;
                    canvas.height = tab.length;
                    var context = canvas.getContext('2d');
                    if (typeof context !== 'undefined' && context !== null)
                    {
                        var oImg = document.createElement("img");
                        var img = this.Table2Image(tab,context);
                        context.putImageData(img,0,0);
//                        oImg.src = "aaa.png";
                        var a = canvas.toDataURL('image/png');
                        oImg.src = a;
//                        window.location.href = oImg.src.replace('image/png', 'image/octet-stream');
                        var link = document.createElement('a');
                        link.download = obj2.GetFileName();
                        link.href = oImg.src.replace('image/png', 'image/octet-stream');
                        link.click();


//                        window.location.pathname = 'hhh/aaa.png';
//                        var w=window.open('about:blank','image from canvas');
//                        w.document.write("<img src='"+a+"' alt='from canvas'/>");
//                        window.location.href = img.src.replace('image/png', 'image/octet-stream');
//                        context.drawImage(object, 0, 0,canvas.width,canvas.height);
//                        var imgData = context.getImageData(0, 0, canvas.width, canvas.height);
//                        variable.SetValue(imgData);
                    }
                }
                
            }            
//            $('#' + this.GetId()).on('change', this.DropChangeHandlerLoadFile);
            obj.thisObject = this;
        }
        this.Interaction2(object);
        TActionButtonRecalculate.prototype.Interaction.call(this,object);
    };

    TActionButtonSaveImageRecalculate.prototype.Interaction2 = function(object){
        var obj = document.getElementById(this.GetId()),scene,context;
        var objM = this.GetObjectManager();
        
        if (objM !== null && this.actionObject !== null)
        {
            var i,n = this.GetNId(),id_,obj2,scene_,k,tabObj,obj3;
            for(i = 0;i < n;i++)
            {
                id_ = this.GetId(i);
                if (typeof id_ !== 'undefined' && id_ !== null)
                {
                    obj2 = document.getElementById(id_);
                    if (typeof obj2 !== 'undefined' && obj2 !== null)
                    {
                        if (typeof obj2.typeDraw === 'undefined' || obj2.typeDraw === null)
                            if (obj2.thisObject.IsType('TTableShow'))
                            {
                                obj2.thisObject.Refresh();
                            }else
                                if (obj2.thisObject.IsType('TTableEdit'))
                                    obj2.thisObject.RefreshTable();
                                else
                                {
                                    if (obj2.thisObject.IsType('TInteractiveImageBitmap'))
                                        obj2.thisObject.Refresh();                                    
                                }
                        if (obj2.typeDraw === 'three')
                        {
                            if (typeof obj2.camera !== 'undefined' && obj2.camera !== null && typeof obj2.renderer !== 'undefined' && obj2.renderer !== null && typeof obj2.scene !== 'undefined' && obj2.scene !== null)
                            {
                                scene = obj2.scene;
                                scene_ = scene.GetScene();
                                if (scene_ !== null)
                                {
                                    for (k = scene_.children.length - 1;k >= 0;k--)
                                    {
                                        obj3 = scene_.children[k];
                                        scene_.remove(obj3);
                                    }
                                }
                                tabObj = obj2.tabObj;
                                if (typeof tabObj !== 'undefined' && tabObj !== null)
                                {
                                    for (k = 0;k < tabObj.length;k++)
                                    {
                                        obj = tabObj[k];
                                        if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                        {
                                            obj.DrawFigure(scene);
                                        }
                                    }
                                }
                                obj2.renderer.render(scene_, obj2.camera.GetCamera());                         
                            }
                        }
                        if (obj2.typeDraw === 'canvas')
                        {
                            tabObj = obj2.tabObj;
                            var ctx_ = obj2.getContext('2d');
                            scene = objM.newObject('TCanvasScene');
                            scene.SetScale(1);
//                            var matrix = objM.newObject('TMatrixTransformation3D');
//                            matrix.SetTranslationMatrix(0,0,0);

//                            scene.SetTransformation(matrix);
//                            scene.SetContext(ctx_);
                            if (typeof obj2.scene !== 'undefined' && obj2.scene !== null)
                            {
                                scene.SetContext(ctx_);
                                scene.SetTransformation(obj2.transformationMatrix);
//                                scene.SetTransformationMatrix(obj2.scene.GetTransformationMatrix());
//                                obj2.scene.context.fillText('aaaaaa',0,0)
                                if (typeof tabObj !== 'undefined' && tabObj !== null)
                                {
 //                                   context = scene.GetContext();
                                    context = ctx_;
                                    if (typeof context !== 'undefined' && context !== null)
                                    {
                                        context.clearRect(0, 0, context.canvas.width, context.canvas.height);
                                        for (k = 0;k < tabObj.length;k++)
                                        {
                                            obj = tabObj[k];
                                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                            {
                                                obj.DrawFigure(scene);
                                            }
                                        }
                                    }
                                }
                            }                            
                        }
                        
                    }
                }
            }

        }
    }


}

TActionButtonSaveImageRecalculate.prototype = new TActionButtonRecalculate();


function TActionInteractiveImageBitmap(){
    var type = 'TActionInteractiveImageBitmap';
    TActionEdit.prototype.InitConstructor = function(){
        TAction.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetTagName('image');
    };
    this.InitConstructor();

    TActionInteractiveImageBitmap.prototype.Init = function(_object){
        TAction.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionInteractiveImageBitmap'))
        {
        }
    };
    
    TActionInteractiveImageBitmap.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TAction.prototype.IsType.call(this,_type);
    };

}

TActionInteractiveImageBitmap.prototype = new TAction();

function TActionInteractiveImageBitmapRecalculate(){
    var type = 'TActionInteractiveImageBitmapRecalculate';
    TActionInteractiveImageBitmapRecalculate.prototype.InitConstructor = function(){
        TActionInteractiveImageBitmap.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TActionInteractiveImageBitmapRecalculate.prototype.Init = function(_object){
        TActionInteractiveImageBitmap.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionEditRecalculate'))
        {
        }
    };
    
    TActionInteractiveImageBitmapRecalculate.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TActionInteractiveImageBitmap.prototype.IsType.call(this,_type);
    };

    TActionInteractiveImageBitmapRecalculate.prototype.Interaction = function(object){
        var obj = document.getElementById(this.GetId()),scene,context;
        var objM = this.GetObjectManager();
        if (objM !== null && this.actionObject !== null)
        {
            if (typeof object.thisObject !== 'undefined' && object.thisObject !== null && object.thisObject.IsType('TInteractiveImageBitmap') && typeof object.typeInteraction !== 'undefined' && object.typeInteraction !== null)
            {
                if (object.typeInteraction === 'OnClick')
                {
                    if (object.thisObject.GetClickNextImage())
                    {
                    object.thisObject.NextImage();
                    var file = object.thisObject.GetFile();
                    var catalog = object.imageCatalog;
                    if (typeof file !== 'undefined' && file !== null && typeof catalog !== 'undefined' && catalog !== null)
                        object.src = catalog + '/' + file.GetFileNameString();
                    }
                }
                if (object.typeInteraction === 'OnLoad')
                {
                    object.thisObject.CalculateImage();
                    var variable = object.thisObject.FindVariable(object.thisObject.GetVariableImageName());
                    if (variable != null)
                    {
                        var canvas = document.createElement('canvas');
                        if (variable.GetNaturalSize())
                        {
                            canvas.width = object.naturalWidth;
                            canvas.height = object.naturalHeight;
                        }else
                        {
                            if (object.hidden)
                            {
                                object.hidden = false;
                                canvas.width = object.width;
                                canvas.height = object.height;
                                object.hidden = true;
                            }else
                            {
                                canvas.width = object.width;
                                canvas.height = object.height;
                            }
                        }
                        var context = canvas.getContext('2d');
    //                    var img = document.getElementById("scream");
                        context.drawImage(object, 0, 0,canvas.width,canvas.height);
                        var imgData = context.getImageData(0, 0, canvas.width, canvas.height);
                        variable.SetValue(imgData);
                    }    
                    if (object.src.substr(0,10) !== 'data:image')
                    {
                        variable = object.thisObject.FindVariable(object.thisObject.GetVariableImage2Name());
                        if (variable != null)
                        {
                            var canvas = document.createElement('canvas');
                            if (variable.GetNaturalSize())
                            {
                                canvas.width = object.naturalWidth;
                                canvas.height = object.naturalHeight;
                            }else
                            {
                                canvas.width = object.width;
                                canvas.height = object.height;
                            }
                            var context = canvas.getContext('2d');
        //                    var img = document.getElementById("scream");
                            context.drawImage(object, 0, 0,canvas.width,canvas.height);
                            var imgData = context.getImageData(0, 0, canvas.width, canvas.height);
                            variable.SetValue(imgData);
                        }
                    }
                }
            }
            
            var i,n = this.GetNId(),id_,obj2,scene_,k,tabObj,obj3;
            for(i = 0;i < n;i++)
            {
                id_ = this.GetId(i);
                if (typeof id_ !== 'undefined' && id_ !== null)
                {
                    obj2 = document.getElementById(id_);
                    if (typeof obj2 !== 'undefined' && obj2 !== null)
                    {
                        if (typeof obj2.thisObject !== 'undefined' && obj2.thisObject !== null)
                        {
                            if (obj2.thisObject.IsType('TParagraphElement'))
                                obj2.thisObject.Refresh();
                            if (obj2.thisObject.IsType('TPageElement'))
                                obj2.thisObject.Refresh();
                        }
                        if (obj2.typeDraw === 'three')
                        {
                            if (typeof obj2.camera !== 'undefined' && obj2.camera !== null && typeof obj2.renderer !== 'undefined' && obj2.renderer !== null && typeof obj2.scene !== 'undefined' && obj2.scene !== null)
                            {
                                scene = obj2.scene;
                                scene_ = scene.GetScene();
                                if (scene_ !== null)
                                {
                                    for (k = scene_.children.length - 1;k >= 0;k--)
                                    {
                                        obj3 = scene_.children[k];
                                        scene_.remove(obj3);
                                    }
                                }
                                tabObj = obj2.tabObj;
                                if (typeof tabObj !== 'undefined' && tabObj !== null)
                                {
                                    for (k = 0;k < tabObj.length;k++)
                                    {
                                        obj = tabObj[k];
                                        if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                        {
                                            obj.DrawFigure(scene);
                                        }
                                    }
                                }
                                obj2.renderer.render(scene_, obj2.camera.GetCamera());                         
                            }
                        }
                        if (obj2.typeDraw === 'canvas')
                        {
                            tabObj = obj2.tabObj;
                            var ctx_ = obj2.getContext('2d');
                            scene = objM.newObject('TCanvasScene');
                            scene.SetScale(1);
//                            var matrix = objM.newObject('TMatrixTransformation3D');
//                            matrix.SetTranslationMatrix(0,0,0);

//                            scene.SetTransformation(matrix);
//                            scene.SetContext(ctx_);
                            if (typeof obj2.scene !== 'undefined' && obj2.scene !== null)
                            {
                                scene.SetContext(ctx_);
                                scene.SetTransformation(obj2.transformationMatrix);
//                                scene.SetTransformationMatrix(obj2.scene.GetTransformationMatrix());
//                                obj2.scene.context.fillText('aaaaaa',0,0)
                                if (typeof tabObj !== 'undefined' && tabObj !== null)
                                {
 //                                   context = scene.GetContext();
                                    context = ctx_;
                                    if (typeof context !== 'undefined' && context !== null)
                                    {
                                        context.clearRect(0, 0, context.canvas.width, context.canvas.height);
                                        for (k = 0;k < tabObj.length;k++)
                                        {
                                            obj = tabObj[k];
                                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                            {
						if (typeof obj.variables !== 'undefined' && obj.variables !== null && obj.variables.IsType('TVariables'))
						    obj.variables.ActualizeVariables();
                                                obj.DrawFigure(scene);
                                            }
                                        }
                                    }
                                }
                            }                            
                        }
                        
                    }
                }
            }

        }
    };

}

TActionInteractiveImageBitmapRecalculate.prototype = new TActionInteractiveImageBitmap();

function TActionSlider(){
    var type = 'TActionSlider';
    TActionSlider.prototype.InitConstructor = function(){
        TAction.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetTagName('slider');
    };
    this.InitConstructor();

    TActionSlider.prototype.Init = function(_object){
        TAction.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionSlider'))
        {
        }
    };
    
    TActionSlider.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TAction.prototype.IsType.call(this,_type);
    };

    TActionSlider.prototype.Interaction = function(object){
        var obj = document.getElementById(this.GetId()),scene,context;
        var objM = this.GetObjectManager();
        
        if (objM !== null && this.actionObject !== null)
        {
            var obj2 = this.GetObject();
            if (typeof obj2 !== 'undefined' && obj2 !== null && obj2.IsType('TSlider'))
            {
                var v = obj2.FindVariable(obj2.GetVariableName());
                if (typeof v !== 'undefined' && v !== null)
                {
                    if (typeof obj.value !== 'undefined' && obj.value !== null && IsNumeric(obj.value))
                    {
                        v.SetValue(parseFloat(obj.value));
                    }
                }            
            }
            
            var i,n = this.GetNId(),id_,obj2,scene_,k,tabObj,obj3;
            for(i = 0;i < n;i++)
            {
                id_ = this.GetId(i);
                if (typeof id_ !== 'undefined' && id_ !== null)
                {
                    obj2 = document.getElementById(id_);
                    if (typeof obj2 !== 'undefined' && obj2 !== null)
                    {
                        if (typeof obj2.typeDraw === 'undefined' || obj2.typeDraw === null)
                            if (obj2.thisObject.IsType('TTableShow'))
                            {
                                obj2.thisObject.Refresh();
                            }else
                                if (obj2.thisObject.IsType('TTableEdit'))
                                    obj2.thisObject.RefreshTable();
                            else
                            {
                                if (obj2.thisObject.IsType('TParagraphElement'))
                                    obj2.thisObject.Refresh();
                                else
                                {
                                    if (obj2.thisObject.IsType('TPageElement'))
                                        obj2.thisObject.Refresh();
                                }
                            }
//                                else
//                                {
//                                    if (obj2.thisObject.IsType('TInteractiveImageBitmap'))
//                                        obj2.thisObject.Refresh();                                    
//                                }
                        if (obj2.typeDraw === 'three')
                        {
                            if (typeof obj2.camera !== 'undefined' && obj2.camera !== null && typeof obj2.renderer !== 'undefined' && obj2.renderer !== null && typeof obj2.scene !== 'undefined' && obj2.scene !== null)
                            {
                                scene = obj2.scene;
                                scene_ = scene.GetScene();
                                if (scene_ !== null)
                                {
                                    for (k = scene_.children.length - 1;k >= 0;k--)
                                    {
                                        obj3 = scene_.children[k];
                                        scene_.remove(obj3);
                                    }
                                }
                                tabObj = obj2.tabObj;
                                if (typeof tabObj !== 'undefined' && tabObj !== null)
                                {
                                    for (k = 0;k < tabObj.length;k++)
                                    {
                                        obj = tabObj[k];
                                        if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                        {
                                            obj.DrawFigure(scene);
                                        }
                                    }
                                }
                                obj2.renderer.render(scene_, obj2.camera.GetCamera());                         
                            }
                        }
                        if (obj2.typeDraw === 'canvas')
                        {
                            tabObj = obj2.tabObj;
                            var ctx_ = obj2.getContext('2d');
                            scene = objM.newObject('TCanvasScene');
                            scene.SetScale(1);
//                            var matrix = objM.newObject('TMatrixTransformation3D');
//                            matrix.SetTranslationMatrix(0,0,0);

//                            scene.SetTransformation(matrix);
//                            scene.SetContext(ctx_);
                            if (typeof obj2.scene !== 'undefined' && obj2.scene !== null)
                            {
                                scene.SetContext(ctx_);
                                scene.SetTransformation(obj2.transformationMatrix);
//                                scene.SetTransformationMatrix(obj2.scene.GetTransformationMatrix());
//                                obj2.scene.context.fillText('aaaaaa',0,0)
                                if (typeof tabObj !== 'undefined' && tabObj !== null)
                                {
 //                                   context = scene.GetContext();
                                    context = ctx_;
                                    if (typeof context !== 'undefined' && context !== null)
                                    {
                                        context.clearRect(0, 0, context.canvas.width, context.canvas.height);
                                        for (k = 0;k < tabObj.length;k++)
                                        {
                                            obj = tabObj[k];
                                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                            {
                                                obj.DrawFigure(scene);
                                            }
                                        }
                                    }
                                }
                            }                            
                        }
                        
                    }
                }
            }

        }
    };


}

TActionSlider.prototype = new TAction();


function TThreeCamera(){
    var type = 'TThreeCamera';
    TThreeCamera.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.positionCamera = null;
        this.alpha = 0;
        this.beta = 0;
        this.camera = null;
        this.distance = 1;
    };
    this.InitConstructor();

    TThreeCamera.prototype.Init = function(_object){
        TObject.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionThreeCamera'))
        {
            if (typeof _object.positionCamera !== 'undefined' && _object.positionCamera !== null && _object.positionCamera.IsType('TVector3DT'))
                this.positionCamera = objM.copy(_object.positionCamera);
            if (typeof _object.alpha !== 'undefined' && _object.alpha !== null && IsNumeric(_object.alpha))
                this.alpha = _object.alpha;
            if (typeof _object.beta !== 'undefined' && _object.beta !== null && IsNumeric(_object.beta))
                this.beta = _object.beta;
            if (typeof _object.camera !== 'undefined' && _object.camera !== null)
                this.camera = _object.camera;
            if (typeof _object.distance !== 'undefined' && _object.distance !== null && IsNumeric(_object.distance))
                this.distance = _object.distance;
        }
    };
    
    TThreeCamera.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };

    TThreeCamera.prototype.SetPositionCamera = function(coord){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof coord !== 'undefined' && coord !== null && coord.IsType('TVector3DT'))
            this.positionCamera = objM.copy(coord);
    };

    TThreeCamera.prototype.SetAlpha = function(alpha_){
        if (typeof alpha_ !== 'undefined' && alpha_ !== null && IsNumeric(alpha_))
            this.alpha = alpha_;
    };
    
    TThreeCamera.prototype.GetAlpha = function(){
        return this.alpha;
    };
    
    TThreeCamera.prototype.IncreaseAlpha = function(alpha_){
        if (typeof alpha_ !== 'undefined' && alpha_ !== null && IsNumeric(alpha_))
            this.alpha = this.alpha + alpha_;
    };
    
    TThreeCamera.prototype.SetBeta = function(beta_){
        if (typeof beta_ !== 'undefined' && beta_ !== null && IsNumeric(beta_))
            this.beta = beta_;
    };
    
    TThreeCamera.prototype.GetBeta = function(){
        return this.beta;
    };
    
    TThreeCamera.prototype.IncreaseBeta = function(beta_){
        if (typeof beta_ !== 'undefined' && beta_ !== null && IsNumeric(beta_))
            this.beta = this.beta + beta_;
    };

    TThreeCamera.prototype.CalculateCameraPosition = function(){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof this.positionCamera !== 'undefined' && this.positionCamera !== null && this.positionCamera.IsType('TVector3DT'))
        {
            var camera = this.GetCamera();
            var matrixR1 = objM.newObject('TMatrixTransformation3D');
            var matrixR2 = objM.newObject('TMatrixTransformation3D');
            if (typeof camera !== 'undefined' && camera !== null && typeof matrixR1 !== 'undefined' && matrixR1 !== null && typeof matrixR2 !== 'undefined' && matrixR2 !== null)
            {
                matrixR1.SetRotateYMatrix3D(this.alpha);
                matrixR2.SetRotateXMatrix3D(this.beta);
                matrixR1.MatrixMultiplication(matrixR2);
                var tmp = matrixR1.MatrixVectorMultiplication(this.positionCamera);
                if (tmp !== null)
                {
                    camera.position.set(this.distance*tmp.GetX(), this.distance*tmp.GetY(), this.distance*tmp.GetZ());
                }
            }
        }
    };

    TThreeCamera.prototype.SetCamera = function(camera_){
        if (typeof camera_ !== 'undefined' && camera_ !== null)
            this.camera = camera_;
    };

    TThreeCamera.prototype.GetCamera = function(){
        return this.camera;
    };

    TThreeCamera.prototype.SetDistance = function(dist){
        if (typeof dist !== 'undefined' && dist !== null && IsNumeric(dist))
            this.distance = dist;
    };

    TThreeCamera.prototype.IncreaseDistance = function(dist){
        if (typeof dist !== 'undefined' && dist !== null && IsNumeric(dist))
            this.distance = this.distance + dist;
    };
    
}

TThreeCamera.prototype = new TObject();


function TActionThree(){
    var type = 'TActionThree';
    TActionThree.prototype.InitConstructor = function(){
        TAction.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.renderer = null;
        this.scene = null;
        this.camera = null;
    };
    this.InitConstructor();

    TActionThree.prototype.InitConstructor2 = function(){
/*        if (typeof this.camera === 'undefined' || this.camera === null)
        {
            var objM = this.GetObjectManager();
            if (objM !== null )
                this.camera = objM.newObject('TThreeCamera');
        }*/
    };

    TActionThree.prototype.Init = function(_object){
        TAction.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionThree'))
        {
            if (typeof _object.renderer !== 'undefined' && _object.renderer !== null)
                this.renderer = _object.renderer;
            if (typeof _object.scene !== 'undefined' && _object.scene !== null)
                this.scene = _object.scene;
            if (typeof _object.camera !== 'undefined' && _object.camera !== null && _object.camera.IsType('TThreeCamera'))
                this.camera = _object.camera;
        }
    };
    
    TActionThree.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TAction.prototype.IsType.call(this,_type);
    };

    TActionThree.prototype.SetRenderer = function(renderer_){
        if (typeof renderer_ !== 'undefined' && renderer_ !== null)
            this.renderer = renderer_;
    };

    TActionThree.prototype.GetRenderer = function(){
        return this.renderer;
    };

    TActionThree.prototype.SetScene = function(scene_){
        if (typeof scene_ !== 'undefined' && scene_ !== null && scene_.IsType('TThreeScene'))
            this.scene = scene_;
    };

    TActionThree.prototype.GetScene = function(){
        return this.scene;
    };

    TActionThree.prototype.SetCamera = function(camera_){
        if (typeof camera_ !== 'undefined' && camera_ !== null && camera_.IsType('TThreeCamera'))
            this.camera = camera_;
    };

    TActionThree.prototype.GetCamera = function(){
        return this.camera;
    };

    TActionThree.prototype.RenderScene = function(){
        if (this.renderer !== null && this.scene !== null && this.camera !== null && this.camera.IsType('TThreeCamera'))
        {
            var scene2 = this.scene.GetScene();
            if (typeof scene2 !== 'undefined' && scene2 !== null)
                this.renderer.render(scene2, this.camera.GetCamera()); 
        }
    };
}

TActionThree.prototype = new TAction();

function TActionThreeCamera(){
    var type = 'TActionThreeCamera';
    TActionThreeCamera.prototype.InitConstructor = function(){
        TActionThree.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetActionType('ThreeCamera');
    };
    this.InitConstructor();

    TActionThreeCamera.prototype.Init = function(_object){
        TActionThree.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionThreeCamera'))
        {
        }
    };
    
    TActionThreeCamera.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TActionThree.prototype.IsType.call(this,_type);
    };

    TActionThreeCamera.prototype.SetPositionCamera = function(coord){
        var tmp = this.GetCamera();
        if (typeof tmp !== 'undefined' && tmp !== null && tmp.IsType('TThreeCamera'))
            tmp.SetPositionCamera(coord);
    };

    TActionThreeCamera.prototype.SetAlpha = function(alpha_){
        var tmp = this.GetCamera();
        if (typeof tmp !== 'undefined' && tmp !== null && tmp.IsType('TThreeCamera'))
            tmp.SetAlpha(alpha_);
    };
    
    TActionThreeCamera.prototype.GetAlpha = function(){
        var tmp = this.GetCamera();
        if (typeof tmp !== 'undefined' && tmp !== null && tmp.IsType('TThreeCamera'))
            return tmp.GetAlpha();
        return null;
    };
    
    TActionThreeCamera.prototype.IncreaseAlpha = function(alpha_){
        var tmp = this.GetCamera();
        if (typeof tmp !== 'undefined' && tmp !== null && tmp.IsType('TThreeCamera'))
            tmp.IncreaseAlpha(alpha_);
    };

    TActionThreeCamera.prototype.SetBeta = function(beta_){
        var tmp = this.GetCamera();
        if (typeof tmp !== 'undefined' && tmp !== null && tmp.IsType('TThreeCamera'))
            tmp.SetBeta(beta_);
    };
    
    TActionThreeCamera.prototype.GetBeta = function(){
        var tmp = this.GetCamera();
        if (typeof tmp !== 'undefined' && tmp !== null && tmp.IsType('TThreeCamera'))
            return tmp.GetBeta();
        return null;
    };
    
    TActionThreeCamera.prototype.IncreaseBeta = function(beta_){
        var tmp = this.GetCamera();
        if (typeof tmp !== 'undefined' && tmp !== null && tmp.IsType('TThreeCamera'))
            tmp.IncreaseBeta(beta_);
    };


    TActionThreeCamera.prototype.CalculateCameraPosition = function(){
        var tmp = this.GetCamera();
        if (typeof tmp !== 'undefined' && tmp !== null && tmp.IsType('TThreeCamera'))
        {
            tmp.CalculateCameraPosition();
            var scene = this.GetScene();
            if (scene !== null)
            {
                var scene2 = scene.GetScene();
                if (typeof scene2 !== 'undefined' && scene2 !== null)
                {
                    var camera_ = tmp.GetCamera();
                    if (typeof camera_ !== 'undefined' && camera_ !== null)
                        camera_.lookAt(scene2.position);
                }
            }
        }
    };

    TActionThreeCamera.prototype.SetDistance = function(dist){
        var tmp = this.GetCamera();
        if (typeof tmp !== 'undefined' && tmp !== null && tmp.IsType('TThreeCamera'))
            tmp.SetDistance(dist);
    };

    TActionThreeCamera.prototype.IncreaseDistance = function(dist){
        var tmp = this.GetCamera();
        if (typeof tmp !== 'undefined' && tmp !== null && tmp.IsType('TThreeCamera'))
            tmp.IncreaseDistance(dist);
    };

}

TActionThreeCamera.prototype = new TActionThree();

function TActionThreeRotateButton(){
    var type = 'TActionThreeRotateButton';
    TActionThreeCamera.prototype.InitConstructor = function(){
        TActionThree.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetActionType('ThreeRotateButton');
        this.SetTagName('button');
        this.buttonType = null;
        this.skipAlpha = Math.PI/180;
        this.skipBeta = Math.PI/180;
    };
    this.InitConstructor();

    TActionThreeRotateButton.prototype.Init = function(_object){
        TActionThreeCamera.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionThreeRotateButton'))
        {
            if (typeof _object.buttonType !== 'undefined' && _object.buttonType !== null)
            {
                this.buttonType = new String(_object.buttonType);
                if (this.buttonType !== null)
                    this.buttonType = this.buttonType.toString();
            }
            if (typeof _object.skipAlpha !== 'undefined' && _object.skipAlpha !== null && IsNumeric(_object.skipAlpha))
                this.skipAlpha = _object.skipAlpha;
            if (typeof _object.skipBeta !== 'undefined' && _object.skipBeta !== null && IsNumeric(_object.skipBeta))
                this.skipBeta = _object.skipBeta;
        }
    };
    
    TActionThreeRotateButton.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TActionThreeCamera.prototype.IsType.call(this,_type);
    };

    TActionThreeRotateButton.prototype.SetButtonType= function(type_){
        if (typeof type_ !== 'undefined' && type_ !== null)
        {
            this.buttonType = new String(type_);
            if (this.buttonType !== null)
                this.buttonType = this.buttonType.toString();                    
        }
    };

    TActionThreeRotateButton.prototype.Interaction = function(object){
        TActionThreeCamera.prototype.Interaction.call(this,object);
        var obj = document.getElementById(this.GetId()),scene;
        if (this.actionObject !== null)
        {
            var i,n = this.GetNId(),id_,obj2,scene_,k,tabObj,obj3;
            var camera,obj;
            for(i = 0;i < n;i++)
            {
                id_ = this.GetId(i);
                if (typeof id_ !== 'undefined' && id_ !== null)
                {
                    obj2 = document.getElementById(id_);
                    if (typeof obj2 !== 'undefined' && obj2 !== null && typeof obj2.camera !== 'undefined' && obj2.camera !== null && typeof obj2.renderer !== 'undefined' && obj2.renderer !== null && typeof obj2.scene !== 'undefined' && obj2.scene !== null)
                    {
                        this.SetCamera(obj2.camera);
                        this.SetScene(obj2.scene);
                        this.SetRenderer(obj2.renderer);
//                        this.SetScene(this.GetScene());
                        if (this.buttonType === 'left')
                            this.IncreaseAlpha(this.skipAlpha);
                        if (this.buttonType === 'right')
                            this.IncreaseAlpha(-this.skipAlpha);
                        if (this.buttonType === 'top')
                            this.IncreaseBeta(this.skipBeta);
                        if (this.buttonType === 'bottom')
                            this.IncreaseBeta(-this.skipBeta);
                        this.CalculateCameraPosition(); 
                        this.RenderScene();
                        
                    }
                }
            }
        }
    };

    TActionThreeRotateButton.prototype.SetSkipAlpha = function(skip_){
        if (typeof skip_ !== 'undefined' && skip_ !== null && IsNumeric(skip_))
            this.skipAlpha = skip_;
    };
    
    TActionThreeRotateButton.prototype.SetSkipBeta = function(skip_){
        if (typeof skip_ !== 'undefined' && skip_ !== null && IsNumeric(skip_))
            this.skipBeta = skip_;
    };

}

TActionThreeRotateButton.prototype = new TActionThreeCamera();


function TPageElement(){
    var type = 'TPageElement';
    TPageElement.prototype.InitConstructor = function(){
        TObjectMultilanguage.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.typePageElement = 'PageElement';
        this.id = null;
        this.visible = true;
        this.referenceName = [];
        this.referenceValue = [];
        this.classStyle = null;
        this.variables = null;
        this.actions = [];
    };
    this.InitConstructor();

    TPageElement.prototype.InitConstructor2 = function(){
        TObjectMultilanguage.prototype.InitConstructor2.call(this);
        var objM = this.GetObjectManager();
        if (objM !== null)
            this.variables = objM.newObject('TVariables');
    };

    TPageElement.prototype.Init = function(_object){
        TObjectMultilanguage.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TPageElement'))
        {
            if (typeof _object.typePageElement !== 'undefined' && _object.typePageElement !== null)
            {
                this.typePageElement = new String(_object.typePageElemen);
                this.typePageElement = this.typePageElement.toString();
            }
            if (typeof _object.id !== 'undefined' && _object.id !== null)
            {
                this.id = new String(_object.id);
                this.id = this.id.toString();
            }
            if (typeof _object.visible !== 'undefined' && _object.visible !== null)
                this.visible = _object.visible;
            if (typeof _object.referenceName !== 'undefined' && _object.referenceName !== null)
                this.referenceName = _object.referenceName;
            if (typeof _object.referenceValue !== 'undefined' && _object.referenceValue !== null)
                this.referenceValue = _object.referenceValue;
            if (typeof _object.classStyle !== 'undefined' && _object.classStyle !== null)
            {
                this.classStyle = new String(_object.classStyle);
                this.classStyle = this.classStyle.toString();
            }
            if (typeof _object.variables !== 'undefined' && _object.variables !== null && _object.variables.IsType('TVariables'))
                this.variables = objM.copy(_object.variables);
            if (typeof _object.actions !== 'undefined' && _object.actions !== null)
            {
                var i;            
                this.actions = [];
                for (i = 0;i < _object.actions.length;i++)
                    this.actions[i] = objM.copy(_object.actions[i]);
            }
        }
    };

    TPageElement.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectMultilanguage.prototype.IsType.call(this,_type);
    };
    
    TPageElement.prototype.GetTypePageElement = function(){
        return this.typePageElement;
    };

    TPageElement.prototype.SetTypePageElement = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            this.typePageElement = new String(_type);
            this.typePageElement = this.typePageElement.toString();            
        }
    };
    TPageElement.prototype.Draw = function(_object){
    };
    
    TPageElement.prototype.ParseXML = function(tag1,tag2){
        
    };

    TPageElement.prototype.ReadXMLInit = function(tag){
        if (typeof tag !== 'undefined' && tag !== null)
        {
            var tmp = tag.getAttribute('defaultLanguage');
            if (tmp !== null)
                this.defaultLanguage = tmp;
            this.id = tag.getAttribute('id');
            this.classStyle = tag.getAttribute('style');
        }
    };

    TPageElement.prototype.ReadXML = function(tag,fun){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            this.ReadXMLInit(tag);
            var obj;
            var lang = this.GetCurrentNameLanguage();
            var i,x = tag.childNodes,YN = false,tmp = null,tmp2 = null,value;
            for (i = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if (x[i].nodeName.toLowerCase() === lang)
                    {
                        YN = true;
                        tmp2 = x[i];
                    }
                    if (typeof this.defaultLanguage !== 'undefined' && this.defaultLanguage !== null && x[i].nodeName.toLowerCase() === this.defaultLanguage)
                    {
                        tmp = x[i];
                    }
                    if (x[i].nodeName.toLowerCase() === 'vari')
                    {
                        obj = objM.newObject('TVariableInt');
                        if (obj !== null)
                        {
                            if (this.variables !== null)
                                this.variables.SetVariable(obj);
                            value = this.CalculateValue(x[i].getAttribute('value'));
                            obj.SetName(x[i].getAttribute('name'));
                            obj.SetEquation(x[i].getAttribute('value'));
                            obj.SetValue(value);
                            
//                            obj.ReadXML(x[i],fun);
                        }
                    }
                    if (x[i].nodeName.toLowerCase() === 'vard')
                    {
                        obj = objM.newObject('TVariableDouble');
                        if (obj !== null)
                        {
                            if (this.variables !== null)
                                this.variables.SetVariable(obj);
                            value = this.CalculateValue(x[i].getAttribute('value'));
                            obj.SetName(x[i].getAttribute('name'));
                            obj.SetEquation(x[i].getAttribute('value'));
			    if (x[i].getAttribute('calculate') === 'True')
// ???????????????????
	                        obj.calculate = true;
                            obj.SetValue(value);
                            
//                            obj.ReadXML(x[i],fun);
                        }
                    }
                    if (x[i].nodeName.toLowerCase() === 'vars')
                    {
                        obj = objM.newObject('TVariableString');
                        if (obj !== null)
                        {
                            if (this.variables !== null)
                                this.variables.SetVariable(obj);
                            value = this.CalculateValue(x[i].getAttribute('value'));
                            obj.SetName(x[i].getAttribute('name'));
                            obj.SetValue(value);
                            
//                            obj.ReadXML(x[i],fun);
                        }
                    }
                    if (x[i].nodeName.toLowerCase() === 'varv')
                    {
                        obj = objM.newObject('TVariableVoidTXT');
                        if (obj !== null)
                        {
			    if (x[i].getAttribute('recalculate') === 'True' || x[i].getAttribute('recalculate') === 'true')
	                        obj.SetRecalculate(true);
                             if (this.variables !== null)
                                this.variables.SetVariable(obj);
                            value = this.CalculateValue(x[i].getAttribute('value'));
                            obj.SetName(x[i].getAttribute('name'));
                            obj.SetEquation(x[i].getAttribute('value'));
                            obj.SetValue(value);
                           
                        }
                    }
                }
            }
            if (YN)
            {
                this.ParseXML(tag,tmp2);
            }else
            {
                if (tmp !== null)
                {
                    this.ParseXML(tag,tmp);
                }
            }                
        }
    };

    TPageElement.prototype.DrawFromAnotherElement = function(_object){
    };

    TPageElement.prototype.ActualizeId = function(_pageElements){
    };

    TPageElement.prototype.GetId = function(){
        if (this.id !== null)
        {
            var tmp = new String(this.id);
            if (tmp !== null)
                return tmp.toString();
        }
        return null;
    };

    TPageElement.prototype.GetClassStyle = function(){
        if (this.classStyle !== null)
        {
            var tmp = new String(this.classStyle);
            if (tmp !== null)
                return tmp.toString();
        }
        return null;
    };

    TPageElement.prototype.FindElement = function(id,_pageElements){
        if (typeof _pageElements !== 'undefined' && _pageElements !== null && typeof id !== 'undefined' && id !== null)
        {
            var i;
            for (i = 0;i < _pageElements.length;i++)
            {
                if (typeof _pageElements[i] !== 'undefined' && _pageElements[i] !== null && _pageElements[i].IsType('TPageElement'))
                {
                    if (_pageElements[i].GetId() === id)
                    {
                        return _pageElements[i];
                    }   
                }
            }
        }
        return null;
    };

    TPageElement.prototype.GetVisible = function(){
        return this.visible;
    };

    TPageElement.prototype.SetVisible = function(_visible){
        if (typeof _visible !== 'undefined' && _visible !== null)
            return this.visible = _visible;
    };

    TPageElement.prototype.GetTXT = function(){
        return null;
    };

    TPageElement.prototype.SetReferenceName = function(tab){
        if (typeof tab !== 'undefined')
            this.referenceName = tab;
    };

/*    TPageElement.prototype.SetReferenceValue = function(tab){
        if (typeof tab !== 'undefined')
            this.referenceValue = tab;
    };*/

    TPageElement.prototype.LinkMethod = function(){
    };

    TPageElement.prototype.ActualizeData = function(data){
        return null;
    };
    
    TPageElement.prototype.SetImageCatalog = function(catalog){
    };

    TPageElement.prototype.CalculateValue = function(value_){
        if (this.variables !== null)
            return this.variables.CalculateValue(value_);
        return null;
    };

    TPageElement.prototype.FindVariable = function(name_){
        if (this.variables !== null)
            return this.variables.FindVariable(name_);
        return null;
    };


    TPageElement.prototype.SetVariable = function(var_,name_){
        if (this.variables !== null)
            this.variables.SetVariable(var_,name_);
    };

    TPageElement.prototype.SetVariables = function(var_){
        if (this.variables !== null)
            this.variables.SetVariables(var_);
    };

    TPageElement.prototype.GetVariables = function(){
        if (this.variables !== null)
            return this.variables.GetVariables();
        return null;
    };

   TPageElement.prototype.GetObjectVariables = function(){
        return this.variables;
    };

    TPageElement.prototype.ActualizeActions = function(){
        var tmp2 = document.getElementById(this.GetId());
        if (tmp2 !== null)
            tmp2.thisObject = this;
        var objM = this.GetObjectManager();
        if (objM !== null && typeof this.actions !== 'undefined' && this.actions !== null && this.actions.length > 0)
        {
            var i,j,tmp;
            for (i = 0;i < this.actions.length;i++)
                if (typeof this.actions[i] !== 'undefined' && this.actions[i] !== null && this.actions[i].IsType('TAction'))
                {
//                    tmp2 = this.actions[i].GetTagName();
//                    if (tmp2 !== null)
                    {
                        tmp = document.getElementById(this.actions[i].GetId());
                        if (tmp !== null)
                        {
                            if (typeof tmp.actionObject === 'undefined' || tmp.actionObject === null)
                            {
                                tmp.actionObject = objM.newObject('TArrayActions');
                                tmp.actionObject.SetId(this.actions[i].GetId());
                            }
                            if (typeof tmp.actionObject !== 'undefined' && tmp.actionObject !== null)
                            {
                                tmp.actionObject.SetAction(this.actions[i]);
                                if (this.actions[i].IsType('TActionEdit'))
                                {
                                    tmp.onclick = tmp.actionObject.InteractionOnClick;
                                    tmp.onkeyup = tmp.actionObject.InteractionOnKeyUp;
                                }else
                                {
                                    if (this.actions[i].IsType('TActionInteractiveImageBitmap'))
                                    {
                                        tmp.onclick = tmp.actionObject.InteractionOnClick;
                                        tmp.onload = tmp.actionObject.InteractionOnLoad;
                                    }else
                                    {
                                        if (this.actions[i].IsType('TActionSelectRecalculate'))
                                            tmp.onchange =  tmp.actionObject.InteractionOnChange;
                                        else
                                            if (this.actions[i].IsType('TActionSlider'))
                                            {
                                                tmp.onclick = tmp.actionObject.InteractionOnClick;
                                                tmp.onchange = tmp.actionObject.InteractionOnChange;
                                            }else
                                                tmp.onclick = tmp.actionObject.InteractionOnClick;  // nazwa funkcji bez ()!
                                    }
                                }
                            }
                        }
/*                        tmp = document.getElementsByTagName(tmp2);
                        for(j = 0; j < tmp.length; j++)
                        {
                            if (tmp[j].id === this.actions[i].GetId())
                            {
                                tmp[j].actionObject = this.actions[i];
                                if (this.actions[i].IsType('TActionEdit'))
                                {
                                    tmp[j].onkeyup = this.actions[i].Interaction;
                                }else
                                    tmp[j].onclick = this.actions[i].Interaction;  // nazwa funkcji bez ()!
                            }
                        }*/
                    }
                }
        }

    };

    TPageElement.prototype.SetAction = function(action_,number){
        if (typeof action_ !== 'undefined' && action_ !== null && action_.IsType('TAction'))
        {
            if (typeof number === 'undefined' || number === null || !IsInt(number))
                number = 0;
            this.actions[number] = action_;
        }
    };

    TPageElement.prototype.GetAction = function(number){
        if (typeof number === 'undefined' || number === null || !IsInt(number))
            number = 0;
        return this.actions[number];
    };
    
    TPageElement.prototype.GetNActions = function(){
        return this.actions.length;
    };
    
    TPageElement.prototype.FindElementById = function(id){
        if (typeof id !== 'undefined' && id !== null)
        {
            if (id === this.GetId())
                return this;
        }
        return null;
    };
    
    TPageElement.prototype.Refresh = function(){
    };    
}

TPageElement.prototype = new TObjectMultilanguage();


function TActionVariables(){
    var type = 'TActionVariables';
    TActionVariables.prototype.InitConstructor = function(){
        TAction.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.variables = null;
    };
    this.InitConstructor();

    TActionVariables.prototype.InitConstructor2 = function(){
        TAction.prototype.InitConstructor2.call(this);
        var objM = this.GetObjectManager();
        if (objM !== null)
            this.variables = objM.newObject('TVariables');
    };

    TActionVariables.prototype.Init = function(_object){
        TAction.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionTimeout'))
        {
            if (typeof _object.variables !== 'undefined' && _object.variables !== null && _object.variables.IsType('TVariables'))
                this.variables = objM.copy(_object.variables);
        }
    };
    
    TActionVariables.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TAction.prototype.IsType.call(this,_type);
    };

    TActionVariables.prototype.CalculateValue = function(value_){
        if (this.variables !== null)
            return this.variables.CalculateValue(value_);
        return null;
    };

    TActionVariables.prototype.FindVariable = function(name_){
        if (this.variables !== null)
            return this.variables.FindVariable(name_);
        return null;
    };


    TActionVariables.prototype.SetVariable = function(var_,name_){
        if (this.variables !== null)
            this.variables.SetVariable(var_,name_);
    };

    TActionVariables.prototype.SetVariables = function(var_){
        if (this.variables !== null)
            this.variables.SetVariables(var_);
    };

    TActionVariables.prototype.GetVariables = function(){
        if (this.variables !== null)
            return this.variables.GetVariables();
        return null;
    };

}

TActionVariables.prototype = new TAction();

function TActionQueue(){
    var type = 'TActionQueue';
    TActionQueue.prototype.InitConstructor = function(){
        TActionVariables.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetTagName('');
        this.idNext = [];
        this.next = [];
    };
    this.InitConstructor();

    TActionQueue.prototype.Init = function(_object){
        TActionVariables.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionTimeout'))
        {
            var i;            
            if (typeof _object.idNext !== 'undefined' && _object.idNext !== null)
            {
                this.idNext = [];
                for (i = 0;i < _object.idNext.length;i++)
                {
                    this.idNext[i] = new String(_object.idNext[i]);
                    if (this.idNext[i] !== null)
                        this.idNext[i] = this.idNext[i].toString();
                }
            }
            if (typeof _object.next !== 'undefined' && _object.next !== null)
            {
                this.next = [];
                for (i = 0;i < _object.next.length;i++)
                {
                    this.next[i] = _object.next[i];
                }
            }
        }
    };
    
    TActionQueue.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TActionVariables.prototype.IsType.call(this,_type);
    };

    TActionQueue.prototype.ReadXML = function(tag){
        TActionVariables.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var i,x = tag.childNodes,jNext = 0,attr;
            for (i = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if (x[i].nodeName.toLowerCase() === 'next')
                    {
                        attr = x[i].getAttribute('id');
                        if (typeof attr !== 'undefined' && attr !== null)
                        {
                            this.idNext[jNext++] = attr;
                        }            
                    }
                }
            }
                            
        }
    };

    TActionQueue.prototype.SetNext = function(next_,number){
        if (typeof number === 'undefined' || number === null || !IsInt(number))
            number = 0;
        if (typeof next_ !== 'undefined' && next_ !== null && next_.IsType('TAction'))
        {
            this.next[number] = next_;
        }
        if (next_ === null)
            this.next[number] = null;
    };

    TActionQueue.prototype.GetIdNext = function(number){
        if (typeof number === 'undefined' || number === null || !IsInt(number))
            number = 0;
        if (number >= 0 && number < this.idNext.length)
        {
            if (typeof this.idNext[number] !== 'undefined' && this.idNext[number] !== null )
            {
                var tmp = new String(this.idNext[number]);
                if (tmp !== null)
                    return tmp.toString();
            }
        }
        return null;
    };

    TActionQueue.prototype.GetNNext = function(){
        var tmp = this.idNext.length;
        if (tmp < this.next.length)
            return this.next.length;
        else
            return tmp;
    };

    TActionQueue.prototype.GetNext = function(number){
        if (typeof number === 'undefined' || number === null || !IsInt(number))
            number = 0;
        if (number >= 0 && number < this.next.length)
        {
            return this.next[number];
        }
        return null;
    };


}

TActionQueue.prototype = new TActionVariables();

function TActionTimeout(){
    var type = 'TActionTimeout';
    TActionTimeout.prototype.InitConstructor = function(){
        TActionQueue.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetTagName('');
        this.changeVariables = [];
        this.variableValue = [];
        this.variableName = [];
        this.alpha = null;
        this.beta = null;
        this.gamma = null;
        this.timeOut = 1000;
        this.numberTimeOut = -1;
        this.rebuild = 'none';
        this.distance = 1;
    };
    this.InitConstructor();

    TActionTimeout.prototype.Init = function(_object){
        TActionQueue.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionTimeout'))
        {
            var i;            
            if (typeof _object.changeVariables !== 'undefined' && _object.changeVariables !== null)
            {
                this.changeVariables = [];
                for (i = 0;i < _object.changeVariables.length;i++)
                    this.changeVariables[i] = _object.changeVariables[i];
            }
            if (typeof _object.variableValue !== 'undefined' && _object.variableValue !== null)
            {
                this.variableValue = [];
                for (i = 0;i < _object.variableValue.length;i++)
                {
                    this.variableValue[i] = new String(_object.variableValue[i]);
                    if (this.variableValue[i] !== null)
                        this.variableValue[i] = this.variableValue[i].toString();
                }
            }
            if (typeof _object.variableName !== 'undefined' && _object.variableName !== null)
            {
                this.variableName = [];
                for (i = 0;i < _object.variableName.length;i++)
                {
                    this.variableName[i] = new String(_object.variableName[i]);
                    if (this.variableName[i] !== null)
                        this.variableName[i] = this.variableName[i].toString();
                }
            }
            if (typeof _object.alpha !== 'undefined' && _object.alpha !== null)
            {
                this.alpha = new String(_object.alpha);
                if (this.alpha !== null)
                    this.alpha = this.alpha.toString();
            }
            if (typeof _object.beta !== 'undefined' && _object.beta !== null)
            {
                this.beta = new String(_object.beta);
                if (this.beta !== null)
                    this.beta = this.beta.toString();
            }
            if (typeof _object.gamma !== 'undefined' && _object.gamma !== null)
            {
                this.gamma = new String(_object.gamma);
                if (this.gamma !== null)
                    this.gamma = this.gamma.toString();
            }
            if (typeof _object.timeOut !== 'undefined' && _object.timeOut !== null && IsNumeric(_object.timeOut))
            {
                this.timeOut = _object.timeOut;
            }
            if (typeof _object.numberTimeOut !== 'undefined' && _object.numberTimeOut !== null && IsInt(_object.numberTimeOut))
                this.numberTimeOut = _object.numberTimeOut;
            if (typeof _object.rebuild !== 'undefined' && _object.rebuild !== null)
            {
                this.rebuild = new String(_object.rebuild);
                if (this.rebuild !== null)
                    this.rebuild = this.rebuild.toString();
            }
            if (typeof _object.distance !== 'undefined' && _object.distance !== null)
            {
                this.distance = new String(_object.distance);
                if (this.distance !== null)
                    this.distance = this.distance.toString();
            }
        }
    };
    
    TActionTimeout.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TActionQueue.prototype.IsType.call(this,_type);
    };

    TActionTimeout.prototype.ReadXML = function(tag){
        TActionQueue.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr,tmp,attr2;
            attr = tag.getAttribute('timeOut');
            if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
            {
                tmp = parseFloat(attr);
                if (tmp >= 0)
                    this.timeOut = tmp;                            
            }
            attr = tag.getAttribute('rebuild');
            if (typeof attr !== 'undefined' && attr !== null)
                this.rebuild = attr;                            
            var i,x = tag.childNodes,iobj = 0,iVar = 0;
            for (i = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if (x[i].nodeName.toLowerCase() === 'object')
                    {
                        attr = x[i].getAttribute('id');
                        if (typeof attr !== 'undefined' && attr !== null)
                            this.SetId(attr,iobj++);                        
                    }
                    if (x[i].nodeName.toLowerCase() === 'var')
                    {
                        attr = x[i].getAttribute('name');
                        if (typeof attr !== 'undefined' && attr !== null)
                        {
                            attr2 = x[i].getAttribute('value');
                            if (typeof attr2 !== 'undefined' && attr2 !== null)
                            {
                                this.variableName[iVar] = attr;
                                this.variableValue[iVar++] = attr2;
                            }
                        }
                    }
                    if (x[i].nodeName.toLowerCase() === 'camera')
                    {
                        attr = x[i].getAttribute('alpha');
                        if (typeof attr !== 'undefined' && attr !== null)
                            this.alpha = attr;
                        attr = x[i].getAttribute('beta');
                        if (typeof attr !== 'undefined' && attr !== null)
                            this.beta = attr;
                        attr = x[i].getAttribute('gamma');
                        if (typeof attr !== 'undefined' && attr !== null)
                            this.gamma = attr;
                        attr = x[i].getAttribute('distance');
                        if (typeof attr !== 'undefined' && attr !== null)
                            this.distance = attr;
                    }
                }
            }
        }
    };

    TActionTimeout.prototype.Interaction = function(object){
        if (this.timeOut !== null)
        {
            var pointer = setTimeout(this.Interaction2,this.timeOut,this);
            this.numberTimeOut = AddTimeOut(pointer);
        }
    };

    TActionTimeout.prototype.Interaction2 = function(object){
        if (typeof object !== 'undefined' && object !== null && object.IsType('TActionTimeout'))
        {
            var objM = object.GetObjectManager();
            if (objM !== null)
            {
                RemoveTimeOut(object.GetNumberTimeOut());
                object.SetNumberTimeOut(-1);
                var i,n,idObj,obj,alpha,beta,gamma,action,var_;
                n = object.GetNChangeVariable();
                for (i = 0;i < n;i++)
                {
                    var_ = object.GetChangeVariable(i);
                    if (typeof var_ !== 'undefined' && var_ !== null && var_.IsType('TVariable'))
                    {
                        var_.SetValue(object.GetValueVariable(i));
                    }
                }
                
                var scene,scene_,k,obj3,tabObj,obj_,distance;
                n = object.GetNId();
                for (i = 0;i < n;i++)
                {
                    idObj = object.GetId(i);
                    if (typeof idObj !== 'undefined' && idObj !== null)
                    {
                        obj = document.getElementById(idObj);
                        if (typeof obj !== 'undefined' && obj !== null)
                        {
                            if (typeof obj.camera !== 'undefined' && obj.camera !== null)
                            {

                                if (object.GetRebuild() === 'all')
                                {
                                    scene = obj.scene;
        //                        scene_ = new THREE.Scene();
                                    scene_ = scene.GetScene();
                                    if (scene_ !== null)
                                    {
                                        for (k = scene_.children.length - 1;k >= 0;k--)
                                        {
                                            obj3 = scene_.children[k];
                                            scene_.remove(obj3);
                                        }
                                    }
                                    tabObj = obj.tabObj;
                                    if (typeof tabObj !== 'undefined' && tabObj !== null)
                                    {
                                        for (k = 0;k < tabObj.length;k++)
                                        {
                                            obj_ = tabObj[k];
                                            if (typeof obj_ !== 'undefined' && obj_ !== null && obj_.IsType('TObjectFigure'))
                                            {
                                                obj_.DrawFigure(scene);
                                            }
                                        }
                                    }
                                }

                                alpha = object.GetAlpha();
                                beta = object.GetBeta();
                                gamma = object.GetGamma();
                                distance = object.GetDistance();
                                action = objM.newObject('TActionThreeCamera');
                                if (action !== null)
                                {
                                    action.SetCamera(obj.camera);
                                    action.SetScene(obj.scene);
                                    action.SetRenderer(obj.renderer);
                                    action.SetPositionCamera(obj.cameraCoordintes); 
                                    action.SetAlpha(alpha);
                                    action.SetBeta(beta);
                                    action.SetDistance(distance);
                                    action.CalculateCameraPosition();
                                    action.RenderScene();
                                }
                            }
                        }
                    }
                }
                n = object.GetNNext();
                for (i = 0;i < n;i++)
                {
                    obj_ = object.GetNext(i);
                    if (typeof obj_ !== 'undefined' && obj_ !== null && obj_.IsType('TAction'))
                    {
                        obj_.Interaction(null);
                    }
                }                
                
            }
        }
    };

    TActionTimeout.prototype.GetAlpha = function(){
        var tmp = this.CalculateValue(this.alpha);
        if (tmp !== null)
            tmp = tmp*Math.PI/180;
        return tmp;
    };

    TActionTimeout.prototype.GetBeta = function(){
        var tmp = this.CalculateValue(this.beta);
        if (tmp !== null)
            tmp = tmp*Math.PI/180;
        return tmp;
    };
    
    TActionTimeout.prototype.GetGamma = function(){
        return this.CalculateValue(this.gamma);
    };

    TActionTimeout.prototype.SetNumberTimeOut = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number))
        {
            this.numberTimeOut = number;
        }
    };
    
    TActionTimeout.prototype.GetNumberTimeOut = function(){
        return this.numberTimeOut;
    };

    TActionTimeout.prototype.ActualizeVariable = function(){
        var i,n = this.variableName.length,var_;
        for (i = 0;i < n;i++)
        {
            var_ = this.FindVariable(this.variableName[i]);
            if (var_ !== null)
                this.changeVariables[i] = var_;
        }
    };

    TActionTimeout.prototype.GetNChangeVariable = function(){
        return this.changeVariables.length;
    };

    TActionTimeout.prototype.GetChangeVariable = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0 && number < this.changeVariables.length)
        {
            return this.changeVariables[number];
        }
        return null;
    };

    TActionTimeout.prototype.GetValueVariable = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0 && number < this.variableValue.length)
        {
            return this.CalculateValue(this.variableValue[number]);
        }
        return null;
    };

    TActionTimeout.prototype.GetTimeOut = function(){
        return this.timeOut;
    };

    TActionTimeout.prototype.GetRebuild = function(){
        if (this.rebuild !== null)
        {
            var tmp = new String(this.rebuild);
            if (tmp !== null)
                return tmp.toString();
        }
        return null;
    };

    TActionTimeout.prototype.GetDistance = function(){
        return this.CalculateValue(this.distance);
    };
    
    TActionTimeout.prototype.SetDistance = function(dist){
        if (typeof dist !== 'undefined' && dist !== null && IsNumeric(dist))
            this.distance = dist;
    };

}

TActionTimeout.prototype = new TActionQueue();

function TActionTimeoutIncrease(){
    var type = 'TActionTimeoutIncrease';
    TActionTimeoutIncrease.prototype.InitConstructor = function(){
        TActionTimeout.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetTagName('');
//        this.incVariableValue = [];
//        this.incAlpha = null;
//        this.incBeta = null;
        this.n = 1;
        this.counter = 0;
        this.SetDistance(0);
    };
    this.InitConstructor();

    TActionTimeoutIncrease.prototype.Init = function(_object){
        TActionTimeout.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TActionTimeout'))
        {
/*            var i;            
            if (typeof _object.incVariableValue !== 'undefined' && _object.incVariableValue !== null)
            {
                this.incVariableValue = [];
                for (i = 0;i < _object.incVariableValue.length;i++)
                {
                    this.incVariableValue[i] = new String(_object.incVariableValue[i]);
                    if (this.incVariableValue[i] !== null)
                        this.incVariableValue[i] = this.incVariableValue[i].toString();
                }
            }
            if (typeof _object.incAlpha !== 'undefined' && _object.incAlpha !== null)
            {
                this.incAlpha = new String(_object.incAlpha);
                if (this.incAlpha !== null)
                    this.incAlpha = this.incAlpha.toString();
            }
            if (typeof _object.incBeta !== 'undefined' && _object.incBeta !== null)
            {
                this.incBeta = new String(_object.incBeta);
                if (this.incBeta !== null)
                    this.incBeta = this.incBeta.toString();
            }*/
            if (typeof _object.n !== 'undefined' && _object.n !== null && IsInt(_object.n))
                this.n = _object.n;
            if (typeof _object.counter !== 'undefined' && _object.counter !== null && IsInt(_object.counter))
                this.counter = _object.counter;
        }
    };
    
    TActionTimeoutIncrease.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TActionTimeout.prototype.IsType.call(this,_type);
    };

    TActionTimeoutIncrease.prototype.ReadXML = function(tag){
        TActionTimeout.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr,tmp,attr2;
            attr = tag.getAttribute('n');
            if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
            {
                tmp = parseFloat(attr);
                if (tmp >= 0)
                    this.n = tmp;                            
            }
/*            var i,x = tag.childNodes,iobj = 0,iVar = 0;
            for (i = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if (x[i].nodeName.toLowerCase() === 'object')
                    {
                        attr = x[i].getAttribute('id');
                        if (typeof attr !== 'undefined' && attr !== null)
                            this.SetId(attr,iobj++);                        
                    }
                    if (x[i].nodeName.toLowerCase() === 'var')
                    {
                        attr = x[i].getAttribute('name');
                        if (typeof attr !== 'undefined' && attr !== null)
                        {
                            attr2 = x[i].getAttribute('value');
                            if (typeof attr2 !== 'undefined' && attr2 !== null)
                            {
                                this.variableName[iVar] = attr;
                                this.variableValue[iVar++] = attr2;
                            }
                        }
                    }
                    if (x[i].nodeName.toLowerCase() === 'camera')
                    {
                        attr = x[i].getAttribute('alpha');
                        if (typeof attr !== 'undefined' && attr !== null)
                            this.alpha = attr;
                        attr = x[i].getAttribute('beta');
                        if (typeof attr !== 'undefined' && attr !== null)
                            this.beta = attr;
                        attr = x[i].getAttribute('gamma');
                        if (typeof attr !== 'undefined' && attr !== null)
                            this.gamma = attr;
                    }
                }
            }*/
        }
    };

    TActionTimeoutIncrease.prototype.Interaction = function(object){
        if (this.timeOut !== null)
        {
            this.counter = 0;
            if (this.n > 0)
            {
                var pointer = setTimeout(this.Interaction2,this.GetTimeOut(),this);
                this.SetNumberTimeOut(AddTimeOut(pointer));
            }
        }
    };

    TActionTimeoutIncrease.prototype.Interaction2 = function(object){
        if (typeof object !== 'undefined' && object !== null && object.IsType('TActionTimeout'))
        {
            var objM = object.GetObjectManager();
            if (objM !== null)
            {
                RemoveTimeOut(object.GetNumberTimeOut());
                object.SetNumberTimeOut(-1);
                var i,n,idObj,obj,alpha,beta,action,var_,value;
                n = object.GetNChangeVariable();
                for (i = 0;i < n;i++)
                {
                    var_ = object.GetChangeVariable(i);
                    if (typeof var_ !== 'undefined' && var_ !== null && var_.IsType('TVariable'))
                    {
                        value = var_.GetValue();
                        if (value !== null && object.GetValueVariable(i) !== null)
                            var_.SetValue(value + object.GetValueVariable(i));
                    }
                }
                
                var scene,scene_,k,obj3,tabObj,obj_,distance;
                n = object.GetNId();
                for (i = 0;i < n;i++)
                {
                    idObj = object.GetId(i);
                    if (typeof idObj !== 'undefined' && idObj !== null)
                    {
                        obj = document.getElementById(idObj);
                        if (typeof obj !== 'undefined' && obj !== null)
                        {
                            if (typeof obj.camera !== 'undefined' && obj.camera !== null)
                            {

/*                                scene = obj.scene;
    //                        scene_ = new THREE.Scene();
                                scene_ = scene.GetScene();
                                if (scene_ !== null)
                                {
                                    for (k = scene_.children.length - 1;k >= 0;k--)
                                    {
                                        obj3 = scene_.children[k];
                                        scene_.remove(obj3);
                                    }
                                }
                                tabObj = obj.tabObj;
                                if (typeof tabObj !== 'undefined' && tabObj !== null)
                                {
                                    for (k = 0;k < tabObj.length;k++)
                                    {
                                        obj_ = tabObj[k];
                                        if (typeof obj_ !== 'undefined' && obj_ !== null && obj_.IsType('TObjectFigure'))
                                        {
                                            obj_.DrawFigure(scene);
                                        }
                                    }
                                }*/

                                alpha = object.GetAlpha();
                                beta = object.GetBeta();
                                distance = object.GetDistance();
                                action = objM.newObject('TActionThreeCamera');
                                if (action !== null)
                                {
                                    action.SetCamera(obj.camera);
                                    action.SetScene(obj.scene);
                                    action.SetRenderer(obj.renderer);
                                    action.SetPositionCamera(obj.cameraCoordintes);
                                    action.IncreaseDistance(distance);
                                    if (action.GetAlpha() !== null)
                                    {
                                        alpha = alpha + action.GetAlpha();
                                        action.SetAlpha(alpha);
                                    }
                                    if (action.GetAlpha() !== null)
                                    {
                                        beta = beta + action.GetBeta();
                                        action.SetBeta(beta);
                                    }
                                    action.CalculateCameraPosition();
                                    action.RenderScene();
                                }
                            }
                        }
                    }
                }
                
                object.IncCounter();
                if (object.GetCounter() < object.GetN())
                {
                    var pointer = setTimeout(object.Interaction2,object.GetTimeOut(),object);
                    object.SetNumberTimeOut(AddTimeOut(pointer));
                    
                }else
                {
                    n = object.GetNNext();
                    for (i = 0;i < n;i++)
                    {
                        obj_ = object.GetNext(i);
                        if (typeof obj_ !== 'undefined' && obj_ !== null && obj_.IsType('TAction'))
                        {
                            obj_.Interaction(null);
                        }
                    }                
                }
            }
        }
    };

    TActionTimeoutIncrease.prototype.GetCounter = function(){
        return this.counter;
    };

    TActionTimeoutIncrease.prototype.GetN = function(){
        return this.n;
    };
    
    TActionTimeoutIncrease.prototype.IncCounter = function(){
        this.counter++;
    };

}

TActionTimeoutIncrease.prototype = new TActionTimeout();


function TTimer(){
    var type = 'TTimer';
    TTimer.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.idStart = null;
    };
    this.InitConstructor();

    TTimer.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TTimer'))
        {
            if (typeof _object.idStart !== 'undefined' && _object.idStart !== null)
            {
                this.idStart = new String(_object.idStart);
                if (this.idStart !== null)
                    this.idStart = this.idStart.toString();
            }
        }
    };
    
    TTimer.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };

    TTimer.prototype.ActualizeActions = function(){
        var i,n = this.GetNActions(),obj;
        if (n !== null)
        {
            for (i=0;i<n;i++)
            {
                obj = this.GetAction(i);
                if (obj !== null)
                {
                    obj.SetVariables(this.GetVariables());
                }
            }
        }
        this.ActualizeId();
        this.ActualizeVariable();
    };

    TTimer.prototype.ReadXML = function(tag,fun){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var tmp = tag.getAttribute('start');
            if (typeof tmp !== 'undefined' && tmp !== null)
            {
                this.idStart = tmp;
                var i,x = tag.childNodes,obj,tmp = null,j=0;
                for (i = 0;i < x.length;i++)
                {
                    if (x[i].nodeType === 1)
                    {
                        if (x[i].nodeName.toLowerCase() === 'action')
                        {
                            tmp = x[i].getAttribute('type');
                            if (typeof tmp !== 'undefined' && tmp !== null)
                            {
                                if (tmp === 'TimeOut')
                                {
                                    obj = objM.newObject('TActionTimeout');
                                    if (obj !== null)
                                    {
                                        this.SetAction(obj,j++);
                                        obj.ReadXML(x[i]);
                                    }
                                }
                                if (tmp === 'Increase')
                                {
                                    obj = objM.newObject('TActionTimeoutIncrease');
                                    if (obj !== null)
                                    {
                                        this.SetAction(obj,j++);
                                        obj.ReadXML(x[i]);
                                    }
                                    
                                }
                            }
                        }
                    }
                }
            }
        }
    };
    TTimer.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            _object.Add('Timer',this);
        }        
    };
    TTimer.prototype.Start = function(){
        if (typeof this.idStart !== 'undefined' && this.idStart !== null)
        {
            var obj = this.FindActionById(this.idStart);
            if (obj !== null && obj.IsType('TAction'))
            {
                obj.Interaction(null);
            }
        }
    };

    TTimer.prototype.FindActionById = function(id_){
        if (typeof id_ !== 'undefined' && id_ !== null)
        {
            var i,n = this.GetNActions(),obj,id2;
            if (n !== null)
            {
                for (i=0;i<n;i++)
                {
                    obj = this.GetAction(i);
                    if (obj !== null && obj.IsType('TAction'))
                    {
                        id2 = obj.GetIdAction();
                        if (id2 === id_)
                            return obj;
                    }
                }
            }
        }
        return null;
    };

    TTimer.prototype.ActualizeId = function(){
        var i,j,n = this.GetNActions(),obj,obj2,m;
        if (n !== null)
        {
            for (i=0;i<n;i++)
            {
                obj = this.GetAction(i);
                if (obj !== null && obj.IsType('TActionQueue'))
                {
                    m = obj.GetNNext();
                    for (j = 0;j < m;j++)
                    {
                        obj2 = this.FindActionById(obj.GetIdNext(j));
                        if (obj2 !== null)
                            obj.SetNext(obj2,j);
                    }
                }
            }
        }
    };

    TTimer.prototype.ActualizeVariable = function(){
        var i,j,n = this.GetNActions(),obj,obj2,m;
        if (n !== null)
        {
            for (i=0;i<n;i++)
            {
                obj = this.GetAction(i);
                if (obj !== null && obj.IsType('TActionQueue'))
                {
                    obj.ActualizeVariable();
                }
            }
        }
    };

}

TTimer.prototype = new TPageElement();


function TVar(){
    var type = 'TVar';
    TVar.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);   
        this.typePageElement = 'Var';
    };
    this.InitConstructor();

    TVar.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };

    TVar.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TVariable'))
        {
        }
    };


    TVar.prototype.ReadXML = function(tag,fun){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var tmp = tag.getAttribute('typeVar');
            if (typeof tmp !== 'undefined' && tmp !== null)
            {
                var obj = null;
                switch(tmp)
                {
                    case 'int':
                        obj = objM.newObject('TVariableInt');
                        break;
                    case 'double':
                        obj = objM.newObject('TVariableDouble');
                        break;
                    case 'string':
                        obj = objM.newObject('TVariableString');
                        break;
                    case 'void':
                        obj = objM.newObject('TVariableVoidTXT');
                        break;
                    case 'image':
                        obj = objM.newObject('TVariableImage');
                        break;
                }
                if (obj !== null)
                {
                    obj.ReadXML(tag,fun);
                    this.SetVariable(obj);
                }
            }
        }
    };
}

TVar.prototype = new TPageElement();

function TFun(){
    var type = 'TFun';
    TFun.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);   
        this.typePageElement = 'Fun';
    };
    this.InitConstructor();

    TFun.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };

    TFun.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TVariable'))
        {
        }
    };


    TFun.prototype.ReadXML = function(tag,fun){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var tmp = tag.getAttribute('function');
            if (typeof tmp !== 'undefined' && tmp !== null)
            {
                var obj = objM.newObject('TVariableFunction');
                if (obj !== null)
                {
                    obj.ReadXML(tag,fun);
                    this.SetVariable(obj);
                }
            }
        }
    };
}

TFun.prototype = new TPageElement();


function TTitle(){
    var type = 'TTitle';
    TTitle.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.title = null;
        this.shortHeading = null;
        this.level = 0;
        this.SetTypePageElement('Title');
    };
    this.InitConstructor();

    TTitle.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TTitle'))
        {
            if (typeof _object.title !== 'undefined' && _object.title !== null && _object.title.IsType('TMultilanguageStringData'))
                this.title = objM.copy(_object.title);
            if (typeof _object.shortHeading !== 'undefined' && _object.shortHeading !== null && _object.shortHeading.IsType('TMultilanguageStringData'))
                this.shortHeading = objM.copy(_object.shortHeading);
            if (typeof _object.level !== 'undefined' && _object.level !== null && IsInt(_object.level))
                this.level = _object.level;
        }
    };

    TTitle.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    
    TTitle.prototype.AddTitleStr = function(title,_language){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof title !== 'undefined' && typeof _language !== 'undefined' && _language !== null)
        {
            if (this.title === null)
                this.title = objM.newObject('TMultilanguageStringData');
            if (this.title !== null)
            {
                this.title.SetStringData(title,_language);
            }
        }
    };    
    TTitle.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.title !== 'undefined' && this.title !== null)
            {
                var tmp = [];
                tmp[0] = this.GetLevel();
                tmp[1] = this.GetId();
                tmp[2] = this.GetVisible();
                if (this.shortHeading !== null)
                    tmp[3] = this.shortHeading.GetStringData();
                else
                    tmp[3] = null;
                _object.Add('Title',this.title.GetStringData(),tmp);
            }
//            if (typeof this.title !== 'undefined' && this.title !== null && this.title.IsType('TMultilanguageStringData'))
//                _object.Title(this.title.GetStringData(),null,this.GetLevel());
        }        
    };

    TTitle.prototype.GetLevel = function(){
        return this.level;
    };

    TTitle.prototype.SetLevel = function(_level){
        if (typeof _level !== 'undefined' && _level !== null && IsInt(_level))
            this.level = _level;
    };

    TTitle.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        if (this.title !== null)
            this.title.ChangeCurrentLanguageNumber(_language);
    };

    TTitle.prototype.ParseXML = function(tag1,tag2){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag2 !== 'undefined' && tag2 !== null)
        {
            var i,x = tag2.childNodes,x2;
            for (i = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Title')
                    {
                        x2 = x[i].childNodes;
                        if (this.title === null)
                            this.title = objM.newObject('TMultilanguageStringData');
                        if (this.title !== null)
                        {
                            this.title.SetStringData(x2[0].nodeValue);
                        }
                    }
                    if(x[i].nodeName === 'ShortHeading')
                    {
                        x2 = x[i].childNodes;
                        if (this.shortHeading === null)
                            this.shortHeading = objM.newObject('TMultilanguageStringData');
                        if (this.shortHeading !== null)
                        {
                            this.shortHeading.SetStringData(x2[0].nodeValue);
                        }
                    }
                }
            }
        }
        if (typeof tag1 !== 'undefined' && tag1 !== null)
        {
            var tmp = tag1.getAttribute('level');
            tmp = parseInt(tmp);
            if (tmp !== null && IsInt(tmp))
                this.level = tmp;
        }
        
    };

    TTitle.prototype.GetTitle = function(){
        return this.title;
    };

}

TTitle.prototype = new TPageElement();

function TPageElementPresentationTitle(){
    var type = 'TPageElementPresentationTitle';
    TPageElementPresentationTitle.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.title = null;
        this.level = 0;
        this.SetTypePageElement('Title');
    };
    this.InitConstructor();

    TPageElementPresentationTitle.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TPageElementPresentationTitle'))
        {
            if (typeof _object.title !== 'undefined' && _object.title !== null && _object.title.IsType('TParagraph'))
                this.title = objM.copy(_object.title);
            if (typeof _object.level !== 'undefined' && _object.level !== null && IsInt(_object.level))
                this.level = _object.level;
        }
    };

    TPageElementPresentationTitle.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    
    TPageElementPresentationTitle.prototype.AddTitleStr = function(title,_language){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof title !== 'undefined' && typeof _language !== 'undefined' && _language !== null)
        {
            var tmp;
            if (this.title === null)
            {
                this.title = objM.newObject('TParagraph');
                tmp = objM.newObject('TParagraphString');
                if (tmp !== null && this.title !== null)
                {
                    tmp.SetStringData(title,_language);
                    this.title.SetNewLineYN(false);
                    this.title.AddElement(tmp,0);
                }
            }else
            {
                tmp = this.title.GetElement(0);
                if (tmp !== null && tmp.IsType('TParagraphString'))
                    tmp.SetStringData(title,_language);                
            }
        }
    };    
    TPageElementPresentationTitle.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.title !== 'undefined' && this.title !== null)
            {
                var tmp = [];
                tmp[0] = this.GetLevel();
                tmp[1] = this.GetId();
                if (this.title !== null && this.title.IsType('TParagraph'))
                {
                    var tmp2 = this.title.GetElement(0);
                    if (tmp2 !== null && tmp2.IsType('TParagraphString'))
                        _object.Add('Title',tmp2.GetStringData(),tmp);
                }
            }
        }        
    };

    TPageElementPresentationTitle.prototype.GetLevel = function(){
        return this.level;
    };

    TPageElementPresentationTitle.prototype.SetLevel = function(_level){
        if (typeof _level !== 'undefined' && _level !== null && IsInt(_level))
            this.level = _level;
    };

    TPageElementPresentationTitle.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        if (this.title !== null)
            this.title.ChangeCurrentLanguageNumber(_language);
    };

    TPageElementPresentationTitle.prototype.GetTitle = function(){
        return this.title;
    };

    TPageElementPresentationTitle.prototype.ParseXML = function(tag1,tag2){
        TPageElement.prototype.ParseXML.call(this,tag1,tag2);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag2 !== 'undefined' && tag2 !== null)
        {
            var i,x = tag2.childNodes;
            for (i = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 3)
                {

                    if (this.title === null)
                    {
                        this.title = objM.newObject('TParagraph');
                        this.title.SetNewLineYN(false);
                        tmp = objM.newObject('TParagraphString');
                        if (tmp !== null)
                        {
                            this.title.AddElement(tmp,0);
                        }
                    }
                    if (this.title !== null)
                    {
                        var tmp2 = this.title.GetElement(0);
                        if (tmp2 !== null && tmp2.IsType('TParagraphString'))
                            tmp2.SetStringData(x[i].nodeValue);
                    }
                    
                }
            }
            var tmp = tag1.getAttribute('level');
            if (typeof tmp !== 'undefined' && tmp !== null && IsInt(tmp))
            {
                this.SetLevel(tmp);
            }
        }
    };

}

TPageElementPresentationTitle.prototype = new TPageElement();

function TPaperTitle(){
    var type = 'TPaperTitle';
    TPaperTitle.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.title = null;
        this.subtitle = null;
        this.SetTypePageElement('PaperTitle');
    };
    this.InitConstructor();

    TPaperTitle.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TPaperTitle'))
        {
            if (typeof _object.title !== 'undefined' && _object.title !== null && _object.title.IsType('TMultilanguageStringData'))
                this.title = objM.copy(_object.title);
            if (typeof _object.subtitle !== 'undefined' && _object.subtitle !== null && _object.subtitle.IsType('TMultilanguageStringData'))
                this.subtitle = objM.copy(_object.subtitle);
        }
    };

    TPaperTitle.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    
    TPaperTitle.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.title !== 'undefined' && this.title !== null)
                _object.Add('TitlePaper',this.title.GetStringData());
            if (typeof this.subtitle !== 'undefined' && this.subtitle !== null)
                _object.Add('Subtitle',this.subtitle.GetStringData());
        }        
    };

    TPaperTitle.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        if (this.title !== null)
            this.title.ChangeCurrentLanguageNumber(_language);
        if (this.subtitle !== null)
            this.subtitle.ChangeCurrentLanguageNumber(_language);
    };

    TPaperTitle.prototype.ParseXML = function(tag1,tag2){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag2 !== 'undefined' && tag2 !== null)
        {
            var i,x = tag2.childNodes,x2;
            for (i = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Title')
                    {
                        x2 = x[i].childNodes;
                        if (this.title === null)
                            this.title = objM.newObject('TMultilanguageStringData');
                        if (this.title !== null)
                        {
                            this.title.SetStringData(x2[0].nodeValue);
                        }
                    }
                    if(x[i].nodeName === 'Subtitle')
                    {
                        x2 = x[i].childNodes;
                        if (this.subtitle === null)
                            this.subtitle = objM.newObject('TMultilanguageStringData');
                        if (this.subtitle !== null)
                        {
                            this.subtitle.SetStringData(x2[0].nodeValue);
                        }
                    }
                }
            }
        }
    };

}

TPaperTitle.prototype = new TPageElement();

function TParagraphElement(){
    var type = 'TParagraphElement';
    TParagraphElement.prototype.InitConstructor = function(){
        TObjectMultilanguage.prototype.InitConstructor.call(this);
        this.SetType(type);     
        this.variables = null;
        this.classStyle = null;
        this.functionName = null;
    };
    this.InitConstructor();

    TParagraphElement.prototype.InitConstructor2 = function(){
        TObjectMultilanguage.prototype.InitConstructor2.call(this);
        var objM = this.GetObjectManager();
        if (objM !== null)
            this.variables = objM.newObject('TVariables');
    };

    TParagraphElement.prototype.Init = function(_object){
        TObjectMultilanguage.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphElement'))
        {
            if (typeof _object.variables !== 'undefined' && _object.variables !== null && _object.variables.IsType('TVariables'))
                this.variables = objM.copy(_object.variables);
            if (typeof _object.classStyle !== 'undefined' && _object.classStyle !== null)
            {
                this.classStyle = new String(_object.classStyle);
                this.classStyle = this.classStyle.toString();
            }
            if (typeof _object.functionName !== 'undefined' && _object.functionName !== null)
            {
                this.functionName = new String(_object.functionName);
                this.functionName = this.functionName.toString();
            }
        }
    };

    TParagraphElement.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectMultilanguage.prototype.IsType.call(this,_type);
    };
    
    TParagraphElement.prototype.ParseXML = function(tag1){
        if (typeof tag1 !== 'undefined' && tag1 !== null)
        {
            this.classStyle = tag1.getAttribute('style');
            this.SetFunctionName(tag1.getAttribute('function'));
        }
    };

    TParagraphElement.prototype.Draw = function(_object){
    };

    TParagraphElement.prototype.ChangeCurrentLanguageNumber = function(_language){
    };

    TParagraphElement.prototype.CalculateValue = function(value_){
        if (this.variables !== null)
            return this.variables.CalculateValue(value_);
        return null;
    };

    TParagraphElement.prototype.FindVariable = function(name_){
        if (this.variables !== null)
            return this.variables.FindVariable(name_);
        return null;
    };


    TParagraphElement.prototype.SetVariable = function(var_,name_){
        if (this.variables !== null)
            this.variables.SetVariable(var_,name_);
    };

    TParagraphElement.prototype.SetVariables = function(var_){
        if (this.variables !== null)
            this.variables.SetVariables(var_);
    };

    TParagraphElement.prototype.GetVariables = function(){
        if (this.variables !== null)
            return this.variables.GetVariables();
        return null;
    };

    TParagraphElement.prototype.GetObjectVariables = function(){
        return this.variables;
    };


    TParagraphElement.prototype.GetClassStyle = function(){
        if (this.classStyle !== null)
        {
            var tmp = new String(this.classStyle);
            if (tmp !== null)
                return tmp.toString();
        }
        return null;
    };

    TParagraphElement.prototype.SetClassStyle = function(classStyle_){
        if (typeof classStyle_ !== 'undefined' && classStyle_ !== null)
        {
            this.classStyle = new String(classStyle_);
            if (this.classStyle !== null)
                this.classStyle = this.classStyle.toString();
        }
        if (classStyle_ === null)
            this.classStyle = null;
    };

    TParagraphElement.prototype.Refresh = function(){
    };


    TParagraphElement.prototype.GetFunctionName = function(){
        if (this.functionName !== null)
        {
            var tmp = new String(this.functionName);
            return tmp.toString();
        }
        return null;
    };

    TParagraphElement.prototype.SetFunctionName = function(name_){
        if (typeof name_ !== 'undefined' && name_ !== null)
        {
            this.functionName = new String(name_);
            this.functionName = this.functionName.toString();
        }        
    };

    TParagraphElement.prototype.GetValueVariable = function(name_){
        if (this.variables !== null)
            return this.variables.GetValueVariable(name_);
        return null;
    };

    TParagraphElement.prototype.SetValueVariable = function(name_,value){
        this.variables.SetValueVariable(name_,value);
    };

    TParagraphElement.prototype.GetTXT = function(){
        return null;
    };

}

TParagraphElement.prototype = new TObjectMultilanguage();

function TParagraphString(){
    var type = 'TParagraphString';
    TParagraphString.prototype.InitConstructor = function(){
        TParagraphElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.data = null;
    };
    this.InitConstructor();

    TParagraphString.prototype.Init = function(_object){
        TParagraphElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphString'))
        {
            if (typeof _object.data !== 'undefined' && _object.data !== null && _object.data.IsType('TMultilanguageStringData'))
                this.data = objM.copy(_object.data);
        }
    };

    TParagraphString.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphElement.prototype.IsType.call(this,_type);
    };
    
    TParagraphString.prototype.ChangeCurrentLanguageNumber = function(_language){
        TParagraphElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        if (this.data !== null)
        {
            this.data.ChangeCurrentLanguageNumber(_language);
        }
    };

    TParagraphString.prototype.GetStringData = function(){
        if (typeof this.data !== 'undefined' && this.data !== null && this.data.IsType('TMultilanguageStringData'))
        {
            return this.data.GetStringData();
        }
        return null;
    };

    TParagraphString.prototype.SetStringData = function(_string,lang){
        if (typeof _string !== 'undefined' && _string !== null)
        {
            if (this.data === null)
            {
                var objM = this.GetObjectManager();
                if (objM !== null)
                    this.data = objM.newObject('TMultilanguageStringData');
            }
            if (this.data !== null)
            {
                this.data.SetStringData(_string,lang);
            }
        }        
    };

    TParagraphString.prototype.ParseXML = function(tag){
        if (typeof tag !== 'undefined' && tag !== null)
        {
            if (tag.nodeType === 3)
                this.SetStringData(tag.nodeValue);
//            var x2 = tag.childNodes;
//            this.SetStringData(x2[0].nodeValue);
        }    
    };

    TParagraphString.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            _object.Add('PT',this.GetStringData());
        }
    };

    TParagraphString.prototype.GetTXT = function(){
        return this.GetStringData();
    };


}

TParagraphString.prototype = new TParagraphElement();

function TParagraphSymbol(){
    var type = 'TParagraphSymbol';
    TParagraphSymbol.prototype.InitConstructor = function(){
        TParagraphElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.symbol = '';
    };
    this.InitConstructor();

    TParagraphSymbol.prototype.Init = function(_object){
        TParagraphElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphSymbol'))
        {
            if (typeof _object.symbol !== 'undefined' && _object.symbol !== null)
            {
                this.symbol = new String(_object.symbol);
                this.symbol = this.symbol.toString();
            }
        }
    };

    TParagraphSymbol.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphElement.prototype.IsType.call(this,_type);
    };

    TParagraphSymbol.prototype.GetSymbol = function(){
        return this.symbol;
    };

    TParagraphSymbol.prototype.SetSymbol = function(_symbol){
        if (typeof _symbol !== 'undefined' && _symbol !== null)
        {
            this.symbol = new String(_symbol);
            this.symbol = this.symbol.toString();
        }        
    };
    
    TParagraphSymbol.prototype.ParseXML = function(tag){
        if (typeof tag !== 'undefined' && tag !== null)
        {
            if (tag.nodeName === 'S')
                this.SetSymbol('Space');
            else
                this.SetSymbol(tag.nodeName);
        }    
    };

    TParagraphSymbol.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
            {
                _object.Add('Symbol',this.GetSymbol());
            }
        }
    };

}

TParagraphSymbol.prototype = new TParagraphElement();

function TParagraphSpaceLength(){
    var type = 'TParagraphSpaceLength';
    TParagraphSpaceLength.prototype.InitConstructor = function(){
        TParagraphElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.length_ = '';
    };
    this.InitConstructor();

    TParagraphSpaceLength.prototype.Init = function(_object){
        TParagraphElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphSpaceLength'))
        {
            if (typeof _object.length_ !== 'undefined' && _object.length_ !== null)
            {
                this.length_ = new String(_object.length_);
                if (this.length_ !== null)
                    this.length_ = this.length_.toString();
            }
        }
    };

    TParagraphSpaceLength.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphElement.prototype.IsType.call(this,_type);
    };

    TParagraphSpaceLength.prototype.GetLength = function(){
        return this.length_;
    };

    TParagraphSpaceLength.prototype.SetLength = function(_length){
        if (typeof _length !== 'undefined' && _length !== null)
        {
            this.length_ = new String(_length);
            if (this.length_)
                this.length_ = this.length_.toString();
        }    
    };
    
    TParagraphSpaceLength.prototype.ParseXML = function(tag){
        if (typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('l');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                this.SetLength(attr);
            }

        }    
    };

    TParagraphSpaceLength.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
            {
                _object.Add('SpaceLength',this.GetLength());
            }
        }
    };

}

TParagraphSpaceLength.prototype = new TParagraphElement();

function TParagraphSelectStart(){
    var type = 'TParagraphSelectStart';
    TParagraphSelectStart.prototype.InitConstructor = function(){
        TParagraphElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.id = null;
//        this.classStyle = null;
        this.title = null;
        this.variable = null;
        this.actions = [];
    };
    this.InitConstructor();

    TParagraphSelectStart.prototype.Init = function(_object){
        TParagraphElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphFormStart'))
        {
            if (typeof _object.id !== 'undefined' && _object.id !== null)
            {
                this.id = new String(_object.id);
                this.id = this.id.toString();
            }
/*            if (typeof _object.classStyle !== 'undefined' && _object.classStyle !== null)
            {
                this.classStyle = new String(_object.classStyle);
                this.classStyle = this.classStyle.toString();
            }*/
            if (typeof _object.title !== 'undefined' && _object.title !== null)
            {
                this.title = new String(_object.title);
                this.title = this.title.toString();
            }
            if (typeof _object.variable !== 'undefined' && _object.variable !== null && _object.variable.IsType('TVariable'))
                this.variable = _object.variable;
            if (typeof _object.actions !== 'undefined' && _object.actions !== null )
            {
                this.actions = [];
                for (i = 0;i < _object.actions.length;i++)
                {
                    if (typeof _object.actions[i] !== 'undefined' && _object.actions[i] !== null && _object.actions[i].IsType('TActionEdit'))
                    {
                        this.actions[i] = objM.copy(_object.actions[i]);
                    }
                }
            }
        }
    };

    TParagraphSelectStart.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphElement.prototype.IsType.call(this,_type);
    };

    TParagraphSelectStart.prototype.ParseXML = function(tag){
        TParagraphElement.prototype.ParseXML.call(this,tag);
        if (typeof tag !== 'undefined' && tag !== null)
        {
            var tmp = tag.getAttribute('title');
            if (tmp !== null)
                this.title = tmp;
            this.id = tag.getAttribute('id');
//            this.classStyle = tag.getAttribute('style');
            var i,j=0,x = tag.childNodes,x2,k;
            attr = tag.getAttribute('nameVariable');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                tmp = this.FindVariable(attr);
                if (typeof tmp !== 'undefined' && tmp !== null && tmp.IsType('TVariable'))
                    data = tmp.GetValue();
            }
            if (tmp !== null)
            {
                this.variable = tmp;
                if (tmp.IsType('TVariableString'))
                    this.variable.SetValue(data);
                else
                {
                    this.variable.SetEquation(data);
                    this.variable.SetValue(this.CalculateValue(data));
                }
                
            }
            for (i = 0,k = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Id')
                    {
                        x2 = x[i].childNodes;
                        attr = x[i].getAttribute('id');
                        if (attr !== null)
                        {
                            if (k === 0)
                            {
                                this.actions[j] = this.NewActtion();
                                this.actions[j].SetObject(this);
                                this.actions[j].SetId(this.GetId());
                            }
                            if (this.actions[j] !== null)
                            {
                                if (k === 0)
                                    this.actions[j].SetId(this.GetId());
                                this.actions[j].SetId(attr,k++);
                            }
                        }
                    }
                }
            }
        }    
    };

    TParagraphSelectStart.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
            {
//                _object.Add('SelectStart','');
                var tmp = [];
                tmp[0] = this.classStyle;
                tmp[1] = this.title;
                tmp[2] = this.GetFunctionName();
                if (this.id === null)
                    _object.Add('SelectStart','',tmp);
                else
                    _object.Add('SelectStart',this.id,tmp);
            }
        }
    };

    TParagraphSelectStart.prototype.NewActtion = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.newObject('TActionSelectRecalculate');
        return null;
    };

    TParagraphSelectStart.prototype.GetNActions = function(){
        if (typeof this.actions !== 'undefined' && this.actions !== null)
            return this.actions.length;
        return null;
    };

    TParagraphSelectStart.prototype.GetAction = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0 && number < this.actions.length)
            return this.actions[number];
        return null;
    };

    TParagraphSelectStart.prototype.SetId = function(id_){
        if (typeof id_ !== 'undefined' && id_ !== null)
        {
            this.id = new String(id_);
            if (this.id !== null)
                this.id = this.id.toString();
        }
        if (id_ === null)
            this.id = null;
    };

    TParagraphSelectStart.prototype.GetId = function(){
        var tmp = new String(this.id);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TParagraphSelectStart.prototype.GetVariable = function(){
        return this.variable;
    };

    TParagraphSelectStart.prototype.GetValue = function(){
        if (this.variable != null)
            return this.variable.GetValue();
        else
            return null;
    };

}

TParagraphSelectStart.prototype = new TParagraphElement();

function TParagraphSelectStop(){
    var type = 'TParagraphSelectStop';
    TParagraphSelectStop.prototype.InitConstructor = function(){
        TParagraphElement.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TParagraphSelectStop.prototype.Init = function(_object){
        TParagraphElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphFormStop'))
        {
        }
    };

    TParagraphSelectStop.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphElement.prototype.IsType.call(this,_type);
    };

    TParagraphSelectStop.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
            {
                _object.Add('SelectStop','');
            }
        }
    };


}

TParagraphSelectStop.prototype = new TParagraphElement();

function TParagraphOption(){
    var type = 'TParagraphOption';
    TParagraphOption.prototype.InitConstructor = function(){
        TParagraphElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.id = null;
        this.value = null;
        this.text = '';
        this.selected = false;
        this.variable = null;
        this.actions = [];
    };
    this.InitConstructor();

    TParagraphOption.prototype.Init = function(_object){
        TParagraphElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphInput'))
        {
            if (typeof _object.id !== 'undefined' && _object.id !== null)
            {
                this.id = new String(_object.id);
                this.id = this.id.toString();
            }
            if (typeof _object.value !== 'undefined' && _object.value !== null)
            {
                this.value = new String(_object.value);
                this.value = this.value.toString();
            }
            if (typeof _object.text !== 'undefined' && _object.text !== null)
            {
                this.text = new String(_object.text);
                this.text = this.text.toString();
            }
            if (typeof _object.selected !== 'undefined' && _object.selected !== null)
                this.selected = _object.selected;
            if (typeof _object.variable !== 'undefined' && _object.variable !== null && _object.variable.IsType('TVariable'))
                this.variable = _object.variable;
            if (typeof _object.actions !== 'undefined' && _object.actions !== null )
            {
                this.actions = [];
                for (i = 0;i < _object.actions.length;i++)
                {
                    if (typeof _object.actions[i] !== 'undefined' && _object.actions[i] !== null && _object.actions[i].IsType('TActionEdit'))
                    {
                        this.actions[i] = objM.copy(_object.actions[i]);
                    }
                }
            }
        }
    };

    TParagraphOption.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphElement.prototype.IsType.call(this,_type);
    };

    TParagraphOption.prototype.SetId = function(id_){
        if (typeof id_ !== 'undefined' && id_ !== null)
        {
            this.id = new String(id_);
            if (this.id !== null)
                this.id = this.id.toString();
        }
        if (id_ === null)
            this.id = null;
    };

    TParagraphOption.prototype.GetId = function(){
        var tmp = new String(this.id);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TParagraphOption.prototype.SetSelected = function(YN){
        if (typeof YN !== 'undefined' && YN !== null)
        {
            this.selected = YN;
        }
    };

    TParagraphOption.prototype.GetSelected = function(){
        return this.selected;
    };

    TParagraphOption.prototype.ParseXML = function(tag){
        TParagraphElement.prototype.ParseXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('id');
            this.SetId(attr);
            var attr = tag.getAttribute('value');
            this.SetValue(attr);

            var attr = tag.getAttribute('selected');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                if ((attr === 'Yes' || attr === 'yes' || attr === 'True' || attr === 'true'))
                    this.selected = true;
                else
                    this.selected = false;
            }
            
            var tmp = null,data = null;
            
            attr = tag.getAttribute('nameVariable');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                tmp = this.FindVariable(attr);
                if (typeof tmp !== 'undefined' && tmp !== null && tmp.IsType('TVariable'))
                    data = tmp.GetValue();
            }
            if (tmp !== null)
            {
                this.variable = tmp;
                if (tmp.IsType('TVariableString'))
                    this.variable.SetValue(data);
                else
                {
                    this.variable.SetEquation(data);
                    this.variable.SetValue(this.CalculateValue(data));
                }
                
            }
            var i,j=0,x = tag.childNodes,x2,k;
            for (i = 0,k = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 3)
                {
                    this.SetText(x[i].data);
                }
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Id')
                    {
                        x2 = x[i].childNodes;
                        attr = x[i].getAttribute('id');
                        if (attr !== null)
                        {
                            if (k === 0)
                            {
                                this.actions[j] = this.NewActtion();
                                this.actions[j].SetObject(this);
                                this.actions[j].SetId(this.GetId());
                            }
                            if (this.actions[j] !== null)
                            {
                                if (k === 0)
                                    this.actions[j].SetId(this.GetId());
                                this.actions[j].SetId(attr,k++);
                            }
                        }
                    }
                }
            }
        }    
    };

    TParagraphOption.prototype.GetVariable = function(){
        return this.variable;
    };

    TParagraphOption.prototype.SetValue= function(value_){
        if (typeof value_ !== 'undefined' && value_ !== null)
        {
            this.value = new String(value_);
            if (this.value !== null)
                this.value = this.value.toString();
        }
        if (value_ === null)
            this.value = null;
    };

    TParagraphOption.prototype.GetValue = function(){
        var tmp = new String(this.value);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TParagraphOption.prototype.SetText= function(text_){
        if (typeof text_ !== 'undefined' && text_ !== null)
        {
            this.text = new String(text_);
            if (this.text !== null)
                this.text = this.text.toString();
        }
        if (text_ === null)
            this.text = '';
    };

    TParagraphOption.prototype.GetText = function(){
        var tmp = new String(this.text);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };


    TParagraphOption.prototype.GetNActions = function(){
        if (typeof this.actions !== 'undefined' && this.actions !== null)
            return this.actions.length;
        return null;
    };

    TParagraphOption.prototype.GetAction = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0 && number < this.actions.length)
            return this.actions[number];
        return null;
    };


    TParagraphOption.prototype.Draw = function(_object){
        TParagraphElement.prototype.Draw.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.variable !== 'undefined' && this.variable !== null && this.variable.IsType('TVariable'))
            {
                var tmp = [],tmp2;
                if (!this.variable.IsType('TVariableString'))
                    this.variable.SetValue(this.CalculateValue(this.variable.GetName()));
                tmp[0] = this.variable.GetValue();
                tmp[1] = this.variable.GetWidth();
                tmp2 = this.CalculateValue(this.GetValue());
                if (tmp2 !== null)
                {
                    var tmpF = parseFloat(tmp2);
                    if (!isNaN(tmpF))
                    {
                        var tmpF2 = parseFloat(tmp[0]);
                        if (tmpF2 === tmp2)
                            tmp[2] = true;
                        else
                            tmp[2] = false;
                    }else
                    {
                        if (tmp[0] === tmp2)
                            tmp[2] = true;
                        else
                            tmp[2] = false;
                    }
                }else
                {
                    if (tmp[0] === this.GetValue())
                        tmp[2] = true;
                    else
                        tmp[2] = false;
                }
                tmp[3] = this.GetText();
                tmp[4] = this.GetValue();
                tmp[5] = this;
//                tmp[3] = this.GetStartChecked();
/*                tmp[2] = this.GetClassStyle();
                tmp[3] = this.colourBackground;
                tmp[4] = this.colourText;*/
//                _object.Add('Edit',this.GetId(),tmp);
                _object.Add('SelectOption',this.GetId(),tmp);
            }
        }        
        
    };


    TParagraphOption.prototype.NewActtion = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.newObject('TActionOption');
        return null;
    };

    TParagraphOption.prototype.Refresh = function(){
        var tmp = this.GetId();
        if (tmp !== null)
        {
            var tmp2 = document.getElementById(tmp);
            if (typeof tmp2 !== 'undefined' && tmp2 !== null)
            {
                if (typeof this.variable !== 'undefined' && this.variable !== null && this.variable.IsType('TVariable'))
                {
                    if (!this.variable.IsType('TVariableString'))
                    {
                        this.variable.SetValue(this.CalculateValue(this.variable.GetName()));
                        var tmp3 = this.variable.GetValue();
                        if (tmp3 === 1)
                        {
                            tmp2.checked = true;
                        }else
                            tmp2.checked = false;
                    }else
                    {
                        var tmp3 = this.variable.GetValue();
                        tmp3 = tmp3.toLowerCase();
                        if (tmp3 === 'true' || tmp3 === 'yes' || tmp3 === 'tak')
                        {
                            tmp2.checked = true;
                        }else
                            tmp2.checked = false;
                    }
                }
            }
        }
    };


}

TParagraphOption.prototype = new TParagraphElement();



function TParagraphFormStart(){
    var type = 'TParagraphFormStart';
    TParagraphFormStart.prototype.InitConstructor = function(){
        TParagraphElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.vertical = false;
    };
    this.InitConstructor();

    TParagraphFormStart.prototype.Init = function(_object){
        TParagraphElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphFormStart'))
        {
            if (typeof _object.vertical !== 'undefined' && _object.vertical !== null)
                this.vertical = _object.vertical;
        }
    };

    TParagraphFormStart.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphElement.prototype.IsType.call(this,_type);
    };

    TParagraphFormStart.prototype.ParseXML = function(tag){
        if (typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('vertical');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                if (attr === "true" || attr === "True")
                    this.vertical = true;
                else
                    this.vertical = false;
            }

        }    
    };

    TParagraphFormStart.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
            {
                _object.Add('FormStart','',this.vertical);
            }
        }
    };

}

TParagraphFormStart.prototype = new TParagraphElement();

function TParagraphFormStop(){
    var type = 'TParagraphFormStop';
    TParagraphFormStop.prototype.InitConstructor = function(){
        TParagraphElement.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TParagraphFormStop.prototype.Init = function(_object){
        TParagraphElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphFormStop'))
        {
        }
    };

    TParagraphFormStop.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphElement.prototype.IsType.call(this,_type);
    };

    TParagraphFormStop.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
            {
                _object.Add('FormStop','');
            }
        }
    };

}

TParagraphFormStop.prototype = new TParagraphElement();

function TParagraphInput(){
    var type = 'TParagraphInput';
    TParagraphInput.prototype.InitConstructor = function(){
        TParagraphElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.id = null;
        this.group = null;
        this.inputType = null;
        this.variable = null;
        this.value = null;
        this.actions = [];
    };
    this.InitConstructor();

    TParagraphInput.prototype.Init = function(_object){
        TParagraphElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphInput'))
        {
            if (typeof _object.id !== 'undefined' && _object.id !== null)
            {
                this.id = new String(_object.id);
                this.id = this.id.toString();
            }
            if (typeof _object.group !== 'undefined' && _object.group !== null)
            {
                this.group = new String(_object.group);
                this.group = this.group.toString();
            }
            if (typeof _object.inputType !== 'undefined' && _object.inputType !== null)
            {
                this.inputType = new String(_object.inputType);
                this.inputType = this.inputType.toString();
            }
            if (typeof _object.variable !== 'undefined' && _object.variable !== null && _object.variable.IsType('TVariable'))
                this.variable = _object.variable;
            if (typeof _object.value !== 'undefined' && _object.value !== null)
            {
                this.value = new String(_object.value);
                this.value = this.value.toString();
            }
            if (typeof _object.actions !== 'undefined' && _object.actions !== null )
            {
                this.actions = [];
                for (i = 0;i < _object.actions.length;i++)
                {
                    if (typeof _object.actions[i] !== 'undefined' && _object.actions[i] !== null && _object.actions[i].IsType('TActionEdit'))
                    {
                        this.actions[i] = objM.copy(_object.actions[i]);
                    }
                }
            }
        }
    };

    TParagraphInput.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphElement.prototype.IsType.call(this,_type);
    };

    TParagraphInput.prototype.SetId = function(id_){
        if (typeof id_ !== 'undefined' && id_ !== null)
        {
            this.id = new String(id_);
            if (this.id !== null)
                this.id = this.id.toString();
        }
        if (id_ === null)
            this.id = null;
    };

    TParagraphInput.prototype.GetId = function(){
        var tmp = new String(this.id);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TParagraphInput.prototype.SetGroup = function(group_){
        if (typeof group_ !== 'undefined' && group_ !== null)
        {
            this.group = new String(group_);
            if (this.group !== null)
                this.group = this.group.toString();
        }
        if (group_ === null)
            this.group = null;
    };

    TParagraphInput.prototype.GetGroup = function(){
        var tmp = new String(this.group);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TParagraphInput.prototype.SetInputType = function(type_){
        if (typeof type_ !== 'undefined' && type_ !== null)
        {
            this.inputType = new String(type_);
            if (this.inputType !== null)
                this.inputType = this.inputType.toString();
        }
        if (type_ === null)
            this.inputType = null;
    };

    TParagraphInput.prototype.GetInputType = function(){
        var tmp = new String(this.inputType);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TParagraphInput.prototype.ParseXML = function(tag){
        TParagraphElement.prototype.ParseXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('id');
            this.SetId(attr);
            var attr = tag.getAttribute('group');
            this.SetGroup(attr);
            var attr = tag.getAttribute('type');
            this.SetInputType(attr);
            var attr = tag.getAttribute('value');
            this.SetValue(attr);
            var tmp = null,data = null;
            
            attr = tag.getAttribute('nameVariable');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                tmp = this.FindVariable(attr);
                if (typeof tmp !== 'undefined' && tmp !== null && tmp.IsType('TVariable'))
                    data = tmp.GetValue();
            }
            if (tmp !== null)
            {
                this.variable = tmp;
                if (tmp.IsType('TVariableString'))
                    this.variable.SetValue(data);
                else
                {
                    this.variable.SetEquation(data);
                    this.variable.SetValue(this.CalculateValue(data));
                }
//                this.variable.ReadXML(tag);
                
            }
/*            this.actions[0] = this.NewActtion();
            if (this.actions[0] !== null)
            {
                this.actions[0].SetId(this.GetId());
                this.actions[0].SetObject(this);
            }*/
            var i,j=0,x = tag.childNodes,x2,k;
            for (i = 0,k = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Id')
                    {
                        x2 = x[i].childNodes;
                        attr = x[i].getAttribute('id');
                        if (attr !== null)
                        {
                            if (k === 0)
                            {
                                this.actions[j] = this.NewActtion();
                                this.actions[j].SetObject(this);
                                this.actions[j].SetId(this.GetId());
                            }
                            if (this.actions[j] !== null)
                            {
                                if (k === 0)
                                    this.actions[j].SetId(this.GetId());
                                this.actions[j].SetId(attr,k++);
                            }
                        }
                    }
                }
            }
        }    
    };

    TParagraphInput.prototype.GetVariable = function(){
        return this.variable;
    };

    TParagraphInput.prototype.SetValue= function(value_){
        if (typeof value_ !== 'undefined' && value_ !== null)
        {
            this.value = new String(value_);
            if (this.value !== null)
                this.value = this.value.toString();
        }
        if (value_ === null)
            this.value = null;
    };

    TParagraphInput.prototype.GetValue = function(){
        var tmp = new String(this.value);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TParagraphInput.prototype.NewActtion = function(){
        return null;
    };

    TParagraphInput.prototype.GetNActions = function(){
        if (typeof this.actions !== 'undefined' && this.actions !== null)
            return this.actions.length;
        return null;
    };

    TParagraphInput.prototype.GetAction = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0 && number < this.actions.length)
            return this.actions[number];
        return null;
    };


}

TParagraphInput.prototype = new TParagraphElement();


function TParagraphRadioButton(){
    var type = 'TParagraphRadioButton';
    TParagraphRadioButton.prototype.InitConstructor = function(){
        TParagraphInput.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.startChecked = false;
    };
    this.InitConstructor();

    TParagraphRadioButton.prototype.Init = function(_object){
        TParagraphInput.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphRadioButton'))
        {
            if (typeof _object.startChecked !== 'undefined' && _object.startChecked !== null)
                this.startChecked = _object.startChecked;
        }
    };

    TParagraphRadioButton.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphInput.prototype.IsType.call(this,_type);
    };

    TParagraphRadioButton.prototype.ParseXML = function(tag){
        TParagraphInput.prototype.ParseXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('checked');
            if (typeof attr !== 'undefined' && attr !== null && (attr === 'Yes' || attr === 'yes' || attr === 'True' || attr === 'true'))
                this.SetStartChecked(true);
            else
                this.SetStartChecked(false);
        }    
    };


    TParagraphRadioButton.prototype.Draw = function(_object){
        TParagraphInput.prototype.Draw.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.variable !== 'undefined' && this.variable !== null && this.variable.IsType('TVariable'))
            {
                var tmp = [],tmp2;
                if (!this.variable.IsType('TVariableString'))
                    this.variable.SetValue(this.CalculateValue(this.variable.GetName()));
                tmp[0] = this.variable.GetValue();
                tmp[1] = this.variable.GetWidth();
                tmp[2] = this.GetGroup();
                tmp2 = this.CalculateValue(this.GetValue());
                if (tmp2 !== null)
                {
                    if (tmp[0] === tmp2)
                        tmp[3] = true;
                    else
                        tmp[3] = false;
                }else
                {
                    if (tmp[0] === this.GetValue())
                        tmp[3] = true;
                    else
                        tmp[3] = false;
                }
                tmp[4] = this.GetFunctionName();
                tmp[5] = this.GetValue();
                tmp[6] = this;
//                tmp[3] = this.GetStartChecked();
/*                tmp[2] = this.GetClassStyle();
                tmp[3] = this.colourBackground;
                tmp[4] = this.colourText;*/
//                _object.Add('Edit',this.GetId(),tmp);
                _object.Add('RadioButton',this.GetId(),tmp);
            }
        }        
        
    };


    TParagraphRadioButton.prototype.SetStartChecked= function(YN){
        if (typeof YN !== 'undefined' && YN !== null)
        {
            this.startChecked = YN;
        }
    };

    TParagraphRadioButton.prototype.GetStartChecked = function(){
        return this.startChecked;
    };

    TParagraphRadioButton.prototype.NewActtion = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.newObject('TActionRadioInput');
        return null;
    };

    TParagraphRadioButton.prototype.Refresh = function(){
        var tmp = this.GetId();
        if (tmp !== null)
        {
            var tmp2 = document.getElementById(tmp);
            if (typeof tmp2 !== 'undefined' && tmp2 !== null)
            {
                if (typeof this.variable !== 'undefined' && this.variable !== null && this.variable.IsType('TVariable'))
                {
                    if (!this.variable.IsType('TVariableString'))
                    {
                        this.variable.SetValue(this.CalculateValue(this.variable.GetName()));
                        var tmp3 = this.variable.GetValue();
                        if (tmp3 === 1)
                        {
                            tmp2.checked = true;
                        }else
                            tmp2.checked = false;
                    }else
                    {
                        var tmp3 = this.variable.GetValue();
                        tmp3 = tmp3.toLowerCase();
                        if (tmp3 === 'true' || tmp3 === 'yes' || tmp3 === 'tak')
                        {
                            tmp2.checked = true;
                        }else
                            tmp2.checked = false;
                    }
                }
            }
        }
    };


}

TParagraphRadioButton.prototype = new TParagraphInput();



function TParagraphCheckBox(){
    var type = 'TParagraphCheckBox';
    TParagraphCheckBox.prototype.InitConstructor = function(){
        TParagraphInput.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TParagraphCheckBox.prototype.Init = function(_object){
        TParagraphInput.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphCheckBox'))
        {
        }
    };

    TParagraphCheckBox.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphInput.prototype.IsType.call(this,_type);
    };

    TParagraphCheckBox.prototype.ParseXML = function(tag){
        TParagraphInput.prototype.ParseXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
        }    
    };


    TParagraphCheckBox.prototype.Draw = function(_object){
        TParagraphInput.prototype.Draw.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.variable !== 'undefined' && this.variable !== null && this.variable.IsType('TVariable'))
            {
                var tmp = [],tmp2;
                if (!this.variable.IsType('TVariableString'))
                    this.variable.SetValue(this.CalculateValue(this.variable.GetName()));
                tmp[0] = this.variable.GetValue();
                tmp[1] = this.variable.GetWidth();
                tmp[2] = this.GetGroup();
                tmp2 = this.CalculateValue(this.GetValue());
                if (tmp2 !== null)
                {
                    if (tmp[0] === tmp2)
                        tmp[3] = true;
                    else
                        tmp[3] = false;
                }else
                {
                    if (tmp[0] === this.GetValue())
                        tmp[3] = true;
                    else
                        tmp[3] = false;
                }
                tmp[4] = this.GetFunctionName();
                tmp[5] = this.GetValue();
                tmp[6] = this;
//                tmp[3] = this.GetStartChecked();
/*                tmp[2] = this.GetClassStyle();
                tmp[3] = this.colourBackground;
                tmp[4] = this.colourText;*/
//                _object.Add('Edit',this.GetId(),tmp);
                _object.Add('CheckBox',this.GetId(),tmp);
            }
        }        
        
    };



    TParagraphCheckBox.prototype.NewActtion = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.newObject('TActionCheckBoxInput');
        return null;
    };

    TParagraphCheckBox.prototype.Refresh = function(){
        var tmp = this.GetId();
        if (tmp !== null)
        {
            var tmp2 = document.getElementById(tmp);
            if (typeof tmp2 !== 'undefined' && tmp2 !== null)
            {
                if (typeof this.variable !== 'undefined' && this.variable !== null && this.variable.IsType('TVariable'))
                {
                    if (!this.variable.IsType('TVariableString'))
                    {
                        this.variable.SetValue(this.CalculateValue(this.variable.GetName()));
                        var tmp3 = this.variable.GetValue();
                        if (tmp3 === 1)
                        {
                            tmp2.checked = true;
                        }else
                            tmp2.checked = false;
                    }else
                    {
                        var tmp3 = this.variable.GetValue();
                        tmp3 = tmp3.toLowerCase();
                        if (tmp3 === 'true' || tmp3 === 'yes' || tmp3 === 'tak')
                        {
                            tmp2.checked = true;
                        }else
                            tmp2.checked = false;
                    }
                }
            }
        }
    };


}

TParagraphCheckBox.prototype = new TParagraphInput();


function TEdit(){
    var type = 'TEdit';
    TEdit.prototype.InitConstructor = function(){
        TParagraphElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.variable = null;
        this.id = null;
        this.actions = [];
        this.colourText = null;
        this.colourBackground = null;
        this.colourTextError = null;
        this.colourBackgroundError = null;
//        this.variableName = null;
        this.nonZero = false;
        this.max = null;
        this.min = null;
        this.typeVariable = 'double';
        this.functionKeyPress = null;
        this.functionKeyDown = null;
        this.functionKeyUp = null;
    };
    this.InitConstructor();

    TEdit.prototype.Init = function(_object){
        TParagraphElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TEdit'))
        {
            var i;
            if (typeof _object.variable !== 'undefined' && _object.variable !== null && _object.variable.IsType('TVariable'))
                this.variable = _object.variable;
            if (typeof _object.id !== 'undefined' && _object.id !== null)
            {
                this.id = new String(_object.id);
                if (this.id !== null)
                    this.id = this.id.toString();
            }
            if (typeof _object.actions !== 'undefined' && _object.actions !== null )
            {
                this.actions = [];
                for (i = 0;i < _object.actions.length;i++)
                {
                    if (typeof _object.actions[i] !== 'undefined' && _object.actions[i] !== null && _object.actions[i].IsType('TActionEdit'))
                    {
                        this.actions[i] = objM.copy(_object.actions[i]);
                    }
                }
            }
            if (typeof _object.colourText !== 'undefined' && _object.colourText !== null && _object.colourText.IsType('TColourRGBA'))
                this.colourText = objM.copy(_object.colourText);
            if (typeof _object.colourBackground !== 'undefined' && _object.colourBackground !== null && _object.colourBackground.IsType('TColourRGBA'))
                this.colourBackground = objM.copy(_object.colourBackground);
            if (typeof _object.colourTextError !== 'undefined' && _object.colourTextError !== null && _object.colourTextError.IsType('TColourRGBA'))
                this.colourTextError = objM.copy(_object.colourTextError);
            if (typeof _object.colourBackgroundError !== 'undefined' && _object.colourBackgroundError !== null && _object.colourBackgroundError.IsType('TColourRGBA'))
                this.colourBackgroundError = objM.copy(_object.colourBackgroundError);
            if (typeof _object.nonZero !== 'undefined' && _object.nonZero !== null)
                this.nonZero = _object.nonZero;
            if (typeof _object.max !== 'undefined' && _object.max !== null && IsInt(_object.max))
                this.max = _object.max;
            if (typeof _object.min !== 'undefined' && _object.min !== null && IsInt(_object.min))
                this.min = _object.min;
            if (typeof _object.typeVariable !== 'undefined' && _object.typeVariable !== null)
            {
                this.typeVariable = new String(_object.typeVariable);
                if (this.typeVariable !== null)
                    this.typeVariable = this.typeVariable.toString();
            }
            if (typeof _object.functionKeyPress !== 'undefined' && _object.functionKeyPress !== null)
            {
                this.functionKeyPress = new String(_object.functionKeyPress);
                this.functionKeyPress = this.functionKeyPress.toString();
            }
            if (typeof _object.functionKeyDown !== 'undefined' && _object.functionKeyDown !== null)
            {
                this.functionKeyDown = new String(_object.functionKeyDown);
                this.functionKeyDown = this.functionKeyDown.toString();
            }
            if (typeof _object.functionKeyUp !== 'undefined' && _object.functionKeyUp !== null)
            {
                this.functionKeyUp = new String(_object.functionKeyUp);
                this.functionKeyUp = this.functionKeyUp.toString();
            }
        }
    };

    TEdit.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphElement.prototype.IsType.call(this,_type);
    };

    TEdit.prototype.ParseXML = function(tag){
        TParagraphElement.prototype.ParseXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('id');
            this.SetId(attr);
            this.SetFunctionKeyPress(tag.getAttribute('keypress'));
            this.SetFunctionKeyDown(tag.getAttribute('keydown'));
            this.SetFunctionKeyUp(tag.getAttribute('keyup'));
            attr = tag.getAttribute('typeVar');
            this.SetTypeVariable(attr);
            attr = tag.getAttribute('name');
            var attr2 = tag.getAttribute('value');
            var data = null,tmp;
            if (typeof attr2 !== 'undefined' && attr2 !== null)
                data = attr2;
            else
            {
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    tmp = this.FindVariable(attr);
                    if (typeof tmp !== 'undefined' && tmp !== null && tmp.IsType('TVariable'))
                        data = tmp.GetValue();
                }
            }
            if (tmp !== null)
            {
                this.variable = tmp;
                if (tmp.IsType('TVariableString'))
                    this.variable.SetValue(data);
                else
                {
                    this.variable.SetValue(this.CalculateValue(data));
                    this.variable.SetEquation(data);
                    this.variable.ReadXML(tag);
                }
                
            }else
            {
                if (typeof attr !== 'undefined' && attr !== null)// && data !== null)
                {
                    var attr3 = tag.getAttribute('typeVar');
                    this.variable = null;
                    if (typeof attr3 !== 'undefined' && attr3 !== null)
                    {
                        if (attr3 === 'int')
                        {
                            this.variable = objM.newObject('TVariableInt');
                            if (this.variable !== null)
                            {
                                this.variable.SetValue(this.CalculateValue(data));
                                this.variable.SetEquation(data);
                                this.variable.ReadXML(tag);
                            }
                        }
                        if (attr3 === 'double')
                        {
                            this.variable = objM.newObject('TVariableDouble');
                            if (this.variable !== null)
                            {
                                this.variable.SetValue(this.CalculateValue(data));
                                this.variable.SetEquation(data);
                                this.variable.ReadXML(tag);
                            }
                        }
                        if (attr3 === 'string')
                        {
                            this.variable = objM.newObject('TVariableString');
                            if (this.variable !== null)
                            {
                                this.variable.SetValue(data);
                                this.variable.ReadXML(tag);
                            }
                        }
                        if (attr3 === 'void')
                        {
                            this.variable = objM.newObject('TVariableVoidTXT');
                            if (this.variable !== null)
                            {
                                this.variable.SetEquation(data);
//                                this.variable.SetValue(data);
                                this.variable.ReadXML(tag);
                            }
                        }
                    }

                    if (this.variable === null)
                    {
                        if (IsInt(attr2))
                        {
                            this.variable = objM.newObject('TVariableInt');
                            if (this.variable !== null)
                                this.variable.ReadXML(tag);
                        }else
                        {
                            if (IsNumeric(attr2))
                            {
                                this.variable = objM.newObject('TVariableDouble');
                                if (this.variable !== null)
                                    this.variable.ReadXML(tag);
                            }else
                            {
                                this.variable = objM.newObject('TVariableString');
                                if (this.variable !== null)
                                    this.variable.ReadXML(tag);
                            }

                        }
                    }

                }
            }
            this.actions = [];
            var i,j=0,x = tag.childNodes,x2,k;
            this.actions[j] = objM.newObject('TActionEditError');
            if (this.actions[j] !== null)
            {
                this.actions[j].SetId(this.GetId());
                this.actions[j++].SetObject(this);
            }
            for (i = 0,k = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Id')
                    {
                        x2 = x[i].childNodes;
                        attr = x[i].getAttribute('id');
                        if (attr !== null)
                        {
                            if (k === 0)
                                this.actions[j] = objM.newObject('TActionEditRecalculate');
                            if (this.actions[j] !== null)
                            {
                                if (k === 0)
                                    this.actions[j].SetId(this.GetId());
                                this.actions[j].SetId(attr,k++);
                            }
                        }
                    }
                }
            }
            var tmp = tag.getAttribute('nonzero');
            if (typeof tmp !== 'undefined' && tmp !== null && (tmp==='Yes' || tmp ==='yes'))
                this.nonZero = true;
            tmp = tag.getAttribute('max');
            if (tmp !== null && IsNumeric(tmp))
                this.max = parseFloat(tmp);
            tmp = tag.getAttribute('min');
            if (tmp !== null && IsNumeric(tmp))
                this.min = parseFloat(tmp);

            var tag_ = tag.childNodes,r,g,b,a,tmp;
            if (tag_ !== null)
            {
                for (i = 0;i < tag_.length;i++)
                {
                    if (tag_[i].nodeType === 1)
                    {
                        if (tag_[i].nodeName === 'ColourBackground')
                        {
                            r = 0;g = 0;b = 0;a = 1;
                            attr = this.CalculateValue(tag_[i].getAttribute('r'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    r = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('g'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    g = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('b'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    b = tmp;
                            }
                            attr = tag_[i].getAttribute('a');
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    a = tmp;
                            }
                            this.colourBackground = objM.newObject('TColourRGBA');
                            if (this.colourBackground !== null)
                                this.colourBackground.SetColourRGBA(r,g,b,a);
                        }
                        if (tag_[i].nodeName === 'ColourText')
                        {
                            r = 0;g = 0;b = 0;a = 1;
                            attr = this.CalculateValue(tag_[i].getAttribute('r'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    r = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('g'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    g = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('b'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    b = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('a'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    a = tmp;
                            }
                            this.colourText = objM.newObject('TColourRGBA');
                            if (this.colourText !== null)
                                this.colourText.SetColourRGBA(r,g,b,a);
                        }
                        if (tag_[i].nodeName === 'ColourErrorBackground')
                        {
                            r = 0;g = 0;b = 0;a = 1;
                            attr = this.CalculateValue(tag_[i].getAttribute('r'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    r = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('g'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    g = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('b'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    b = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('a'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    a = tmp;
                            }
                            this.colourBackgroundError = objM.newObject('TColourRGBA');
                            if (this.colourBackgroundError !== null)
                                this.colourBackgroundError.SetColourRGBA(r,g,b,a);
                        }
                        if (tag_[i].nodeName === 'ColourErrorText')
                        {
                            r = 0;g = 0;b = 0;a = 1;
                            attr = this.CalculateValue(tag_[i].getAttribute('r'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    r = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('g'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    g = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('b'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    b = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('a'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    a = tmp;
                            }
                            this.colourTextError = objM.newObject('TColourRGBA');
                            if (this.colourTextError !== null)
                                this.colourTextError.SetColourRGBA(r,g,b,a);
                        }
                    }
                }
            }
        }    
    };

    TEdit.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.variable !== 'undefined' && this.variable !== null && this.variable.IsType('TVariable'))
            {
                var tmp = [];
                if (!this.variable.IsType('TVariableString'))
                    this.variable.SetValue(this.CalculateValue(this.variable.GetName()));
                tmp[0] = this.variable.GetValue();
                tmp[1] = this.variable.GetWidth();
                tmp[2] = this.GetClassStyle();
                tmp[3] = this.colourBackground;
                tmp[4] = this.colourText;
                tmp[5] = this.GetFunctionName();
                tmp[6] = this.GetFunctionKeyPress();
                tmp[7] = this.GetFunctionKeyDown();
                tmp[8] = this.GetFunctionKeyUp();
                tmp[9] = this;
                _object.Add('Edit',this.GetId(),tmp);
            }
        }
        
    };

    TEdit.prototype.GetVariable = function(){
        return this.variable;
    };

    TEdit.prototype.SetId = function(id_){
        if (typeof id_ !== 'undefined' && id_ !== null)
        {
            this.id = new String(id_);
            if (this.id !== null)
                this.id = this.id.toString();
        }
        if (id_ === null)
            this.id = null;
    };

    TEdit.prototype.GetId = function(){
        var tmp = new String(this.id);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TEdit.prototype.GetNActions = function(){
        if (typeof this.actions !== 'undefined' && this.actions !== null)
            return this.actions.length;
        return null;
    };

    TEdit.prototype.GetAction = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0 && number < this.actions.length)
            return this.actions[number];
        return null;
    };

    TEdit.prototype.GetColourText = function(){
        return this.colourText;
    };

    TEdit.prototype.GetColourBackground = function(){
        return this.colourBackground;
    };

    TEdit.prototype.GetColourTextError = function(){
        return this.colourTextError;
    };

    TEdit.prototype.GetColourBackgroundError = function(){
        return this.colourBackgroundError;
    };

    TEdit.prototype.GetNonZero= function(){
        return this.nonZero;
    };

    TEdit.prototype.GetMax= function(){
        return this.max;
    };

    TEdit.prototype.GetMin= function(){
        return this.min;
    };

    TEdit.prototype.SetTypeVariable = function(type){
        if (typeof type !== 'undefined' && type !== null)
        {
            this.typeVariable = new String(type);
            if (this.typeVariable !== null)
                this.typeVariable = this.typeVariable.toString();
        }
//        if (type === null)
//            this.typeVariable = null;
    };

    TEdit.prototype.GetTypeVariable = function(){
        if (this.typeVariable !== null)
        {
            var tmp = new String(this.typeVariable);
            if (tmp !== null)
                return tmp.toString();
        }
        return null;
    };

    TEdit.prototype.GetFunctionKeyPress = function(){
        if (this.functionKeyPress !== null)
        {
            var tmp = new String(this.functionKeyPress);
            return tmp.toString();
        }
        return null;
    };

    TEdit.prototype.SetFunctionKeyPress = function(name_){
        if (typeof name_ !== 'undefined' && name_ !== null)
        {
            this.functionKeyPress = new String(name_);
            this.functionKeyPress = this.functionKeyPress.toString();
        }        
    };

    TEdit.prototype.GetFunctionKeyDown = function(){
        if (this.functionKeyDown !== null)
        {
            var tmp = new String(this.functionKeyDown);
            return tmp.toString();
        }
        return null;
    };

    TEdit.prototype.SetFunctionKeyDown = function(name_){
        if (typeof name_ !== 'undefined' && name_ !== null)
        {
            this.functionKeyDown = new String(name_);
            this.functionKeyDown = this.functionKeyDown.toString();
        }        
    };

    TEdit.prototype.GetFunctionKeyUp = function(){
        if (this.functionKeyUp !== null)
        {
            var tmp = new String(this.functionKeyUp);
            return tmp.toString();
        }
        return null;
    };

    TEdit.prototype.SetFunctionKeyUp = function(name_){
        if (typeof name_ !== 'undefined' && name_ !== null)
        {
            this.functionKeyUp = new String(name_);
            this.functionKeyUp = this.functionKeyUp.toString();
        }        
    };

    TEdit.prototype.Refresh = function(){
        var tmp = this.GetId();
        if (tmp !== null)
        {
            var tmp2 = document.getElementById(tmp);
            if (typeof tmp2 !== 'undefined' && tmp2 !== null)
            {
                if (typeof this.variable !== 'undefined' && this.variable !== null && this.variable.IsType('TVariable'))
                    if (!this.variable.IsType('TVariableString'))
                         this.variable.SetValue(this.CalculateValue(this.variable.GetName()));
//                tmp2.innerHTML = this.variable.GetValue();
                tmp2.value = this.variable.GetValue();
            }
        }
    };

}

TEdit.prototype = new TParagraphElement();


function TTextArea(){
    var type = 'TTextArea';
    TTextArea.prototype.InitConstructor = function(){
        TEdit.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.nRows = 1;        
    };
    this.InitConstructor();

    TTextArea.prototype.Init = function(_object){
        TEdit.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TEdit'))
        {
            var i;
            if (typeof _object.nRows !== 'undefined' && _object.nRows !== null && IsInt(nRows))
                this.nRows = _object.nRows;
        }
    };

    TTextArea.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TEdit.prototype.IsType.call(this,_type);
    };

    TTextArea.prototype.ParseXML = function(tag){
        TEdit.prototype.ParseXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            this.SetRows(tag.getAttribute('rows'));
        }    
    };

    TTextArea.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.variable !== 'undefined' && this.variable !== null && this.variable.IsType('TVariable'))
            {
                var tmp = [];
                if (!this.variable.IsType('TVariableString'))
                    this.variable.SetValue(this.CalculateValue(this.variable.GetName()));
                tmp[0] = this.variable.GetValue();
                tmp[1] = this.variable.GetWidth();
                tmp[2] = this.GetClassStyle();
                tmp[3] = this.colourBackground;
                tmp[4] = this.colourText;
                tmp[5] = this.GetFunctionName();
                tmp[6] = this.GetFunctionKeyPress();
                tmp[7] = this.GetFunctionKeyDown();
                tmp[8] = this.GetFunctionKeyUp();
                tmp[9] = this;
                tmp[10] = this.GetRows();
                _object.Add('TextArea',this.GetId(),tmp);
            }
        }
        
    };

    TTextArea.prototype.SetRows = function(rows){
        if (typeof rows !== 'undefined' && rows !== null && IsInt(rows))
        {
            this.nRows = rows;
        }
    };

    TTextArea.prototype.GetRows = function(){
        return this.nRows;
    };

}

TTextArea.prototype = new TEdit();

function TButton(){
    var type = 'TButton';
    TButton.prototype.InitConstructor = function(){
        TParagraphElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.id = null;
        this.actions = [];
        this.colourText = null;
        this.colourBackground = null;
        this.text = null;
    };
    this.InitConstructor();

    TButton.prototype.Init = function(_object){
        TParagraphElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TButton'))
        {
            var i;
            if (typeof _object.id !== 'undefined' && _object.id !== null)
            {
                this.id = new String(_object.id);
                if (this.id !== null)
                    this.id = this.id.toString();
            }
            if (typeof _object.actions !== 'undefined' && _object.actions !== null )
            {
                this.actions = [];
                for (i = 0;i < _object.actions.length;i++)
                {
                    if (typeof _object.actions[i] !== 'undefined' && _object.actions[i] !== null && _object.actions[i].IsType('TActionButton'))
                    {
                        this.actions[i] = objM.copy(_object.actions[i]);
                    }
                }
            }
            if (typeof _object.colourText !== 'undefined' && _object.colourText !== null && _object.colourText.IsType('TColourRGBA'))
                this.colourText = objM.copy(_object.colourText);
            if (typeof _object.colourBackground !== 'undefined' && _object.colourBackground !== null && _object.colourBackground.IsType('TColourRGBA'))
                this.colourBackground = objM.copy(_object.colourBackground);
            if (typeof _object.text !== 'undefined' && _object.text !== null)
            {
                this.text = new String(_object.text);
                if (this.text !== null)
                    this.text = this.text.toString();
            }
        }
    };

    TButton.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphElement.prototype.IsType.call(this,_type);
    };

    TButton.prototype.ParseXMLActions = function(tag){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            this.actions = [];
            var i,j=0,x = tag.childNodes,x2,k;
            for (i = 0,k = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Id')
                    {
                        x2 = x[i].childNodes;
                        attr = x[i].getAttribute('id');
                        if (attr !== null)
                        {
                            if (k === 0)
                                this.actions[j] = objM.newObject('TActionButtonRecalculate');
                            if (this.actions[j] !== null)
                            {
                                if (k === 0)
                                    this.actions[j].SetId(this.GetId());
                                this.actions[j].SetId(attr,k++);
                                this.actions[j].SetObject(this);
                            }
                        }
                    }
                }
            }
        }

    }

    TButton.prototype.ParseXML = function(tag){
        TParagraphElement.prototype.ParseXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('id');
            this.SetId(attr);
            attr = tag.getAttribute('text');
            this.SetText(attr);
            this.ParseXMLActions(tag);
            var tag_ = tag.childNodes,r,g,b,a,tmp;
            if (tag_ !== null)
            {
                var i;
                for (i = 0;i < tag_.length;i++)
                {
                    if (tag_[i].nodeType === 1)
                    {
                        if (tag_[i].nodeName === 'ColourBackground')
                        {
                            r = 0;g = 0;b = 0;a = 1;
                            attr = this.CalculateValue(tag_[i].getAttribute('r'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    r = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('g'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    g = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('b'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    b = tmp;
                            }
                            attr = tag_[i].getAttribute('a');
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    a = tmp;
                            }
                            this.colourBackground = objM.newObject('TColourRGBA');
                            if (this.colourBackground !== null)
                                this.colourBackground.SetColourRGBA(r,g,b,a);
                        }
                        if (tag_[i].nodeName === 'ColourText')
                        {
                            r = 0;g = 0;b = 0;a = 1;
                            attr = this.CalculateValue(tag_[i].getAttribute('r'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    r = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('g'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    g = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('b'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    b = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('a'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    a = tmp;
                            }
                            this.colourText = objM.newObject('TColourRGBA');
                            if (this.colourText !== null)
                                this.colourText.SetColourRGBA(r,g,b,a);
                        }
                    }
                }
            }
        }    
    };

    TButton.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var tmp = [];
            tmp[0] = this.GetClassStyle();
            tmp[1] = this.colourBackground;
            tmp[2] = this.colourText;
            tmp[3] = this.GetText();
            tmp[4] = this.GetFunctionName();
            tmp[5] = this;
            _object.Add('Button',this.GetId(),tmp);
        }
        
    };

    TButton.prototype.SetId = function(id_){
        if (typeof id_ !== 'undefined' && id_ !== null)
        {
            this.id = new String(id_);
            if (this.id !== null)
                this.id = this.id.toString();
        }
        if (id_ === null)
            this.id = null;
    };

    TButton.prototype.GetId = function(){
        var tmp = new String(this.id);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TButton.prototype.SetText = function(text_){
        if (typeof text_ !== 'undefined' && text_ !== null)
        {
            this.text = new String(text_);
            if (this.text !== null)
                this.text = this.text.toString();
        }
        if (text_ === null)
            this.text = null;
    };

    TButton.prototype.GetText = function(){
        var tmp = new String(this.text);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TButton.prototype.GetNActions = function(){
        if (typeof this.actions !== 'undefined' && this.actions !== null)
            return this.actions.length;
        return null;
    };

    TButton.prototype.GetAction = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0 && number < this.actions.length)
            return this.actions[number];
        return null;
    };

    TButton.prototype.GetColourText = function(){
        return this.colourText;
    };

    TButton.prototype.GetColourBackground = function(){
        return this.colourBackground;
    };

}

TButton.prototype = new TParagraphElement();


function TButtonLoadImage(){
    var type = 'TButtonLoadImage';
    TButtonLoadImage.prototype.InitConstructor = function(){
        TButton.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.idComponentImage = null;
        this.variableName = null;
        this.variable2Name = null;
    };
    this.InitConstructor();

    TButtonLoadImage.prototype.Init = function(_object){
        TButton.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TButtonLoadImage'))
        {
            if (typeof _object.idComponentImage !== 'undefined' && _object.idComponentImage !== null)
            {
                this.idComponentImage = new String(_object.idComponentImage);
                if (this.idComponentImage !== null)
                    this.idComponentImage = this.idComponentImage.toString();
            }
            if (typeof _object.variableName !== 'undefined' && _object.variableName !== null)
            {
                this.variableName = new String(_object.variableName);
                if (this.variableName !== null)
                    this.variableName = this.variableName.toString();
            }
            if (typeof _object.variable2Name !== 'undefined' && _object.variable2Name !== null)
            {
                this.variable2Name = new String(_object.variable2Name);
                if (this.variable2Name !== null)
                    this.variable2Name = this.variable2Name.toString();
            }
        }
    };

    TButtonLoadImage.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TButton.prototype.IsType.call(this,_type);
    };

    TButtonLoadImage.prototype.ParseXMLActions = function(tag){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            this.actions = [];
            var i,j=0,x = tag.childNodes,x2,k;
            for (i = 0,k = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Id')
                    {
                        x2 = x[i].childNodes;
                        attr = x[i].getAttribute('id');
                        if (attr !== null)
                        {
                            if (k === 0)
                                this.actions[j] = objM.newObject('TActionButtonLoadImageRecalculate');
                            if (this.actions[j] !== null)
                            {
                                if (k === 0)
                                    this.actions[j].SetId(this.GetId());
                                this.actions[j].SetId(attr,k++);
                                this.actions[j].SetObject(this);
                                this.actions[j].SetIdComponentImage(this.idComponentImage);
                            }
                        }
                    }
                }
            }
        }
    }

    TButtonLoadImage.prototype.ParseXML = function(tag){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('idComponentImage');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                this.idComponentImage = attr; 
            }
            attr = tag.getAttribute('variable');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                this.variableName = attr; 
            }
            attr = tag.getAttribute('variable2');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                this.variable2Name = attr; 
            }
        }    
        TButton.prototype.ParseXML.call(this,tag);
    };


    TButtonLoadImage.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var tmp = [];
            tmp[0] = this.GetClassStyle();
            tmp[1] = this.GetColourBackground();
            tmp[2] = this.GetColourText();
            tmp[3] = this.GetText();
            tmp[4] = this.GetFunctionName();
            tmp[5] = this;
            _object.Add('ButtonLoadImage',this.GetId(),tmp);
        }
        
    };

    TButtonLoadImage.prototype.GetIdComponentImage = function(){
        var tmp = new String(this.idComponentImage);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TButtonLoadImage.prototype.GetVariableName = function(){
        var tmp = new String(this.variableName);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TButtonLoadImage.prototype.GetVariable2Name = function(){
        var tmp = new String(this.variable2Name);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

}

TButtonLoadImage.prototype = new TButton();


function TButtonSaveImage(){
    var type = 'TButtonSaveImage';
    TButtonSaveImage.prototype.InitConstructor = function(){
        TButton.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.variableName = null;
        this.fileName = 'image.png';
    };
    this.InitConstructor();

    TButtonSaveImage.prototype.Init = function(_object){
        TButton.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TButtonSaveImage'))
        {
            if (typeof _object.variableName !== 'undefined' && _object.variableName !== null)
            {
                this.variableName = new String(_object.variableName);
                if (this.variableName !== null)
                    this.variableName = this.variableName.toString();
            }
            if (typeof _object.fileName !== 'undefined' && _object.fileName !== null)
            {
                this.fileName = new String(_object.fileName);
                if (this.fileName !== null)
                    this.fileName = this.fileName.toString();
            }
        }
    };

    TButtonSaveImage.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TButton.prototype.IsType.call(this,_type);
    };

    TButtonSaveImage.prototype.ParseXMLActions = function(tag){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            this.actions = [];
            var i,j=0,x = tag.childNodes,x2,k = 0;
            this.actions[j] = objM.newObject('TActionButtonSaveImageRecalculate');
            this.actions[j].SetId(this.GetId());
            this.actions[j].SetId(attr,k);
            this.actions[j++].SetObject(this);
            for (i = 0,k = 1;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Id')
                    {
                        x2 = x[i].childNodes;
                        attr = x[i].getAttribute('id');
                        if (attr !== null)
                        {
//                            if (k === 0)
//                                this.actions[j] = objM.newObject('TActionButtonSaveImageRecalculate');
                            if (this.actions[j] !== null)
                            {
                                if (k === 0)
                                    this.actions[j].SetId(this.GetId());
                                this.actions[j].SetId(attr,k++);
                                this.actions[j].SetObject(this);
                            }
                        }
                    }
                }
            }
        }
    }

    TButtonSaveImage.prototype.ParseXML = function(tag){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            attr = tag.getAttribute('variable');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                this.variableName = attr; 
            }
            attr = tag.getAttribute('fileName');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                this.fileName = attr; 
            }
        }    
        TButton.prototype.ParseXML.call(this,tag);
    };

    TButtonSaveImage.prototype.GetVariableName = function(){
        var tmp = new String(this.variableName);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TButtonSaveImage.prototype.GetFileName = function(){
        var tmp = new String(this.fileName);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

}

TButtonSaveImage.prototype = new TButton();


function TSlider(){
    var type = 'TSlider';
    TSlider.prototype.InitConstructor = function(){
        TParagraphElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.id = null;
        this.actions = [];
        this.variableName = null;
        this.startValue = 0;
        this.minValue = 0;
        this.maxValue = 100;
        this.stepValue = 1;
        this.width = null;
        this.functionOnChange = null;
    };
    this.InitConstructor();

    TSlider.prototype.Init = function(_object){
        TParagraphElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TSlider'))
        {
            var i;
            if (typeof _object.id !== 'undefined' && _object.id !== null)
            {
                this.id = new String(_object.id);
                if (this.id !== null)
                    this.id = this.id.toString();
            }
            if (typeof _object.actions !== 'undefined' && _object.actions !== null )
            {
                this.actions = [];
                for (i = 0;i < _object.actions.length;i++)
                {
                    if (typeof _object.actions[i] !== 'undefined' && _object.actions[i] !== null && _object.actions[i].IsType('TActionSlider'))
                    {
                        this.actions[i] = objM.copy(_object.actions[i]);
                    }
                }
            }
            if (typeof _object.variableName !== 'undefined' && _object.variableName !== null)
            {
                this.variableName = new String(_object.variableName);
                if (this.variableName !== null)
                    this.variableName = this.variableName.toString();
            }
            if (typeof _object.startValue !== 'undefined' && _object.startValue !== null && IsNumeric(_object.startValue))
                this.startValue = _object.startValue;
            if (typeof _object.minValue !== 'undefined' && _object.minValue !== null && IsNumeric(_object.minValue))
                this.minValue = _object.minValue;
            if (typeof _object.maxValue !== 'undefined' && _object.maxValue !== null && IsNumeric(_object.maxValue))
                this.maxValue = _object.maxValue;
            if (typeof _object.stepValue !== 'undefined' && _object.stepValue !== null && IsNumeric(_object.stepValue))
                this.stepValue = _object.stepValue;
            if (typeof _object.functionOnChange !== 'undefined' && _object.functionOnChange !== null)
            {
                this.functionOnChange = new String(_object.functionOnChange);
                if (this.functionOnChange !== null)
                    this.functionOnChange = this.functionOnChange.toString();
            }
        }
    };

    TSlider.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphElement.prototype.IsType.call(this,_type);
    };

    TSlider.prototype.ParseXMLActions = function(tag){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            this.actions = [];
            var i,j=0,x = tag.childNodes,x2,k;
            for (i = 0,k = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Id')
                    {
                        x2 = x[i].childNodes;
                        attr = x[i].getAttribute('id');
                        if (attr !== null)
                        {
                            if (k === 0)
                                this.actions[j] = objM.newObject('TActionSlider');
                            if (this.actions[j] !== null)
                            {
                                if (k === 0)
                                    this.actions[j].SetId(this.GetId());
                                this.actions[j].SetId(attr,k++);
                                this.actions[j].SetObject(this);
                            }
                        }
                    }
                }
            }
        }

    }

    TSlider.prototype.ParseXML = function(tag){
        TParagraphElement.prototype.ParseXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('id');
            this.SetId(attr);
            attr = tag.getAttribute('variable');
            if (typeof attr !== 'undefined' && attr !== null)
                this.variableName = attr; 
            attr = tag.getAttribute('value');
            if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                this.startValue = attr; 
            attr = tag.getAttribute('min');
            if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                this.minValue = attr; 
            attr = tag.getAttribute('max');
            if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                this.maxValue = attr; 
            attr = tag.getAttribute('step');
            if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                this.stepValue = attr; 
            attr = tag.getAttribute('width');
            if (typeof attr !== 'undefined' && attr !== null)
                this.width = attr;
            attr = tag.getAttribute('onChange');
            if (typeof attr !== 'undefined' && attr !== null)
                this.functionOnChange = attr;
            this.ParseXMLActions(tag);
        }    
    };

    TSlider.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var tmp = [];
            tmp[0] = this.GetClassStyle();
            var v = this.FindVariable(this.variableName);
            if (typeof v !== 'undefined' && v !== null && v.IsType('TVariable'))
                tmp[1] = v.GetValue();
            else
                tmp[1] = this.startValue;
            tmp[2] = this.minValue;
            tmp[3] = this.maxValue;
            tmp[4] = this.stepValue;
            tmp[5] = this.GetFunctionName();            
            tmp[6] = this.width;
            tmp[7] = this;
            tmp[8] = this.functionOnChange;            
            _object.Add('Slider',this.GetId(),tmp);
        }
        
    };

    TSlider.prototype.SetId = function(id_){
        if (typeof id_ !== 'undefined' && id_ !== null)
        {
            this.id = new String(id_);
            if (this.id !== null)
                this.id = this.id.toString();
        }
        if (id_ === null)
            this.id = null;
    };

    TSlider.prototype.GetId = function(){
        var tmp = new String(this.id);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TSlider.prototype.GetNActions = function(){
        if (typeof this.actions !== 'undefined' && this.actions !== null)
            return this.actions.length;
        return null;
    };

    TSlider.prototype.GetAction = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0 && number < this.actions.length)
            return this.actions[number];
        return null;
    };
    
    TSlider.prototype.GetVariableName = function(){
        var tmp = new String(this.variableName);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

}

TSlider.prototype = new TParagraphElement();


function TParagraphText(){
    var type = 'TParagraphText';
    TParagraphText.prototype.InitConstructor = function(){
        TParagraphElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.variable = null;
        this.id = null;
        this.colourText = null;
        this.colourBackground = null;
    };
    this.InitConstructor();

    TParagraphText.prototype.Init = function(_object){
        TParagraphElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphText'))
        {
            if (typeof _object.variable !== 'undefined' && _object.variable !== null && _object.variable.IsType('TVariable'))
                this.variable = _object.variable;
            if (typeof _object.id !== 'undefined' && _object.id !== null)
            {
                this.id = new String(_object.id);
                if (this.id !== null)
                    this.id = this.id.toString();
            }
            if (typeof _object.colourText !== 'undefined' && _object.colourText !== null && _object.colourText.IsType('TColourRGBA'))
                this.colourText = objM.copy(_object.colourText);
            if (typeof _object.colourBackground !== 'undefined' && _object.colourBackground !== null && _object.colourBackground.IsType('TColourRGBA'))
                this.colourBackground = objM.copy(_object.colourBackground);
        }
    };

    TParagraphText.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphElement.prototype.IsType.call(this,_type);
    };

    TParagraphText.prototype.ParseXML = function(tag){
        TParagraphElement.prototype.ParseXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('id');
            this.SetId(attr);
            attr = tag.getAttribute('name');
            var attr2 = tag.getAttribute('value');
            var data = null,tmp;
            if (typeof attr2 !== 'undefined' && attr2 !== null)
                data = attr2;
            else
            {
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    tmp = this.FindVariable(attr);
                    if (typeof tmp !== 'undefined' && tmp !== null && tmp.IsType('TVariable'))
                        data = tmp.GetValue();
                }
            }
            if (tmp !== null)
            {
                this.variable = tmp;
                if (tmp.IsType('TVariableString'))
                    this.variable.SetValue(data);
                else
                {
                    this.variable.SetValue(this.CalculateValue(data));
                    this.variable.SetEquation(data);
                    this.variable.ReadXML(tag);
                }
                
            }else
            {
                if (typeof attr !== 'undefined' && attr !== null)// && data !== null)
                {
                    var attr3 = tag.getAttribute('typeVar');
                    this.variable = null;
                    if (typeof attr3 !== 'undefined' && attr3 !== null)
                    {
                        if (attr3 === 'int')
                        {
                            this.variable = objM.newObject('TVariableInt');
                            if (this.variable !== null)
                            {
                                this.variable.SetValue(this.CalculateValue(data));
                                this.variable.SetEquation(data);
                                this.variable.ReadXML(tag);
                            }
                        }
                        if (attr3 === 'double')
                        {
                            this.variable = objM.newObject('TVariableDouble');
                            if (this.variable !== null)
                            {
                                this.variable.SetValue(this.CalculateValue(data));
                                this.variable.SetEquation(data);
                                this.variable.ReadXML(tag);
                            }
                        }
                        if (attr3 === 'string')
                        {
                            this.variable = objM.newObject('TVariableString');
                            if (this.variable !== null)
                            {
                                this.variable.SetValue(data);
                                this.variable.ReadXML(tag);
                            }
                        }
                        if (attr3 === 'void')
                        {
                            this.variable = objM.newObject('TVariableVoidTXT');
                            if (this.variable !== null)
                            {
                                this.variable.SetEquation(data);
//                                this.variable.SetValue(data);
                                this.variable.ReadXML(tag);
                            }
                        }
                    }

                    if (this.variable === null)
                    {
                        if (IsInt(attr2))
                        {
                            this.variable = objM.newObject('TVariableInt');
                            if (this.variable !== null)
                                this.variable.ReadXML(tag);
                        }else
                        {
                            if (IsNumeric(attr2))
                            {
                                this.variable = objM.newObject('TVariableDouble');
                                if (this.variable !== null)
                                    this.variable.ReadXML(tag);
                            }else
                            {
                                this.variable = objM.newObject('TVariableString');
                                if (this.variable !== null)
                                    this.variable.ReadXML(tag);
                            }

                        }
                    }

                }
            }

            var tag_ = tag.childNodes,r,g,b,a,tmp;
            if (tag_ !== null)
            {
                for (i = 0;i < tag_.length;i++)
                {
                    if (tag_[i].nodeType === 1)
                    {
                        if (tag_[i].nodeName === 'ColourBackground')
                        {
                            r = 0;g = 0;b = 0;a = 1;
                            attr = this.CalculateValue(tag_[i].getAttribute('r'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    r = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('g'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    g = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('b'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    b = tmp;
                            }
                            attr = tag_[i].getAttribute('a');
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    a = tmp;
                            }
                            this.colourBackground = objM.newObject('TColourRGBA');
                            if (this.colourBackground !== null)
                                this.colourBackground.SetColourRGBA(r,g,b,a);
                        }
                        if (tag_[i].nodeName === 'ColourText')
                        {
                            r = 0;g = 0;b = 0;a = 1;
                            attr = this.CalculateValue(tag_[i].getAttribute('r'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    r = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('g'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    g = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('b'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    b = tmp;
                            }
                            attr = this.CalculateValue(tag_[i].getAttribute('a'));
                            if (attr !== null && IsNumeric(attr))
                            {
                                tmp = parseFloat(attr);
                                if (tmp !== null && tmp >= 0 && tmp <= 1)
                                    a = tmp;
                            }
                            this.colourText = objM.newObject('TColourRGBA');
                            if (this.colourText !== null)
                                this.colourText.SetColourRGBA(r,g,b,a);
                        }
                    }
                }
            }
        }    
    };

    TParagraphText.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.variable !== 'undefined' && this.variable !== null && this.variable.IsType('TVariable'))
            {
                var tmp = [];
                if (!this.variable.IsType('TVariableString'))
                    this.variable.SetValue(this.CalculateValue(this.variable.GetName()));
                tmp[0] = this.variable.GetValue();
                tmp[1] = this.variable.GetWidth();
                tmp[2] = this.GetClassStyle();
                tmp[3] = this.colourBackground;
                tmp[4] = this.colourText;
                tmp[5] = this;
                _object.Add('ParagraphText',this.GetId(),tmp);
            }
        }
        
    };

    TParagraphText.prototype.GetVariable = function(){
        return this.variable;
    };

    TParagraphText.prototype.SetId = function(id_){
        if (typeof id_ !== 'undefined' && id_ !== null)
        {
            this.id = new String(id_);
            if (this.id !== null)
                this.id = this.id.toString();
        }
        if (id_ === null)
            this.id = null;
    };

    TParagraphText.prototype.GetId = function(){
        var tmp = new String(this.id);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TParagraphText.prototype.GetColourText = function(){
        return this.colourText;
    };

    TParagraphText.prototype.GetColourBackground = function(){
        return this.colourBackground;
    };

    TParagraphText.prototype.SetTypeVariable = function(type){
        if (typeof type !== 'undefined' && type !== null)
        {
            this.typeVariable = new String(type);
            if (this.typeVariable !== null)
                this.typeVariable = this.typeVariable.toString();
        }
//        if (type === null)
//            this.typeVariable = null;
    };

    TParagraphText.prototype.Refresh = function(){
        var tmp = this.GetId();
        if (tmp !== null)
        {
            var tmp2 = document.getElementById(tmp);
            if (typeof tmp2 !== 'undefined' && tmp2 !== null)
            {
                if (typeof this.variable !== 'undefined' && this.variable !== null && this.variable.IsType('TVariable'))
                    if (!this.variable.IsType('TVariableString'))
                         this.variable.SetValue(this.CalculateValue(this.variable.GetName()));
                tmp2.innerHTML = this.variable.GetValue();
            }
        }
    };

    TParagraphText.prototype.GetText = function(){
        if (this.variable !== null)
        {
            if (typeof this.variable !== 'undefined' && this.variable !== null && this.variable.IsType('TVariable'))
            {
                this.variable.SetValue(this.CalculateValue(this.variable.GetName()));
            }
            return this.variable.GetValue();
        }
        return '';
    };

}

TParagraphText.prototype = new TParagraphElement();





function TParagraphFigure(){
    var type = 'TParagraphFigure';
    TParagraphFigure.prototype.InitConstructor = function(){
        TParagraphElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.width = null;
        this.height = null;
        this.lineWidth = null;
        this.colourBackground = null;
        this.colour = null;
    };
    this.InitConstructor();

    TParagraphFigure.prototype.Init = function(_object){
        TParagraphElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphFigure'))
        {
            if (typeof _object.width !== 'undefined' && _object.width !== null && IsNumeric(_object.width))
                this.width = _object.width;
            if (typeof _object.height !== 'undefined' && _object.height !== null && IsNumeric(_object.height))
                this.height = _object.height;
            if (typeof _object.lineWidth !== 'undefined' && _object.lineWidth !== null && IsNumeric(_object.lineWidth))
                this.lineWidth = _object.lineWidth;
            if (typeof _object.colourBackground !== 'undefined' && _object.colourBackground !== null && _object.colourBackground.IsType('TColourTXT'))
                this.colourBackground = objM.copy(_object.colourBackground);
            if (typeof _object.colour !== 'undefined' && _object.colour !== null && _object.colour.IsType('TColourTXT'))
                this.colour = objM.copy(_object.colour);
        }
    };

    TParagraphFigure.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphElement.prototype.IsType.call(this,_type);
    };

    TParagraphFigure.prototype.ParseXML = function(tag){
        TParagraphElement.prototype.ParseXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            this.SetWidth(tag.getAttribute('width'));
            this.SetHeight(tag.getAttribute('height'));
            this.SetLineWidth(tag.getAttribute('lineWidth'));
            this.colourBackground = objM.newObject('TColourTXT'); 
            if (this.colourBackground !== null)
                this.colourBackground.ReadXML(tag);
            this.colour = objM.newObject('TColourTXT'); 
            if (this.colour !== null)
			{
				var attr = tag.getAttribute('rl');
				if (typeof attr !== 'undefined' && attr !== null)
					this.colour.SetR(attr);
				attr = tag.getAttribute('gl');
				if (typeof attr !== 'undefined' && attr !== null)
					this.colour.SetG(attr);
				attr = tag.getAttribute('bl');
				if (typeof attr !== 'undefined' && attr !== null)
					this.colour.SetB(attr);
				attr = tag.getAttribute('al');
				if (typeof attr !== 'undefined' && attr !== null)
					this.colour.SetA(attr);
			}
        }    
    };

    TParagraphFigure.prototype.SetWidth = function(w){
        if (typeof w !== 'undefined' && w !== null && IsNumeric(w))
            this.width = w;
        if (w === null)
            this.width = null;
    };

    TParagraphFigure.prototype.GetWidth = function(){
        return this.width;
    };

    TParagraphFigure.prototype.SetHeight = function(h){
        if (typeof h!== 'undefined' && h !== null && IsNumeric(h))
            this.height = h;
        if (h === null)
            this.height = null;
    };

    TParagraphFigure.prototype.GetHeight = function(){
        return this.height;
    };

    TParagraphFigure.prototype.SetLineWidth = function(w){
        if (typeof w !== 'undefined' && w !== null && IsNumeric(w))
            this.lineWidth = w;
        if (w === null)
            this.lineWidth = null;
    };

    TParagraphFigure.prototype.GetLineWidth = function(){
        return this.lineWidth;
    };


    TParagraphFigure.prototype.GetColourBackgroundTXT = function(){
        return this.colourBackground;
    };

    TParagraphFigure.prototype.GetColourBackground = function(){
        if (this.colourBackground !== null)
            return this.colourBackground.GetColour(this.GetObjectVariables());
        else
            return null;
    };

    TParagraphFigure.prototype.GetColourTXT = function(){
        return this.colour;
    };

    TParagraphFigure.prototype.GetColour = function(){
        if (this.colour !== null)
            return this.colour.GetColour(this.GetObjectVariables());
        else
            return null;
    };

}

TParagraphFigure.prototype = new TParagraphElement();


function TParagraphRectangle(){
    var type = 'TParagraphRectangle';
    TParagraphRectangle.prototype.InitConstructor = function(){
        TParagraphFigure.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TParagraphRectangle.prototype.Init = function(_object){
        TParagraphFigure.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphRectangle'))
        {
        }
    };

    TParagraphRectangle.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphFigure.prototype.IsType.call(this,_type);
    };

    TParagraphRectangle.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var tmp = [];
            tmp[0] = this.GetWidth();
            tmp[1] = this.GetHeight();
            tmp[2] = this.GetColourBackground();
            tmp[3] = this.GetLineWidth();
            tmp[4] = this.GetColour();
            _object.Add('Rectangle','Rect',tmp);
        }
    };

}

TParagraphRectangle.prototype = new TParagraphFigure();

function TParagraphImage(){
    var type = 'TParagraphImage';
    TParagraphImage.prototype.InitConstructor = function(){
        TParagraphFigure.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.variable = null;
        this.id = null;
	this.fileName = "";
    };
    this.InitConstructor();

    TParagraphImage.prototype.Init = function(_object){
        TParagraphFigure.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphText'))
        {
            if (typeof _object.variable !== 'undefined' && _object.variable !== null && _object.variable.IsType('TVariable'))
                this.variable = _object.variable;
            if (typeof _object.id !== 'undefined' && _object.id !== null)
            {
                this.id = new String(_object.id);
                if (this.id !== null)
                    this.id = this.id.toString();
            }
            if (typeof _object.fileName !== 'undefined' && _object.fileName !== null)
            {
                this.fileName = new String(_object.fileName);
                if (this.fileName !== null)
                    this.fileName = this.fileName.toString();
            }
        }
    };

    TParagraphImage.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphFigure.prototype.IsType.call(this,_type);
    };

    TParagraphImage.prototype.ParseXML = function(tag){
        TParagraphFigure.prototype.ParseXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('id');
            this.SetId(attr);
	    this.fileName = tag.getAttribute('fileName');
            attr = tag.getAttribute('name');
            var attr2 = tag.getAttribute('value');
            var data = null,tmp = null;
            if (typeof attr2 !== 'undefined' && attr2 !== null)
                data = attr2;
            else
            {
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    tmp = this.FindVariable(attr);
                    if (typeof tmp !== 'undefined' && tmp !== null && tmp.IsType('TVariable'))
                        data = tmp.GetValue();
                }
            }
            if (tmp !== null)
            {
                this.variable = tmp;
                if (tmp.IsType('TVariableString'))
                    this.variable.SetValue(data);
                else
                {
                    this.variable.SetValue(this.CalculateValue(data));
                    this.variable.SetEquation(data);
                    this.variable.ReadXML(tag);
                }
                
            }else
            {
                if (typeof attr !== 'undefined' && attr !== null)// && data !== null)
                {
                    var attr3 = tag.getAttribute('typeVar');
                    this.variable = null;
                    if (typeof attr3 !== 'undefined' && attr3 !== null)
                    {
                        if (attr3 === 'int')
                        {
                            this.variable = objM.newObject('TVariableInt');
                            if (this.variable !== null)
                            {
                                this.variable.SetValue(this.CalculateValue(data));
                                this.variable.SetEquation(data);
                                this.variable.ReadXML(tag);
                            }
                        }
                        if (attr3 === 'double')
                        {
                            this.variable = objM.newObject('TVariableDouble');
                            if (this.variable !== null)
                            {
                                this.variable.SetValue(this.CalculateValue(data));
                                this.variable.SetEquation(data);
                                this.variable.ReadXML(tag);
                            }
                        }
                        if (attr3 === 'string')
                        {
                            this.variable = objM.newObject('TVariableString');
                            if (this.variable !== null)
                            {
                                this.variable.SetValue(data);
                                this.variable.ReadXML(tag);
                            }
                        }
                        if (attr3 === 'void')
                        {
                            this.variable = objM.newObject('TVariableVoidTXT');
                            if (this.variable !== null)
                            {
                                this.variable.SetEquation(data);
//                                this.variable.SetValue(data);
                                this.variable.ReadXML(tag);
                            }
                        }
                    }

                    if (this.variable === null)
                    {
                        if (IsInt(attr2))
                        {
                            this.variable = objM.newObject('TVariableInt');
                            if (this.variable !== null)
                                this.variable.ReadXML(tag);
                        }else
                        {
                            if (IsNumeric(attr2))
                            {
                                this.variable = objM.newObject('TVariableDouble');
                                if (this.variable !== null)
                                    this.variable.ReadXML(tag);
                            }else
                            {
                                this.variable = objM.newObject('TVariableString');
                                if (this.variable !== null)
                                    this.variable.ReadXML(tag);
                            }

                        }
                    }

                }
            }

        }    
    };

    TParagraphImage.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.variable !== 'undefined' && this.variable !== null && this.variable.IsType('TVariable'))
            {
                var tmp = [],tmp2;
                if (!this.variable.IsType('TVariableString'))
                    this.variable.SetValue(this.CalculateValue(this.variable.GetName()));
                tmp2 = this.variable.GetValue();
                if (typeof tmp2 !== 'undefined' && tmp2 !== null && tmp2.length > 0)
                    tmp[0] = _SlideImageCatalog + '/' + tmp2;
                else
                    tmp[0] = _SlideImageCatalog + '/' + this.fileName;
                tmp[1] = this.variable.GetWidth();
                tmp[2] = this.GetClassStyle();
                tmp[3] = this.GetWidth();
                tmp[4] = this.GetHeight();
                tmp[5] = this;
                _object.Add('ParagraphImage',this.GetId(),tmp);
            }
	    if (this.fileName != null && this.fileName != "")
	    {
                var tmp = [];
                tmp[0] = _SlideImageCatalog + '/' + this.fileName;
                tmp[1] = null;
                tmp[2] = this.GetClassStyle();
                tmp[3] = this.GetWidth();
                tmp[4] = this.GetHeight();
                tmp[5] = this;
                _object.Add('ParagraphImage',this.GetId(),tmp);
            }
        }
        
    };

    TParagraphImage.prototype.GetVariable = function(){
        return this.variable;
    };

    TParagraphImage.prototype.SetId = function(id_){
        if (typeof id_ !== 'undefined' && id_ !== null)
        {
            this.id = new String(id_);
            if (this.id !== null)
                this.id = this.id.toString();
        }
        if (id_ === null)
            this.id = null;
    };

    TParagraphImage.prototype.GetId = function(){
        var tmp = new String(this.id);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TParagraphImage.prototype.SetTypeVariable = function(type){
        if (typeof type !== 'undefined' && type !== null)
        {
            this.typeVariable = new String(type);
            if (this.typeVariable !== null)
                this.typeVariable = this.typeVariable.toString();
        }
//        if (type === null)
//            this.typeVariable = null;
    };

    TParagraphImage.prototype.Refresh = function(){
        var tmp = this.GetId();
        if (tmp !== null)
        {
            var tmp2 = document.getElementById(tmp),tmp3;
            if (typeof tmp2 !== 'undefined' && tmp2 !== null)
            {
                if (typeof this.variable !== 'undefined' && this.variable !== null && this.variable.IsType('TVariable'))
                    if (!this.variable.IsType('TVariableString'))
                         this.variable.SetValue(this.CalculateValue(this.variable.GetName()));
                tmp3 = this.variable.GetValue();
                if (typeof tmp3 !== 'undefined' && tmp3 !== null && tmp3.length > 0)
                    tmp2.innerHTML = _SlideImageCatalog + '/' + tmp3;
                else
                    tmp2.innerHTML = "";
            }
        }
    };

    TParagraphImage.prototype.GetFileName = function(){
        if (this.variable !== null)
        {
            if (typeof this.variable !== 'undefined' && this.variable !== null && this.variable.IsType('TVariable'))
            {
                this.variable.SetValue(this.CalculateValue(this.variable.GetName()));
            }
            return this.variable.GetValue();
        }
        return '';
    };

}

TParagraphImage.prototype = new TParagraphFigure();


function TParagraphEmph(){
    var type = 'TParagraphEmph';
    TParagraphEmph.prototype.InitConstructor = function(){
        TParagraphElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.number = -1;
        this.paragraph = null;
    };
    this.InitConstructor();

    TParagraphEmph.prototype.Init = function(_object){
        TParagraphElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphEmph'))
        {
            if (typeof _object.number !== 'undefined' && _object.number !== null)
                this.number = _object.number;
            if (typeof _object.paragraph !== 'undefined' && _object.paragraph !== null && _object.paragraph.IsType('TParagraph'))
                this.paragraph = objM.copy(_object.paragraph);
        }
    };

    TParagraphEmph.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphElement.prototype.IsType.call(this,_type);
    };

    TParagraphEmph.prototype.GetNumber = function(){
        return this.number;
    };

    TParagraphEmph.prototype.SetNumber = function(_number){
        if (typeof _number !== 'undefined' && _number !== null && IsInt(_number))
        {
            this.number = _number;
        }        
    };

    TParagraphEmph.prototype.ParseXML = function(tag){
        TParagraphElement.prototype.ParseXML.call(this,tag);
        if (typeof tag !== 'undefined' && tag !== null)
        {
            var objM = this.GetObjectManager();
            if (typeof this.paragraph === 'undefined' || this.paragraph === null)
            {
                if (objM !== null)
                    this.paragraph = objM.newObject('TParagraph');
            }
            if (typeof this.paragraph !== 'undefined' && this.paragraph !== null && this.paragraph.IsType('TParagraph'))
            {
                this.paragraph.SetNewLineYN(false);
                var tmp = tag.childNodes;
                if (tmp !== 'undefined' && tmp !== null)
                {
                    this.paragraph.SetVariables(this.GetVariables());
                    this.paragraph.ParseXML(null,tag);
                }
            }
            this.SetNumber(-1);
            var tmp = tag.getAttribute('Number');
            if (tmp !== null)
            {
                tmp = parseInt(tmp);
                if (tmp !== null)
                    this.SetNumber(tmp);
            }
        }    
    };

    TParagraphEmph.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var tmp = [];
            tmp[0] = this.GetNumber();
            tmp[1] = this.GetClassStyle();
            _object.Add('Emph','Start',tmp);
            if (this.paragraph !== null)
                this.paragraph.Draw(_object);
            _object.Add('Emph','Stop',this.GetNumber());
        }
    };

}

TParagraphEmph.prototype = new TParagraphElement();

function TParagraphCode(){
    var type = 'TParagraphCode';
    TParagraphCode.prototype.InitConstructor = function(){
        TParagraphString.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.number = -1;
    };
    this.InitConstructor();

    TParagraphCode.prototype.Init = function(_object){
        TParagraphString.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphCode'))
        {
            if (typeof _object.number !== 'undefined' && _object.number !== null)
                this.number = _object.number;
        }
    };

    TParagraphCode.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphString.prototype.IsType.call(this,_type);
    };

    TParagraphCode.prototype.GetNumber = function(){
        return this.number;
    };

    TParagraphCode.prototype.SetNumber = function(_number){
        if (typeof _number !== 'undefined' && _number !== null && IsInt(_number))
        {
            this.number = _number;
        }        
    };

    TParagraphCode.prototype.ParseXML = function(tag){
        if (typeof tag !== 'undefined' && tag !== null)
        {
            this.SetNumber(-1);
            var tmp = tag.getAttribute('Number');
            if (tmp !== null)
            {
                tmp = parseInt(tmp);
                if (tmp !== null)
                    this.SetNumber(tmp);
            }
            var x2 = tag.childNodes;
            if (x2 !== null)
            {
                this.SetClassStyle(tag.getAttribute('style'));
                TParagraphString.prototype.ParseXML.call(this,x2[0]);
            }
        }    
    };

    TParagraphCode.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var tmp = [];
            tmp[0] = this.GetNumber();
            tmp[1] = this.GetClassStyle();
            _object.Add('Code','Start',tmp);
            TParagraphString.prototype.Draw.call(this,_object);
            _object.Add('Code','Stop',this.GetNumber());
        }
    };

}

TParagraphCode.prototype = new TParagraphString();


function TParagraphHyperref(){
    var type = 'TParagraphHyperref';
    TParagraphHyperref.prototype.InitConstructor = function(){
        TParagraphString.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.typeRef = null;
        this.link = null;
    };
    this.InitConstructor();

    TParagraphHyperref.prototype.Init = function(_object){
        TParagraphString.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphHyperref'))
        {
            if (typeof _object.typeRef !== 'undefined' && _object.typeRef !== null)
            {
                this.typeRef = new String(_object.typeRef);
                this.typeRef = this.typeRef.toString();
            }
            if (typeof _object.link !== 'undefined' && _object.link !== null)
            {
                this.link = new String(_object.link);
                this.link = this.link.toString();
            }
        }
    };

    TParagraphHyperref.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphString.prototype.IsType.call(this,_type);
    };

    TParagraphHyperref.prototype.GetTypeRef = function(){
        var tmp = new String(this.typeRef);
        return tmp.toString();
    };

    TParagraphHyperref.prototype.GetLink = function(){
        var tmp = new String(this.link);
        return tmp.toString();
    };

    TParagraphHyperref.prototype.ParseXML = function(tag){
        if (typeof tag !== 'undefined' && tag !== null)
        {
            var tmp = tag.getAttribute('link');
            if (tmp !== null)
            {
                this.link = new String(tmp);
                this.link = this.link.toString();
            }
            var tmp = tag.getAttribute('typeRef');
            if (tmp !== null)
            {
                this.typeRef = new String(tmp);
                this.typeRef = this.typeRef.toString();
            }
            var x2 = tag.childNodes;
            if (x2 !== null)
                TParagraphString.prototype.ParseXML.call(this,x2[0]);
        }    
    };

    TParagraphHyperref.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var tmp = [];
            tmp[0] = this.typeRef;
            tmp[1] = this.link;
            _object.Add('Href','Start',tmp);
            TParagraphString.prototype.Draw.call(this,_object);
            _object.Add('Href','Stop');
        }
    };

}

TParagraphHyperref.prototype = new TParagraphString();

function TParagraphHyperref(){
    var type = 'TParagraphHyperref';
    TParagraphHyperref.prototype.InitConstructor = function(){
        TParagraphString.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.typeRef = null;
        this.link = null;
    };
    this.InitConstructor();

    TParagraphHyperref.prototype.Init = function(_object){
        TParagraphString.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphHyperref'))
        {
            if (typeof _object.typeRef !== 'undefined' && _object.typeRef !== null)
            {
                this.typeRef = new String(_object.typeRef);
                this.typeRef = this.typeRef.toString();
            }
            if (typeof _object.link !== 'undefined' && _object.link !== null)
            {
                this.link = new String(_object.link);
                this.link = this.link.toString();
            }
        }
    };

    TParagraphHyperref.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphString.prototype.IsType.call(this,_type);
    };

    TParagraphHyperref.prototype.GetTypeRef = function(){
        var tmp = new String(this.typeRef);
        return tmp.toString();
    };

    TParagraphHyperref.prototype.GetLink = function(){
        var tmp = new String(this.link);
        return tmp.toString();
    };

    TParagraphHyperref.prototype.ParseXML = function(tag){
        if (typeof tag !== 'undefined' && tag !== null)
        {
            var tmp = tag.getAttribute('link');
            if (tmp !== null)
            {
                this.link = new String(tmp);
                this.link = this.link.toString();
            }
            var tmp = tag.getAttribute('typeRef');
            if (tmp !== null)
            {
                this.typeRef = new String(tmp);
                this.typeRef = this.typeRef.toString();
            }
            var x2 = tag.childNodes;
            if (x2 !== null)
                TParagraphString.prototype.ParseXML.call(this,x2[0]);
        }    
    };

    TParagraphHyperref.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var tmp = [];
            tmp[0] = this.typeRef;
            tmp[1] = this.link;
            _object.Add('Href','Start',tmp);
            TParagraphString.prototype.Draw.call(this,_object);
            _object.Add('Href','Stop');
        }
    };

}

TParagraphHyperref.prototype = new TParagraphString();


function TParagraphLocalHyperref(){
    var type = 'TParagraphLocalHyperref';
    TParagraphLocalHyperref.prototype.InitConstructor = function(){
        TParagraphString.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.typeRef = null;
        this.link = null;
    };
    this.InitConstructor();

    TParagraphLocalHyperref.prototype.Init = function(_object){
        TParagraphString.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphLocalHyperref'))
        {
            if (typeof _object.typeRef !== 'undefined' && _object.typeRef !== null)
            {
                this.typeRef = new String(_object.typeRef);
                this.typeRef = this.typeRef.toString();
            }
            if (typeof _object.link !== 'undefined' && _object.link !== null)
            {
                this.link = new String(_object.link);
                this.link = this.link.toString();
            }
        }
    };

    TParagraphLocalHyperref.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphString.prototype.IsType.call(this,_type);
    };

    TParagraphLocalHyperref.prototype.GetTypeRef = function(){
        var tmp = new String(this.typeRef);
        return tmp.toString();
    };

    TParagraphLocalHyperref.prototype.GetLink = function(){
        var tmp = new String(this.link);
        return tmp.toString();
    };

    TParagraphLocalHyperref.prototype.ParseXML = function(tag){
        if (typeof tag !== 'undefined' && tag !== null)
        {
            var tmp = tag.getAttribute('link');
            if (tmp !== null)
            {
                this.link = new String(tmp);
                this.link = this.link.toString();
            }
            var tmp = tag.getAttribute('typeRef');
            if (tmp !== null)
            {
                this.typeRef = new String(tmp);
                this.typeRef = this.typeRef.toString();
            }
            var x2 = tag.childNodes;
            if (x2 !== null)
                TParagraphString.prototype.ParseXML.call(this,x2[0]);
        }    
    };

    TParagraphLocalHyperref.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var tmp = [];
            tmp[0] = this.typeRef;
            tmp[1] = this.link;
            _object.Add('LocalHref','Start',tmp);
            TParagraphString.prototype.Draw.call(this,_object);
            _object.Add('LocalHref','Stop');
        }
    };

}

TParagraphLocalHyperref.prototype = new TParagraphString();


function TParagraphEquation(){
    var type = 'TParagraphEquation';
    TParagraphEquation.prototype.InitConstructor = function(){
        TParagraphString.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TParagraphEquation.prototype.Init = function(_object){
        TParagraphString.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphEmph'))
        {
        }
    };

    TParagraphEquation.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphString.prototype.IsType.call(this,_type);
    };

    TParagraphEquation.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            _object.Add('PE','Start');
            TParagraphString.prototype.Draw.call(this,_object);
            _object.Add('PE','Stop');
        }
    };

}

TParagraphEquation.prototype = new TParagraphString();

function TParagraphReference(){
    var type = 'TParagraphReference';
    TParagraphReference.prototype.InitConstructor = function(){
        TParagraphElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.reference = null;
        this.referenceObject = null;
    };
    this.InitConstructor();

    TParagraphReference.prototype.Init = function(_object){
        TParagraphElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraphReference'))
        {
            if (typeof _object.reference !== 'undefined' && _object.reference !== null)
            {
                this.reference = new String(_object.reference);
                this.reference = this.reference.toString();
            }
            if (typeof _object.referenceObject !== 'undefined' && _object.referenceObject !== null)
            {
                this.referenceObject = _object.referenceObject;
            }
        }
    };

    TParagraphReference.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphElement.prototype.IsType.call(this,_type);
    };
    
    TParagraphReference.prototype.ParseXML = function(tag){
        if (typeof tag !== 'undefined' && tag !== null)
        {
            var x2 = tag.childNodes;
            this.reference = new String(x2[0].nodeValue);
            if (this.reference !== null)
                this.reference = this.reference.toString();
        }    
    };

    TParagraphReference.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.referenceObject !== 'undefined' && this.referenceObject !== null && this.referenceObject.IsType('TNumberElement'))
            {
                _object.Add('Ref',this.reference,this.referenceObject.GetNumber());
            }
        }
    };

    TParagraphReference.prototype.SetReferenceObject = function(_object){
        if (typeof _object !== 'undefined')
        {
            this.referenceObject = _object;
        }
    };

    TParagraphReference.prototype.GetReference = function(){
        var tmp = new String(this.reference);
        if (tmp !== null)
            return tmp.toString();
        else
            return null;
    };

    TParagraphReference.prototype.ActualizeId = function(_pageElements){
        if (typeof _pageElements !== 'undefined' && _pageElements !== null && _pageElements.length > 0)
        {
            var i,obj,obj2;
            for (i = 0;i < _pageElements.length;i++)
            {
                obj = _pageElements[i];
                if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObject'))
                {
//                    if (this.reference === obj.GetId())
                    obj2 = obj.FindElementById(this.reference);
                    if (obj2 !== null)
                    
                    {
                        this.referenceObject = obj2;
                        return;
                    }
                }
            }
        }
    };

}

TParagraphReference.prototype = new TParagraphElement();

function TReference(){
    var type = 'TReference';
    TReference.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);    
        this.ref;
        this.SetTypePageElement('Reference');
    };
    this.InitConstructor();

    TReference.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TReference'))
        {
            if (typeof _object.ref !== 'undefined' && _object.ref !== null)
            {
                this.ref = new String(_object.ref);
                this.ref = this.ref.toString();
            }
        }
    };

    TReference.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    
    TReference.prototype.ReadXML = function(tag,fun){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var x = tag.getAttribute('ref');
            if (typeof x !== 'undefined' && x !== null)
            {
                this.ref = new String(x);
                this.ref = this.ref.toString();
                
            }
        }
    };

    TReference.prototype.GetReference = function(){
        if (this.ref !== null)
        {
            var tmp = new String(this.ref);
            return tmp.toString();
        }
        return null;
    };


    TReference.prototype.ActualizeData = function(data){
        TPageElement.prototype.ActualizeData.call(this,data);
        if (typeof data !== 'undefined' && data !== null && data.IsType('TReadPaperData'))
        {
            var n = data.GetNumberOfElements(),i,ob,id;
            for (i = 0;i < n;i++)
            {
                ob = data.GetElement(i);
                if (typeof ob !== 'undefined' && ob !== null && ob.IsType('TPageElement'))
                {
                    id = ob.GetId();
                    if (typeof id !== 'undefined' && id !== null)
                    {
                        if (this.ref === id)
                        {
                            return ob;
                        }
                    }
                }
            }
        }
        return null;
    };

}

TReference.prototype = new TPageElement();


function TItem(){
    var type = 'TItem';
    TItem.prototype.InitConstructor = function(){
        TMultilanguageStringData.prototype.InitConstructor.call(this);
        this.SetType(type);     
        this.itemElements = [];
        this.numberElement = 0;
        this.variables = null;
        this.classStyle = null;
//        this.SetTypePageElement('Itemize');
    };
    this.InitConstructor();

    TItem.prototype.InitConstructor2 = function(){
        TObjectMultilanguage.prototype.InitConstructor2.call(this);
        var objM = this.GetObjectManager();
        if (objM !== null)
            this.variables = objM.newObject('TVariables');
    };


    TItem.prototype.Init = function(_object){
        TMultilanguageStringData.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TItem'))
        {
            var i;            
            if (typeof _object.itemElements !== 'undefined' && _object.itemElements !== null)
            {
                this.itemElements = [];
                for (i = 0;i < _object.itemElements.length;i++)
                    this.itemElements[i] = objM.copy(_object.itemElements[i]);
            }
            if (typeof _object.numberElement !== 'undefined' && _object.numberElement !== null && IsInt(_object.numberElement))
                this.numberElement = _object.numberElement;
            if (typeof _object.variables !== 'undefined' && _object.variables !== null && _object.variables.IsType('TVariables'))
                this.variables = objM.copy(_object.variables);
            if (typeof _object.classStyle !== 'undefined' && _object.classStyle !== null)
            {
                this.classStyle = new String(_object.classStyle);
                this.classStyle = this.classStyle.toString();
            }
            
        }
    };

    TItem.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TMultilanguageStringData.prototype.IsType.call(this,_type);
    };
    
    TItem.prototype.ReadXML = function(tag,fun){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            this.classStyle = tag.getAttribute('style');
            var tag_ = tag.childNodes,i,tag2,k = 0,obj,attr;
            if (tag_ !== null)
            {
                for (i = 0;i < tag_.length;i++)
                {
                    if (tag_[i].nodeType === 1)
                    {
                        if (tag_[i].nodeName === 'Element')
                        {
                            tag2 = tag_[i];
                            attr = tag2.getAttribute('type');
                            if (attr !== null)
                            {
                                if (attr === 'Paragraph' || attr === 'Itemize' || attr === 'Table' || attr === 'DrawFigure' || attr === 'Equation' || attr === 'Var' || attr === 'Fun' || attr === 'Timer' || attr === 'Code')
                                {
                                    obj = this.GetElement(k);
                                    if (typeof obj === 'undefined' || obj === null)
                                    {
                                        obj = objM.newObject('T'+attr);
                                        if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                                        {
                                            obj.SetVariables(this.GetVariables());
                                            obj.SetDefaultLanguage(this.GetDefaultLanguage());
                                            this.itemElements[k] = obj;
                                        }
                                    }
                                    if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                                    {
//                                        obj.SetVariables(this.GetVariables());
                                        obj.ReadXML(tag2);
                                        if (attr === 'Var' || attr === 'Fun')
                                            this.SetVariables(obj.GetVariables());
                                    }
                                    k++;                                    
                                }
                            }                            
                        }
                    }
                }
            }
        }
    };

    TItem.prototype.GetElement = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0)
        {
            if (this.itemElements !== null && number < this.itemElements.length)
                return this.itemElements[number];
        }
        return null;
    };    

    TItem.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var i;
            var tmp = [];
            tmp[0] = this.classStyle;
            _object.Add('Item','Start',tmp);
            for (i = 0;i < this.itemElements.length;i++)
                if (this.itemElements[i] !== null)
                    this.itemElements[i].Draw(_object);
            _object.Add('Item','Stop');
        }
    };

    TItem.prototype.ActualizeId = function(_pageElements){
        if(typeof this.itemElements !== 'undefined' && this.itemElements !== null)
        {
            var i,n = this.itemElements.length,ob;
            for(i = 0;i<n;i++)
            {
                ob = this.itemElements[i];
                if (typeof ob !== 'undefined' && ob !== null && ob.IsType('TPageElement'))
                {
                    ob.ActualizeId(_pageElements);
                }
            }
        }
    };
    
    TItem.prototype.ChangeCurrentLanguageNumber = function(_language){
        TMultilanguageStringData.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        var i;
        if (typeof this.itemElements !== 'undefined' && this.itemElements !== null)
        {
            var i;            
            for (i = 0;i < this.itemElements.length;i++)
            {
                if (typeof this.itemElements[i] !== 'undefined' && this.itemElements[i] !== null && this.itemElements[i].IsType('TObjectMultilanguage'))
                    this.itemElements[i].ChangeCurrentLanguageNumber(_language);
            }
        }
    };

    TItem.prototype.ResetNumberElement = function(){
        this.numberElement = 0;
        if (typeof this.itemElements !== 'undefined' && this.itemElements !== null)
        {
            var i;            
            for (i = 0;i < this.itemElements.length;i++)
            {
                if (typeof this.itemElements[i] !== 'undefined' && this.itemElements[i] !== null && (this.itemElements[i].IsType('TEnumerate') || this.itemElements[i].IsType('TItemize')))
                    this.itemElements[i].ResetNumberElement();
            }
        }
    };

    TItem.prototype.GetElement = function(typeObject){
        if (typeof typeObject !== 'undefined' && typeObject !== null)
        {
            if (this.numberElement >= 0 && this.numberElement < this.itemElements.length)
            {
                var element;
                for (;this.numberElement < this.itemElements.length;this.numberElement++)
                {
                    if (typeof this.itemElements[this.numberElement] !== 'undefined' && this.itemElements[this.numberElement] !== null)
                    {
                        if (this.itemElements[this.numberElement].IsType('TEnumerate') || this.itemElements[this.numberElement].IsType('TItemize'))
                        {
                            element = this.itemElements[this.numberElement].GetElement(typeObject);
                            if (element !== null)
                                return element;
                        }
                        if (this.itemElements[this.numberElement].IsType(typeObject))
                        {
                            this.numberElement++;
                            return this.itemElements[this.numberElement-1];
                        }
                    }
                }
            }
        }
        return null;
    };

    TItem.prototype.LinkMethodRef = function(){
        if (typeof this.itemElements !== 'undefined' && this.itemElements !== null)
        {
            var i,j,obj,obj2;
            var links = document.getElementsByTagName('a');
            for (j = 0;j < this.itemElements.length;j++)
            {
                if (this.itemElements[j] !== null)
                {
                    if (this.itemElements[j].IsType('TNumberElement'))
                    {
                        for(i=0; i < links.length; i++)
                        {
                            obj = this.itemElements[j].FindElementById(links[i].className);
//                            if (links[i].className===this.itemElements[j].GetId())
                            if (obj !== null)
                            {
                                obj2 = this.GetParent();
                                if (obj2 !== null)
                                {
                                    obj2 = obj2.GetParent();
                                    if (obj2 !== null)
                                    {
                                        links[i].onclick = obj2.LinkClickRef;  // nazwa funkcji bez ()!
                                        links[i].thisObject = obj2;
                                    }
                                }
//                                links[i].thisObject = this;
//                                links[i].objectPageElement = this.pageELements[j];
                                links[i].objectPageElement = obj;
                            }
                        }    
                    }
                }
            }
        }
    };    


    TItem.prototype.ActualizeActions = function(){
//        TMultilanguageStringData.prototype.ActualizeActions.call(this);
        this.LinkMethodRef();
        if (typeof this.itemElements !== 'undefined' && this.itemElements !== null)
        {
            var i;
            for (i = 0;i < this.itemElements.length;i++)
            {
                if (typeof this.itemElements[i] !== 'undefined' && this.itemElements[i] !== null)
                {
                    this.itemElements[i].ActualizeActions();
                }                
            }            
        }
    };

    TItem.prototype.CalculateValue = function(value_){
        if (this.variables !== null)
            return this.variables.CalculateValue(value_);
        return null;
    };

    TItem.prototype.FindVariable = function(name_){
        if (this.variables !== null)
            return this.variables.FindVariable(name_);
        return null;
    };


    TItem.prototype.SetVariable = function(var_,name_){
        if (this.variables !== null)
            this.variables.SetVariable(var_,name_);
    };

    TItem.prototype.SetVariables = function(var_){
        if (this.variables !== null)
            this.variables.SetVariables(var_);
    };

    TItem.prototype.GetVariables = function(){
        if (this.variables !== null)
            return this.variables.GetVariables();
        return null;
    };

    TItem.prototype.FindElementById = function(id){
        if (typeof id !== 'undefined' && id !== null)
        {
            if (typeof this.itemElements !== 'undefined' && this.itemElements !== null)
            {
                var i,obj;
                for (i = 0;i < this.itemElements.length;i++)
                {
                    if (typeof this.itemElements[i] !== 'undefined' && this.itemElements[i] !== null && this.itemElements[i].IsType('TPageElement'))
                    {
                        obj = this.itemElements[i].FindElementById(id);
                        if (obj !== null)
                            return obj;
                    }
                }
            }
        }
        return null;
    };

    TItem.prototype.SetImageCatalog = function(catalog){
        if (typeof catalog !== 'undefined' && catalog !== null)
        {
            if (typeof this.itemElements !== 'undefined' && this.itemElements !== null)
            {
                var i;            
                for (i = 0;i < this.itemElements.length;i++)
                {
                    if (typeof this.itemElements[i] !== 'undefined' && this.itemElements[i] !== null && this.itemElements[i].IsType('TDrawFigure'))
                        this.itemElements[i].SetImageCatalog(catalog);
                }
            }
        }
    };


}

TItem.prototype = new TMultilanguageStringData();

function TEnumerate(){
    var type = 'TEnumerate';
    TEnumerate.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.SetTypePageElement('Enumerate');
        this.item = [];
        this.numberElement = 0;
    };
    this.InitConstructor();

    TEnumerate.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TEnumerate'))
        {
            if (typeof _object.item !== 'undefined' && _object.item !== null)
            {
                var i;            
                this.item = [];
                for (i = 0;i < _object.item.length;i++)
                {
                    this.item[i] = objM.copy(_object.item[i]);
                    if (typeof this.item[i] !== 'undefined' && this.item[i] !== null && this.item[i].IsType('TObject'))
                        this.item[i].SetParent(this);
                }
            }
            if (typeof _object.numberElement !== 'undefined' && _object.numberElement !== null && IsInt(_object.numberElement))
                this.numberElement = _object.numberElement;
        }
    };

    TEnumerate.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    
    TEnumerate.prototype.ReadXML = function(tag,fun){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var tag_ = tag.childNodes,i,tag2,k = 0,obj;
            if (tag_ !== null)
            {
                for (i = 0;i < tag_.length;i++)
                {
                    if (tag_[i].nodeType === 1)
                    {
                        if (tag_[i].nodeName === 'Item')
                        {
                            tag2 = tag_[i];
                            if (tag2 !== null)
                            {
                                obj = this.GetItem(k);
                                if (obj === null)
                                {
                                    obj = objM.newObject('TItem');
                                    obj.SetVariables(this.GetVariables());
                                    this.item[k] = obj;
                                    obj.SetParent(this);
                                    obj.SetDefaultLanguage(this.GetDefaultLanguage());
                                }
                                if (obj !== null)
                                    obj.ReadXML(tag2,fun);
                                k++;
                            }                            
                        }
                    }
                }
            }
        }
    };

    TEnumerate.prototype.GetItem = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0)
        {
            if (this.item !== null && number < this.item.length)
                return this.item[number];
        }
        return null;
    };
    
    TEnumerate.prototype.GetNItem = function(){
        if (this.item !== null)
            return this.item.length;
        return 0;
    };
    

    TEnumerate.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var YN = this.GetVisible();
            if (typeof _object.drawObject !== 'undefined' && _object.drawObject !== null && _object.drawObject.GetObjectType() === 'TeX')
                YN = true;
            if (YN)
            {
                var i;
                _object.Add('Enum','Start');
                for (i = 0;i < this.item.length;i++)
                    if (this.item[i] !== null)
                        this.item[i].Draw(_object);
                TPageElement.prototype.Draw.call(this,_object);
                _object.Add('Enum','Stop');
            }
        }
    };


    TEnumerate.prototype.ActualizeId = function(_pageElements){
        if(typeof this.item !== 'undefined' && this.item !== null)
        {
            var i,n = this.item.length,ob;
            for(i = 0;i<n;i++)
            {
                ob = this.item[i];
                if (typeof ob !== 'undefined' && ob !== null)
                {
                    ob.ActualizeId(_pageElements);
                }
            }
        }
        TPageElement.prototype.ActualizeId.call(this,_pageElements);
    };
    
    TEnumerate.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        if (typeof this.item !== 'undefined' && this.item !== null)
        {
            var i;            
            for (i = 0;i < this.item.length;i++)
            {
                if (typeof this.item[i] !== 'undefined' && this.item[i] !== null && this.item[i].IsType('TObjectMultilanguage'))
                    this.item[i].ChangeCurrentLanguageNumber(_language);
            }
        }
    };

    TEnumerate.prototype.ResetNumberElement = function(){
        this.numberElement = 0;
        if (typeof this.item !== 'undefined' && this.item !== null)
        {
            var i;            
            for (i = 0;i < this.item.length;i++)
            {
                if (typeof this.item[i] !== 'undefined' && this.item[i] !== null && this.item[i].IsType('TItem'))
                    this.item[i].ResetNumberElement();
            }
        }
    };

    TEnumerate.prototype.GetElement = function(typeObject){
        if (typeof typeObject !== 'undefined' && typeObject !== null)
        {
            if (this.numberElement >= 0 && this.numberElement < this.item.length)
            {
                var element;
                for (;this.numberElement < this.item.length;this.numberElement++)
                {
                    if (typeof this.item[this.numberElement] !== 'undefined' && this.item[this.numberElement] !== null && this.item[this.numberElement].IsType('TItem'))
                    {
                        element = this.item[this.numberElement].GetElement(typeObject);
                        if (element !== null)
                            return element;
                    }
                }
            }
        }
        return null;
    };

    TEnumerate.prototype.ActualizeActions = function(){
        TPageElement.prototype.ActualizeActions.call(this);
        if (typeof this.item !== 'undefined' && this.item !== null)
        {
            var i;            
            for (i = 0;i < this.item.length;i++)
            {
                if (typeof this.item[i] !== 'undefined' && this.item[i] !== null)
                    this.item[i].ActualizeActions();
            }
        }
    };

    TEnumerate.prototype.FindElementById = function(id){
        var obj = TPageElement.prototype.FindElementById.call(this,id);
        if (obj !== null)
            return obj;
        if (typeof id !== 'undefined' && id !== null)
        {
            if (typeof this.item !== 'undefined' && this.item !== null)
            {
                var i;
                for (i = 0;i < this.item.length;i++)
                {
                    if (typeof this.item[i] !== 'undefined' && this.item[i] !== null)
                    {
                        obj = this.item[i].FindElementById(id);
                        if (obj !== null)
                            return obj;
                    }
                }
            }
        }
        return null;
    };

    TEnumerate.prototype.SetImageCatalog = function(catalog){
        TPageElement.prototype.SetImageCatalog.call(this,catalog);
        if (typeof catalog !== 'undefined' && catalog !== null)
        {
            this.imageCatalog = new String(catalog);
            this.imageCatalog = this.imageCatalog.toString();
        }
        if (catalog === null)
            this.imageCatalog = null;        
        if (typeof this.imageCatalog !== 'undefined' && this.imageCatalog !== null)
        {
            if (typeof this.item !== 'undefined' && this.item !== null)
            {
                var i;            
                for (i = 0;i < this.item.length;i++)
                {
                    if (typeof this.item[i] !== 'undefined' && this.item[i] !== null)
                        this.item[i].SetImageCatalog(this.imageCatalog);
                }
            }
        }
    };

}

TEnumerate.prototype = new TPageElement();


function TItemize(){
    var type = 'TItemize';
    TItemize.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.SetTypePageElement('Itemize');
        this.item = [];
        this.numberElement = 0;
    };
    this.InitConstructor();

    TItemize.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TItemize'))
        {
            if (typeof _object.item !== 'undefined' && _object.item !== null)
            {
                var i;            
                this.item = [];
                for (i = 0;i < _object.item.length;i++)
                {
                    this.item[i] = objM.copy(_object.item[i]);
                    if (typeof this.item[i] !== 'undefined' && this.item[i] !== null && this.item[i].IsType('TObject'))
                        this.item[i].SetParent(this);
                }
            }
            if (typeof _object.numberElement !== 'undefined' && _object.numberElement !== null && IsInt(_object.numberElement))
                this.numberElement = _object.numberElement;
        }
    };

    TItemize.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    
    TItemize.prototype.ReadXML = function(tag,fun){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var tag_ = tag.childNodes,i,tag2,k = 0,obj;
            if (tag_ !== null)
            {
                for (i = 0;i < tag_.length;i++)
                {
                    if (tag_[i].nodeType === 1)
                    {
                        if (tag_[i].nodeName === 'Item')
                        {
                            tag2 = tag_[i];
                            if (tag2 !== null)
                            {
                                obj = this.GetItem(k);
                                if (obj === null)
                                {
                                    obj = objM.newObject('TItem');
                                    obj.SetVariables(this.GetVariables());
                                    this.item[k] = obj;
                                    obj.SetParent(this);
                                    obj.SetDefaultLanguage(this.GetDefaultLanguage());
                                }
                                if (obj !== null)
                                    obj.ReadXML(tag2,fun);
                                k++;
                            }                            
                        }
                    }
                }
            }
        }
    };

    TItemize.prototype.GetItem = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0)
        {
            if (this.item !== null && number < this.item.length)
                return this.item[number];
        }
        return null;
    };    

    TItemize.prototype.GetNItem = function(){
        if (this.item !== null)
            return this.item.length;
        return 0;
    };
    

    TItemize.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var YN = this.GetVisible();
            if (typeof _object.drawObject !== 'undefined' && _object.drawObject !== null && _object.drawObject.GetObjectType() === 'TeX')
                YN = true;
            if (YN)
            {
                var i;
                _object.Add('Itemize','Start');
                for (i = 0;i < this.item.length;i++)
                    if (this.item[i] !== null)
                        this.item[i].Draw(_object);
                TPageElement.prototype.Draw.call(this,_object);
                _object.Add('Itemize','Stop');
            }
        }
    };

    TItemize.prototype.ActualizeId = function(_pageElements){
        if(typeof this.item !== 'undefined' && this.item !== null)
        {
            var i,n = this.item.length,ob;
            for(i = 0;i<n;i++)
            {
                ob = this.item[i];
                if (typeof ob !== 'undefined' && ob !== null)
                {
                    ob.ActualizeId(_pageElements);
                }
            }
        }
        TPageElement.prototype.ActualizeId.call(this,_pageElements);
    };

    TItemize.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        var i;
        if (typeof this.item !== 'undefined' && this.item !== null)
        {
            var i;            
            for (i = 0;i < this.item.length;i++)
            {
                if (typeof this.item[i] !== 'undefined' && this.item[i] !== null && this.item[i].IsType('TObjectMultilanguage'))
                    this.item[i].ChangeCurrentLanguageNumber(_language);
            }
        }
    };

    TItemize.prototype.ResetNumberElement = function(){
        this.numberElement = 0;
        if (typeof this.item !== 'undefined' && this.item !== null)
        {
            var i;            
            for (i = 0;i < this.item.length;i++)
            {
                if (typeof this.item[i] !== 'undefined' && this.item[i] !== null && this.item[i].IsType('TItem'))
                    this.item[i].ResetNumberElement();
            }
        }
    };

    TItemize.prototype.GetElement = function(typeObject){
        if (typeof typeObject !== 'undefined' && typeObject !== null)
        {
            if (this.numberElement >= 0 && this.numberElement < this.item.length)
            {
                var element;
                for (;this.numberElement < this.item.length;this.numberElement++)
                {
                    if (typeof this.item[this.numberElement] !== 'undefined' && this.item[this.numberElement] !== null && this.item[this.numberElement].IsType('TItem'))
                    {
                        element = this.item[this.numberElement].GetElement(typeObject);
                        if (element !== null)
                            return element;
                    }
                }
            }
        }
        return null;
    };

    TItemize.prototype.ActualizeActions = function(){
        TPageElement.prototype.ActualizeActions.call(this);
        if (typeof this.item !== 'undefined' && this.item !== null)
        {
            var i;            
            for (i = 0;i < this.item.length;i++)
            {
                if (typeof this.item[i] !== 'undefined' && this.item[i] !== null)
                    this.item[i].ActualizeActions();
            }
        }
    };

    TItemize.prototype.FindElementById = function(id){
        var obj = TPageElement.prototype.FindElementById.call(this,id);
        if (obj !== null)
            return obj;
        if (typeof id !== 'undefined' && id !== null)
        {
            if (typeof this.item !== 'undefined' && this.item !== null)
            {
                var i;
                for (i = 0;i < this.item.length;i++)
                {
                    if (typeof this.item[i] !== 'undefined' && this.item[i] !== null)
                    {
                        obj = this.item[i].FindElementById(id);
                        if (obj !== null)
                            return obj;
                    }
                }
            }
        }
        return null;
    };

    TItemize.prototype.SetImageCatalog = function(catalog){
        TPageElement.prototype.SetImageCatalog.call(this,catalog);
        if (typeof catalog !== 'undefined' && catalog !== null)
        {
            this.imageCatalog = new String(catalog);
            this.imageCatalog = this.imageCatalog.toString();
        }
        if (catalog === null)
            this.imageCatalog = null;        
        if (typeof this.imageCatalog !== 'undefined' && this.imageCatalog !== null)
        {
            if (typeof this.item !== 'undefined' && this.item !== null)
            {
                var i;            
                for (i = 0;i < this.item.length;i++)
                {
                    if (typeof this.item[i] !== 'undefined' && this.item[i] !== null)
                        this.item[i].SetImageCatalog(this.imageCatalog);
                }
            }
        }
    };


}

TItemize.prototype = new TPageElement();


function TParagraph(){
    var type = 'TParagraph';
    TParagraph.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.paragraph = [];
        this.newLineYN = true;
        this.SetTypePageElement('Paragraph');
    };
    this.InitConstructor();

    TParagraph.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TParagraph'))
        {
            var i;
            if (typeof _object.paragraph !== 'undefined' && _object.paragraph !== null)
            {
                for (i = 0;i < _object.paragraph.length;i++)
                    this.paragraph[i] = objM.copy(_object.paragraph[i]);
            }
            if (typeof _object.newLineYN !== 'undefined' && _object.newLineYN !== null)
                this.newLineYN = _object.newLineYN;
        }
    };

    TParagraph.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    
    TParagraph.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var YN = this.GetVisible();
            if (typeof _object.drawObject !== 'undefined' && _object.drawObject !== null && _object.drawObject.GetObjectType() === 'TeX')
                YN = true;
            if (YN)
            {
                YN = this.newLineYN;
                var i;
                if (typeof this.paragraph !== 'undefined' && this.paragraph !== null && this.paragraph.length > 0)
                {
                    if (YN)
                    {
                        var tmp = [];
                        tmp[0] = this.GetId();
                        tmp[1] = this.GetClassStyle();
                        _object.Add('Paragraph','Start',tmp);
                    }
                    for (i = 0;i < this.paragraph.length;i++)
                    {
                        if (this.paragraph[i] !== null)
                        {
                            this.paragraph[i].Draw(_object);
                        }
                    }
                    if (YN)
                        _object.Add('Paragraph','Stop',tmp);
                }
            }
        }
    };

    TParagraph.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        var i;
        if (typeof this.paragraph !== 'undefined' && this.paragraph !== null)
        {
            for (i = 0;i < this.paragraph.length;i++)
                this.paragraph[i].ChangeCurrentLanguageNumber(_language);
        }
    };

    TParagraph.prototype.ParseXML = function(tag1,tag2){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag2 !== 'undefined' && tag2 !== null)
        {
            var i,x = tag2.childNodes,x2,j,k,k2,n,n2,attr;
            if (typeof tag1 !== 'undefined' && tag1 !== null)
                this.classStyle = tag1.getAttribute('style');
            for (i = 0,j = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 3)
                {
                    if (j >= this.paragraph.length || this.paragraph[j] === null)
                        this.paragraph[j] = objM.newObject('TParagraphString');
                    if (this.paragraph[j] !== null && this.paragraph[j].IsType('TParagraphString'))
                        this.paragraph[j].ParseXML(x[i]);
                    j++;
                }
                if (x[i].nodeType === 1)
                {
/*                    if(x[i].nodeName === 'T')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                            this.paragraph[j] = objM.newObject('TParagraphString');
                        if (this.paragraph[j] !== null && this.paragraph[j].IsType('TParagraphString'))
                            this.paragraph[j].ParseXML(x[i]);
                        j++;
                    }*/
                    if(x[i].nodeName === 'Underscore' || x[i].nodeName === 'Hash' || x[i].nodeName === 'Dash' || x[i].nodeName === 'Backslash' || x[i].nodeName === 'Br' || x[i].nodeName === 'br' || x[i].nodeName === 'S' || x[i].nodeName === 'Space' || x[i].nodeName === 'Less' || x[i].nodeName === 'Greater' || x[i].nodeName === 'Percent')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                        {
                            this.paragraph[j] = objM.newObject('TParagraphSymbol');
                            if (this.paragraph[j] !== null)
                                this.paragraph[j].ParseXML(x[i]);
                        }
                        j++;                        
                    }
                    if(x[i].nodeName === 'SpaceLength' || x[i].nodeName === 'spacelength')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                        {
                            this.paragraph[j] = objM.newObject('TParagraphSpaceLength');
                            if (this.paragraph[j] !== null)
                                this.paragraph[j].ParseXML(x[i]);
                        }
                        j++;                        
                    }
                    if(x[i].nodeName === 'StartSelect')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                        {
                            this.paragraph[j] = objM.newObject('TParagraphSelectStart');
                            if (this.paragraph[j] !== null)
                            {
                                this.paragraph[j].SetVariables(this.GetVariables());
                                this.paragraph[j].ParseXML(x[i]);
                                n = this.paragraph[j].GetNActions();
                                n2 = this.GetNActions();
                                for (k = 0,k2 = n2;k < n;k++,k2++)
                                    this.SetAction(this.paragraph[j].GetAction(k),k2);
                            }
                        }
                        j++;                        
                    }
                    if(x[i].nodeName === 'StopSelect')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                        {
                            this.paragraph[j] = objM.newObject('TParagraphSelectStop');
                            if (this.paragraph[j] !== null)
                                this.paragraph[j].ParseXML(x[i]);
                        }
                        j++;                        
                    }
                    if(x[i].nodeName === 'Option')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                        {
                            this.paragraph[j] = objM.newObject('TParagraphOption');

                            if (this.paragraph[j] !== null)
                            {
                                this.paragraph[j].SetVariables(this.GetVariables());
                                this.paragraph[j].ParseXML(x[i]);
                                n = this.paragraph[j].GetNActions();
                                n2 = this.GetNActions();
                                for (k = 0,k2 = n2;k < n;k++,k2++)
                                    this.SetAction(this.paragraph[j].GetAction(k),k2);
                            }
                        }
                        j++;                        
                        
                    }
                    if(x[i].nodeName === 'StartForm')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                        {
                            this.paragraph[j] = objM.newObject('TParagraphFormStart');
                            if (this.paragraph[j] !== null)
                                this.paragraph[j].ParseXML(x[i]);
                        }
                        j++;                        
                    }
                    if(x[i].nodeName === 'StopForm')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                        {
                            this.paragraph[j] = objM.newObject('TParagraphFormStop');
                            if (this.paragraph[j] !== null)
                                this.paragraph[j].ParseXML(x[i]);
                        }
                        j++;                        
                    }
                    if(x[i].nodeName === 'Input')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                        {
                            attr = x[i].getAttribute('type');
                            switch(attr)
                            {
                                case 'radio':
                                    this.paragraph[j] = objM.newObject('TParagraphRadioButton');
                                    break;
                                case 'checkbox':
                                    this.paragraph[j] = objM.newObject('TParagraphCheckBox');
                                    break;
                            }
                            if (this.paragraph[j] !== null)
                            {
                                this.paragraph[j].SetVariables(this.GetVariables());
                                this.paragraph[j].ParseXML(x[i]);
                                n = this.paragraph[j].GetNActions();
                                n2 = this.GetNActions();
                                for (k = 0,k2 = n2;k < n;k++,k2++)
                                    this.SetAction(this.paragraph[j].GetAction(k),k2);
                            }
                        }
                        j++;                        
                    }
                    if(x[i].nodeName === 'Edit')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                        {
                            this.paragraph[j] = objM.newObject('TEdit');
                            if (this.paragraph[j] !== null)
                            {
                                this.paragraph[j].SetVariables(this.GetVariables());
                                this.paragraph[j].ParseXML(x[i]);
                                n = this.paragraph[j].GetNActions();
                                n2 = this.GetNActions();
                                for (k = 0,k2 = n2;k < n;k++,k2++)
                                    this.SetAction(this.paragraph[j].GetAction(k),k2);
                                    

//                                this.SetVariable(this.paragraph[j].GetVariable());
                            }
                        }
                        j++;                        
                    }
                    if(x[i].nodeName === 'TextArea')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                        {
                            this.paragraph[j] = objM.newObject('TTextArea');
                            if (this.paragraph[j] !== null)
                            {
                                this.paragraph[j].SetVariables(this.GetVariables());
                                this.paragraph[j].ParseXML(x[i]);
                                n = this.paragraph[j].GetNActions();
                                n2 = this.GetNActions();
                                for (k = 0,k2 = n2;k < n;k++,k2++)
                                    this.SetAction(this.paragraph[j].GetAction(k),k2);
                                    

//                                this.SetVariable(this.paragraph[j].GetVariable());
                            }
                        }
                        j++;                        
                    }
                    if(x[i].nodeName === 'Button' || x[i].nodeName === 'ButtonLoadImage' || x[i].nodeName === 'ButtonSaveImage')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                        {
                            if(x[i].nodeName === 'ButtonLoadImage')
                                this.paragraph[j] = objM.newObject('TButtonLoadImage');
                            else
                                if(x[i].nodeName === 'ButtonSaveImage')
                                    this.paragraph[j] = objM.newObject('TButtonSaveImage');
                                else
                                    this.paragraph[j] = objM.newObject('TButton');
                            if (this.paragraph[j] !== null)
                            {
                                this.paragraph[j].SetVariables(this.GetVariables());
                                this.paragraph[j].ParseXML(x[i]);
                                n = this.paragraph[j].GetNActions();
                                n2 = this.GetNActions();
                                for (k = 0,k2 = n2;k < n;k++,k2++)
                                    this.SetAction(this.paragraph[j].GetAction(k),k2);
                                    

//                                this.SetVariable(this.paragraph[j].GetVariable());
                            }
                        }
                        j++;                        
                    }                    
                    if(x[i].nodeName === 'Slider')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                        {
                            this.paragraph[j] = objM.newObject('TSlider');
                            if (this.paragraph[j] !== null)
                            {
                                this.paragraph[j].SetVariables(this.GetVariables());
                                this.paragraph[j].ParseXML(x[i]);
                                n = this.paragraph[j].GetNActions();
                                n2 = this.GetNActions();
                                for (k = 0,k2 = n2;k < n;k++,k2++)
                                    this.SetAction(this.paragraph[j].GetAction(k),k2);
                                    

//                                this.SetVariable(this.paragraph[j].GetVariable());
                            }
                        }
                        j++;                        
                    }                    

                    if(x[i].nodeName === 'Text')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                        {
                            this.paragraph[j] = objM.newObject('TParagraphText');
                            if (this.paragraph[j] !== null)
                            {
                                this.paragraph[j].SetVariables(this.GetVariables());
                                this.paragraph[j].ParseXML(x[i]);
                            }
                        }
                        j++;                        
                    }
/*                    if(x[i].nodeName === 'Text')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                        {
                            this.paragraph[j] = objM.newObject('TParagraphText');
                            if (this.paragraph[j] !== null)
                            {
                                this.paragraph[j].SetVariables(this.GetVariables());
                                this.paragraph[j].ParseXML(x[i]);
                            }
                        }
                        j++;                        
                    }*/
                    if(x[i].nodeName === 'Image')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                        {
                            this.paragraph[j] = objM.newObject('TParagraphImage');
                            if (this.paragraph[j] !== null)
                            {
                                this.paragraph[j].SetVariables(this.GetVariables());
                                this.paragraph[j].ParseXML(x[i]);
                            }
                        }
                        j++;                        
                    }
                    if(x[i].nodeName === 'Emph')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                            this.paragraph[j] = objM.newObject('TParagraphEmph');
                        if (this.paragraph[j] !== null)
                        {
                            this.paragraph[j].SetVariables(this.GetVariables());
                            this.paragraph[j].ParseXML(x[i]);
                        }
                        j++;                        
                    }
                    if(x[i].nodeName === 'Code' || x[i].nodeName === 'code')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                            this.paragraph[j] = objM.newObject('TParagraphCode');
                        if (this.paragraph[j] !== null)
                            this.paragraph[j].ParseXML(x[i]);
                        j++;                        
                    }
                    if(x[i].nodeName === 'Href')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                            this.paragraph[j] = objM.newObject('TParagraphHyperref');
                        if (this.paragraph[j] !== null)
                            this.paragraph[j].ParseXML(x[i]);
                        j++;                        
                    }
                    if(x[i].nodeName === 'LocalHref')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                            this.paragraph[j] = objM.newObject('TParagraphLocalHyperref');
                        if (this.paragraph[j] !== null)
                            this.paragraph[j].ParseXML(x[i]);
                        j++;                        
                    }
                    if(x[i].nodeName === 'E')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                            this.paragraph[j] = objM.newObject('TParagraphEquation');
                        if (this.paragraph[j] !== null)
                        {
                            x2 = x[i].childNodes;
                            if (x2 !== null)
                                this.paragraph[j].ParseXML(x2[0]);
                        }
                        j++;                        
                    }
                    if(x[i].nodeName === 'R')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                            this.paragraph[j] = objM.newObject('TParagraphReference');
                        if (this.paragraph[j] !== null)
                        {
                            this.paragraph[j].ParseXML(x[i]);
                        }
                        j++;                        
                    }
                    if(x[i].nodeName === 'Rectangle')
                    {
                        if (j >= this.paragraph.length || this.paragraph[j] === null)
                            this.paragraph[j] = objM.newObject('TParagraphRectangle');
                        if (this.paragraph[j] !== null)
                        {
                            this.paragraph[j].SetVariables(this.GetVariables());
                            this.paragraph[j].ParseXML(x[i]);
                        }
                        j++;                        
                    }
                }
            }
        }
    };

    TParagraph.prototype.FindReferenceValue = function(name){
        if (typeof name !== 'undefined' && name !== null && typeof this.referenceName !== 'undefined' && this.referenceName !== null)
        {
            var i;
            for (i = 0;i < this.referenceName.length;i++)
            {
                if (name === this.referenceName[i])
                    return this.referenceValue[i];
            }
        }
        return null;
    };

    TParagraph.prototype.LinkMethod = function(){
        TPageElement.prototype.LinkMethod.call(this);
        var i,txt;
        if (typeof this.paragraph !== 'undefined' && this.paragraph !== null && this.paragraph.length > 0)
        {
            txt = '';
            for (i = 0;i < this.paragraph.length;i++)
            {
                if (this.paragraph[i] !== null)
                {
//                    if (this.paragraph[i].IsType('TParagraphReference'))
//                        this.paragraph[i].SetReferenceValue(this.FindReferenceValue(this.paragraph[i].GetReference()));
                }
            }
        }
    };
    
    TParagraph.prototype.ActualizeId = function(_pageElements){
        TPageElement.prototype.ActualizeId.call(this,_pageElements);
        var i,txt;
        if (typeof this.paragraph !== 'undefined' && this.paragraph !== null && this.paragraph.length > 0)
        {
            txt = '';
            for (i = 0;i < this.paragraph.length;i++)
            {
                if (this.paragraph[i] !== null)
                {
                    if (this.paragraph[i].IsType('TParagraphReference'))
                        this.paragraph[i].ActualizeId(_pageElements);
                }
            }
        }
    };

    TParagraph.prototype.SetNewLineYN = function(YN){
         if (typeof YN !== 'undefined' && YN !== null)
             this.newLineYN = YN;
    };
    
    TParagraph.prototype.AddElement = function(elem,number){
        if (typeof elem !== 'undefined' && elem !== null && elem.IsType('TParagraphElement'))
        {
            if (typeof number === 'undefined' || number === null || !IsInt(number))
            {
                this.paragraph[this.paragraph.length] = elem;
                return this.paragraph.length - 1;
            }else
            {
                this.paragraph[number] = elem;
                return number;
            }
        }
        return null;
    };

    TParagraph.prototype.GetElement = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number))
        {
            return this.paragraph[number];
        }
        return null;
    };
    
    TParagraph.prototype.SetVariables = function(var_){
        TPageElement.prototype.SetVariables.call(this,var_);
        var i,txt;
        if (typeof this.paragraph !== 'undefined' && this.paragraph !== null && this.paragraph.length > 0)
        {
            txt = '';
            for (i = 0;i < this.paragraph.length;i++)
            {
                if (this.paragraph[i] !== null)
                {
                    if (this.paragraph[i].IsType('TEdit'))
                        this.paragraph[i].SetVariables(var_);
                }
            }
        }
    };    
    
    TParagraph.prototype.GetTXT = function(){
        var res1 = TPageElement.prototype.GetTXT.call(this);
        var i,res2 = '',YN = false;
        if (typeof this.paragraph !== 'undefined' && this.paragraph !== null && this.paragraph.length > 0)
        {
            for (i = 0;i < this.paragraph.length;i++)
            {
                if (this.paragraph[i] !== null && this.paragraph[i].IsType('TParagraphElement'))
                {
                    txt = this.paragraph[i].GetTXT();
                    if (txt !== null)
                    {
                        res2 = res2 + txt;
                        YN = true;
                    }
                }
            }
        }
        if (YN)
        {
            if (res1 != null)
            {
                res2 = res1 + res2;
            }
            return res2;
        }
            
        return res1;
    };    
    
}

TParagraph.prototype = new TPageElement();

function TCode(){
    var type = 'TCode';
    TCode.prototype.InitConstructor = function(){
        TParagraph.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.SetTypePageElement('Code');
        this.spaceLength = "2em"
        this.styleComment = "comment";
        this.symbolComment = "//";
        this.styleReservedWord = "reservedWord";
        this.styleClassName = "className";
        this.symbolString = '"';
        this.styleString = "programString";
        this.styleProgramCode = "programCode";
    };
    this.InitConstructor();

    TCode.prototype.Init = function(_object){
        TParagraph.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TCode'))
        {
            if (typeof _object.spaceLength !== 'undefined' && _object.spaceLength !== null)
            {
                this.spaceLength = new String(_object.spaceLength);
                this.spaceLength = this.spaceLength.toString();
            }
            if (typeof _object.styleComment !== 'undefined' && _object.styleComment !== null)
            {
                this.styleComment = new String(_object.styleComment);
                this.styleComment = this.styleComment.toString();
            }
            if (typeof _object.symbolComment !== 'undefined' && _object.symbolComment !== null)
            {
                this.symbolComment = new String(_object.symbolComment);
                this.symbolComment = this.symbolComment.toString();
            }
            if (typeof _object.styleReservedWord !== 'undefined' && _object.styleReservedWord !== null)
            {
                this.styleReservedWord = new String(_object.styleReservedWord);
                this.styleReservedWord = this.styleReservedWord.toString();
            }
            if (typeof _object.styleClassName !== 'undefined' && _object.styleClassName !== null)
            {
                this.styleClassName = new String(_object.styleClassName);
                this.styleClassName = this.styleClassName.toString();
            }
            if (typeof _object.symbolString !== 'undefined' && _object.symbolString !== null)
            {
                this.symbolString = new String(_object.symbolString);
                this.symbolString = this.symbolString.toString();
            }
            if (typeof _object.styleString !== 'undefined' && _object.styleString !== null)
            {
                this.styleString = new String(_object.styleString);
                this.styleString = this.styleString.toString();
            }
            if (typeof _object.styleProgramCode !== 'undefined' && _object.styleProgramCode !== null)
            {
                this.styleProgramCode = new String(_object.styleProgramCode);
                this.styleProgramCode = this.styleProgramCode.toString();
            }
        }
    };

    TCode.prototype.AddNodes = function(tag2, text, name, argumentName, argument){
        var n,i,node,txt,txt2,YN;
        for (i = 0;i < tag2.childNodes.length;i++)
        {
            if (tag2.childNodes[i].nodeType === 3)
            {
                YN = true;
                txt = tag2.childNodes[i].nodeValue;
                while (1)
                {
                    n = txt.search(text);
                    if (n < 0)
                    {
                        txt2 = txt;
                        if (!YN)
                        {
                            node = document.createTextNode(txt2);
                            if (i + 1 >= tag2.childNodes.length)
                                tag2.appendChild(node);
                            else
                                tag2.insertBefore(node,tag2.childNodes[i+1]);
                            i++;
                        }
                    }else
                        txt2 = txt.slice(0,n);
                    if (n > 0)
                    {
                        node = document.createTextNode(txt2);
                        if (YN)
                        {
                            tag2.replaceChild(node,tag2.childNodes[i]);
                            YN = false;
                        }else
                        {
                            if (i + 1 >= tag2.childNodes.length)
                                tag2.appendChild(node);
                            else
                                tag2.insertBefore(node,tag2.childNodes[i+1]);
                            i++;                        
                        }
                    }else
                        if(YN && n === 0)
                        {
                            tag2.removeChild(tag2.childNodes[i]);
                            YN = false;
                            i--;
                        }
                    if (n < 0)
                        break;
                    
                    node = document.createElement(name);
                    if (typeof argumentName !== 'undefined' && argumentName !== null && typeof argument !== 'undefined' && argument !== null)
                        node.setAttribute(argumentName, argument);
                    if (i + 1 >= tag2.childNodes.length)
                        tag2.appendChild(node);
                    else
                        tag2.insertBefore(node,tag2.childNodes[i+1]);
                    i++;
                    txt = txt.slice(n+1,txt.length)
                }
            }
        }
    }

    TCode.prototype.AddComment = function(tag2, commentTag, style){
        var i,x = tag2.childNodes,node,node2,n,txt;
        for (i = 0;i < x.length;i++)
        {
            if (x[i].nodeType === 3)
            {
                txt = x[i].nodeValue;
                n = txt.search(commentTag);
                if (n >= 0)
                {
                    node = document.createElement("Code");
                    node2 = document.createTextNode(txt);
                    node.appendChild(node2);                    
                    if (typeof style !== 'undefined' && style !== null)
                        node.setAttribute("style", style);
                    tag2.replaceChild(node,tag2.childNodes[i]);
                }
            }
        }
    }
    
    TCode.prototype.ReadWords = function(txt){
        var n = 0,i = 0,j,res = [];
        for(j = 0;;j++)
        {
            n = txt.indexOf(",",i);
            if (n < 0)
            {
                if (txt.length > 0)
                    res[j] = txt.slice(i,txt.length);
                break;
            }
            res[j] = txt.slice(i,n);
            i = n + 1;
        }
        return res;
    }

    TCode.prototype.AddWord = function(tag2, word, style){
        var i,node,node2,n,txt,txt2,YN,n2,YN2;
        for (i = 0;i < tag2.childNodes.length;i++)
        {
            if (tag2.childNodes[i].nodeType === 3)
            {
                txt = tag2.childNodes[i].nodeValue;
                YN = false;
                for(;;)
                {
                    n = txt.search(word);
                    if (n > 0)
                    {
                        YN2 = true;
                        txt2 = txt.toLowerCase();
                        for(;;)
                        {
                            if ((txt2[n-1] >= 'a' && txt2[n-1] <= 'z') || (txt2[n+word.length] >= 'a' && txt2[n+word.length] <= 'z'))
                            {
                                n = txt.indexOf(word,n+1);
                                if (n < 0)
                                    break;
                            }else
                                break;
                        }
                    }
                    if (n >= 0)
                    {
                        node = document.createElement("Code");
                        node2 = document.createTextNode(word);
                        node.appendChild(node2);                    
                        if (typeof style !== 'undefined' && style !== null)
                            node.setAttribute("style", style);
                        if (n > 0)
                        {
                            txt2 = txt.slice(0,n);
                            node2 = document.createTextNode(txt2);
                            if (YN)
                            {
                                if (i + 1 >= tag2.childNodes.length)
                                    tag2.appendChild(node2);
                                else
                                    tag2.insertBefore(node2,tag2.childNodes[i+1]);
                                i++;
                            }else
                                tag2.replaceChild(node2,tag2.childNodes[i]);
                        }else
                        {
                            if (!YN)
                            {
                                tag2.removeChild(tag2.childNodes[i]);
                                i--;
                            }
                        }
                        txt = txt.slice(n + word.length,txt.length);
                        if (i + 1 >= tag2.childNodes.length)
                            tag2.appendChild(node);
                        else
                            tag2.insertBefore(node,tag2.childNodes[i+1]);
                        i++;
                        YN = true;
                    }else
                    {
                        if (YN && txt.length > 0)
                        {
                            node = document.createTextNode(txt);
                            if (i + 1 >= tag2.childNodes.length)
                                tag2.appendChild(node);
                            else
                                tag2.insertBefore(node,tag2.childNodes[i+1]);                            
                        }
                        break;
                    }
                }
            }
        }
    }

    TCode.prototype.AddString = function(tag2, symbol, style){
        var i,node,node2,n,txt,txt2,YN,n2,YN2;
        for (i = 0;i < tag2.childNodes.length;i++)
        {
            if (tag2.childNodes[i].nodeType === 3)
            {
                txt = tag2.childNodes[i].nodeValue;
                YN = false;
                for(;;)
                {
                    n = txt.search(symbol);
                    n2 = txt.indexOf(symbol,n+1);
                    if (n > 0 && n2 > 0)
                    {
                        YN2 = true;
                    }
                    if (n >= 0)
                    {
                        node = document.createElement("Code");
                        node2 = document.createTextNode(txt.slice(n,n2+1));
                        node.appendChild(node2);                    
                        if (typeof style !== 'undefined' && style !== null)
                            node.setAttribute("style", style);
                        if (n > 0)
                        {
                            txt2 = txt.slice(0,n);
                            node2 = document.createTextNode(txt2);
                            if (YN)
                            {
                                if (i + 1 >= tag2.childNodes.length)
                                    tag2.appendChild(node2);
                                else
                                    tag2.insertBefore(node2,tag2.childNodes[i+1]);
                                i++;
                            }else
                                tag2.replaceChild(node2,tag2.childNodes[i]);
                        }else
                        {
                            if (!YN)
                            {
                                tag2.removeChild(tag2.childNodes[i]);
                                i--;
                            }
                        }
                        txt = txt.slice(n2+1,txt.length);
                        if (i + 1 >= tag2.childNodes.length)
                            tag2.appendChild(node);
                        else
                            tag2.insertBefore(node,tag2.childNodes[i+1]);
                        i++;
                        YN = true;
                    }else
                    {
                        if (YN && txt.length > 0)
                        {
                            node = document.createTextNode(txt);
                            if (i + 1 >= tag2.childNodes.length)
                                tag2.appendChild(node);
                            else
                                tag2.insertBefore(node,tag2.childNodes[i+1]);                            
                        }
                        break;
                    }
                }
            }
        }
    }

    TCode.prototype.AddCodeLine = function(tag2, style){
        var i,x = tag2.childNodes,node,node2,n,txt;
        for (i = 0;i < x.length;i++)
        {
            if (x[i].nodeType === 3)
            {
                txt = x[i].nodeValue;
                if (txt.length > 0)
                {
                    node = document.createElement("Code");
                    node2 = document.createTextNode(txt);
                    node.appendChild(node2);                    
                    if (typeof style !== 'undefined' && style !== null)
                        node.setAttribute("style", style);
                    tag2.replaceChild(node,tag2.childNodes[i]);
                }
            }
        }
    }

    TCode.prototype.ParseXML = function(tag1,tag2){

        var words = [],i,className = [];
        if (typeof tag1 !== 'undefined' && tag1 !== null)
        {
            var tmp;
            tmp = tag1.getAttribute('spaceLength');
            if (typeof tmp !== 'undefined' && tmp !== null)
                this.spaceLength = tmp;
            tmp = tag1.getAttribute('styleComment');
            if (typeof tmp !== 'undefined' && tmp !== null)
                this.styleComment = tmp;
            tmp = tag1.getAttribute('symbolComment');
            if (typeof tmp !== 'undefined' && tmp !== null)
                this.symbolComment = tmp;
            tmp = tag1.getAttribute('reservedWord');
            if (typeof tmp !== 'undefined' && tmp !== null)
                words = this.ReadWords(tmp);
            tmp = tag1.getAttribute('styleReservedWord');
            if (typeof tmp !== 'undefined' && tmp !== null)
                this.styleReservedWord = tmp;
            
            tmp = tag1.getAttribute('className');
            if (typeof tmp !== 'undefined' && tmp !== null)
                className = this.ReadWords(tmp);
            tmp = tag1.getAttribute('styleClassName');
            if (typeof tmp !== 'undefined' && tmp !== null)
                this.styleClassName = tmp;
            tmp = tag1.getAttribute('symbolString');
            if (typeof tmp !== 'undefined' && tmp !== null)
                this.symbolString = tmp;
            tmp = tag1.getAttribute('styleString');
            if (typeof tmp !== 'undefined' && tmp !== null)
                this.styleString = tmp;
            tmp = tag1.getAttribute('styleProgramCode');
            if (typeof tmp !== 'undefined' && tmp !== null)
                this.styleProgramCode = tmp;
        }
        
        this.AddNodes(tag2,"\n",'Br');
        
        if (tag2.childNodes.length > 0 && tag2.childNodes[0].nodeType === 1 && (tag2.childNodes[0].nodeName === 'Br' || tag2.childNodes[0].nodeName === 'br'))
            tag2.removeChild(tag2.childNodes[0]);

        if (tag2.childNodes.length > 0 && tag2.childNodes[tag2.childNodes.length - 1].nodeType === 1 && (tag2.childNodes[tag2.childNodes.length - 1].nodeName === 'Br' || tag2.childNodes[tag2.childNodes.length - 1].nodeName === 'br'))
            tag2.removeChild(tag2.childNodes[tag2.childNodes.length - 1]);

        this.AddNodes(tag2,"\t",'SpaceLength','l',this.spaceLength);
        
        this.AddComment(tag2,this.symbolComment,this.styleComment);
        
        this.AddString(tag2,this.symbolString,this.styleString);
        
        if (words.length > 0)
        {
            for (i = 0;i < words.length;i++)
                this.AddWord(tag2,words[i],this.styleReservedWord);
        }
        if (className.length > 0)
        {
            for (i = 0;i < className.length;i++)
                this.AddWord(tag2,className[i],this.styleClassName);
        }
        
        this.AddCodeLine(tag2,this.styleProgramCode);
        
        TParagraph.prototype.ParseXML.call(this,tag1,tag2);
    };
}

TCode.prototype = new TParagraph();


function TTimeOut(){
    var type = 'TTimeOut';
    TTimeOut.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.timeOut = [];
        this.SetTypePageElement('TimeOut');
    };
    this.InitConstructor();

    TTimeOut.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TTimeOut'))
        {
            if (typeof _object.timeOut !== 'undefined' && _object.timeOut !== null)
            {
                var i;
                for (i = 0;i < _object.timeOut.lenght;i++)
                    this.timeOut[i] = _object.timeOut[i];
            }
        }
    };

    TTimeOut.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    
    TTimeOut.prototype.ParseXML = function(tag1,tag2){
        var objM = this.GetObjectManager();
        var noLang = this.GetCurrentLanguage();
        if (objM !== null && typeof tag2 !== 'undefined' && tag2 !== null && typeof noLang !== 'undefined' && noLang !== null)
        {
            var i,x = tag2.childNodes,j,attr;
            for (i = 0,j = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Parameters')
                    {
                        attr = x[i].getAttribute('t');
                        if (typeof attr !== 'undefined' && attr !== null && IsInt(attr))
                        {
                            this.timeOut[noLang] = parseInt(attr);
                        }
                    }
                }
            }
        }
    };

    TTimeOut.prototype.GetTimeOut = function(){
        var noLang = this.GetCurrentLanguage();
        if (typeof noLang !== 'undefined' && noLang !== null)
        {
            return this.timeOut[noLang];
        }
        return null;
    };
}

TTimeOut.prototype = new TPageElement();


function TNumberElement(){
    var type = 'TNumberElement';
    TNumberElement.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.elementName = null;
        this.number = [];
        this.numeration = true;
        this.SetTypePageElement('NumberElement');
    };
    this.InitConstructor();

    TNumberElement.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TNumberElement'))
        {
            if (typeof _object.number !== 'undefined' && _object.number !== null)
            {
                var i;
                for (i = 0;i < _object.number.length;i++)
                    this.number[i] = _object.number[i];
            }
            if (typeof _object.elementName !== 'undefined' && _object.elementName !== null && _object.elementName.IsType('TMultilanguageStringData'))
                this.elementName = objM.copy(_object.elementName);
            if (typeof _object.numeration !== 'undefined' && _object.numeration !== null)
                this.numeration = _object.numeration;
        }
    };

    TNumberElement.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    

    TNumberElement.prototype.ChangeCurrentLanguageNumber = function(_language){
        if (typeof this.elementName !== 'undefined' && this.elementName !== null && this.elementName.IsType('TMultilanguageStringData'))
            this.elementName.ChangeCurrentLanguageNumber(_language);
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
    };

    TNumberElement.prototype.Draw = function(_object,levels,_numberFigure){
/*        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var YN = this.GetVisible();
            if (typeof _object.drawObject !== 'undefined' && _object.drawObject !== null && _object.drawObject.GetObjectType() === 'TeX')
                YN = true;
            if (YN)
            {
                _object.Add('Figure','Start');
                if (typeof this.caption !== 'undefined' && this.caption !== null && this.caption.IsType('TFigureElementCaption'))
                {                               
                    if (typeof this.figureName !== 'undefined' && this.figureName !== null && this.figureName.IsType('TMultilanguageStringData'))
                    {                               
                        _object.Add('FigureName',this.figureName.GetStringData());
    //                    txt = _object.FigureCaption(txt,this.figureName.GetStringData(),levels,_numberFigure);
    //                    _object.Figure(txt,'h',this.GetId());
                    }
                    this.caption.Draw(_object);
                }
                _object.Add('Figure','Stop');
            }
        }*/
    };

    TNumberElement.prototype.AddObjectName = function(name,_language){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof name !== 'undefined' && typeof _language !== 'undefined' && _language !== null)
        {
            if (this.elementName === null)
                this.elementName = objM.newObject('TMultilanguageStringData');
            if (this.elementName !== null)
            {
                this.elementName.SetStringData(name,_language);
            }
        }
    };    

    TNumberElement.prototype.AddObjectNameObject = function(object){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof object !== 'undefined' && object !== null && object.IsType('TMultilanguageStringData'))
        {
            this.elementName = objM.copy(object);
        }
    };    

    TNumberElement.prototype.SetNumber = function(_number){
        if (typeof _number !== 'undefined' && _number !== null)
        {
            var i;
            for (i = 0;i < _number.length;i++)
                this.number[i] = _number[i];            
        }
    };    

    TNumberElement.prototype.GetObjectNameString = function(_language){
        if (typeof this.elementName !== 'undefined' && this.elementName !== null && this.elementName.IsType('TMultilanguageStringData'))
        {
            return this.elementName.GetStringData(_language);
        }
        return null;
    };    

    TNumberElement.prototype.GetNumber = function(){
        var tmp = [];
        if (typeof this.number !== 'undefined' && this.number !== null)
        {
            var i;
            for (i = 0;i < this.number.length;i++)
                tmp[i] = this.number[i];            
        }
        return tmp;
    };    

    TNumberElement.prototype.SetNumeration = function(numeration_){
        if (typeof numeration_ !== 'undefined' && numeration_ !== null)
            this.numeration = numeration_;
    };    

    TNumberElement.prototype.GetNumeration = function(){
        return this.numeration;
    };    

    TNumberElement.prototype.ReadXML = function(tag,fun){
        TPageElement.prototype.ReadXML.call(this,tag,fun);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('numeration');
            if (attr !== 'undefined' && attr !== null)
            {
                if (attr === 'no' || attr === 'No')
                    this.SetNumeration(false);
                else
                    this.SetNumeration(true);
            }
                

        }
    };


}

TNumberElement.prototype = new TPageElement();



function TCell(){
    var type = 'TCell';
    TCell.prototype.InitConstructor = function(){
        TObjectMultilanguage.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.paragraphs = [];
        this.typeCell = null;
        this.htmlWidth = null;
        this.htmlFontSize = null;
        this.rowSpan = 0;
        this.colSpan = 0;
        this.colourCell = null;
        this.colourFont = null;
        this.id = null;
        this.classStyle = null;
        this.variables = null;
    };
    this.InitConstructor();

    TCell.prototype.Init = function(_object){
        TObjectMultilanguage.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TCell'))
        {
            var i;
            if (typeof _object.paragraphs !== 'undefined' && _object.paragraphs !== null)
            {
                for (i = 0;i < _object.paragraphs.length;i++)
                {
                    if (typeof _object.paragraphs[i] !== 'undefined' && _object.paragraphs[i] !== null)
                    {
                        this.paragraphs[i] = objM.copy(_object.paragraphs[i]);
                    }else
                        this.paragraphs[i] = null;
                }
            }
            if (typeof _object.typeCell !== 'undefined' && _object.typeCell !== null)
            {
                this.typeCell = new String(_object.typeCell);
                this.typeCell = this.typeCell.toString();
            }
            if (typeof _object.htmlWidth !== 'undefined' && _object.htmlWidth !== null)
            {
                this.htmlWidth = new String(_object.htmlWidth);
                this.htmlWidth = this.htmlWidth.toString();
            }
            if (typeof _object.htmlFontSize !== 'undefined' && _object.htmlFontSize !== null)
            {
                this.htmlFontSize = new String(_object.htmlFontSize);
                this.htmlFontSize = this.htmlFontSize.toString();
            }
            if (typeof _object.id !== 'undefined' && _object.id !== null)
            {
                this.id = new String(_object.id);
                this.id = this.id.toString();
            }
            if (typeof _object.classStyle !== 'undefined' && _object.classStyle !== null)
            {
                this.classStyle = new String(_object.classStyle);
                this.classStyle = this.classStyle.toString();
            }
            if (typeof _object.rowSpan !== 'undefined' && _object.rowSpan !== null)
                this.rowSpan = _object.rowSpan;
            if (typeof _object.colSpan !== 'undefined' && _object.colSpan !== null)
                this.colSpan = _object.colSpan;
            if (typeof _object.colourCell !== 'undefined' && _object.colourCell !== null && _object.colourCell.IsType('TColourTXT'))
                this.colourCell = objM.copy(_object.colourCell);
            if (typeof _object.colourFont !== 'undefined' && _object.colourFont !== null && _object.colourFont.IsType('TColourTXT'))
                this.colourFont = objM.copy(_object.colourFont);
            if (typeof _object.variables !== 'undefined' && _object.variables !== null && _object.variables.IsType('TVariables'))
                this.variables = objM.copy(_object.variables);
/*            if (typeof _object.title !== 'undefined' && _object.title !== null && _object.title.IsType('TMultilanguageStringData'))
                this.title = objM.copy(_object.title);
            if (typeof _object.shortHeading !== 'undefined' && _object.shortHeading !== null && _object.shortHeading.IsType('TMultilanguageStringData'))
                this.shortHeading = objM.copy(_object.shortHeading);
            if (typeof _object.level !== 'undefined' && _object.level !== null && IsInt(_object.level))
                this.level = _object.level;*/
        }
    };

    TCell.prototype.InitConstructor2 = function(){
        TObjectMultilanguage.prototype.InitConstructor2.call(this);
        var objM = this.GetObjectManager();
        if (objM !== null)
            this.variables = objM.newObject('TVariables');
    };

    TCell.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectMultilanguage.prototype.IsType.call(this,_type);
    };

    TCell.prototype.ReadXMLInit = function(tag){
        if (typeof tag !== 'undefined' && tag !== null)
        {
            this.id = tag.getAttribute('id');
            this.classStyle = tag.getAttribute('style');
        }
    };


    TCell.prototype.ReadXML = function(tag,fun){
        var objM = this.GetObjectManager();        
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var tmp2 = tag.nodeName.toLowerCase();
            if (typeof tmp2 !== 'undefined' && tmp2 !== null)
                this.typeCell = tmp2;
            
            this.ReadXMLInit(tag);
            
            this.htmlWidth = tag.getAttribute('htmlWidth');
            this.htmlFontSize = tag.getAttribute('htmlFontSize');
            this.rowSpan = tag.getAttribute('rowSpan');
            if (typeof this.rowSpan !== 'undefined' && this.rowSpan !== null)
            {
                this.rowSpan = parseInt(this.rowSpan);
                if (typeof this.rowSpan === 'undefined' || this.rowSpan === null || this.rowSpan < 1)
                    this.rowSpan = 0;
            }else
                this.rowSpan = 0;
            this.colSpan = tag.getAttribute('colSpan');
            if (typeof this.colSpan !== 'undefined' && this.colSpan !== null)
            {
                this.colSpan = parseInt(this.colSpan);
                if (typeof this.colSpan === 'undefined' || this.colSpan === null || this.colSpan < 1)
                    this.colSpan = 0;
            }else
                this.colSpan = 0;
            var br = tag.getAttribute('br');
            var bg = tag.getAttribute('bg');
            var bb = tag.getAttribute('bb');
            var ba = tag.getAttribute('ba');
            
            if (typeof br !== 'undefined' && br !== null && typeof bg !== 'undefined' && bg !== null && typeof bb !== 'undefined' && bb !== null)
            {
                if (typeof ba === 'undefined' || ba === null)
                    ba = "1";
                this.colourCell = objM.newObject('TColourTXT');
                if (this.colourCell !== null)
                {
                    this.colourCell.SetRGBA(br,bg,bb,ba);
                }
            }
            
            var r = tag.getAttribute('r');
            var g = tag.getAttribute('g');
            var b = tag.getAttribute('b');
            var a = tag.getAttribute('a');
            
            if (typeof r !== 'undefined' && r !== null && typeof g !== 'undefined' && g !== null && typeof b !== 'undefined' && b !== null)
            {
                r = parseFloat(r);
                g = parseFloat(g);
                b = parseFloat(b);
                if (typeof a !== 'undefined' && a !== null)
                    a = parseFloat(a);
                if (typeof a === 'undefined' || a === null)
                    a = 1;
                if (typeof r !== 'undefined' && r !== null && typeof g !== 'undefined' && g !== null && typeof b !== 'undefined' && b !== null)
                {
                    this.colourFont = objM.newObject('TColourTXT');
                    if (this.colourFont !== null)
                    {
                        this.colourFont.SetRGBA(r,g,b,a);
                    }
                }
                
            }
            
            
            var i,x = tag.childNodes,ii,attr,obj;
            for (i = 0,ii = -1;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if (x[i].nodeName.toLowerCase() === 'element')
                    {
                        attr = x[i].getAttribute('type');
                        if (typeof attr !== 'undefined' && attr !== null)
                        {
                            if (typeof this.paragraphs[ii+1] === 'undefined' || this.paragraphs[ii+1] === null)
                                obj = objM.newObject('T'+attr);
                            else
                                obj = this.paragraphs[ii+1];
                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                            {
                                ii = ii + 1;
                                obj.SetVariables(this.GetVariables());
                                obj.ReadXML(x[i],tag);
                                this.paragraphs[ii] = obj;
                            }else
                                this.paragraphs[ii] = null;
                        }
                    }
                }
            }
        }
    };

    
    TCell.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {    
            var i;
            if (this.typeCell !== null)
            {
                var tmp = [];
                tmp[0] = this.id;
                tmp[1] = this.classStyle;
                tmp[2] = this.htmlWidth;
                tmp[3] = this.htmlFontSize;
                tmp[4] = this.rowSpan;
                tmp[5] = this.colSpan;
                tmp[6] = this.colourCell;
                tmp[7] = this.colourFont;
                _object.Add(this.typeCell,'Start',tmp);
                if (typeof this.paragraphs !== 'undefined' && this.paragraphs !== null)
                {
                    for (i = 0;i < this.paragraphs.length;i++)
                    {
                        if (typeof this.paragraphs[i] !== 'undefined' && this.paragraphs[i] !== null && this.paragraphs[i].IsType('TPageElement'))
                        {
                            this.paragraphs[i].Draw(_object);
                        }
                    }
                }
                _object.Add(this.typeCell,'Stop');
            }
    
        }        
    };



    TCell.prototype.ChangeCurrentLanguageNumber = function(_language){
        TObjectMultilanguage.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        var i;
        if (typeof this.paragraphs !== 'undefined' && this.paragraphs !== null)
        {
            for (i = 0;i < this.paragraphs.length;i++)
            {
                if (typeof this.paragraphs[i] !== 'undefined' && this.paragraphs[i] !== null && this.paragraphs[i].IsType('TObjectMultilanguage'))
                {
                    this.paragraphs[i].ChangeCurrentLanguageNumber(_language);
                }
            }
        }
    };

/*    TCell.prototype.SetVariables = function(var_){
        var i,j;
        if (this.caption !== null)
            this.caption.SetVariables(var_);
        if (typeof this.cells !== 'undefined' && this.cells !== null)
        {
            for (i = 0;i < this.cells.length;i++)
            {
                if (typeof this.cells[i] !== 'undefined' && this.cells[i] !== null)
                {
                    for (j = 0;j < this.cells[i].length;j++)
                    {
                        if (typeof this.cells[i][j] !== 'undefined' && this.cells[i][j] !== null && this.cells[i][j].IsType('TObjectMultilanguage'))
                        {
                            this.cells[i][j].SetVariables(var_);
                        }
                    }
                }
            }
        }
    };    */

    TCell.prototype.SetVariables = function(var_){
        if (this.variables !== null)
            this.variables.SetVariables(var_);
        var i;
        if (typeof this.paragraphs !== 'undefined' && this.paragraphs !== null)
        {
            for (i = 0;i < this.paragraphs.length;i++)
            {
                if (typeof this.paragraphs[i] !== 'undefined' && this.paragraphs[i] !== null && this.paragraphs[i].IsType('TObjectMultilanguage'))
                {
                    this.paragraphs[i].SetVariables(var_);
                }
            }
        }
    };


    TCell.prototype.GetVariables = function(){
        if (this.variables !== null)
            return this.variables.GetVariables();
        return null;
    };

    TCell.prototype.ActualizeActions = function(){
        if (typeof this.paragraphs !== 'undefined' && this.paragraphs !== null)
        {
            for (i = 0;i < this.paragraphs.length;i++)
            {
                if (typeof this.paragraphs[i] !== 'undefined' && this.paragraphs[i] !== null && this.paragraphs[i].IsType('TPageElement'))
                {
                    this.paragraphs[i].ActualizeActions();
                }
            }
        }
    };

}

TCell.prototype = new TObjectMultilanguage();


function TTable(){
    var type = 'TTable';
    TTable.prototype.InitConstructor = function(){
        TNumberElement.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.cells = [];
        this.htmlWidth = null;
        this.htmlFontSize = null;
        this.SetTypePageElement('Table');
        this.caption = null;
        this.textAlign = null;
        this.headerAlign = null;
        this.lineStyle = null;
        this.positionTeX = 'htbp';
    };
    this.InitConstructor();

    TTable.prototype.Init = function(_object){
        TNumberElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TTable'))
        {
            var i,j;
            if (typeof _object.caption !== 'undefined' && _object.caption !== null && _object.caption.IsType('TFigureElementCaption'))
                this.caption = objM.copy(_object.caption);
            if (typeof _object.cells !== 'undefined' && _object.cells !== null)
            {
                for (i = 0;i < _object.cells.length;i++)
                {
                    this.cells[i] = [];
                    if (typeof _object.cells[i] !== 'undefined' && _object.cells[i] !== null)
                    {
                        for (j = 0;j < _object.cells[i].length;j++)
                        {
                            if (typeof _object.cells[i][j] !== 'undefined' && _object.cells[i][j] !== null)
                            {
                                this.cells[i][j] = objM.copy(_object.cells[i][j]);
                            }else
                                this.cells[i][j] = null;
                        }
                    }
                }
            }
            if (typeof _object.textAlign !== 'undefined' && _object.textAlign !== null)
            {
                this.textAlign = new String(_object.textAlign);
                this.textAlign = this.textAlign.toString();
            }
            if (typeof _object.textAlign !== 'undefined' && _object.textAlign !== null)
            {
                this.headerAlign = new String(_object.headerAlign);
                this.headerAlign = this.headerAlign.toString();
            }
            if (typeof _object.lineStyle !== 'undefined' && _object.lineStyle !== null)
            {
                this.lineStyle = new String(_object.lineStyle);
                this.lineStyle = this.lineStyle.toString();
            }
            if (typeof _object.positionTeX !== 'undefined' && _object.positionTeX !== null)
            {
                this.positionTeX = new String(_object.positionTeX);
                if (this.positionTeX !== null)
                    this.positionTeX = this.positionTeX.toString();
            }
            if (typeof _object.htmlWidth !== 'undefined' && _object.htmlWidth !== null)
            {
                this.htmlWidth = new String(_object.htmlWidth);
                this.htmlWidth = this.htmlWidth.toString();
            }
            if (typeof _object.htmlFontSize !== 'undefined' && _object.htmlFontSize !== null)
            {
                this.htmlFontSize = new String(_object.htmlFontSize);
                this.htmlFontSize = this.htmlFontSize.toString();
            }
        }
    };

    TTable.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TNumberElement.prototype.IsType.call(this,_type);
    };

    TTable.prototype.ReadXML = function(tag,fun){
        TNumberElement.prototype.ReadXML.call(this,tag,fun);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            this.ReadXMLInit(tag);
            this.textAlign = tag.getAttribute('textAlign');
            this.headerAlign = tag.getAttribute('headerAlign');
            this.lineStyle = tag.getAttribute('lineStyle');
            this.htmlWidth = tag.getAttribute('htmlWidth');
            this.htmlFontSize = tag.getAttribute('htmlFontSize');
            var attr = tag.getAttribute('positionTeX');
            this.SetPositionTeX(attr);
            var i,x = tag.childNodes,tmp = null,ii,jj,x2,j;
            for (i = 0,ii = -1,jj = -1,j = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if (x[i].nodeName === 'Caption')
                    {
                        if (this.caption === null)
                            this.caption = objM.newObject('TFigureElementCaption');
                        if (this.caption !== null)
                        {
//                            this.caption.SetVariables(this.GetVariables());
                            this.caption.ReadXML(x[i],fun);
                        }
                    }
                    if (x[i].nodeName.toLowerCase() === 'tr')
                    {
                        ii = ii + 1;
                        jj = -1;
                        if (typeof this.cells[ii] === 'undefined' || this.cells[ii] === null)
                        {
                            this.cells[ii] = [];
                        }
                        x2 = x[i].childNodes;
                        for (j = 0;j < x2.length;j++)
                        {
                            if (x2[j].nodeType === 1)
                            {
                                if (x2[j].nodeName.toLowerCase() === 'th' || x2[j].nodeName.toLowerCase() === 'th2' || x2[j].nodeName.toLowerCase() === 'td')
                                {
                                    jj = jj + 1;
                                    if (typeof this.cells[ii][jj] === 'undefined' || this.cells[ii][jj] === null)
                                        this.cells[ii][jj] = objM.newObject('TCell');
                                    if (this.cells[ii][jj] !== null)
                                    {
                                        this.cells[ii][jj].SetVariables(this.GetVariables());
                                        this.cells[ii][jj].ReadXML(x2[j],fun);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    };

    
    TTable.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var YN = this.GetVisible();
            if (typeof _object.drawObject !== 'undefined' && _object.drawObject !== null && _object.drawObject.GetObjectType() === 'TeX')
                YN = true;
            if (YN)
            {
                var i,j;
                if (typeof this.cells !== 'undefined' && this.cells !== null)
                {
                    var tmp = [],tmp2,maxCol = 0;
                    for (i = 0;i < this.cells.length;i++)
                    {
                        if (typeof this.cells[i] !== 'undefined' && this.cells[i] !== null)
                        {
                            if (maxCol === 0 || maxCol < this.cells[i].length)
                                maxCol = this.cells[i].length;
                        }
                    }

                    
                    tmp[0] = this.GetId();
                    tmp[1] = this.cells.length;
                    tmp[2] = maxCol;
                    tmp[3] = this.GetClassStyle();
                    if (typeof this.caption !== 'undfined' && this.caption !== null)
                        tmp[4] = true;
                    else
                        tmp[4] = false;
                    tmp[5] = this.textAlign;
                    tmp[6] = this.headerAlign;
                    tmp[7] = this.lineStyle;
                    tmp[8] = this.positionTeX;
                    tmp[9] = this.htmlWidth;
                    tmp[10] = this.htmlFontSize;
                    _object.Add('Table','Start',tmp);
                    var name = this.GetObjectNameString();
                    var number = this.GetNumber();
                    for (i = 0;i < this.cells.length;i++)
                    {
                        tmp2 = [];
                        tmp2[0] = null;
                        tmp2[1] = this.cells[i].length;
                        _object.Add('tr','Start',tmp2);
                        if (typeof this.cells[i] !== 'undefined' && this.cells[i] !== null)
                        {
                            for (j = 0;j < this.cells[i].length;j++)
                            {
                                if (typeof this.cells[i][j] !== 'undefined' && this.cells[i][j] !== null && this.cells[i][j].IsType('TCell'))
                                {
                                    this.cells[i][j].Draw(_object);
                                }
                            }
                        }
                        _object.Add('tr','Stop');
                    }
                    if (typeof this.caption !== 'undfined' && this.caption !== null)
                        this.caption.Draw(_object,name,number);
                    _object.Add('Table','Stop');
                }
            }
        }

    };



    TTable.prototype.ChangeCurrentLanguageNumber = function(_language){
        TNumberElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        var i,j;
        if (this.caption !== null)
            this.caption.ChangeCurrentLanguageNumber(_language);
        if (typeof this.cells !== 'undefined' && this.cells !== null)
        {
            for (i = 0;i < this.cells.length;i++)
            {
                if (typeof this.cells[i] !== 'undefined' && this.cells[i] !== null)
                {
                    for (j = 0;j < this.cells[i].length;j++)
                    {
                        if (typeof this.cells[i][j] !== 'undefined' && this.cells[i][j] !== null && this.cells[i][j].IsType('TObjectMultilanguage'))
                        {
                            this.cells[i][j].ChangeCurrentLanguageNumber(_language);
                        }
                    }
                }
            }
        }
    };

/*    TTable.prototype.ParseXML = function(tag1,tag2){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag2 !== 'undefined' && tag2 !== null)
        {
            var i,x = tag2.childNodes,x2;
            for (i = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Title')
                    {
                        x2 = x[i].childNodes;
                        if (this.title === null)
                            this.title = objM.newObject('TMultilanguageStringData');
                        if (this.title !== null)
                        {
                            this.title.SetStringData(x2[0].nodeValue);
                        }
                    }
                    if(x[i].nodeName === 'ShortHeading')
                    {
                        x2 = x[i].childNodes;
                        if (this.shortHeading === null)
                            this.shortHeading = objM.newObject('TMultilanguageStringData');
                        if (this.shortHeading !== null)
                        {
                            this.shortHeading.SetStringData(x2[0].nodeValue);
                        }
                    }
                }
            }
        }
        if (typeof tag1 !== 'undefined' && tag1 !== null)
        {
            var tmp = tag1.getAttribute('level');
            tmp = parseInt(tmp);
            if (tmp !== null && IsInt(tmp))
                this.level = tmp;
        }
        
    };*/

    TTable.prototype.SetPositionTeX = function(pos){
        if (typeof pos !== 'undefined' && pos !== null)
        {
            this.positionTeX = new String(pos);
            if (this.positionTeX !== null)
                this.positionTeX = this.positionTeX.toString();
        }
    };

    TTable.prototype.SetVariables = function(var_){
        TNumberElement.prototype.SetVariables.call(this,var_);
        var i,j;
//        if (this.caption !== null)
//            this.caption.SetVariables(var_);
        if (typeof this.cells !== 'undefined' && this.cells !== null)
        {
            for (i = 0;i < this.cells.length;i++)
            {
                if (typeof this.cells[i] !== 'undefined' && this.cells[i] !== null)
                {
                    for (j = 0;j < this.cells[i].length;j++)
                    {
                        if (typeof this.cells[i][j] !== 'undefined' && this.cells[i][j] !== null && this.cells[i][j].IsType('TObjectMultilanguage'))
                        {
                            this.cells[i][j].SetVariables(var_);
                        }
                    }
                }
            }
        }
    };    

    TTable.prototype.ActualizeActions = function(){
        TNumberElement.prototype.ActualizeActions.call(this);
        if (typeof this.cells !== 'undefined' && this.cells !== null)
        {
            var i;
            for (i = 0;i < this.cells.length;i++)
            {
                if (typeof this.cells[i] !== 'undefined' && this.cells[i] !== null)
                {
                    for (j = 0;j < this.cells[i].length;j++)
                    {
                        if (typeof this.cells[i][j] !== 'undefined' && this.cells[i][j] !== null && this.cells[i][j].IsType('TCell'))
                        {
                            this.cells[i][j].ActualizeActions();
                        }
                    }
                }
            }
        }
    };

}

TTable.prototype = new TNumberElement();

function TEquationElement(){
    var type = 'TEquationElement';
    TEquationElement.prototype.InitConstructor = function(){
        TMultilanguageStringData.prototype.InitConstructor.call(this);
        this.SetType(type);            
    };
    this.InitConstructor();

    TEquationElement.prototype.Init = function(_object){
        TMultilanguageStringData.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TEquationElement'))
        {
        }
    };

    TEquationElement.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TMultilanguageStringData.prototype.IsType.call(this,_type);
    };

    TEquationElement.prototype.Refresh = function(){
    };

}

TEquationElement.prototype = new TMultilanguageStringData();

function TEquationTextElement(){
    var type = 'TEquationTextElement';
    TEquationTextElement.prototype.InitConstructor = function(){
        TEquationElement.prototype.InitConstructor.call(this);
        this.text = null;
        this.variables = null;
        this.SetType(type);            
    };
    this.InitConstructor();

    TEquationTextElement.prototype.InitConstructor2 = function(){
        TEquationElement.prototype.InitConstructor2.call(this);
        var objM = this.GetObjectManager();
        if (objM !== null)
            this.variables = objM.newObject('TVariables');
    };

    TEquationTextElement.prototype.Init = function(_object){
        TEquationElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TEquationTextElement'))
        {
            if (typeof _object.text !== 'undefined' && _object.text !== null && _object.text.IsType('TParagraphText'))
                this.text = objM.copy(_object.text);
            if (typeof _object.variables !== 'undefined' && _object.variables !== null && _object.variables.IsType('TVariables'))
                this.variables = objM.copy(_object.variables);
        }
    };

    TEquationTextElement.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TEquationElement.prototype.IsType.call(this,_type);
    };
    
    TEquationTextElement.prototype.ParseXML = function(tag){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            if (this.text === null)
                this.text = objM.newObject('TParagraphText');
            if (this.text !== null)
            {
                this.text.SetVariables(this.variables.GetVariables());
                this.text.ParseXML(tag);
            }
        }
    };

    TEquationTextElement.prototype.GetTextObject = function(){
        return this.text;
    };
    
    TEquationTextElement.prototype.SetVariables = function(var_){
        if (this.variables !== null)
            this.variables.SetVariables(var_);
        if (this.text !== null)
            this.text.SetVariables(var_);
    };

    TEquationTextElement.prototype.GetStringData = function(_language){
        if (this.text !== null)
        {
            return this.text.GetText();
        }
        return '';
    };
    
    TEquationTextElement.prototype.Refresh = function(){
        TEquationElement.prototype.Refresh.call(this);
        
/*        var tmp = this.GetId();
        if (tmp !== null)
        {
            var tmp2 = document.getElementById(tmp);
            if (typeof tmp2 !== 'undefined' && tmp2 !== null)
            {
                if (typeof this.variable !== 'undefined' && this.variable !== null && this.variable.IsType('TVariable'))
                     this.variable.SetValue(this.CalculateValue(this.variable.GetName()));
                tmp2.innerHTML = this.variable.GetValue();
            }
        }*/
    };
    
    
}

TEquationTextElement.prototype = new TEquationElement();


function TEquation(){
    var type = 'TEquation';
    TEquation.prototype.InitConstructor = function(){
        TNumberElement.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.equation = [];
        this.SetTypePageElement('Equation');
    };
    this.InitConstructor();

    TEquation.prototype.Init = function(_object){
        TNumberElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TEquation'))
        {
            var i;
            if (typeof _object.equation !== 'undefined' && _object.equation !== null)
            {
                for (i = 0;i < _object.equation.length;i++)
                    this.equation[i] = objM.copy(_object.equation[i]);
            }
        }
    };

    TEquation.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TNumberElement.prototype.IsType.call(this,_type);
    };
    
    TEquation.prototype.GetTXT = function(){
        var i,txt;
        if (typeof this.equation !== 'undefined' && this.equation !== null && this.equation.length > 0)
        {
            txt = this.equation[0].GetStringData();
            for (i = 1;i < this.equation.length;i++)
                txt = txt + ' ' +  this.equation[i].GetStringData();
            return txt;
        }
        return null;
    };
    
    TEquation.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var YN = this.GetVisible();
            if (typeof _object.drawObject !== 'undefined' && _object.drawObject !== null && _object.drawObject.GetObjectType() === 'TeX')
                YN = true;
            if (YN)
            {
                var tmp = [],i,tmp2 = [];
                tmp[0] = this.GetId();
                tmp[1] = this.GetNumber();
                _object.Add('Equation','Start',tmp);
                for (i = 0;i < this.equation.length;i++)
                    _object.Add('SubEquation',this.equation[i].GetStringData());
                _object.Add('Equation','Stop');
                
            }
        }
//        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
//        {
//            _object.Equation(this.GetTXT());
//        }        
    };

    TEquation.prototype.ChangeCurrentLanguageNumber = function(_language){
        TNumberElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        var i;
        if (typeof this.equation !== 'undefined' && this.equation !== null)
        {
            for (i = 0;i < this.equation.length;i++)
                this.equation[i].ChangeCurrentLanguageNumber(_language);
        }
    };

    TEquation.prototype.ParseXML = function(tag1,tag2){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag2 !== 'undefined' && tag2 !== null)
        {
            var i,x = tag2.childNodes,x2,j;
            for (i = 0,j = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'E')
                    {
                        x2 = x[i].childNodes;
                        if (j >= this.equation.length || this.equation[j] === null)
                            this.equation[j] = objM.newObject('TEquationElement');
                        if (this.equation[j] !== null)
                        {
                            this.equation[j].SetStringData(x2[0].nodeValue);
                        }
                        j++;
                    }
                    if(x[i].nodeName === 'T')
                    {
                        if (j >= this.equation.length || this.equation[j] === null)
                            this.equation[j] = objM.newObject('TEquationTextElement');
                        if (this.equation[j] !== null)
                        {
                            this.equation[j].SetVariables(this.GetVariables());
                            this.equation[j].ParseXML(x[i]);
                        }
                        j++;
                    }
                }
            }
        }
    };

    TEquation.prototype.Refresh = function(){
        TNumberElement.prototype.Refresh.call(this);
        var i;
        if (typeof this.equation !== 'undefined' && this.equation !== null && this.equation.length > 0)
        {
            for (i = 0;i < this.equation.length;i++)
                if (this.equation[i] !== null)
                    this.equation[i].Refresh();
        }
        var id  = this.GetId();
        if (id !== null)
        {
            var math = MathJax.Hub.getAllJax(id)[0];
            if (typeof math !== 'undefined' && math !== null)
            {
                MathJax.Hub.Queue(["Text",math,this.GetTXT()]);
            }
        }
    };

}

TEquation.prototype = new TNumberElement();


function TFigureElement(){
    var type = 'TFigureElement';
    TFigureElement.prototype.InitConstructor = function(){
        TObjectMultilanguage.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TFigureElement.prototype.Init = function(_object){
        TObjectMultilanguage.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TFigureElement'))
        {
        }
    };

    TFigureElement.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectMultilanguage.prototype.IsType.call(this,_type);
    };
    
    TFigureElement.prototype.ReadXML = function(tag,fun){
    };

    TFigureElement.prototype.Draw = function(_object,txt){
        return txt;
    };

    TFigureElement.prototype.ChangeCurrentLanguageNumber = function(_language){
    };

    TFigureElement.prototype.ParseXML = function(tag1,tag2){
        
    };

    TFigureElement.prototype.Draw = function(_object){
        return '';
    };
}

TFigureElement.prototype = new TObjectMultilanguage();

function TFigureElementCaption(){
    var type = 'TFigureElementCaption';
    TFigureElementCaption.prototype.InitConstructor = function(){
        TFigureElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.paragraph = null;
    };
    this.InitConstructor();

    TFigureElementCaption.prototype.Init = function(_object){
        TFigureElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TFigureElementCaption'))
        {
            if (typeof _object.paragraph !== 'undefined' && _object.paragraph !== null && _object.paragraph.IsType('TParagraph'))
            {
                this.paragraph = _object.paragraph ;
            }
        }
    };

    TFigureElementCaption.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TFigureElement.prototype.IsType.call(this,_type);
    };
    
    TFigureElementCaption.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        var i;
        if (typeof this.paragraph !== 'undefined' && this.paragraph !== null && this.paragraph.IsType('TObjectMultilanguage'))
        {
            this.paragraph.ChangeCurrentLanguageNumber(_language);
        }
    };

    TFigureElementCaption.prototype.ReadXML = function(tag,fun){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var i,tag2,tag2_ = tag.childNodes;//FindTags(tag.getElementsByTagName("Element"));
            if (tag2_ !== null)
            {
                for (i = 0;i < tag2_.length;i++)
                {
                    tag2 = tag2_[i];
                    if (tag2 !== null && tag2.nodeType === 1 && tag2.nodeName === 'Element')
                    {
                        var attr = tag2.getAttribute('type');
                        if(attr === 'Paragraph')
                        {
                            obj = this.paragraph;
                            if (typeof obj=== 'undefined' || obj === null)
                            {
                                var obj = objM.newObject('T'+attr);
                                if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                                {
                                    this.paragraph = obj;
                                }
                            }
                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                            {
                                obj.ReadXML(tag2,fun);
                            }
                        }
                    }
                }
            }

        }
    };


    TFigureElementCaption.prototype.Draw = function(_object,figureName,number){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.paragraph !== 'undefined' && this.paragraph !== null && this.paragraph.IsType('TParagraph'))
            {
                var tmp = [];
                if (typeof number !== 'undefined' && number !== null && number.length > 0)
                    tmp[0] = true;
                else
                    tmp[0] = false;
                _object.Add('FigureCaption','Start',tmp);
                if (typeof figureName !== 'undefined' && figureName !== null)
                {
                    if (typeof number !== 'undefined' && number !== null && number.length > 0)
                    {
                        _object.Add('FigureName',figureName,number);
                    }else
                        _object.Add('FigureName',figureName);
                }
                this.paragraph.Draw(_object);
                _object.Add('FigureCaption','Stop');
            }
        }
    };

    TFigureElementCaption.prototype.ActualizeId = function(_pageElements){
        if(typeof this.paragraph !== 'undefined' && this.paragraph !== null)
        {
            this.paragraph.ActualizeId(_pageElements);
        }
//        TFigureElement.prototype.ActualizeId.call(this,_pageElements);
    };

}

TFigureElementCaption.prototype = new TFigureElement();


function TImageBitmap(){
    var type = 'TImageBitmap';
    TImageBitmap.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.fileName = null;
        this.width = 0;
        this.height = 0;
    };
    this.InitConstructor();

    TImageBitmap.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TImageBitmap'))
        {
            if (typeof _object.fileName !== 'undefined' && _object.fileName !== null && _object.fileName.IsType('TImageFileName'))
            {
                this.fileName = _object.fileName;
            }
            if (typeof _object.width !== 'undefined' && _object.width !== null && IsInt(_object.width))
                this.width = _object.width;
            if (typeof _object.height !== 'undefined' && _object.height !== null && IsInt(_object.height))
                this.height = _object.height;
        }
    };

    TImageBitmap.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    
   TImageBitmap.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        var i;
        if (typeof this.fileName !== 'undefined' && this.fileName !== null && this.fileName.IsType('TObjectMultilanguage'))
        {
            this.fileName.ChangeCurrentLanguageNumber(_language);
        }
    };

    TImageBitmap.prototype.ReadXML = function(tag,fun){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var i,tag2,tag2_ = tag.childNodes,obj;//FindTags(tag.getElementsByTagName("Element"));
            var attr = tag.getAttribute('width');
            this.ReadXMLInit(tag);
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseInt(attr);
                if (attr !== null && IsInt(attr))
                    this.width = attr;
            }
            var attr = tag.getAttribute('height');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseInt(attr);
                if (attr !== null && IsInt(attr))
                    this.height = attr;
            }
            if (tag2_ !== null)
            {
                for (i = 0;i < tag2_.length;i++)
                {
                    tag2 = tag2_[i];
                    if (tag2 !== null && tag2.nodeType === 1)
                    {
                        if (tag2.nodeName === 'ImageFileName')
                        {
                            obj = this.fileName;
                            if (typeof obj === 'undefined' || obj === null)
                            {
                                obj = objM.newObject('TImageFileName');
                                if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TImageFileName'))
                                    this.fileName = obj;
                            }
                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TImageFileName'))
                            {
                                obj.ReadXML(tag2);
                            }
                        }
                    }
                }
            }

        }
    };


    TImageBitmap.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.fileName !== 'undefined' && this.fileName !== null && this.fileName.IsType('TImageFileName'))
            {
                var tmp2 = [],tmp1,id = this.GetId();
                tmp1 = this.fileName.GetFileNameString();
                tmp2[0] = this.width;
                tmp2[1] = this.height;
                if (id !== null)
                    tmp2[2] = id;
                _object.Add('FigureImageBitmap',tmp1,tmp2);
            }
        }
    };

}

TImageBitmap.prototype = new TPageElement();

function TInteractiveImageBitmap(){
    var type = 'TInteractiveImageBitmap';
    TInteractiveImageBitmap.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.fileNames = [];
        this.width = 0;
        this.height = 0;
        this.noActualImage = 0;
        this.variable = null;
        this.functionKeyPress = null;
        this.variableNoActualImage = null;
        this.variableImage = null;
        this.variableImage2 = null;
        this.clickNextImage = true;
        this.calcFunction = null;
        this.visibleImage = true;
        this.actions = [];
    };
    this.InitConstructor();

    TInteractiveImageBitmap.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TInteractiveImageBitmap'))
        {
            var i;
            if (typeof _object.fileNames !== 'undefined' && _object.fileNames !== null)
            {
                for (i = 0;i < _object.fileNames.length;i++)
                    this.fileNames[i] = objM.copy(_object.fileNames[i]);
            }
            if (typeof _object.width !== 'undefined' && _object.width !== null && IsInt(_object.width))
                this.width = _object.width;
            if (typeof _object.height !== 'undefined' && _object.height !== null && IsInt(_object.height))
                this.height = _object.height;
            if (typeof _object.noActualImage !== 'undefined' && _object.noActualImage !== null && IsInt(_object.noActualImage))
                this.noActualImage = _object.noActualImage;
            if (typeof _object.variable !== 'undefined' && _object.variable !== null && _object.variable.IsType('TVariable'))
                this.variable = _object.variable;
            if (typeof _object.functionKeyPress !== 'undefined' && _object.functionKeyPress !== null)
            {
                this.functionKeyPress = new String(_object.functionKeyPress);
                this.functionKeyPress = this.functionKeyPress.toString();
            }
            if (typeof _object.variableNoActualImage !== 'undefined' && _object.variableNoActualImage !== null)
            {
                this.variableNoActualImage = new String(_object.variableNoActualImage);
                this.variableNoActualImage = this.variableNoActualImage.toString();
            }
            if (typeof _object.variableImage !== 'undefined' && _object.variableImage !== null)
            {
                this.variableImage = new String(_object.variableImage);
                this.variableImage = this.variableImage.toString();
            }
            if (typeof _object.variableImage2 !== 'undefined' && _object.variableImage2 !== null)
            {
                this.variableImage2 = new String(_object.variableImage2);
                this.variableImage2 = this.variableImage2.toString();
            }
            if (typeof _object.clickNextImage !== 'undefined' && _object.clickNextImage !== null)
                this.clickNextImage = _object.clickNextImage;
            if (typeof _object.calcFunction !== 'undefined' && _object.calcFunction !== null)
            {
                this.calcFunction = new String(_object.calcFunction);
                this.calcFunction = this.calcFunction.toString();
            }
            if (typeof _object.visibleImage !== 'undefined' && _object.visibleImage !== null)
                this.visibleImage = _object.visibleImage;
            if (typeof _object.actions !== 'undefined' && _object.actions !== null )
            {
                this.actions = [];
                for (i = 0;i < _object.actions.length;i++)
                {
                    if (typeof _object.actions[i] !== 'undefined' && _object.actions[i] !== null && _object.actions[i].IsType('TActionInteractiveImageBitmap'))
                    {
                        this.actions[i] = objM.copy(_object.actions[i]);
                    }
                }
            }
        }
    };

    TInteractiveImageBitmap.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    
   TInteractiveImageBitmap.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        var i;
        if (typeof this.fileNames !== 'undefined' && this.fileNames !== null)
        {
            for (i = 0;i < this.fileNames.length;i++)
                if (typeof this.fileNames[i] !== 'undefined' && this.fileNames[i] !== null && this.fileNames[i].IsType('TObjectMultilanguage'))
                    this.fileNames[i].ChangeCurrentLanguageNumber(_language);
        }
    };

    TInteractiveImageBitmap.prototype.ReadXML = function(tag,fun){
        TPageElement.prototype.ReadXML.call(this,tag,fun);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var i,tag2,tag2_ = tag.childNodes,obj,j;//FindTags(tag.getElementsByTagName("Element"));
            var attr = tag.getAttribute('width');
            this.ReadXMLInit(tag);
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseInt(attr);
                if (attr !== null && IsInt(attr))
                    this.width = attr;
            }
            var attr = tag.getAttribute('height');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseInt(attr);
                if (attr !== null && IsInt(attr))
                    this.height = attr;
            }
            attr = tag.getAttribute('varNoImage');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                this.variableNoActualImage = attr;
                var tmpV = this.FindVariable(attr);
                if (tmpV !== null)
                    tmpV.SetValue(this.noActualImage);
            }
            attr = tag.getAttribute('varImage');
            if (typeof attr !== 'undefined' && attr !== null)
                this.variableImage = attr;
            attr = tag.getAttribute('var2Image');
            if (typeof attr !== 'undefined' && attr !== null)
                this.variableImage2 = attr;
            this.SetFunctionKeyPress(tag.getAttribute('keypress'));
            attr = tag.getAttribute('calcFunction');
            if (typeof attr !== 'undefined' && attr !== null)
                this.calcFunction = attr;
            attr = tag.getAttribute('clickNextImage');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                if (attr === 'No')
                    this.clickNextImage = false;
                else
                    this.clickNextImage = true;
            }
            attr = tag.getAttribute('visibleImage');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                if (attr === 'No')
                    this.visibleImage = false;
                else
                    this.visibleImage = true;
            }
            if (tag2_ !== null)
            {
                for (i = 0,j = 0;i < tag2_.length;i++)
                {
                    tag2 = tag2_[i];
                    if (tag2 !== null && tag2.nodeType === 1)
                    {
                        if (tag2.nodeName === 'ImageFileName')
                        {
                            obj = this.fileNames[j];
                            if (typeof obj === 'undefined' || obj === null)
                            {
                                obj = objM.newObject('TImageFileName');
                                if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TImageFileName'))
                                    this.fileNames[j] = obj;
                            }
                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TImageFileName'))
                            {
                                obj.ReadXML(tag2);
                            }
                            j++;
                        }
                    }
                }
            }
            var x = tag.childNodes,x2,k;
//            this.actions[j] = objM.newObject('TActionEditError');
//            if (this.actions[j] !== null)
//            {
//                this.actions[j].SetId(this.GetId());
//                this.actions[j++].SetObject(this);
//            }
            for (i = 0,j=0,k = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Id')
                    {
                        x2 = x[i].childNodes;
                        attr = x[i].getAttribute('id');
                        if (attr !== null)
                        {
                            if (k === 0)
                                this.actions[j] = objM.newObject('TActionInteractiveImageBitmapRecalculate');
                            if (this.actions[j] !== null)
                            {
                                if (k === 0)
                                    this.actions[j].SetId(this.GetId());
                                this.actions[j].SetId(attr,k++);
                            }
                        }
                    }
                }
            }
            

        }
//TActionInteractiveImageBitmapRecalculate        
    };


    TInteractiveImageBitmap.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (this.noActualImage >= 0 && this.noActualImage < this.fileNames.length)
            {
                if (typeof this.fileNames[this.noActualImage] !== 'undefined' && this.fileNames[this.noActualImage] !== null && this.fileNames[this.noActualImage].IsType('TImageFileName'))
                {
                    var tmp2 = [],tmp1,id = this.GetId();
                    var tmpV = this.FindVariable(this.variableNoActualImage);
                    if (tmpV !== null)
                        this.noActualImage = tmpV.GetValue();
                    tmp1 = this.fileNames[this.noActualImage].GetFileNameString();
                    tmp2[0] = this.width;
                    tmp2[1] = this.height;
                    if (id !== null)
                        tmp2[2] = id;
                    tmp2[3] = this.GetFunctionKeyPress();
                    tmp2[4] = this.visibleImage;
                    tmp2[9] = this;
                    _object.Add('InteractiveImageBitmap',tmp1,tmp2);
                }
            }
        }
    };

    TInteractiveImageBitmap.prototype.SetFunctionKeyPress = function(name_){
        if (typeof name_ !== 'undefined' && name_ !== null)
        {
            this.functionKeyPress = new String(name_);
            this.functionKeyPress = this.functionKeyPress.toString();
        }        
    };

    TInteractiveImageBitmap.prototype.GetFunctionKeyPress = function(){
        if (this.functionKeyPress !== null)
        {
            var tmp = new String(this.functionKeyPress);
            return tmp.toString();
        }
        return null;
    };

    TInteractiveImageBitmap.prototype.NextImage = function(){
        if (this.clickNextImage)
        {
            this.noActualImage++;
            if (this.noActualImage >= this.fileNames.length)
                this.noActualImage = 0;
            var tmpV = this.FindVariable(this.variableNoActualImage);
            if (tmpV !== null)
                tmpV.SetValue(this.noActualImage);
        }
    }

    TInteractiveImageBitmap.prototype.GetFile = function(){
        if (this.fileNames.length > 0)
            return this.fileNames[this.noActualImage];
        else
            return null;
    }

    TInteractiveImageBitmap.prototype.GetVariableImageName = function(){
        if (this.variableImage !== null)
        {
            var tmp = new String(this.variableImage);
            return tmp.toString();
        }
        return null;
    };

    TInteractiveImageBitmap.prototype.GetVariableImage2Name = function(){
        if (this.variableImage2 !== null)
        {
            var tmp = new String(this.variableImage2);
            return tmp.toString();
        }
        return null;
    };

    TInteractiveImageBitmap.prototype.Refresh = function(){
        var tmp = this.GetId();
        if (tmp !== null)
        {
            var tmp2 = document.getElementById(tmp);
            var tmpV = this.FindVariable(this.variableNoActualImage);
            if (tmpV !== null)
            {
                var v = tmpV.GetValue();
                if (this.noActualImage !== v)
                {
                    this.noActualImage = v;
                
                    if (typeof tmp2 !== 'undefined' && tmp2 !== null && tmpV !== null)
                    {
                        var tmp1 = this.fileNames[this.noActualImage].GetFileNameString();
                        tmp2.src = tmp2.imageCatalog + '/' + tmp1;
                        tmp2.newImage = true;
                    }
                }
            }
            if (tmp2.newImage !== true)
            {
                var tmpVar = this.FindVariable(this.variableImage);
                var canvas = document.createElement('canvas');
                canvas.width = tmp2.width;
                canvas.height = tmp2.height;
                var context = canvas.getContext('2d');
//                    context.drawImage(tmp2, 0, 0,canvas.width,canvas.height);
//                    var imgData = context.getImageData(0, 0, canvas.width, canvas.height);
//                    var tab = this.Image2Table(tmpVar.GetTable());
                var tab = tmpVar.GetTable();
                if (this.calcFunction !== null)
                {
                    var txt = 'tab = ' + this.calcFunction + '(tab);';
                    eval(txt);
                }
                imgData = this.Table2Image(tab,context);
                context.putImageData(imgData,0,0);
                tmp2.src = canvas.toDataURL();
            }        
        
        }
    }; 
    
    TInteractiveImageBitmap.prototype.Image2Table = function(img){
        var v = [];
        if (typeof img !== 'undefined' && img !== null && typeof img.data !== 'undefined' && img.data !== null)
        {
            var i,j,k,tmp;
            v = [];
            var w,h;
            w = img.width;                
            h = img.height;
            this.height = h;
            this.width_ = w;
            var n = img.data.length/(this.height*this.width_);
            tmp = n*w;
            for (i = 0;i < h;i++)
            {
                v[i] = [];
                for (j = 0;j < w;j++)
                {
                    v[i][j] = [];
                    for (k = 0;k < n;k++)
                        v[i][j][k] = img.data[k + j*n + i*tmp];
                }
            }
        }
        return v;
    };
    
    TInteractiveImageBitmap.prototype.Table2Image = function(tab,context){
        var imgData = null;
        if (typeof tab !== 'undefined' && tab !== null && typeof context !== 'undefined' && context !== null)
        {
            if (tab.length > 0)
            {
                var i,j,k,tmp;
                imgData=context.createImageData(tab[0].length,tab.length);
                var n = imgData.data.length/(imgData.height*imgData.width);
                tmp = n*imgData.width;
                for (i = 0;i < imgData.height;i++)
                {
                    for (j = 0;j < imgData.width;j++)
                    {
                        for (k = 0;k < n;k++)
                            imgData.data[k + j*n + i*tmp] = tab[i][j][k];
                    }
                }
            }
        }
        return imgData;
    };
    
    TInteractiveImageBitmap.prototype.CalculateImage = function(){
        if (this.calcFunction != null)
        {
            var tmp = this.GetId();
            if (tmp !== null)
            {
                var tmp2 = document.getElementById(tmp);
                if (typeof tmp2.newImage === 'undefined' || tmp2.newImage === null || tmp2.newImage)
                {
//                    tmp2.hidden = true;
                    tmp2.newImage = false;
                    var canvas = document.createElement('canvas');
                    canvas.width = tmp2.width;
                    canvas.height = tmp2.height;
                    var context = canvas.getContext('2d');
//                    var img = document.getElementById("scream");
                    context.drawImage(tmp2, 0, 0,canvas.width,canvas.height);
                    var imgData = context.getImageData(0, 0, canvas.width, canvas.height);
                    var tab = this.Image2Table(imgData);
                    var txt = 'tab = ' + this.calcFunction + '(tab);';
                    eval(txt);
                    imgData = this.Table2Image(tab,context);
                    context.putImageData(imgData,0,0);
                    tmp2.src = canvas.toDataURL();
                }
            }
        }
    }; 

    TInteractiveImageBitmap.prototype.GetClickNextImage = function(){
        return this.clickNextImage;
    };
    
}

TInteractiveImageBitmap.prototype = new TPageElement();


function TVideo(){
    var type = 'TVideo';
    TVideo.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.fileName = null;
        this.width = 0;
        this.height = 0;
        this.autoplay = false;
        this.controls = true;
        this.loop = false;
		this.muted = false;	
    };
    this.InitConstructor();

    TVideo.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TVideo'))
        {
            if (typeof _object.fileName !== 'undefined' && _object.fileName !== null && _object.fileName.IsType('TVideoFileName'))
            {
                this.fileName = _object.fileName;
            }
            if (typeof _object.width !== 'undefined' && _object.width !== null && IsInt(_object.width))
                this.width = _object.width;
            if (typeof _object.height !== 'undefined' && _object.height !== null && IsInt(_object.height))
                this.height = _object.height;
            if (typeof _object.autoplay !== 'undefined' && _object.autoplay !== null)
                this.autoplay = _object.autoplay;
            if (typeof _object.controls !== 'undefined' && _object.controls !== null)
                this.controls = _object.controls;
            if (typeof _object.loop !== 'undefined' && _object.loop !== null)
                this.loop = _object.loop;
            if (typeof _object.mute !== 'undefined' && _object.mute !== null)
                this.mute = _object.mute;        }
    };

    TVideo.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    
   TVideo.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        var i;
        if (typeof this.fileName !== 'undefined' && this.fileName !== null && this.fileName.IsType('TObjectMultilanguage'))
        {
            this.fileName.ChangeCurrentLanguageNumber(_language);
        }
    };

    TVideo.prototype.ReadXML = function(tag,fun){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var i,tag2,tag2_ = tag.childNodes,obj;//FindTags(tag.getElementsByTagName("Element"));
            var attr = tag.getAttribute('width');
            this.ReadXMLInit(tag);
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseInt(attr);
                if (attr !== null && IsInt(attr))
                    this.width = attr;
            }
            var attr = tag.getAttribute('height');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseInt(attr);
                if (attr !== null && IsInt(attr))
                    this.height = attr;
            }
            var attr = tag.getAttribute('autoplay');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                if (attr === 'Yes' || attr ==='yes')
                    this.autoplay = true;
                else
                    this.autoplay = false;
            }
            var attr = tag.getAttribute('controls');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                if (attr === 'No' || attr ==='no')
                    this.controls = false;
                else
                    this.controls = true;
            }
            var attr = tag.getAttribute('loop');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                if (attr === 'No' || attr ==='no')
                    this.loop = false;
                else
                    this.loop = true;
            }
            var attr = tag.getAttribute('mute');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                if (attr === 'No' || attr ==='no')
                    this.mute = false;
                else
                    this.mute = true;
            }
            if (tag2_ !== null)
            {
                for (i = 0;i < tag2_.length;i++)
                {
                    tag2 = tag2_[i];
                    if (tag2 !== null && tag2.nodeType === 1)
                    {
                        if (tag2.nodeName === 'VideoFileName')
                        {
                            obj = this.fileName;
                            if (typeof obj === 'undefined' || obj === null)
                            {
                                obj = objM.newObject('TVideoFileName');
                                if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TVideoFileName'))
                                    this.fileName = obj;
                            }
                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TVideoFileName'))
                            {
                                obj.ReadXML(tag2);
                            }
                        }
                    }
                }
            }

        }
    };


    TVideo.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.fileName !== 'undefined' && this.fileName !== null && this.fileName.IsType('TVideoFileName'))
            {
                var tmp2 = [],tmp1,id = this.GetId(),style=this.GetClassStyle();
                tmp1 = this.fileName.GetFileNameString();
                tmp2[0] = this.width;
                tmp2[1] = this.height;
                if (id !== null)
                    tmp2[2] = id;
                else
                    tmp2[2] = null;
                tmp2[3] = this.fileName.GetVideoType();
                tmp2[4] = this.autoplay;
                tmp2[5] = this.controls;
                if (style !== null)
                    tmp2[6] = style;
                else
                    tmp2[6] = null;
                tmp2[7] = this.loop;
                tmp2[8] = this.mute;
                _object.Add('FigureVideo',tmp1,tmp2);
            }
        }
    };
    
    TVideo.prototype.GetVideoAutoPlay = function(){
        return this.autoplay;
    };    

}

TVideo.prototype = new TPageElement();

function TYouTubeVideo(){
    var type = 'TYouTubeVideo';
    TYouTubeVideo.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.fileName = null;
        this.width = 0;
        this.height = 0;
        this.startVideo = 0;
        this.autoplay = false;
        this.controls = true;
        this.loop = false;
		this.mute = false;
    };
    this.InitConstructor();

    TYouTubeVideo.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TYouTubeVideo'))
        {
            if (typeof _object.fileName !== 'undefined' && _object.fileName !== null && _object.fileName.IsType('TVideoFileName'))
            {
                this.fileName = _object.fileName;
            }
            if (typeof _object.width !== 'undefined' && _object.width !== null && IsInt(_object.width))
                this.width = _object.width;
            if (typeof _object.height !== 'undefined' && _object.height !== null && IsInt(_object.height))
                this.height = _object.height;
            if (typeof _object.startVideo !== 'undefined' && _object.startVideo !== null && IsInt(_object.startVideo))
                this.startVideo = _object.startVideo;
            if (typeof _object.autoplay !== 'undefined' && _object.autoplay !== null)
                this.autoplay = _object.autoplay;
            if (typeof _object.controls !== 'undefined' && _object.controls !== null)
                this.controls = _object.controls;
            if (typeof _object.loop !== 'undefined' && _object.loop !== null)
                this.loop = _object.loop;
            if (typeof _object.mute !== 'undefined' && _object.mute !== null)
                this.mute = _object.mute;
        }
    };

    TYouTubeVideo.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    
   TYouTubeVideo.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        var i;
        if (typeof this.fileName !== 'undefined' && this.fileName !== null && this.fileName.IsType('TObjectMultilanguage'))
        {
            this.fileName.ChangeCurrentLanguageNumber(_language);
        }
    };

    TYouTubeVideo.prototype.ReadXML = function(tag,fun){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var i,tag2,tag2_ = tag.childNodes,obj;//FindTags(tag.getElementsByTagName("Element"));
            var attr = tag.getAttribute('width');
            this.ReadXMLInit(tag);
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseInt(attr);
                if (attr !== null && IsInt(attr))
                    this.width = attr;
            }
            var attr = tag.getAttribute('height');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseInt(attr);
                if (attr !== null && IsInt(attr))
                    this.height = attr;
            }
            var attr = tag.getAttribute('start');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseInt(attr);
                if (attr !== null && IsInt(attr))
                    this.startVideo = attr;
            }
            var attr = tag.getAttribute('autoplay');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                if (attr === 'Yes' || attr ==='yes')
                    this.autoplay = true;
                else
                    this.autoplay = false;
            }
            var mute = tag.getAttribute('mute');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                if (attr === 'Yes' || attr ==='yes')
                    this.mute = true;
                else
                    this.mute = false;
            }
            var attr = tag.getAttribute('controls');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                if (attr === 'No' || attr ==='no')
                    this.controls = false;
                else
                    this.controls = true;
            }
            var attr = tag.getAttribute('loop');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                if (attr === 'No' || attr ==='no')
                    this.loop = false;
                else
                    this.loop = true;
            }
            if (tag2_ !== null)
            {
                for (i = 0;i < tag2_.length;i++)
                {
                    tag2 = tag2_[i];
                    if (tag2 !== null && tag2.nodeType === 1)
                    {
                        if (tag2.nodeName === 'VideoFileName')
                        {
                            obj = this.fileName;
                            if (typeof obj === 'undefined' || obj === null)
                            {
                                obj = objM.newObject('TVideoFileName');
                                if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TVideoFileName'))
                                    this.fileName = obj;
                            }
                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TVideoFileName'))
                            {
                                obj.ReadXML(tag2);
                            }
                        }
                    }
                }
            }

        }
    };


    TYouTubeVideo.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.fileName !== 'undefined' && this.fileName !== null && this.fileName.IsType('TVideoFileName'))
            {
                var tmp2 = [],tmp1,id = this.GetId(),style=this.GetClassStyle();
                tmp1 = this.fileName.GetFileNameString();
                tmp2[0] = this.width;
                tmp2[1] = this.height;
                if (id !== null)
                    tmp2[2] = id;
                else
                    tmp2[2] = null;
                tmp2[3] = this.mute;
                tmp2[4] = this.autoplay;
                tmp2[5] = this.controls;
                if (style !== null)
                    tmp2[6] = style;
                else
                    tmp2[6] = null;
                tmp2[7] = this.loop;
                tmp2[8] = this.startVideo;
                _object.Add('FigureYouTubeVideo',tmp1,tmp2);
            }
        }
    };
    
    TYouTubeVideo.prototype.GetVideoAutoPlay = function(){
        return this.autoplay;
    };    

}

TYouTubeVideo.prototype = new TPageElement();

function TGoogleMaps(){
    var type = 'TGoogleMaps';
    TGoogleMaps.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.fileName = null;
        this.width = 0;
        this.height = 0;
    };
    this.InitConstructor();

    TGoogleMaps.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TGoogleMaps'))
        {
            if (typeof _object.fileName !== 'undefined' && _object.fileName !== null && _object.fileName.IsType('TFileName'))
            {
                this.fileName = _object.fileName;
            }
            if (typeof _object.width !== 'undefined' && _object.width !== null && IsInt(_object.width))
                this.width = _object.width;
            if (typeof _object.height !== 'undefined' && _object.height !== null && IsInt(_object.height))
                this.height = _object.height;
        }
    };

    TGoogleMaps.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    
   TGoogleMaps.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        var i;
        if (typeof this.fileName !== 'undefined' && this.fileName !== null && this.fileName.IsType('TObjectMultilanguage'))
        {
            this.fileName.ChangeCurrentLanguageNumber(_language);
        }
    };

    TGoogleMaps.prototype.ReadXML = function(tag,fun){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var i,tag2,tag2_ = tag.childNodes,obj;//FindTags(tag.getElementsByTagName("Element"));
            var attr = tag.getAttribute('width');
            this.ReadXMLInit(tag);
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseInt(attr);
                if (attr !== null && IsInt(attr))
                    this.width = attr;
            }
            var attr = tag.getAttribute('height');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseInt(attr);
                if (attr !== null && IsInt(attr))
                    this.height = attr;
            }
            if (tag2_ !== null)
            {
                for (i = 0;i < tag2_.length;i++)
                {
                    tag2 = tag2_[i];
                    if (tag2 !== null && tag2.nodeType === 1)
                    {
                        if (tag2.nodeName === 'FileName')
                        {
                            obj = this.fileName;
                            if (typeof obj === 'undefined' || obj === null)
                            {
                                obj = objM.newObject('TFileName');
                                if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TFileName'))
                                    this.fileName = obj;
                            }
                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TFileName'))
                            {
                                obj.ReadXML(tag2);
                            }
                        }
                    }
                }
            }

        }
    };


    TGoogleMaps.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.fileName !== 'undefined' && this.fileName !== null && this.fileName.IsType('TFileName'))
            {
                var tmp2 = [],tmp1,id = this.GetId(),style=this.GetClassStyle();
                tmp1 = this.fileName.GetFileNameString();
                tmp2[0] = this.width;
                tmp2[1] = this.height;
                if (id !== null)
                    tmp2[2] = id;
                else
                    tmp2[2] = null;
                if (style !== null)
                    tmp2[6] = style;
                else
                    tmp2[6] = null;
                _object.Add('FigureGoogleMaps',tmp1,tmp2);
            }
        }
    };
    

}

TGoogleMaps.prototype = new TPageElement();



function TObjectFigure(){
    var type = 'TObjectFigure';
    TObjectFigure.prototype.InitConstructor = function(){
        TObjectMultilanguage.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.figure = null;
        this.lineWidth = 1;
        this.colourLine = null;
        this.colourFill = null;
        this.variables = null;
        this.colourFillTXT = null;
        this.colourLineTXT = null;
        this.colourTextTXT = null;
        this.colourSideTextTXT = null;
        this.fontParameters = null;
        this.arrowParameters = null;
    };
    this.InitConstructor();

    TObjectFigure.prototype.InitConstructor2 = function(){
        TObjectMultilanguage.prototype.InitConstructor2.call(this);
        var objM = this.GetObjectManager();
        if (objM !== null)
            this.variables = objM.newObject('TVariables');
    };


    TObjectFigure.prototype.Init = function(_object){
        TObjectMultilanguage.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TObjectFigure'))
        {
            if (typeof _object.figure !== 'undefined' && _object.figure !== null && _object.figure.IsType('TFigure'))
                this.figure = objM.copy(_object.figure);
            if (typeof _object.lineWidth !== 'undefined' && _object.lineWidth !== null && IsNumeric(_object.lineWidth))
                this.lineWidth = _object.lineWidth;
            if (typeof _object.colourLine !== 'undefined' && _object.colourLine !== null && _object.colourLine.IsType('TColourRGBA'))
                this.colourLine = objM.copy(_object.colourLine);
            if (typeof _object.colourFill !== 'undefined' && _object.colourFill !== null && _object.colourFill.IsType('TColourRGBA'))
                this.colourFill = objM.copy(_object.colourFill);
            if (typeof _object.variables !== 'undefined' && _object.variables !== null && _object.variables.IsType('TVariables'))
                this.variables = objM.copy(_object.variables);
            if (typeof _object.colourFillTXT !== 'undefined' && _object.colourFillTXT !== null && _object.colourFillTXT.IsType('TColourTXT'))
                this.colourFillTXT = objM.copy(_object.colourFillTXT);
            if (typeof _object.colourLineTXT !== 'undefined' && _object.colourLineTXT !== null && _object.colourLineTXT.IsType('TColourTXT'))
                this.colourLineTXT = objM.copy(_object.colourLineTXT);
            if (typeof _object.colourTextTXT !== 'undefined' && _object.colourTextTXT !== null && _object.colourTextTXT.IsType('TColourTXT'))
                this.colourTextTXT = objM.copy(_object.colourTextTXT);
            if (typeof _object.colourSideTextTXT !== 'undefined' && _object.colourSideTextTXT !== null && _object.colourSideTextTXT.IsType('TColourTXT'))
                this.colourSideTextTXT = objM.copy(_object.colourSideTextTXT);
            if (typeof _object.fontParameters !== 'undefined' && _object.fontParameters !== null && _object.fontParameters.IsType('TFontParameters'))
                this.fontParameters = objM.copy(_object.fontParameters);
            if (typeof _object.arrowParameters !== 'undefined' && _object.arrowParameters !== null && _object.arrowParameters.IsType('TArrowParameters'))
                this.arrowParameters = objM.copy(_object.arrowParameters);
        }
    };

    TObjectFigure.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectMultilanguage.prototype.IsType.call(this,_type);
    };   
    
    TObjectFigure.prototype.ReadXML = function(tag){
    };


    TObjectFigure.prototype.DrawFigure = function(ctx){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof ctx !== 'undefined' && ctx !== null && ctx.IsType('TDrawContext'))
        {
            if (this.figure !== null)
            {
                this.Recalculate();
                this.figure.Draw(ctx);
            }
        }
    };

    TObjectFigure.prototype.SetFigure = function(fig)
    {
        if (typeof fig !== 'undefined' && fig !== null && fig.IsType('TFigure'))
            this.figure = fig;
        if (fig === null)
            this.figure = null;
    };

    TObjectFigure.prototype.GetFigure = function()
    {
        return this.figure;
    };

    TObjectFigure.prototype.SetLineWidth = function(lineW)
    {
        if (typeof lineW !== 'undefined' && lineW !== null && IsNumeric(lineW))
        {
            if (this.figure !== null)
                this.figure.SetLineWidth(lineW);
            this.lineWidth = parseFloat(lineW);
        }
    };

    TObjectFigure.prototype.GetLineWidth = function()
    {
        return this.lineWidth;
    };

    TObjectFigure.prototype.SetColourLine = function(r,g,b,a){
        var objM = this.GetObjectManager();
        if (objM !== null && (typeof this.colourLine === 'undefined' || this.colourLine === null))
            this.colourLine = objM.newObject('TColourRGBA');
        
        if (typeof this.colourLine !== 'undefined' && this.colourLine !== null)
            this.colourLine.SetColourRGBA(r,g,b,a);
        
    };

    TObjectFigure.prototype.SetColourFill = function(r,g,b,a){
        var objM = this.GetObjectManager();
        if (objM !== null && (typeof this.colourFill === 'undefined' || this.colourFill === null))
            this.colourFill = objM.newObject('TColourRGBA');
        
        if (typeof this.colourFill !== 'undefined' && this.colourFill !== null)
            this.colourFill.SetColourRGBA(r,g,b,a);
        
    };

    TObjectFigure.prototype.CalculateValue = function(value_){
        if (this.variables !== null)
            return this.variables.CalculateValue(value_);
        return null;
    };

    TObjectFigure.prototype.FindVariable = function(name_){
        if (this.variables !== null)
            return this.variables.FindVariable(name_);
        return null;
    };


    TObjectFigure.prototype.SetVariable = function(var_,name_){
        if (this.variables !== null)
            this.variables.SetVariable(var_,name_);
    };

    TObjectFigure.prototype.SetVariables = function(var_){
        if (this.variables !== null)
            this.variables.SetVariables(var_);
    };

    TObjectFigure.prototype.GetVariables = function(){
        if (this.variables !== null)
            return this.variables.GetVariables();
        return null;
    };

    TObjectFigure.prototype.SetColour = function(r,g,b,a){
        this.SetColourFill(r,g,b,a);       
    };

    TObjectFigure.prototype.Recalculate = function(){
    };

    TObjectFigure.prototype.SetColourLineRGBA = function(c){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof c !== 'undefined' && c !== null && c.IsType('TColourRGBA'))
            this.colourLine = objM.copy(c);
        if (c === null)
            this.colourLine = null;
    };

    TObjectFigure.prototype.SetColourFillRGBA = function(c){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof c !== 'undefined' && c !== null && c.IsType('TColourRGBA'))
            this.colourFill = objM.copy(c);
        if (c === null)
            this.colourLine = null;
    };

    TObjectFigure.prototype.SetColourRGBA = function(c){
        this.SetColourFillRGBA(c);       
    };

    TObjectFigure.prototype.SetColourFillTXT = function(c){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof c !== 'undefined' && c !== null && c.IsType('TColourTXT'))
            this.colourFillTXT = objM.copy(c);
    };

    TObjectFigure.prototype.GetColourFillTXT = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.copy(this.colourFillTXT);
    };

    TObjectFigure.prototype.SetColourLineTXT = function(c){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof c !== 'undefined' && c !== null && c.IsType('TColourTXT'))
            this.colourLineTXT = objM.copy(c);
    };

    TObjectFigure.prototype.GetColourLineTXT = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.copy(this.colourLineTXT);
    };

    TObjectFigure.prototype.SetColourTextTXT = function(c){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof c !== 'undefined' && c !== null && c.IsType('TColourTXT'))
            this.colourTextTXT = objM.copy(c);
    };

    TObjectFigure.prototype.GetColourTextTXT = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.copy(this.colourTextTXT);
    };

    TObjectFigure.prototype.SetColourSideTextTXT = function(c){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof c !== 'undefined' && c !== null && c.IsType('TColourTXT'))
            this.colourSideTextTXT = objM.copy(c);
    };

    TObjectFigure.prototype.GetColourSideTextTXT = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.copy(this.colourSideTextTXT);
    };
    
    TObjectFigure.prototype.SetArrowParameters = function(c){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof c !== 'undefined' && c !== null && c.IsType('TArrowParameters'))
            this.arrowParameters = objM.copy(c);
    };
    
    TObjectFigure.prototype.GetArrowParameters = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.copy(this.arrowParameters);
    };
    
    TObjectFigure.prototype.SetFontParameters = function(f){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof f !== 'undefined' && f !== null && f.IsType('TFontParameters'))
            this.fontParameters = objM.copy(f);
    };
    
    TObjectFigure.prototype.GetFontParameters = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.copy(this.fontParameters);
    };
    
    TObjectFigure.prototype.ActualizeActions = function(){
    };
    
};

TObjectFigure.prototype = new TObjectMultilanguage();

function TFigure_(){
    var type = 'TFigure_';
    TFigure_.prototype.InitConstructor = function(){
        TObjectFigure.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.coordinates = [];
        this.coordinates[0] = [];
        this.coordinates[1] = [];
        this.coordinates[2] = [];
        this.coordinatesVar = [];
        this.coordinatesVar[0] = [];
        this.coordinatesVar[1] = [];
        this.coordinatesVar[2] = [];
    };
    this.InitConstructor();

    TFigure_.prototype.Init = function(_object){
        TObjectFigure.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TFigure_'))
        {
            var i,j;
            if (typeof _object.coordinates !== 'undefined' && _object.coordinates !== null)
            {
                for (i = 0;i < _object.coordinates.length;i++)
                    if (typeof _object.coordinates[i] !== 'undefined' && _object.coordinates[i] !== null)
                        for (j = 0;j < _object.coordinates[i].length;j++)
                            if (typeof _object.coordinates[i][j] !== 'undefined' && _object.coordinates[i][j] !== null && IsNumeric(_object.coordinates[i][j]))
                                this.coordinates[i][j] = _object.coordinates[i][j];
            }
            if (typeof _object.coordinatesVar !== 'undefined' && _object.coordinatesVar !== null)
            {
                for (i = 0;i < _object.coordinatesVar.length;i++)
                    if (typeof _object.coordinatesVar[i] !== 'undefined' && _object.coordinatesVar[i] !== null)
                        for (j = 0;j < _object.coordinatesVar[i].length;j++)
                            if (typeof _object.coordinatesVar[i][j] !== 'undefined' && _object.coordinatesVar[i][j] !== null)
                            {
                                this.coordinatesVar[i][j] = new String(_object.coordinatesVar[i][j]);
                                if (this.coordinatesVar[i][j] !== null)
                                    this.coordinatesVar[i][j] = this.coordinatesVar[i][j].toString();
                            }
            }
        }
    };

    TFigure_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectFigure.prototype.IsType.call(this,_type);
    };   
    
    TFigure_.prototype.ReadXML = function(tag){
        TObjectFigure.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {

            var i,x_ = tag.childNodes,k,attr;

            for (i = 0,k = 0;i < x_.length;i++)
            {
                if (x_[i].nodeType === 1)
                {
                    if (x_[i].nodeName === 'V')
                    {

                        this.coordinates[0][k] = 0;
                        this.coordinatesVar[0][k] = 0;
                        this.coordinates[1][k] = 0;
                        this.coordinatesVar[1][k] = 0;
                        this.coordinates[2][k] = 0;
                        this.coordinatesVar[2][k] = 0;
                        attr = this.CalculateValue(x_[i].getAttribute('x'));
                        if (attr !== null)
                        {
                            this.coordinates[0][k] = parseFloat(attr);
                        }
                        this.coordinatesVar[0][k] = x_[i].getAttribute('x');
                        attr = this.CalculateValue(x_[i].getAttribute('y'));
                        if (attr !== null)
                        {
                            this.coordinates[1][k] = parseFloat(attr);
                        }
                        this.coordinatesVar[1][k] = x_[i].getAttribute('y');
                        attr = this.CalculateValue(x_[i].getAttribute('z'));
                        if (attr !== null)
                        {
                            this.coordinates[2][k] = parseFloat(attr);
                        }
                        this.coordinatesVar[2][k] = x_[i].getAttribute('z');
                        k++;
                    }
                }
            }

        }
    };
    TFigure_.prototype.GetCoordinate = function(numberCoordinate,number){
        if (typeof numberCoordinate !== 'undefined' && numberCoordinate !== null && numberCoordinate >=0 && numberCoordinate < this.coordinatesVar.length)
        {
            if (typeof numberCoordinate === 'undefined' || numberCoordinate === null)
                number = 0;
            return this.CalculateValue(this.coordinatesVar[numberCoordinate][number]);
        }
        return null;
    };

};

TFigure_.prototype = new TObjectFigure();


function TLocaleFigure(){
    var type = 'TLocaleFigure';
    TLocaleFigure.prototype.InitConstructor = function(){
        TObjectFigure.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TLocaleFigure.prototype.Init = function(_object){
        TObjectFigure.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TLocaleFigure'))
        {
        }
    };

    TLocaleFigure.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectFigure.prototype.IsType.call(this,_type);
    };   
    
    TLocaleFigure.prototype.ReadXML = function(tag){
        TObjectFigure.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {

            var i;

            var tmp = tag.getAttribute('defaultLanguage');
            if (tmp !== null)
                this.defaultLanguage = tmp;

            var lang = this.GetCurrentNameLanguage();
            var i,x = tag.childNodes,YN = false,tmp = null,tmp2 = null;
            for (i = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if (x[i].nodeName.toLowerCase() === lang)
                    {
                        YN = true;
                        tmp2 = x[i];
                    }
                    if (typeof this.defaultLanguage !== 'undefined' && this.defaultLanguage !== null && x[i].nodeName.toLowerCase() === this.defaultLanguage)
                    {
                        tmp = x[i];
                    }
                }
            }
            if (YN)
            {
                this.ParseXML(tag,tmp2);
            }else
            {
                if (tmp !== null)
                {
                    this.ParseXML(tag,tmp);
                }
            }                


        }
    };

    TLocaleFigure.prototype.ParseXML = function(tag1,tag2){
    };

    TLocaleFigure.prototype.ChangeCurrentLanguageNumber = function(_language){
        TObjectFigure.prototype.ChangeCurrentLanguageNumber.call(this,_language);
    };

};

TLocaleFigure.prototype = new TObjectFigure();


function TLine_(){
    var type = 'TLine_';
    TLine_.prototype.InitConstructor = function(){
        TFigure_.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.beginArrowWidth = 15;
        this.beginArrowHeight = 10;
        this.endArrowWidth = 15;
        this.endArrowHeight = 10;
    };
    this.InitConstructor();

    TLine_.prototype.Init = function(_object){
        TFigure_.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TLine_'))
        {
            if (typeof _object.beginArrowWidth !== 'undefined' && _object.beginArrowWidth !== null && IsNumeric(_object.beginArrowWidth))
                this.lineWidth = _object.beginArrowWidth;
            if (typeof _object.beginArrowHeight !== 'undefined' && _object.beginArrowHeight !== null && IsNumeric(_object.beginArrowHeight))
                this.beginArrowHeight = _object.beginArrowHeight;
            if (typeof _object.endArrowWidth !== 'undefined' && _object.endArrowWidth !== null && IsNumeric(_object.endArrowWidth))
                this.endArrowWidth = _object.endArrowWidth;
            if (typeof _object.endArrowHeight !== 'undefined' && _object.endArrowHeight !== null && IsNumeric(_object.endArrowHeight))
                this.endArrowHeight = _object.endArrowHeight;
        }
    };

    TLine_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TFigure_.prototype.IsType.call(this,_type);
    };
    
    TLine_.prototype.ReadXML_ = function(line,tag){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var i,coord,attr,x,y,z;
            if (line !== null)
            {
                line.SetLineWidth(this.GetLineWidth());
//                var colour = objM.newObject('TColourRGBA');
//                if (colour !== null)
                {
//                    colour.SetColourRGBA(0,0,0,1);
                    line.SetLineColour(this.colourLine);
                    for (i = 0;i < this.coordinates[0].length;i++)
                    {
                        coord = objM.newObject('TVector3DT');
                        if (coord !== null)
                        {
                            x = this.GetCoordinate(0,i);
                            y = this.GetCoordinate(1,i);
                            z = this.GetCoordinate(2,i);
                            if (x !== null && y !== null)
                            {
                                coord.SetCoordinates(x,y,z);
                                line.SetVerticle(i,coord);
                            }
                        }
                    }
                    
                    attr = tag.getAttribute('dashedType');
                    if (typeof attr !== 'undefined' && attr !== null)
                    {
                        this.SetDashedType(attr);
                        line.SetDashedType(attr);                        
                    }
                    attr = tag.getAttribute('begin');
                    if (typeof attr !== 'undefined' && attr !== null)
                    {
                        line.SetArrow('T' + attr,true);
                        line.SetBeginArrowWidth(this.beginArrowWidth);
                        line.SetBeginArrowHeight(this.beginArrowHeight);
                    }
                    attr = tag.getAttribute('end');
                    if (typeof attr !== 'undefined' && attr !== null)
                    {
                        line.SetArrow('T' + attr,false);
                        line.SetEndArrowWidth(this.endArrowWidth);
                        line.SetEndArrowHeight(this.endArrowHeight);
                    }
//                    this.SetFigure(line);
                    
                    attr = tag.getAttribute('beginLength');
                    if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                    {
                        attr = parseFloat(attr);
                        if (attr !== null && IsNumeric(attr))
                            line.SetBeginLength(attr);
                    }
                    attr = tag.getAttribute('endLength');
                    if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                    {
                        attr = parseFloat(attr);
                        if (attr !== null && IsNumeric(attr))
                            line.SetEndLength(attr);
                    }
                }
            }
            
        }
    };

    
    TLine_.prototype.ReadXML = function(tag){
        TFigure_.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var line;
            line = objM.newObject('TLine');
            if (line !== null)
            {
                this.ReadXML_(line,tag);
                this.SetFigure(line);                    
            }
            
        }
    };

    TLine_.prototype.SetBeginArrowWidth = function(width)
    {
        if (typeof width !== 'undefined' && width !== null && IsNumeric(width))
        {
            var obj = this.GetFigure();
            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TLine'))
                obj.SetBeginArrowWidth(width);
            this.beginArrowWidth = parseFloat(width);
        }
    };

    TLine_.prototype.GetBeginArrowWidth = function()
    {
        return this.beginArrowWidth;
    };

    TLine_.prototype.SetBeginArrowHeight = function(height)
    {
        if (typeof height !== 'undefined' && height !== null && IsNumeric(height))
        {
            var obj = this.GetFigure();
            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TLine'))
                obj.SetBeginArrowHeight(height);
            this.beginArrowHeight = parseFloat(height);
        }
    };

    TLine_.prototype.GetBeginArrowHeight = function()
    {
        return this.beginArrowHeight;
    };

    TLine_.prototype.SetEndArrowWidth = function(width)
    {
        if (typeof width !== 'undefined' && width !== null && IsNumeric(width))
        {
            var obj = this.GetFigure();
            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TLine'))
                obj.SetEndArrowWidth(width);
            this.endArrowWidth = parseFloat(width);
        }
    };

    TLine_.prototype.GetEndArrowWidth = function()
    {
        return this.endArrowWidth;
    };

    TLine_.prototype.SetEndArrowHeight = function(height)
    {
        if (typeof height !== 'undefined' && height !== null && IsNumeric(height))
        {
            var obj = this.GetFigure();
            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TLine'))
                obj.SetEndArrowHeight(height);
            this.endArrowHeight = parseFloat(height);
        }
    };

    TLine_.prototype.GetEndArrowHeight = function()
    {
        return this.endArrowHeight;
    };

    TLine_.prototype.SetDashedType = function(type){
        if (typeof type !== 'undefined' && type !== null)
        {
            var obj = this.GetFigure();
            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TLine'))
                obj.SetDashedType(type);
        }
    };


};

TLine_.prototype = new TFigure_();


function TPolygon_(){
    var type = 'TPolygon_';
    TPolygon_.prototype.InitConstructor = function(){
        TFigure_.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TPolygon_.prototype.Init = function(_object){
        TFigure_.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TPolygon_'))
        {
        }
    };

    TPolygon_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TFigure_.prototype.IsType.call(this,_type);
    };
    
    TPolygon_.prototype.ReadXML_ = function(polygon,tag){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var i,coord,attr,x,y,z;
            if (polygon !== null)
            {
//                var colour = objM.newObject('TColourRGBA');
//                if (colour !== null)
                {
//                    colour.SetColourRGBA(0,0,0,1);
                    polygon.SetColour(this.colourFill);
                    polygon.SetLineColour(this.colourLine);
                    for (i = 0;i < this.coordinates[0].length;i++)
                    {
                        coord = objM.newObject('TVector3DT');
                        if (coord !== null)
                        {
                            x = this.GetCoordinate(0,i);
                            y = this.GetCoordinate(1,i);
                            z = this.GetCoordinate(2,i);
                            if (x !== null && y !== null)
                            {
                                coord.SetCoordinates(x,y,z);
                                polygon.SetVerticle(i,coord);
                            }
                        }
                    }
                    
                }
            }
            
        }
    };

    
    TPolygon_.prototype.ReadXML = function(tag){
        TFigure_.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var polygon;
            polygon = objM.newObject('TPolygon');
            if (polygon !== null)
            {
                this.ReadXML_(polygon,tag);
                this.SetFigure(polygon);                    
            }
            
        }
    };

};

TPolygon_.prototype = new TFigure_();


function TRationalBezierCurve_(){
    var type = 'TRationalBezierCurve_';
    TRationalBezierCurve_.prototype.InitConstructor = function(){
        TLine_.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.nVerticles = 10;
        this.shift = 0;
    };
    this.InitConstructor();

    TRationalBezierCurve_.prototype.Init = function(_object){
        TLine_.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TRationalBezierCurve_'))
        {
            if (typeof _object.nVerticles !== 'undefined' && _object.nVerticles !== null && IsInt(_object.nVerticles))
                this.nVerticles = _object.nVerticles;
            if (typeof _object.shift !== 'undefined' && _object.shift !== null && IsNumeric(_object.shift))
                this.shift = _object.shift;
        }
    };

    TRationalBezierCurve_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TLine_.prototype.IsType.call(this,_type);
    };
    
    TRationalBezierCurve_.prototype.ReadXML = function(tag){
        TFigure_.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var line,attr,P0,P2;
            line = objM.newObject('TRationalBezierCurve');
            if (line !== null)
            {

                this.ReadXML_(line,tag);
                
                line.SetNVerticles(this.nVerticles);
                attr = tag.getAttribute('nVerticlesBezier');
                if (typeof attr !== 'undefined' && attr !== null && IsInt(attr))
                {
                    attr = parseInt(attr);
                    if (attr !== null && IsInt(attr))
                        line.SetNVerticles(attr);
                }
                
                this.SetFigure(line);                    

                P0 = line.GetVerticle(0);
                P2 = line.GetVerticle(1);
                line.SetVerticle(2,P2);

                attr = tag.getAttribute('shift');
                if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                    {
                        this.shift = parseFloat(attr);
                        this.CalculateP1();
                    }
                }
            
            }
            
        }
    };

    TRationalBezierCurve_.prototype.SetNVerticles = function(n)
    {
        if (typeof n !== 'undefined' && n !== null && IsInt(n))
        {
            var obj = this.GetFigure();
            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TRationalBezierCurve'))
                obj.SetNVerticles(n);
            this.nVerticles = parseFloat(n);
        }
    };

    TRationalBezierCurve_.prototype.CalculateP1 = function(){
        var shift_ = this.shift;
        if(typeof shift_ !== 'undefined' && shift_ !== null && IsNumeric(shift_))
        {
            var line = this.GetFigure();
            var objM = this.GetObjectManager();
            if (line !== null && objM !== null)
            {
                var P0 = null,P1a,P1b,P1c,P2 = null,dif;
                var x0 = null,y0 = null;
                P0 = line.GetVerticle(0);
                P2 = line.GetVerticle(2);
                if (P0 !== null && P2 !== null)
                {
                    P1a = objM.copy(P2);
                    P1a.Subtraction(P0);
                    P1a.MultiplicationScalar(0.5);
                    x0 = P1a.GetCoordinate(0);
                    y0 = P1a.GetCoordinate(1);
                    if (x0 !== 0 || y0 !== 0)
                    {
                        P1b = objM.newObject(P1a.GetType());
                        if (x0 > 0 && y0 > 0)
                        {
                            P1b.SetCoordinate(0,x0);
                            P1b.SetCoordinate(1,-y0);
                        }
                        if (x0 === 0 && y0 > 0)
                        {
                            P1b.SetCoordinate(0,y0);
                            P1b.SetCoordinate(1,0);
                        }
                        if (x0 > 0 && y0 < 0)
                        {
                            P1b.SetCoordinate(0,-x0);
                            P1b.SetCoordinate(1,y0);
                        }
                        if (x0 > 0 && y0 === 0)
                        {
                            P1b.SetCoordinate(0,0);
                            P1b.SetCoordinate(1,-x0);
                        }
                        if (x0 < 0 && y0 < 0)
                        {
                            P1b.SetCoordinate(0,x0);
                            P1b.SetCoordinate(1,-y0);
                        }
                        if (x0 === 0 && y0 < 0)
                        {
                            P1b.SetCoordinate(0,y0);
                            P1b.SetCoordinate(1,0);
                        }
                        if (x0 < 0 && y0 > 0)
                        {
                            P1b.SetCoordinate(0,-x0);
                            P1b.SetCoordinate(1,y0);
                        }
                        if (x0 < 0 && y0 === 0)
                        {
                            P1b.SetCoordinate(0,0);
                            P1b.SetCoordinate(1,-x0);
                        }
                        if (P1a.ScalarProduct(P1b) === 0)
                        {
                            dif = objM.copy(P1b);
                        }else
                        {
                            var c = P1a.VectorComponent(P1b);
                            P1c = objM.copy(P1a);
                            P1c.MultiplicationScalar(c);
                            dif = objM.copy(P1b);
                            dif.Subtraction(P1c);
                        }
                        var norm = dif.Norm();
    //                    dif.MultiplicationScalar(25/norm);
                        dif.MultiplicationScalar(shift_/norm);
                        dif.Addition(P0);                    
                        dif.Addition(P1a);
                        line.SetVerticle(1,dif);
                        var obj = line.GetChild(0);
                        obj.CalculateVertices();
                        obj = line.GetChild(1);
                        obj.CalculateVertices();
                    }
                }
            }
        }
    };


};

TRationalBezierCurve_.prototype = new TLine_();


function TCircle_(){
    var type = 'TCircle_';
    TCircle_.prototype.InitConstructor = function(){
        TFigure_.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TCircle_.prototype.Init = function(_object){
        TFigure_.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TCircle_'))
        {
        }
    };

    TCircle_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TFigure_.prototype.IsType.call(this,_type);
    };
    
    TCircle_.prototype.ReadXML = function(tag){
        TFigure_.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var i,coord,circle,attr,x,y,z;
            circle = objM.newObject('TCircle');
            if (circle !== null)
            {
                circle.SetLineWidth(this.GetLineWidth());
                circle.SetLineColour(this.colourLine);
                circle.SetBackgroundColour(this.colourFill);
                if (this.coordinates[0].length > 0)
                {
                    coord = objM.newObject('TVector3DT');
                    if (coord !== null)
                    {
                        x = this.GetCoordinate(0,0);
                        y = this.GetCoordinate(1,0);
                        z = this.GetCoordinate(2,0);
                        if (x !== null && y !== null)
                        {
                            coord.SetCoordinates(x,y,z);
                            circle.SetVerticle(0,coord);
                        }
//                        coord.SetCoordinates(this.coordinates[0][0],this.coordinates[1][0],this.coordinates[2][0]);
//                        circle.SetVerticle(0,coord);
                    }
                }
                this.SetFigure(circle);

                if (circle !== null)
                {
                    attr = tag.getAttribute('radius');
                    if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                    {
                        attr = parseFloat(attr);
                        if (attr !== null && IsNumeric(attr))
                                this.SetRadius(attr);
                    }
                }
            }
            
        }
    };

    TCircle_.prototype.SetRadius = function(r)
    {
        if (typeof r !== 'undefined' && r !== null && IsNumeric(r))
        {
            var obj = this.GetFigure();
            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TCircle'))
                obj.SetRadius(r);
        }
    };

};

TCircle_.prototype = new TFigure_();


function TEllipse_(){
    var type = 'TEllipse_';
    TEllipse_.prototype.InitConstructor = function(){
        TFigure_.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TEllipse_.prototype.Init = function(_object){
        TFigure_.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TEllipse_'))
        {
        }
    };

    TEllipse_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TFigure_.prototype.IsType.call(this,_type);
    };
    
    TEllipse_.prototype.ReadXML = function(tag){
        TFigure_.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var i,coord,ellipse,attr,attr2,x,y,z;
            ellipse = objM.newObject('TEllipse');
            if (ellipse !== null)
            {
                ellipse.SetLineWidth(this.GetLineWidth());
                ellipse.SetLineColour(this.colourLine);
                ellipse.SetBackgroundColour(this.colourFill);
                if (this.coordinates[0].length > 0)
                {
                    coord = objM.newObject('TVector3DT');
                    if (coord !== null)
                    {
                        x = this.GetCoordinate(0,0);
                        y = this.GetCoordinate(1,0);
                        z = this.GetCoordinate(2,0);
                        if (x !== null && y !== null)
                        {
                            coord.SetCoordinates(x,y,z);
                            ellipse.SetVerticle(0,coord);
                        }
                    }
                }
                this.SetFigure(ellipse);

                if (ellipse !== null)
                {
                    attr = tag.getAttribute('radiusX');
                    attr2 = tag.getAttribute('radiusY');
                    if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr) && typeof attr2 !== 'undefined' && attr2 !== null && IsNumeric(attr2))
                    {
                        attr = parseFloat(attr);
                        attr2 = parseFloat(attr2);
                        if (attr !== null && IsNumeric(attr) && attr2 !== null && IsNumeric(attr2))
                            this.SetRadius(attr,attr2);
                    }
                }
            }
            
        }
    };

    TEllipse_.prototype.SetRadius = function(rx,ry)
    {
        if (typeof rx !== 'undefined' && rx !== null && IsNumeric(rx) && typeof ry !== 'undefined' && ry !== null && IsNumeric(ry))
        {
            var obj = this.GetFigure();
            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TEllipse'))
                obj.SetRadius(rx,ry);
        }
    };

};

TEllipse_.prototype = new TFigure_();


function TThreeTriangle_(){
    var type = 'TThreeTriangle_';
    TThreeTriangle_.prototype.InitConstructor = function(){
        TFigure_.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TThreeTriangle_.prototype.Init = function(_object){
        TFigure_.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TThreeTriangle_'))
        {
        }
    };

    TThreeTriangle_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TFigure_.prototype.IsType.call(this,_type);
    };

    TThreeTriangle_.prototype.Recalculate = function(){
        TFigure_.prototype.Recalculate.call(this);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var i,coord,triangle,x,y,z;
            triangle = objM.newObject('TThreeTriangle');
            if (triangle !== null)
            {
                triangle.SetLineWidth(this.GetLineWidth());
                triangle.SetLineColour(this.colourLine);
                triangle.SetBackgroundColour(this.colourFill);
                if (this.coordinates[0].length > 0)
                {
                    coord = objM.newObject('TVector3DT');
                    if (coord !== null)
                    {
                        x = this.GetCoordinate(0,0);
                        y = this.GetCoordinate(1,0);
                        z = this.GetCoordinate(2,0);
                        if (x !== null && y !== null && z !== null)
                        {
                            coord.SetCoordinates(x,y,z);
                            triangle.SetVerticle(0,coord);
                        }
                    }
                }
                if (this.coordinates[1].length > 1)
                {
                    coord = objM.newObject('TVector3DT');
                    if (coord !== null)
                    {
                        x = this.GetCoordinate(0,1);
                        y = this.GetCoordinate(1,1);
                        z = this.GetCoordinate(2,1);
                        if (x !== null && y !== null && z !== null)
                        {
                            coord.SetCoordinates(x,y,z);
                            triangle.SetVerticle(1,coord);
                        }
                    }
                }
                if (this.coordinates[1].length > 1)
                {
                    coord = objM.newObject('TVector3DT');
                    if (coord !== null)
                    {
                        x = this.GetCoordinate(0,2);
                        y = this.GetCoordinate(1,2);
                        z = this.GetCoordinate(2,2);
                        if (x !== null && y !== null && z !== null)
                        {
                            coord.SetCoordinates(x,y,z);
                            triangle.SetVerticle(2,coord);
                        }
                    }
                }
                this.SetFigure(triangle);

            }
            
        }
    };    
    
    TThreeTriangle_.prototype.ReadXML = function(tag){
        TFigure_.prototype.ReadXML.call(this,tag);
        this.Recalculate();
    };

};

TThreeTriangle_.prototype = new TFigure_();


function TThreeSphere_(){
    var type = 'TThreeSphere_';
    TThreeSphere_.prototype.InitConstructor = function(){
        TFigure_.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.radius = 1;
	this.wireframe = false;
    };
    this.InitConstructor();

    TThreeSphere_.prototype.Init = function(_object){
        TFigure_.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TThreeSphere_'))
        {
            if (typeof _object.radius !== 'undefined' && _object.radius !== null && IsNumeric(_object.radius))
                this.radius = _object.radius;
            if (typeof _object.radius !== 'undefined' && _object.radius !== null && IsNumeric(_object.radius))
                this.radius = _object.radius;
            if (typeof _object.wireframe !== 'undefined' && _object.wireframe !== null)
                this.wireframe = _object.wireframe;
        }
    };

    TThreeSphere_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TFigure_.prototype.IsType.call(this,_type);
    };

    TThreeSphere_.prototype.Recalculate = function(){
        TFigure_.prototype.Recalculate.call(this);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var i,coord,triangle,x,y,z;
            sphere = this.GetFigure();
            if (sphere !== null)
            {
                sphere.SetBackgroundColour(this.colourFill);
                sphere.SetRadius(this.CalculateValue(this.radius));
                if (this.coordinates[0].length > 0)
                {
                    coord = objM.newObject('TVector3DT');
                    if (coord !== null)
                    {
                        x = this.GetCoordinate(0,0);
                        y = this.GetCoordinate(1,0);
                        z = this.GetCoordinate(2,0);
                        if (x !== null && y !== null && z !== null)
                        {
                            coord.SetCoordinates(x,y,z);
                            sphere.SetVerticle(0,coord);
                        }
                    }
                }
                this.SetFigure(sphere);

            }
            
        }
    };    
    
    TThreeSphere_.prototype.ReadXML = function(tag){
        TFigure_.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var attr,sphere = objM.newObject('TThreeSphere'),coord,x,y,z;
            if (sphere !== null)
            {
                attr = this.CalculateValue(tag.getAttribute('radius'));
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                    {
			this.radius = attr;
                        sphere.SetRadius(attr);
                    }
                }
                attr = tag.getAttribute('wireframe');
                if (typeof attr !== 'undefined' && attr !== null && (attr === "True" || attr === "true"))
		    this.wireframe = true;
		else
		    this.wireframe = false;
		sphere.SetWireframe(this.wireframe);
                coord = objM.newObject('TVector3DT');
                if (coord !== null)
                {
                    x = this.GetCoordinate(0,0);
                    y = this.GetCoordinate(1,0);
                    z = this.GetCoordinate(2,0);
                    if (x !== null && y !== null && z !== null)
                    {
                        coord.SetCoordinates(x,y,z);
                        sphere.SetVerticle(i,coord);
                    }
                }
                this.SetFigure(sphere);
	    }
	}
        this.Recalculate();
    };

};

TThreeSphere_.prototype = new TFigure_();


function TThreeLine_(){
    var type = 'TThreeLine_';
    TThreeLine_.prototype.InitConstructor = function(){
        TFigure_.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TThreeLine_.prototype.Init = function(_object){
        TFigure_.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TThreeLine_'))
        {
        }
    };

    TThreeLine_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TFigure_.prototype.IsType.call(this,_type);
    };

    TThreeLine_.prototype.Recalculate = function(){
        TFigure_.prototype.Recalculate.call(this);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var i,coord,line,x,y,z;
            line = this.GetFigure();
            if (typeof line !== 'undefined' && line !== null)
            {
                line.SetLineWidth(this.GetLineWidth());
                line.SetLineColour(this.colourLine);
                for (i = 0;i< this.coordinates.length;i++)
                {
                    if (this.coordinates[i].length > 0)
                    {
                        coord = objM.newObject('TVector3DT');
                        if (coord !== null)
                        {
                            x = this.GetCoordinate(0,i);
                            y = this.GetCoordinate(1,i);
                            z = this.GetCoordinate(2,i);
                            if (x !== null && y !== null && z !== null)
                            {
                                coord.SetCoordinates(x,y,z);
                                line.SetVerticle(i,coord);
                            }
                        }
                    }
                }
  
            }
            
        }
    };    
    
    TThreeLine_.prototype.ReadXML = function(tag){
        TFigure_.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var attr,i,coord,line = objM.newObject('TThreeLine'),x,y,z=0;
            if (line !== null)
            {

                for (i = 0;i < this.coordinates[0].length;i++)
                {
                    coord = objM.newObject('TVector3DT');
                    if (coord !== null)
                    {
                        x = this.GetCoordinate(0,i);
                        y = this.GetCoordinate(1,i);
                        z = this.GetCoordinate(2,i);
                        if (x !== null && y !== null)
                        {
                            coord.SetCoordinates(x,y,z);
                            line.SetVerticle(i,coord);
                        }
                    }
                }
                attr = tag.getAttribute('begin');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    line.SetArrow('T' + attr,true);
                    line.SetBeginArrowWidth(this.beginArrowWidth);
                    line.SetBeginArrowHeight(this.beginArrowHeight);
                }
                attr = tag.getAttribute('end');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    line.SetArrow('T' + attr,false);
                    line.SetEndArrowWidth(this.endArrowWidth);
                    line.SetEndArrowHeight(this.endArrowHeight);
                }
    //                    this.SetFigure(line);

                attr = tag.getAttribute('beginLength');
                if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        line.SetBeginLength(attr);
                }
                attr = tag.getAttribute('endLength');
                if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        line.SetEndLength(attr);
                }
                this.SetFigure(line);
            }
        }
        
        this.Recalculate();
    };

    TThreeLine_.prototype.SetBeginArrowWidth = function(width)
    {
        if (typeof width !== 'undefined' && width !== null && IsNumeric(width))
        {
            var obj = this.GetFigure();
            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TThreeLine'))
                obj.SetBeginArrowWidth(width);
            this.beginArrowWidth = parseFloat(width);
        }
    };

    TThreeLine_.prototype.GetBeginArrowWidth = function()
    {
        return this.beginArrowWidth;
    };

    TThreeLine_.prototype.SetBeginArrowHeight = function(height)
    {
        if (typeof height !== 'undefined' && height !== null && IsNumeric(height))
        {
            var obj = this.GetFigure();
            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TThreeLine'))
                obj.SetBeginArrowHeight(height);
            this.beginArrowHeight = parseFloat(height);
        }
    };

    TThreeLine_.prototype.GetBeginArrowHeight = function()
    {
        return this.beginArrowHeight;
    };

    TThreeLine_.prototype.SetEndArrowWidth = function(width)
    {
        if (typeof width !== 'undefined' && width !== null && IsNumeric(width))
        {
            var obj = this.GetFigure();
            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TThreeLine'))
                obj.SetEndArrowWidth(width);
            this.endArrowWidth = parseFloat(width);
        }
    };

    TThreeLine_.prototype.GetEndArrowWidth = function()
    {
        return this.endArrowWidth;
    };

    TThreeLine_.prototype.SetEndArrowHeight = function(height)
    {
        if (typeof height !== 'undefined' && height !== null && IsNumeric(height))
        {
            var obj = this.GetFigure();
            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TThreeLine'))
                obj.SetEndArrowHeight(height);
            this.endArrowHeight = parseFloat(height);
        }
    };

    TThreeLine_.prototype.GetEndArrowHeight = function()
    {
        return this.endArrowHeight;
    };

/*    TThreeLine_.prototype.DrawFigure = function(scene){
        this.Recalculate();
        TFigure_.prototype.DrawFigure.call(this,scene);
    };*/
};

TThreeLine_.prototype = new TFigure_();


/*function TFigureText(){
    var type = 'TFigureText';
    TFigureText.prototype.InitConstructor = function(){
        TParagraphString.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.data = null;
    };
    this.InitConstructor();

    TFigureText.prototype.Init = function(_object){
        TParagraphString.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TFigureText'))
        {
        }
    };

    TFigureText.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TParagraphString.prototype.IsType.call(this,_type);
    };
    

    TFigureText.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            _object.Add('FT',this.GetStringData());
        }
    };
}

TFigureText.prototype = new TParagraphString();
*/

function TText_(){
    var type = 'TText_';
    TText_.prototype.InitConstructor = function(){
        TLocaleFigure.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.element = [];
        this.scaleTextYN = true;
        this.colourText = null;
        this.fontSize = 10;
        this.fontRelativeSize = 'normalsize';
        this.font = 'Arial';
        this.alignmentX = 'center';
        this.alignmentY = 'center';
    };
    this.InitConstructor();

    TText_.prototype.Init = function(_object){
        TLocaleFigure.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TText_'))
        {
            var i;
            if (typeof _object.element !== 'undefined' && _object.element !== null)
            {
                for (i = 0;i < _object.element.length;i++)
                {
                    if (typeof _object.element[i] !== 'undefined' && _object.element[i] !== null && _object.element[i].IsType('TParagraphElement'))
                        this.element[i] = objM.copy(_object.element[i]);
                }
            }
            if (typeof _object.scaleTextYN !== 'undefined' && _object.scaleTextYN !== null)
                this.scaleTextYN = _object.scaleTextYN;
            if (typeof _object.colourText !== 'undefined' && _object.colourText !== null && _object.colourText.IsType('TColourRGBA'))
                this.colourText = objM.copy(_object.colourText);
            if (typeof _object.fontSize !== 'undefined' && _object.fontSize !== null && IsNumeric(_object.fontSize))
                this.fontSize = _object.fontSize;
            if (typeof _object.fontRelativeSize !== 'undefined' && _object.fontRelativeSize !== null)
            {
                this.fontRelativeSize = new String(_object.fontRelativeSize);
                if (this.fontRelativeSize !== null)
                    this.fontRelativeSize = this.fontRelativeSize.toString();
            }
            if (typeof _object.font !== 'undefined' && _object.font !== null)
            {
                this.font = new String(_object.font);
                if (this.font !== null)
                    this.font = this.font.toString();
            }
            if (typeof _object.alignmentX !== 'undefined' && _object.alignmentX !== null)
            {
                this.alignmentX = new String(_object.alignmentX);
                if (this.alignmentX !== null)
                    this.alignmentX = this.alignmentX.toString();
            }
            if (typeof _object.alignmentY !== 'undefined' && _object.alignmentY !== null)
            {
                this.alignmentY = new String(_object.alignmentY);
                if (this.alignmentY !== null)
                    this.alignmentY = this.alignmentY.toString();
            }
            
 /*           if (typeof _object.width !== 'undefined' && _object.width !== null && IsInt(_object.width))
                this.width = _object.width;
            if (typeof _object.height !== 'undefined' && _object.height !== null && IsInt(_object.height))
                this.height = _object.height;
            if (typeof _object.listFigures !== 'undefined' && _object.listFigures !== null && IsInt(_object.listFigures))
                this.listFigures = objM.copy(_object.listFigures);*/
        }
    };

    TText_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TLocaleFigure.prototype.IsType.call(this,_type);
    };
    
    TText_.prototype.ParseXML = function(tag1,tag2){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var i,text,attr,x=0,y=0,z=0,coord;
            text = objM.newObject('TText');
            if (text !== null)
            {
                attr = tag1.getAttribute('x');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(this.CalculateValue(attr));
                    if (attr !== null && IsNumeric(attr))
                        x = attr;
                }
                attr = tag1.getAttribute('y');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(this.CalculateValue(attr));
                    if (attr !== null && IsNumeric(attr))
                        y = attr;
                }
                attr = tag1.getAttribute('z');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(this.CalculateValue(attr));
                    if (attr !== null && IsNumeric(attr))
                        z = attr;
                }
                attr = tag1.getAttribute('scaleText');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    if (attr === 'No')
                        this.scaleTextYN = false;
                    else
                        this.scaleTextYN = true;
                }
                attr = tag1.getAttribute('fontSize');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseInt(attr);
                    if (attr !== null && IsInt(attr))
                        this.fontSize = attr;
                }
                attr = tag1.getAttribute('fontRelativeSize');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    this.fontRelativeSize = attr;
                }
                attr = tag1.getAttribute('font');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    this.font = attr;
                }
                attr = tag1.getAttribute('alignmentX');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    this.alignmentX = attr;
                }
                attr = tag1.getAttribute('alignmentY');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    this.alignmentY = attr;
                }
                attr = tag1.getAttribute('rotate');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(this.CalculateValue(attr));
                    if (attr !== null && IsNumeric(attr))
                        text.SetRotate(attr);
                }
                
                
                coord = objM.newObject('TVector3DT');
                if (coord !== null)
                {
                    coord.SetCoordinates(x,y,z);
                    text.SetCoordinates(coord);
                }
                
                this.SetFigure(text);

                var i,x_ = tag2.childNodes,attr,k;

                for (i = 0,k=0;i < x_.length;i++)
                {
                    if (x_[i].nodeType === 3)
                    {
                        if (this.element.length <= k || typeof this.element === 'undefined' || this.element === null)
                        {
                            this.element[k] = objM.newObject('TParagraphString');
                        }
                        if (this.element.length > k && typeof this.element !== 'undefined' && this.element !== null)
                        {
                            this.element[k].ParseXML(x_[i]);
                        }
/*                        if (typeof attr !== 'undefined' && attr !== null && attr === 'Paragraph')
                        {
                            if (typeof this.paragraph === 'undefined' || this.paragraph === null)
                                this.paragraph = objM.newObject('TParagraph');
                            if (typeof this.paragraph !== 'undefined' && this.paragraph !== null)
                            {
                                this.paragraph.ReadXML(x_[i]);
                                break;
                            }
                        }*/
                    }
                }
            
            }
            
        }
    };


    TText_.prototype.DrawFigure = function(ctx){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
//            ctx.SetScaleTextYN(this.scaleTextYN);
            var i,txt = '';
            for (i = 0;i < this.element.length;i++)
            {
                if (typeof this.element[i] !== 'undefined' && this.element[i] !== null)
                    txt = txt + this.element[i].GetStringData();
            }
            var obj = this.GetFigure();
            if (obj !== null)
            {
                obj.SetText(null,txt);
                obj.SetScaleTextYN(this.scaleTextYN);
                obj.SetFontSize(this.fontSize);
                obj.SetFontRelativeSize(this.fontRelativeSize);
                obj.SetFont(this.font);
                obj.SetAlignmentX(this.alignmentX);
                obj.SetAlignmentY(this.alignmentY);
            }
            
/*            var drawHtml = objM.newObject('THTMLObject');
            if (drawHtml !== null)
            {
                drawHtml.SetTypeDrawObject('THTMLParagraphs');
                this.paragraph.Draw(drawHtml);
                var txt = drawHtml.GetTXT();
                var obj = this.GetFigure();
                if (obj !== null)
                {
                    obj.SetText(null,txt);
                }
            }*/
            ctx.SetDefaultTextColour(this.colourText);
        }
        TLocaleFigure.prototype.DrawFigure.call(this,ctx);
    };

/*    TText_.prototype.Draw = function(ctx){
        if (typeof ctx !== 'undefined' && ctx !== null && ctx.IsType('TDrawContext'))
        {
            ctx.SetScaleTextYN(this.scaleTextYN);
            TLocaleFigure.prototype.Draw.call(this,ctx);
        }
    };*/


    TText_.prototype.ChangeCurrentLanguageNumber = function(_language){
        TLocaleFigure.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        if (typeof this.element !== 'undefined' && this.element !== null)
        {
            var i;
            for (i = 0;i < this.element.length;i++)
                if (this.element[i] !== null)
                    this.element[i].ChangeCurrentLanguageNumber(_language);
        }
    };

    TText_.prototype.SetColourText = function(r,g,b,a){
        var objM = this.GetObjectManager();
        if (objM !== null && (typeof this.colourText === 'undefined' || this.colourText === null))
            this.colourText = objM.newObject('TColourRGBA');
        
        if (typeof this.colourText !== 'undefined' && this.colourText !== null)
            this.colourText.SetColourRGBA(r,g,b,a);
        
    };

};

TText_.prototype = new TLocaleFigure();

function TCharts_(){
    var type = 'TCharts_';
    TCharts_.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.x = null;
        this.y = null;
        this.colour = null;
        this.lineWidth = '1';
        this.lineType = 'solid';
        this.idChart = null;
    };
    this.InitConstructor();

    TCharts_.prototype.Init = function(_object){
        TObject.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TCharts_'))
        {
            if (typeof _object.x !== 'undefined' && _object.x !== null)
            {
                this.x = new String(_object.x);
                if (this.x !== null)
                    this.x = this.x.toString();
            }
            if (typeof _object.y !== 'undefined' && _object.y !== null)
            {
                this.y = new String(_object.y);
                if (this.y !== null)
                    this.y = this.y.toString();
            }
            if (typeof _object.colour !== 'undefined' && _object.colour !== null)
                this.colour = objM.copy(_object.colour);
            if (typeof _object.lineWidth !== 'undefined' && _object.lineWidth !== null)
            {
                this.lineWidth = new String(_object.lineWidth);
                if (this.lineWidth !== null)
                    this.lineWidth = this.lineWidth.toString();
            }
            if (typeof _object.lineType !== 'undefined' && _object.lineType !== null)
            {
                this.lineType = new String(_object.lineType);
                if (this.lineType !== null)
                    this.lineType = this.lineType.toString();
            }
            if (typeof _object.idChart !== 'undefined' && _object.idChart !== null)
            {
                this.idChart = new String(_object.idChart);
                if (this.idChart !== null)
                    this.idChart = this.idChart.toString();
            }
        }
    };

    TCharts_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };

    
    TCharts_.prototype.ReadXML = function(tag){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var attr;
            attr = tag.getAttribute('x');
            if (typeof attr !== 'undefined' && attr !== null)
                this.x = attr;
            attr = tag.getAttribute('y');
            if (typeof attr !== 'undefined' && attr !== null)
                this.y = attr;
            this.colour = objM.newObject('TColourTXT'); 
            if (this.colour !== null)
                this.colour.ReadXML(tag);
            attr = tag.getAttribute('lineWidth');
            if (typeof attr !== 'undefined' && attr !== null)
                this.lineWidth = attr;
            attr = tag.getAttribute('lineType');
            if (typeof attr !== 'undefined' && attr !== null)
                this.lineType = attr;
            attr = tag.getAttribute('id');
            if (typeof attr !== 'undefined' && attr !== null)
                this.idChart = attr;
        }
    };

    TCharts_.prototype.Recalculate = function(chart){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof chart !== 'undefined' && chart !== null && chart.IsType('TCharts'))
        {
            chart.SetLineType(this.lineType);
            chart.SetIdChart(this.idChart);
        }
    };    

    TCharts_.prototype.GetX = function(){
        if (typeof this.x !== 'undefined' && this.x != null)
        {
            var res = new String(this.x);
            if (res !== null)
                return res.toString();
        }
        return null;
    }

    TCharts_.prototype.GetY = function(){
        if (typeof this.y !== 'undefined' && this.y != null)
        {
            var res = new String(this.y);
            if (res !== null)
                return res.toString();
        }
        return null;
    }

    TCharts_.prototype.GetColour = function(){
        var objM = this.GetObjectManager();
        if (typeof this.colour !== 'undefined' && this.colour !== null && objM != null)
            return objM.copy(this.colour);
        return null;
    }


    TCharts_.prototype.GetLineWidth = function(){
        if (typeof this.lineWidth !== 'undefined' && this.lineWidth != null)
        {
            var res = new String(this.lineWidth);
            if (res !== null)
                return res.toString();
        }
        return null;
    }

};

TCharts_.prototype = new TObject();

function TLineChart_(){
    var type = 'TLineChart_';
    TLineChart_.prototype.InitConstructor = function(){
        TCharts_.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TLineChart_.prototype.Init = function(_object){
        TCharts_.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TLineChart_'))
        {
        }
    };

    TLineChart_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TCharts_.prototype.IsType.call(this,_type);
    };
    
    TLineChart_.prototype.ReadXML = function(tag){
        TCharts_.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
/*            var attr;
            attr = tag.getAttribute('fontSize');
            if (typeof attr !== 'undefined' && attr !== null)
                this.fontSize = attr;*/
        }
//        this.Recalculate();
    };

    TLineChart_.prototype.Recalculate = function(chart){
        TCharts_.prototype.Recalculate.call(this,chart);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            
        }
    };    

};

TLineChart_.prototype = new TCharts_();

function TPointChart_(){
    var type = 'TPointChart_';
    TPointChart_.prototype.InitConstructor = function(){
        TCharts_.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.backgroundColour = null;
        this.size = 5;
        this.nPoints = 4;
        this.startAngle = 45;
    };
    this.InitConstructor();

    TPointChart_.prototype.Init = function(_object){
        TCharts_.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TPointChart_'))
        {
            if (typeof _object.backgroundColour !== 'undefined' && _object.backgroundColour !== null)
                this.backgroundColour = objM.copy(_object.backgroundColour);
            if (typeof _object.size !== 'undefined' && _object.size !== null && IsNumeric(_object.size))
                this.size = _object.size;
            if (typeof _object.nPoints !== 'undefined' && _object.nPoints !== null && IsInt(_object.nPoints))
                this.nPoints = _object.nPoints;
            if (typeof _object.startAngle !== 'undefined' && _object.startAngle !== null && IsNumeric(_object.startAngle))
                this.startAngle = _object.startAngle;
        }
    };

    TPointChart_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TCharts_.prototype.IsType.call(this,_type);
    };


    TPointChart_.prototype.ReadXML = function(tag){
        TCharts_.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var attr;
            var r = tag.getAttribute('br');
            var g = tag.getAttribute('bg');
            var b = tag.getAttribute('bb');
            var a = tag.getAttribute('ba');
            
            if (typeof r !== 'undefined'  && typeof g !== 'undefined' && typeof b !== 'undefined')
            {
                if (typeof a === 'undefined')
                    a = null;
                this.backgroundColour = objM.newObject('TColourTXT');
                if (this.backgroundColour !== null)
                    this.backgroundColour.SetRGBA(r,g,b,a);
            }
            
            attr = tag.getAttribute('size');
            if (typeof attr !== 'undefined' && attr !== null)
                this.size = attr;
            attr = tag.getAttribute('nPoints');
            if (typeof attr !== 'undefined' && attr !== null)
                this.nPoints = attr;
            attr = tag.getAttribute('startAngle');
            if (typeof attr !== 'undefined' && attr !== null)
                this.startAngle = attr;
        }
//        this.Recalculate();
    };

    TPointChart_.prototype.Recalculate = function(chart){
        TCharts_.prototype.Recalculate.call(this,chart);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            chart.SetSize(this.size);            
            chart.SetNPoints(this.nPoints);            
            chart.SetStartAngle(this.startAngle*Math.PI/180);
        }
    };    

    TPointChart_.prototype.GetBackgroundColour = function(){
        var objM = this.GetObjectManager();
        if (typeof this.backgroundColour !== 'undefined' && this.backgroundColour !== null && objM != null)
            return objM.copy(this.backgroundColour);
        return null;
    }

};

TPointChart_.prototype = new TCharts_();

function TBarChart_(){
    var type = 'TBarChart_';
    TBarChart_.prototype.InitConstructor = function(){
        TCharts_.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.backgroundColour = null;
        this.interspace = 0;
    };
    this.InitConstructor();

    TBarChart_.prototype.Init = function(_object){
        TCharts_.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TPointChart_'))
        {
            if (typeof _object.backgroundColour !== 'undefined' && _object.backgroundColour !== null)
                this.backgroundColour = objM.copy(_object.backgroundColour);
            if (typeof _object.interspace !== 'undefined' && _object.interspace !== null && IsNumeric(_object.interspace))
                this.interspace = _object.interspace;
        }
    };

    TBarChart_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TCharts_.prototype.IsType.call(this,_type);
    };

    TBarChart_.prototype.ReadXML = function(tag){
        TCharts_.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var attr;
            var r = tag.getAttribute('br');
            var g = tag.getAttribute('bg');
            var b = tag.getAttribute('bb');
            var a = tag.getAttribute('ba');
            
            if (typeof r !== 'undefined'  && typeof g !== 'undefined' && typeof b !== 'undefined')
            {
                if (typeof a === 'undefined')
                    a = null;
                this.backgroundColour = objM.newObject('TColourTXT');
                if (this.backgroundColour !== null)
                    this.backgroundColour.SetRGBA(r,g,b,a);
            }
            
            attr = tag.getAttribute('interspace');
            if (typeof attr !== 'undefined' && attr !== null)
                this.interspace = attr;
        }
    };

    TBarChart_.prototype.Recalculate = function(chart){
        TCharts_.prototype.Recalculate.call(this,chart);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            chart.SetInterspace(this.interspace);            
        }
    };    

    TBarChart_.prototype.GetBackgroundColour = function(){
        var objM = this.GetObjectManager();
        if (typeof this.backgroundColour !== 'undefined' && this.backgroundColour !== null && objM != null)
            return objM.copy(this.backgroundColour);
        return null;
    }

};

TBarChart_.prototype = new TCharts_();


function TChartLegend_(){
    var type = 'TChartLegend_';
    TChartLegend_.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.x = '0';
        this.y = '0';
        this.fontSize = '12';
        this.font = 'Arial';
        this.fontStyle = 'normal';
        this.lineSpacing = '30';
        this.interspace = '30';
        this.signWidth = '10';
        this.text = [];
        this.id1 = [];
        this.id2 = [];
        this.chartDefaultLanguage = null;
    };
    this.InitConstructor();

    TChartLegend_.prototype.Init = function(_object){
        TObject.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TChartLegend_'))
        {
            var i;
            if (typeof _object.x !== 'undefined' && _object.x !== null)
            {
                this.x = new String(_object.x);
                if (this.x !== null)
                    this.x = this.x.toString();
            }
            if (typeof _object.y !== 'undefined' && _object.y !== null)
            {
                this.y = new String(_object.y);
                if (this.y !== null)
                    this.y = this.y.toString();
            }
            if (typeof _object.font !== 'undefined' && _object.font !== null)
            {
                this.font = new String(_object.font);
                if (this.font !== null)
                    this.font = this.font.toString();
            }
            if (typeof _object.fontSize !== 'undefined' && _object.fontSize !== null)
            {
                this.fontSize = new String(_object.fontSize);
                if (this.fontSize !== null)
                    this.fontSize = this.fontSize.toString();
            }
            if (typeof _object.fontStyle !== 'undefined' && _object.fontStyle !== null)
            {
                this.fontStyle = new String(_object.fontStyle);
                if (this.fontStyle !== null)
                    this.fontStyle = this.fontStyle.toString();
            }
            if (typeof _object.lineSpacing !== 'undefined' && _object.lineSpacing !== null)
            {
                this.lineSpacing = new String(_object.lineSpacing);
                if (this.lineSpacing !== null)
                    this.lineSpacing = this.lineSpacing.toString();
            }
            if (typeof _object.interspace !== 'undefined' && _object.interspace !== null)
            {
                this.interspace = new String(_object.interspace);
                if (this.interspace !== null)
                    this.interspace = this.interspace.toString();
            }
            if (typeof _object.signWidth !== 'undefined' && _object.signWidth !== null)
            {
                this.signWidth = new String(_object.signWidth);
                if (this.signWidth !== null)
                    this.signWidth = this.signWidth.toString();
            }
            if (typeof _object.text !== 'undefined' && _object.text !== null)
            {
                for (i = 0;i < _object.text.length;i++)
                {
                    if (typeof _object.text[i] !== 'undefined' && _object.text[i] !== null && _object.text[i].IsType('TPageElement'))
                        this.text[i] = objM.copy(_object.text[i]);
                }
            }
            if (typeof _object.id1 !== 'undefined' && _object.id1 !== null)
            {
                this.id1 = new String(_object.id1);
                if (this.id1 !== null)
                    this.id1 = this.id1.toString();
            }
            if (typeof _object.id2 !== 'undefined' && _object.id2 !== null)
            {
                this.id2 = new String(_object.id2);
                if (this.id2 !== null)
                    this.id2 = this.id2.toString();
            }
            if (typeof _object.chartDefaultLanguage !== 'undefined' && _object.chartDefaultLanguage !== null)
            {
                this.chartDefaultLanguage = new String(_object.chartDefaultLanguage);
                if (this.chartDefaultLanguage !== null)
                    this.chartDefaultLanguage = this.chartDefaultLanguage.toString();
            }
        }
    };

    TChartLegend_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };

    
    TChartLegend_.prototype.ReadXML = function(tag,variables){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var attr;
            attr = tag.getAttribute('x');
            if (typeof attr !== 'undefined' && attr !== null)
                this.x = attr;
            attr = tag.getAttribute('y');
            if (typeof attr !== 'undefined' && attr !== null)
                this.y = attr;
            attr = tag.getAttribute('fontSize');
            if (typeof attr !== 'undefined' && attr !== null)
                this.fontSize = attr;
            attr = tag.getAttribute('font');
            if (typeof attr !== 'undefined' && attr !== null)
                this.font = attr;
            attr = tag.getAttribute('fontStyle');
            if (typeof attr !== 'undefined' && attr !== null)
                this.fontStyle = attr;
            attr = tag.getAttribute('lineSpacing');
            if (typeof attr !== 'undefined' && attr !== null)
                this.lineSpacing = attr;
            attr = tag.getAttribute('interspace');
            if (typeof attr !== 'undefined' && attr !== null)
                this.interspace = attr;
            attr = tag.getAttribute('signWidth');
            if (typeof attr !== 'undefined' && attr !== null)
                this.signWidth = attr;
            var x = tag.childNodes,i,ch,obj,j,object_,k,y,ii=0;
            this.text = [];
            this.id1 = [];
            this.id2 = [];
            for(k = 0;k < x.length;k++)
            {
                if (x[k].nodeType === 1)
                {
                    if (x[k].nodeName.toLowerCase() === 'text')
                    {
                        y = x[k].childNodes
                        for(i = 0,j = 0;i < y.length;i++)
                        {
                            if (y[i].nodeType === 1)
                            {
                                if (y[i].nodeName.toLowerCase() === 'element')
                                {
                                    attr = y[i].getAttribute('type');
                                    if (typeof attr !== 'undefined' && attr !== null)
                                    {
                                        if (typeof this.text[ii] === 'undefined' || this.text[ii] === null)
                                            obj = objM.newObject('T'+attr);
                                        else
                                            obj = this.text[ii];
                                        ii++;
                                        if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                                        {
                                            if (this.chartDefaultLanguage != null)
                                                obj.SetDefaultLanguage(this.chartDefaultLanguage);
                                            obj.SetVariables(variables);
                                            obj.ReadXML(y[i],x[k]);
                                            object_ = obj;
                                        }else
                                            object_ = null;
                                        this.text[j] = object_;
                                    }
                                    attr = y[i].getAttribute('id1');
                                    if (typeof attr !== 'undefined' && attr !== null)
                                        this.id1[j] = attr;
                                    attr = y[i].getAttribute('id2');
                                    if (typeof attr !== 'undefined' && attr !== null)
                                        this.id2[j] = attr;
                                    j++;
                                }
                            }
                        }
                    }
                }
            }
        }
    };

    TChartLegend_.prototype.Recalculate = function(l,ch){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof l !== 'undefined' && l !== null && l.IsType('TChartLegend'))
        {
            l.SetFontSize(this.fontSize);
            l.SetFont(this.font);
            l.SetFontStyle(this.fontStyle);
            l.SetLineSpacing(this.lineSpacing);
            l.SetInterspace(this.interspace);
            l.SetSignWidth(this.signWidth);
            l.SetText(this.text);
            if (typeof ch !== 'undefined' && ch !== null)
            {
                var i,j,res = [];
                for (i = 0;i < this.id1.length;i++)
                    if (typeof this.id1[i] !== 'undefined' && this.id1[i] !== null)
                        for (j = 0;j < ch.length;j++)
                        {
                            if (typeof ch[j] !== 'undefined' && ch[j] !== null && ch[j].IsType('TCharts'))
                            {
                                if (ch[j].GetIdChart() === this.id1[i])
                                {
                                    res[i] = ch[j];
                                    break;
                                }
                            }                    
                        }
                l.SetChart1(res);
                res = [];
                for (i = 0;i < this.id2.length;i++)
                    if (typeof this.id2[i] !== 'undefined' && this.id2[i] !== null)
                        for (j = 0;j < ch.length;j++)
                        {
                            if (typeof ch[j] !== 'undefined' && ch[j] !== null && ch[j].IsType('TCharts'))
                            {
                                if (ch[j].GetIdChart() === this.id2[i])
                                {
                                    res[i] = ch[j];
                                    break;
                                }
                            }                    
                        }
                l.SetChart2(res);
            }
        }
    };    

    TChartLegend_.prototype.ChangeCurrentLanguageNumber = function(_language){
        if (typeof this.text !== 'undefined' && this.text !== null )
        {
            for (i = 0;i < this.text.length;i++)
            {
                if (typeof this.text[i] !== 'undefined' && this.text[i] !== null && this.text[i].IsType('TPageElement'))
                    this.text[i].ChangeCurrentLanguageNumber(_language);
            }
        }
    };

    TChartLegend_.prototype.SetChartDefaultLanguage = function(_language){
        if (typeof _language !== 'undefined' && _language !== null)
        {
            this.chartDefaultLanguage = new String(_language);
            this.chartDefaultLanguage = this.chartDefaultLanguage.toString();
        }   
        if (_language === null)
            this.chartDefaultLanguage = null;
    };

    TChartLegend_.prototype.GetX = function(){
        if (typeof this.x !== 'undefined' && this.x != null)
        {
            var res = new String(this.x);
            if (res !== null)
                return res.toString();
        }
        return null;
    }

    TChartLegend_.prototype.GetY = function(){
        if (typeof this.y !== 'undefined' && this.y != null)
        {
            var res = new String(this.y);
            if (res !== null)
                return res.toString();
        }
        return null;
    }

};

TChartLegend_.prototype = new TObject();


function TChart_(){
    var type = 'TChart_';
    TChart_.prototype.InitConstructor = function(){
        TFigure_.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.fontSize = '1';
        this.font = 'Arial';
        this.fontStyle = 'normal';
        this.width = '10';
        this.height = '10';
        this.axisLineWidth = 1;
        this.axisArrowWidth = 15;
        this.axisArrowHeight = 10;
        this.axisTypeArrow = 'TArrowTriangle';
        this.x = '0';
        this.y = '0';
        this.xMin = '0';
        this.xMax = '1';
        this.yMin = '0';
        this.yMax = '1';
        this.axisXZero = false;
        this.axisYZero = false;
        this.axisXYN = true;
        this.axisYYN = true;
        this.scaleAxisXYN = true;
        this.scaleAxisYYN = true;
	this.proportionalScaleAxisYN = false;
        this.descriptionLineWidth = 1;
        this.sizeDescriptionLine = 10;
        this.shiftDescriptionAxisX = -17;
        this.shiftDescriptionAxisY = -10;
        this.shiftDescriptionAxisZeroX = 0;
        this.shiftDescriptionAxisZeroY = 0;
        this.descriptionFontSize = '12';
        this.descriptionFont = 'Arial';
        this.descriptionFontStyle = 'normal';
        this.descriptionAxisX = [];
        this.descriptionAxisXText = [];
        this.descriptionXWidthAxisArrow = 15;
        this.descriptionXRangeIncludeZero = false;
        this.autoDescriptionX = true;
//        this.descriptionAxisX = '[]';
//        this.descriptionAxisXText = '[]';
        this.descriptionAxisY = [];
        this.descriptionAxisYText = [];
        this.descriptionYWidthAxisArrow = 15;
        this.descriptionYRangeIncludeZero = false;
        this.autoDescriptionY = true;
        this.descriptionSeparator = null;
        this.xLabel = null;
        this.shiftXLabel = -35;
        this.yLabel = null;
        this.shiftYLabel = -35;
        this.charts = [];
        this.chartDefaultLanguage = null;
        this.nameObjectChart = null;
        this.chartType = null;
        this.legend = null;
    };
    this.InitConstructor();

    TChart_.prototype.Init = function(_object){
        TFigure_.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TChart_'))
        {
            var i;
            if (typeof _object.font !== 'undefined' && _object.font !== null)
            {
                this.font = new String(_object.font);
                if (this.font !== null)
                    this.font = this.font.toString();
            }
            if (typeof _object.fontSize !== 'undefined' && _object.fontSize !== null)
            {
                this.fontSize = new String(_object.fontSize);
                if (this.fontSize !== null)
                    this.fontSize = this.fontSize.toString();
            }
            if (typeof _object.fontStyle !== 'undefined' && _object.fontStyle !== null)
            {
                this.fontStyle = new String(_object.fontStyle);
                if (this.fontStyle !== null)
                    this.fontStyle = this.fontStyle.toString();
            }
            if (typeof _object.width !== 'undefined' && _object.width !== null)
            {
                this.width = new String(_object.width);
                if (this.width !== null)
                    this.width = this.width.toString();
            }
            if (typeof _object.height !== 'undefined' && _object.height !== null)
            {
                this.height = new String(_object.height);
                if (this.height !== null)
                    this.height = this.height.toString();
            }
            if (typeof _object.axisLineWidth !== 'undefined' && _object.axisLineWidth !== null && IsNumeric(_object.axisLineWidth))
                this.axisLineWidth = _object.axisLineWidth;
            if (typeof _object.axisArrowWidth !== 'undefined' && _object.axisArrowWidth !== null && IsNumeric(_object.axisArrowWidth))
                this.axisArrowWidth = _object.axisArrowWidth;
            if (typeof _object.axisArrowHeight !== 'undefined' && _object.axisArrowHeight !== null && IsNumeric(_object.axisArrowHeight))
                this.axisArrowHeight = _object.axisArrowHeight;
            if (typeof _object.axisTypeArrow !== 'undefined' && _object.axisTypeArrow !== null)
            {
                this.axisTypeArrow = new String(_object.axisTypeArrow);
                if (this.axisTypeArrow !== null)
                    this.axisTypeArrow = this.axisTypeArrow.toString();
            }
            if (typeof _object.x !== 'undefined' && _object.x !== null)
            {
                this.x = new String(_object.x);
                if (this.x !== null)
                    this.x = this.x.toString();
            }
            if (typeof _object.y !== 'undefined' && _object.y !== null)
            {
                this.y = new String(_object.y);
                if (this.y !== null)
                    this.y = this.y.toString();
            }
            if (typeof _object.xMin !== 'undefined' && _object.xMin !== null)
            {
                this.xMin = new String(_object.xMin);
                if (this.xMin !== null)
                    this.xMin = this.xMin.toString();
            }
            if (typeof _object.xMax !== 'undefined' && _object.xMax !== null)
            {
                this.xMax = new String(_object.xMax);
                if (this.xMax !== null)
                    this.xMax = this.xMax.toString();
            }
            if (typeof _object.yMin !== 'undefined' && _object.yMin !== null)
            {
                this.yMin = new String(_object.yMin);
                if (this.yMin !== null)
                    this.yMin = this.yMin.toString();
            }
            if (typeof _object.yMax !== 'undefined' && _object.yMax !== null)
            {
                this.yMax = new String(_object.yMax);
                if (this.yMax !== null)
                    this.yMax = this.yMax.toString();
            }
            if (typeof _object.axisXZero !== 'undefined' && _object.axisXZero !== null && IsNumeric(_object.axisXZero))
                this.axisXZero = _object.axisXZero;
            if (typeof _object.axisYZero !== 'undefined' && _object.axisYZero !== null && IsNumeric(_object.axisYZero))
                this.axisYZero = _object.axisYZero;
            if (typeof _object.descriptionLineWidth !== 'undefined' && _object.descriptionLineWidth !== null && IsNumeric(_object.descriptionLineWidth))
                this.descriptionLineWidth = _object.descriptionLineWidth;
            if (typeof _object.sizeDescriptionLine !== 'undefined' && _object.sizeDescriptionLine !== null && IsNumeric(_object.sizeDescriptionLine))
                this.sizeDescriptionLine = _object.sizeDescriptionLine;
            if (typeof _object.shiftDescriptionAxisX !== 'undefined' && _object.shiftDescriptionAxisX !== null && IsNumeric(_object.shiftDescriptionAxisX))
                this.shiftDescriptionAxisX = _object.shiftDescriptionAxisX;
            if (typeof _object.shiftDescriptionAxisY !== 'undefined' && _object.shiftDescriptionAxisY !== null && IsNumeric(_object.shiftDescriptionAxisY))
                this.shiftDescriptionAxisY = _object.shiftDescriptionAxisY;
            if (typeof _object.shiftDescriptionAxisZeroX !== 'undefined' && _object.shiftDescriptionAxisZeroX !== null && IsNumeric(_object.shiftDescriptionAxisZeroX))
                this.shiftDescriptionAxisZeroX = _object.shiftDescriptionAxisZeroX;
            if (typeof _object.shiftDescriptionAxisZeroY !== 'undefined' && _object.shiftDescriptionAxisZeroY !== null && IsNumeric(_object.shiftDescriptionAxisZeroY))
                this.shiftDescriptionAxisZeroY = _object.shiftDescriptionAxisZeroY;
            if (typeof _object.descriptionFontSize !== 'undefined' && _object.descriptionFontSize !== null)
            {
                this.descriptionFontSize = new String(_object.descriptionFontSize);
                if (this.descriptionFontSize !== null)
                    this.descriptionFontSize = this.descriptionFontSize.toString();
            }
            if (typeof _object.descriptionFont !== 'undefined' && _object.descriptionFont !== null)
            {
                this.descriptionFont = new String(_object.descriptionFont);
                if (this.descriptionFont !== null)
                    this.descriptionFont = this.descriptionFont.toString();
            }
            if (typeof _object.descriptionFontStyle !== 'undefined' && _object.descriptionFontStyle !== null)
            {
                this.descriptionFontStyle = new String(_object.descriptionFontStyle);
                if (this.descriptionFontStyle !== null)
                    this.descriptionFontStyle = this.descriptionFontStyle.toString();
            }
            if (typeof _object.descriptionAxisX !== 'undefined' && _object.descriptionAxisX !== null)
            {
                for (i = 0;i < _object.descriptionAxisX.length;i++)
                {
                    if (typeof _object.descriptionAxisX[i] !== 'undefined' && _object.descriptionAxisX[i] !== null && IsNumeric(_object.descriptionAxisX[i]))
                        this.descriptionAxisX[i] = _object.descriptionAxisX[i];
                }
            }
            if (typeof _object.descriptionAxisX !== 'undefined' && _object.descriptionAxisX !== null)
            {
                this.descriptionAxisX = new String(_object.descriptionAxisX);
                if (this.descriptionAxisX !== null)
                    this.descriptionAxisX = this.descriptionAxisX.toString();
            }
            if (typeof _object.descriptionAxisXText !== 'undefined' && _object.descriptionAxisXText !== null)
            {
                for (i = 0;i < _object.descriptionAxisXText.length;i++)
                {
                    if (typeof _object.descriptionAxisXText[i] !== 'undefined' && _object.descriptionAxisXText[i] !== null && _object.descriptionAxisXText[i].IsType('TPageElement'))
                        this.descriptionAxisXText[i] = objM.copy(_object.descriptionAxisXText[i]);
                }
            }
            if (typeof _object.descriptionXWidthAxisArrow !== 'undefined' && _object.descriptionXWidthAxisArrow !== null && IsNumeric(_object.descriptionXWidthAxisArrow))
                this.descriptionXWidthAxisArrow = _object.descriptionXWidthAxisArrow;
            if (typeof _object.descriptionXRangeIncludeZero !== 'undefined' && _object.descriptionXRangeIncludeZero !== null)
                this.descriptionXRangeIncludeZero = _object.descriptionXRangeIncludeZero;
            if (typeof _object.autoDescriptionX !== 'undefined' && _object.autoDescriptionX !== null)
                this.autoDescriptionX = _object.autoDescriptionX;
            if (typeof _object.descriptionAxisY !== 'undefined' && _object.descriptionAxisY !== null)
            {
                this.descriptionAxisY = new String(_object.descriptionAxisY);
                if (this.descriptionAxisY !== null)
                    this.descriptionAxisY = this.descriptionAxisY.toString();
            }
            if (typeof _object.descriptionAxisYText !== 'undefined' && _object.descriptionAxisYText !== null)
            {
                this.descriptionAxisYText = new String(_object.descriptionAxisYText);
                if (this.descriptionAxisYText !== null)
                    this.descriptionAxisYText = this.descriptionAxisYText.toString();
            }
            if (typeof _object.descriptionAxisY !== 'undefined' && _object.descriptionAxisY !== null)
            {
                this.descriptionAxisY = new String(_object.descriptionAxisY);
                if (this.descriptionAxisY !== null)
                    this.descriptionAxisY = this.descriptionAxisY.toString();
            }
            if (typeof _object.descriptionAxisYText !== 'undefined' && _object.descriptionAxisYText !== null)
            {
                for (i = 0;i < _object.descriptionAxisYText.length;i++)
                {
                    if (typeof _object.descriptionAxisYText[i] !== 'undefined' && _object.descriptionAxisYText[i] !== null && _object.descriptionAxisYText[i].IsType('TPageElement'))
                        this.descriptionAxisYText[i] = objM.copy(_object.descriptionAxisYText[i]);
                }
            }
            if (typeof _object.descriptionYWidthAxisArrow !== 'undefined' && _object.descriptionYWidthAxisArrow !== null && IsNumeric(_object.descriptionYWidthAxisArrow))
                this.descriptionYWidthAxisArrow = _object.descriptionYWidthAxisArrow;
            if (typeof _object.descriptionYRangeIncludeZero !== 'undefined' && _object.descriptionYRangeIncludeZero !== null)
                this.descriptionYRangeIncludeZero = _object.descriptionYRangeIncludeZero;
            if (typeof _object.autoDescriptionY !== 'undefined' && _object.autoDescriptionY !== null)
                this.autoDescriptionY = _object.autoDescriptionY;
            if (typeof _object.descriptionSeparator !== 'undefined' && _object.descriptionSeparator !== null && _object.descriptionSeparator.IsType('TPageElement'))
                this.descriptionSeparator = objM.copy(_object.descriptionSeparator);
            if (typeof _object.xLabel !== 'undefined' && _object.xLabel !== null && _object.xLabel.IsType('TPageElement'))
                this.xLabel = objM.copy(_object.xLabel);
            if (typeof _object.shiftXLabel !== 'undefined' && _object.shiftXLabel !== null && IsNumeric(_object.shiftXLabel))
                this.shiftXLabel = _object.shiftXLabel;
            if (typeof _object.yLabel !== 'undefined' && _object.yLabel !== null && _object.yLabel.IsType('TPageElement'))
                this.yLabel = objM.copy(_object.yLabel);
            if (typeof _object.shiftYLabel !== 'undefined' && _object.shiftYLabel !== null && IsNumeric(_object.shiftYLabel))
                this.shiftYLabel = _object.shiftYLabel;
            if (typeof _object.charts !== 'undefined' && _object.charts !== null)
            {
                for (i = 0;i < _object.charts.length;i++)
                {
                    if (typeof _object.charts[i] !== 'undefined' && _object.charts[i] !== null && _object.charts[i].IsType('TCharts_'))
                        this.charts[i] = objM.copy(_object.charts[i]);
                }
            }
            if (typeof _object.chartDefaultLanguage !== 'undefined' && _object.chartDefaultLanguage !== null)
            {
                this.chartDefaultLanguage = new String(_object.chartDefaultLanguage);
                if (this.chartDefaultLanguage !== null)
                    this.chartDefaultLanguage = this.chartDefaultLanguage.toString();
            }
            if (typeof _object.legend !== 'undefined' && _object.legend !== null && _object.legend.IsType('TChartLegend_'))
                this.legend = objM.copy(_object.legend);
            if (typeof _object.axisXYN !== 'undefined' && _object.axisXYN !== null)
                this.axisXYN = _object.axisXYN;
            if (typeof _object.axisYYN !== 'undefined' && _object.axisYYN !== null)
                this.axisYYN = _object.axisYYN;
            if (typeof _object.scaleAxisXYN !== 'undefined' && _object.scaleAxisXYN !== null)
                this.scaleAxisXYN = _object.scaleAxisXYN;
            if (typeof _object.scaleAxisYYN !== 'undefined' && _object.scaleAxisYYN !== null)
                this.scaleAxisYYN = _object.scaleAxisYYN;
            if (typeof _object.proportionalScaleAxisYN !== 'undefined' && _object.proportionalScaleAxisYN !== null)
                this.proportionalScaleAxisYN = _object.proportionalScaleAxisYN;
        }
    };

    TChart_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TFigure_.prototype.IsType.call(this,_type);
    };

    TChart_.prototype.ReadXMLText = function(tag,object_){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null && typeof object_ !== 'undefined')
        {
            var x = tag.childNodes,i,ch,obj;
            for(i = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if (x[i].nodeName.toLowerCase() === 'element')
                    {
                        attr = x[i].getAttribute('type');
                        if (typeof attr !== 'undefined' && attr !== null)
                        {
                            if (typeof object_ === 'undefined' || object_ === null)
                                obj = objM.newObject('T'+attr);
                            else
                                obj = object_;
                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                            {
                                if (this.chartDefaultLanguage != null)
                                    obj.SetDefaultLanguage(this.chartDefaultLanguage);
                                obj.SetVariables(this.GetVariables());
                                obj.ReadXML(x[i],tag);
                                object_ = obj;
                            }else
                                object_ = null;
                        }
                    }
                }
            }
        }
        return object_;
    }

    TChart_.prototype.ReadXMLText2 = function(tag,position,objects){
        var res = [],objM = this.GetObjectManager();
        res[0] = [];
        res[1] = [];
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var x = tag.childNodes,i,ii=0,ch,obj,j,object_,k,y;
            for(k = 0;k < x.length;k++)
            {
                if (x[k].nodeType === 1)
                {
                    if (x[k].nodeName.toLowerCase() === 'text')
                    {
                        y = x[k].childNodes
                        for(i = 0,j = 0;i < y.length;i++)
                        {
                            if (y[i].nodeType === 1)
                            {
                                if (y[i].nodeName.toLowerCase() === 'element')
                                {
                                    attr = y[i].getAttribute('type');
                                    if (typeof attr !== 'undefined' && attr !== null)
                                    {
                                        if (typeof objects[ii] === 'undefined' || objects[ii] === null)
                                            obj = objM.newObject('T'+attr);
                                        else
                                            obj = objects[ii];
                                        if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                                        {
                                            if (this.chartDefaultLanguage != null)
                                                obj.SetDefaultLanguage(this.chartDefaultLanguage);
                                            obj.SetVariables(this.GetVariables());
                                            obj.ReadXML(y[i],x[k]);
                                            object_ = obj;
                                        }else
                                            object_ = null;
                                        res[1][j] = object_;
                                        ii++;
                                    }
                                    attr = y[i].getAttribute(position);
                                    if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                                    {
                                        res[0][j] = parseFloat(attr);
                                    }
                                    j++;
                                }
                            }
                        }
                    }
                }
            }
        }
        return res;
    }
    
    
    TChart_.prototype.ReadXML = function(tag){
        TFigure_.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var attr;
            attr = tag.getAttribute('fontSize');
            if (typeof attr !== 'undefined' && attr !== null)
                this.fontSize = attr;
            attr = tag.getAttribute('font');
            if (typeof attr !== 'undefined' && attr !== null)
                this.font = attr;
            attr = tag.getAttribute('fontStyle');
            if (typeof attr !== 'undefined' && attr !== null)
                this.fontStyle = attr;
            attr = tag.getAttribute('width');
            if (typeof attr !== 'undefined' && attr !== null)
                this.width = attr;
            attr = tag.getAttribute('height');
            if (typeof attr !== 'undefined' && attr !== null)
                this.height = attr;
            attr = tag.getAttribute('axisLineWidth');
            if (typeof attr !== 'undefined' && attr !== null)
                this.axisLineWidth = parseFloat(attr);
            attr = tag.getAttribute('axisArrowWidth');
            if (typeof attr !== 'undefined' && attr !== null)
                this.axisArrowWidth = parseFloat(attr);
            attr = tag.getAttribute('axisArrowHeight');
            if (typeof attr !== 'undefined' && attr !== null)
                this.axisArrowHeight = parseFloat(attr);
            attr = tag.getAttribute('axisTypeArrow');
            if (typeof attr !== 'undefined' && attr !== null)
                this.axisTypeArrow = attr;
            attr = tag.getAttribute('x');
            if (typeof attr !== 'undefined' && attr !== null)
                this.x = attr;
            attr = tag.getAttribute('y');
            if (typeof attr !== 'undefined' && attr !== null)
                this.y = attr;
            attr = tag.getAttribute('xMin');
            if (typeof attr !== 'undefined' && attr !== null)
                this.xMin = attr;
            attr = tag.getAttribute('xMax');
            if (typeof attr !== 'undefined' && attr !== null)
                this.xMax = attr;
            attr = tag.getAttribute('yMin');
            if (typeof attr !== 'undefined' && attr !== null)
                this.yMin = attr;
            attr = tag.getAttribute('yMax');
            if (typeof attr !== 'undefined' && attr !== null)
                this.yMax = attr;
            var attr = tag.getAttribute('axisXZero');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                if ((attr === 'Yes' || attr === 'yes' || attr === 'True' || attr === 'true'))
                    this.axisXZero = true;
                else
                    this.axisXZero = false;
            }
            var attr = tag.getAttribute('axisYZero');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                if ((attr === 'Yes' || attr === 'yes' || attr === 'True' || attr === 'true'))
                    this.axisYZero = true;
                else
                    this.axisYZero = false;
            }
	    attr = tag.getAttribute('axisX');
	    if (typeof attr !== 'undefined' && attr !== null)
	    {
		if (attr === 'No' || attr === 'no')
		    this.axisXYN = false;
		else
		    this.axisXYN = true;
	    }
	    attr = tag.getAttribute('axisY');
	    if (typeof attr !== 'undefined' && attr !== null)
	    {
		if (attr === 'No' || attr === 'no')
		    this.axisYYN = false;
		else
		    this.axisYYN = true;
	    }
	    attr = tag.getAttribute('scaleAxisX');
	    if (typeof attr !== 'undefined' && attr !== null)
	    {
		if (attr === 'No' || attr === 'no')
		    this.scaleAxisXYN = false;
		else
		    this.scaleAxisXYN = true;
	    }
	    attr = tag.getAttribute('scaleAxisY');
	    if (typeof attr !== 'undefined' && attr !== null)
	    {
		if (attr === 'No' || attr === 'no')
		    this.scaleAxisYYN = false;
		else
		    this.scaleAxisYYN = true;
	    }
	    attr = tag.getAttribute('proportionalScaleAxis');
	    if (typeof attr !== 'undefined' && attr !== null)
	    {
		if (attr === 'No' || attr === 'no')
		    this.proportionalScaleAxisYN = false;
		else
		    this.proportionalScaleAxisYN = true;
	    }
            attr = tag.getAttribute('descriptionLineWidth');
            if (typeof attr !== 'undefined' && attr !== null)
                this.descriptionLineWidth = attr;
            attr = tag.getAttribute('sizeDescriptionLine');
            if (typeof attr !== 'undefined' && attr !== null)
                this.sizeDescriptionLine = attr;
//            attr = tag.getAttribute('shiftDescriptionAxisX');
//            if (typeof attr !== 'undefined' && attr !== null)
//                this.shiftDescriptionAxisX = attr;
//            attr = tag.getAttribute('shiftDescriptionAxisY');
//            if (typeof attr !== 'undefined' && attr !== null)
//                this.shiftDescriptionAxisY = attr;
//            attr = tag.getAttribute('shiftDescriptionAxisZeroX');
//            if (typeof attr !== 'undefined' && attr !== null)
//                this.shiftDescriptionAxisZeroX = attr;
//            attr = tag.getAttribute('shiftDescriptionAxisZeroY');
//            if (typeof attr !== 'undefined' && attr !== null)
//                this.shiftDescriptionAxisZeroY = attr;
            attr = tag.getAttribute('descriptionFontSize');
            if (typeof attr !== 'undefined' && attr !== null)
                this.descriptionFontSize = attr;
            attr = tag.getAttribute('descriptionFont');
            if (typeof attr !== 'undefined' && attr !== null)
                this.descriptionFont = attr;
            attr = tag.getAttribute('descriptionFontStyle');
            if (typeof attr !== 'undefined' && attr !== null)
                this.descriptionFontStyle = attr;
//            attr = tag.getAttribute('descriptionAxisX');
//            if (typeof attr !== 'undefined' && attr !== null)
//                this.descriptionAxisX = attr;
//            attr = tag.getAttribute('descriptionAxisXText');
//            if (typeof attr !== 'undefined' && attr !== null)
//                this.descriptionAxisXText = attr;
//            attr = tag.getAttribute('descriptionAxisY');
//            if (typeof attr !== 'undefined' && attr !== null)
//                this.descriptionAxisY = attr;
//            attr = tag.getAttribute('descriptionAxisYText');
//            if (typeof attr !== 'undefined' && attr !== null)
//                this.descriptionAxisYText = attr;
            attr = tag.getAttribute('defaultLanguage');
            if (typeof attr !== 'undefined' && attr !== null)
                this.chartDefaultLanguage = attr;
            var x = tag.childNodes,i,ch,res,obj;
            for(i = 0,j=0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Line')
                    {
                        ch = objM.newObject('TLineChart_');
                        ch.ReadXML(x[i]);
                        this.charts[this.charts.length] = ch;
                    }
                    if(x[i].nodeName === 'Point')
                    {
                        ch = objM.newObject('TPointChart_');
                        ch.ReadXML(x[i]);
                        this.charts[this.charts.length] = ch;
                    }
                    if(x[i].nodeName === 'Bar')
                    {
                        ch = objM.newObject('TBarChart_');
                        ch.ReadXML(x[i]);
                        this.charts[this.charts.length] = ch;
                    }
                    if(x[i].nodeName === 'XLabel')
                    {
                        this.xLabel = this.ReadXMLText(x[i],this.xLabel);
                        attr = x[i].getAttribute('shift');
                        if (typeof attr !== 'undefined' && attr !== null)
                            this.shiftXLabel = attr;
                    }
                    if(x[i].nodeName === 'YLabel')
                    {
                        this.yLabel = this.ReadXMLText(x[i],this.yLabel);
                        attr = x[i].getAttribute('shift');
                        if (typeof attr !== 'undefined' && attr !== null)
                            this.shiftYLabel = attr;
                    }
                    if(x[i].nodeName === 'XDescription')
                    {
                        res = this.ReadXMLText2(x[i],'x',this.descriptionAxisXText);
                        this.descriptionAxisX = res[0];
                        this.descriptionAxisXText = res[1];
                        attr = x[i].getAttribute('shift');
                        if (typeof attr !== 'undefined' && attr !== null)
                            this.shiftDescriptionAxisX = attr;
                        attr = x[i].getAttribute('shiftZero');
                        if (typeof attr !== 'undefined' && attr !== null)
                            this.shiftDescriptionAxisZeroX = attr;
                        attr = x[i].getAttribute('widthAxisArrow');
                        if (typeof attr !== 'undefined' && attr !== null)
                            this.descriptionXWidthAxisArrow = attr;
                        attr = x[i].getAttribute('rangeIncludeZero');
                        if (typeof attr !== 'undefined' && attr !== null)
                        {
                            if ((attr === 'Yes' || attr === 'yes' || attr === 'True' || attr === 'true'))
                                this.descriptionXRangeIncludeZero = true;
                            else
                                this.descriptionXRangeIncludeZero = false;
                        }
                        attr = x[i].getAttribute('auto');
                        if (typeof attr !== 'undefined' && attr !== null)
                        {
                            if ((attr === 'Yes' || attr === 'yes' || attr === 'True' || attr === 'true'))
                                this.autoDescriptionX = true;
                            else
                                this.autoDescriptionX = false;
                        }
                    }
                    if(x[i].nodeName === 'YDescription')
                    {
                        res = this.ReadXMLText2(x[i],'y',this.descriptionAxisYText);
                        this.descriptionAxisY = res[0];
                        this.descriptionAxisYText = res[1];
                        attr = x[i].getAttribute('shift');
                        if (typeof attr !== 'undefined' && attr !== null)
                            this.shiftDescriptionAxisY = attr;
                        attr = x[i].getAttribute('shiftZero');
                        if (typeof attr !== 'undefined' && attr !== null)
                            this.shiftDescriptionAxisZeroY = attr;
                        attr = x[i].getAttribute('widthAxisArrow');
                        if (typeof attr !== 'undefined' && attr !== null)
                            this.descriptionYWidthAxisArrow = attr;
                        attr = x[i].getAttribute('rangeIncludeZero');
                        if (typeof attr !== 'undefined' && attr !== null)
                        {
                            if ((attr === 'Yes' || attr === 'yes' || attr === 'True' || attr === 'true'))
                                this.descriptionYRangeIncludeZero = true;
                            else
                                this.descriptionYRangeIncludeZero = false;
                        }
                        attr = x[i].getAttribute('auto');
                        if (typeof attr !== 'undefined' && attr !== null)
                        {
                            if ((attr === 'Yes' || attr === 'yes' || attr === 'True' || attr === 'true'))
                                this.autoDescriptionY = true;
                            else
                                this.autoDescriptionY = false;
                        }
                    }
                    if(x[i].nodeName === 'DescriptionSeparator')
                    {
                        this.descriptionSeparator = this.ReadXMLText(x[i],this.descriptionSeparator);
                    }
                    if(x[i].nodeName === 'Legend')
                    {
                        obj = objM.newObject('TChartLegend_');
                        if (typeof obj !== 'undefined' && obj !== null)
                        {
                            if (this.chartDefaultLanguage != null)
                                obj.SetChartDefaultLanguage(this.chartDefaultLanguage);
                            obj.ReadXML(x[i],this.GetVariables());
                            this.legend = obj;
                        }                    
                    }
                }
            }
        }
        this.Recalculate();
    };

    TChart_.prototype.ActualizeActions = function(){
        TFigure_.prototype.ActualizeActions.call(this);
/*        if (this.table !== null)
            this.table.ActualizeActions();*/
    };

    TChart_.prototype.Recalculate = function(){
        TFigure_.prototype.Recalculate.call(this);
        var objM = this.GetObjectManager();
        if (objM !== null && this.nameObjectChart != null)
        {
            var fig;
            fig = objM.newObject(this.nameObjectChart);
            if (fig !== null)
            {
                fig.SetWidth(this.CalculateValue(this.width));
                fig.SetHeight(this.CalculateValue(this.height));
                fig.SetFontSize(this.fontSize);
                fig.SetFont(this.font);
                fig.SetFontStyle(this.fontStyle);                
                fig.SetAxisLineWidth(this.axisLineWidth);
                fig.SetAxisArrowWidth(this.axisArrowWidth);
                fig.SetAxisArrowHeight(this.axisLineWidth);
                fig.SetAxisTypeArrow(this.axisTypeArrow);
                fig.SetX(this.CalculateValue(this.x));
                fig.SetY(this.CalculateValue(this.y));
                fig.SetXMin(this.CalculateValue(this.xMin));
                fig.SetXMax(this.CalculateValue(this.xMax));
                fig.SetYMin(this.CalculateValue(this.yMin));
                fig.SetYMax(this.CalculateValue(this.yMax));
                fig.SetAxisXZero(this.axisXZero);
                fig.SetAxisYZero(this.axisYZero);
                fig.SetAxisXYN(this.axisXYN);
                fig.SetAxisYYN(this.axisYYN);
                fig.SetScaleAxisXYN(this.scaleAxisXYN);
                fig.SetScaleAxisYYN(this.scaleAxisYYN);
                fig.SetProportionalScaleAxisYN(this.proportionalScaleAxisYN);
                fig.SetDescriptionLineWidth(this.descriptionLineWidth);
                fig.SetSizeDescriptionLine(this.sizeDescriptionLine);
                fig.SetShiftDescriptionAxisX(this.shiftDescriptionAxisX);
                fig.SetShiftDescriptionAxisY(this.shiftDescriptionAxisY);
                fig.SetShiftDescriptionAxisZeroX(this.shiftDescriptionAxisZeroX);
                fig.SetShiftDescriptionAxisZeroY(this.shiftDescriptionAxisZeroY);
                fig.SetShiftDescriptionAxisY(this.shiftDescriptionAxisY);
                fig.SetDescriptionFontSize(this.descriptionFontSize);
                fig.SetDescriptionFont(this.descriptionFont);
                fig.SetDescriptionFontStyle(this.descriptionFontStyle);
                fig.SetDescriptionAxisX(this.descriptionAxisX);
                fig.SetDescriptionAxisXTextTXT(this.descriptionAxisXText);
                fig.SetDescriptionXWidthAxisArrow(parseFloat(this.descriptionXWidthAxisArrow));
                fig.SetDescriptionXRangeIncludeZero(this.descriptionXRangeIncludeZero);
                fig.SetAutoDescriptionX(this.autoDescriptionX);
                fig.SetDescriptionAxisY(this.descriptionAxisY);
                fig.SetDescriptionAxisYTextTXT(this.descriptionAxisYText);
                fig.SetDescriptionYWidthAxisArrow(parseFloat(this.descriptionYWidthAxisArrow));
                fig.SetDescriptionYRangeIncludeZero(this.descriptionYRangeIncludeZero);
                fig.SetAutoDescriptionY(this.autoDescriptionY);
                fig.SetDescriptionSeparator(this.descriptionSeparator);
                fig.SetXLabel(this.xLabel);
                fig.SetShiftXLabel(this.shiftXLabel);
                fig.SetYLabel(this.yLabel);
                fig.SetShiftYLabel(this.shiftYLabel);
                var i,ch,colour,legend_;
                if (this.chartType  !== null)
                {
                    for (i = 0;i < this.charts.length;i++)
                    {
                        if (typeof this.charts[i] !== 'undefined' && this.charts[i] !== null)
                        {
                            if (this.charts[i].IsType('TLineChart_') || this.charts[i].IsType('TPointChart_') || this.charts[i].IsType('TBarChart_'))
                            {
                                if (this.charts[i].IsType('TLineChart_'))
                                    ch = objM.newObject('T' + this.chartType + 'LineChart');
                                if (this.charts[i].IsType('TPointChart_'))
                                    ch = objM.newObject('T' + this.chartType + 'PointChart');
                                if (this.charts[i].IsType('TBarChart_'))
                                    ch = objM.newObject('T' + this.chartType + 'BarChart');
                                ch.SetX(this.CalculateValue(this.charts[i].GetX()));
                                ch.SetY(this.CalculateValue(this.charts[i].GetY()));
                                ch.SetWidth(this.CalculateValue(this.width));
                                ch.SetHeight(this.CalculateValue(this.height));
                                ch.SetXMin(this.CalculateValue(this.xMin));
                                ch.SetXMax(this.CalculateValue(this.xMax));
                                ch.SetYMin(this.CalculateValue(this.yMin));
                                ch.SetYMax(this.CalculateValue(this.yMax));
                                ch.SetShiftX(this.CalculateValue(this.x));
                                ch.SetShiftY(this.CalculateValue(this.y));
				ch.SetScaleAxisXYN(this.scaleAxisXYN);
				ch.SetScaleAxisYYN(this.scaleAxisYYN);
				ch.SetProportionalScaleAxisYN(this.proportionalScaleAxisYN);
                                colour = this.charts[i].GetColour();
                                if (colour != null)
                                    ch.SetLineColour(colour.GetColour(this.variables));
                                if (this.charts[i].IsType('TPointChart_') || this.charts[i].IsType('TBarChart_'))
                                {
                                    colour = this.charts[i].GetBackgroundColour();
                                    if (colour != null)
                                        ch.SetBackgroundColour(colour.GetColour(this.variables));                                    
                                }
                                ch.SetLineWidth(this.CalculateValue(this.charts[i].GetLineWidth()));
                                this.charts[i].Recalculate(ch);
//                                ch.SetX(this.CalculateValue(this.descriptionAxisY));
                                fig.AddChart(ch);
                            }
                        }
                    }
                }
                if (typeof this.legend !== 'undefined' && this.legend !== null &&this.legend.IsType('TChartLegend_'))
                {
                    legend_ = objM.newObject('T' + this.chartType + 'ChartLegend');
                    legend_.SetX(this.CalculateValue(this.x) + this.CalculateValue(this.legend.GetX()));
                    legend_.SetY(this.CalculateValue(this.y) + this.CalculateValue(this.legend.GetY()));
                    this.legend.Recalculate(legend_,fig.GetCharts());
                    fig.SetLegend(legend_);
                }
                
//                SetDescriptionAxisX
                this.SetFigure(fig);
            }
            
        }
    };    

    TChart_.prototype.SetFont = function(font_){
        if (typeof font_ !== 'undefined' && font_ !== null)
        {
            this.font = new String(font_);
            if (this.font !== null)
                this.font = this.font.toString();
        }
        if (font_ === null)
            this.font = null;
    };

    TChart_.prototype.SetFontStyle = function(fontStyle_){
        if (typeof fontStyle_ !== 'undefined' && fontStyle_ !== null)
        {
            this.fontStyle = new String(fontStyle_);
            if (this.fontStyle !== null)
                this.fontStyle = this.fontStyle.toString();
        }
    };

    TChart_.prototype.SetFontSize = function(size_){
        if (typeof size_ !== 'undefined' && size_ !== null)
        {
            this.fontSize = new String(size_);
            if (this.fontSize !== null)
                this.fontSize = this.fontSize.toString();
        }
    };

    TChart_.prototype.ChangeCurrentLanguageNumber = function(_language){
        TFigure_.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        var i;
        if (typeof this.legend !== 'undefined' && this.legend !== null && this.legend.IsType('TChartLegend_'))
            this.legend.ChangeCurrentLanguageNumber(_language);
        if (typeof this.xLabel !== 'undefined' && this.xLabel !== null && this.xLabel.IsType('TPageElement'))
            this.xLabel.ChangeCurrentLanguageNumber(_language);
        if (typeof this.yLabel !== 'undefined' && this.yLabel !== null && this.yLabel.IsType('TPageElement'))
            this.yLabel.ChangeCurrentLanguageNumber(_language);
        if (typeof this.descriptionAxisXText !== 'undefined' && this.descriptionAxisXText !== null )
        {
            for (i = 0;i < this.descriptionAxisXText.length;i++)
            {
                if (typeof this.descriptionAxisXText[i] !== 'undefined' && this.descriptionAxisXText[i] !== null && this.descriptionAxisXText[i].IsType('TPageElement'))
                    this.descriptionAxisXText[i].ChangeCurrentLanguageNumber(_language);
            }
        }
        if (typeof this.descriptionAxisYText !== 'undefined' && this.descriptionAxisYText !== null )
        {
            for (i = 0;i < this.descriptionAxisYText.length;i++)
            {
                if (typeof this.descriptionAxisYText[i] !== 'undefined' && this.descriptionAxisYText[i] !== null && this.descriptionAxisYText[i].IsType('TPageElement'))
                    this.descriptionAxisYText[i].ChangeCurrentLanguageNumber(_language);
            }
        }
        this.Recalculate();
/*        var i;
        if (typeof this.charts !== 'undefined' && this.charts !== null)
        {
            for (i = 0;i < this.charts.length;i++)
                this.charts[i].ChangeCurrentLanguageNumber(_language);
        }*/
    };

    TChart_.prototype.GetAxisXYN = function(){
        return this.axisXYN;
    };

    TChart_.prototype.GetAxisYYN = function(){
        return this.axisYYN;
    };

    TChart_.prototype.GetScaleAxisXYN = function(){
        return this.scaleAxisXYN;
    };

    TChart_.prototype.GetScaleAxisYYN = function(){
        return this.scaleAxisYYN;
    };

    TChart_.prototype.GetProportionalScaleAxisYN = function(){
        return this.proportionalScaleAxisYN;
    };

};

TChart_.prototype = new TFigure_();


function TThreeLocaleFigure(){
    var type = 'TThreeLocaleFigure';
    TThreeLocaleFigure.prototype.InitConstructor = function(){
        TLocaleFigure.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.x = null;
        this.y = null;
        this.z = null;
        this.alpha = null;
        this.beta = null;
        this.gamma = null;
        this.scaleX = null;
        this.scaleY = null;
        this.scaleZ = null;
    };
    this.InitConstructor();

    TThreeLocaleFigure.prototype.Init = function(_object){
        TLocaleFigure.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TThreeLocaleFigure'))
        {
            if (typeof _object.x !== 'undefined' && _object.x !== null)
            {
                this.x = new String(_object.x);
                if (this.x !== null)
                    this.x = this.x.toString();
            }
            if (typeof _object.y !== 'undefined' && _object.y !== null)
            {
                this.y = new String(_object.y);
                if (this.y !== null)
                    this.y = this.y.toString();
            }
            if (typeof _object.z !== 'undefined' && _object.z !== null)
            {
                this.z = new String(_object.z);
                if (this.z !== null)
                    this.z = this.z.toString();
            }
            if (typeof _object.alpha !== 'undefined' && _object.alpha !== null)
            {
                this.alpha = new String(_object.alpha);
                if (this.alpha !== null)
                    this.alpha = this.alpha.toString();
            }
            if (typeof _object.beta !== 'undefined' && _object.beta !== null)
            {
                this.beta = new String(_object.beta);
                if (this.beta !== null)
                    this.beta = this.beta.toString();
            }
            if (typeof _object.gamma !== 'undefined' && _object.gamma !== null)
            {
                this.gamma = new String(_object.gamma);
                if (this.gamma !== null)
                    this.gamma = this.gamma.toString();
            }
            if (typeof _object.scaleX !== 'undefined' && _object.scaleX !== null)
            {
                this.scaleX = new String(_object.scaleX);
                if (this.scaleX !== null)
                    this.scaleX = this.scaleX.toString();
            }
            if (typeof _object.scaleY !== 'undefined' && _object.scaleY !== null)
            {
                this.scaleY = new String(_object.scaleY);
                if (this.scaleY !== null)
                    this.scaleY = this.scaleY.toString();
            }
            if (typeof _object.scaleZ !== 'undefined' && _object.scaleZ !== null)
            {
                this.scaleZ = new String(_object.scaleZ);
                if (this.scaleZ !== null)
                    this.scaleZ = this.scaleZ.toString();
            }
        }
    };

    TThreeLocaleFigure.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TLocaleFigure.prototype.IsType.call(this,_type);
    };

    TThreeLocaleFigure.prototype.SetX = function(x_){
        if (typeof x_ !== 'undefined' && x_ !== null)
        {
            this.x = new String(x_);
            if (this.x !== null)
                this.x = this.x.toString();
        }
        if (x_ === null)
            this.x = null;
    };

    TThreeLocaleFigure.prototype.GetX = function(){
        var tmp = new String(this.x);
        if (tmp !== null)
            return tmp.toString();
        return tmp;
    };

    TThreeLocaleFigure.prototype.SetY = function(y_){
        if (typeof y_ !== 'undefined' && y_ !== null)
        {
            this.y = new String(y_);
            if (this.y !== null)
                this.y = this.y.toString();
        }
        if (y_ === null)
            this.y = null;
    };

    TThreeLocaleFigure.prototype.GetY = function(){
        var tmp = new String(this.y);
        if (tmp !== null)
            return tmp.toString();
        return tmp;
    };

    TThreeLocaleFigure.prototype.SetZ = function(z_){
        if (typeof z_ !== 'undefined' && z_ !== null)
        {
            this.z = new String(z_);
            if (this.z !== null)
                this.z = this.z.toString();
        }
        if (z_ === null)
            this.z = null;
    };

    TThreeLocaleFigure.prototype.GetZ = function(){
        var tmp = new String(this.z);
        if (tmp !== null)
            return tmp.toString();
        return tmp;
    };

    TThreeLocaleFigure.prototype.SetAlpha = function(alpha_){
        if (typeof alpha_ !== 'undefined' && alpha_ !== null)
        {
            this.alpha = new String(alpha_);
            if (this.alpha !== null)
                this.alpha = this.alpha.toString();
        }
        if (alpha_ === null)
            this.alpha = null;
    };

    TThreeLocaleFigure.prototype.GetAlpha = function(){
        var tmp = new String(this.alpha);
        if (tmp !== null)
            return this.CalculateValue(tmp.toString())*Math.PI/180;
        return tmp;
    };

    TThreeLocaleFigure.prototype.SetBeta = function(beta_){
        if (typeof beta_ !== 'undefined' && beta_ !== null)
        {
            this.beta = new String(beta_);
            if (this.beta !== null)
                this.beta = this.beta.toString();
        }
        if (beta_ === null)
            this.beta = null;
    };

    TThreeLocaleFigure.prototype.GetBeta = function(){
        var tmp = new String(this.beta);
        if (tmp !== null)
            return this.CalculateValue(tmp.toString())*Math.PI/180;
        return tmp;
    };

    TThreeLocaleFigure.prototype.SetGamma = function(gamma_){
        if (typeof gamma_ !== 'undefined' && gamma_ !== null)
        {
            this.gamma = new String(gamma_);
            if (this.gamma !== null)
                this.gamma = this.gamma.toString();
        }
        if (gamma_ === null)
            this.gamma = null;
    };

    TThreeLocaleFigure.prototype.GetGamma = function(){
        var tmp = new String(this.gamma);
        if (tmp !== null)
            return this.CalculateValue(tmp.toString())*Math.PI/180;
        return tmp;
    };

    TThreeLocaleFigure.prototype.SetScaleX = function(scale){
        if (typeof scale !== 'undefined' && scale !== null)
        {
            this.scaleX = new String(scale);
            if (this.scaleX !== null)
                this.scaleX = this.scaleX.toString();
        }
        if (scale === null)
            this.scaleX = null;
    };

    TThreeLocaleFigure.prototype.GetScaleX = function(){
        var tmp = new String(this.scaleX);
        if (tmp !== null)
            return tmp.toString();
        return tmp;
    };

    TThreeLocaleFigure.prototype.SetScaleY = function(scale){
        if (typeof scale !== 'undefined' && scale !== null)
        {
            this.scaleY = new String(scale);
            if (this.scaleY !== null)
                this.scaleY = this.scaleY.toString();
        }
        if (scale === null)
            this.scaleY = null;
    };

    TThreeLocaleFigure.prototype.GetScaleY = function(){
        var tmp = new String(this.scaleY);
        if (tmp !== null)
            return tmp.toString();
        return tmp;
    };

    TThreeLocaleFigure.prototype.SetScaleZ = function(scale){
        if (typeof scale !== 'undefined' && scale !== null)
        {
            this.scaleZ = new String(scale);
            if (this.scaleZ !== null)
                this.scaleZ = this.scaleZ.toString();
        }
        if (scale === null)
            this.scaleZ = null;
    };

    TThreeLocaleFigure.prototype.GetScaleZ = function(){
        var tmp = new String(this.scaleZ);
        if (tmp !== null)
            return tmp.toString();
        return tmp;
    };

    TThreeLocaleFigure.prototype.SetScale = function(scale){
        if (typeof scale !== 'undefined' && scale !== null)
        {
            this.scaleX = new String(scale);
            if (this.scaleX !== null)
                this.scaleX = this.scaleX.toString();
            this.scaleY = new String(scale);
            if (this.scaleY !== null)
                this.scaleY = this.scaleY.toString();
            this.scaleZ = new String(scale);
            if (this.scaleZ !== null)
                this.scaleZ = this.scaleZ.toString();
        }
        if (scale === null)
        {
            this.scaleX = null;
            this.scaleY = null;
            this.scaleZ = null;
        }
    };

    TThreeLocaleFigure.prototype.ParseXML = function(tag1,tag2){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var attr;
            attr = tag1.getAttribute('x');
            if (typeof attr !== 'undefined' && attr !== null)
                this.x = attr;
            attr = tag1.getAttribute('y');
            if (typeof attr !== 'undefined' && attr !== null)
                this.y = attr;
            attr = tag1.getAttribute('z');
            if (typeof attr !== 'undefined' && attr !== null)
                this.z = attr;
            attr = tag1.getAttribute('alpha');
            if (typeof attr !== 'undefined' && attr !== null)
                this.alpha = attr;
            attr = tag1.getAttribute('beta');
            if (typeof attr !== 'undefined' && attr !== null)
                this.beta = attr;
            attr = tag1.getAttribute('gamma');
            if (typeof attr !== 'undefined' && attr !== null)
                this.gamma = attr;
            attr = tag1.getAttribute('scaleX');
            if (typeof attr !== 'undefined' && attr !== null)
                this.scaleX = attr;
            attr = tag1.getAttribute('scaleY');
            if (typeof attr !== 'undefined' && attr !== null)
                this.scaleY = attr;
            attr = tag1.getAttribute('scaleZ');
            if (typeof attr !== 'undefined' && attr !== null)
                this.scaleZ = attr;
            attr = tag1.getAttribute('scale');
            if (typeof attr !== 'undefined' && attr !== null)
                this.SetScale(attr);
        }
    };
};

TThreeLocaleFigure.prototype = new TLocaleFigure();


function TThreeText_(){
    var type = 'TThreeText_';
    TThreeText_.prototype.InitConstructor = function(){
        TThreeLocaleFigure.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.element = [];
        this.colourText = null;
        this.colourSide = null;
        this.fontSize = '1';
        this.font = 'Arial';
        this.alignmentX = 'center';
        this.alignmentY = 'center';
        this.curveSegments = '1';
        this.height = '0.1';
        this.style = 'normal';
        this.weight = 'normal';
    };
    this.InitConstructor();

    TThreeText_.prototype.Init = function(_object){
        TThreeLocaleFigure.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TThreeText_'))
        {
            var i;
            if (typeof _object.element !== 'undefined' && _object.element !== null)
            {
                for (i = 0;i < _object.element.length;i++)
                {
                    if (typeof _object.element[i] !== 'undefined' && _object.element[i] !== null && _object.element[i].IsType('TParagraphElement'))
                        this.element[i] = objM.copy(_object.element[i]);
                }
            }
            if (typeof _object.colourText !== 'undefined' && _object.colourText !== null && _object.colourText.IsType('TColourRGBA'))
                this.colourText = objM.copy(_object.colourText);
            if (typeof _object.colourSide !== 'undefined' && _object.colourSide !== null && _object.colourSide.IsType('TColourRGBA'))
                this.colourSide = objM.copy(_object.colourSide);
            if (typeof _object.font !== 'undefined' && _object.font !== null)
            {
                this.font = new String(_object.font);
                if (this.font !== null)
                    this.font = this.font.toString();
            }
            if (typeof _object.alignmentX !== 'undefined' && _object.alignmentX !== null)
            {
                this.alignmentX = new String(_object.alignmentX);
                if (this.alignmentX !== null)
                    this.alignmentX = this.alignmentX.toString();
            }
            if (typeof _object.alignmentY !== 'undefined' && _object.alignmentY !== null)
            {
                this.alignmentY = new String(_object.alignmentY);
                if (this.alignmentY !== null)
                    this.alignmentY = this.alignmentY.toString();
            }
            if (typeof _object.fontSize !== 'undefined' && _object.fontSize !== null)
            {
                this.fontSize = new String(_object.fontSize);
                if (this.fontSize !== null)
                    this.fontSize = this.fontSize.toString();
            }
            if (typeof _object.height !== 'undefined' && _object.height !== null)
            {
                this.height = new String(_object.height);
                if (this.height !== null)
                    this.height = this.height.toString();
            }
            if (typeof _object.curveSegments !== 'undefined' && _object.curveSegments !== null)
            {
                this.curveSegments = new String(_object.curveSegments);
                if (this.curveSegments !== null)
                    this.curveSegments = this.curveSegments.toString();
            }
            if (typeof _object.style !== 'undefined' && _object.style !== null)
            {
                this.style = new String(_object.style);
                if (this.style !== null)
                    this.style = this.style.toString();
            }
            if (typeof _object.weight !== 'undefined' && _object.weight !== null)
            {
                this.weight = new String(_object.weight);
                if (this.weight !== null)
                    this.weight = this.weight.toString();
            }
        }
    };

    TThreeText_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TThreeLocaleFigure.prototype.IsType.call(this,_type);
    };
    
    TThreeText_.prototype.ParseXML = function(tag1,tag2){
        TThreeLocaleFigure.prototype.ParseXML.call(this,tag1,tag2);
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var i,attr;
            attr = tag1.getAttribute('fontSize');
            if (typeof attr !== 'undefined' && attr !== null)
                this.fontSize = attr;
            attr = tag1.getAttribute('font');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                this.font = attr;
            }
            attr = tag1.getAttribute('alignmentX');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                this.alignmentX = attr;
            }
            attr = tag1.getAttribute('alignmentY');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                this.alignmentY = attr;
            }
            attr = tag1.getAttribute('curveSegments');
            if (typeof attr !== 'undefined' && attr !== null)
                this.curveSegments = attr;
            attr = tag1.getAttribute('fontHeight');
            if (typeof attr !== 'undefined' && attr !== null)
                this.height = attr;


/*            this.coordinates = objM.newObject('TVector3DT');
            if (this.coordinates !== null)
            {
                this.coordinates.SetCoordinates(x,y,z);
            }*/

            var i,x_ = tag2.childNodes,attr,k;

            for (i = 0,k=0;i < x_.length;i++)
            {
                if (x_[i].nodeType === 3)
                {
                    if (this.element.length <= k || typeof this.element[k] === 'undefined' || this.element[k] === null)
                    {
                        this.element[k] = objM.newObject('TParagraphString');
                    }
                    if (this.element.length > k && typeof this.element[k] !== 'undefined' && this.element[k] !== null)
                    {
                        this.element[k++].ParseXML(x_[i]);
                    }
                }
            }
            
            var fig = this.GetFigure();
            if (fig === null)
            {
                fig = objM.newObject('TThreeText');
                this.SetFigure(fig);
            }
        }
    };


    TThreeText_.prototype.DrawFigure = function(ctx){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
//            ctx.SetScaleTextYN(this.scaleTextYN);
            var i,txt = '';
            for (i = 0;i < this.element.length;i++)
            {
                if (typeof this.element[i] !== 'undefined' && this.element[i] !== null)
                    txt = txt + this.element[i].GetStringData();
            }
            var obj = this.GetFigure();
            if (typeof obj !== 'undefined' && obj !== null)
            {
                obj.SetText(txt);
                var coord = objM.newObject('TVector3DT');
                if (coord !== null)
                {
                    coord.SetX(this.CalculateValue(this.GetX()));
                    coord.SetY(this.CalculateValue(this.GetY()));
                    coord.SetZ(this.CalculateValue(this.GetZ()));
                    obj.SetCoordinates(coord);
                }
                obj.SetAlpha(this.GetAlpha());
                obj.SetBeta(this.GetBeta());
                obj.SetGamma(this.GetGamma());
                obj.SetScaleX(this.GetScaleX());
                obj.SetScaleY(this.GetScaleY());
                obj.SetScaleZ(this.GetScaleZ());
                obj.SetFontSize(this.CalculateValue(this.fontSize));
                obj.SetHeight(this.CalculateValue(this.height));
                obj.SetCurveSegments(this.CalculateValue(this.curveSegments));
                obj.SetColourText(this.colourText);
                obj.SetSideColourText(this.colourSide);
                obj.SetFont(this.font);
                obj.SetFontStyle(this.style);
                obj.SetFontWeight(this.weight);
                obj.SetAlignX(this.alignmentX);
                obj.SetAlignY(this.alignmentY);
//                obj.SetScaleTextYN(this.scaleTextYN);
 //               obj.SetFontSize(this.fontSize);
 //               obj.SetFontRelativeSize(this.fontRelativeSize);
 //               obj.SetFont(this.font);
  //              obj.SetAlignmentX(this.alignmentX);
  //              obj.SetAlignmentY(this.alignmentY);
            }
            
/*            var drawHtml = objM.newObject('THTMLObject');
            if (drawHtml !== null)
            {
                drawHtml.SetTypeDrawObject('THTMLParagraphs');
                this.paragraph.Draw(drawHtml);
                var txt = drawHtml.GetTXT();
                var obj = this.GetFigure();
                if (obj !== null)
                {
                    obj.SetText(null,txt);
                }
            }*/
//            ctx.SetDefaultTextColour(this.colourText);
        }
        TThreeLocaleFigure.prototype.DrawFigure.call(this,ctx);
    };

/*    TText_.prototype.Draw = function(ctx){
        if (typeof ctx !== 'undefined' && ctx !== null && ctx.IsType('TDrawContext'))
        {
            ctx.SetScaleTextYN(this.scaleTextYN);
            TThreeLocaleFigure.prototype.Draw.call(this,ctx);
        }
    };*/


    TThreeText_.prototype.ChangeCurrentLanguageNumber = function(_language){
        TThreeLocaleFigure.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        if (typeof this.element !== 'undefined' && this.element !== null)
        {
            var i;
            for (i = 0;i < this.element.length;i++)
                if (this.element[i] !== null)
                    this.element[i].ChangeCurrentLanguageNumber(_language);
        }
    };

    TThreeText_.prototype.SetColourText = function(r,g,b,a){
        var objM = this.GetObjectManager();
        if (objM !== null && (typeof this.colourText === 'undefined' || this.colourText === null))
            this.colourText = objM.newObject('TColourRGBA');
        
        if (typeof this.colourText !== 'undefined' && this.colourText !== null)
            this.colourText.SetColourRGBA(r,g,b,a);
        
    };

    TThreeText_.prototype.SetSideColourText = function(r,g,b,a){
        var objM = this.GetObjectManager();
        if (objM !== null && (typeof this.colourSide === 'undefined' || this.colourSide === null))
            this.colourSide = objM.newObject('TColourRGBA');
        
        if (typeof this.colourSide !== 'undefined' && this.colourSide !== null)
            this.colourSide.SetColourRGBA(r,g,b,a);
        
    };

    TThreeText_.prototype.SetFont = function(font_){
        if (typeof font_ !== 'undefined' && font_ !== null)
        {
            this.font = new String(font_);
            if (this.font !== null)
                this.font = this.font.toString();
        }
        if (font_ === null)
            this.font = null;
    };

    TThreeText_.prototype.SetFontStyle = function(style_){
        if (typeof style_ !== 'undefined' && style_ !== null)
        {
            this.style = new String(style_);
            if (this.style !== null)
                this.style = this.style.toString();
        }
    };

    TThreeText_.prototype.SetFontWeight = function(weight_){
        if (typeof weight_ !== 'undefined' && weight_ !== null)
        {
            this.weight = new String(weight_);
            if (this.weight !== null)
                this.weight = this.weight.toString();
        }
    };

    TThreeText_.prototype.SetFontSize = function(size_){
        if (typeof size_ !== 'undefined' && size_ !== null)
        {
            this.fontSize = new String(size_);
            if (this.fontSize !== null)
                this.fontSize = this.fontSize.toString();
        }
    };

    TThreeText_.prototype.SetCurveSegments = function(segm){
        if (typeof segm !== 'undefined' && segm !== null)
        {
            this.curveSegments = new String(segm);
            if (this.curveSegments !== null)
                this.curveSegments = this.curveSegments.toString();
        }
    };

    TThreeText_.prototype.SetColourTextRGBA = function(c){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof c !== 'undefined' && c !== null && c.IsType('TColourRGBA'))
            this.colourText = objM.copy(c);
        if (c === null)
            this.colourText = null;
    };

    TThreeText_.prototype.SetColourSideTextRGBA = function(c){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof c !== 'undefined' && c !== null && c.IsType('TColourRGBA'))
            this.colourSide = objM.copy(c);
        if (c === null)
            this.colourSide = null;
    };

};

TThreeText_.prototype = new TThreeLocaleFigure();


function TThreeHTML_(){
    var type = 'TThreeHTML_';
    TThreeHTML_.prototype.InitConstructor = function(){
        TLocaleFigure.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.pragraph = null;
        this.x = null;
        this.y = null;
        this.z = null;
    };
    this.InitConstructor();

    TThreeHTML_.prototype.Init = function(_object){
        TLocaleFigure.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TThreeHTML_'))
        {
            var i;
            if (typeof _object.pragraph !== 'undefined' && _object.pragraph !== null && _object.pragraph.IsType('TParagraph'))
            {
                this.pragraph = objM.copy(_object.pragraph);
            }
            if (typeof _object.x !== 'undefined' && _object.x !== null)
            {
                this.x = new String(_object.x);
                if (this.x !== null)
                    this.x = this.x.toString();
            }
            if (typeof _object.y !== 'undefined' && _object.y !== null)
            {
                this.y = new String(_object.y);
                if (this.y !== null)
                    this.y = this.y.toString();
            }
            if (typeof _object.z !== 'undefined' && _object.z !== null)
            {
                this.z = new String(_object.z);
                if (this.z !== null)
                    this.z = this.z.toString();
            }
        }
    };

    TThreeHTML_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TLocaleFigure.prototype.IsType.call(this,_type);
    };
    
    TThreeHTML_.prototype.ParseXML = function(tag1,tag2){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var i,attr;
            attr = tag1.getAttribute('x');
            if (typeof attr !== 'undefined' && attr !== null)
                this.x = attr;
            attr = tag1.getAttribute('y');
            if (typeof attr !== 'undefined' && attr !== null)
                this.y = attr;
            attr = tag1.getAttribute('z');
            if (typeof attr !== 'undefined' && attr !== null)
                this.z = attr;

            this.pragraph = objM.newObject('TParagraph');
            if (this.pragraph !== null)
                this.pragraph.ParseXML(tag1,tag2);

            var fig = this.GetFigure();
            if (fig === null)
            {
                fig = objM.newObject('TThreeHTML');
                this.SetFigure(fig);
            }
        }
    };


    TThreeHTML_.prototype.DrawFigure = function(ctx){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
/*            var i,txt = '';
            for (i = 0;i < this.element.length;i++)
            {
                if (typeof this.element[i] !== 'undefined' && this.element[i] !== null)
                    txt = txt + this.element[i].GetStringData();
            }*/
            var obj = this.GetFigure();
            if (obj !== null)
            {
//                obj.SetHTML(txt);
                var coord = objM.newObject('TVector3DT');
                if (coord !== null)
                {
                    coord.SetX(this.CalculateValue(this.x));
                    coord.SetY(this.CalculateValue(this.y));
                    coord.SetZ(this.CalculateValue(this.z));
                    obj.SetCoordinates(coord);
                }
            }
            
        }
        TLocaleFigure.prototype.DrawFigure.call(this,ctx);
    };

    TThreeHTML_.prototype.ChangeCurrentLanguageNumber = function(_language){
        TLocaleFigure.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        if (typeof this.element !== 'undefined' && this.element !== null)
        {
            if (this.pragraph !== null)
                this.pragraph.ChangeCurrentLanguageNumber(_language);
        }
    };

};

TThreeHTML_.prototype = new TLocaleFigure();

function TDrawImage_(){
    var type = 'TDrawImage_';
    TDrawImage_.prototype.InitConstructor = function(){
        TLocaleFigure.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.fileName = null;
        this.imageCatalog = null;
        this.varImage = null;
    };
    this.InitConstructor();

    TDrawImage_.prototype.Init = function(_object){
        TLocaleFigure.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TDrawImage_'))
        {
            if (typeof _object.fileName !== 'undefined' && _object.fileName !== null && _object.fileName.IsType('TImageFileName'))
                this.fileName = objM.copy(_object.fileName);
            if (typeof _object.imageCatalog !== 'undefined' && _object.imageCatalog !== null)
            {
                this.imageCatalog = new String(_object.imageCatalog);
                if (this.imageCatalog !== null)
                    this.imageCatalog = this.imageCatalog.toString();
            }
            if (typeof _object.varImage !== 'undefined' && _object.varImage !== null)
            {
                this.varImage = new String(_object.varImage);
                if (this.varImage !== null)
                    this.varImage = this.varImage.toString();
            }
        }
    };

    TDrawImage_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TLocaleFigure.prototype.IsType.call(this,_type);
    };
    
    TDrawImage_.prototype.ParseXML = function(tag1,tag2){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var i,obj,attr,x=0,y=0,z=0,coord,s=1,w=0,h=0,alignX='left',alignY='top';
            obj = objM.newObject('TDrawImage');
            if (obj !== null)
            {
                attr = this.CalculateValue(tag1.getAttribute('x'));
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        x = attr;
                }
                attr = this.CalculateValue(tag1.getAttribute('y'));
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        y = attr;
                }
                attr = this.CalculateValue(tag1.getAttribute('z'));
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        z = attr;
                }
                attr = tag1.getAttribute('scale');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        s = attr;
                }
                attr = tag1.getAttribute('width');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        w = attr;
                }
                attr = tag1.getAttribute('height');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        h = attr;
                }
                attr = tag1.getAttribute('alignX');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    alignX = attr;
                }
                attr = tag1.getAttribute('alignY');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    alignY = attr;
                }
                
                obj.SetScale(s);
                obj.SetAlignX(alignX);
                obj.SetAlignY(alignY);

                attr = tag1.getAttribute('scaleTikZ');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        obj.SetScaleTikZ(attr);
                }
                
                attr = tag1.getAttribute('varImage');
                if (typeof attr !== 'undefined' && attr !== null)
                    this.varImage = attr;
                
                coord = objM.newObject('TVector3DT');
                if (coord !== null)
                {
                    coord.SetCoordinates(x,y,z);
                    obj.SetVerticle(0,coord);
                }
                coord = objM.newObject('TVector3DT');
                if (coord !== null)
                {
                    coord.SetCoordinates(s*w + x,s*h + y);
                    obj.SetVerticle(1,coord);
//                    obj.SetWidthHeight(coord);
                }

                var x_ = tag2.childNodes;

                for (i = 0;i < x_.length;i++)
                {
                    if (x_[i].nodeType === 1 && x_[i].nodeName === 'Image')
                    {
                        if (typeof this.fileName === 'undefined' || this.fileName === null)
                        {
                            this.fileName = objM.newObject('TImageFileName');
                            if (this.fileName !== null)
                                this.fileName.SetCatalog(this.imageCatalog);
                        }
                        if (typeof this.fileName !== 'undefined' && this.fileName !== null)
                        {
                            this.fileName.ParseXML(tag1,tag2);
                        }
                    }
                }
                
                this.SetFigure(obj);

            }
            
        }
    };


    TDrawImage_.prototype.DrawFigure = function(ctx){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof this.fileName !== 'undefined' && this.fileName !== null && this.fileName.IsType('TObjectMultilanguage'))
        {
            var obj = this.GetFigure();
            if (typeof obj !== 'undefined' && obj !== null)
            {
                if (this.varImage !== null)
                {
                    var tmp = this.CalculateValue(this.varImage);
                    //this.FindVariable(this.varImage);
//                    tmp = tmp.GetTable();
                    obj.SetImage(tmp);
                }else
                {
                    var txt = this.fileName.GetFileNameString();
                    if (this.imageCatalog !== null)
                        txt = this.imageCatalog +'/' + txt;
                    obj.SetFileName(txt);
                    if (this.fileName.IsType('TImageFileName') && obj.IsType('TDrawImage'))
                    {
                        var img = this.fileName.GetImage();
                        obj.SetImage(img);
                    }
                }
            }
            
        }
        TLocaleFigure.prototype.DrawFigure.call(this,ctx);
    };


    TDrawImage_.prototype.ChangeCurrentLanguageNumber = function(_language){
        TLocaleFigure.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        if (typeof this.fileName !== 'undefined' && this.fileName !== null && this.fileName.IsType('TObjectMultilanguage'))
        {
            this.fileName.ChangeCurrentLanguageNumber(_language);
        }
    };

    TDrawImage_.prototype.SetImageCatalog = function(catalog){
        if (typeof catalog !== 'undefined' && catalog !== null)
        {
            this.imageCatalog = new String(catalog);
            this.imageCatalog = this.imageCatalog.toString();
            if (this.fileName !== 'undefined' && this.fileName !== null && this.fileName.IsType('TImageFileName'))
            {
                this.fileName.SetCatalog(catalog);
            }
        }
        if (catalog === null)
            this.imageCatalog = null;
    };

};

TDrawImage_.prototype = new TLocaleFigure();


function TGraph_(){
    var type = 'TGraph_';
    TGraph_.prototype.InitConstructor = function(){
        TObjectFigure.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.graph = null;
        this.text = [];
        this.codes = [];
        this.nCodes = 0;
        this.styleScaleTextYN = true;
        this.elementLineWidth = 1;
        this.elementLineType = 'solid';
        this.colourElementLine = null;
        this.colourElementBackground = null;
        this.elementBackgroundType = 'fill';
        this.connectorLineWidth = 1;
        this.beginArrowWidth = null;
        this.beginArrowHeight = null;
        this.endArrowWidth = null;
        this.endArrowHeight = null;
        this.nVerticles = null;
        this.elementTextStyle = [];
        this.connectorTextStyle = [];
        this.elementFontRelativeSize = 'normalsize';
        this.connectorFontRelativeSize = 'normalsize';
        this.colourElementText = null;
        this.colourConnectorText = null;
        this.colourConnectorLine = null;
        this.connectorTextAlignmentX = 'center';
        this.connectorTextAlignmentY = 'center';
        this.connectorLineType = 'solid';
        this.alignX = 'center';
        this.alignY = 'center';
        this.elementFont = null;
        this.connectorFont = null;
        this.coordText = null;
    };
    this.InitConstructor();

    TGraph_.prototype.Init = function(_object){
        TObjectFigure.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TGraph_'))
        {
            var i;
            if (typeof _object.graph !== 'undefined' && _object.graph !== null && _object.graph.IsType('TGraph'))
                this.graph = _object.graph;
            if (typeof _object.text !== 'undefined' && _object.text !== null)
            {
                for (i = 0;i < _object.text.length;i++)
                {
                    if (typeof _object.text[i] !== 'undefined' && _object.text[i] !== null && _object.text[i].IsType('TMultilanguageStringData'))
                        this.text[i] = objM.copy(_object.text[i]);
                }
            }
            if (typeof _object.nCodes !== 'undefined' && _object.nCodes !== null && IsInt(_object.nCodes))
                this.nCodes = _object.nCodes;
            if (typeof _object.codes !== 'undefined' && _object.codes !== null)
            {
                for (i = 0;i < _object.codes.length;i++)
                {
                    if (typeof _object.codes[i] !== 'undefined' && _object.codes[i] !== null)
                    {
                        this.codes[i] = new String(_object.codes[i]);
                        if (this.codes[i] !== null)
                            this.codes[i] = this.codes[i].toString();
                    }
                }
            }
            if (typeof _object.styleScaleTextYN !== 'undefined' && _object.styleScaleTextYN !== null)
                this.styleScaleTextYN = _object.styleScaleTextYN;
            if (typeof _object.elementLineWidth !== 'undefined' && _object.elementLineWidth !== null && IsNumeric(_object.elementLineWidth))
                this.elementLineWidth = _object.elementLineWidth;
            if (typeof _object.elementLineType !== 'undefined' && _object.elementLineType !== null)
            {
                this.elementLineType = new String(_object.elementLineType);
                if (this.elementLineType !== null)
                    this.elementLineType = this.elementLineType.toString();
            }
            if (typeof _object.connectorLineType !== 'undefined' && _object.connectorLineType !== null)
            {
                this.connectorLineType = new String(_object.connectorLineType);
                if (this.connectorLineType !== null)
                    this.connectorLineType = this.connectorLineType.toString();
            }
            if (typeof _object.elementBackgroundType !== 'undefined' && _object.elementBackgroundType !== null)
            {
                this.elementBackgroundType = new String(_object.elementBackgroundType);
                if (this.elementBackgroundType !== null)
                    this.elementBackgroundType = this.elementBackgroundType.toString();
            }
            if (typeof _object.connectorLineWidth !== 'undefined' && _object.connectorLineWidth !== null && IsNumeric(_object.connectorLineWidth))
                this.connectorLineWidth = _object.connectorLineWidth;
            if (typeof _object.beginArrowWidth !== 'undefined' && _object.beginArrowWidth !== null && IsNumeric(_object.beginArrowWidth))
                this.beginArrowWidth = _object.beginArrowWidth;
            if (typeof _object.beginArrowHeight !== 'undefined' && _object.beginArrowHeight !== null && IsNumeric(_object.beginArrowHeight))
                this.beginArrowHeight = _object.beginArrowHeight;
            if (typeof _object.endArrowWidth !== 'undefined' && _object.endArrowWidth !== null && IsNumeric(_object.endArrowWidth))
                this.endArrowWidth = _object.endArrowWidth;
            if (typeof _object.endArrowHeight !== 'undefined' && _object.endArrowHeight !== null && IsNumeric(_object.endArrowHeight))
                this.endArrowHeight = _object.endArrowHeight;
            if (typeof _object.nVerticles !== 'undefined' && _object.nVerticles !== null && IsInt(_object.nVerticles))
                this.nVerticles = _object.nVerticles;
            if (typeof _object.colourElementLine !== 'undefined' && _object.colourElementLine !== null && _object.colourElementLine.IsType('TColour'))
                this.colourElementLine = objM.copy(_object.colourElementLine);
            if (typeof _object.colourElementBackground !== 'undefined' && _object.colourElementBackground !== null && _object.colourElementBackground.IsType('TColour'))
                this.colourElementBackground = objM.copy(_object.colourElementBackground);
            if (typeof _object.elementTextStyle !== 'undefined' && _object.elementTextStyle !== null)
            {
                for (i = 0;i < _object.elementTextStyle.length;i++)
                {
                    if (typeof _object.elementTextStyle[i] !== 'undefined' && _object.elementTextStyle[i] !== null)
                    {
                        this.elementTextStyle[i] = new String(_object.elementTextStyle[i]);
                        if (this.elementTextStyle[i] !== null)
                            this.elementTextStyle[i] = this.elementTextStyle[i].toString();
                    }
                }
            }
            if (typeof _object.connectorTextStyle !== 'undefined' && _object.connectorTextStyle !== null)
            {
                for (i = 0;i < _object.connectorTextStyle.length;i++)
                {
                    if (typeof _object.connectorTextStyle[i] !== 'undefined' && _object.connectorTextStyle[i] !== null)
                    {
                        this.connectorTextStyle[i] = new String(_object.connectorTextStyle[i]);
                        if (this.connectorTextStyle[i] !== null)
                            this.connectorTextStyle[i] = this.connectorTextStyle[i].toString();
                    }
                }
            }
            if (typeof _object.elementFontRelativeSize !== 'undefined' && _object.elementFontRelativeSize !== null)
            {
                this.elementFontRelativeSize = new String(_object.elementFontRelativeSize);
                if (this.elementFontRelativeSize !== null)
                    this.elementFontRelativeSize = this.elementFontRelativeSize.toString();
            }
            if (typeof _object.connectorFontRelativeSize !== 'undefined' && _object.connectorFontRelativeSize !== null)
            {
                this.connectorFontRelativeSize = new String(_object.connectorFontRelativeSize);
                if (this.connectorFontRelativeSize !== null)
                    this.connectorFontRelativeSize = this.connectorFontRelativeSize.toString();
            }
            if (typeof _object.colourElementText !== 'undefined' && _object.colourElementText !== null && _object.colourElementText.IsType('TColour'))
                this.colourElementText = objM.copy(_object.colourElementText);
            if (typeof _object.colourConnectorText !== 'undefined' && _object.colourConnectorText !== null && _object.colourConnectorText.IsType('TColour'))
                this.colourConnectorText = objM.copy(_object.colourConnectorText);
            if (typeof _object.colourConnectorLine !== 'undefined' && _object.colourConnectorLine !== null && _object.colourConnectorLine.IsType('TColour'))
                this.colourConnectorLine = objM.copy(_object.colourConnectorLine);
            if (typeof _object.connectorAlignmentX !== 'undefined' && _object.connectorAlignmentX !== null)
            {
                this.connectorAlignmentX = new String(_object.connectorAlignmentX);
                if (this.connectorAlignmentX !== null)
                    this.connectorAlignmentX = this.connectorAlignmentX.toString();
            }
            if (typeof _object.connectorAlignmentY !== 'undefined' && _object.connectorAlignmentY !== null)
            {
                this.connectorAlignmentY = new String(_object.connectorAlignmentY);
                if (this.connectorAlignmentY !== null)
                    this.connectorAlignmentY = this.connectorAlignmentY.toString();
            }
            if (typeof _object.alignX !== 'undefined' && _object.alignX !== null)
            {
                this.alignX = new String(_object.alignX);
                if (this.alignX !== null)
                    this.alignX = this.alignX.toString();
            }
            if (typeof _object.alignY !== 'undefined' && _object.alignY !== null)
            {
                this.alignY = new String(_object.alignY);
                if (this.alignY !== null)
                    this.alignY = this.alignY.toString();
            }
            if (typeof _object.elementFont !== 'undefined' && _object.elementFont !== null)
            {
                this.elementFont = new String(_object.elementFont);
                if (this.elementFont !== null)
                    this.elementFont = this.elementFont.toString();
            }
            if (typeof _object.connectorFont !== 'undefined' && _object.connectorFont !== null)
            {
                this.connectorFont = new String(_object.connectorFont);
                if (this.connectorFont !== null)
                    this.connectorFont = this.connectorFont.toString();
            }
            if (typeof _object.coordText !== 'undefined' && _object.coordText !== null && _object.coordText.IsType('TVector'))
                this.coordText = objM.copy(_object.coordText);
        }
    };

    TGraph_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectFigure.prototype.IsType.call(this,_type);
    };

    TGraph_.prototype.FindTextByCode = function(code){
        if (typeof code !== 'undefined' && code !== null)
        {
            var i;
            for(i = 0;i < this.codes.length;i++)
            {
                if (this.codes[i] === code)
                    return i;
            }
        }
        return null;
    };
        
    TGraph_.prototype.ReadElement = function(tag){
        var code = tag.getAttribute('code');
        var objM = this.GetObjectManager();
        if (objM !== null && typeof code !== 'undefined' && code !== null && this.graph !== null)
        {
            var x = 0,y = 0,z = 0,w,h,noText,attr;
            var obj = this.graph.GetElementByCode(code);
            if (obj === null)
            {
                attr = tag.getAttribute('x');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        x = attr;
                }
                attr = tag.getAttribute('y');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        y = attr;
                }
                attr = tag.getAttribute('z');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        z = attr;
                }
                attr = tag.getAttribute('width');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        w = attr;
                }
                attr = tag.getAttribute('height');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        h = attr;
                }
                var coord = objM.newObject('TVector3DT');
                if (coord !== null)
                {
                    if (this.alignX === 'center')
                        x = x - w/2;
                    if (this.alignY === 'center')
                        y = y - h/2;
                    coord.SetCoordinates(x,y,z);
                    this.graph.AddElement(coord,'ABC',code,w,h);
                    this.codes[this.nCodes] = new String(code);
                    if (this.codes[this.nCodes] !== null)
                        this.codes[this.nCodes] = this.codes[this.nCodes].toString();
                    this.nCodes++;
                }
            }

            obj = this.graph.GetElementByCode(code);
            noText = this.FindTextByCode(code);
            if (obj !== null && obj.IsType('TGraphElement') && noText !== null && noText >= 0)
            {
                obj.SetScaleTextYN(this.styleScaleTextYN);
                obj.SetLineWidth(this.elementLineWidth);
                obj.SetLineType(this.elementLineType);
                obj.SetBackgroundType(this.elementBackgroundType);
//                obj.SetAlignX(this.alignX);
//                obj.SetAlignY(this.alignY);
                if (this.colourElementLine !== null)
                    obj.SetLineColour(this.colourElementLine);
                if (this.colourElementBackground !== null)
                    obj.SetBackgroundColour(this.colourElementBackground);
                if (this.colourElementText !== null)
                    obj.SetTextColour(this.colourElementText);
                obj.SetTextStyle(this.elementTextStyle);
                obj.SetFontRelativeSize(this.elementFontRelativeSize);
                obj.SetFont(this.elementFont);
                var i,x_ = tag.childNodes,x__,j,lang = this.GetCurrentNameLanguage();

                for (i = 0;i < x_.length;i++)
                {
                    if (x_[i].nodeType === 1)
                    {
//                        x_[i].nodeName
                        x__ = x_[i].childNodes;
                        if (x_[i].nodeName.toLowerCase() === lang)
                        {
                            for(j = 0;j < x__.length;j++)
                            {
                                if (x__[j].nodeType === 3)
                                {
                                    if (typeof this.text[noText] === 'undefined' || this.text[noText] === null)
                                    {
                                        this.text[noText] = objM.newObject('TMultilanguageStringData');
                                    }
                                    if (this.text[noText] !== null)
                                    {
                                        this.text[noText].SetStringData(x__[j].nodeValue,lang);
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }                
            }
        }
    };

    TGraph_.prototype.ReadConnector = function(tag){
        var code = tag.getAttribute('code');
        var codeBegin = tag.getAttribute('codeBegin');
        var codeEnd = tag.getAttribute('codeEnd');
        var objM = this.GetObjectManager();
        if (objM !== null && typeof code !== 'undefined' && code !== null && typeof codeBegin !== 'undefined' && codeBegin !== null && typeof codeEnd !== 'undefined' && codeEnd !== null && this.graph !== null)
        {
            var xText = 0;
            var yText = 0,zText = 0;
            var obj = this.graph.GetElementByCode(code),noText;
            if (obj === null)
            {
                this.graph.AddConnector(codeBegin,codeEnd,code);
                this.codes[this.nCodes] = new String(code);
                if (this.codes[this.nCodes] !== null)
                    this.codes[this.nCodes] = this.codes[this.nCodes].toString();
                this.nCodes++;
            }
            obj = this.graph.GetConnectorByCode(code);
            noText = this.FindTextByCode(code);
            if (obj !== null && obj.IsType('TGraphConnector') && noText !== null && noText >= 0)
            {
                var beginLength = 1,endLength = 1;
                
                obj.SetText('');
                obj.SetScaleTextYN(this.styleScaleTextYN);
                obj.SetTextStyle(this.connectorTextStyle);
                obj.SetFontRelativeSize(this.connectorFontRelativeSize);
                obj.SetAlignmentX(this.connectorAlignmentX);
                obj.SetAlignmentY(this.connectorAlignmentY);

                if (this.colourConnectorLine !== null)
                    obj.SetLineColour(this.colourConnectorLine);
                if (this.colourConnectorText !== null)
                    obj.SetTextColour(this.colourConnectorText);
                
                obj.SetLineType(this.connectorLineType);
                obj.SetLineWidth(this.connectorLineWidth);
                obj.SetBeginArrowWidth(this.beginArrowWidth);
                obj.SetBeginArrowHeight(this.beginArrowHeight);
                obj.SetEndArrowWidth(this.endArrowWidth);
                obj.SetEndArrowHeight(this.endArrowHeight);
                obj.SetFont(this.connectorFont);
                
                var attr = tag.getAttribute('beginLength');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        beginLength = attr;
                }
                attr = tag.getAttribute('endLength');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        endLength = attr;
                }
                obj.SetBeginLength(beginLength);
                obj.SetEndLength(endLength);

                attr = tag.getAttribute('shift');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        obj.SetShift(attr);
                }

                attr = tag.getAttribute('nVerticles');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        obj.SetNVerticles(attr);
                }else
                {
                    if (this.nVerticles !== null)
                        obj.SetNVerticles(this.nVerticles);
                }

                attr = tag.getAttribute('begin');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    obj.SetArrow(attr,true);
                }
                attr = tag.getAttribute('end');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    obj.SetArrow(attr,false);
                }
                attr = tag.getAttribute('xText');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        xText = attr;
                }
                attr = tag.getAttribute('yText');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        yText = attr;
                }
                attr = tag.getAttribute('zText');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        zText = attr;
                }
                
                this.coordText = objM.newObject('TVector3DT');
                if (this.coordText !== null)
                {
                    this.coordText.SetCoordinates(xText,yText,zText);
                    obj.SetTextCoordinates(this.coordText);
                }

                obj.SetLineWidth(this.connectorLineWidth);

                var i,x_ = tag.childNodes,x__,j,lang = this.GetCurrentNameLanguage();

                for (i = 0;i < x_.length;i++)
                {
                    if (x_[i].nodeType === 1)
                    {
//                        x_[i].nodeName
                        x__ = x_[i].childNodes;
                        if (x_[i].nodeName.toLowerCase() === lang)
                        {
                            for(j = 0;j < x__.length;j++)
                            {
                                if (x__[j].nodeType === 3)
                                {
                                    if (typeof this.text[noText] === 'undefined' || this.text[noText] === null)
                                    {
                                        this.text[noText] = objM.newObject('TMultilanguageStringData');
                                    }
                                    if (this.text[noText] !== null)
                                    {
                                        this.text[noText].SetStringData(x__[j].nodeValue,lang);
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }                
            }
        }
    };

    TGraph_.prototype.ReadXML = function(tag){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var i,attr,x=0,y=0,z=0,s=1,w=0,h=0,r = null,g = null,b = null,a = null,tmp;
            this.graph = objM.newObject('TGraph');
            if (this.graph !== null)
            {
                attr = tag.getAttribute('x');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        x = attr;
                }
                attr = tag.getAttribute('y');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        y = attr;
                }
                attr = tag.getAttribute('z');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        z = attr;
                }
                attr = tag.getAttribute('scale');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        s = attr;
                }
                attr = tag.getAttribute('width');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        w = attr;
                }
                attr = tag.getAttribute('height');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        h = attr;
                }
                
                this.graph.SetScale(s);
                
                this.graph.SetCoordinates(x,y,z);
                this.graph.SetSize(w,h);

         

                var x_ = tag.childNodes;

                for (i = 0;i < x_.length;i++)
                {
                    if (x_[i].nodeType === 1)
                    {
                        if (x_[i].nodeName === 'Element')
                        {
                            this.ReadElement(x_[i]);
                        }
                        if (x_[i].nodeName === 'Connector')
                        {
                            this.ReadConnector(x_[i]);
                        }
                        if (x_[i].nodeName === 'Style')
                        {
                            attr = x_[i].getAttribute('scaleText');
                            if (typeof attr !== 'undefined' && attr !== null)
                            {
                                if (attr === 'No')
                                    this.styleScaleTextYN = false;
                                else
                                    this.styleScaleTextYN = true;
                            }
                            attr = x_[i].getAttribute('elementLineWidth');
                            if (typeof attr !== 'undefined' && attr !== null)
                            {
                                attr = parseFloat(attr);
                                if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                                    this.elementLineWidth = attr;
                            }
                            attr = x_[i].getAttribute('elementLineType');
                            if (typeof attr !== 'undefined' && attr !== null)
                                this.elementLineType = attr;
                            attr = x_[i].getAttribute('elementBackroundType');
                            if (typeof attr !== 'undefined' && attr !== null)
                                this.elementBackgroundType = attr;
                            attr = x_[i].getAttribute('connectorLineWidth');
                            if (typeof attr !== 'undefined' && attr !== null)
                            {
                                attr = parseFloat(attr);
                                if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                                    this.connectorLineWidth = attr;
                            }
                            attr = x_[i].getAttribute('elementTextStyle');
                            if (typeof attr !== 'undefined' && attr !== null)
                            {
                                if (attr === 'reset')
                                    this.elementTextStyle = [];
                                else
                                    this.elementTextStyle[this.elementTextStyle.length] = attr;
                            }
                            attr = x_[i].getAttribute('elementFontRelativeSize');
                            if (typeof attr !== 'undefined' && attr !== null)
                                this.elementFontRelativeSize = attr;
                            attr = x_[i].getAttribute('connectorFontRelativeSize');
                            if (typeof attr !== 'undefined' && attr !== null)
                                this.connectorFontRelativeSize = attr;
                            attr = x_[i].getAttribute('connectorTextStyle');
                            if (typeof attr !== 'undefined' && attr !== null)
                            {
                                if (attr === 'reset')
                                    this.connectorTextStyle = [];
                                else
                                    this.connectorTextStyle[this.connectorTextStyle.length] = attr;
                            }
                            attr = x_[i].getAttribute('connectorAlignmentX');
                            if (typeof attr !== 'undefined' && attr !== null)
                                this.connectorAlignmentX = attr;
                            attr = x_[i].getAttribute('connectorAlignmentY');
                            if (typeof attr !== 'undefined' && attr !== null)
                                this.connectorAlignmentY = attr;
                            attr = x_[i].getAttribute('connectorLineType');
                            if (typeof attr !== 'undefined' && attr !== null)
                                this.connectorLineType = attr;
                            attr = x_[i].getAttribute('connectorNVerticles');
                            if (typeof attr !== 'undefined' && attr !== null)
                            {
                                attr = parseFloat(attr);
                                if (typeof attr !== 'undefined' && attr !== null && IsInt(attr))
                                    this.nVerticles = attr;
                            }
                            attr = x_[i].getAttribute('connectorLineWidth');
                            if (typeof attr !== 'undefined' && attr !== null)
                            {
                                attr = parseFloat(attr);
                                if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                                    this.connectorLineWidth = attr;
                            }
                            attr = x_[i].getAttribute('beginArrowWidth');
                            if (typeof attr !== 'undefined' && attr !== null)
                            {
                                attr = parseFloat(attr);
                                if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                                    this.beginArrowWidth = attr;
                            }
                            attr = x_[i].getAttribute('beginArrowHeight');
                            if (typeof attr !== 'undefined' && attr !== null)
                            {
                                attr = parseFloat(attr);
                                if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                                    this.beginArrowHeight = attr;
                            }
                            attr = x_[i].getAttribute('endArrowWidth');
                            if (typeof attr !== 'undefined' && attr !== null)
                            {
                                attr = parseFloat(attr);
                                if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                                    this.endArrowWidth = attr;
                            }
                            attr = x_[i].getAttribute('endArrowHeight');
                            if (typeof attr !== 'undefined' && attr !== null)
                            {
                                attr = parseFloat(attr);
                                if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                                    this.endArrowHeight = attr;
                            }
                            attr = x_[i].getAttribute('alignX');
                            if (typeof attr !== 'undefined' && attr !== null)
                                this.alignX = attr;
                            attr = x_[i].getAttribute('alignY');
                            if (typeof attr !== 'undefined' && attr !== null)
                                this.alignY = attr;
                            attr = x_[i].getAttribute('elementFont');
                            if (typeof attr !== 'undefined' && attr !== null)
                                this.elementFont = attr;
                            attr = x_[i].getAttribute('connectorFont');
                            if (typeof attr !== 'undefined' && attr !== null)
                                this.connectorFont = attr;
                        }
                        tmp = this.ReadColour(x_[i],'ColourElementLine');
                        if (tmp !== null)
                            this.colourElementLine = tmp;
                        tmp = this.ReadColour(x_[i],'ColourElementBackground');
                        if (tmp !== null)
                            this.colourElementBackground = tmp;
                        tmp = this.ReadColour(x_[i],'ColourElementText');
                        if (tmp !== null)
                            this.colourElementText = tmp;
                        tmp = this.ReadColour(x_[i],'ColourConnectorLine');
                        if (tmp !== null)
                            this.colourConnectorLine = tmp;
                        tmp = this.ReadColour(x_[i],'ColourConnectorText');
                        if (tmp !== null)
                            this.colourConnectorText = tmp;
                    }
                }
                
//                this.SetFigure(this.graph);

            }
            
        }
    };


    TGraph_.prototype.DrawFigure = function(ctx){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof this.graph !== 'undefined' && this.graph !== null && this.graph.IsType('TGraph'))
        {
            var i,obj,noText;
            for (i = 0;i < this.nCodes;i++)
            {
                obj = this.graph.GetElementByCode(this.codes[i]);
                noText = this.FindTextByCode(this.codes[i]);
                if (typeof obj !== 'undefined' && obj !== null)
                {
                    if (obj.IsType('TGraphElement'))
                    {
                        if (noText !== null && this.text.length > noText && typeof this.text[noText] !== 'undefined' && this.text[noText] !== null)
                            obj.SetText(this.text[noText].GetStringData(this.GetCurrentNameLanguage()));
                        else
                            obj.SetText('');
                    }
                }else
                {
                    obj = this.graph.GetConnectorByCode(this.codes[i]);
                    if (obj!== null && obj.IsType('TGraphConnector'))
                    {
                        if (noText !== null && this.text.length > noText && typeof this.text[noText] !== 'undefined' && this.text[noText] !== null)
                            obj.SetText(this.text[noText].GetStringData(this.GetCurrentNameLanguage()));
                        else
                            obj.SetText('');
                        if (this.colourConnectorText !== null)
                            obj.SetTextColour(this.colourConnectorText);
                        obj.SetTextStyle(this.connectorTextStyle);
                        obj.SetScaleTextYN(this.styleScaleTextYN);
                        obj.SetFontRelativeSize(this.connectorFontRelativeSize);
                        obj.SetAlignmentX(this.connectorAlignmentX);
                        obj.SetAlignmentY(this.connectorAlignmentY);
                        obj.SetFont(this.connectorFont);
                        obj.ReloadCoordinateText();
                    }
                }
            }
            this.graph.Draw2(ctx);
        }
    };


    TGraph_.prototype.ChangeCurrentLanguageNumber = function(_language){
        TObjectFigure.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        if (typeof this.text !== 'undefined' && this.text !== null)
        {
            var i;
            for (i = 0;i < this.text.length;i++)
            {
                if (typeof this.text[i] !== 'undefined' && this.text[i] !== null && this.text[i].IsType('TMultilanguageStringData'))
                    this.text[i].ChangeCurrentLanguageNumber(_language);
            }
        }
    };

    TGraph_.prototype.ReadColour = function(tag,name){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null && typeof name !== 'undefined' && name !== null)
        {
            if (tag.nodeName === name)
            {
                var attr,r = null,g = null,b = null,a,result;
                attr = tag.getAttribute('r');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        r = attr;
                }
                attr = tag.getAttribute('g');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        g = attr;
                }
                attr = tag.getAttribute('b');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        b = attr;
                }
                a = null;
                attr = tag.getAttribute('a');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        a = attr;
                }
                if (r !== null && g !== null && b !== null && r >= 0 && r <=1 & g >= 0 && b <=1 & b >= 0 && r <=1)
                {
                    if (a === null ||a > 1)
                        a = 1;
                    if (a < 0)
                        a = 0;
                    result = objM.newObject('TColourRGBA');
                    if (result !== null)
                        result.SetColourRGBA(r,g,b,a);
                    return result;
                }
            }
        }
        return null;
    };

};

TGraph_.prototype = new TObjectFigure();

function TRectangle_(){
    var type = 'TRectangle_';
    TRectangle_.prototype.InitConstructor = function(){
        TObjectFigure.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.fileName = null;
        this.imageCatalog = null;
    };
    this.InitConstructor();

    TRectangle_.prototype.Init = function(_object){
        TObjectFigure.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TRectangle_'))
        {
        }
    };

    TRectangle_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectFigure.prototype.IsType.call(this,_type);
    };
    
    TRectangle_.prototype.ReadXML = function(tag){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var i,obj,attr,x=0,y=0,z=0,coord,w=0,h=0,alignX,alignY;
            obj = objM.newObject('TRectangle');
            if (obj !== null)
            {
                attr = tag.getAttribute('x');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        x = attr;
                }
                attr = tag.getAttribute('y');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        y = attr;
                }
                attr = tag.getAttribute('z');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        z = attr;
                }
                attr = tag.getAttribute('width');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        w = attr;
                }
                attr = tag.getAttribute('height');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        h = attr;
                }
                attr = tag.getAttribute('alignX');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    alignX = attr;
                }
                attr = tag.getAttribute('alignY');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    alignY = attr;
                }
                
//                obj.SetAlignX(alignX);
//                obj.SetAlignY(alignY);
                
                
                coord = objM.newObject('TVector3DT');
                if (coord !== null)
                {
                    coord.SetCoordinates(x,y,z);
                    obj.SetCoordinates(coord);
                }
                
                obj.SetWidth(w);
                obj.SetHeight(h);

                obj.SetLineWidth(this.GetLineWidth());
                obj.SetLineColour(this.colourLine);
                obj.SetBackgroundColour(this.colourFill);
                
                this.SetFigure(obj);

            }
            
        }
    };

    TRectangle_.prototype.DrawFigure = function(ctx){
        TObjectFigure.prototype.DrawFigure.call(this,ctx);
    };

};

TRectangle_.prototype = new TObjectFigure();


function TFigureForeignObject_(){
    var type = 'TFigureForeignObject_';
    TFigureForeignObject_.prototype.InitConstructor = function(){
        TObjectFigure.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.elements = [];
    };
    this.InitConstructor();

    TFigureForeignObject_.prototype.Init = function(_object){
        TObjectFigure.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TFigureForeignObject_'))
        {
            var i;
            if (typeof _object.elements !== 'undefined' && _object.elements !== null)
            {
                for (i = 0;i < _object.elements.length;i++)
                {
                    if (typeof _object.elements[i] !== 'undefined' && _object.elements[i] !== null && _object.elements[i].IsType('TPageElement'))
                        this.elements[i] = objM.copy(_object.elements[i]);
                }
            }
        }
    };

    TFigureForeignObject_.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectFigure.prototype.IsType.call(this,_type);
    };

    TFigureForeignObject_.prototype.ReadXML = function(tag){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            var i,coord,obj,attr,x=0,y=0,z=0,w=0,h=0,k,alignX,alignY;
            obj = objM.newObject('TFigureForeignObject');
            if (obj !== null)
            {
                attr = this.CalculateValue(tag.getAttribute('x'));
                if (attr !== null && IsNumeric(attr))
                    x = attr;
                attr = this.CalculateValue(tag.getAttribute('y'));
                if (attr !== null && IsNumeric(attr))
                    y = attr;
                attr = this.CalculateValue(tag.getAttribute('z'));
                if (attr !== null && IsNumeric(attr))
                    z = attr;
                attr = this.CalculateValue(tag.getAttribute('width'));
                if (attr !== null && IsNumeric(attr))
                    w = attr;
                attr = this.CalculateValue(tag.getAttribute('height'));
                if (attr !== null && IsNumeric(attr))
                    h = attr;
/*                attr = tag.getAttribute('x');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        x = attr;
                }
                attr = tag.getAttribute('y');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        y = attr;
                }
                attr = tag.getAttribute('z');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        z = attr;
                }
                attr = tag.getAttribute('width');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        w = attr;
                }
                attr = tag.getAttribute('height');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                        h = attr;
                }*/

                attr = tag.getAttribute('alignX');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    alignX = attr;
                }
                attr = tag.getAttribute('alignY');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    alignY = attr;
                }
                
                obj.SetWidth(w);
                obj.SetHeight(h);
                obj.SetAlignX(alignX);
                obj.SetAlignY(alignY);
                
/*                coord = objM.newObject('TVector3DT');
                if (coord !== null)
                {
                    coord.SetCoordinates(x,y,z);
                    obj.SetCoordinates(coord);
                }*/


                coord = objM.newObject('TVector3DT');
                if (coord !== null)
                {
                    coord.SetCoordinates(x,y,z);
                    obj.SetVerticle(0,coord);
                }



                var x_ = tag.childNodes,obj2;

                for (i = 0,k = 0;i < x_.length;i++)
                {
                    if (x_[i].nodeType === 1)
                    {
                        if (x_[i].nodeName === 'Element')
                        {
                            attr = x_[i].getAttribute('type');
                            if (attr !== null)
                            {
                                obj2 = null;
                                if (this.elements.length > k)
                                    obj2 = this.elements[k];
                                if (typeof obj2 === 'undefined' || obj2 === null)
                                    obj2 = objM.newObject('T'+attr);
                                if (typeof obj2 !== 'undefined' && obj2 !== null)
                                {
                                    obj2.SetVariables(this.GetVariables());
                                    obj2.ReadXML(x_[i]);
                                    this.elements[k] = obj2;
                                    k++;
                                }
                            }
                        }
                    }
                }
                
                
                this.SetFigure(obj);
            }
            
        }
    };
    

    TFigureForeignObject_.prototype.DrawFigure = function(ctx){
        var objM = this.GetObjectManager();
        if (objM !== null && ctx !== null)
        {
            var drawHtml = objM.newObject('THTMLObject');
            if (drawHtml !== null)
            {
                if (ctx.GetType() === 'TDrawSvgContext')
                {
                    var i;
    //                var paragraphs = objM.newObject('THTMLObject');
    //                paragraphs.Draw(drawHtml,'THTMLParagraphs');
                    drawHtml.SetTypeDrawObject('THTMLParagraphs');  
                    for (i = 0;i < this.elements.length;i++)
                    {
                        if (this.elements[i] !== null)
                            this.elements[i].Draw(drawHtml);
                    }
                    var txt = drawHtml.GetTXT();
                    var obj = this.GetFigure();
                    if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TFigureForeignObject'))
                        obj.SetObject(txt);
//                    ctx.ForeignObject(this.GetVerticle(0),this.GetVerticle(1));

                }
                if (ctx.GetType() === 'TDrawTikZContext')
                {
                    var i;
    //                var paragraphs = objM.newObject('THTMLObject');
    //                paragraphs.Draw(drawHtml,'THTMLParagraphs');
                    drawHtml.SetTypeDrawObject('TTeXParagraphs');  
                    for (i = 0;i < this.elements.length;i++)
                    {
                        if (this.elements[i] !== null)
                            this.elements[i].Draw(drawHtml);
                    }
                    var txt = drawHtml.GetTXT();
                    var obj = this.GetFigure();
                    if (obj !== null && obj.IsType('TFigureForeignObject'))
                        obj.SetObject(txt);
//                    ctx.ForeignObject(this.GetVerticle(0),this.GetVerticle(1));

                }
            }
/*            ctx.SetScaleTextYN(this.scaleTextYN);
            var i,txt = '';
            for (i = 0;i < this.element.length;i++)
            {
                if (typeof this.element[i] !== 'undefined' && this.element[i] !== null)
                    txt = txt + this.element[i].GetStringData();
            }
            var obj = this.GetFigure();
            if (obj !== null)
            {
                obj.SetText(null,txt);
                obj.SetFontSize(this.fontSize);
                obj.SetFont(this.font);
                obj.SetAlignmentX(this.alignmentX);
                obj.SetAlignmentY(this.alignmentY);
            }
            
            ctx.SetDefaultTextColour(this.colourText);*/
        }
        TObjectFigure.prototype.DrawFigure.call(this,ctx);
    };


    TFigureForeignObject_.prototype.ChangeCurrentLanguageNumber = function(_language){
        TObjectFigure.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        if (typeof this.elements !== 'undefined' && this.elements !== null)
        {
            var i;
            for (i = 0;i < this.elements.length;i++)
                if (this.elements[i] !== null)
                    this.elements[i].ChangeCurrentLanguageNumber(_language);
        }
    };

    TFigureForeignObject_.prototype.ActualizeActions = function(){
        TObjectFigure.prototype.ActualizeActions.call(this);
        if (typeof this.elements !== 'undefined' && this.elements !== null)
        {
            var i;
            for (i = 0;i < this.elements.length;i++)
                if (this.elements[i] !== null)
                    this.elements[i].ActualizeActions();
        }
    };

};

TFigureForeignObject_.prototype = new TObjectFigure();


function TDrawObject(){
    var type = 'TDrawObject';
    TDrawObject.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.width = 0;
        this.height = 0;
        this.xmin = 0;
        this.xmax = 0;
        this.ymin = null;
        this.ymax = null;
        this.zmin = null;
        this.zmax = null;
        this.figures = [];
        this.imageCatalog = null;
        this.alignX = null;
        this.colourBackground = null;
    };
    this.InitConstructor();

    TDrawObject.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TDrawObject'))
        {
            var i;
            if (typeof _object.width !== 'undefined' && _object.width !== null && IsInt(_object.width))
                this.width = _object.width;
            if (typeof _object.height !== 'undefined' && _object.height !== null && IsInt(_object.height))
                this.height = _object.height;
            if (typeof _object.xmin !== 'undefined' && _object.xmin !== null && IsNumeric(_object.xmin))
                this.xmin = _object.xmin;
            if (typeof _object.xmax !== 'undefined' && _object.xmax !== null && IsNumeric(_object.xmax))
                this.xmax = _object.xmax;
            if (typeof _object.ymin !== 'undefined' && _object.ymin !== null && IsNumeric(_object.ymin))
                this.ymin = _object.ymin;
            if (typeof _object.ymax !== 'undefined' && _object.ymax !== null && IsNumeric(_object.ymax))
                this.ymax = _object.ymax;
            if (typeof _object.zmin !== 'undefined' && _object.zmin !== null && IsNumeric(_object.zmin))
                this.zmin = _object.zmin;
            if (typeof _object.zmax !== 'undefined' && _object.zmax !== null && IsNumeric(_object.zmax))
                this.zmax = _object.zmax;
            if (typeof _object.figures !== 'undefined' && _object.figures !== null)
            {
                for (i = 0;i < _object.figures.length;i++)
                    if (typeof _object.figures[i] !== 'undefined' && _object.figures[i] !== null && _object.figures[i].IsType('TObjectFigure'))
                        this.figures[i] = objM.copy(_object.figures[i]);
            }
            if (typeof _object.imageCatalog !== 'undefined' && _object.imageCatalog !== null)
            {
                this.imageCatalog = new String(_object.imageCatalog);
                if (this.imageCatalog !== null)
                    this.imageCatalog = this.imageCatalog.toString();
            }
            if (typeof _object.alignX !== 'undefined' && _object.alignX !== null)
            {
                this.alignX = new String(_object.alignX);
                if (this.alignX !== null)
                    this.alignX = this.alignX.toString();
            }
            if (typeof _object.colourBackground !== 'undefined' && _object.colourBackground !== null && _object.colourBackground.IsType('TColourRGBA'))
                this.colourBackground = objM.copy(_object.colourBackground);
        }
    };

    TDrawObject.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    
   TDrawObject.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        var i;
        if (typeof this.figures !== 'undefined' && this.figures !== null)
        {
            for (i = 0;i < this.figures.length;i++)
                if (typeof this.figures[i] !== 'undefined' && this.figures[i] !== null && this.figures[i].IsType('TObjectFigure'))
                    this.figures[i].ChangeCurrentLanguageNumber(_language);
        }
    };

    TDrawObject.prototype.ReadXMLData = function(tag){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('width');
            this.ReadXMLInit(tag);
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseInt(attr);
                if (attr !== null && IsInt(attr))
                    this.width = attr;
            }
            attr = tag.getAttribute('height');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseInt(attr);
                if (attr !== null && IsInt(attr))
                    this.height = attr;
            }
            if (this.width <= 0 || this.height <= 0)
                return;
            this.xmin = 0;this.xmax = this.width;
            this.ymin = null;this.ymax = null;
            attr = tag.getAttribute('xmin');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseFloat(attr);
                if (attr !== null && IsNumeric(attr))
                    this.xmin = attr;
            }
            attr = tag.getAttribute('xmax');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseFloat(attr);
                if (attr !== null && IsNumeric(attr))
                {
                    if (attr > this.xmin)
                        this.xmax = attr;
                }
            }
            attr = tag.getAttribute('ymin');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseFloat(attr);
                if (attr !== null && IsNumeric(attr))
                    this.ymin = attr;
            }
            attr = tag.getAttribute('ymax');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseFloat(attr);
                if (attr !== null && IsNumeric(attr))
                    this.ymax = attr;
            }
            attr = tag.getAttribute('zmin');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseFloat(attr);
                if (attr !== null && IsNumeric(attr))
                    this.zmin = attr;
            }
            attr = tag.getAttribute('zmax');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseFloat(attr);
                if (attr !== null && IsNumeric(attr))
                    this.zmax = attr;
            }
            
            this.SetAlignX(tag.getAttribute('alignX'));

            var aspect = this.height/this.width;
            var range = this.xmax - this.xmin;
            var range2 = range*aspect;
            if (this.ymin === null && this.ymax === null)
            {
                this.ymax = range2/2;
                this.ymin = -this.ymax;
            }else
            {
                if (this.ymin !== null)
                    this.ymax = this.ymin + range2;
                else
                    this.ymin = this.ymax - range2;
            }
            this.colourBackground = objM.newObject('TColourRGBA');
            if (this.colourBackground !== null)
            {
                attr = tag.getAttribute('r');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                    {
                        this.colourBackground.SetColourR(attr);
                    }
                }
                attr = tag.getAttribute('g');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                    {
                        this.colourBackground.SetColourG(attr);
                    }
                }
                attr = tag.getAttribute('b');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                    {
                        this.colourBackground.SetColourB(attr);
                    }
                }
                attr = tag.getAttribute('a');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                    {
                        this.colourBackground.SetColourA(attr);
                    }
                }
                
            }
        }
    };


    TDrawObject.prototype.SetImageCatalog = function(catalog){
        if (typeof catalog !== 'undefined' && catalog !== null)
        {
            this.imageCatalog = catalog;
            if (typeof this.figures !== 'undefined' && this.figures !== null)
            {
                var i;
                for (i = 0;i < this.figures.length;i++)
                    if (typeof this.figures[i] !== 'undefined' && this.figures[i] !== null && this.figures[i].IsType('TDrawImage_'))
                        this.figures[i].SetImageCatalog(catalog);
            }
        }
    };

    TDrawObject.prototype.SetAlignX = function(align){
        if (typeof align !== 'undefined' && align !== null)
        {
            this.alignX = new String(align);
            if (this.alignX !== null)
                this.alignX = this.alignX.toString();
        }
        if (align === null)
            this.alignX = null;
    };

    TDrawObject.prototype.GetFigure = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0 && number < this.figures.length)
        {
            return this.figures[number];
        }
        return null;
    };

    TDrawObject.prototype.SetFigure = function(number,fig){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0)
        {
            if (typeof fig !== 'undefined' && fig !== null && fig.IsType('TObjectFigure'))
                this.figures[number] = fig;
        }
    };

    TDrawObject.prototype.GetWidth = function(){
        return this.width;
    };

    TDrawObject.prototype.GetHeight = function(){
        return this.height;
    };

    TDrawObject.prototype.GetFigures = function(){
        return this.figures;
    };

    TDrawObject.prototype.GetXMax = function(){
        return this.xmax;
    };

    TDrawObject.prototype.GetXMin = function(){
        return this.xmin;
    };

    TDrawObject.prototype.GetYMax = function(){
        return this.ymax;
    };

    TDrawObject.prototype.GetYMin = function(){
        return this.ymin;
    };

    TDrawObject.prototype.GetZMax = function(){
        return this.zmax;
    };

    TDrawObject.prototype.GetZMin = function(){
        return this.zmin;
    };

    TDrawObject.prototype.GetAlignX = function(){
        if (typeof this.alignX !== 'undefined' && this.alignX !== null)
        {
            var tmp;
            tmp = new String(this.alignX);
            if (tmp !== null)
                return tmp.toString();
            return tmp;
        }
        return null;
    };

    TDrawObject.prototype.GetColourBackground = function(){
        return this.colourBackground;
    };

    TDrawObject.prototype.ActualizeActions = function(){
        TPageElement.prototype.ActualizeActions.call(this);
        if (typeof this.figures !== 'undefined' && this.figures !== null)
        {
            var i;
            for (i = 0;i < this.figures.length;i++)
                if (this.figures[i] !== null)
                    this.figures[i].ActualizeActions();
        }
    };


};

TDrawObject.prototype = new TPageElement();


function TDraw(){
    var type = 'TDraw';
    TDraw.prototype.InitConstructor = function(){
        TDrawObject.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.scaleTikZ = 1;
        this.scale = 1;
        this.generate = null;
    };
    this.InitConstructor();

    TDraw.prototype.Init = function(_object){
        TDrawObject.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TDraw'))
        {
            var i;
            if (typeof _object.scale !== 'undefined' && _object.scale !== null && IsNumeric(_object.scale))
                this.scale = _object.scale;
            if (typeof _object.scaleTikZ !== 'undefined' && _object.scaleTikZ !== null && IsNumeric(_object.scaleTikZ))
                this.scaleTikZ = _object.scaleTikZ;
            if (typeof _object.generate !== 'undefined' && _object.generate !== null)
            {
                this.generate = new String(_object.generate);
                if (this.generate !== null)
                    this.generate = this.generate.toString();
            }
        }
    };

    TDraw.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TDrawObject.prototype.IsType.call(this,_type);
    };
    
    TDraw.prototype.ReadXML = function(tag,fun){
        TDrawObject.prototype.ReadXML.call(this,tag,fun);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            this.ReadXMLData(tag);
            var i = tag.childNodes;//FindTags(tag.getElementsByTagName("Element"));
            attr = tag.getAttribute('scaleTikZ');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseFloat(attr);
                if (attr !== null && IsNumeric(attr))
                    this.scaleTikZ = attr;
            }
            attr = tag.getAttribute('scale');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseFloat(attr);
                if (attr !== null && IsNumeric(attr))
                    this.scale = attr;
            }

            attr = tag.getAttribute('generate');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                this.generate = attr;
            }


            var i,x = tag.childNodes,k,lineWidth = 1,endArrowWidth = 15,endArrowHeight = 10,beginArrowWidth=15,beginArrowHeight=10;
            var r=0,g=0,b=0,a=1;
            var rf=1,gf=1,bf=1,af=1;
            var rt=0,gt=0,bt=0,at=1;
            var nVerticlesBezier = 10;
            var fig;

            for (i = 0,k = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    fig = this.GetFigure(k);
                    if (x[i].nodeName === 'DrawText')
                    {
                        
                        if (fig === null)
                        {
                            this.SetFigure(k, objM.newObject('TText_'));
                            fig = this.GetFigure(k);
                            fig.SetVariables(this.GetVariables());
                            fig.SetDefaultLanguage(this.GetDefaultLanguage());
                        }                        
                        if (fig !== null && fig.IsType('TText_'))
                        {
//                            this.figures[k].SetColourLine(r,g,b,a);
//                            this.figures[k].SetColourFill(rf,gf,bf,af);
                            fig.SetColourText(rt,gt,bt,at);
                            fig.ReadXML(x[i]);
                            k++;
                            continue;
                        }
                    }
                    if (x[i].nodeName === 'DrawImage')
                    {
                        if (fig === null)
                        {
                            this.SetFigure(k, objM.newObject('TDrawImage_'));
                            fig = this.GetFigure(k);
                            fig.SetVariables(this.GetVariables());
                            fig.SetDefaultLanguage(this.GetDefaultLanguage());
                            fig.SetImageCatalog(this.imageCatalog);
                        }                        
                        if (fig !== null && fig.IsType('TDrawImage_'))
                        {
                            fig.ReadXML(x[i]);
                            k++;
                            continue;
                        }
                    }
                    if (x[i].nodeName === 'Rectangle')
                    {
                        if (fig === null)
                        {
                            this.SetFigure(k, objM.newObject('TRectangle_'));
                            fig = this.GetFigure(k);
                        }                        
                        if (fig !== null && fig.IsType('TRectangle_'))
                        {
                            fig.SetColourLine(r,g,b,a);
                            fig.SetColourFill(rf,gf,bf,af);
                            fig.SetLineWidth(lineWidth);
                            fig.ReadXML(x[i]);
                            k++;
                            continue;
                        }
                    }
                    if (x[i].nodeName === 'Chart')
                    {
                        if (fig === null)
                        {
                            this.SetFigure(k, objM.newObject('TChart_'));
                            fig = this.GetFigure(k);
                        }                        
                        if (fig !== null && fig.IsType('TChart_'))
                        {
                            fig.SetColourLine(r,g,b,a);
                            fig.SetColourFill(rf,gf,bf,af);
                            fig.SetLineWidth(lineWidth);
                            fig.ReadXML(x[i]);
                            k++;
                            continue;
                        }
                    }
                    if (x[i].nodeName === 'Graph')
                    {
                        if (fig === null)
                        {
                            this.SetFigure(k, objM.newObject('TGraph_'));
                            fig = this.GetFigure(k);
                        }                        
                        if (fig !== null && fig.IsType('TGraph_'))
                        {
                            fig.ReadXML(x[i]);
                            k++;
                            continue;
                        }
                    }
                    if (x[i].nodeName === 'Object')
                    {
                        if (fig === null)
                        {
                            this.SetFigure(k, objM.newObject('TFigureForeignObject_'));
                            fig = this.GetFigure(k);
                        }                        
                        if (fig !== null && fig.IsType('TFigureForeignObject_'))
                        {
                            fig.SetVariables(this.GetVariables());
                            fig.ReadXML(x[i]);
                            k++;
                            continue;
                        }
                    }
                    if (x[i].nodeName === 'F')
                    {
                        if (fig === null)
                        {
                            var attr = x[i].getAttribute('type');
                            if (attr !== null)
                            {
                                switch(attr)
                                {
                                    case 'line':
                                        this.SetFigure(k, objM.newObject('TLine_'));
                                        break;
                                    case 'circle':
                                        this.SetFigure(k, objM.newObject('TCircle_'));
                                        break;
                                    case 'ellipse':
                                        this.SetFigure(k, objM.newObject('TEllipse_'));
                                        break;
                                    case 'polygon':
                                        this.SetFigure(k, objM.newObject('TPolygon_'));
                                        break;
                                    case 'rationalBezier':
                                        this.SetFigure(k, objM.newObject('TRationalBezierCurve_'));
                                        break;
                                }
                                fig = this.GetFigure(k);
                            }

        /*                    if (this.caption === null)
                                this.caption = objM.newObject('TFigureElementCaption');
                            if (this.caption !== null)
                                this.caption.ReadXML(x[i],fun);*/
                        }
                        if (fig !== null)
                        {
                            fig.SetVariables(this.GetVariables());
                            fig.SetLineWidth(lineWidth);
                            if (fig.IsType('TLine_'))
                            {
                                fig.SetBeginArrowWidth(beginArrowWidth);
                                fig.SetBeginArrowHeight(beginArrowHeight);
                                fig.SetEndArrowWidth(endArrowWidth);
                                fig.SetEndArrowHeight(endArrowHeight);
                            }
                            if (fig.IsType('TRationalBezierCurve_'))
                                fig.SetNVerticles(nVerticlesBezier);
                            fig.SetColourLine(r,g,b,a);
                            fig.SetColourFill(rf,gf,bf,af);
                            fig.ReadXML(x[i]);
                        }

                        k++;
                        continue;
                    }
                    if (x[i].nodeName === 'Style')
                    {
                        attr = x[i].getAttribute('lineWidth');
                        if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                        {
                            lineWidth = parseFloat(attr);
                        }
                        attr = x[i].getAttribute('endArrowWidth');
                        if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                        {
                            endArrowWidth = parseFloat(attr);
                        }
                        attr = x[i].getAttribute('endArrowHeight');
                        if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                        {
                            endArrowHeight = parseFloat(attr);
                        }
                        attr = x[i].getAttribute('beginArrowWidth');
                        if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                        {
                            beginArrowWidth = parseFloat(attr);
                        }
                        attr = x[i].getAttribute('beginArrowHeight');
                        if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                        {
                            beginArrowHeight = parseFloat(attr);
                        }                        
                        attr = x[i].getAttribute('nVerticlesBezier');
                        if (typeof attr !== 'undefined' && attr !== null && IsInt(attr))
                        {
                            nVerticlesBezier = parseInt(attr);
                        }                        
                    }
                    if (x[i].nodeName === 'ColourLine')
                    {
                        attr = x[i].getAttribute('r');
                        if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                            r = parseFloat(attr);
                        attr = x[i].getAttribute('g');
                        if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                            g = parseFloat(attr);
                        attr = x[i].getAttribute('b');
                        if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                            b = parseFloat(attr);
                        attr = x[i].getAttribute('a');
                        if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                            a = parseFloat(attr);
                    }
                    if (x[i].nodeName === 'ColourFill')
                    {
                        attr = x[i].getAttribute('r');
                        if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                            rf = parseFloat(attr);
                        attr = x[i].getAttribute('g');
                        if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                            gf = parseFloat(attr);
                        attr = x[i].getAttribute('b');
                        if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                            bf = parseFloat(attr);
                        attr = x[i].getAttribute('a');
                        if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                            af = parseFloat(attr);
                    }
                    if (x[i].nodeName === 'ColourText')
                    {
                        attr = x[i].getAttribute('r');
                        if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                            rt = parseFloat(attr);
                        attr = x[i].getAttribute('g');
                        if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                            gt = parseFloat(attr);
                        attr = x[i].getAttribute('b');
                        if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                            bt = parseFloat(attr);
                        attr = x[i].getAttribute('a');
                        if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                            at = parseFloat(attr);
                    }
                }
            }

        }
    };


    TDraw.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var tmp2 = [],id = this.GetId();
            if (id !== null)
            {
                tmp2[0] = this.GetWidth();
                tmp2[1] = this.GetHeight();
                tmp2[2] = this.GetFigures();
                tmp2[3] = this.GetXMax()-this.GetXMin();
                tmp2[4] = this.GetYMax()-this.GetYMin();
                tmp2[5] = 1;
                tmp2[6] = this.GetXMin();
                tmp2[7] = this.GetYMin();
                tmp2[8] = 0;
                tmp2[9] = this.generate;
                tmp2[10] = this.scaleTikZ;
                tmp2[11] = this.scale;
                tmp2[12] = this.GetAlignX();
                _object.Add('Generate',id,tmp2);
            }
        }
    };

};

TDraw.prototype = new TDrawObject();


function TColourTXT(){
    var type = 'TColourTXT';
    TColourTXT.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.r = null;
        this.g = null;
        this.b = null;
        this.a = null;
    };
    this.InitConstructor();

    TColourTXT.prototype.Init = function(_object){
        TObject.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TColourTXT'))
        {
            if (typeof _object.r !== 'undefined' && _object.r !== null)
            {
                this.r = new String(_object.r);
                if (this.r !== null)
                    this.r = this.r.toString();
            }
            if (typeof _object.g !== 'undefined' && _object.g !== null)
            {
                this.g = new String(_object.g);
                if (this.g !== null)
                    this.g = this.g.toString();
            }
            if (typeof _object.b !== 'undefined' && _object.b !== null)
            {
                this.b = new String(_object.b);
                if (this.b !== null)
                    this.b = this.b.toString();
            }
            if (typeof _object.a !== 'undefined' && _object.a !== null)
            {
                this.a = new String(_object.a);
                if (this.a !== null)
                    this.a = this.a.toString();
            }
        }
    };

    TColourTXT.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };
    
    TColourTXT.prototype.ReadXML = function(tag){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('r');
            if (typeof attr !== 'undefined' && attr !== null)
                this.r = attr;
            attr = tag.getAttribute('g');
            if (typeof attr !== 'undefined' && attr !== null)
                this.g = attr;
            attr = tag.getAttribute('b');
            if (typeof attr !== 'undefined' && attr !== null)
                this.b = attr;
            attr = tag.getAttribute('a');
            if (typeof attr !== 'undefined' && attr !== null)
                this.a = attr;
        }
    };


    TColourTXT.prototype.SetR = function(r_){
        if (typeof r_ !== 'undefined' && r_ !== null)
        {
            this.r = new String(r_);
            if (this.r !== null)
                this.r = this.r.toString();
        }
        if (r_ === null)
            this.r = null;
    };

    TColourTXT.prototype.SetG = function(g_){
        if (typeof g_ !== 'undefined' && g_ !== null)
        {
            this.g = new String(g_);
            if (this.g !== null)
                this.g = this.g.toString();
        }
        if (g_ === null)
            this.g = null;
    };

    TColourTXT.prototype.SetB = function(b_){
        if (typeof b_ !== 'undefined' && b_ !== null)
        {
            this.b = new String(b_);
            if (this.b !== null)
                this.b = this.b.toString();
        }
        if (b_ === null)
            this.b = null;
    };

    TColourTXT.prototype.SetA = function(a_){
        if (typeof a_ !== 'undefined' && a_ !== null)
        {
            this.a = new String(a_);
            if (this.a !== null)
                this.a = this.a.toString();
        }
        if (a_ === null)
            this.a = null;
    };

    TColourTXT.prototype.SetRGBA = function(r_, g_, b_, a_){
        this.SetR(r_);
        this.SetG(g_);
        this.SetB(b_);
        this.SetA(a_);
    };

    TColourTXT.prototype.GetR = function(){
        var tmp = new String(this.r);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TColourTXT.prototype.GetG = function(){
        var tmp = new String(this.g);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TColourTXT.prototype.GetB = function(){
        var tmp = new String(this.b);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TColourTXT.prototype.GetA = function(){
        var tmp = new String(this.a);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TColourTXT.prototype.GetValueR = function(var_){
        if (typeof var_ !== 'undefined' && var_ !== null && var_.IsType('TVariables'))
            return var_.CalculateValue(this.r);
        return null;
    };

    TColourTXT.prototype.GetValueG = function(var_){
        if (typeof var_ !== 'undefined' && var_ !== null && var_.IsType('TVariables'))
            return var_.CalculateValue(this.g);
        return null;
    };

    TColourTXT.prototype.GetValueB = function(var_){
        if (typeof var_ !== 'undefined' && var_ !== null && var_.IsType('TVariables'))
            return var_.CalculateValue(this.b);
        return null;
    };

    TColourTXT.prototype.GetValueA = function(var_){
        if (typeof var_ !== 'undefined' && var_ !== null && var_.IsType('TVariables'))
            return var_.CalculateValue(this.a);
        return null;
    };
    
    TColourTXT.prototype.GetColour = function(var_){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof var_ !== 'undefined' && var_ !== null && var_.IsType('TVariables'))
        {
            var colour = objM.newObject('TColourRGBA');
            if (colour !== null)
            {
                var r = var_.CalculateValue(this.r);
                var g = var_.CalculateValue(this.g);
                var b = var_.CalculateValue(this.b);
                var a = var_.CalculateValue(this.a);
                colour.SetColourRGBA(r,g,b,a);
                return colour;
            }
        }
        return null;
    };
    
    
};

TColourTXT.prototype = new TObject();


function TArrowParameters(){
    var type = 'TArrowParameters';
    TArrowParameters.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.beginArrowWidth = 15;
        this.beginArrowHeight = 10;
        this.endArrowWidth = 15;
        this.endArrowHeight = 10;
    };
    this.InitConstructor();

    TArrowParameters.prototype.Init = function(_object){
        TObject.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TArrowParameters'))
        {
            if (typeof _object.beginArrowWidth !== 'undefined' && _object.beginArrowWidth !== null && IsNumeric(_object.beginArrowWidth))
                this.beginArrowWidth = _object.beginArrowWidth;
            if (typeof _object.beginArrowHeight !== 'undefined' && _object.beginArrowHeight !== null && IsNumeric(_object.beginArrowHeight))
                this.beginArrowHeight = _object.beginArrowHeight;
            if (typeof _object.endArrowWidth !== 'undefined' && _object.endArrowWidth !== null && IsNumeric(_object.endArrowWidth))
                this.endArrowWidth = _object.endArrowWidth;
            if (typeof _object.endArrowHeight !== 'undefined' && _object.endArrowHeight !== null && IsNumeric(_object.endArrowHeight))
                this.endArrowHeight = _object.endArrowHeight;
        }
    };

    TArrowParameters.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };
    
    TArrowParameters.prototype.ReadXML = function(tag){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('beginArrowWidth');
            if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                this.beginArrowWidth = parseFloat(attr);
            attr = tag.getAttribute('beginArrowHeight');
            if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                this.beginArrowHeight = parseFloat(attr);
            attr = tag.getAttribute('endArrowWidth');
            if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                this.endArrowWidth = parseFloat(attr);
            attr = tag.getAttribute('endArrowHeight');
            if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                this.endArrowHeight = parseFloat(attr);
        }
    };

    TArrowParameters.prototype.SetBeginArrowWidth = function(v){
        if (typeof v !== 'undefined' && v !== null && IsNumeric(v))
            this.beginArrowWidth = v;
    };
    
    TArrowParameters.prototype.GetBeginArrowWidth = function(){
        return this.beginArrowWidth;
    };
    
    TArrowParameters.prototype.SetBeginArrowHeight = function(v){
        if (typeof v !== 'undefined' && v !== null && IsNumeric(v))
            this.beginArrowHeight = v;
    };
    
    TArrowParameters.prototype.GetBeginArrowHeight = function(){
        return this.beginArrowHeight;
    };
    
    TArrowParameters.prototype.SetEndArrowWidth = function(v){
        if (typeof v !== 'undefined' && v !== null && IsNumeric(v))
            this.endArrowWidth = v;
    };
    
    TArrowParameters.prototype.GetEndArrowWidth = function(){
        return this.endArrowWidth;
    };
    
    TArrowParameters.prototype.SetEndArrowHeight = function(v){
        if (typeof v !== 'undefined' && v !== null && IsNumeric(v))
            this.endArrowHeight = v;
    };
    
    TArrowParameters.prototype.GetEndArrowHeight = function(){
        return this.endArrowHeight;
    };
    
};

TArrowParameters.prototype = new TObject();


function TFontParameters(){
    var type = 'TFontParameters';
    TFontParameters.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.font = null;
        this.fontSize = 1;
        this.fontStyle = 'normal';
        this.fontWeight = 'normal';
        this.alignmentX = 'center';
        this.alignmentY = 'center';
        this.curveSegments = 1;
    };
    this.InitConstructor();

    TFontParameters.prototype.Init = function(_object){
        TObject.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TFontParameters'))
        {
            if (typeof _object.fontSize !== 'undefined' && _object.fontSize !== null && IsNumeric(_object.fontSize))
                this.fontSize = _object.fontSize;
            if (typeof _object.font !== 'undefined' && _object.font !== null)
            {
                this.font = new String(_object.font);
                if (this.font !== null)
                    this.font = this.font.toString();
            }
            if (typeof _object.fontStyle !== 'undefined' && _object.fontStyle !== null)
            {
                this.fontStyle = new String(_object.fontStyle);
                if (this.fontStyle !== null)
                    this.fontStyle = this.fontStyle.toString();
            }
            if (typeof _object.fontWeight !== 'undefined' && _object.fontWeight !== null)
            {
                this.fontWeight = new String(_object.fontWeight);
                if (this.fontWeight !== null)
                    this.fontWeight = this.fontWeight.toString();
            }
            if (typeof _object.alignmentX !== 'undefined' && _object.alignmentX !== null)
            {
                this.alignmentX = new String(_object.alignmentX);
                if (this.alignmentX !== null)
                    this.alignmentX = this.alignmentX.toString();
            }
            if (typeof _object.alignmentY !== 'undefined' && _object.alignmentY !== null)
            {
                this.alignmentY = new String(_object.alignmentY);
                if (this.alignmentY !== null)
                    this.alignmentY = this.alignmentY.toString();
            }
            if (typeof _object.curveSegments !== 'undefined' && _object.curveSegments !== null && IsNumeric(_object.curveSegments))
                this.curveSegments = _object.curveSegments;
        }
    };

    TFontParameters.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };
    
    TFontParameters.prototype.ReadXML = function(tag){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('font');
            if (typeof attr !== 'undefined' && attr !== null )
                this.font = attr;
            attr = tag.getAttribute('fontStyle');
            if (typeof attr !== 'undefined' && attr !== null)
                this.fontStyle = attr;
            attr = tag.getAttribute('fontWeight');
            if (typeof attr !== 'undefined' && attr !== null)
                this.fontWeight = attr;
            attr = tag.getAttribute('alignmentX');
            if (typeof attr !== 'undefined' && attr !== null)
                this.alignmentX = attr;
            attr = tag.getAttribute('alignmentY');
            if (typeof attr !== 'undefined' && attr !== null)
                this.alignmentY = attr;
            attr = tag.getAttribute('fontSize');
            if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                this.fontSize = parseFloat(attr);
            attr = tag.getAttribute('curveSegments');
            if (typeof attr !== 'undefined' && attr !== null && IsNumeric(attr))
                this.curveSegments = parseFloat(attr);
        }
    };

    TFontParameters.prototype.SetFont = function(font_){
        if (typeof font_ !== 'undefined' && font_ !== null)
        {
            this.font = new String(font_);
            if (this.font !== null)
                this.font = this.toString();
        }
        if (font_ === null)
            this.font = null;
    };

    TFontParameters.prototype.GetFont = function(){
        var tmp = new String(this.font);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TFontParameters.prototype.SetFontStyle = function(style){
        if (typeof style !== 'undefined' && style !== null)
        {
            this.fontStyle = new String(style);
            if (this.fontStyle !== null)
                this.fontStyle = this.toString();
        }
        if (style === null)
            this.fontStyle = null;
    };

    TFontParameters.prototype.GetFontStyle = function(){
        var tmp = new String(this.fontStyle);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TFontParameters.prototype.SetFontWeight = function(weight){
        if (typeof weight !== 'undefined' && weight !== null)
        {
            this.fontWeight = new String(weight);
            if (this.fontWeight !== null)
                this.fontWeight = this.toString();
        }
        if (weight === null)
            this.fontWeight = null;
    };

    TFontParameters.prototype.GetFontWeight = function(){
        var tmp = new String(this.fontWeight);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TFontParameters.prototype.SetAlignmentX = function(align){
        if (typeof align !== 'undefined' && align !== null)
        {
            this.alignmentX = new String(align);
            if (this.alignmentX !== null)
                this.alignmentX = this.toString();
        }
        if (align === null)
            this.alignmentX = null;
    };

    TFontParameters.prototype.GetAlignmentX = function(){
        var tmp = new String(this.alignmentX);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TFontParameters.prototype.SetAlignmentY = function(align){
        if (typeof align !== 'undefined' && align !== null)
        {
            this.alignmentY = new String(align);
            if (this.alignmentY !== null)
                this.alignmentY = this.toString();
        }
        if (align === null)
            this.alignmentY = null;
    };

    TFontParameters.prototype.GetAlignmentY = function(){
        var tmp = new String(this.alignmentY);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TFontParameters.prototype.SetFontSize = function(size){
        if (typeof size !== 'undefined' && size !== null && IsNumeric(size))
            this.fontSize = size;
    };

    TFontParameters.prototype.GetFontSize = function(){
        return this.fontSize;
    };

    TFontParameters.prototype.SetCurveSegments = function(n){
        if (typeof n !== 'undefined' && n !== null && IsNumeric(n))
            this.curveSegments = n;
    };

    TFontParameters.prototype.GetCurveSegments = function(){
        return this.curveSegments;
    };

};

TFontParameters.prototype = new TObject();


function TThreeBlock(){
    var type = 'TThreeBlock';
    TThreeBlock.prototype.InitConstructor = function(){
        TObjectFigure.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.colourFill = null;
        this.colourLine = null;
        this.colourText = null;
        this.colourSideText = null;
        this.arrowParameters = null;
        this.fontParameters = null;
        this.figures = [];
        this.variables = null;
    };
    this.InitConstructor();

    TThreeBlock.prototype.Init = function(_object){
        TObjectFigure.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TThreeBlock'))
        {
            var i;
            if (typeof _object.colourFill !== 'undefined' && _object.colourFill !== null && _object.colourFill.IsType('TColourTXT'))
                this.colourFill = objM.copy(_object.colourFill);
            if (typeof _object.colourLine !== 'undefined' && _object.colourLine !== null && _object.colourLine.IsType('TColourTXT'))
                this.colourLine = objM.copy(_object.colourLine);
            if (typeof _object.colourText !== 'undefined' && _object.colourText !== null && _object.colourText.IsType('TColourTXT'))
                this.colourText = objM.copy(_object.colourText);
            if (typeof _object.colourSideText !== 'undefined' && _object.colourSideText !== null && _object.colourSideText.IsType('TColourTXT'))
                this.colourSideText = objM.copy(_object.colourSideText);
            if (typeof _object.arrowParameters !== 'undefined' && _object.arrowParameters !== null && _object.arrowParameters.IsType('TArrowParameters'))
                this.arrowParameters = objM.copy(_object.arrowParameters);
            if (typeof _object.fontParameters !== 'undefined' && _object.fontParameters !== null && _object.fontParameters.IsType('TFontParameters'))
                this.fontParameters = objM.copy(_object.fontParameters);
            if (typeof _object.figures !== 'undefined' && _object.figures !== null)
            {
                for (i = 0;i < _object.figures.length;i++)
                    if (typeof _object.figures[i] !== 'undefined' && _object.figures[i] !== null && _object.figures[i].IsType('TObjectFigure'))
                        this.figures[i] = objM.copy(_object.figures[i]);
            }
            if (typeof _object.variables !== 'undefined' && _object.variables !== null && _object.variables.IsType('TVariables'))
                this.variables = objM.copy(_object.variables);
        }
    };

    TThreeBlock.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectFigure.prototype.IsType.call(this,_type);
    };
    
    TThreeBlock.prototype.ReadXML = function(tag){
        TObjectFigure.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var x = tag.childNodes,i,k,fig;
            for (i = 0,k = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    fig = this.GetFigure(k);
                    if (x[i].nodeName === 'F')
                    {
                        if (fig === null)
                        {
                            var attr = x[i].getAttribute('type');
                            if (attr !== null)
                            {
                                switch(attr)
                                {
                                    case 'sphere':
                                        this.SetFigure(k, objM.newObject('TThreeSphere_'));
                                        break;
                                    case 'triangle':
                                        this.SetFigure(k, objM.newObject('TThreeTriangle_'));
                                        break;
                                    case 'line':
                                        this.SetFigure(k, objM.newObject('TThreeLine_'));
                                        break;
                                }
                                fig = this.GetFigure(k);
                            }
                        }
                        if (fig !== null)
                        {
                            fig.SetVariables(this.GetVariables());

                            if (this.colourFill !== null)
                                fig.SetColourRGBA(this.colourFill.GetColour(this.GetObjectVariables()));
                            if (this.colourLine !== null)
                                fig.SetColourLineRGBA(this.colourLine.GetColour(this.GetObjectVariables()));

                            if (fig.IsType('TThreeLine_'))
                            {
                                if (this.arrowParameters !== null)
                                {
                                    fig.SetBeginArrowWidth(this.arrowParameters.GetBeginArrowWidth());
                                    fig.SetBeginArrowHeight(this.arrowParameters.GetBeginArrowHeight());
                                    fig.SetEndArrowWidth(this.arrowParameters.GetEndArrowWidth());
                                    fig.SetEndArrowHeight(this.arrowParameters.GetEndArrowHeight());
                                }
                            }
                            
                            fig.ReadXML(x[i]);                            
                        }
                        k++;
                        continue;
                    }
                    if (x[i].nodeName === 'Text')
                    {
                        if (fig === null)
                        {
                            this.SetFigure(k, objM.newObject('TThreeText_'));
                            fig = this.GetFigure(k);
                        }
                        if (fig !== null)
                        {
                            fig.SetVariables(this.GetVariables());
                            if (this.colourText !== null)
                                fig.SetColourTextRGBA(this.colourText.GetColour(this.GetObjectVariables()));
                            if (this.colourSideText !== null)
                                fig.SetColourSideTextRGBA(this.colourSideText.GetColour(this.GetObjectVariables()));
                            if (this.fontParameters !== null)
                            {
                                fig.SetFont(this.fontParameters.GetFont());
                                fig.SetFontStyle(this.fontParameters.GetFontStyle());
                                fig.SetFontWeight(this.fontParameters.GetFontWeight());
                                fig.SetFontSize(this.fontParameters.GetFontSize());
                                fig.SetCurveSegments(this.fontParameters.GetCurveSegments());
                            }

                            fig.ReadXML(x[i]);                            
                        }
                        k++;
                        continue;
                    }
                    if (x[i].nodeName === 'For')
                    {
                        if (fig === null)
                        {
                            this.SetFigure(k,objM.newObject('TThreeFor'));
                            fig = this.GetFigure(k);
                        }
                        if (fig !== null)
                        {
                            fig.SetVariables(this.GetVariables());
                            fig.SetColourFillTXT(this.GetColourFill());
                            fig.SetColourLineTXT(this.GetColourLine());
                            fig.SetColourTextTXT(this.GetColourText());
                            fig.SetColourSideTextTXT(this.GetColourSideTextTXT());
                            fig.SetArrowParameters(this.GetArrowParameters());
                            fig.SetFontParameters(this.GetFontParameters());
                            fig.ReadXML(x[i]);                            
                        }
                        k++;
                        continue;
                    }
                    if (x[i].nodeName === 'If')
                    {
                        if (fig === null)
                        {
                            this.SetFigure(k,objM.newObject('TThreeIf'));
                            fig = this.GetFigure(k);
                        }
                        if (fig !== null)
                        {
                            fig.SetVariables(this.GetVariables());
                            fig.SetColourFillTXT(this.GetColourFill());
                            fig.SetColourLineTXT(this.GetColourLine());
                            fig.SetColourTextTXT(this.GetColourText());
                            fig.SetColourSideTextTXT(this.GetColourSideTextTXT());
                            fig.SetArrowParameters(this.GetArrowParameters());
                            fig.SetFontParameters(this.GetFontParameters());
                            fig.ReadXML(x[i]);                            
                        }
                        k++;
                        continue;
                    }
                    if (x[i].nodeName === 'Colour')
                    {
                        if (this.colourFill === null)
                            this.colourFill = objM.newObject('TColourTXT');
                        if (this.colourFill !== null)
                            this.colourFill.ReadXML(x[i]);
                    }
                    if (x[i].nodeName === 'ColourLine')
                    {
                        if (this.colourLine === null)
                            this.colourLine = objM.newObject('TColourTXT');
                        if (this.colourLine !== null)
                            this.colourLine.ReadXML(x[i]);
                    }
                    if (x[i].nodeName === 'TextColour')
                    {
                        if (this.colourText === null)
                            this.colourText = objM.newObject('TColourTXT');
                        if (this.colourText !== null)
                            this.colourText.ReadXML(x[i]);
                    }
                    if (x[i].nodeName === 'TextSideColour')
                    {
                        if (this.colourSideText === null)
                            this.colourSideText = objM.newObject('TColourTXT');
                        if (this.colourSideText !== null)
                            this.colourSideText.ReadXML(x[i]);
                    }
                    if (x[i].nodeName === 'TextStyle')
                    {
                        if (this.fontParameters === null)
                            this.fontParameters = objM.newObject('TFontParameters');
                        if (this.fontParameters !== null)
                            this.fontParameters.ReadXML(x[i]);
                    }
                    if (x[i].nodeName === 'Style')
                    {
                        if (this.arrowParameters === null)
                            this.arrowParameters = objM.newObject('TArrowParameters');
                        if (this.arrowParameters !== null)
                            this.arrowParameters.ReadXML(x[i]);
                    }
                }
            }
        }
    };

    TThreeBlock.prototype.SetColourFill = function(c){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof c !== 'undefined' && c !== null && c.IsType('TColourTXT'))
            this.colourFill = objM.copy(c);
    };
    
    TThreeBlock.prototype.GetColourFill = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.copy(this.colourFill);
    };
    
    TThreeBlock.prototype.SetColourLine = function(c){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof c !== 'undefined' && c !== null && c.IsType('TColourTXT'))
            this.colourLine = objM.copy(c);
    };
    
    TThreeBlock.prototype.GetColourLine = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.copy(this.colourLine);
    };
    
    TThreeBlock.prototype.SetColourText = function(c){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof c !== 'undefined' && c !== null && c.IsType('TColourTXT'))
            this.colourText = objM.copy(c);
    };
    
    TThreeBlock.prototype.GetColourText = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.copy(this.colourText);
    };
    
    TThreeBlock.prototype.SetColourSideText = function(c){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof c !== 'undefined' && c !== null && c.IsType('TColourTXT'))
            this.colourSideText = objM.copy(c);
    };
    
    TThreeBlock.prototype.GetColourSideText = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.copy(this.colourSideText);
    };
    
    TThreeBlock.prototype.SetArrowParameters = function(c){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof c !== 'undefined' && c !== null && c.IsType('TArrowParameters'))
            this.arrowParameters = objM.copy(c);
    };
    
    TThreeBlock.prototype.GetArrowParameters = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.copy(this.arrowParameters);
    };
    
    TThreeBlock.prototype.SetFontParameters = function(f){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof f !== 'undefined' && f !== null && f.IsType('TFontParameters'))
            this.fontParameters = objM.copy(f);
    };
    
    TThreeBlock.prototype.GetFontParameters = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.copy(this.fontParameters);
    };

    TThreeBlock.prototype.GetFigure = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0 && number < this.figures.length)
        {
            return this.figures[number];
        }
        return null;
    };

    TThreeBlock.prototype.SetFigure = function(number,fig){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0)
        {
            if (typeof fig !== 'undefined' && fig !== null && fig.IsType('TObjectFigure'))
                this.figures[number] = fig;
        }
    };

    TThreeBlock.prototype.GetObjectVariables = function(){
        return this.variables;
    };

    TThreeBlock.prototype.SetObjectVariables = function(var_){
        if (typeof var_ !== 'undefined' && var_ !== null && var_.IsType('TVariables'))
            this.variables = var_;
    };

    TThreeBlock.prototype.GetFigures = function(){
        return this.figures;
    };

    TThreeBlock.prototype.DrawFigure = function(ctx){
        if (typeof ctx !== 'undefined' && ctx !== null && ctx.IsType('TDrawContext'))
        {
            var i,n = this.figures.length;
            for (i = 0;i < n;i++)
            {
                if (typeof this.figures[i] !== 'undefined' && this.figures[i] !== null && this.figures[i].IsType('TObjectFigure'))
                {
                    this.figures[i].DrawFigure(ctx);
                }
            }
        }
    };
};

TThreeBlock.prototype = new TObjectFigure();

function TThreeFor(){
    var type = 'TThreeFor';
    TThreeFor.prototype.InitConstructor = function(){
        TObjectFigure.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.variable = null;
        this.startValue = null;
        this.endValue = null;
        this.step = '1';
        this.figure2 = null;
    };
    this.InitConstructor();

    TThreeFor.prototype.Init = function(_object){
        TObjectFigure.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TThreeFor'))
        {
            if (typeof _object.variable !== 'undefined' && _object.variable !== null && _object.variable.IsType('TVariableDouble'))
                this.variable = _object.variable;
            if (typeof _object.startValue !== 'undefined' && _object.startValue !== null)
            {
                this.startValue = new String(_object.startValue);
                if (this.startValue !== null)
                    this.startValue = this.startValue.toString();
            }
            if (typeof _object.endValue !== 'undefined' && _object.endValue !== null)
            {
                this.endValue = new String(_object.endValue);
                if (this.endValue !== null)
                    this.endValue = this.endValue.toString();
            }
            if (typeof _object.step !== 'undefined' && _object.step !== null)
            {
                this.step = new String(_object.step);
                if (this.step !== null)
                    this.step = this.step.toString();
            }
            if (typeof _object.figure2 !== 'undefined' && _object.figure2 !== null && _object.figure2.IsType('TObjectFigure'))
                this.figure2 = objM.copy(_object.figure2);
        }
    };

    TThreeFor.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectFigure.prototype.IsType.call(this,_type);
    };
    
    TThreeFor.prototype.ReadXML = function(tag){
        TObjectFigure.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('var');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                this.variable = objM.newObject('TVariableDouble');
                if (this.variable !== null)
                    this.variable.SetName(attr);
            }
            attr = tag.getAttribute('startValue');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                this.startValue = attr;
                this.variable.SetValue(attr);
                this.variable.SetEquation(attr);
            }
            attr = tag.getAttribute('endValue');
            if (typeof attr !== 'undefined' && attr !== null)
                this.endValue = attr;
            attr = tag.getAttribute('step');
            if (typeof attr !== 'undefined' && attr !== null)
                this.step = attr;
            var block = this.GetFigure();
            if (block === null)
                block = objM.newObject('TThreeBlock');
            if (block !== null)
            {
                this.SetFigure(block);
                block.SetVariables(this.GetVariables());
                block.SetVariable(this.variable);
                block.SetColourFill(this.GetColourFillTXT());
                block.SetColourLine(this.GetColourLineTXT());
                block.SetColourText(this.GetColourTextTXT());
                block.SetColourSideText(this.GetColourSideTextTXT());
                block.SetArrowParameters(this.GetArrowParameters());
                block.SetFontParameters(this.GetFontParameters());
                block.ReadXML(tag);
            }
        }
    };

    TThreeFor.prototype.SetFigure = function(fig)
    {
        if (typeof fig !== 'undefined' && fig !== null && fig.IsType('TObjectFigure'))
            this.figure2 = fig;
        if (fig === null)
            this.figure2 = null;
    };

    TThreeFor.prototype.GetFigure = function()
    {
        return this.figure2;
    };

    TThreeFor.prototype.DrawFigure = function(ctx){
        if (typeof ctx !== 'undefined' && ctx !== null && ctx.IsType('TDrawContext'))
        {
            var obj = this.GetFigure();
            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
            {
                if (this.variable !== null)
                {
                    var start_,stop_,step_,i;
                    start_ = this.CalculateValue(this.startValue);
                    stop_ = this.CalculateValue(this.endValue);
                    step_ = this.CalculateValue(this.step);
                    if (typeof start_ !== 'undefined' && start_ !== null && IsNumeric(start_))
                    {
                        if (typeof stop_ !== 'undefined' && stop_ !== null && IsNumeric(stop_))
                        {
                            if (typeof step_ !== 'undefined' && step_ !== null && IsNumeric(step_))
                            {
				if (step_ != 0)
				{
				    if (step_ > 0)
				    {
                                	for (i = start_;i <= stop_;i = i + step_)
                                	{
	                                    this.variable.SetValue(i);
	                                    obj.DrawFigure(ctx);                                    
	                                }
				    }else
				    {
                                	for (i = start_;i >= stop_;i = i + step_)
                                	{
	                                    this.variable.SetValue(i);
	                                    obj.DrawFigure(ctx);                                    
	                                }
				    }
				}
                            }                        
                        }                        
                    }
                }
            }
        }
    };

};

TThreeFor.prototype = new TObjectFigure();

function TThreeIf(){
    var type = 'TThreeIf';
    TThreeIf.prototype.InitConstructor = function(){
        TObjectFigure.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.condition = null;
        this.figure2 = null;
    };
    this.InitConstructor();

    TThreeIf.prototype.Init = function(_object){
        TObjectFigure.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TThreeIf'))
        {
            if (typeof _object.condition !== 'undefined' && _object.condition !== null)
            {
                this.condition = new String(_object.condition);
                if (this.condition !== null)
                    this.condition = this.condition.toString();
            }
            if (typeof _object.figure2 !== 'undefined' && _object.figure2 !== null && _object.figure2.IsType('TObjectFigure'))
                this.figure2 = objM.copy(_object.figure2);
        }
    };

    TThreeIf.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectFigure.prototype.IsType.call(this,_type);
    };
    
    TThreeIf.prototype.ReadXML = function(tag){
        TObjectFigure.prototype.ReadXML.call(this,tag);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var attr = tag.getAttribute('condition');
            if (typeof attr !== 'undefined' && attr !== null)
                this.condition = attr;
            var block = this.GetFigure();
            if (block === null)
                block = objM.newObject('TThreeBlock');
            if (block !== null)
            {
                this.SetFigure(block);
                block.SetVariables(this.GetVariables());
                block.SetVariable(this.variable);
                block.SetColourFill(this.GetColourFillTXT());
                block.SetColourLine(this.GetColourLineTXT());
                block.SetColourText(this.GetColourTextTXT());
                block.SetColourSideText(this.GetColourSideTextTXT());
                block.SetArrowParameters(this.GetArrowParameters());
                block.SetFontParameters(this.GetFontParameters());
                block.ReadXML(tag);
            }
        }
    };

    TThreeIf.prototype.SetFigure = function(fig)
    {
        if (typeof fig !== 'undefined' && fig !== null && fig.IsType('TObjectFigure'))
            this.figure2 = fig;
        if (fig === null)
            this.figure2 = null;
    };

    TThreeIf.prototype.GetFigure = function()
    {
        return this.figure2;
    };

    TThreeIf.prototype.DrawFigure = function(ctx){
        if (typeof ctx !== 'undefined' && ctx !== null && ctx.IsType('TDrawContext'))
        {
            var obj = this.GetFigure();
            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
            {
                if (this.condition !== null)
                {
                    var cond;
                    cond = this.CalculateValue(this.condition);
                    if (cond)
                    {
                        obj.DrawFigure(ctx);                                    
                    }
                }
            }
        }
    };

};

TThreeIf.prototype = new TObjectFigure();


function TThreeDraw(){
    var type = 'TThreeDraw';
    TThreeDraw.prototype.InitConstructor = function(){
        TDrawObject.prototype.InitConstructor.call(this);
        this.cameraCoordinates = null;
        this.cameraType = 'orthographic';
        this.cameraAngle = 45;
        this.cameraNear = 1;
        this.cameraFar = 100;
        this.scaleTeX = 80;
        this.widthTeX = -1;
        this.alpha = 0;
        this.beta = 0;
        this.distanceCamera = 1;
        this.typeRenderer = 'three';
        this.SetType(type);
    };
    this.InitConstructor();

    TThreeDraw.prototype.Init = function(_object){
        TDrawObject.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TThreeDraw'))
        {
            if (typeof _object.cameraCoordinates !== 'undefined' && _object.cameraCoordinates !== null && _object.cameraCoordinates.IsType('TVector3DT'))
                this.cameraCoordinates = objM.copy(_object.cameraCoordinates);
            if (typeof _object.cameraType !== 'undefined' && _object.cameraType !== null)
            {
                this.cameraType = new String(_object.cameraType);
                if (this.cameraType !== null)
                    this.cameraType = this.cameraType.toString();
            }
            if (typeof _object.cameraAngle !== 'undefined' && _object.cameraAngle !== null && IsNumeric(_object.cameraAngle))
                this.cameraAngle = _object.cameraAngle;
            if (typeof _object.cameraNear !== 'undefined' && _object.cameraNear !== null && IsNumeric(_object.cameraNear))
                this.cameraNear = _object.cameraNear;
            if (typeof _object.scaleTeX !== 'undefined' && _object.scaleTeX !== null && IsNumeric(_object.scaleTeX))
                this.scaleTeX = _object.scaleTeX;
            if (typeof _object.widthTeX !== 'undefined' && _object.widthTeX !== null && IsNumeric(_object.widthTeX))
                this.widthTeX = _object.widthTeX;
            if (typeof _object.alpha !== 'undefined' && _object.alpha !== null && IsNumeric(_object.alpha))
                this.alpha = _object.alpha;
            if (typeof _object.beta !== 'undefined' && _object.beta !== null && IsNumeric(_object.beta))
                this.beta = _object.beta;
            if (typeof _object.distanceCamera !== 'undefined' && _object.distanceCamera !== null && IsNumeric(_object.distanceCamera))
                this.distanceCamera = _object.distanceCamera;
            if (typeof _object.typeRenderer !== 'undefined' && _object.typeRenderer !== null)
            {
                this.typeRenderer = new String(_object.typeRenderer);
                if (this.typeRenderer !== null)
                    this.typeRenderer = this.typeRenderer.toString();
            }
        }
    };

    TThreeDraw.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TDrawObject.prototype.IsType.call(this,_type);
    };
    
    TThreeDraw.prototype.ReadXML = function(tag,fun){
        TDrawObject.prototype.ReadXML.call(this,tag,fun);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            var tmp,tmp2;
            var attr;
            var obj,camera;
            this.ReadXMLData(tag);
            
            camera = objM.newObject('TThreeCamera');

            attr = tag.getAttribute('buttonLeft');
            if (typeof attr !== 'undefined' && attr !== null && attr === 'Yes')
            {
                obj = objM.newObject('TActionThreeRotateButton');
                if (obj !== null)
                {
                    obj.SetCamera(camera);
                    obj.SetButtonType('left');
                    obj.SetId(this.GetId() + 'left');
                    obj.SetId(this.GetId(),0);
                    obj.SetParent(this);
                    this.SetAction(obj,0);
                }
            }
            attr = tag.getAttribute('buttonRight');
            if (typeof attr !== 'undefined' && attr !== null && attr === 'Yes')
            {
                obj = objM.newObject('TActionThreeRotateButton');
                if (obj !== null)
                {
                    obj.SetCamera(camera);
                    obj.SetButtonType('right');
                    obj.SetId(this.GetId() + 'right');
                    obj.SetId(this.GetId(),0);
                    obj.SetParent(this);
                    this.SetAction(obj,1);
                }
            }
            attr = tag.getAttribute('buttonTop');
            if (typeof attr !== 'undefined' && attr !== null && attr === 'Yes')
            {
                obj = objM.newObject('TActionThreeRotateButton');
                if (obj !== null)
                {
                    obj.SetCamera(camera);
                    obj.SetButtonType('top');
                    obj.SetId(this.GetId() + 'top');
                    obj.SetId(this.GetId(),0);
                    obj.SetParent(this);
                    this.SetAction(obj,2);
                }
            }
            attr = tag.getAttribute('buttonBottom');
            if (typeof attr !== 'undefined' && attr !== null && attr === 'Yes')
            {
                obj = objM.newObject('TActionThreeRotateButton');
                if (obj !== null)
                {
                    obj.SetCamera(camera);
                    obj.SetButtonType('bottom');
                    obj.SetId(this.GetId() + 'bottom');
                    obj.SetId(this.GetId(),0);
                    obj.SetParent(this);
                    this.SetAction(obj,3);
                }
            }

            attr = tag.getAttribute('alpha');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                tmp = parseFloat(attr);
                if (tmp !== null && IsNumeric(tmp))
                {
                    tmp2 = tmp*Math.PI/180;
                    this.alpha = tmp2;
                    camera.SetAlpha(tmp2);
                    obj = this.GetAction(0);
                    if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TActionThreeRotateButton'))
                        obj.SetAlpha(tmp2);
                    obj = this.GetAction(1);
                    if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TActionThreeRotateButton'))
                        obj.SetAlpha(tmp2);
                }
            }
            attr = tag.getAttribute('skipAlpha');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                tmp = parseFloat(attr);
                if (tmp !== null && IsNumeric(tmp))
                {
                    tmp2 = tmp*Math.PI/180;
                    obj = this.GetAction(0);
                    if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TActionThreeRotateButton'))
                        obj.SetSkipAlpha(tmp2);
                    obj = this.GetAction(1);
                    if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TActionThreeRotateButton'))
                        obj.SetSkipAlpha(tmp2);
                }
            }
            attr = tag.getAttribute('beta');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                tmp = parseFloat(attr);
                if (tmp !== null && IsNumeric(tmp))
                {
                    tmp2 = tmp*Math.PI/180;
                    this.beta = tmp2;
                    camera.SetBeta(tmp2);
                    obj = this.GetAction(2);
                    if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TActionThreeRotateButton'))
                        obj.SetBeta(tmp2);
                    obj = this.GetAction(3);
                    if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TActionThreeRotateButton'))
                        obj.SetBeta(tmp2);
                }
            }
            attr = tag.getAttribute('skipBeta');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                tmp = parseFloat(attr);
                if (tmp !== null && IsNumeric(tmp))
                {
                    tmp2 = tmp*Math.PI/180;
                    obj = this.GetAction(2);
                    if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TActionThreeRotateButton'))
                        obj.SetSkipBeta(tmp2);
                    obj = this.GetAction(3);
                    if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TActionThreeRotateButton'))
                        obj.SetSkipBeta(tmp2);
                }
            }
            
            this.cameraCoordinates = objM.newObject('TVector3DT');
            if (this.cameraCoordinates !== null)
            {
                attr = tag.getAttribute('camX');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                    {
                        this.cameraCoordinates.SetX(attr);
                    }
                }
                attr = tag.getAttribute('camY');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                    {
                        this.cameraCoordinates.SetY(attr);
                    }
                }
                attr = tag.getAttribute('camZ');
                if (typeof attr !== 'undefined' && attr !== null)
                {
                    attr = parseFloat(attr);
                    if (attr !== null && IsNumeric(attr))
                    {
                        this.cameraCoordinates.SetZ(attr);
                    }
                }                
            }    
            attr = tag.getAttribute('camDist');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseFloat(attr);
                if (attr !== null && IsNumeric(attr))
                {
                    this.distanceCamera=attr;
                }
            }
            
            attr = tag.getAttribute('camType');
            if (typeof attr !== 'undefined' && attr !== null)
                this.cameraType = attr;
            attr = tag.getAttribute('camAngle');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseFloat(attr);
                if (attr !== null && IsNumeric(attr))
                    this.cameraAngle = attr;
            }
            attr = tag.getAttribute('camNear');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseFloat(attr);
                if (attr !== null && IsNumeric(attr))
                    this.cameraNear = attr;
            }
            attr = tag.getAttribute('camFar');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseFloat(attr);
                if (attr !== null && IsNumeric(attr))
                    this.cameraFar = attr;
            }
            attr = tag.getAttribute('scaleTeX');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseFloat(attr);
                if (attr !== null && IsNumeric(attr))
                    this.scaleTeX = attr;
            }
            attr = tag.getAttribute('widthTeX');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseFloat(attr);
                if (attr !== null && IsInt(attr))
                    this.widthTeX = attr;
            }
            attr = tag.getAttribute('typeRenderer');
            if (typeof attr !== 'undefined' && attr !== null)
                this.typeRenderer = attr;
            var block = this.GetFigure(0);
            if (block === null)
                block = objM.newObject('TThreeBlock');
            if (block !== null)
            {
                this.SetFigure(0, block);
                block.SetVariables(this.GetVariables());
                block.ReadXML(tag);
            }
        }
    };


    TThreeDraw.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var tmp2 = [],id = this.GetId(),controls = [];
            if (id !== null)
            {
                controls[0] = this.GetAction(0);
                controls[1] = this.GetAction(1);
                controls[2] = this.GetAction(2);
                controls[3] = this.GetAction(3);
                
                tmp2[0] = this.GetWidth();
                tmp2[1] = this.GetHeight();
                tmp2[2] = this.GetFigures();
                tmp2[3] = this.GetXMax()-this.GetXMin();
                tmp2[4] = this.GetYMax()-this.GetYMin();
                tmp2[5] = this.GetZMax()-this.GetZMin();
                tmp2[6] = this.GetXMin();
                tmp2[7] = this.GetYMin();
                tmp2[8] = this.GetZMin();
                tmp2[9] = this.GetAlignX();
                tmp2[10] = this.GetColourBackground();
                tmp2[11] = this.cameraCoordinates;
                tmp2[12] = this.cameraType;
                tmp2[13] = this.cameraAngle;
                tmp2[14] = this.cameraNear;
                tmp2[15] = this.cameraFar;
                tmp2[16] = controls;
//                tmp2[17] = RandomString(15);
                tmp2[18] = this.scaleTeX;
                tmp2[19] = this.widthTeX;
                if (typeof controls[0] !== 'undefined' && controls[0] !== null && controls[0].IsType('TActionThreeCamera'))
                {
                    tmp2[20] = controls[0].GetAlpha();
                    tmp2[21] = controls[0].GetBeta();
                }else
                {
                    tmp2[20] = this.alpha;
                    tmp2[21] = this.beta;
                }
                tmp2[22] = this.distanceCamera;
                tmp2[23] = this.typeRenderer;
                tmp2[24] = this.classStyle;
                _object.Add('GenerateThree',id,tmp2);
            }
        }
    };

    TThreeDraw.prototype.SetAlpha = function(alpha_){
        if (typeof alpha_ !== 'undefined' && alpha_ !== null && IsNumeric(alpha_))
            this.alpha = alpha_;
    };

    TThreeDraw.prototype.SetBeta = function(beta_){
        if (typeof beta_ !== 'undefined' && beta_ !== null && IsNumeric(beta_))
            this.beta = beta_;
    };
};

TThreeDraw.prototype = new TDrawObject();


function TDrawFigure(){
    var type = 'TDrawFigure';
    TDrawFigure.prototype.InitConstructor = function(){
        TNumberElement.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.figure = [];
        this.caption = null;
        this.imageCatalog = null;
        this.alignX = null;
        this.SetTypePageElement('DrawFigure');
        this.positionTeX = 'htbp';
    };
    this.InitConstructor();

    TDrawFigure.prototype.Init = function(_object){
        TNumberElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TDrawFigure'))
        {
            var i;
            if (typeof _object.caption !== 'undefined' && _object.caption !== null && _object.caption.IsType('TFigureElementCaption'))
                this.caption = objM.copy(_object.caption);
            if (typeof _object.figure !== 'undefined' && _object.figure !== null)
            {
                for (i = 0;i < _object.figure.length;i++)
//                    this.figure[i] = objM.copy(_object.figure[i]);
                    this.figure[i] = _object.figure[i];
            }
            if (typeof _object.imageCatalog !== 'undefined' && _object.imageCatalog !== null)
            {
                this.imageCatalog = new String(_object.imageCatalog);
                if (this.imageCatalog !== null)
                    this.imageCatalog = this.imageCatalog.toString();
            }
            if (typeof _object.alignX !== 'undefined' && _object.alignX !== null)
            {
                this.alignX = new String(_object.alignX);
                if (this.alignX !== null)
                    this.alignX = this.alignX.toString();
            }
            if (typeof _object.positionTeX !== 'undefined' && _object.positionTeX !== null)
            {
                this.positionTeX = new String(_object.positionTeX);
                if (this.positionTeX !== null)
                    this.positionTeX = this.positionTeX.toString();
            }
        }
    };

    TDrawFigure.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TNumberElement.prototype.IsType.call(this,_type);
    };
    
    
    TDrawFigure.prototype.ReadXML = function(tag,fun){
        TNumberElement.prototype.ReadXML.call(this,tag,fun);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            this.ReadXMLInit(tag);
            var attr = tag.getAttribute('positionTeX');
            this.SetPositionTeX(attr);
            
            var i,x = tag.childNodes,kk,obj,n,n2,k;
            for (i = 0,kk = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1 && x[i].nodeName === 'Caption')
                {
                    if (this.caption === null)
                        this.caption = objM.newObject('TFigureElementCaption');
                    if (this.caption !== null)
                        this.caption.ReadXML(x[i],fun);
                }
                if (x[i].nodeType === 1 && x[i].nodeName === 'Figure')
                {
                    attr = x[i].getAttribute('type');
                    if (attr !== null)
                    {
                        obj = this.figure[kk];
                        if (typeof obj === 'undefined' || obj === null)
                        {
                            obj = objM.newObject('T'+attr);
                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                            {
                                obj.SetVariables(this.GetVariables());
                                obj.SetDefaultLanguage(this.GetDefaultLanguage());
                                this.figure[kk] = obj;
                                this.figure[kk].SetImageCatalog(this.imageCatalog);
                                if (this.figure[kk].IsType('TDraw'))
                                    this.figure[kk].SetAlignX(this.alignX);
                            }
                        }
                        if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                        {
                            obj.ReadXML(x[i],fun);
/////////////// ????????????????????????????????                            
                            if(attr === 'InteractiveImageBitmap')
                            {
                                n = obj.GetNActions();
                                n2 = this.GetNActions();
                                for (k = 0,k2 = n2;k < n;k++,k2++)
                                {
                                    this.SetAction(obj.GetAction(k),k2);
                                }                   
                            }
                        }
                        kk++;
                    }
                    
                }
            }

        }
    };

    TDrawFigure.prototype.ChangeCurrentLanguageNumber = function(_language){
        TNumberElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        if (typeof this.figure !== 'undefined' && this.figure !== null)
        {
            var i;
            for (i = 0;i < this.figure.length;i++)
                if (this.figure[i] !== null)
                    this.figure[i].ChangeCurrentLanguageNumber(_language);
        }
        if (this.caption !== null)
            this.caption.ChangeCurrentLanguageNumber(_language);
        if (typeof this.figureName !== 'undefined' && this.figureName !== null && this.figureName.IsType('TMultilanguageStringData'))
            this.figureName.ChangeCurrentLanguageNumber(_language);
    };

    TDrawFigure.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var YN = this.GetVisible(),i,j;
            if (typeof _object.drawObject !== 'undefined' && _object.drawObject !== null && _object.drawObject.GetObjectType() === 'TeX')
                YN = true;
            if (YN)
            {
                var tmp = [];
                tmp[0] = this.GetId();
                tmp[1] = this.alignX;
                tmp[2] = this.positionTeX;
                _object.Add('Figure','Start',tmp);
//                if (typeof this.caption !== 'undefined' && this.caption !== null && this.caption.IsType('TFigureElementCaption'))
                _object.Add('Subfigure','Start');
                for (i = 0,j = 0;i < this.figure.length;i++)
                {
                    if (typeof this.figure[i] !== 'undefined' && this.figure[i] !== null && this.figure[i].IsType('TPageElement'))
                    {
                        if (this.figure.length > 1)
                            _object.Add('Subfigure','Number',alphabet[j++]);
                        else
                            _object.Add('Subfigure','NotNumber');
                        this.figure[i].Draw(_object);
                    }
                }
                _object.Add('Subfigure','Stop');
                if (typeof this.caption !== 'undfined' && this.caption !== null && this.caption.IsType('TFigureElementCaption'))
                {
                    var name = this.GetObjectNameString();
                    var number = this.GetNumber();
                    if (!this.GetNumeration())
                        number = null;
                    this.caption.Draw(_object,name,number);
                }
                _object.Add('Figure','Stop');
            }
        }        
    };

    TDrawFigure.prototype.ActualizeId = function(_pageElements){
        if(typeof this.caption !== 'undefined' && this.caption !== null)
        {
            this.caption.ActualizeId(_pageElements);
        }
        TNumberElement.prototype.ActualizeId.call(this,_pageElements);
    };

    TDrawFigure.prototype.SetImageCatalog = function(catalog){
        if (typeof catalog !== 'undefined' && this.catalog !== null)
        {
            this.imageCatalog = catalog;
            if (typeof this.figure !== 'undefined' && this.figure !== null)
            {
                var i;
                for (i = 0;i < this.figure.length;i++)
                    if (typeof this.figure[i] !== 'undefined' && this.figure[i] !== null && this.figure[i].IsType('TDraw'))
                        this.figure[i].SetImageCatalog(catalog);
            }
        }
    };

    TDrawFigure.prototype.SetAlignX = function(align){
        if (typeof align !== 'undefined' && this.align !== null)
        {
            this.alignX = new String(align);
            if (this.alignX !== null)
                this.alignX = this.alignX.toString();
            if (typeof this.figure !== 'undefined' && this.figure !== null)
            {
                var i;
                for (i = 0;i < this.figure.length;i++)
                    if (typeof this.figure[i] !== 'undefined' && this.figure[i] !== null && this.figure[i].IsType('TDraw'))
                        this.figure[i].SetAlignX(align);
            }
        }
        if (align === null)
            this.alignX = null;
    };

    TDrawFigure.prototype.GetFigure = function(number){
        if (typeof number !== 'undefined' && number !== null && number >= 0 && number < this.figure.length)
        {
            return this.figure[number];
        }
        return null;
    };

    TDrawFigure.prototype.GetNumberOfFigure = function(){
        return this.figure.length;
    };

    TDrawFigure.prototype.ActualizeActions = function(){
        TNumberElement.prototype.ActualizeActions.call(this);
// ????????????????????????
        if (typeof this.figure !== 'undefined' && this.figure !== null)
        {
            var i;
            for (i = 0;i < this.figure.length;i++)
                if (this.figure[i] !== null && this.figure[i].IsType('TThreeDraw'))
                    this.figure[i].ActualizeActions();
        }
    };

    TDrawFigure.prototype.SetPositionTeX = function(pos){
        if (typeof pos !== 'undefined' && pos !== null)
        {
            this.positionTeX = new String(pos);
            if (this.positionTeX !== null)
                this.positionTeX = this.positionTeX.toString();
        }
    };


    TDrawFigure.prototype.SetDefaultLanguage = function(_language){
        TNumberElement.prototype.SetDefaultLanguage.call(this,_language);
        if (typeof this.figure !== 'undefined' && this.figure !== null)
        {
            var i;
            for (i = 0;i < this.figure.length;i++)
                if (this.figure[i] !== null)
                    this.figure[i].SetDefaultLanguage(_language);
        }
    };


}

TDrawFigure.prototype = new TNumberElement();

function TNote(){
    var type = 'TNote';
    TNote.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.noteElements = [];
        this.SetType(type);            
        this.SetTypePageElement('Note');
    };
    this.InitConstructor();

    TNote.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TNote'))
        {
            var i;
            if (typeof _object.noteElements !== 'undefined' && _object.noteElements !== null)
            {
                for (i = 0;i < _object.noteElements.length;i++)
                    this.noteElements[i] = objM.copy(_object.noteElements[i]);
            }
        }
    };

    TNote.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    
    TNote.prototype.ReadXML = function(tag,fun){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            this.ReadXMLInit(tag);
            var i,x = tag.childNodes,tag2,attr,obj,kk;

            if (x !== null)
            {
                for (i = 0,kk = 0;i < x.length;i++)
                {
                    tag2 = x[i];                                                           
                    if (tag2 !== null && tag2.nodeType === 1)
                    {
                        attr = tag2.getAttribute('type');
                        if (attr !== null)
                        {
                            obj = this.noteElements[kk];
                            if (typeof obj === 'undefined' || obj === null)
                            {
                                obj = objM.newObject('T'+attr);
                                if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                                {
                                    this.noteElements[kk] = obj;
//                                                                                obj.SetReferenceName(object.GetReferenceName());
//                                                                                obj.SetReferenceValue(object.GetReferenceValue());
                                }
                            }
                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                            {
                                obj.ReadXML(tag2);
                            }
                            kk++;
                        }
                    }
                }
            }

        }
    };

    TNote.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        if (typeof this.noteElements !== 'undefined' && this.noteElements !== null)
        {
            var i;
            for (i = 0;i < this.noteElements.length;i++)
                if (this.noteElements[i] !== null)
                    this.noteElements[i].ChangeCurrentLanguageNumber(_language);
        }
    };

    TNote.prototype.Draw = function(_object,numberNote){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var YN = this.GetVisible();
            if (typeof _object.drawObject !== 'undefined' && _object.drawObject !== null && _object.drawObject.GetObjectType() === 'TeX')
                YN = true;
            if (YN)
            {
                _object.Add('Note','Start',numberNote);
                if (typeof this.noteElements !== 'undefined' && this.noteElements !== null)
                {
                    var i;
                    for (i = 0;i < this.noteElements.length;i++)
                        if (this.noteElements[i] !== null)
                            this.noteElements[i].Draw(_object);
                }
                _object.Add('Note','Stop');
            }
        }        
    };

    TNote.prototype.ActualizeData = function(data){
        TPageElement.prototype.ActualizeData.call(this,data);
        if (typeof data !== 'undefined' && data !== null && data.IsType('TReadPaperData'))
        {
            var n = this.noteElements.length,i,ob;
            for (i = 0;i < n;i++)
            {
                if (typeof this.noteElements[i] !== 'undefined' && this.noteElements[i] !== null && this.noteElements[i].IsType('TPageElement'))
                {
                    ob = this.noteElements[i].ActualizeData(data);
                    if (ob !== null && this.noteElements[i].IsType('TReference'))
                        this.noteElements[i] = ob;
                }
            }
        }
        return null;
    };

/*    TNote.prototype.ActualizeId = function(_pageElements){
        if(typeof this.caption !== 'undefined' && this.caption !== null)
        {
            this.caption.ActualizeId(_pageElements);
        }
        TPageElement.prototype.ActualizeId.call(this,_pageElements);
    };*/

}

TNote.prototype = new TPageElement();


function TAuthor(){
    var type = 'TAuthor';
    TAuthor.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.name = [];
        this.surname = [];
        this.idAffiliation = [];
        this.affiliation = [];
        this.email = [];
        this.WWW = [];
        this.SetTypePageElement('Author');
    };
    this.InitConstructor();

    TAuthor.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TAuthor'))
        {
            var i;
            if (typeof _object.name !== 'undefined' && _object.name !== null)
            {
                for (i = 0;i < _object.name.length;i++)
                    this.name[i] = objM.copy(_object.name[i]);
            }
            if (typeof _object.surname !== 'undefined' && _object.surname !== null)
            {
                for (i = 0;i < _object.surname.length;i++)
                    this.surname[i] = objM.copy(_object.surname[i]);
            }
            if (typeof _object.idAffiliation !== 'undefined' && _object.idAffiliation !== null)
            {
                for (i = 0;i < _object.idAffiliation.length;i++)
                {
                    this.idAffiliation[i] = new String(_object.idAffiliation[i]);
                    this.idAffiliation[i] = this.idAffiliation[i].toString();
                }
            }
            if (typeof _object.affiliation !== 'undefined' && _object.affiliation !== null)
            {
                for (i = 0;i < _object.affiliation.length;i++)
                    this.affiliation[i] = _object.affiliation[i];
            }
            if (typeof _object.email !== 'undefined' && _object.email !== null)
            {
                for (i = 0;i < _object.email.length;i++)
                    this.email[i] = objM.copy(_object.email[i]);
            }
            if (typeof _object.WWW !== 'undefined' && _object.WWW !== null)
            {
                for (i = 0;i < _object.WWW.length;i++)
                    this.WWW[i] = objM.copy(_object.WWW[i]);
            }
        }
    };

    TAuthor.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    
    TAuthor.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var i,txt;
            if (typeof this.name !== 'undefined' && this.name !== null && this.name.length > 0)
            {
                for (i = 0;i < this.name.length;i++)
                    _object.Add('AuthorName',this.name[i].GetStringData());
            }
            if (typeof this.surname !== 'undefined' && this.surname !== null && this.surname.length > 0)
            {
                for (i = 0;i < this.surname.length;i++)
                    _object.Add('AuthorSurname',this.surname[i].GetStringData());

            }
            _object.Enter();
            if (typeof this.email !== 'undefined' && this.email !== null && this.email.length > 0)
            {
                for (i = 0;i < this.email.length;i++)
                    _object.Add('Email',this.email[i].GetStringData());
            }
            if (typeof this.WWW !== 'undefined' && this.WWW !== null && this.WWW.length > 0)
            {
                for (i = 0;i < this.WWW.length;i++)
                    _object.Add('WWW',this.WWW[i].GetStringData());
            }
            if (typeof this.affiliation !== 'undefined' && this.affiliation !== null && this.affiliation.length > 0)
            {
                for (i = 0;i < this.affiliation.length;i++)
                    if (typeof this.affiliation[i] !== 'undefined' && this.affiliation !== null)
                        this.affiliation[i].DrawFromAnotherElement(_object);
            }
        }        
    };

    TAuthor.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        var i;
        if (typeof this.name !== 'undefined' && this.name !== null)
        {
            for (i = 0;i < this.name.length;i++)
                this.name[i].ChangeCurrentLanguageNumber(_language);
        }
        if (typeof this.surname !== 'undefined' && this.surname !== null)
        {
            for (i = 0;i < this.surname.length;i++)
                this.surname[i].ChangeCurrentLanguageNumber(_language);
        }
        if (typeof this.email !== 'undefined' && this.email !== null)
        {
            for (i = 0;i < this.email.length;i++)
                this.email[i].ChangeCurrentLanguageNumber(_language);
        }
        if (typeof this.WWW !== 'undefined' && this.WWW !== null)
        {
            for (i = 0;i < this.WWW.length;i++)
                this.WWW[i].ChangeCurrentLanguageNumber(_language);
        }
    };

    TAuthor.prototype.ParseXML = function(tag1,tag2){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag2 !== 'undefined' && tag2 !== null)
        {
            var i,x = tag2.childNodes,x2,j,k,kk,kkk;
            for (i = 0,j = 0,k = 0,kk = 0,kkk = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Name')
                    {
                        x2 = x[i].childNodes;
                        if (j >= this.name.length || this.name[j] === null)
                            this.name[j] = objM.newObject('TMultilanguageStringData');
                        if (this.name[j] !== null)
                        {
                            this.name[j].SetStringData(x2[0].nodeValue);
                        }
                        j++;
                    }
                    if(x[i].nodeName === 'Surname')
                    {
                        x2 = x[i].childNodes;
                        if (k >= this.surname.length || this.surname[k] === null)
                            this.surname[k] = objM.newObject('TMultilanguageStringData');
                        if (this.surname[k] !== null)
                        {
                            this.surname[k].SetStringData(x2[0].nodeValue);
                        }
                        k++;
                    }
                    if(x[i].nodeName === 'Email')
                    {
                        x2 = x[i].childNodes;
                        if (k >= this.email.length || this.email[kk] === null)
                            this.email[kk] = objM.newObject('TMultilanguageStringData');
                        if (this.email[kk] !== null)
                        {
                            this.email[kk].SetStringData(x2[0].nodeValue);
                        }
                        kk++;
                    }
                    if(x[i].nodeName === 'WWW')
                    {
                        x2 = x[i].childNodes;
                        if (k >= this.WWW.length || this.WWW[kkk] === null)
                            this.WWW[kkk] = objM.newObject('TMultilanguageStringData');
                        if (this.WWW[kkk] !== null)
                        {
                            this.WWW[kkk].SetStringData(x2[0].nodeValue);
                        }
                        kkk++;
                    }
                }
            }
        }
        if (typeof tag1 !== 'undefined' && tag1 !== null)
        {
            var i,tmp,j;
            for (i = 1,j = 0;i < 100;i++)
            {
                tmp = tag1.getAttribute('idAffiliation' + i);
                if (typeof tmp === 'undefined' || tmp === null)
                    break;
                this.idAffiliation[j++] = tmp;                
            }
        }
    };
    
    TAuthor.prototype.ActualizeId = function(_pageElements){
        TPageElement.prototype.ActualizeId.call(this,_pageElements);
        var i;
        if (typeof _pageElements !== 'undefined' && _pageElements !== null)
        {
            for (i = 0;i < this.idAffiliation.length;i++)
            {
                this.affiliation[i] = this.FindElement(this.idAffiliation[i],_pageElements);
            }
        }
    };

}

TAuthor.prototype = new TPageElement();

function TAffiliation(){
    var type = 'TAffiliation';
    TAffiliation.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.work = [];
        this.adress = null;
        this.SetTypePageElement('Affiliation');
    };
    this.InitConstructor();

    TAffiliation.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TAffiliation'))
        {
            var i;
            if (typeof _object.work !== 'undefined' && _object.work !== null)
            {
                for (i = 0;i < _object.work.length;i++)
                    this.work[i] = objM.copy(_object.work[i]);
            }
            if (typeof _object.adress !== 'undefined' && _object.adress !== null && _object.adress.IsType('TMultilanguageStringData'))
                this.adress = objM.copy(_object.adress);
        }
    };

    TAffiliation.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    
    TAffiliation.prototype.DrawFromAnotherElement = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var i;
            if (typeof this.work !== 'undefined' && this.work !== null && this.work.length > 0)
            {
                for (i = 0;i < this.work.length;i++)
                    _object.Add('AffiliationWork',this.work[i].GetStringData());
            }
            if (typeof this.adress !== 'undefined' && this.adress !== null && this.adress.IsType('TMultilanguageStringData'))
            {
                _object.Add('AffiliationAdress',this.adress.GetStringData());
            }
        }        
    };

    TAffiliation.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        var i;
        if (typeof this.work !== 'undefined' && this.work !== null)
        {
            for (i = 0;i < this.work.length;i++)
                this.work[i].ChangeCurrentLanguageNumber(_language);
        }
        if (typeof this.adress !== 'undefined' && this.adress !== null && this.adress.IsType('TMultilanguageStringData'))
            this.adress.ChangeCurrentLanguageNumber(_language);
    };

    TAffiliation.prototype.ParseXML = function(tag1,tag2){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag2 !== 'undefined' && tag2 !== null)
        {
            var i,x = tag2.childNodes,x2,j;
            for (i = 0,j = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Work')
                    {
                        x2 = x[i].childNodes;
                        if (j >= this.work.length || this.work[j] === null)
                            this.work[j] = objM.newObject('TMultilanguageStringData');
                        if (this.work[j] !== null)
                        {
                            this.work[j].SetStringData(x2[0].nodeValue);
                        }
                        j++;
                    }
                    if(x[i].nodeName === 'Adress')
                    {
                        x2 = x[i].childNodes;
                        if (this.adress === null)
                            this.adress = objM.newObject('TMultilanguageStringData');
                        if (this.adress !== null)
                        {
                            this.adress.SetStringData(x2[0].nodeValue);
                        }
                    }
                }
            }
        }
    };

}

TAffiliation.prototype = new TPageElement();

function TFileName(){
    var type = 'TFileName';
    TFileName.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.fileName = null;
        this.catalog = null;
        this.SetTypePageElement('FileName');
    };
    this.InitConstructor();

    TFileName.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TFileName'))
        {
            if (typeof _object.fileName !== 'undefined' && _object.fileName !== null && _object.fileName.IsType('TMultilanguageStringData'))
                this.fileName = objM.copy(_object.fileName);
            if (typeof _object.catalog !== 'undefined' && _object.catalog !== null)
            {
                this.catalog = new String(_object.catalog);
                if (this.catalog !== null)
                    this.catalog = this.catalog.toString();
            }
        }
    };

    TFileName.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    

    TFileName.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        if (this.fileName !== null)
            this.fileName.ChangeCurrentLanguageNumber(_language);
    };

    TFileName.prototype.ParseXML = function(tag1,tag2){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag2 !== 'undefined' && tag2 !== null)
        {
            var i,x = tag2.childNodes,x2;
            for (i = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Image' || x[i].nodeName === 'Video' || x[i].nodeName === 'Source')
                    {
                        x2 = x[i].getAttribute('file');
                        if (this.fileName === null)
                            this.fileName = objM.newObject('TMultilanguageStringData');
                        if (this.fileName !== null)
                        {
                            this.fileName.SetStringData(x2);
                        }
                    }
/*                    if(x[i].nodeName === 'Video')
                    {
                        x2 = x[i].getAttribute('src');
                        if (this.fileName === null)
                            this.fileName = objM.newObject('TMultilanguageStringData');
                        if (this.fileName !== null)
                        {
                            this.fileName.SetStringData(x2);
                        }
                    }*/
                }
            }
        }
        if (typeof tag1 !== 'undefined' && tag1 !== null)
        {
            var tmp = tag1.getAttribute('level');
            tmp = parseInt(tmp);
            if (tmp !== null && IsInt(tmp))
                this.level = tmp;
        }
        
    };

    TFileName.prototype.GetFileNameString = function(){
        if (typeof this.fileName !== 'undefined' && this.fileName !== null && this.fileName.IsType('TMultilanguageStringData'))
        {
            var tmp = this.fileName.GetStringData(this.GetCurrentNameLanguage());
            if (typeof tmp === 'undefined' || tmp === null)
                tmp = this.fileName.GetStringData(this.GetDefaultLanguage());
            return tmp;
        }
        return null;
    };

    TFileName.prototype.SetCatalog = function(cat){
        if (typeof cat !== 'undefined' && cat !== null)
        {
            this.catalog = new String(cat);
            if (this.catalog !== null)
                this.catalog = this.catalog.toString();
        }
    };

    TFileName.prototype.GetCatalog = function(){
        if (typeof this.catalog !== 'undefined' && this.catalog !== null)
        {
            var tmp = new String(this.catalog);
            if (tmp !== null)
                return tmp.toString();
        }
        return null;
    };

}

TFileName.prototype = new TPageElement();

function TImageFileName(){
    var type = 'TImageFileName';
    TImageFileName.prototype.InitConstructor = function(){
        TFileName.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.SetTypePageElement('ImageFileName');
        this.height = 0;
        this.width = 0;
        this.loadYN = false;
        this.image = [];
    };
    this.InitConstructor();

    TImageFileName.prototype.Init = function(_object){
        TFileName.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TImageFileName'))
        {
            var i;
            if (typeof _object.height !== 'undefined' && _object.height !== null && IsInt(_object.height))
                this.height = _object.height;
            if (typeof _object.width !== 'undefined' && _object.width !== null && IsInt(_object.width))
                this.width = _object.width;
            if (typeof _object.image !== 'undefined' && _object.image !== null)
            {
                for (i = 0;i < _object.image.length;i++)
                {
                    if (typeof _object.image[i] !== 'undefined' && _object.image[i] !== null)
                        this.image[i] = _object.image[i];
                    else
                        this.image[i] = null;
                }
            }
            if (typeof _object.loadYN !== 'undefined' && _object.loadYN !== null)
                this.loadYN = _object.loadYN;
        }
    };

    TImageFileName.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TFileName.prototype.IsType.call(this,_type);
    };
    
    TImageFileName.prototype.ParseXML = function(tag1,tag2){
        TFileName.prototype.ParseXML.call(this,tag1,tag2);
        
        if (tag1 !== null)
        {
            var attr = tag1.getAttribute('defaultLanguage');
            if (typeof attr !== 'undefined' && attr !== null)
                this.SetDefaultLanguage(attr);
            attr = tag1.getAttribute('load');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                if (attr === 'Yes' || attr === 'yes')
                {
//                    this.image.thisObject = this;
                    this.loadYN = true;


                    var tmp = this.GetFileNameString();
                    var noLanguage = this.GetCurrentLanguage();
                    if (noLanguage !== null && noLanguage >= 0)
                        this.image[noLanguage] = null;
                    if (noLanguage !== null && noLanguage >= 0 && tmp !== null && this.GetCatalog() !== null)
                    {
                        
//                        this.image.onload = function() {
//                          this.thisObject.SetHeight(this.height);
//                          this.thisObject.SetWidth(this.width);
//                        } ;       
                        tmp =  this.GetCatalog() + '/' + tmp;

                        var image = new Image();
                        image.thisObject = this;
                        image.onload = function() {
                            this.thisObject.SetHeight(this.height);
                            this.thisObject.SetWidth(this.width);
                        } ;       
//                        tmp =  this.GetCatalog() + '/' + tmp;
                        image.src = tmp;
                        this.image[noLanguage] = image;
                    
                    }
                    
                }else
                {
                    attr = tag1.getAttribute('width');
                    this.SetWidth(attr);
                    attr = tag1.getAttribute('height');
                    this.SetHeight(attr);
                }
            }else
            {
                attr = tag1.getAttribute('width');
                this.SetWidth(attr);
                attr = tag1.getAttribute('height');
                this.SetHeight(attr);
            }
        }
        
    };

    TImageFileName.prototype.ChangeCurrentLanguageNumber = function(_language){
        TFileName.prototype.ChangeCurrentLanguageNumber.call(this,_language);
//        if (this.image !== null)
//        {
//            var tmp = this.GetFileNameString();
//            if (tmp !== null)
//                this.image.src = tmp;
//        }
    };

    TImageFileName.prototype.GetImage = function(){
        var noLanguage = this.GetCurrentLanguage();
        if (noLanguage !== null && noLanguage >= 0)
            return this.image[noLanguage];
        return null;
    };

    TImageFileName.prototype.SetHeight = function(h){
        if (typeof h !== 'undefined' && h !== null && IsInt(h))
            this.height = h;
    };

    TImageFileName.prototype.GetHeight = function(){
        return this.height;
    };
    
    TImageFileName.prototype.SetWidth = function(w){
        if (typeof w !== 'undefined' && w !== null && IsInt(w))
            this.width = w;
    };

    TImageFileName.prototype.GetWidth = function(){
        return this.width;
    };
    
    TImageFileName.prototype.SetCatalog = function(cat){
        TFileName.prototype.SetCatalog.call(this,cat);
        if (typeof cat !== 'undefined' && cat !== null)
        {
            if (this.loadYN)
            {
/*                var tmp = this.GetFileNameString();
                if (tmp !== null && this.GetCatalog() !== null)
                {
                    this.image.onload = function() {
                      this.thisObject.SetHeight(this.height);
                      this.thisObject.SetWidth(this.width);
                    } ;       
                    tmp =  this.GetCatalog() + '/' + tmp;
                    this.image.src = tmp;
                }*/
            }
        }
    };

}

TImageFileName.prototype = new TFileName();

function TVideoFileName(){
    var type = 'TVideoFileName';
    TVideoFileName.prototype.InitConstructor = function(){
        TFileName.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.SetTypePageElement('VideoFileName');
        this.height = 0;
        this.width = 0;
        this.video = [];
        this.typeVideo = null;
    };
    this.InitConstructor();

    TVideoFileName.prototype.Init = function(_object){
        TFileName.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TVideoFileName'))
        {
            var i;
            if (typeof _object.height !== 'undefined' && _object.height !== null && IsInt(_object.height))
                this.height = _object.height;
            if (typeof _object.width !== 'undefined' && _object.width !== null && IsInt(_object.width))
                this.width = _object.width;
            if (typeof _object.video !== 'undefined' && _object.video !== null)
            {
                for (i = 0;i < _object.video.length;i++)
                {
                    if (typeof _object.video[i] !== 'undefined' && _object.video[i] !== null)
                        this.video[i] = _object.video[i];
                    else
                        this.video[i] = null;
                }
            }
            if (typeof _object.typeVideo !== 'undefined' && _object.typeVideo !== null)
            {
                this.typeVideo = new String(_object.typeVideo);
                if (this.typeVideo !== null)
                    this.typeVideo = this.typeVideo.toString();
            }
        }
    };

    TVideoFileName.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TFileName.prototype.IsType.call(this,_type);
    };
    
    TVideoFileName.prototype.ParseXML = function(tag1,tag2){
        TFileName.prototype.ParseXML.call(this,tag1,tag2);
        
        if (tag1 !== null)
        {
            var attr = tag1.getAttribute('defaultLanguage');
            if (typeof attr !== 'undefined' && attr !== null)
                this.SetDefaultLanguage(attr);
            attr = tag1.getAttribute('width');
            this.SetWidth(attr);
            attr = tag1.getAttribute('height');
            this.SetHeight(attr);

            var i,x = tag2.childNodes,x2;
            for (i = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1)
                {
                    if(x[i].nodeName === 'Video')
                    {
                        x2 = x[i].getAttribute('typeVideo');
                        this.SetVideoType(x2);
                    }

                }
            }
            
        }
        
    };

    TVideoFileName.prototype.ChangeCurrentLanguageNumber = function(_language){
        TFileName.prototype.ChangeCurrentLanguageNumber.call(this,_language);
//        if (this.image !== null)
//        {
//            var tmp = this.GetFileNameString();
//            if (tmp !== null)
//                this.image.src = tmp;
//        }
    };

    TVideoFileName.prototype.SetHeight = function(h){
        if (typeof h !== 'undefined' && h !== null && IsInt(h))
            this.height = h;
    };

    TVideoFileName.prototype.GetHeight = function(){
        return this.height;
    };
    
    TVideoFileName.prototype.SetWidth = function(w){
        if (typeof w !== 'undefined' && w !== null && IsInt(w))
            this.width = w;
    };

    TVideoFileName.prototype.GetWidth = function(){
        return this.width;
    };
    
    TVideoFileName.prototype.SetVideoType = function(type_){
        if (typeof type_ !== 'undefined' && type_ !== null)
        {
            this.typeVideo = new String(type_);
            if (this.typeVideo !== null)
                this.typeVideo = this.typeVideo.toString();
        }
    };

    TVideoFileName.prototype.GetVideoType = function(){
        if (this.typeVideo !== null)
        {
            var tmp = new String(this.typeVideo);
            if (tmp !== null)
                return tmp.toString();
        }
        return null;
    };
}

TVideoFileName.prototype = new TFileName();


function TFrameFileName(){
    var type = 'TFrameFileName';
    TFrameFileName.prototype.InitConstructor = function(){
        TFileName.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.SetTypePageElement('FrameFileName');
    };
    this.InitConstructor();

    TFrameFileName.prototype.Init = function(_object){
        TFileName.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TFrameFileName'))
        {
        }
    };

    TFrameFileName.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TFileName.prototype.IsType.call(this,_type);
    };
    
    TFrameFileName.prototype.ParseXML = function(tag1,tag2){
        TFileName.prototype.ParseXML.call(this,tag1,tag2);
        
        if (tag1 !== null)
        {
           
        }
        
    };

    TFrameFileName.prototype.ChangeCurrentLanguageNumber = function(_language){
        TFileName.prototype.ChangeCurrentLanguageNumber.call(this,_language);
//        if (this.image !== null)
//        {
//            var tmp = this.GetFileNameString();
//            if (tmp !== null)
//                this.image.src = tmp;
//        }
    };

}

TFrameFileName.prototype = new TFileName();


function TFrame(){
    var type = 'TFrame';
    TFrame.prototype.InitConstructor = function(){
        TPageElement.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.fileName = null;
        this.width = null;
        this.height = null;
        this.SetTypePageElement('Frame');
    };
    this.InitConstructor();

    TFrame.prototype.Init = function(_object){
        TPageElement.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TFrame'))
        {
            if (typeof _object.fileName !== 'undefined' && _object.fileName !== null && _object.fileName.IsType('TFrameFileName'))
            {
                this.fileName = _object.fileName;
            }
            if (typeof _object.width !== 'undefined' && _object.width !== null && IsInt(_object.width))
                this.width = _object.width;
            if (typeof _object.height !== 'undefined' && _object.height !== null && IsInt(_object.height))
                this.height = _object.height;
        }
    };

    TFrame.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPageElement.prototype.IsType.call(this,_type);
    };
    

    TFrame.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPageElement.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        var i;
        if (typeof this.fileName !== 'undefined' && this.fileName !== null && this.fileName.IsType('TObjectMultilanguage'))
        {
            this.fileName.ChangeCurrentLanguageNumber(_language);
        }
	};

    TFrame.prototype.ReadXML = function(tag,fun){
        TPageElement.prototype.ReadXML.call(this,tag,fun);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof tag !== 'undefined' && tag !== null)
        {
            this.ReadXMLInit(tag);
            var i,x = tag.childNodes,obj;
            var attr = tag.getAttribute('height');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseInt(attr);
                if (attr !== null && IsInt(attr))
                    this.height = attr;
            }
            attr = tag.getAttribute('width');
            if (typeof attr !== 'undefined' && attr !== null)
            {
                attr = parseInt(attr);
                if (attr !== null && IsInt(attr))
                    this.width = attr;
            }
            for (i = 0;i < x.length;i++)
            {
                if (x[i].nodeType === 1 && x[i].nodeName === 'FrameFileName')
				{
					obj = this.fileName;
					if (typeof obj === 'undefined' || obj === null)
					{
						obj = objM.newObject('TFrameFileName');
						if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TFrameFileName'))
							this.fileName = obj;
					}
					if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TFrameFileName') && x[i].childNodes !== 'undefined' && x[i].childNodes !== null)
					{
						obj.ReadXML(x[i]);
					}
				}
			}
		}
	}

    TFrame.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.fileName !== 'undefined' && this.fileName !== null && this.fileName.IsType('TFrameFileName'))
            {
                var tmp2 = [],tmp1,id = this.GetId(),style=this.GetClassStyle();
                tmp1 = this.fileName.GetFileNameString();
                tmp2[0] = this.width;
                tmp2[1] = this.height;
                if (id !== null)
                    tmp2[2] = id;
                else
                    tmp2[2] = null;
                if (style !== null)
                    tmp2[3] = style;
                else
                    tmp2[3] = null;				
                _object.Add('Frame',tmp1,tmp2);
            }
        }
//        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
//        {
//            _object.Equation(this.GetTXT());
//        }        
    };


    TFrame.prototype.GetWidth = function(){
        return this.width;
    };

    TFrame.prototype.SetWidth = function(w){
        if (typeof w !== 'undefined' && w !== null && IsNumeric(w))
            this.width = w;
        if (w === null)
            this.width = null;
    };

    TFrame.prototype.SetHeight = function(){
        return this.height;
    };

    TFrame.prototype.SetHeight = function(h){
        if (typeof h !== 'undefined' && h !== null && IsNumeric(h))
            this.height = h;
        if (h === null)
            this.height = null;
    };


}

TFrame.prototype = new TPageElement();




function TReadData(){
    var type = 'TReadData';
    TReadData.prototype.InitConstructor = function(){
        TObjectMultilanguage.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.pageELements = [];
        this.loadLanguageYN = [];
        this.fun = null;
        this.referenceName = [];
        this.referenceValue = [];
        this.imageCatalog = null;
        this.variables = null;
    };
    this.InitConstructor();

    TReadData.prototype.InitConstructor2 = function(){
        TObjectMultilanguage.prototype.InitConstructor2.call(this);
        var objM = this.GetObjectManager();
        if (objM !== null)
            this.variables = objM.newObject('TVariables');
    };

    TReadData.prototype.Init = function(_object){
        TObjectMultilanguage.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TReadData'))
        {
            var i;
            if (typeof _object.pageELements !== 'undefined' && _object.pageELements !== null)
            {
                this.pageELements = [];
                for (i = 0;i < _object.pageELements.length;i++)
                    this.pageELements[i] = _object.pageELements[i];
            }
            if (typeof _object.loadLanguageYN !== 'undefined' && _object.loadLanguageYN !== null)
            {
                this.loadLanguageYN = [];
                for (i = 0;i < _object.loadLanguageYN.length;i++)
                    this.loadLanguageYN[i] = _object.loadLanguageYN[i];
            }
            if (typeof _object.fun !== 'undefined' && _object.fun !== null)
                this.fun = _object.fun;
            if (typeof _object.referenceName !== 'undefined' && _object.referenceName !== null)
            {
                this.referenceName = [];
                for (i = 0;i < _object.referenceName.length;i++)
                {
                    if (typeof _object.referenceName[i] !== 'undefined' && _object.referenceName[i] !== null)
                    {
                        this.referenceName[i] = new String(_object.referenceName[i]);
                        this.referenceName[i] = this.referenceName[i].toString();
                    }
                }
            }
            if (typeof _object.referenceValue !== 'undefined' && _object.referenceValue !== null)
            {
                this.referenceValue = [];
                for (i = 0;i < _object.referenceValue.length;i++)
                {
                    if (typeof _object.referenceValue[i] !== 'undefined' && _object.referenceValue[i] !== null)
                    {
                        this.referenceValue[i] = new String(_object.referenceValue[i]);
                        this.referenceValue[i] = this.referenceValue[i].toString();
                    }
                }
            }
            if (typeof _object.catalog !== 'undefined' && _object.catalog !== null)
            {
                this.imageCatalog = new String(_object.imageCatalog);
                if (this.imageCatalog !== null)
                    this.imageCatalog = this.imageCatalog.toString();
            }
            if (typeof _object.variables !== 'undefined' && _object.variables !== null && _object.variables.IsType('TVariables'))
                this.variables = objM.copy(_object.variables);
        }
    };

    TReadData.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectMultilanguage.prototype.IsType.call(this,_type);
    };

    TReadData.prototype.AddElement = function(_element){
        if (typeof _element !== 'undefined' && _element !== null && _element.IsType('TPageElement'))
        {
            this.pageELements[this.pageELements.length] = _element;
        }        
    };
    
    TReadData.prototype.SetElement = function(_element,number){
        if (typeof _element !== 'undefined' && _element !== null && _element.IsType('TPageElement'))
        {
            if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0)
                this.pageELements[number] = _element;
        }        
    };
    
    TReadData.prototype.GetElement = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0)
        {
            if (this.pageELements !== null && number < this.pageELements.length)
                return this.pageELements[number];
        }
        return null;
    };    

    TReadData.prototype.GetNumberOfElements = function(){
        if (this.pageELements !== null)
        {
            return this.pageELements.length;
        }
        return 0;
    };

    TReadData.prototype.ChangeCurrentLanguageNumber = function(_language){
        if (typeof _language !== 'undefined' && _language !== null)
        {
            var i,n = this.GetNumberOfElements(),object;
            for (i = 0;i < n;i++)
            {
                object = this.GetElement(i);
                if (typeof object !== 'undefined' && object !== null && object.IsType('TPageElement'))
                {
                    object.ChangeCurrentLanguageNumber(_language);
                }
            }
        } 
    
    };
    
    TReadData.prototype.Read = function(readObject,_fun){
        if (typeof readObject !== 'undefined' && readObject !== null && readObject.IsType('TRead') && typeof _fun !== 'undefined' && _fun !== null )
        {
            this.fun = _fun;
            var numberLang = this.GetCurrentLanguage();
            if (!this.GetLoadLanguage(numberLang))
            {
                readObject.Read(this,this.fun,this.imageCatalog);
                this.SetLoadLanguage(numberLang,true);
            }else
            {
                this.ChangeCurrentLanguageNumber(numberLang);
                this.fun();
//                this.LinkMethod();
                this.ActualizeVisible();
            }
            
        }
    };

    TReadData.prototype.SetLoadLanguage = function(_language,loadYN){
        if (typeof _language !== 'undefined' && _language !== null && IsInt(_language) && _language >= 0)
        {
            if (typeof loadYN !== 'undefined' && loadYN !== null)
            {
                this.loadLanguageYN[_language] = loadYN;
            }            
        }
    };

    TReadData.prototype.SetLoadNameLanguage = function(_language,loadYN){
        if (typeof _language !== 'undefined' && _language !== null)
        {
            var number = this.NumberLanguage(_language);
            this.SetLoadLanguage(number,loadYN);          
        }
    };

    TReadData.prototype.GetLoadLanguage = function(_language){
        if (typeof _language !== 'undefined' && _language !== null && IsInt(_language) && _language >= 0)
        {
            if (_language >= this.loadLanguageYN.length || typeof this.loadLanguageYN[_language] === 'undefined' || this.loadLanguageYN[_language] === null || this.loadLanguageYN[_language] === false)
                return false;
            else
                return true;
        }
        return false;
    };

    TReadData.prototype.GetLoadNameLanguage = function(_language){
        if (typeof _language !== 'undefined' && _language !== null)
        {
            var number = this.NumberLanguage(_language);
            return this.GetLoadLanguage(number);          
        }
        return false;
    };

    TReadData.prototype.ActualizeId = function(){
        var i,numberChapter = 0,numberFigure = 0;
        if (typeof this.pageELements !== 'undefined' && this.pageELements !== null)
            for (i = 0;i < this.pageELements.length;i++)
                if (typeof this.pageELements[i] !== 'undefined' && this.pageELements[i] !== null && this.pageELements[i].IsType('TPageElement'))
                {
                    this.pageELements[i].ActualizeId(this.pageELements);
                    this.referenceName[i] = this.pageELements[i].GetId();
                    if (this.pageELements[i].IsType('TTitle') && this.pageELements[i].GetLevel() === 0)
                        numberChapter = numberChapter + 1;
                    if (this.pageELements[i].IsType('TDrawFigure'))
                    {
                        numberFigure = numberFigure + 1;
                        this.referenceValue[i] = numberChapter + '.' + numberFigure;
                    }
                }
        
    };
    
    TReadData.prototype.ActualizeVisible = function(){
    };

    TReadData.prototype.ActualizeLocaleString = function(){
    };

    TReadData.prototype.GetFun = function(){
        return this.fun;
    };

    TReadData.prototype.FindReference = function(name){
        if (typeof name !== 'undefined' && name !== null && typeof this.referenceName !== 'undefined' && this.referenceName !== null)
        {
            var i;
            for (i = 0;i < this.referenceName.length;i++)
            {
                if (name === this.referenceName[i])
                    return i;
            }
        }
        return null;
    };
    
    TReadData.prototype.GetReferenceName = function(){
        return this.referenceName;
    };

    TReadData.prototype.GetReferenceValue = function(){
        return this.referenceValue;
    };

    TReadData.prototype.SetImageCatalog = function(cat){
        if (typeof cat !== 'undefined' && cat !== null)
        {
            this.imageCatalog = new String(cat);
            if (this.imageCatalog !== null)
                this.imageCatalog = this.imageCatalog.toString();
        }
        if (cat === null)
            this.imageCatalog = null;
    };


    TReadData.prototype.CalculateValue = function(value_){
        if (this.variables !== null)
            return this.variables.CalculateValue(value_);
        return null;
    };

    TReadData.prototype.FindVariable = function(name_){
        if (this.variables !== null)
            return this.variables.FindVariable(name_);
        return null;
    };


    TReadData.prototype.SetVariable = function(var_,name_){
        if (this.variables !== null)
            this.variables.SetVariable(var_,name_);
    };

    TReadData.prototype.SetVariables = function(var_){
        if (this.variables !== null)
            this.variables.SetVariables(var_);
    };

    TReadData.prototype.GetVariables = function(){
        if (this.variables !== null)
            return this.variables.GetVariables();
        return null;
    };

}

TReadData.prototype = new TObjectMultilanguage();

function TReadPaperData(){
    var type = 'TReadPaperData';
    TReadPaperData.prototype.InitConstructor = function(){
        TReadData.prototype.InitConstructor.call(this);
        this.SetType(type);            
    };
    this.InitConstructor();

    TReadPaperData.prototype.Init = function(_object){
        TReadData.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TReadPaperData'))
        {
        }
    };

    TReadPaperData.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TReadData.prototype.IsType.call(this,_type);
    };

    TReadPaperData.prototype.Read = function(readObject,fun){
        if (typeof readObject !== 'undefined' && readObject !== null && readObject.IsType('TRead'))
        {
            readObject.EmptyDataType();
            readObject.AddDataType('PaperTitle');
            readObject.AddDataType('Author');
            readObject.AddDataType('Affiliation');
            readObject.AddDataType('Title');
            readObject.AddDataType('Paragraph');
            readObject.AddDataType('Code');
            readObject.AddDataType('Enumerate');
            readObject.AddDataType('Itemize');
            readObject.AddDataType('Equation');
            readObject.AddDataType('DrawFigure');
            readObject.AddDataType('ImageFileName');
            readObject.AddDataType('Table');
            readObject.AddDataType('VideoFileName');
            readObject.AddDataType('FrameFileName');
            readObject.AddDataType('Var');
            readObject.AddDataType('Fun');
            readObject.AddDataType('Timer');
            readObject.AddDataType('TableShow');
            readObject.AddDataType('TableEdit');
            readObject.AddDataType('Frame');
//            if (this.figureName !== null)
//                this.figureName.ChangeCurrentLanguageNumber(this.GetCurrentLanguage());
            TReadData.prototype.Read.call(this,readObject,fun);
           
        }
    };

};

TReadPaperData.prototype = new TReadData();


function TPage(){
    var type = 'TPage';
    TPage.prototype.InitConstructor = function(){
        TObjectMultilanguage.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.data = null;
        this.pageELements = [];
        this.dataType = [];
        this.fun = null;
        this.imageCatalog = null;
        this.variables = null;
    };
    this.InitConstructor();

    TPage.prototype.InitConstructor2 = function(){
        TObjectMultilanguage.prototype.InitConstructor2.call(this);
        var objM = this.GetObjectManager();
        if (objM !== null)
            this.variables = objM.newObject('TVariables');
    };

    TPage.prototype.Init = function(_object){
        TObjectMultilanguage.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TPage'))
        {
            if (typeof _object.data !== 'undefined' && _object.data !== null && _object.data.IsType('TReadData'))
                this.data = _object.data;
            if (typeof _object.fun !== 'undefined' && _object.fun !== null)
                this.fun = _object.fun;
            var i;
            if (typeof _object.pageELements !== 'undefined' && _object.pageELements !== null)
            {
                this.pageELements = [];
                for (i = 0;i < _object.pageELements.length;i++)
                    this.pageELements[i] = _object.pageELements[i];
            }
            if (typeof _object.dataType !== 'undefined' && _object.dataType !== null)
            {
                this.dataType = [];
                for (i = 0;i < _object.dataType;i++)
                {
                    this.dataType[i] = new String(_object.dataType[i]);
                    this.dataType[i] = this.dataType[i].toString();
                }
            }
            if (typeof _object.imageCatalog !== 'undefined' && _object.imageCatalog !== null)
            {
                this.imageCatalog = new String(_object.imageCatalog);
                this.imageCatalog = this.imageCatalog.toString();
            }
            if (typeof _object.variables !== 'undefined' && _object.variables !== null && _object.variables.IsType('TVariables'))
                this.variables = objM.copy(_object.variables);
        }
    };

    TPage.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectMultilanguage.prototype.IsType.call(this,_type);
    };

    TPage.prototype.SetData = function(_data){
        if (typeof _data !== 'undefined' && _data !== null && _data.IsType('TReadData'))
            this.data = _data;
        if (_data === null)
            this.data = null;
    };

    TPage.prototype.ActualizeData = function(){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof this.data !== 'undefined' && this.data !== null && this.data.IsType('TReadPaperData'))
        {
            var j,i,k,n = this.data.GetNumberOfElements(),ob;
            this.pageELements = [];
            for(i = 0,k = 0;i<n;i++)
            {
                ob = this.data.GetElement(i);
                if (typeof ob !== 'undefined' && ob !== null)
                {
                    for (j = 0;j < this.dataType.length;j++)
                    {
                        if (typeof this.dataType[j] !== 'undefined' && this.dataType[j] !== null)
                        {
                            if (this.dataType[j] === ob.GetTypePageElement())
                            {
                                this.pageELements[k] = objM.copy(ob);
                                if (typeof this.pageELements[k] !== 'undefined' && this.pageELements[k] !== null && this.pageELements[k].IsType('TPageElement'))
                                {
                                    this.pageELements[k].SetVariables(this.GetVariables());
                                    if (this.pageELements[k].IsType('TVar'))
                                        this.SetVariables(this.pageELements[k].GetVariables());
                                    this.pageELements[k].SetParent(this);
                                }
                                k++;
                                break;
                            }
                        }
                    }
                }
            }
            this.ActualizeId();
            this.ActualizeVisible();
            this.SetImageCatalog();
        }
    };
    
    TPage.prototype.Draw = function(_object){
    };    

    TPage.prototype.GetNumberOfElements = function(){
        if (this.pageELements !== null)
        {
            return this.pageELements.length;
        }
        return 0;
    };

    TPage.prototype.GetElement = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0)
        {
            if (this.pageELements !== null && number < this.pageELements.length)
                return this.pageELements[number];
        }
        return null;
    };    

    TPage.prototype.AddElement = function(_element){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _element !== 'undefined' && _element !== null && _element.IsType('TPageElement'))
        {
//            this.pageELements[this.pageELements.length] = objM.copy(_element);
            this.pageELements[this.pageELements.length] = _element;
            _element.SetParent(this);
        }
    };    

    TPage.prototype.EmptyDataType = function(){
        this.dataType = [];
    };

    TPage.prototype.AddDataType = function(_dataType){
        if (typeof _dataType !== 'undefined' && _dataType !== null)
        {
            this.dataType[this.dataType.length] = new String(_dataType);
            this.dataType[this.dataType.length - 1] = this.dataType[this.dataType.length - 1].toString();
        }
    };

    TPage.prototype.ActualizeId = function(){
        if(typeof this.pageELements !== 'undefined' && this.pageELements !== null)
        {
            var i,n = this.pageELements.length,ob;
            for(i = 0;i<n;i++)
            {
                ob = this.pageELements[i];
                if (typeof ob !== 'undefined' && ob !== null)
                {
                    ob.ActualizeId(this.pageELements);
                }
            }
        }
    };

    TPage.prototype.ActualizeVisible = function(){
    };

    TPage.prototype.VisibleElements = function(_visible){
        if (typeof _visible !== 'undefined' && _visible !== null && typeof this.pageELements !== 'undefined' && this.pageELements !== null)
        {
            var j;
            for (j = 0;j < this.pageELements.length;j++)
            {
                if (this.pageELements[j] !== null && this.pageELements[j].IsType('TPageElement'))
                {
                    this.pageELements[j].SetVisible(_visible);
                }
            }
        }
    };

    TPage.prototype.LinkMethod = function(){
        var i;
        if (typeof this.pageELements !== 'undefined' && this.pageELements !== null)
            for (i = 0;i < this.pageELements.length;i++)
                if (typeof this.pageELements[i] !== 'undefined' && this.pageELements[i] !== null && this.pageELements[i].IsType('TPageElement'))
                {
                    this.pageELements[i].LinkMethod();
                }
                
    };

    TPage.prototype.GetFun = function(){
        return this.fun;
    };

    TPage.prototype.SetFun = function(_fun){
        if (typeof _fun !== 'undefined')
            this.fun = _fun;
    };


    TPage.prototype.SetImageCatalog = function(catalog){
        if (typeof catalog !== 'undefined' && catalog !== null)
        {
            this.imageCatalog = new String(catalog);
            this.imageCatalog = this.imageCatalog.toString();
        }
        if (catalog === null)
            this.imageCatalog = null;        
        if (typeof this.imageCatalog !== 'undefined' && this.imageCatalog !== null)
        {
            if (typeof this.pageELements !== 'undefined' && this.pageELements !== null)
            {
                var i;
                for (i = 0;i < this.pageELements.length;i++)
                    if (typeof this.pageELements[i] !== 'undefined' && this.pageELements[i] !== null)
                    {
                        this.pageELements[i].SetImageCatalog(this.imageCatalog);
                        if (this.pageELements[i].IsType('TDrawFigure'))
                            this.pageELements[i].SetImageCatalog(this.imageCatalog);
                        if (this.pageELements[i].IsType('TEnumerate'))
                            this.pageELements[i].SetImageCatalog(this.imageCatalog);
                        if (this.pageELements[i].IsType('TItemize'))
                            this.pageELements[i].SetImageCatalog(this.imageCatalog);
                    }
            }
/*            if (typeof this.slideElements !== 'undefined' && this.slideElements !== null)
            {
                var i;
                for (i = 0;i < this.slideElements.length;i++)
                    if (typeof this.slideElements[i] !== 'undefined' && this.slideElements[i] !== null && this.slideElements[i].IsType('TDrawFigure'))
                        this.slideElements[i].SetImageCatalog(this.imageCatalog);
            }*/
        }
    };

    TPage.prototype.GetImageCatalog = function(){
        if (this.imageCatalog === null)
            return null;
        var tmp = new String(this.imageCatalog);
        return tmp.toString();
    };

    TPage.prototype.CalculateValue = function(value_){
        if (this.variables !== null)
            return this.variables.CalculateValue(value_);
        return null;
    };

    TPage.prototype.FindVariable = function(name_){
        if (this.variables !== null)
            return this.variables.FindVariable(name_);
        return null;
    };


    TPage.prototype.SetVariable = function(var_,name_){
        if (this.variables !== null)
            this.variables.SetVariable(var_,name_);
    };

    TPage.prototype.SetVariables = function(var_){
        if (this.variables !== null)
            this.variables.SetVariables(var_);
    };

    TPage.prototype.GetVariables = function(){
        if (this.variables !== null)
            return this.variables.GetVariables();
        return null;
    };

}

TPage.prototype = new TObjectMultilanguage();


function TPagePaper(){
    var type = 'TPagePaper';
    TPagePaper.prototype.InitConstructor = function(){
        TPage.prototype.InitConstructor.call(this);
        this.SetType(type);            
    };
    this.InitConstructor();

    TPagePaper.prototype.Init = function(_object){
        TPage.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TPagePaper'))
        {
        }
    };

    TPagePaper.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPage.prototype.IsType.call(this,_type);
    };
    
    TPagePaper.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            if (typeof this.imageCatalog !== 'undefined' && this.imageCatalog !== null)
            {
                _object.Add('ImageCatalog',this.imageCatalog);
            }
            var i,n = this.GetNumberOfElements(),object;
            for (i = 0;i < n;i++)
            {
                object = this.GetElement(i);
                if (typeof object !== 'undefined' && object !== null && object.IsType('TPageElement'))
                {
                    object.Draw(_object);
                }
            }
        } 
    };        


}

TPagePaper.prototype = new TPage();

function TPagePaperParagraphs(){
    var type = 'TPagePaperParagraphs';
    TPagePaperParagraphs.prototype.InitConstructor = function(){
        TPagePaper.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.visibleSection = [];
        this.figureName = null;
        this.tableName = null;
    };
    this.InitConstructor();

    TPagePaperParagraphs.prototype.Init = function(_object){
        TPagePaper.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TPagePaperParagraphs'))
        {
            if (typeof _object.visibleSection !== 'undefined' && _object.visibleSection !== null)
            {
                var i;            
                this.visibleSection = [];
                for (i = 0;i < _object.visibleSection.length;i++)
                    this.visibleSection[i] = _object.visibleSection[i];
            }
            if (typeof _object.figureName !== 'undefined' && _object.figureName !== null && _object.figureName.IsType('TMultilanguageStringData'))
                this.figureName = objM.copy(_object.figureName);
            if (typeof _object.tableName !== 'undefined' && _object.tableName !== null && _object.tableName.IsType('TMultilanguageStringData'))
                this.tableName = objM.copy(_object.tableName);
        }
    };

    TPagePaperParagraphs.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPagePaper.prototype.IsType.call(this,_type);
    };
    
    TPagePaperParagraphs.prototype.Read = function(readObject,fun){
        if (typeof readObject !== 'undefined' && readObject !== null && readObject.IsType('TRead'))
        {
            readObject.EmptyDataType();
            readObject.AddDataType('Title');
            readObject.AddDataType('Paragraph');
            readObject.AddDataType('Code');
            readObject.AddDataType('Equation');
            readObject.AddDataType('DrawFigure');
            readObject.AddDataType('Table');
            readObject.AddDataType('Var');
            readObject.AddDataType('Fun');
            readObject.AddDataType('Timer');
            readObject.AddDataType('TableShow');
            readObject.AddDataType('TableEdit');
            readObject.AddDataType('Frame');
            if (this.figureName !== null)
                this.figureName.ChangeCurrentLanguageNumber(this.GetCurrentLanguage());
            if (this.tableName !== null)
                this.tableName.ChangeCurrentLanguageNumber(this.GetCurrentLanguage());
            TPagePaper.prototype.Read.call(this,readObject,fun);
           
        }
    };
    
    TPagePaperParagraphs.prototype.Draw = function(_object,_drawObjectName){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            _object.SetTypeDrawObject(_drawObjectName);        
            _object.Add('ResizeToFontObject','p');        
        }
        TPagePaper.prototype.Draw.call(this,_object);
    };    
    
    TPagePaperParagraphs.prototype.LinkMethod = function(){
        TPagePaper.prototype.LinkMethod.call(this);        
        var i,j,n = this.GetNumberOfElements(),elem;
        var links = document.getElementsByTagName('a');
        for (j = 0;j < n;j++)
        {
            elem = this.GetElement(j);
            if (elem !== null && elem.IsType('TTitle'))
            {
                for(i=0; i < links.length; i++)
                {
                    if (links[i].className===elem.GetId())
                    {
                        links[i].onclick = this.LinkClick;  // nazwa funkcji bez ()!
                        links[i].thisObject = this;
//                            break;
                    }
                }    
            }
        }
    };    

    TPagePaperParagraphs.prototype.LinkClick = function(event){
        if (typeof event !== 'undefined' && event !== null && typeof event.currentTarget !== 'undefined' && event.currentTarget !== null)
        {
            if (typeof event.currentTarget.className !== 'undefined' && event.currentTarget.className !== null)
            {
//                var className = event.currentTarget.className;
                var id_ = event.currentTarget.hash;
                if (typeof id_ !== 'undefined' && id_ !== null)
                {
                    id_ = id_.substring(1,id_.length);
                    event.currentTarget.thisObject.FindVisibleSection(id_);
                    event.currentTarget.thisObject.SetVisibleSection();
                    var fun = event.currentTarget.thisObject.GetFun();
                    RemoveAllTimeOut();
                    if (fun !== null)
                        fun();
                    window.location.hash = id_;
//                    setTimeout(function(){ 
//                                       window.location.hash = id_;
//                                    }, 1000);
                    
                }
            }
        }
    };
    
    TPagePaperParagraphs.prototype.LinkMethodRef = function(){
        TPagePaper.prototype.LinkMethod.call(this);        
        var i,j,n = this.GetNumberOfElements(),elem,obj;
        var links = document.getElementsByTagName('a');
        for (j = 0;j < n;j++)
        {
            elem = this.GetElement(j);
            if (elem !== null)
            {
                if (elem.IsType('TNumberElement'))
                {
                    for(i=0; i < links.length; i++)
                    {
                        obj = elem.FindElementById(links[i].className);
//                        if (links[i].className===elem.GetId())
                        if (obj !== null)
                        {
                            links[i].onclick = this.LinkClickRef;  // nazwa funkcji bez ()!
                            links[i].thisObject = this;
//                            links[i].objectPageElement = elem;
                            links[i].objectPageElement = obj;
                        }
                    }    
                }
            }
        }
    };    


    TPagePaperParagraphs.prototype.ActualizeActions = function(){
        this.LinkMethodRef();
        var i,n = this.GetNumberOfElements(),elem;
        for (i = 0;i < n;i++)
        {
            elem = this.GetElement(i);
            if (typeof elem !== 'undefined' && elem !== null)
                elem.ActualizeActions();
        }
    };

    TPagePaperParagraphs.prototype.LinkClickRef = function(event){
        if (typeof event !== 'undefined' && event !== null && typeof event.currentTarget !== 'undefined' && event.currentTarget !== null)
        {
            var obj = event.currentTarget.objectPageElement;
            var thisObject = event.currentTarget.thisObject;
            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TNumberElement'))
            {
                var number = obj.GetNumber();
                if (typeof thisObject.visibleSection !== 'undefined' && thisObject.visibleSection !== null && thisObject.visibleSection.length > 0)
                {
                    var i,YN = false;
//                    if (thisObject.visibleSection.length > number.length)
                    if (thisObject.visibleSection.length > 1)
                        YN = true;
                    else
                        for (i = 0;i < thisObject.visibleSection.length;i++)
                        {
                            if (thisObject.visibleSection[i] !== number[i])
                            {
                                YN = true;
                                break;
                            }
                        }
                        if (YN)
                        {
                            thisObject.visibleSection = [];
                            thisObject.visibleSection[0] = number[0];
                            event.currentTarget.thisObject.SetVisibleSection();
                            RemoveAllTimeOut();
                            var fun = event.currentTarget.thisObject.GetFun();
                            if (fun !== null)
                                fun();
                        }
                    var id_ = event.currentTarget.hash;
                    id_ = id_.substring(1,id_.length);
                    window.location.hash = id_;
                }
            }
        }
    };
            
    TPagePaperParagraphs.prototype.ActualizeVisible = function(){
        if (typeof this.visibleSection !== 'undefined' && this.visibleSection !== null && typeof this.visibleSection.length > 0)
        {
            this.SetVisibleSection();
        }else 
            this.VisibleElements(false);
    };

    TPagePaperParagraphs.prototype.FindVisibleSection = function(id){
        this.visibleSection = [];
        if (typeof id !== 'undefined' && id !== null)
        {
            var i,j,n = this.GetNumberOfElements(),object,level,YN = false;
            for (i = 0;i < n;i++)
            {
                object = this.GetElement(i);
                if (typeof object !== 'undefined' && object !== null && object.IsType('TTitle'))
                {
                    level = object.GetLevel();
                    if (this.visibleSection.length <= level)
                        this.visibleSection[level] = 0;
                    for (j = level + 1;j < this.visibleSection.length;j++)
                        this.visibleSection[j] = 0;
                    this.visibleSection[level] = this.visibleSection[level] + 1;
                    if (id === object.GetId())
                    {
                        YN = true;
                        break;
                    }
                }
            }
            if (!YN)
                this.visibleSection = [];
        }
    };
    
    TPagePaperParagraphs.prototype.SetVisibleSection = function(){
        var ref = false;
        if (typeof this.visibleSection !== 'undefined' && this.visibleSection !== null && this.visibleSection.length > 0)
        {
            var i,n = this.GetNumberOfElements(),object,level,levels = [],YN = false,YN2,j;
            for (i = 0;i < n;i++)
            {
                object = this.GetElement(i);
                if (typeof object !== 'undefined' && object !== null)
                {
                    if (object.IsType('TTitle'))
                    {
                        level = object.GetLevel();
                        if (levels.length <= level)
                            levels[level] = 0;
                        for (j = level + 1;j < levels.length;j++)
                            levels[j] = 0;
                        levels[level] = levels[level] + 1;
                        if (levels.length >= this.visibleSection.length)
                        {
                            YN2 = true;
                            for (j = 0;j < this.visibleSection.length && this.visibleSection[j] !== 0;j++)
                            {
                                if (levels[j] !== this.visibleSection[j])
                                {
                                    YN2 = false;
                                    break;
                                }
                            }
                        }else
                            YN2 = false;
                        if (YN2)
                        {
                            YN = true;
                            ref = true;
                        }else
                            YN = false;
                    }
                }
                object.SetVisible(YN);
            }
        }
        return ref;
    };

    TPagePaperParagraphs.prototype.AddFigureName = function(name,_language){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof name !== 'undefined' && typeof _language !== 'undefined' && _language !== null)
        {
            if (this.figureName === null)
                this.figureName = objM.newObject('TMultilanguageStringData');
            if (this.figureName !== null)
            {
                this.figureName.SetStringData(name,_language);
            }
        }
    };    

    TPagePaperParagraphs.prototype.AddTableName = function(name,_language){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof name !== 'undefined' && typeof _language !== 'undefined' && _language !== null)
        {
            if (this.tableName === null)
                this.tableName = objM.newObject('TMultilanguageStringData');
            if (this.tableName !== null)
            {
                this.tableName.SetStringData(name,_language);
            }
        }
    };    

    TPagePaperParagraphs.prototype.ActualizeLocaleString = function(){
//        if (typeof this.figureName !== 'undefined' && this.figureName !== null && this.figureName.IsType('TMultilanguageStringData'))
        {
            var i,n = this.GetNumberOfElements(),object;
            for (i = 0;i < n;i++)
            {
                object = this.GetElement(i);
                if (typeof object !== 'undefined' && object !== null)
                {
                    if (object.IsType('TDrawFigure'))
                    {
                        object.AddObjectNameObject(this.figureName);
                    }
                    if (object.IsType('TTable'))
                    {
                        object.AddObjectNameObject(this.tableName);
                    }
                }
            }
        }
    };

    TPagePaperParagraphs.prototype.ChangeCurrentLanguageNumber = function(_language){
        TPagePaper.prototype.ChangeCurrentLanguageNumber.call(this,_language);
        if (typeof _language !== 'undefined' && _language !== null)
        {
            if (typeof this.figureName !== 'undefined' && this.figureName !== null && this.figureName.IsType('TMultilanguageStringData'))
            {
                this.figureName.ChangeCurrentLanguageNumber(_language);
            }
            if (typeof this.tableName !== 'undefined' && this.tableName !== null && this.tableName.IsType('TMultilanguageStringData'))
            {
                this.tableName.ChangeCurrentLanguageNumber(_language);
            }
        } 
    };

    TPagePaperParagraphs.prototype.ActualizeData = function(){
        this.EmptyDataType();
        this.AddDataType('Title');
        this.AddDataType('Paragraph');
        this.AddDataType('Code');
        this.AddDataType('Enumerate');
        this.AddDataType('Itemize');
        this.AddDataType('Equation');
        this.AddDataType('DrawFigure');
        this.AddDataType('ImageFileName');
        this.AddDataType('Table');
        this.AddDataType('Var');
        this.AddDataType('Fun');
        this.AddDataType('Timer');
        this.AddDataType('TableShow');
        this.AddDataType('TableEdit');
        this.AddDataType('Frame');
        TPagePaper.prototype.ActualizeData.call(this);
        var element,i,n = this.GetNumberOfElements(),obj,numberFigure,number = [],numberTable,number2 = [],numberEquation,number3 = [];
        for (i = 0,number[0] = 0,number2[0] = 0,number3[0] = 0,numberFigure = 0,numberTable = 0,numberEquation=0;i < n;i++)
        {
            obj = this.GetElement(i);
            if (typeof obj !== 'undefined' && obj !== null)
            {
                if (obj.IsType('TEnumerate') || obj.IsType('TItemize'))
                {
                    obj.ResetNumberElement();
                    for(;;)
                    {
                        element = obj.GetElement('TNumberElement');
                        if (element === null)
                            break;
                        if (element !== 'undefined' && element.GetNumeration())
                        {
                            if  (element.IsType('TDrawFigure'))
                            {
                                numberFigure++;
                                element.AddObjectNameObject(this.figureName);
                                number[1] = numberFigure;
                                element.SetNumber(number);
                            }
                            if  (element.IsType('TTable'))
                            {
                                numberTable++;
                                element.AddObjectNameObject(this.tableName);
                                number2[1] = numberTable;
                                element.SetNumber(number2);
                            }
                            if  (element.IsType('TEquation'))
                            {
                                numberEquation++;
            //                    obj.AddObjectNameObject('');
                                number3[1] = numberEquation;
                                element.SetNumber(number3);
                            }
                        }
                        
                    }
                }
                if  (obj.IsType('TTitle'))
                {
                    if (obj.GetLevel() === 0)
                    {
                        number[0]++;
                        numberFigure = 0;
                        number2[0]++;
                        numberTable = 0;
                        number3[0]++;
                        numberEquation = 0;
                    }
                }
                if  (obj.IsType('TDrawFigure'))
                {
                    numberFigure++;
                    obj.AddObjectNameObject(this.figureName);
                    number[1] = numberFigure;
                    obj.SetNumber(number);
                }
                if  (obj.IsType('TTable'))
                {
                    numberTable++;
                    obj.AddObjectNameObject(this.tableName);
                    number2[1] = numberTable;
                    obj.SetNumber(number2);
                }
                if  (obj.IsType('TEquation'))
                {
                    numberEquation++;
//                    obj.AddObjectNameObject('');
                    number3[1] = numberEquation;
                    obj.SetNumber(number3);
                }
            }
        }
    };

    TPagePaperParagraphs.prototype.NextChapter = function(){
        if (typeof this.visibleSection !== 'undefined' && this.visibleSection !== null)
           if (this.visibleSection.length === 0)
            {
                this.visibleSection[0] = 1;
                this.SetVisibleSection();
            }else
            {
                var tmp = this.visibleSection[0];
                this.visibleSection = [];
                this.visibleSection[0] = tmp + 1; 
                if (!this.SetVisibleSection())
                {
                    this.visibleSection[0] = tmp; 
                    this.SetVisibleSection();
                }
            }
    };

}

TPagePaperParagraphs.prototype = new TPagePaper();

function TPagePaperTitle(){
    var type = 'TPagePaperTitle';
    TPagePaperTitle.prototype.InitConstructor = function(){
        TPagePaper.prototype.InitConstructor.call(this);
        this.SetType(type);            
    };
    this.InitConstructor();

    TPagePaperTitle.prototype.Init = function(_object){
        TPagePaper.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TPagePaperTitle'))
        {
        }
    };

    TPagePaperTitle.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPagePaper.prototype.IsType.call(this,_type);
    };

    TPagePaperTitle.prototype.ActualizeData = function(){
        this.EmptyDataType();
        this.AddDataType('PaperTitle');
        this.AddDataType('Author');
        this.AddDataType('Affiliation');
        TPagePaper.prototype.ActualizeData.call(this);
    };

    TPagePaperTitle.prototype.Draw = function(_object,_drawObjectName){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject') && typeof _drawObjectName !== 'undefined' && _drawObjectName !== null)
            _object.SetTypeDrawObject(_drawObjectName);
        TPagePaper.prototype.Draw.call(this,_object);        
    };
}

TPagePaperTitle.prototype = new TPagePaper();


function TPageTableOfContens(){
    var type = 'TPageTableOfContens';
    TPageTableOfContens.prototype.InitConstructor = function(){
        TPagePaper.prototype.InitConstructor.call(this);
        this.title = null;
        this.SetType(type);            
    };
    this.InitConstructor();

    TPageTableOfContens.prototype.Init = function(_object){
        TPagePaper.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TPageTableOfContens'))
        {
            if (typeof _object.title !== 'undefined' && _object.title !== null && _object.title.IsType('TTitle'))
            {
                this.title = objM.copy(_object.title);
            }
        }
    };

    TPageTableOfContens.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPagePaper.prototype.IsType.call(this,_type);
    };
    
    TPageTableOfContens.prototype.SetTitle = function(title){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof title !== 'undefined' && title !== null && title.IsType('TTitle'))
        {
            this.title = objM.copy(title);
            if (this.title !== null)
                this.title.SetLevel(-1);
        }
        if (title === null)
            this.title = null;
    };    

    TPageTableOfContens.prototype.Read = function(readObject,fun){
        if (typeof readObject !== 'undefined' && readObject !== null && readObject.IsType('TRead'))
        {
            readObject.EmptyDataType();
            readObject.AddDataType('Title');
            TPagePaper.prototype.Read.call(this,readObject,fun);
           
        }
    };

    TPageTableOfContens.prototype.ActualizeData = function(){
        this.EmptyDataType();
        this.AddDataType('Title');
        TPagePaper.prototype.ActualizeData.call(this);
    };

    TPageTableOfContens.prototype.Draw = function(_object,_drawObjectName){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject') && typeof _drawObjectName !== 'undefined' && _drawObjectName !== null)
            _object.SetTypeDrawObject(_drawObjectName);
        if (typeof this.title !== 'undefined' && this.title !== null && this.title.IsType('TTitle'))
            this.title.Draw(_object);
        TPagePaper.prototype.Draw.call(this,_object);
    };    
    
    
    TPageTableOfContens.prototype.ChangeCurrentLanguageNumber = function(_language){
        if (typeof _language !== 'undefined' && _language !== null)
        {
            if (typeof this.title !== 'undefined' && this.title !== null && this.title.IsType('TTitle'))
            {
                this.title.ChangeCurrentLanguageNumber(_language);
            }
        } 
        TPagePaper.prototype.ChangeCurrentLanguageNumber.call(this,_language);
    
    };

}

TPageTableOfContens.prototype = new TPagePaper();

function TPagePresentation(){
    var type = 'TPagePresentation';
    TPagePresentation.prototype.InitConstructor = function(){
        TPage.prototype.InitConstructor.call(this);
        this.SetType(type);            
        this.backgroundId = null;
        this.backgroundFile = null;
        this.slideElements = [];
        this.title = [];
        this.id = null;
        this.numberNote = 0;
        this.timeOut = 0;
        this.timeOutObject = null;
    };
    this.InitConstructor();

    TPagePresentation.prototype.Init = function(_object){
        TPage.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TPagePresentation'))
        {
            var i;
            if (typeof _object.backgroundId !== 'undefined' && _object.backgroundId !== null)
            {
                this.backgroundId = new String(_object.backgroundId);
                this.backgroundId = this.backgroundId.toString();
            }
            if (typeof _object.backgroundFile !== 'undefined' && _object.backgroundFile !== null && _object.backgroundFile.IsType('TFileName'))
                this.backgroundFile = _object.backgroundFile;
            if (typeof _object.pageELements !== 'undefined' && _object.pageELements !== null)
            {
                this.slideElements = [];
                for (i = 0;i < _object.slideElements.length;i++)
                    this.slideElements[i] = _object.slideElements[i];
            }
            if (typeof _object.title !== 'undefined' && _object.title !== null)
            {
                this.title = [];
                for (i = 0;i < _object.title.length;i++)
                    this.title[i] = _object.title[i];
            }
            if (typeof _object.id !== 'undefined' && _object.id !== null)
            {
                this.id = new String(_object.id);
                this.id = this.id.toString();
            }
            if (typeof _object.numberNote !== 'undefined' && _object.numberNote !== null && IsInt(_object.numberNote))
                this.numberNote = _object.numberNote;
            if (typeof _object.timeOut !== 'undefined' && _object.timeOut !== null && IsInt(_object.timeOut))
                this.timeOut = _object.timeOut;
            if (typeof _object.timeOutObject !== 'undefined' && _object.timeOutObject !== null && _object.timeOutObject.IsType('TTimeOut'))
            {
                this.timeOutObject = _object.timeOutObject;
            }
        }
    };

    TPagePresentation.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPage.prototype.IsType.call(this,_type);
    };
    
    TPagePresentation.prototype.Draw = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var i,n = this.GetNumberOfElements(),object,numberNote = 0;
            for (i = 0;i < n;i++)
            {
                object = this.GetElement(i);
                if (typeof object !== 'undefined' && object !== null && object.IsType('TPageElement') && object.GetVisible())
                {
                    object.SetVariables(this.GetVariables());
                    object.Draw(_object);
                    if (object.IsType('TVar'))
                        this.SetVariables(object.GetVariables());
                }
            }
            n = this.GetNumberOfSlideElements();
            for (i = 0;i < n;i++)
            {
                object = this.GetSlideElement(i);
                if (typeof object !== 'undefined' && object !== null && object.IsType('TPageElement') && object.GetVisible())
                {
                    object.SetVariables(this.GetVariables());
                    if (object.IsType('TPresentationSlide'))
                        numberNote = 0;
                    if (object.IsType('TNote'))
                    {                        
                        object.Draw(_object,numberNote);
                        numberNote++;
                    }else
                        object.Draw(_object);
                    if (object.IsType('TVar'))
                        this.SetVariables(object.GetVariables());
                }
            }
            var tmp = this.GetId();
            if (tmp !== null)
                _object.Add('Id',tmp);
        } 
    };
    
    TPagePresentation.prototype.SetBackgroundId = function(_id){
        if (typeof _id !== 'undefined' && _id !== null)
        {
            this.backgroundId = new String(_id);
            this.backgroundId = this.backgroundId.toString();
        }
    };

    TPagePresentation.prototype.GetBackgroundId = function(){
        if (typeof this.backgroundId !== 'undefined' && this.backgroundId !== null)
        {
            var tmp = new String(this.backgroundId);
            return  tmp.toString();
        }
        return null;
    };

    TPagePresentation.prototype.SetBackground = function(file){
        var objM = this.GetObjectManager();
        if (objM !== null &&typeof file !== 'undefined' && file !== null && file.IsType('TFileName'))
            this.background = file;
    };

    TPagePresentation.prototype.GetBackground = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            return this.background;
        }
        return null;
    };
    
    TPagePresentation.prototype.GetFileNameBackgroundString = function(){
        var tmp = this.GetBackground();
        if (typeof tmp !== 'undefined' && tmp !== null)
        {
            return tmp.GetFileNameString();
        }
        return null;
    };
    
    TPagePresentation.prototype.GetNumberOfSlideElements = function(){
        if (this.slideElements !== null)
        {
            return this.slideElements.length;
        }
        return 0;
    };

    TPagePresentation.prototype.GetSlideElement = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0)
        {
            if (this.slideElements !== null && number < this.slideElements.length)
                return this.slideElements[number];
        }
        return null;
    };    

    TPagePresentation.prototype.AddSlideElement = function(_element){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _element !== 'undefined' && _element !== null && _element.IsType('TPageElement'))
        {
//            this.pageELements[this.pageELements.length] = objM.copy(_element);
            this.slideElements[this.slideElements.length] = _element;
        }
    };    
           
    TPagePresentation.prototype.FindSlideElementType = function(_type){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _type !== 'undefined' && _type !== null)
        {
            var i,j=0;
            var res = [];
            for (i = 0;i < this.slideElements.length;i++)
            {
                if (typeof this.slideElements[i] !== 'undefined' && this.slideElements[i] !== null && this.slideElements[i].IsType(_type))
                    res[j++] = this.slideElements[i];
            }
            return res;
        }
        return null;
    };    

    TPagePresentation.prototype.SetSlideElement = function(_element,number){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _element !== 'undefined' && _element !== null && _element.IsType('TPageElement'))
        {
            if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0)
            {
                if (this.slideElements !== null)
                    this.slideElements[number] = _element;
            }
        }
    };    

    TPagePresentation.prototype.SetId = function(_id){
        if (typeof _id !== 'undefined' && _id !== null)
        {
            this.id = new String(_id);
            this.id = this.id.toString();
        }
        if (_id === null)
            this.id = null;
    };

    TPagePresentation.prototype.GetId = function(){
        if (this.id !== null)
        {
            var tmp = new String(this.id);
            if (tmp !== null)
                return tmp.toString();
        }
        return null;
    };

    TPagePresentation.prototype.ActualizeId = function(){
        TPage.prototype.ActualizeId.call(this);
        if(typeof this.slideElements !== 'undefined' && this.slideElements !== null)
        {
            var i,n = this.slideElements.length,ob;
            for(i = 0;i<n;i++)
            {
                ob = this.slideElements[i];
                if (typeof ob !== 'undefined' && ob !== null)
                {
                    ob.ActualizeId(this.slideElements);
                }
            }
        }
    };

    TPagePresentation.prototype.SetNumberNote = function(_number){
        if (typeof _number !== 'undefined' && _number !== null)
        {
            this.numberNote = _number;
            return;
        }
        this.numberNote = 0;
    };

    TPagePresentation.prototype.GetNumberNote = function(){
        return this.numberNote;
    };

    TPagePresentation.prototype.NextNote = function(){
        this.numberNote++;
    };

    TPagePresentation.prototype.PrevNote = function(){
        this.numberNote--;
        if (this.numberNote < 0)
            this.numberNote = 0;
    };


    TPagePresentation.prototype.SetTimeOut = function(time){
        if (typeof time !== 'undefined' && time !== null && IsInt(time))
        {
            time = parseInt(time);
            if (time !== null)
                this.timeOut = time;
        }
    };

    TPagePresentation.prototype.SetTimeOutObject = function(time){
        if (typeof time !== 'undefined' && time !== null && time.IsType('TTimeOut'))
        {
            this.timeOutObject = time;
        }
    };

    
    TPagePresentation.prototype.GetTimeOut = function(){
        if (this.timeOutObject !== null)
        {
            var tmp = this.timeOutObject.GetTimeOut();
            if (tmp !== null)
                return tmp;
        }
        return this.timeOut;
    };

    TPagePresentation.prototype.ActualizeActions = function(){
        var i,n = this.GetNumberOfElements(),elem;
        for (i = 0;i < n;i++)
        {
            elem = this.GetElement(i);
            if (typeof elem !== 'undefined' && elem !== null)
                elem.ActualizeActions();
        }
        if (typeof this.slideElements !== 'undefined' && this.slideElements !== null)
        {
            var i,n = this.slideElements.length,elem;
            for (i = 0;i < n;i++)
            {
                elem = this.slideElements[i];
                if (typeof elem !== 'undefined' && elem !== null)
                    elem.ActualizeActions();
            }
        }
    };

    TPagePresentation.prototype.SetImageCatalog = function(catalog){
        TPage.prototype.SetImageCatalog.call(this,catalog);
        if (typeof this.imageCatalog !== 'undefined' && this.imageCatalog !== null)
        {
            if (typeof this.slideElements !== 'undefined' && this.slideElements !== null)
            {
                var i;
                for (i = 0;i < this.slideElements.length;i++)
                {
                    if (typeof this.slideElements[i] !== 'undefined' && this.slideElements[i] !== null)
                    {
                        if (this.slideElements[i].IsType('TDrawFigure'))
                            this.slideElements[i].SetImageCatalog(this.imageCatalog);
                        if (this.slideElements[i].IsType('TEnumerate'))
                            this.slideElements[i].SetImageCatalog(this.imageCatalog);
                        if (this.slideElements[i].IsType('TItemize'))
                            this.slideElements[i].SetImageCatalog(this.imageCatalog);
                    }
                }
            }
        }
    };

}

TPagePresentation.prototype = new TPage();


function TPresentationTitle(){
    var type = 'TPresentationTitle';
    TPresentationTitle.prototype.InitConstructor = function(){
        TPagePresentation.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TPresentationTitle.prototype.Init = function(_object){
        TPagePresentation.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TPresentationTitle'))
        {
        }
    };

    TPresentationTitle.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPagePresentation.prototype.IsType.call(this,_type);
    };
    

    TPresentationTitle.prototype.ActualizeData = function(){
        this.EmptyDataType();
        this.AddDataType('PaperTitle');
        this.AddDataType('Author');
        this.AddDataType('Affiliation');
        TPagePresentation.prototype.ActualizeData.call(this);
    };

    TPresentationTitle.prototype.Draw = function(_object,_drawObjectName){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject') && typeof _drawObjectName !== 'undefined' && _drawObjectName !== null)
        {
            _object.SetTypeDrawObject(_drawObjectName);
            var tmp = _object.GetDrawObject();
            if (tmp !== null)
                tmp.SetSlide(true);
        }
//        if (typeof this.title !== 'undefined' && this.title !== null && this.title.IsType('TTitle'))
//            this.title.Draw(_object);
//        TPagePresentation.prototype.Draw.call(this,_object);

        
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var i,n = this.GetNumberOfSlideElements(),object;
            for (i = 0;i < n;i++)
            {
                object = this.GetSlideElement(i);
                if (typeof object !== 'undefined' && object !== null && object.IsType('TPageElement') && object.GetVisible())
                {
                    
                    if (!object.IsType('TPaperTitle'))
                    {
                    }
                    object.Draw(_object);
                }
            }
            var j,n2 = this.GetNumberOfElements(),object2,YN;
            for (i = 0;i < n2;i++)
            {
                object = this.GetElement(i);
                if (typeof object !== 'undefined' && object !== null && object.IsType('TPageElement') && object.GetVisible())
                {
                    YN = true;
                    for (j = 0;j < n;j++)
                    {
                        object2 = this.GetSlideElement(j);
                        if (typeof object2 !== 'undefined' && object2 !== null && object2.IsType('TPageElement') && object.GetVisible())
                        {
                            if (object.GetType() === object2.GetType())
                            {
                                YN = false;
                                break;
                            }
                        }
                        
                    }
                    
                    if (YN)
                    {
                        if (!object.IsType('TPaperTitle'))
                        {
                        }
                        object.Draw(_object);
                    }
                }
            }
        } 
    };        
    
}

TPresentationTitle.prototype = new TPagePresentation();

function TPresentationTableOfContents(){
    var type = 'TPresentationTableOfContents';
    TPresentationTableOfContents.prototype.InitConstructor = function(){
        TPagePresentation.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TPresentationTableOfContents.prototype.Init = function(_object){
        TPagePresentation.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TPresentationTableOfContents'))
        {
        }
    };

    TPresentationTableOfContents.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPagePresentation.prototype.IsType.call(this,_type);
    };
    
    TPresentationTableOfContents.prototype.Draw = function(_object,_drawObjectName){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject') && typeof _drawObjectName !== 'undefined' && _drawObjectName !== null)
        {
            _object.SetTypeDrawObject(_drawObjectName);
            var tmp = _object.GetDrawObject();
            if (tmp !== null)
                tmp.SetSlide(true);
        }
        TPagePresentation.prototype.Draw.call(this,_object);        
    };

    TPresentationTableOfContents.prototype.LinkMethod = function(fun,object){
        TPagePresentation.prototype.LinkMethod.call(this);        
        var i,j,n = this.GetNumberOfSlideElements(),obj;
        var links = document.getElementsByTagName('a');
        for (j = 0;j < n;j++)
        {
            obj = this.GetSlideElement(j);
            if (obj !== null && obj.IsType('TPageElementPresentationTitle'))
            {
                for(i=0; i < links.length; i++)
                {
                    if (links[i].className==='Slide' + obj.GetId())
                    {
                        links[i].onclick = fun;  // nazwa funkcji bez ()!
                        links[i].thisObject = object;
//                            break;
                    }
                }    
            }
        }
    };    
    
}

TPresentationTableOfContents.prototype = new TPagePresentation();


function TPresentationSlide(){
    var type = 'TPresentationSlide';
    TPresentationSlide.prototype.InitConstructor = function(){
        TPagePresentation.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.titleYN = true;
    };
    this.InitConstructor();

    TPresentationSlide.prototype.Init = function(_object){
        TPagePresentation.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TPresentationSlide'))
        {
            if (typeof _object.titleYN !== 'undefined' && _object.titleYN !== null)
                this.titleYN = _object.titleYN;
        }
    };

    TPresentationSlide.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TPagePresentation.prototype.IsType.call(this,_type);
    };
    
    TPresentationSlide.prototype.Draw = function(_object,_drawObjectName){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            _object.SetTypeDrawObject(_drawObjectName);
            var tmp = _object.GetDrawObject();
            if (tmp !== null)
            {
                tmp.SetNumberNote(this.GetNumberNote());
                tmp.SetSlide(true);
                if (this.titleYN === false)
                    tmp.Add('TitleYN','No');
            }
        }
        TPagePresentation.prototype.Draw.call(this,_object);        
    };

    TPresentationSlide.prototype.ActualizeData = function(){
        TPagePresentation.prototype.ActualizeData.call(this);        
        var objM = this.GetObjectManager();
        if (objM !== null && typeof this.data !== 'undefined' && this.data !== null && this.data.IsType('TReadPaperData'))
        {
            var i,n = this.GetNumberOfSlideElements(),ob,ob2;
            for(i = 0;i<n;i++)
            {
                ob = this.GetSlideElement(i);
                if (typeof ob !== 'undefined' && ob !== null)
                {
                    ob2 = ob.ActualizeData(this.data);
                    if (ob2 !== null && ob.IsType('TReference'))
                        this.SetSlideElement(ob2,i);
                }
            }
            this.ActualizeId();
            this.ActualizeVisible();
        }
    };

    TPresentationSlide.prototype.FindSlideElementTypeTitleLevel = function(level){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof level !== 'undefined' && level !== null && IsInt(level))
        {
            var i;
            for (i = 0;i < this.slideElements.length;i++)
            {
                if (typeof this.slideElements[i] !== 'undefined' && this.slideElements[i] !== null && this.slideElements[i].IsType('TPageElementPresentationTitle'))
                {
                    if (parseInt(this.slideElements[i].GetLevel()) === level)
                        return this.slideElements[i];
                }
            }
        }
        return null;
    };    

    TPresentationSlide.prototype.SetTitleYN = function(YN){
        if (typeof YN !== 'undefined' && YN !== null)
            this.titleYN = YN;
    };

    TPresentationSlide.prototype.GetTitleYN = function(){
        return this.titleYN;
    };
}

TPresentationSlide.prototype = new TPagePresentation();


function TPresentationManager(){
    var type = 'TPresentationManager';
    TPresentationManager.prototype.InitConstructor = function(){
        TObjectMultilanguage.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.section = [];
        this.fileName = [];
        this.readObject = null;
        this.defaultBackground = [];
        this.data = [];
        this.divId = null;
        this.actualSection = 0;
        this.titles = [];
        this.titlePlanPresentation = null;
        this.screenWidth = 0;
        this.screenHeight = 0;
        this.eventChangeSlide = null;
        this.noteSize = 0;
        this.imageCatalog = null;
        this.funTimeOutSlide = null;
        this.timeOutPointer = null;
        this.sceneTeX = null;
        this.sceneTeX2 = null;
        this.variables = null;
    };
    this.InitConstructor();

    TPresentationManager.prototype.InitConstructor2 = function(){
        TObjectMultilanguage.prototype.InitConstructor2.call(this);
        var objM = this.GetObjectManager();
        if (objM !== null)
            this.variables = objM.newObject('TVariables');
//            this.section[0] = objM.newObject('TPresentationTitle');
    };
    this.InitConstructor();

    TPresentationManager.prototype.Init = function(_object){
        TObjectMultilanguage.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TPresentationManager'))
        {
            var i;
            if (typeof _object.section !== 'undefined' && _object.section !== null)
            {
                this.section = [];
                for (i = 0;i < _object.section.length;i++)
                    this.section[i] = _object.section[i];
            }
            if (typeof _object.fileName !== 'undefined' && _object.fileName !== null)
            {
                this.fileName = [];
                for (i = 0;i < _object.fileName.length;i++)
                    this.fileName[i] = _object.fileName[i];
            }
            if (typeof _object.defaultBackground !== 'undefined' && _object.defaultBackground !== null && _object.defaultBackground.IsType('TFileName'))
                this.defaultBackground = objM.copy(_object.defaultBackground);
            if (typeof _object.data !== 'undefined' && _object.data !== null && _object.data.IsType('TReadData'))
                this.data = _object.data;
            if (typeof _object.divId !== 'undefined' && _object.divId !== null)
            {
                this.divId = new String(_object.divId);
                this.divId = this.divId.toString();
            }
            if (typeof _object.actualSection !== 'undefined' && _object.actualSection !== null && IsInt(_object.actualSection))
                this.actualSection = _object.actualSection;
            if (typeof _object.titles !== 'undefined' && _object.titles !== null)
            {
                this.titles = [];
                for (i = 0;i < _object.titles.length;i++)
                    this.titles[i] = objM.copy(_object.titles[i]);
            }
            if (typeof _object.actualSection !== 'undefined' && _object.actualSection !== null && IsInt(_object.actualSection))
                this.actualSection = _object.actualSection;
            if (typeof _object.screenWidth !== 'undefined' && _object.screenWidth !== null && IsInt(_object.screenWidth))
                this.screenWidth = _object.screenWidth;
            if (typeof _object.screenHeight !== 'undefined' && _object.screenHeight !== null && IsInt(_object.screenHeight))
                this.screenHeight = _object.screenHeight;
            if (typeof _object.eventChangeSlide !== 'undefined' && _object.eventChangeSlide !== null)
                this.eventChangeSlide = _object.eventChangeSlide;
            if (typeof _object.noteSize !== 'undefined' && _object.noteSize !== null)
                this.noteSize = _object.noteSize;
            if (typeof _object.numberNote !== 'undefined' && _object.numberNote !== null)
                this.numberNote = _object.numberNote;
            if (typeof _object.imageCatalog !== 'undefined' && _object.imageCatalog !== null)
            {
                this.imageCatalog = new String(_object.imageCatalog);
                this.imageCatalog = this.imageCatalog.toString();
            }
            if (typeof _object.funTimeOutSlide !== 'undefined' && _object.funTimeOutSlide !== null)
                this.funTimeOutSlide = _object.funTimeOutSlide;
            if (typeof _object.timeOutPointer !== 'undefined' && _object.timeOutPointer !== null)
                this.timeOutPointer = _object.timeOutPointer;
            if (typeof _object.sceneTeX !== 'undefined' && _object.sceneTeX !== null && _object.sceneTeX.IsType('TThreeScene'))
                this.sceneTeX = objM.copy(_object.sceneTeX);
            if (typeof _object.sceneTeX2 !== 'undefined' && _object.sceneTeX2 !== null && _object.sceneTeX2.IsType('TThreeScene'))
                this.sceneTeX2 = objM.copy(_object.sceneTeX2);
            if (typeof _object.variables !== 'undefined' && _object.variables !== null && _object.variables.IsType('TVariables'))
                this.variables = objM.copy(_object.variables);
        }
    };

    TPresentationManager.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectMultilanguage.prototype.IsType.call(this,_type);
    };
    
    TPresentationManager.prototype.Draw = function(_typeObject){
        var txt = '',drawTeX,tmp2;
        var objM = this.GetObjectManager();
        if (objM !== null && typeof this.section !== 'undefined' && this.section !== null && typeof _typeObject !== 'undefined' && _typeObject !== null)// && _object.IsType('TGenerateObject'))
        {
//            var _object = objM.
            if (_typeObject === 'THTMLObject' && typeof this.divId !== 'undefined' && this.divId !== null)
                $('#' + this.divId).empty();
            var _object = objM.newObject(_typeObject);
            var tmp = _object.GetSlide();
            _object.SetSlide(true);
            var i,time_;
            if (_object.IsType('THTMLObject'))
            {
                if (this.actualSection >= 0 && this.actualSection < this.section.length)
                    if (this.section[this.actualSection] !== null)
                    {
                        this.section[this.actualSection].SetVariables(this.GetVariables());
                        if (this.section[this.actualSection].IsType('TPresentationTitle'))
                            this.section[this.actualSection].Draw(_object,'THTMLTitlePageObject');
                        if (this.section[this.actualSection].IsType('TPresentationTableOfContents'))
                            this.section[this.actualSection].Draw(_object,'THTMLTableOfContens');
                        if (this.section[this.actualSection].IsType('TPresentationSlide'))
                            this.section[this.actualSection].Draw(_object,'THTMLSlide');
                        var file = this.section[this.actualSection].GetFileNameBackgroundString();
                        if (this.section[this.actualSection].IsType('TVar'))
                            this.SetVariables(this.section[this.actualSection].GetVariables());
                        time_ = this.section[this.actualSection].GetTimeOut();
                        if (time_ > 0 && this.funTimeOutSlide !== null)
                        {
/*                            tmpasada = this;
                            setTimeout(function(){
                                tmpasada.NextSlide(); 
                                tmpasada.Draw('THTMLObject');
                            }, time_);*/
                            this.timeOutPointer = setTimeout(this.funTimeOutSlide, time_);
                        }
                        var image = this.section[this.actualSection].GetBackground();
                        if (file === null || image === null)// || typeof image === 'undefined')
                        {
                            file = this.GetDefaultBackgroundFileName();
                            image = this.GetDefaultBackground();
                        }
                        var tmp = [];
                        tmp[0] = this.screenWidth;
                        tmp[1] = this.screenHeight;
                        if (typeof image !== 'undefined' && image !== null)
                        {
                            tmp[2] = image.GetWidth();
                            tmp[3] = image.GetHeight();
                        }else
                            return;
                        _object.Add('ImageCatalog',this.imageCatalog);
                        _object.Add('BackgroundImage',file,tmp);
                        _object.Add('ResizeToObject','SlideBlock');                        
                        _object.Add('ResizeToFontObject','SlideBlock');                        
                        if (this.noteSize > 0)
                            _object.Add('NoteSize',this.noteSize);
                            
                        
//                        $('#' + this.divId).css("background-image", "url(" + file + ")");  
                    }
            }
            if (_object.IsType('TTeXObject'))
            {
                var id1 = null,id2 = null,tmp3,tmp4;
                if (typeof this.sceneTeX === 'undefined' || this.sceneTeX === null)
                {
                    this.sceneTeX = objM.newObject('TThreeScene');
                    this.sceneTeX.ResetSynchronization();
                    this.sceneTeX.SetImageCatalog(RandomString(15));
                }
                if (typeof this.sceneTeX2 === 'undefined' || this.sceneTeX2 === null)
                {
                    this.sceneTeX2 = objM.newObject('TCanvasScene');
                    this.sceneTeX2.ResetSynchronization();
                    this.sceneTeX2.SetImageCatalog(this.sceneTeX.GetImageCatalog());
   
                }
                for (i = 0;i < this.section.length;i++)
                {
                    if (this.section[i] !== null)
                    {
                        if (this.section[i].IsType('TPresentationTitle'))
                        {
                            drawTeX = objM.newObject('TTeXObject');
                            drawTeX.SetSlide(true);
                            this.section[i].Draw(drawTeX,'TTeXPresentationTitlePageObject');
//                            drawTeX.SetImageCatalog(this.sceneTeX.GetImageCatalog());
                            drawTeX.Add('ImageCatalog',this.imageCatalog);
                            txt = txt + drawTeX.GetTXT();
                        }
                        if (this.section[i].IsType('TPresentationTableOfContents'))
                        {
                            drawTeX = objM.newObject('TTeXObject');
                            drawTeX.SetSlide(true);
                            this.section[i].Draw(drawTeX,'TTeXTableOfContens');
//                            drawTeX.SetImageCatalog(this.sceneTeX.GetImageCatalog());
                            drawTeX.Add('ImageCatalog',this.imageCatalog);
                            txt = txt + drawTeX.GetTXT();
                        }
                        if (this.section[i].IsType('TPresentationSlide'))
                        {
                            drawTeX = objM.newObject('TTeXObject');
                            drawTeX.SetSlide(true);
                            tmp2 = this.section[i].FindSlideElementTypeTitleLevel(0);
                            if (tmp2 !== null)
                            {
                                if (id1 !== tmp2.GetId())
                                {
                                    id1 = tmp2.GetId();
                                    id2 = null;
                                    tmp3 = tmp2.GetTitle();
                                    if (tmp3 !== null)
                                    {
                                        tmp4 = tmp3.GetElement(0);
                                        if (tmp4 !== null)
                                            txt = txt + '\\section{' + tmp4.GetStringData() +'}\n';                                        
                                    }   
                                }
                            }
                            tmp2 = this.section[i].FindSlideElementTypeTitleLevel(1);
                            if (tmp2 !== null)
                            {
                                if (id2 !== tmp2.GetId())
                                {
                                    id2 = tmp2.GetId();
                                    tmp3 = tmp2.GetTitle();
                                    if (tmp3 !== null)
                                    {
                                        tmp4 = tmp3.GetElement(0);
                                        if (tmp4 !== null)
                                            txt = txt + '\\subsection{' + tmp4.GetStringData() +'}\n';                                        
                                    }   
                                }
                            }
                            this.section[i].Draw(drawTeX,'TTeXSlide');
                            drawTeX.SetImageCatalog(this.sceneTeX.GetImageCatalog());
                            drawTeX.Add('ImageCatalog',this.imageCatalog);
//                            this.sceneTeX.SetImageCatalog(drawTeX.GetImageCatalog());
                            drawTeX.DrawThreeFigure(this.sceneTeX);
                            drawTeX.DrawCanvasFigure(this.sceneTeX2);
                            txt = txt + drawTeX.GetTXT();
                        }
                        var file = this.section[i].GetFileNameBackgroundString();
                        if (file === null)
                            file = this.GetDefaultBackgroundFileName();
                    }
                    
                }
                //scene.SetImageCatalog(drawTeX.GetImageCatalog());

            }
            _object.SetSlide(tmp);
            if (_object.IsType('THTMLObject') && typeof this.divId !== 'undefined' && this.divId !== null)
            {
                txt = _object.GetTXT();
                $('#' + this.divId).append(txt);
/*                var obj,j,id,video;
                
                if (this.section.length > 0 && this.actualSection !== null && this.actualSection >= 0 && typeof this.section[this.actualSection] !== 'undefined' && this.section[this.actualSection] !== null)
                {
                    if (this.section[this.actualSection].IsType('TPresentationSlide'))
                    {
                        obj = this.section[this.actualSection].FindSlideElementType('TVideo');
                        if (obj !== null)
                        {
                            for (j=0;j < obj.length;j++)
                            {
                                if (obj[j].GetVideoAutoPlay())
                                {
                                    id = obj[j].GetId();
                                    video = document.getElementById(id);
                                    if (video !== null)
                                    {
                                        video.addEventListener('canplay', function() {
                                          video.play();
                                        });                                        
                                        video.play();
                                    }
                                }
                            }
                        }
                    }
                }*/
               
                _object.SetThisObject();
                
                for (i = 0;i < this.section.length;i++)
                {
                    if (this.section[i] !== null)
                    {
                        if (this.section[i].IsType('TPresentationTableOfContents'))
                        {
                            this.section[i].LinkMethod(this.LinkClick,this);
                        }
                    }
                }
                var ctx = objM.newObject('TDrawCanvasContext');
                _object.DrawFigure(ctx);
                var ctx = objM.newObject('TDrawSvgContext');
                _object.DrawFigure(ctx);
                var scene = objM.newObject('TThreeScene');
                _object.DrawThreeFigure(scene);
                var scene2 = objM.newObject('TCanvasScene');
                _object.DrawCanvasFigure(scene2);
                this.ActualizeActions();
            }
        }
        return txt;
    };
    

    TPresentationManager.prototype.ActualizeActions = function(){
        if (typeof this.section !== 'undefined' && this.section !== null)
        {
            var i;
            for (i = 0;i < this.section.length;i++)
            {
                if (typeof this.section[i] !== 'undefined' && this.section[i] !== null)
                    this.section[i].ActualizeActions();
            }
        }
    
    };

    TPresentationManager.prototype.Read = function(/*_readObject,*/readSlide,fun){
//        var numberLang = this.GetCurrentLanguage();
//        if (!this.GetLoadLanguage(numberLang))
//        {
            if (typeof this.section !== 'undefined' && this.section !== null)
            {
                readSlide.EmptyDataType();
                readSlide.AddDataType('PaperTitle');
                readSlide.AddDataType('Author');
                readSlide.AddDataType('Affiliation');
                readSlide.AddDataType('Paragraph');
                readSlide.AddDataType('Code');
                readSlide.AddDataType('Equation');
                readSlide.AddDataType('DrawFigure');
                readSlide.AddDataType('Reference');
                readSlide.AddDataType('Enumerate');
                readSlide.AddDataType('Itemize');
                readSlide.AddDataType('Note');
                readSlide.AddDataType('ImageBitmap');
                readSlide.AddDataType('Table');
                readSlide.AddDataType('Video');
                readSlide.AddDataType('TimeOut');
                readSlide.AddDataType('Var');
                readSlide.AddDataType('Fun');
                readSlide.AddDataType('Timer');
                readSlide.AddDataType('TableShow');
                readSlide.AddDataType('TableEdit');
				readSlide.AddDataType('Frame');
                
//                if (typeof _readObject !== 'undefined')
//                    this.readObject = _readObject;
                if (typeof readSlide !== 'undefined' && readSlide !== null && readSlide.IsType('TRead'))
                    readSlide.Read(this,fun,this.imageCatalog);
            }
//            this.SetLoadLanguage(numberLang,true);
//        }else
//        {
//            this.ChangeCurrentLanguageNumber(numberLang);
//            this.fun();
//            this.LinkMethod();
//            this.ActualizeVisible();
//        }
    };
    
    TPresentationManager.prototype.Read2 = function(fun){
        if (typeof this.section !== 'undefined' && this.section !== null && typeof this.readObject !== 'undefined' && this.readObject !== null && this.readObject.IsType('TRead'))
        {
            var i;
            for (i = 0;i < this.section.length;i++)
                if (this.section[i] !== null)
                    this.section[i].Read(this.readObject,fun);
        }
    };

    TPresentationManager.prototype.ChangeCurrentLanguageNumber = function(_language){
        if (typeof _language !== 'undefined' && _language !== null)
        {
            if (typeof this.section !== 'undefined' && this.section !== null)
            {
                var i;
                for (i = 0;i < this.section.length;i++)
                    if (this.section[i] !== null)
                        this.section[i].ChangeCurrentLanguageNumber(_language);
            }
            if (typeof this.fileName !== 'undefined' && this.fileName !== null)
            {
                var i;
                for (i = 0;i < this.fileName.length;i++)
                    if (this.fileName[i] !== null)
                        this.fileName[i].ChangeCurrentLanguageNumber(_language);
            }
            if (typeof this.defaultBackground !== 'undefined' && this.defaultBackground !== null)
                for (i = 0;i < this.defaultBackground.length;i++)
                    this.defaultBackground[i].ChangeCurrentLanguageNumber(_language);
            if (typeof this.titlePlanPresentation !== 'undefined' && this.titlePlanPresentation !== null)
                this.titlePlanPresentation.ChangeCurrentLanguageNumber(_language);
        } 
        TObjectMultilanguage.prototype.ChangeCurrentLanguageNumber.call(this,_language);
    
    };

    TPresentationManager.prototype.SetFileName = function(_fileName,number){
 //       var objM = this.GetObjectManager();
        if (/*objM !== null && */typeof _fileName !== 'undefined' && _fileName !== null && _fileName.IsType('TFileName') && typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0)
        {
            this.fileName[number] = _fileName;
        }else
            this.fileName[number] = null;
    };
    
    TPresentationManager.prototype.GetFileName = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0 && number < this.fileName.length)
        {
            return this.fileName[number];
        }
        return null;
    };

    TPresentationManager.prototype.SetDefaultBackground = function(background){
        if (typeof background !== 'undefined' && background !== null && background.IsType('TFileName'))
        {
            this.defaultBackground = background;
        }else
            this.defaultBackground = null;
    };
    
    TPresentationManager.prototype.GetDefaultBackground = function(){
        return this.defaultBackground;
    };

    TPresentationManager.prototype.GetDefaultBackgroundFileName = function(){
        if (this.defaultBackground !== null)
            return this.defaultBackground.GetFileNameString();
        return null;
    };

    TPresentationManager.prototype.FindFileName = function(_id){
        if (typeof _id !== 'undefined' && _id !== null)
        {
            var i;
            for (i = 0;i < this.fileName.length;i++)
            {
                if (_id === this.fileName[i].GetId())
                    return this.fileName[i];
            }
        }
        return null;
    };

    TPresentationManager.prototype.SetSection = function(_section,number){
 //       var objM = this.GetObjectManager();
        if (/*objM !== null && */typeof _section !== 'undefined' && _section !== null && typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0)
        {
            this.section[number] = _section;
        }else
            this.section[number] = null;
    };
    
    TPresentationManager.prototype.GetSection = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0 && number < this.section.length)
        {
            return this.section[number];
        }
        return null;
    };

    TPresentationManager.prototype.SetData = function(_data){
        if (typeof _data !== 'undefined' && _data !== null && _data.IsType('TReadData'))
        {
            this.data = _data;
        }
    };

    TPresentationManager.prototype.GetData = function(){
        return this.data;
    };

    TPresentationManager.prototype.ActualizeData = function(){
        if (typeof this.section !== 'undefined' && this.section !== null)
        {
            var i,j,YN,obj,n;
            for (i = 0;i < this.section.length;i++)
                if (this.section[i] !== null)
                {
                    if (typeof this.section[i] !== 'undefined' && this.section[i] !== null && this.section[i].IsType('TPresentationTableOfContents'))
                    {
                        n = this.section[i].GetNumberOfSlideElements();
                        YN = true;
                        for (j=0;j < n;j++)
                        {
                            obj = this.section[i].GetSlideElement(j);
                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElementPresentationTitle'))
                            {
                                if (obj.GetLevel() === -1)
                                {
                                    YN = false;
                                    break;
                                }
                            }
                        }
                        if (YN)
                            this.section[i].AddSlideElement(this.titlePlanPresentation);
                        else
                            this.section[i].AddSlideElement(this.SetSlideElement,i);
                    }
                    this.section[i].SetData(this.GetData());
                    this.section[i].ActualizeData();
                    this.section[i].SetBackground(this.FindFileName(this.section[i].GetBackgroundId()));
                    this.section[i].SetImageCatalog(this.imageCatalog);
                }
        }
    };

    TPresentationManager.prototype.SetDivId = function(div){
        if (typeof div !== 'undefined' && div !== null)
        {
            this.divId = new String(div);
            this.divId = this.divId.toString();
        }
    };

    TPresentationManager.prototype.ResetTimeOutPointer = function(){
        if (this.timeOutPointer !== null)
        {
            clearTimeout(this.timeOutPointer);
            this.timeOutPointer = null;
        }
    };

    TPresentationManager.prototype.NextSlide = function(){
        this.ResetTimeOutPointer();
        this.TimeOutNextSlide();
    };

    TPresentationManager.prototype.TimeOutNextSlide = function(){
        if (this.actualSection + 1 < this.section.length)
        {
            this.actualSection++;
            if (this.eventChangeSlide !== null)
            {
                RemoveAllTimeOut();
                this.eventChangeSlide(this.actualSection);
            }
            this.SetNumberNote(0);
        }
    };

    TPresentationManager.prototype.PrevSlide = function(){
        this.ResetTimeOutPointer();
        if (this.actualSection - 1 >= 0)
        {
            this.actualSection--;
            if (this.eventChangeSlide !== null)
            {
                RemoveAllTimeOut();
                this.eventChangeSlide(this.actualSection);
            }
            this.SetNumberNote(0);
        }
    };

    TPresentationManager.prototype.FindTableOfContens = function(){
        var result = [],i,j;
        for (i = 0,j = 0;i < this.section.length;i++)
            if (typeof this.section[i] !== 'undefined' && this.section[i] !== null && this.section[i].IsType('TPresentationTableOfContents'))
                result[j++] = this.section[i];
        return result;
    };

    TPresentationManager.prototype.SetTitle = function(_title,number){
 //       var objM = this.GetObjectManager();
        if (/*objM !== null && */typeof _title !== 'undefined' && _title !== null && _title.IsType('TPageElementPresentationTitle') && typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0)
        {
            this.titles[number] = _title;
        }else
            this.titles[number] = null;
    };
    
    TPresentationManager.prototype.GetTitle = function(number){
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0 && number < this.titles.length)
        {
            return this.titles[number];
        }
        return null;
    };

    TPresentationManager.prototype.FindTitle = function(_id){
        if (typeof _id !== 'undefined' && _id !== null)
        {
            var i;
            for (i = 0;i < this.titles.length;i++)
            {
                if (_id === this.titles[i].GetId())
                    return this.titles[i];
            }
        }
        return null;
    };
    
    TPresentationManager.prototype.SetPlanTitle = function(_title){
        if (typeof _title !== 'undefined' && _title !== null && _title.IsType('TPageElementPresentationTitle'))
        {
            this.titlePlanPresentation = _title;
            this.titlePlanPresentation.SetLevel(-1);
            if (typeof this.section !== 'undefined' && this.section !== null)
            {
                var i,j,n,obj,YN;
                for (i = 0;i < this.section.length;i++)
                    if (typeof this.section[i] !== 'undefined' && this.section[i] !== null && this.section[i].IsType('TPresentationTableOfContents'))
                    {
                        n = this.section[i].GetNumberOfSlideElements();
                        YN = true;
                        for (j=0;j < n;j++)
                        {
                            obj = this.section[i].GetSlideElement(j);
                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElementPresentationTitle'))
                            {
                                if (obj.GetLevel() === -1)
                                {
                                    YN = false;
                                    break;
                                }
                            }
                        }
                        if (YN)
                            this.section[i].AddSlideElement(_title);
                        else
                            this.section[i].AddSlideElement(this.SetSlideElement,i);
                    }
            }
        }else
            this.titlePlanPresentation = null;
    };
    
    TPresentationManager.prototype.LinkClick = function(event){
        if (typeof event !== 'undefined' && event !== null && typeof event.currentTarget !== 'undefined' && event.currentTarget !== null)
        {
            if (typeof event.currentTarget.className !== 'undefined' && event.currentTarget.className !== null)
            {
                var className = event.currentTarget.className;
                var tmp = className.substring(5,className.length);
                event.currentTarget.thisObject.GoSlideId(tmp);
//                event.currentTarget.thisObject.SetVisibleSection();
//                var fun = event.currentTarget.thisObject.GetFun();
//                if (fun !== null)
//                    fun();
            }
        }
    };
    
    TPresentationManager.prototype.GoSlideId = function(_id){
        this.ResetTimeOutPointer();
        if (typeof _id !== 'undefined' && _id !== null) 
        {
            var i = 0,j,YN = false,obj,n;
            for (i = 0;i < this.section.length;i++)
                if (this.section[i] !== null)
                {
                    if (typeof this.section[i] !== 'undefined' && this.section[i] !== null && this.section[i].IsType('TPresentationSlide'))
                    {
                        if (_id === this.section[i].GetId())
                        {
                            YN = true;
                            break;
                        }
                        n = this.section[i].GetNumberOfSlideElements();
                        for (j=0;j < n;j++)
                        {
                            obj = this.section[i].GetSlideElement(j);
                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElementPresentationTitle'))
                            {
                                if (_id === obj.GetId())
                                {
                                    YN = true;
                                    break;
                                }
                            }
                        }
                        if (YN)
                            break;
                    }
                }
            
//            if (this.actualSection + i - 1 < this.section.length)
            if (i < this.section.length)
            {
//                this.actualSection = this.actualSection + i - 1;
                this.actualSection = i;
                this.Draw('THTMLObject');
                if (this.eventChangeSlide !== null)
                {
                    RemoveAllTimeOut();
                    this.eventChangeSlide(this.actualSection);
                }
            }
        }
    };

    TPresentationManager.prototype.GoSlideNumber = function(_number,draw){
        this.ResetTimeOutPointer();
        if (typeof _number !== 'undefined' && _number !== null && IsInt(_number)) 
        {
//            if (_number >= 0 && _number < this.section.length)
            {
                if (typeof draw !== 'undefined' && draw !== null) 
                    draw = true;
                this.actualSection = _number;
                if (draw)
                    this.Draw('THTMLObject');
                if (this.eventChangeSlide !== null)
                {
                    RemoveAllTimeOut();
                    this.eventChangeSlide(this.actualSection);
                }
            }
        }
    };

    TPresentationManager.prototype.SetScreenWidth = function(width){
        if (typeof width !== 'undefined' && width !== null && IsInt(width))
        {
            this.screenWidth = width;
        }
    };

    TPresentationManager.prototype.SetScreenHeight = function(height){
        if (typeof height !== 'undefined' && height !== null && IsInt(height))
        {
            this.screenHeight = height;
        }
    };

    TPresentationManager.prototype.GetSlideNumber = function(){
        return this.actualSection;
    };

    TPresentationManager.prototype.SetEventChangeSlide = function(fun){
        if (typeof fun !== 'undefined' && fun !== null)
        {
            this.eventChangeSlide = fun;
            return;
        }
        this.eventChangeSlide = null;
    };

    TPresentationManager.prototype.SetNoteSize = function(size){
        if (typeof size !== 'undefined' && size !== null)
        {
            this.noteSize = size;
            return;
        }
        this.noteSize = null;
    };

    TPresentationManager.prototype.SetNumberNote = function(_number){
        if (typeof _number !== 'undefined' && _number !== null)
        {
            var i;
            for (i = 0;i < this.section.length;i++)
            {
                if (typeof this.section[i] !== 'undefined' && this.section[i] !== null)
                {
                    if (this.section[i].IsType('TPagePresentation'))
                    {
                        this.section[i].SetNumberNote(_number);
                    }
                }
            }
        }
    };

    TPresentationManager.prototype.NextNote = function(){
        var i;
        for (i = 0;i < this.section.length;i++)
        {
            if (this.section[i] !== null)
            {
                if (this.section[i].IsType('TPagePresentation'))
                {
                    this.section[i].NextNote();
                }
            }
        }
    };

    TPresentationManager.prototype.PrevNote = function(){
        var i;
        for (i = 0;i < this.section.length;i++)
        {
            if (this.section[i] !== null)
            {
                if (this.section[i].IsType('TPagePresentation'))
                {
                    this.section[i].PrevNote();
                }
            }
        }
    };

    TPresentationManager.prototype.SetImageCatalog = function(catalog){
        if (typeof catalog !== 'undefined' && catalog !== null)
        {
            this.imageCatalog = new String(catalog);
            this.imageCatalog = this.imageCatalog.toString();
            _SlideImageCatalog = this.imageCatalog;
        }
        if (catalog === null)
        {
            this.imageCatalog = null;
            _SlideImageCatalog = '';
        }
    };

    TPresentationManager.prototype.GetImageCatalog = function(){
        if (this.imageCatalog === null)
            return null;
        var tmp = new String(this.imageCatalog);
        return tmp.toString();
    };

    TPresentationManager.prototype.SetFunTimeOutSlide = function(fun){
        if (typeof fun !== 'undefined' && fun !== null)
        {
            this.funTimeOutSlide = fun;
        }
        if (fun === null)
            this.funTimeOutSlide = null;
    };

    TPresentationManager.prototype.GetSlideId = function(number){

        if (typeof number === 'undefined' || number === null)
            number = this.actualSection;
        if (typeof number !== 'undefined' && number !== null && IsInt(number) && number >= 0 &&  number < this.section.length)
        {
            return  this.section[number].GetId();
        }
        
        return null;
        
    };

    TPresentationManager.prototype.GetTeXScene = function(){
        return this.sceneTeX;
    };

    TPresentationManager.prototype.CalculateValue = function(value_){
        if (this.variables !== null)
            return this.variables.CalculateValue(value_);
        return null;
    };

    TPresentationManager.prototype.FindVariable = function(name_){
        if (this.variables !== null)
            return this.variables.FindVariable(name_);
        return null;
    };


    TPresentationManager.prototype.SetVariable = function(var_,name_){
        if (this.variables !== null)
            this.variables.SetVariable(var_,name_);
    };

    TPresentationManager.prototype.SetVariables = function(var_){
        if (this.variables !== null)
            this.variables.SetVariables(var_);
    };

    TPresentationManager.prototype.GetVariables = function(){
        if (this.variables !== null)
            return this.variables.GetVariables();
        return null;
    };


}

TPresentationManager.prototype = new TObjectMultilanguage();

function TGenerateObject2(){
    
    var type = 'TGenerateObject2';
    TGenerateObject2.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.txt = '';
        this.dataName = [];
        this.data = [];
        this.dataParameter = [];        
        this.slideYN = false;
        this.typeObject = null;
        this.noteNumber = 0;
    };
    this.InitConstructor();

    TGenerateObject2.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };

    TGenerateObject2.prototype.Init = function(_object){
        TObject.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject2'))
        {
            var i,j;
            if (typeof _object.txt !== 'undefined' && _object.txt !== null)
            {
                this.txt = new String(_object.txt);
                this.txt = this.txt.toString();
            }
            if (typeof _object.typeObject !== 'undefined' && _object.typeObject !== null)
            {
                this.typeObject = new String(_object.typeObject);
                this.typeObject = this.typeObject.toString();
            }
            if (typeof _object.dataName !== 'undefined' && _object.dataName !== null)
            {
                this.dataName = [];
                for (i = 0;i < _object.dataName.length;i++)
                {
                    this.dataName[i] = new String(_object.dataName[i]);
                    this.dataName[i] = this.dataName[i].toString();
                }
            }
            if (typeof _object.data !== 'undefined' && _object.data !== null)
            {
                this.data = [];
                for (i = 0;i < _object.data.length;i++)
                {
                    if (typeof _object.data[i] !== 'undefined' && _object.data[i] !== null)
                    {
                        this.data[i] = [];
                        for (j = 0;j < _object.data[i].length;j++)
                        {
                            this.data[i][j] = new String(_object.data[i][j]);
                            this.data[i][j] = this.data[i][j].toString();
                        }
                    }
                }
            }
            if (typeof _object.dataParameter !== 'undefined' && _object.dataParameter !== null)
            {
                this.dataParameter = [];
                for (i = 0;i < _object.dataParameter.length;i++)
                {
                    if (typeof _object.dataParameter[i] !== 'undefined' && _object.dataParameter[i] !== null)
                    {
                        this.dataParameter[i] = [];
                        for (j = 0;j < _object.dataParameter[i].length;j++)
                            this.dataParameter[i][j] = _object.dataParameter[i][j];
                    }
                }
            }
            if (typeof _object.slideYN !== 'undefined' && _object.slideYN !== null)
                this.slideYN = _object.slideYN;
            if (typeof _object.noteNumber !== 'undefined' && _object.noteNumber !== null && IsInt(_object.noteNumber))
                this.noteNumber = _object.noteNumber;
        }
    };

    TGenerateObject2.prototype.Find = function(text,_number){
        if (typeof text !== 'undefined' && text !== null && typeof this.dataName !== 'undefined' && this.dataName !== null)
        {
            var i,j,n = 0;
            if (typeof _number !== 'undefined' && _number !== null && IsInt(_number))
                n = _number;
            for (i = 0,j = 0;i < this.dataName.length;i++)
            {
                if (text === this.dataName[i])
                {
                    if (j >= n)
                        return i;
                    j++;
                }
            }
        }
        return null;
    };

    TGenerateObject2.prototype.Add = function(type,text,parameter){
        if (typeof this.dataName !== 'undefined' && this.dataName !== null &&typeof type !== 'undefined' && type !== null && typeof text !== 'undefined' && text !== null)
        {
            var number;
            if (this.dataName.length > 0 && this.dataName[this.dataName.length - 1] === type)
                number = this.dataName.length - 1;
            else
            {
                number = this.dataName.length;
                this.dataName[number] = type;
                this.data[number] = [];
                this.dataParameter[number] = [];
            }
            
            this.data[number][this.data[number].length] = text;
            if (typeof parameter !== 'undefined' && parameter !== null)
                this.dataParameter[number][this.dataParameter[number].length] = parameter;
            else
                this.dataParameter[number][this.dataParameter[number].length] = null;
        }
    };

    TGenerateObject2.prototype.GetTXT = function(){
        return '';
    };

    TGenerateObject2.prototype.SetSlide = function(YN) {
        if (typeof YN !== 'undefined' && YN !== null)
            this.slideYN = YN;
    };

    TGenerateObject2.prototype.GetSlide = function() {
        return this.slideYN;
    };

    TGenerateObject2.prototype.SetObjectType = function(_type) {
        if (typeof _type !== 'undefined' && _type !== null)
        {
            this.typeObject = new String(_type);
            this.typeObject = this.typeObject.toString();
        }
        if (_type === null)
            this.typeObject = null;
    };

    TGenerateObject2.prototype.GetObjectType = function() {
        var tmp = new String(this.typeObject);
        if (tmp !== null)
            return tmp.toString();
    };

    TGenerateObject2.prototype.SetNumberNote = function(number) {
        if (typeof number !== 'undefined' && number !== null && IsInt(number))
        {
            this.noteNumber = number;
        }
    };

    TGenerateObject2.prototype.GetNumberNote = function() {
        return this.noteNumber;
    };

    TGenerateHTML.prototype.SetThisObject = function(){
    };

};

TGenerateObject2.prototype = new TObject();


function TGenerateHTML(){
    
    var type = 'TGenerateHTML';
    TGenerateHTML.prototype.InitConstructor = function(){
        TGenerateObject2.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.numberOfAuthors = 0;
//        this.tmpctx = null;
        this.SetObjectType('HTML');
    };
    this.InitConstructor();

    TGenerateHTML.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TGenerateObject2.prototype.IsType.call(this,_type);
    };

    TGenerateHTML.prototype.Init = function(_object){
        TGenerateObject2.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();        
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('THTMLTitlePageObject'))
        {
//            if (typeof _object.tmpctx !== 'undefined' && _object.tmpctx !== null && _object.tmpctx.IsType('TDrawContext'))
//                this.tmpctx = objM.copy(_object.tmpctx);
        }
    };

    TGenerateHTML.prototype.GetTXT = function(){
        var txt = '';

        if (this.GetSlide())
        {
            var number = this.Find('BackgroundImage');
            var numberCatalog = this.Find('ImageCatalog');
            var note = this.Find('NoteSize'),noteSize,slideSize,w_,h_,tmpX_,fontSize_;
            var fontSize = 16;
            if (number !== null && typeof this.data[number] !== 'undefined' && this.data[number] !== null && this.data[number].length > 0 && typeof this.data[number][0] !== 'undefined' && this.data[number][0] !== null)
            {
                if (typeof this.dataParameter[number] !== 'undefined' && this.dataParameter[number] !== null && this.dataParameter[number].length > 0)
                    if (typeof this.dataParameter[number][0] !== 'undefined' && this.dataParameter[number][0] !== null && this.dataParameter[number][0].length > 1)
                        if (typeof this.dataParameter[number][0][0] !== 'undefined' && this.dataParameter[number][0][0] !== null && this.dataParameter[number][0][0] > 0 && typeof this.dataParameter[number][0][1] !== 'undefined' && this.dataParameter[number][0][1] !== null)
                        {
/*                            var tmp,scale = this.dataParameter[number][0][1]/this.dataParameter[number][0][3];
                            var w = this.dataParameter[number][0][2]*scale;
                            if (this.dataParameter[number][0][0] <= w)
                                tmp = 0;
                            else
                            {
                                tmp = (this.dataParameter[number][0][0] - w)/2;
                                tmp = 100*tmp/this.dataParameter[number][0][0];
                            }
                            w = 100*w/this.dataParameter[number][0][0];
                            txt = txt + '<img src="' + this.data[number][0] + '" alt="" style="position: absolute;left: '+ tmp + '%;top:0;width:' + w + '%;height:100%">';*/

                            var tmpX,tmpY,scale,w,h;
                            var aspect1 = this.dataParameter[number][0][0]/this.dataParameter[number][0][1];
                            var aspect2 = this.dataParameter[number][0][2]/this.dataParameter[number][0][3];
                            if (aspect1 <= aspect2)
                            {
                                scale = this.dataParameter[number][0][0]/this.dataParameter[number][0][2];
                                w = this.dataParameter[number][0][2]*scale;
                                h = this.dataParameter[number][0][3]*scale;
                                tmpX = 0;
                                tmpY = (this.dataParameter[number][0][1] - h)/2;
                                tmpY = 100*tmpY/this.dataParameter[number][0][1];
                                w = 100*w/this.dataParameter[number][0][0];
                                h = 100*h/this.dataParameter[number][0][1];
                            }else
                            {
                                scale = this.dataParameter[number][0][1]/this.dataParameter[number][0][3];
                                w = this.dataParameter[number][0][2]*scale;
                                h = this.dataParameter[number][0][3]*scale;
                                tmpY = 0;
                                tmpX = (this.dataParameter[number][0][0] - w)/2;
                                tmpX = 100*tmpX/this.dataParameter[number][0][0];
                                w = 100*w/this.dataParameter[number][0][0];
                                h = 100*h/this.dataParameter[number][0][1];
                            }
                            fontSize = scale*(this.dataParameter[number][0][3]/75);
                            
                            w_ = w;h_ = h;tmpX_ = tmpX;fontSize_ = fontSize;
                            if (note !== null)
                            {
                                noteSize = this.data[note][0];
                                slideSize = 100-noteSize;
                                if (typeof noteSize !== 'undefined' && noteSize !== null && IsInt(noteSize))
                                {
                                    if (tmpX === 0)
                                        tmpX = (100 - w*slideSize/100)/2;
                                    else
                                        tmpX = tmpX + (w - w*slideSize/100)/2;
                                    w = w*slideSize/100;
                                    h = h*slideSize/100;
                                    fontSize = fontSize*slideSize/100;
                                }
                            }
                            
                            txt = txt + '<img src="' + this.data[numberCatalog][0] + '/' + this.data[number][0] + '" alt="" style="position: absolute;left: '+ tmpX + '%;top:'+ tmpY  + '%;width:' + w + '%;height:' + h + '%">';

                            if (note !== null)
                            {
                                var tmp = h_ - h,tmp2 = tmpY + h;
                                txt = txt + '<SlideNotePosition style="position: absolute;left:' + tmpX_ + '%;top:'+ tmp2  + '%;width:' + w_ + '%;height:' + tmp + '%;font-size: '+ fontSize_ + 'px;">';
//                                this.SetNumberNote(0);
                                txt = txt + this.GetTXT2();
                                txt = txt + '</SlideNotePosition>';
                            }

                        }
            }  
            txt = txt + '<TGenerateHTMLSlidePosition style="position: absolute;left:' + tmpX + '%;top:'+ tmpY  + '%;width:' + w + '%;height:' + h + '%;font-size: '+fontSize + 'px;">';
            var tmp = this.GetNumberNote();
            this.SetNumberNote(-1);
            txt = txt + this.GetTXT2();
            this.SetNumberNote(tmp);
            txt = txt + '</TGenerateHTMLSlidePosition>';
        }else
            txt = txt + this.GetTXT2();
        return txt;
    };

    TGenerateHTML.prototype.GetTXT2 = function(){  
    };


    TGenerateHTML.prototype.SetThisObject = function(){
        if (typeof this.data !== 'undefined' && this.data !== null)
        {
            var id,obj,obj_;
            for (i = 0;i < this.data.length;i++)
            {
                for (j = 0;j < this.data[i].length;j++)
                {
                    id = null;
                    obj_ = null;
                    if (this.dataName[i] === 'Button')
                    {
                        id = this.data[i][j];
                        if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null)
                            obj_ = this.dataParameter[i][j][5];
                    }
                    if (this.dataName[i] === 'Slider')
                    {
                        id = this.data[i][j];
                        if (this.dataParameter[i][j].length > 7 && typeof this.dataParameter[i][j][7] !== 'undefined' && this.dataParameter[i][j][7] !== null)
                            obj_ = this.dataParameter[i][j][7];
                    }
                    
                    if (id !== null && typeof obj_ !== 'undefined' && obj_ !== null)
                    {
                        obj = document.getElementById(id);
                        if (typeof obj !== 'undefined' && obj !== null)
                        {
                            obj.thisObject = obj_;
                        }
                    }
                }
            }
        }
    };

    TGenerateHTML.prototype.DrawFigure = function(ctx){
        var number,i,j,k,id,tabObj,obj,canvas,ctx_,matrix,matrix2;
        var objM = this.GetObjectManager(),scaleX,scaleY,scaleZ,txt,tmp_;
        if (typeof ctx === 'undefined' || ctx === null)
            ctx = this.tmpctx;
        if (objM !== null && typeof ctx !== 'undefined' && ctx !== null)
        {
            var numberResizeToObject = this.Find('ResizeToObject'),obj2,widthResizeToObject = 0,aspect;
            var numberResizeToFontObject = this.Find('ResizeToFontObject');
            var numberCatalog = this.Find('ImageCatalog')
            for (i = 0;;i++)
            {
                number = this.Find('ParagraphText',i);
                if (number === null)
                    break;
                for (j = 0;j < this.data[number].length;j++)
                {
                    if (typeof this.data[number][j] !== 'undefined' && this.data[number][j] !== null)
                    {
                        tmp_ = document.getElementById(this.data[number][j]);
                        if (typeof tmp_ !== 'undefined' && tmp_ !== null)
                        {
                            if (this.dataParameter[number][j].length > 5 && typeof this.dataParameter[number][j][5] !== 'undefined' && this.dataParameter[number][j][5] !== null)
                                tmp_.thisObject = this.dataParameter[number][j][5];
                        }
                    }
                }
            }
            for (i = 0;;i++)
            {
                number = this.Find('ParagraphImage',i);
                if (number === null)
                    break;
                for (j = 0;j < this.data[number].length;j++)
                {
                    if (typeof this.data[number][j] !== 'undefined' && this.data[number][j] !== null)
                    {
                        tmp_ = document.getElementById(this.data[number][j]);
                        if (typeof tmp_ !== 'undefined' && tmp_ !== null)
                        {
                            if (this.dataParameter[number][j].length > 5 && typeof this.dataParameter[number][j][5] !== 'undefined' && this.dataParameter[number][j][5] !== null)
                                tmp_.thisObject = this.dataParameter[number][j][5];
                        }
                    }
                }
            }
            for (i = 0;;i++)
            {
                number = this.Find('Edit',i);
                if (number === null)
                    break;
                for (j = 0;j < this.data[number].length;j++)
                {
                    if (typeof this.data[number][j] !== 'undefined' && this.data[number][j] !== null)
                    {
                        tmp_ = document.getElementById(this.data[number][j]);
                        if (typeof tmp_ !== 'undefined' && tmp_ !== null)
                        {
                            if (this.dataParameter[number][j].length > 9 && typeof this.dataParameter[number][j][9] !== 'undefined' && this.dataParameter[number][j][9] !== null)
                                tmp_.thisObject = this.dataParameter[number][j][9];
                        }
                    }
                }
            }
            for (i = 0;;i++)
            {
                number = this.Find('TextArea',i);
                if (number === null)
                    break;
                for (j = 0;j < this.data[number].length;j++)
                {
                    if (typeof this.data[number][j] !== 'undefined' && this.data[number][j] !== null)
                    {
                        tmp_ = document.getElementById(this.data[number][j]);
                        if (typeof tmp_ !== 'undefined' && tmp_ !== null)
                        {
                            if (this.dataParameter[number][j].length > 9 && typeof this.dataParameter[number][j][9] !== 'undefined' && this.dataParameter[number][j][9] !== null)
                                tmp_.thisObject = this.dataParameter[number][j][9];
                        }
                    }
                }
            }
            for (i = 0;;i++)
            {
                number = this.Find('RadioButton',i);
                if (number === null)
                    break;
                for (j = 0;j < this.data[number].length;j++)
                {
                    if (typeof this.data[number][j] !== 'undefined' && this.data[number][j] !== null)
                    {
                        tmp_ = document.getElementById(this.data[number][j]);
                        if (typeof tmp_ !== 'undefined' && tmp_ !== null)
                        {
                            if (this.dataParameter[number][j].length > 6 && typeof this.dataParameter[number][j][6] !== 'undefined' && this.dataParameter[number][j][6] !== null)
                                tmp_.thisObject = this.dataParameter[number][j][6];
                        }
                    }
                }
            }
            for (i = 0;;i++)
            {
                number = this.Find('CheckBox',i);
                if (number === null)
                    break;
                for (j = 0;j < this.data[number].length;j++)
                {
                    if (typeof this.data[number][j] !== 'undefined' && this.data[number][j] !== null)
                    {
                        tmp_ = document.getElementById(this.data[number][j]);
                        if (typeof tmp_ !== 'undefined' && tmp_ !== null)
                        {
                            if (this.dataParameter[number][j].length > 6 && typeof this.dataParameter[number][j][6] !== 'undefined' && this.dataParameter[number][j][6] !== null)
                                tmp_.thisObject = this.dataParameter[number][j][6];
                        }
                    }
                }
            }
            for (i = 0;;i++)
            {
                number = this.Find('InteractiveImageBitmap',i);
                if (number === null)
                    break;
                for (j = 0;j < this.data[number].length;j++)
                {
                    if (typeof this.data[number][j] !== 'undefined' && this.data[number][j] !== null)
                    {
                        if (this.dataParameter[number][j].length > 2 && typeof this.dataParameter[number][j][2] !== 'undefined' && this.dataParameter[number][j][2] !== null)
                        {
                            tmp_ = document.getElementById(this.dataParameter[number][j][2]);
                            if (typeof tmp_ !== 'undefined' && tmp_ !== null)
                            {
                                if (this.dataParameter[number][j].length > 9 && typeof this.dataParameter[number][j][9] !== 'undefined' && this.dataParameter[number][j][9] !== null)
                                {
                                    tmp_.thisObject = this.dataParameter[number][j][9];
                                    if (numberCatalog !== null)
                                        tmp_.imageCatalog = this.data[numberCatalog][0];
                                }
                            }
                        }
                    }
                }
            }
            for (i = 0;;i++)
            {
                number = this.Find('Generate',i);
                if (number === null)
                    break;
                
                
                if (typeof this.data[number] !== 'undefined' && this.data[number] !== null && this.data[number].length > 0)
                {
                    for (j = 0;j < this.data[number].length;j++)
                    {
                        if (this.dataParameter[number][j].length > 9 && typeof this.dataParameter[number][j][9] !== 'undefined' && this.dataParameter[number][j][9] !== null &&  this.dataParameter[number][j][9] === 'svg')
                        {
                            if (ctx.IsType('TDrawSvgContext'))
                            {
                                if (this.dataParameter[number][j].length > 2 && typeof this.dataParameter[number][j][2] !== 'undefined' && this.dataParameter[number][j][2] !== null)
                                {
                                    tabObj = this.dataParameter[number][j][2];
                                    if (typeof tabObj !== 'undefined' && tabObj !== null)
                                    {
                                        ctx = objM.newObject('TDrawSvgContext');
                                        id = this.data[number][j];
                                        if (typeof id !== 'undefined' && id !== null)
                                        {
                                            if (numberResizeToObject !== null)
                                            {
                                                obj2 = document.getElementsByTagName(this.data[numberResizeToObject]);
                                                if (typeof obj2 !== 'undefined' && obj2 !== null && obj2.length > 0)
                                                    if (typeof obj2[0] !== 'undefined' && obj2[0] !== null)
                                                    {
                                                        if (IsNumeric(obj2[0].clientWidth))
                                                            widthResizeToObject = this.dataParameter[number][0][11]*obj2[0].clientWidth;
                                                    }
                                            }
                                            if (numberResizeToFontObject !== null)
                                            {
                                                obj2 = document.getElementsByTagName(this.data[numberResizeToFontObject]);
                                                if (typeof obj2 !== 'undefined' && obj2 !== null && obj2.length > 0)
                                                    if (typeof obj2[0] !== 'undefined' && obj2[0] !== null)
                                                        ctx.SetNormalFontSize($( obj2[0] ).css( "font-size" ));
                                            }
                                            if (widthResizeToObject > 0)
                                            {

                                                aspect = this.dataParameter[number][j][1]/this.dataParameter[number][j][0];
                                                scaleX = widthResizeToObject/this.dataParameter[number][j][3];
                                                scaleY = -widthResizeToObject*aspect/this.dataParameter[number][j][4];
                                            }else
                                            {
                                                scaleX = this.dataParameter[number][j][0]/this.dataParameter[number][j][3];
                                                scaleY = -this.dataParameter[number][j][1]/this.dataParameter[number][j][4];
                                            }
                                            matrix = objM.newObject('TMatrixTransformation3D');
                                            matrix2 = objM.newObject('TMatrixTransformation3D');
//                                            matrix.SetScaleMatrix3D();
//                                            scaleX = this.dataParameter[number][j][0]/this.dataParameter[number][j][3];
//                                            scaleY = -this.dataParameter[number][j][1]/this.dataParameter[number][j][4];
                                            scaleZ = this.dataParameter[number][j][5];
                                            matrix.SetScaleMatrix3D(scaleX,scaleY,scaleZ);
                                            matrix2.SetTranslationMatrix(-this.dataParameter[number][j][6],-this.dataParameter[number][j][7]-this.dataParameter[number][j][4],this.dataParameter[number][j][8]);
                                            matrix.MatrixMultiplication(matrix2);
                                            ctx.SetTransformation(matrix);
                                            for (k = 0;k < tabObj.length;k++)
                                            {
                                                obj = tabObj[k];
                                                if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                                {
                                                    obj.DrawFigure(ctx);
                                                }
                                            }
                                            txt = '<svg';
                                            if (widthResizeToObject > 0)
                                            {
                                                txt = txt + ' width="'+ widthResizeToObject + '" height="' + aspect*widthResizeToObject + '" ';
                                            }else
                                                if (typeof this.dataParameter[number][j] !== 'undefined' && this.dataParameter[number][j] !== null && this.dataParameter[number][j].length > 1)
                                                {
                                                    txt = txt + ' width="'+ this.dataParameter[number][j][0] + '" height="' + this.dataParameter[number][j][1] + '" ';
                                                }
                                            txt = txt + '>';
                                            txt = txt + ctx.GetContext();
                                            txt = txt + '</svg>';
                                            if ($('#' + this.data[number][j]).length > 0)
                                            {
                                                $('#' + this.data[number][j]).empty();
                                                $('#' + this.data[number][j]).append(txt);
                                            }
                                            if ($('#Slide' + this.data[number][j]).length > 0)
                                            {
                                                $('#Slide' + this.data[number][j]).empty();
                                                $('#Slide' + this.data[number][j]).append(txt);
                                            }
//                                            txt = txt + ctx.GetContext();
                                        }
                                    }


                                    //                                    if (this.dataParameter[i][j])
                                }
                            }
                            
                        }else
                        {
                            if (ctx.IsType('TDrawCanvasContext'))
                            {
                                id = this.data[number][j];
                                if (typeof id !== 'undefined' && id !== null)
                                {
                                    if (numberResizeToObject !== null)
                                    {
                                        obj2 = document.getElementsByTagName(this.data[numberResizeToObject]);
                                        if (typeof obj2 !== 'undefined' && obj2 !== null && obj2.length > 0)
                                            if (typeof obj2[0] !== 'undefined' && obj2[0] !== null)
                                            {
                                                if (IsNumeric(obj2[0].clientWidth))
                                                    widthResizeToObject = this.dataParameter[number][0][11]*obj2[0].clientWidth;
//                                                ctx.SetNormalFontSize($( obj2[0] ).css( "font-size" ));
                                            }
                                    }
                                    if (numberResizeToFontObject !== null)
                                    {
                                        obj2 = document.getElementsByTagName(this.data[numberResizeToFontObject]);
                                        if (typeof obj2 !== 'undefined' && obj2 !== null && obj2.length > 0)
                                            if (typeof obj2[0] !== 'undefined' && obj2[0] !== null)
                                                ctx.SetNormalFontSize($( obj2[0] ).css( "font-size" ));
                                    }
/*                                    if (numberResizeToFontObject !== null)
                                    {
                                        obj2 = document.getElementsByTagName(this.data[numberResizeToFontObject]);
                                        if (typeof obj2 !== 'undefined' && obj2 !== null && obj2.length > 0)
                                            if (typeof obj2[0] !== 'undefined' && obj2[0] !== null)
                                            {
                                                if (IsNumeric(obj2[0].clientWidth))
                                                    widthResizeToObject = this.dataParameter[number][0][11]*obj2[0].clientWidth;
                                                ctx.SetNormalFontSize($( obj2[0] ).css( "font-size" ));
                                            }
                                    }*/

                                    matrix = objM.newObject('TMatrixTransformation3D');
                                    matrix2 = objM.newObject('TMatrixTransformation3D');
        //                            matrix.SetScaleMatrix3D();
                                    if (widthResizeToObject > 0)
                                    {

                                        aspect = this.dataParameter[number][j][1]/this.dataParameter[number][j][0];
                                        scaleX = widthResizeToObject/this.dataParameter[number][j][3];
                                        scaleY = -widthResizeToObject*aspect/this.dataParameter[number][j][4];
                                    }else
                                    {
                                        scaleX = this.dataParameter[number][j][0]/this.dataParameter[number][j][3];
                                        scaleY = -this.dataParameter[number][j][1]/this.dataParameter[number][j][4];
                                    }
                                    scaleZ = this.dataParameter[number][j][5];
                                    matrix.SetScaleMatrix3D(scaleX,scaleY,scaleZ);
        //                            matrix2.SetTranslationMatrix(this.dataParameter[number][j][6],this.dataParameter[number][j][7],this.dataParameter[number][j][8]);
                                    matrix2.SetTranslationMatrix(-this.dataParameter[number][j][6],-this.dataParameter[number][j][7]-this.dataParameter[number][j][4],this.dataParameter[number][j][8]);
        //                var matrix2 = objM.newObject('TMatrixTransformation2D');
        //                var matrix3 = objM.newObject('TMatrixTransformation2D');
        //                matrix.SetTranslationMatrix(this.width/2,this.height/2);
        //                matrix2.SetScaleMatrix(this.scale);
        //                matrix3.SetTranslationMatrix(this.x,this.y);
                                    matrix.MatrixMultiplication(matrix2);
        //                matrix.MatrixMultiplication(matrix3);
                                    ctx.SetTransformation(matrix);

                                    tabObj = this.dataParameter[number][j][2];
                                    if (typeof tabObj !== 'undefined' && tabObj !== null)
                                    {
                                        canvas = document.getElementById(id);
                                        if (typeof canvas === 'undefined' || canvas === null)
                                            canvas = document.getElementById('slide' + id);
                                        if (typeof canvas !== 'undefined' && canvas !== null)
                                        {
                                            if (widthResizeToObject > 0)
                                            {
                                                canvas.width = widthResizeToObject;
                                                canvas.height  = aspect*widthResizeToObject;
                                            }

            //                                canvas.transform(1,0,0,-1,0,canvas.height);
                                            ctx_ = canvas.getContext('2d');
                                            ctx.SetContext(ctx_);
//                                            this.tmpctx = objM.copy(ctx);
                                            for (k = 0;k < tabObj.length;k++)
                                            {
                                                obj = tabObj[k];
                                                if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                                {
//                                                    if (obj.IsType('TDrawImage_'))
//                                                    {
//                                                        obj.SetDrawObject(this);
//                                                    }
                                                    obj.DrawFigure(ctx);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    };

    TGenerateHTML.prototype.DrawThreeFigure = function(scene){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof scene !== 'undefined' && scene !== null && scene.IsType('TThreeScene'))
        {
            var i,number,j,id,renderer,tabObj,k,obj,tmp_,action;
            for (i = 0;;i++)
            {
                number = this.Find('GenerateThree',i);
                if (number === null)
                    break;
                if (typeof this.data[number] !== 'undefined' && this.data[number] !== null && this.data[number].length > 0)
                {
//                    a = this.dataParameter[number]
                    if (this.dataParameter[number].length > 0 && typeof this.dataParameter[number] !== 'undefined')
                    {
                        for (j = 0;j < this.data[number].length;j++)
                        {
                            if (this.dataParameter[number][j].length > 0 && typeof this.dataParameter[number][j] !== 'undefined' && IsNumeric(this.dataParameter[number][j][0]) !== null && IsNumeric(this.dataParameter[number][j][1]) !== null)
                            {
                                id = this.data[number][j];
                                if (typeof id !== 'undefined' && id !== null)
                                {
                                    if (this.dataParameter[number][j].length > 23 && this.dataParameter[number][j][23] !== null && this.dataParameter[number][j][23] === 'canvas')
                                    {
                                        renderer = new THREE.CanvasRenderer(); 
                                    }else
                                    {
                                        if(Detector.webgl){ 
                                            renderer = new THREE.WebGLRenderer({antialias:true}); 
//                                        rendererCSS = new THREE.CSS3DRenderer({antialias:true});
//    rendererCSS.domElement.style.position = 'relative';
//    rendererCSS.domElement.style.top = 0;
    
                                        }else
                                        {
                                            renderer = new THREE.CanvasRenderer(); 
    //                                        rendererCSS = null;
                                        }
                                    }
                                    if (renderer !== null)
                                    {
/*                                        if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 16)
                                        {
                                            var tmp = this.dataParameter[i][j][16];
                                            if (typeof tmp !== 'undefined' && tmp !== null && tmp.length > 0)
                                            {
                                                for (k = 0;k < tmp.length;k++)
                                                {
                                                    if (tmp.length > k && typeof tmp[k] !== 'undefined' && tmp[k] !== null && tmp[k].IsType('TActionThree'))
                                                    {
                                                        
                                                    }
                                                }
                                                
                                            }
                                        }*/
                                        
                                            
                                        
                                        if (this.dataParameter[number][j].length > 10 && this.dataParameter[number][j][10] !== null && this.dataParameter[number][j][10].IsType('TColourRGBA'))
                                        {
                                            var tmp = this.dataParameter[number][j][10].Get24bitColour();
                                            renderer.setClearColor(tmp, this.dataParameter[number][j][10].GetColourA());                                             
//                                            rendererCSS.setClearColor(tmp, this.dataParameter[number][j][10].GetColourA());                                             
                                        }else
                                        {
                                            renderer.setClearColor(0x000000, 1);
//                                            rendererCSS.setClearColor(0x000000, 1);
                                        }
                                        renderer.setSize(this.dataParameter[number][j][0], this.dataParameter[number][j][1]);
//                                        rendererCSS.setSize(this.dataParameter[number][j][0], this.dataParameter[number][j][1]);
    //                                    renderer.setSize(100, 100);
                                        document.getElementById(id).appendChild(renderer.domElement); 
//                                        document.getElementById(id).appendChild(rendererCSS.domElement); 

                                        var scene_ = new THREE.Scene();
//                                        var sceneCSS_ = new THREE.Scene();
                                        scene.SetScene(scene_);
//                                        scene.SetSceneCSS(sceneCSS_);
                                        var angle = 45;
                                        var near = 1;
                                        var far = 100;
                                        var alpha = 0,beta = 0;
                                        var distance = 1;
                                        var typeCam = 'orthographic';
                                        if (this.dataParameter[number][j].length > 13 && this.dataParameter[number][j][13] !== null && IsNumeric(this.dataParameter[number][j][13]))
                                            angle = this.dataParameter[number][j][13];
                                        if (this.dataParameter[number][j].length > 14 && this.dataParameter[number][j][14] !== null && IsNumeric(this.dataParameter[number][j][14]))
                                            near = this.dataParameter[number][j][14];
                                        if (this.dataParameter[number][j].length > 15 && this.dataParameter[number][j][15] !== null && IsNumeric(this.dataParameter[number][j][15]))
                                            far = this.dataParameter[number][j][15];
                                        if (this.dataParameter[number][j].length > 20 && this.dataParameter[number][j][20] !== null && IsNumeric(this.dataParameter[number][j][20]))
                                            alpha = this.dataParameter[number][j][20];
                                        if (this.dataParameter[number][j].length > 21 && this.dataParameter[number][j][21] !== null && IsNumeric(this.dataParameter[number][j][21]))
                                            beta = this.dataParameter[number][j][21];
                                        if (this.dataParameter[number][j].length > 22 && this.dataParameter[number][j][22] !== null && IsNumeric(this.dataParameter[number][j][22]))
                                            distance = this.dataParameter[number][j][22];
                                        
                                        if (this.dataParameter[number][j].length > 12 && this.dataParameter[number][j][12] !== null)
                                            typeCam = this.dataParameter[number][j][12];
                 
                                        var camera,coord,X,Y,Z;
                                        coord = objM.newObject('TVector3DT');
                                        if (typeCam === 'perspective')
                                        {
                                            camera = new THREE.PerspectiveCamera(angle, this.dataParameter[number][j][0] / this.dataParameter[number][j][1], near, far);
//                                            cameraCSS = new THREE.PerspectiveCamera(angle, this.dataParameter[number][j][0] / this.dataParameter[number][j][1], near, far);
                                        }else
                                        {
                                            camera = new THREE.OrthographicCamera(-this.dataParameter[number][j][0]/2,this.dataParameter[number][j][0]/2,-this.dataParameter[number][j][1]/2,this.dataParameter[number][j][1]/2, near, far);
//                                            cameraCSS = new THREE.OrthographicCamera(-this.dataParameter[number][j][0]/2,this.dataParameter[number][j][0]/2,-this.dataParameter[number][j][1]/2,this.dataParameter[number][j][1]/2, near, far);
                                        }
                                        if (this.dataParameter[number][j].length > 11 && this.dataParameter[number][j][11] !== null && this.dataParameter[number][j][11].IsType('TVector3DT'))
                                        {
                                            X = this.dataParameter[number][j][11].GetX();
                                            Y = this.dataParameter[number][j][11].GetY();
                                            Z = this.dataParameter[number][j][11].GetZ();
                                        }else
                                        {
                                            X = 0;Y = 0;Z = 10;
                                        }
                                        
                                        if (coord !== null)
                                            coord.SetCoordinates(X,Y,Z);
                                        
                                        camera.position.set(X, Y, Z); 
//                                        cameraCSS.position.set(X, Y, Z); 

                                        tmp_ = document.getElementById(id);
                                        if (typeof tmp_ !== 'undefined' && tmp_ !== null)
                                        {
                                            tmp_.renderer = renderer;
                                            tmp_.scene = objM.copy(scene);
                                            tmp_.camera = objM.newObject('TThreeCamera');
                                            tmp_.camera.SetCamera(camera);
                                            tmp_.camera.SetPositionCamera(coord);
                                            tmp_.camera.SetAlpha(alpha);
                                            tmp_.camera.SetBeta(beta);
                                            tmp_.camera.SetDistance(distance);
                                            tmp_.cameraCoordintes = coord;
                                            tmp_.alpha = alpha;
                                            tmp_.beta = beta;
                                            tmp_.distance = distance;
                                        }
                                        
                                        if (typeof this.dataParameter[number][j] !== 'undefined' && this.dataParameter[number][j] !== null && this.dataParameter[number][j].length > 16)
                                        {
                                            var tmp = this.dataParameter[number][j][16];
                                            var camera2,YN = true;
                                            if (typeof tmp !== 'undefined' && tmp !== null && tmp.length > 0)
                                            {
                                                for (k = 0;k < tmp.length;k++)
                                                {
                                                    if (tmp.length > k && typeof tmp[k] !== 'undefined' && tmp[k] !== null && tmp[k].IsType('TActionThree'))
                                                    {
//                                                        camera2 = tmp[k].GetCamera();
//                                                        if (typeof camera2 !== 'undefined' && camera2 !== null && camera2.IsType('TThreeCamera'))
//                                                            camera2.SetCamera(camera);
                                                        tmp[k].SetCamera(tmp_.camera);
                                                        tmp[k].SetAlpha(tmp_.alpha);
                                                        tmp[k].SetBeta(tmp_.beta);
                                                        tmp[k].SetDistance(tmp_.distance);
                                                        tmp[k].SetRenderer(renderer);
                                                        tmp[k].SetScene(scene);
                                                        tmp[k].SetPositionCamera(coord);
                                                        alpha = tmp[k].GetAlpha();
                                                        if (alpha !== 0)
                                                        {
                                                            if (YN)
                                                            {
                                                                tmp[k].CalculateCameraPosition();
                                                                YN = false;
                                                            }
                                                        }
                                                    }
                                                }
                                                
                                            }
                                            if (YN)
                                            {
                                                action = objM.newObject('TActionThreeCamera');
                                                if (action !== null)
                                                {
                                                    action.SetCamera(tmp_.camera);
                                                    action.SetScene(scene);
                                                    action.SetRenderer(renderer);
                                                    action.SetPositionCamera(coord); 
                                                    action.SetAlpha(tmp_.alpha);
                                                    action.SetBeta(tmp_.beta);
                                                    action.SetDistance(tmp_.distance);
                                                    action.CalculateCameraPosition();
//                                                    action.RenderScene();
                                                }
                                                
                                            }
                                        }

                                        camera.lookAt(scene_.position); 
//                                        cameraCSS.lookAt(sceneCSS_.position); 
//                                        camera.updateProjectionMatrix();
                                        scene_.add(camera);
//                                        sceneCSS_.add(cameraCSS);
                 
                                        function renderScene(){ 
      //                                      if (rendererCSS !== null)
      //                                          rendererCSS.render(sceneCSS_, cameraCSS); 
                                            renderer.render(scene_, camera); 
                                        }        
             
             
                 
                                        tabObj = this.dataParameter[number][j][2];
                                        tmp_.tabObj = tabObj;
                                        tmp_.typeDraw='three';
                                        if (typeof tabObj !== 'undefined' && tabObj !== null)
                                        {
                                            for (k = 0;k < tabObj.length;k++)
                                            {
                                                obj = tabObj[k];
                                                if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                                {
//                                                    if (obj.IsType('TDrawImage_'))
//                                                    {
//                                                        obj.SetDrawObject(this);
//                                                    }
                                                    obj.DrawFigure(scene);
                                                }
                                            }
                                        }
                                        renderScene();

                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    };


    TGenerateHTML.prototype.DrawCanvasFigure = function(scene){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof scene !== 'undefined' && scene !== null && scene.IsType('TCanvasScene'))
        {
            var i,number,j,id,renderer,tabObj,k,obj,tmp_,action,canvas,ctx_,matrix,matrix2;
            for (i = 0;;i++)
            {
                number = this.Find('GenerateCanvas',i);
                if (number === null)
                    break;
                if (typeof this.data[number] !== 'undefined' && this.data[number] !== null && this.data[number].length > 0)
                {
//                    a = this.dataParameter[number]
                    if (this.dataParameter[number].length > 0 && typeof this.dataParameter[number] !== 'undefined')
                    {
                        for (j = 0;j < this.data[number].length;j++)
                        {
                            if (this.dataParameter[number][j].length > 0 && typeof this.dataParameter[number][j] !== 'undefined' && IsNumeric(this.dataParameter[number][j][0]) !== null && IsNumeric(this.dataParameter[number][j][1]) !== null)
                            {
                                id = this.data[number][j];
                                if (typeof id !== 'undefined' && id !== null)
                                {
                                    canvas = document.getElementById(id);
                                    if (typeof canvas !== 'undefined' && canvas !== null)
                                    {
                                        ctx_ = canvas.getContext('2d');
                                        if (typeof ctx_ !== 'undefined' && ctx_ !== null)
                                        {
                                            scene.SetContext(ctx_);
                                            matrix = objM.newObject('TMatrixTransformation3D');
                                            matrix2 = objM.newObject('TMatrixTransformation3D');
                                            if (matrix !== null && matrix2 !== null)
                                            {
                                                if (this.dataParameter[number][j].length > 1 && this.dataParameter[number][j][0] !== null && IsNumeric(this.dataParameter[number][j][0]) && this.dataParameter[number][j][1] !== null && IsNumeric(this.dataParameter[number][j][1]))
                                                {
                                                    if (this.dataParameter[number][j].length > 14 && this.dataParameter[number][j][13] !== null && IsNumeric(this.dataParameter[number][j][13]) && this.dataParameter[number][j][14] !== null && IsNumeric(this.dataParameter[number][j][14]))
                                                    {
                                                        matrix.SetTranslationMatrix(this.dataParameter[number][j][0]/2,this.dataParameter[number][j][1]/2,0);
                                                        matrix2.SetScaleMatrix3D(this.dataParameter[number][j][13],-this.dataParameter[number][j][14],1);
                                                        matrix.MatrixMultiplication(matrix2);
                                                        scene.SetTransformation(matrix);
                                                    }
                                                }
                                            }

                                            tabObj = this.dataParameter[number][j][2];
                                            canvas.tabObj = tabObj;
                                            canvas.typeDraw='canvas';
                                            canvas.scene = scene;
                                            if (this.dataParameter[number][j].length > 15 && this.dataParameter[number][j][15] !== null && IsNumeric(this.dataParameter[number][j][15]))
                                                canvas.correctScale = this.dataParameter[number][j][15];
                                            else
                                                canvas.correctScale = this.dataParameter[number][j][15];
                                            canvas.transformationMatrix = scene.GetTransformation();
                                            if (typeof tabObj !== 'undefined' && tabObj !== null)
                                            {
                                                if (scene.IsType('TCanvasScene'))
                                                    scene.SetCorrectScale(1);
                                                for (k = 0;k < tabObj.length;k++)
                                                {
                                                    obj = tabObj[k];
                                                    if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                                    {
                                                        obj.DrawFigure(scene);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    };

};

TGenerateHTML.prototype = new TGenerateObject2();
    


function TGenerateTeX(){
    
    var type = 'TGenerateTeX';
    TGenerateTeX.prototype.InitConstructor = function(){
        TGenerateObject2.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetObjectType('TeX');
        this.imageCatalog = null;
    };
    this.InitConstructor();

    TGenerateTeX.prototype.InitConstructor2 = function(){
        TGenerateObject2.prototype.InitConstructor2.call(this);
        
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            this.imageCatalog = RandomString(15);
        }
    };

    TGenerateTeX.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TGenerateObject2.prototype.IsType.call(this,_type);
    };

    TGenerateTeX.prototype.Init = function(_object){
        TGenerateObject2.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();        
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('THTMLTitlePageObject'))
        {
//            if (typeof _object.tmpctx !== 'undefined' && _object.tmpctx !== null && _object.tmpctx.IsType('TDrawContext'))
//                this.tmpctx = objM.copy(_object.tmpctx);
            if (typeof _object.imageCatalog !== 'undefined' && _object.imageCatalog !== null)
            {
                this.imageCatalog = new String(_object.imageCatalog);
                if (this.imageCatalog !== null)
                    this.imageCatalog = this.imageCatalog.toString();
            }
        }
    };


    TGenerateTeX.prototype.DrawThreeFigure = function(scene){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof scene !== 'undefined' && scene !== null && scene.IsType('TThreeScene'))
        {
            var i,number,j,id,renderer,tabObj,k,obj,alpha, beta;
            var txt = '';
            
//            scene.ResetSynchronization();
            
            for (i = 0;;i++)
            {
                number = this.Find('GenerateThree',i);
                if (number === null)
                    break;
                if (typeof this.data[number] !== 'undefined' && this.data[number] !== null && this.data[number].length > 0)
                {
                    if (this.dataParameter[number].length > 0 && typeof this.dataParameter[number] !== 'undefined')
                    {
                        for (j = 0;j < this.data[number].length;j++)
                        {
                            if (this.dataParameter[number][j].length > 0 && typeof this.dataParameter[number][j] !== 'undefined' && IsNumeric(this.dataParameter[number][j][0]) !== null && IsNumeric(this.dataParameter[number][j][1]) !== null)
                            {
                                id = this.data[number][j] + 'TeX';
                                if (typeof id !== 'undefined' && id !== null)
                                {
                                    txt = txt + '<div id="' + id + '"></div>';
                                }                                
                            }
                        }
                    }
                }
                
            }
            $('#TeXThreeImages').append(txt);
            for (i = 0;;i++)
            {
                number = this.Find('GenerateThree',i);
                if (number === null)
                    break;
                if (typeof this.data[number] !== 'undefined' && this.data[number] !== null && this.data[number].length > 0)
                {
//                    a = this.dataParameter[number]
                    if (this.dataParameter[number].length > 0 && typeof this.dataParameter[number] !== 'undefined')
                    {
                        for (j = 0;j < this.data[number].length;j++)
                        {
                            if (this.dataParameter[number][j].length > 0 && typeof this.dataParameter[number][j] !== 'undefined' && IsNumeric(this.dataParameter[number][j][0]) !== null && IsNumeric(this.dataParameter[number][j][1]) !== null)
                            {
                                var fileName = this.data[number][j] + '.png';
                                
                                id = this.data[number][j] + 'TeX';
                                if (typeof id !== 'undefined' && id !== null)
                                {
                                    if (this.dataParameter[number][j].length > 23 && this.dataParameter[number][j][23] !== null && this.dataParameter[number][j][23] === 'canvas')
                                    {
                                        renderer = new THREE.CanvasRenderer(); 
                                    }else
                                    {
                                        if(Detector.webgl){ 
                                            renderer = new THREE.WebGLRenderer({antialias:true,preserveDrawingBuffer: true}); 
                                        }else
                                        {
                                            renderer = new THREE.CanvasRenderer(); 
                                        }
                                    }
                                    if (renderer !== null)
                                    {
/*                                        if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 16)
                                        {
                                            var tmp = this.dataParameter[i][j][16];
                                            if (typeof tmp !== 'undefined' && tmp !== null && tmp.length > 0)
                                            {
                                                for (k = 0;k < tmp.length;k++)
                                                {
                                                    if (tmp.length > k && typeof tmp[k] !== 'undefined' && tmp[k] !== null && tmp[k].IsType('TActionThree'))
                                                    {
                                                        
                                                    }
                                                }
                                                
                                            }
                                        }*/
                                        

                                        if (this.dataParameter[number][j].length > 10 && this.dataParameter[number][j][10] !== null && this.dataParameter[number][j][10].IsType('TColourRGBA'))
                                        {
                                            var tmp = this.dataParameter[number][j][10].Get24bitColour();
                                            renderer.setClearColor(tmp, this.dataParameter[number][j][10].GetColourA());                                             
                                        }else
                                            renderer.setClearColor(0x000000, 1); 

                                        if (this.dataParameter[number][j].length > 19 && typeof this.dataParameter[number][j][19] !== 'undefined' && this.dataParameter[number][j][19] !== null && IsInt(this.dataParameter[number][j][19]) && this.dataParameter[number][j][19] > 0)
                                        {
                                            renderer.setSize(this.dataParameter[number][j][19], this.dataParameter[number][j][19]*this.dataParameter[number][j][1]/this.dataParameter[number][j][0]);
                                        }else
                                            renderer.setSize(this.dataParameter[number][j][0], this.dataParameter[number][j][1]);
    //                                    renderer.setSize(100, 100);
                                        document.getElementById(id).appendChild(renderer.domElement); 

                                        var scene_ = new THREE.Scene();
                                        scene.SetScene(scene_);
                                        var angle = 45;
                                        var near = 1;
                                        var far = 100;
                                        var catalog = this.GetImageCatalog();
                                        var typeCam = 'orthographic';
                                        if (this.dataParameter[number][j].length > 13 && this.dataParameter[number][j][13] !== null && IsNumeric(this.dataParameter[number][j][13]))
                                            angle = this.dataParameter[number][j][13];
                                        if (this.dataParameter[number][j].length > 14 && this.dataParameter[number][j][14] !== null && IsNumeric(this.dataParameter[number][j][14]))
                                            near = this.dataParameter[number][j][14];
                                        if (this.dataParameter[number][j].length > 15 && this.dataParameter[number][j][15] !== null && IsNumeric(this.dataParameter[number][j][15]))
                                            far = this.dataParameter[number][j][15];
//                                        if (this.dataParameter[number][j].length > 17 && this.dataParameter[number][j][17] !== null)
//                                            catalog = this.dataParameter[number][j][17];
                                        if (this.dataParameter[number][j].length > 20 && this.dataParameter[number][j][20] !== null && IsNumeric(this.dataParameter[number][j][20]))
                                            alpha = this.dataParameter[number][j][20];
                                        if (this.dataParameter[number][j].length > 21 && this.dataParameter[number][j][21] !== null && IsNumeric(this.dataParameter[number][j][21]))
                                            beta = this.dataParameter[number][j][21];
                                        
                                        if (this.dataParameter[number][j].length > 12 && this.dataParameter[number][j][12] !== null)
                                            typeCam = this.dataParameter[number][j][12];
                 
                                        var camera,coord,X,Y,Z;
                                        coord = objM.newObject('TVector3DT');
                                        if (typeCam === 'perspective')
                                            camera = new THREE.PerspectiveCamera(angle, this.dataParameter[number][j][0] / this.dataParameter[number][j][1], near, far);
                                        else
                                            camera = new THREE.OrthographicCamera(-this.dataParameter[number][j][0]/2,this.dataParameter[number][j][0]/2,-this.dataParameter[number][j][1]/2,this.dataParameter[number][j][1]/2, near, far);
                                        if (this.dataParameter[number][j].length > 11 && this.dataParameter[number][j][11] !== null && this.dataParameter[number][j][11].IsType('TVector3DT'))
                                        {
                                            X = this.dataParameter[number][j][11].GetX();
                                            Y = this.dataParameter[number][j][11].GetY();
                                            Z = this.dataParameter[number][j][11].GetZ();
                                        }else
                                        {
                                            X = 0;Y = 0;Z = 10;
                                        }
                                        
                                        if (coord !== null)
                                            coord.SetCoordinates(X,Y,Z);
                                        
                                        camera.position.set(X, Y, Z); 

                                        var action = objM.newObject('TActionThreeCamera');
                                        if (action !== null)
                                        {
                                            var cam = objM.newObject('TThreeCamera');
                                            cam.SetCamera(camera);
                                            cam.SetPositionCamera(coord);
                                            cam.SetAlpha(alpha);
                                            cam.SetBeta(beta);
                                            action.SetCamera(cam);
                                            action.SetScene(scene);
                                            action.SetRenderer(renderer);
                                            action.SetPositionCamera(coord); 
                                            action.SetAlpha(alpha);
                                            action.SetBeta(beta);
                                            action.CalculateCameraPosition();
                                        }
                                        

                                        camera.lookAt(scene_.position); 
//                                        camera.updateProjectionMatrix();
                                        scene_.add(camera);
                 
                                        function renderScene(){ 
                                            renderer.render(scene_, camera);
                                            var strMime = "image/png";
                                            var imgData = renderer.domElement.toDataURL(strMime);
                                            $.ajax({
                                              type: "POST",
                                              url: "php/saveImageBase64.php",
                                              data: { 
                                                 data: imgData,
                                                 catalog: catalog,
                                                 fileName:fileName
                                              }
                                            }).done(function(o) {
                                              scene.DecSynchronization();
                                              console.log('saved'); 
                                              // If you want the file to be visible in the browser 
                                              // - please modify the callback in javascript. All you
                                              // need is to return the url to the file, you just saved 
                                              // and than put the image in your browser.
                                            });
                                        }        
             
             
                 
                                        tabObj = this.dataParameter[number][j][2];
                                        if (typeof tabObj !== 'undefined' && tabObj !== null)
                                        {
                                            for (k = 0;k < tabObj.length;k++)
                                            {
                                                obj = tabObj[k];
                                                if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                                {
//                                                    if (obj.IsType('TDrawImage_'))
//                                                    {
//                                                        obj.SetDrawObject(this);
//                                                    }
                                                    obj.DrawFigure(scene);
                                                }
                                            }
                                        }
                                        scene.IncSynchronization();
                                        renderScene();

                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    };

    TGenerateTeX.prototype.DrawCanvasFigure = function(scene){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof scene !== 'undefined' && scene !== null && scene.IsType('TCanvasScene'))
        {
            var i,number,j,id,txt = '',tabObj,k,obj,canvas,ctx_,matrix,matrix2;

            for (i = 0;;i++)
            {
                number = this.Find('GenerateCanvas',i);
                if (number === null)
                    break;
                if (typeof this.data[number] !== 'undefined' && this.data[number] !== null && this.data[number].length > 0)
                {
                    if (this.dataParameter[number].length > 0 && typeof this.dataParameter[number] !== 'undefined')
                    {
                        for (j = 0;j < this.data[number].length;j++)
                        {
                            if (this.dataParameter[number][j].length > 0 && typeof this.dataParameter[number][j] !== 'undefined' && IsNumeric(this.dataParameter[number][j][0]) !== null && IsNumeric(this.dataParameter[number][j][1]) !== null)
                            {
                                id = this.data[number][j] + 'TeX';
                                if (typeof id !== 'undefined' && id !== null)
                                {
                                    txt = txt + '<canvas id="' + id + '"';
                                    if (typeof this.dataParameter[number][j] !== 'undefined' && this.dataParameter[number][j] !== null && this.dataParameter[number][j].length > 12)
                                    {
                                        txt = txt + ' width="'+ this.dataParameter[number][j][12] + '" height="' + this.dataParameter[number][j][12]*this.dataParameter[number][j][1]/this.dataParameter[number][j][0] + '" ';
                                    }
                                    txt = txt + '>';
                                    txt = txt + '</canvas>';                        
                                }                                
                            }
                        }
                    }
                }
                
            }
            $('#TeXCanvasImages').append(txt);
            
            var cWidth,cHeight,cScale;
            for (i = 0;;i++)
            {
                number = this.Find('GenerateCanvas',i);
                if (number === null)
                    break;
                if (typeof this.data[number] !== 'undefined' && this.data[number] !== null && this.data[number].length > 0)
                {
//                    a = this.dataParameter[number]
                    if (this.dataParameter[number].length > 0 && typeof this.dataParameter[number] !== 'undefined')
                    {
                        for (j = 0;j < this.data[number].length;j++)
                        {
                            if (this.dataParameter[number][j].length > 0 && typeof this.dataParameter[number][j] !== 'undefined' && IsNumeric(this.dataParameter[number][j][0]) !== null && IsNumeric(this.dataParameter[number][j][1]) !== null)
                            {
                                var fileName = this.data[number][j] + '.png';
                                id = this.data[number][j] + 'TeX';
                                if (typeof id !== 'undefined' && id !== null)
                                {
                                    canvas = document.getElementById(id);
                                    
                                    if (typeof canvas !== 'undefined' && canvas !== null)
                                    {
                                        ctx_ = canvas.getContext('2d');
                                        if (typeof ctx_ !== 'undefined' && ctx_ !== null)
                                        {
                                            scene.SetContext(ctx_);
                                            matrix = objM.newObject('TMatrixTransformation3D');
                                            matrix2 = objM.newObject('TMatrixTransformation3D');
                                            if (matrix !== null && matrix2 !== null)
                                            {
                                                if (this.dataParameter[number][j].length > 1 && this.dataParameter[number][j][0] !== null && IsNumeric(this.dataParameter[number][j][0]) && this.dataParameter[number][j][1] !== null && IsNumeric(this.dataParameter[number][j][1]))
                                                {
                                                    if (this.dataParameter[number][j].length > 14 && this.dataParameter[number][j][13] !== null && IsNumeric(this.dataParameter[number][j][13]) && this.dataParameter[number][j][14] !== null && IsNumeric(this.dataParameter[number][j][14]))
                                                    {
                                                        if (this.dataParameter[number][j][12] !== null && IsNumeric(this.dataParameter[number][j][12]))
                                                        {
                                                            cWidth = this.dataParameter[number][j][12];
                                                            cScale = cWidth/this.dataParameter[number][j][0];
                                                            cHeight = cScale*this.dataParameter[number][j][1];
                                                            matrix.SetTranslationMatrix(cWidth/2,cHeight/2,0);
                                                            matrix2.SetScaleMatrix3D(cScale*this.dataParameter[number][j][13],-cScale*this.dataParameter[number][j][14],1);
                                                            matrix.MatrixMultiplication(matrix2);
                                                            scene.SetTransformation(matrix);
                                                        }
                                                    }
                                                }
                                            }

                                            tabObj = this.dataParameter[number][j][2];
                                            if (this.dataParameter[number][j].length > 15 && this.dataParameter[number][j][15] !== null && IsNumeric(this.dataParameter[number][j][15]))
                                                canvas.correctScale = this.dataParameter[number][j][15];
                                            else
                                                canvas.correctScale = this.dataParameter[number][j][15];
//                                            canvas.tabObj = tabObj;
                                            if (typeof tabObj !== 'undefined' && tabObj !== null)
                                            {
                                                if (scene.IsType('TCanvasScene'))
                                                    scene.SetCorrectScale(canvas.correctScale);
                                                else
                                                    scene.SetCorrectScale(1);
                                                for (k = 0;k < tabObj.length;k++)
                                                {
                                                    obj = tabObj[k];
                                                    if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                                    {
                                                        obj.DrawFigure(scene);
                                                    }
                                                }
                                            }
                                            var catalog = this.GetImageCatalog();
                                            scene.IncSynchronization();
                                            var strMime = "image/png";
                                            var imgData = canvas.toDataURL(strMime);
                                            $.ajax({
                                              type: "POST",
                                              url: "php/saveImageBase64.php",
                                              data: { 
                                                 data: imgData,
                                                 catalog: catalog,
                                                 fileName:fileName
                                              }
                                            }).done(function(o) {
                                              scene.DecSynchronization();
                                              console.log('saved'); 
                                              // If you want the file to be visible in the browser 
                                              // - please modify the callback in javascript. All you
                                              // need is to return the url to the file, you just saved 
                                              // and than put the image in your browser.
                                            });
                
                                        
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    };

    TGenerateTeX.prototype.GetImageCatalog = function(){
        var tmp = new String(this.imageCatalog);
        if (tmp !== null)
            return tmp.toString();
        return null;
    };

    TGenerateTeX.prototype.SetImageCatalog = function(catalog_){
        if (typeof catalog_ !== 'undefined' && catalog_ !== null)
        {
            this.imageCatalog = new String(catalog_);
            if (this.imageCatalog !== null)
                this.imageCatalog =  this.imageCatalog.toString();
        }
    };

};

TGenerateTeX.prototype = new TGenerateObject2();


function THTMLTitlePageObject(){
    
    var type = 'THTMLTitlePageObject';
    THTMLTitlePageObject.prototype.InitConstructor = function(){
        TGenerateHTML.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.numberOfAuthors = 0;
        this.SetObjectType('HTML');
    };
    this.InitConstructor();

    THTMLTitlePageObject.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TGenerateHTML.prototype.IsType.call(this,_type);
    };

    THTMLTitlePageObject.prototype.Init = function(_object){
        TGenerateHTML.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('THTMLTitlePageObject'))
        {
            if (typeof _object.numberOfAuthors !== 'undefined' && _object.numberOfAuthors !== null && IsInt(_object.numberOfAuthors))
            {
                this.numberOfAuthors = _object.numberOfAuthors;
            }            
        }
    };
    
    THTMLTitlePageObject.prototype.PrepareTXT = function(type,cssType,_number){
        var txt = '';
        if (typeof type !== 'undefined' && type !== null && typeof cssType !== 'undefined' && cssType !== null)
        {
            var tmp, i;
            if (this.GetSlide())
                tmp = 'Slide';
            else
                tmp = '';
            var number = this.Find(type,_number);
            if (number !== null)
            {
                for (i = 0;i < this.data[number].length;i++)
                {
                    txt = txt + '<' + tmp + cssType +'>';
                    txt = txt + this.data[number][i];
                    txt = txt + '</' + tmp + cssType + '>';            
                }
            }
        }
        return txt;
    };    

    THTMLTitlePageObject.prototype.PrepareTXT2 = function(type,cssType,_number, delimiter){
        var txt = '';
        if (typeof type !== 'undefined' && type !== null && typeof cssType !== 'undefined' && cssType !== null)
        {
            var tmp, i;
            if (this.GetSlide())
                tmp = 'Slide';
            else
                tmp = '';
            var number = this.Find(type,_number);
            if (number !== null)
            {
                txt = txt + '<' + tmp + cssType +'>';
                for (i = 0;i < this.data[number].length;i++)
                {
                    txt = txt + this.data[number][i];
                    if (i !== this.data[number].length - 1 && typeof delimiter !== 'undefined' && delimiter !== null)
                        txt = txt + delimiter;
                    txt = txt + ' ';
                }
                txt = txt + '</' + tmp + cssType + '>';            
            }
        }
        return txt;
    };    

    THTMLTitlePageObject.prototype.GetTXT2 = function(){
        var txt  = '',i,j;//=  TGenerateHTML.prototype.GetTXT.call(this); 
        if (this.GetNumberNote() < 0 || !this.GetSlide())
        {
            txt = txt + this.PrepareTXT('TitlePaper','PaperTitle');
            txt = txt + this.PrepareTXT('Subtitle','PaperSubtitle');
            if (this.GetSlide())
                txt = txt + '<SlidePersonalData>';
            else
                txt = txt + '<PersonalData>';
            for(i = 0;i < this.numberOfAuthors;i++)
            {
                txt = txt + this.PrepareTXT2('AuthorName','AuthorName',i);
                txt = txt + this.PrepareTXT2('AuthorSurname','AuthorSurname',i);
                txt = txt + this.PrepareTXT2('Email','Email',i,',');
                txt = txt + this.PrepareTXT2('WWW','WWW',i,',');
                txt = txt + this.PrepareTXT('AffiliationWork','AffiliationWork',i);
                txt = txt + this.PrepareTXT('AffiliationAdress','AffiliationAdress',i);
            }
            if (this.GetSlide())
                txt = txt + '</SlidePersonalData>';
            else
                txt = txt + '</PersonalData>';
        }else
        {
            if (this.GetSlide())
            {
                txt = txt + '<SlideNoteBlock>';
                var noteYN = false;
                for (i = 0;i < this.data.length;i++)
                {
                    for (j = 0;j < this.data[i].length;j++)
                    {
                        if (this.dataName[i] === 'Note')
                        {
                            if (this.data[i][j] === 'Start')
                                noteYN = true;
                            if (this.data[i][j] === 'Stop')
                                noteYN = false;
                        }
                        if (noteYN)
                        {
                            if (this.dataName[i] === 'Paragraph')
                            {
                                if (this.data[i][j] === 'Start')
                                {
                                    if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                        txt = txt + '<SlideNoteP class="' + this.dataParameter[i][j][1] + '">';
                                    else
                                        txt = txt + '<SlideNoteP>';
                                }
                                if (this.data[i][j] === 'Stop')
                                    txt = txt + '</SlideNoteP>';
                            }
                            if (this.dataName[i] === 'PT')
                                txt = txt + this.data[i][j];
                        }
                    }
                }
                txt = txt + '</SlideNoteBlock>';
            }
        }
        return txt;
    };

    THTMLTitlePageObject.prototype.Add = function(type,text,parameter){
        TGenerateHTML.prototype.Add.call(this,type,text,parameter);
        if (type === 'AuthorSurname')
            this.numberOfAuthors++;
    };
};

THTMLTitlePageObject.prototype = new TGenerateHTML();


function THTMLTableOfContens(){
    
    var type = 'THTMLTableOfContens';
    THTMLTableOfContens.prototype.InitConstructor = function(){
        TGenerateHTML.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetObjectType('HTML');
    };
    this.InitConstructor();

    THTMLTableOfContens.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TGenerateHTML.prototype.IsType.call(this,_type);
    };

    THTMLTableOfContens.prototype.Init = function(_object){
        TGenerateHTML.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('THTMLTableOfContens'))
        {
        }
    };
    
    THTMLTableOfContens.prototype.GetTXT2 = function(){
        var txt = '';
        if (this.GetSlide())
        {
//            txt = TGenerateHTML.prototype.GetTXT.call(this); 
            if (this.GetNumberNote() < 0)
            {
                var i,j,number = this.Find('Title',0);
                if (number !== null)
                {
                    for (i = 0;i < this.data[number].length;i++)
                    {
                        if (parseInt(this.dataParameter[number][i][0]) === -1)
                        {
                            txt = txt + '<TitleSlidePosition>' + this.data[number][i] + '</TitleSlidePosition>';
                            break;
                        }
                    }
                    var tmp,tmp2,YN;
                    txt = txt + '<SlideBlock>';
                    txt = txt + '<SlideText>';
                    var number2 = this.Find('Id',0);
                    if (number2 !== null)
                        txt = txt + '<SlideCustom_' + this.data[number2][0] + '>';
                    txt = txt + '<ol>';
                    for (i = 0;i < this.data[number].length;i++)
                    {
                        if (parseInt(this.dataParameter[number][i][0]) === 0)
                        {
                            tmp = parseInt(this.dataParameter[number][i][0]) + 1;
                            txt = txt + '<Enumeration' + tmp + '><li>';
                            id = this.dataParameter[number][i][1];
                            txt = txt + '<a href="#';
                            if (typeof id !== 'undefined' && id !== null)
                            {
                                txt = txt + 'Slide' + id;
                                txt = txt + '" class="Slide' + id;  
                            }
                            txt = txt + '">';
                            txt = txt + this.data[number][i];
                            txt = txt + '</a>';            
                            YN = false;
                            for (j = i + 1;j < this.data[number].length;j++)
                            {
                                if (parseInt(this.dataParameter[number][j][0]) === 1)
                                {
                                    if (!YN)
                                    {
                                        YN = true;
                                        txt = txt + '<ul class="ulSlideTableOfContens">';                                  
                                    }
                                    tmp2 = parseInt(this.dataParameter[number][j][0]) + 1;
                                    txt = txt + '<Enumeration' + tmp2 + '><li>';
                                    id = this.dataParameter[number][j][1];
                                    txt = txt + '<a href="#';
                                    if (typeof id !== 'undefined' && id !== null)
                                    {
                                        txt = txt + 'Slide' + id;
                                        txt = txt + '" class="Slide' + id;  
                                    }
                                    txt = txt + '">';
                                    txt = txt + this.data[number][j];
                                    txt = txt + '</a>';            
                                    txt = txt + '</li></Enumeration' + tmp2 + '>';
                                }else
                                    break;
                            }
                            if (YN)
                                txt = txt + '</ul>';                                  
                            txt = txt + '</li></Enumeration' + tmp + '>';
                        }
                    }
                    if (number2 !== null)
                        txt = txt + '</SlideCustom_' + this.data[number2][0] + '>';
                    txt = txt + '</SlideText>';
                    txt = txt + '</SlideBlock>';
                }
            }else
            {
                txt = txt + '<SlideNoteBlock>';
                var noteYN = false;
                for (i = 0;i < this.data.length;i++)
                {
                    for (j = 0;j < this.data[i].length;j++)
                    {
                        if (this.dataName[i] === 'Note')
                        {
                            if (this.data[i][j] === 'Start')
                                noteYN = true;
                            if (this.data[i][j] === 'Stop')
                                noteYN = false;
                        }
                        if (noteYN)
                        {
                            if (this.dataName[i] === 'Paragraph')
                            {
                                if (this.data[i][j] === 'Start')
                                {
                                    if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                        txt = txt + '<SlideNoteP class="' + this.dataParameter[i][j][1] + '">';
                                    else
                                        txt = txt + '<SlideNoteP>';
                                }
                                if (this.data[i][j] === 'Stop')
                                    txt = txt + '</SlideNoteP>';
                            }
                            if (this.dataName[i] === 'PT')
                                txt = txt + this.data[i][j];
                        }
                    }
                }
                txt = txt + '</SlideNoteBlock>';
            }
        }else
        {
            var i,j,level,levelsNumber = [],tmp,id;
            var number = this.Find('Title',0);
            if (number !== null)
            {
                if (this.data[number].length > 0)
                {
                    txt = txt + '<TitleTableOfContens>' + this.data[number][0] + '</TitleTableOfContens>';
                    level = 0;
                    for (i = 1;i < this.data[number].length;i++)
                    {
                        id = this.dataParameter[number][i][1];
                        txt = txt + '<a href="#';
                        if (typeof id !== 'undefined' && id !== null)
                        {
                            txt = txt + id;
                            txt = txt + '" class="' + id;  
                        }
                        txt = txt + '">';
                        level = this.dataParameter[number][i][0];
                        if (typeof level !== 'undefined' && level !== null && IsInt(level) && level >= 0)
                        {
                            if (levelsNumber.length <= level)
                                levelsNumber[level] = 0;
                            if (levelsNumber.length > level)
                                for (j = level + 1;j < levelsNumber.length;j++)
                                    levelsNumber[j] = 0;

                            levelsNumber[level] = levelsNumber[level] + 1;
                        }
                        tmp = level + 1;
                        txt = txt + '<TableOfContensh' + tmp +'>';
                        for (j = 0;j <= level;j++)
                        {
                            txt = txt + levelsNumber[j];
                            txt = txt + '.';
                        }
                        txt = txt + ' ';
                        txt = txt + this.data[number][i];
                        txt = txt + '</TableOfContensh' + tmp + '>';            
                        txt = txt + '</a>';            
                    }
                }
            }
        }
        return txt;
    };

};

THTMLTableOfContens.prototype = new TGenerateHTML();

function THTMLParagraphs(){
    
    var type = 'THTMLParagraphs';
    THTMLParagraphs.prototype.InitConstructor = function(){
        TGenerateHTML.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetObjectType('HTML');
    };
    this.InitConstructor();

    THTMLParagraphs.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TGenerateHTML.prototype.IsType.call(this,_type);
    };

    THTMLParagraphs.prototype.Init = function(_object){
        TGenerateHTML.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('THTMLParagraphs'))
        {
        }
    };
    
    THTMLParagraphs.prototype.GetTXT = function(){
        var txt = '';
        if (this.GetSlide())
        {
        }else
        {
            var i,j,k,levelsNumber = [],currentLevel = 0,tmp,tmp2,id,enumYN=0,itemizeYN=0,figureYN = 0;
            var subfigureNumberYN = false,subfigureNumber = null,tableYN=false,style = null,tabObj=null,obj,ctx;
            var numberCatalog = this.Find('ImageCatalog'),matrix,matrix2,scaleX,scaleY,scaleZ;
            var numberEquation = null,formStart = false;;
            var objM = this.GetObjectManager();
            if (objM === null)
                return;

            for (i = 0;i < this.data.length;i++)
            {
                for (j = 0;j < this.data[i].length;j++)
                {
                    if (this.dataName[i] === 'Title')
                    {
                        currentLevel = this.dataParameter[i][j][0];
                        if (typeof currentLevel !== 'undefined' && currentLevel !== null && IsInt(currentLevel) && currentLevel >= 0)
                        {
                            if (levelsNumber.length <= currentLevel)
                                levelsNumber[currentLevel] = 0;
                            if (levelsNumber.length > currentLevel)
                                for (k = currentLevel + 1;k < levelsNumber.length;k++)
                                    levelsNumber[k] = 0;

                            levelsNumber[currentLevel] = levelsNumber[currentLevel] + 1;
                        }
                        if (this.dataParameter[i][j][2])
                        {
                            tmp = currentLevel + 1;
                            id = this.dataParameter[i][j][1];
                            txt = txt + '<h' + tmp;
                            if (typeof id !== 'undefined' && id !== null)
                                txt = txt + ' id="'+ id + '"';          
                            txt = txt + '>';
                            if (typeof levelsNumber !== 'undefined' && levelsNumber !== null)
                            {
                                for (k = 0;k < levelsNumber.length && k <= currentLevel;k++)
                                {
                                    txt = txt + levelsNumber[k] + '.';
                                }
                                txt = txt + ' ';
                            }
                            txt = txt + this.data[i][j];
                            txt = txt + '</h' + tmp + '>';            
                        }                        
                    }
                    if (this.dataName[i] === 'Enum')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            txt = txt + '<ol class="olPaper">';
                            enumYN++;
                        }
                        if (this.data[i][j] === 'Stop')
                        {
                            txt = txt + '</ol>';                        
                            enumYN--;
                            if (enumYN < 0)
                                enumYN = 0;
                        }
                    }
                    if (this.dataName[i] === 'Ref')
                    {
//                        txt = txt + ' ';
                        txt = txt + '<a href="#';
                        if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                        {
                            txt = txt + this.data[i][j];
                            txt = txt + '" class="' + this.data[i][j];  
                        }
                        txt = txt + '">';

                        if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0)
                        {
                            for(k = 0;k < this.dataParameter[i][j].length - 1;k++)
                            {
                                txt = txt + this.dataParameter[i][j][k] + '.';
                            }
                            txt = txt + this.dataParameter[i][j][k];
                        }
                        txt = txt + '</a>';
                    }
                    if (this.dataName[i] === 'Itemize')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            if (enumYN > 0)
                                txt = txt + '<ul class="ulPaper2">';
                            else
                                txt = txt + '<ul class="ulPaper1">';
                            itemizeYN++;
                        }
                        if (this.data[i][j] === 'Stop')
                        {
                            txt = txt + '</ul>';                        
                            itemizeYN--;
                            if (itemizeYN < 0)
                                itemizeYN = 0;
                        }
                    }
                    if (this.dataName[i] === 'Item')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                txt = txt + '<li class="' +  this.dataParameter[i][j][0] + '">';
                            else
                                txt = txt + '<li>';
                        }
                        if (this.data[i][j] === 'Stop')
                            txt = txt + '</li>';                        
                    }
                    if (this.dataName[i] === 'Figure')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null)
                            {
                                if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                    txt = txt + '<Figure id="' + this.dataParameter[i][j][0] + '">';
                                else
                                    txt = txt + '<Figure>';
                            }else
                                txt = txt + '<Figure>';
                            figureYN++;
                        }
                        if (this.data[i][j] === 'Stop')
                        {
                            txt = txt + '</Figure>';
                            figureYN--;                            
                            if (figureYN < 0)
                                figureYN = 0;
                        }
                    }
                    if (this.dataName[i] === 'FigureCaption')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            txt = txt + '<FigureCaption>';
                        }
                        if (this.data[i][j] === 'Stop')
                        {
                            txt = txt + '</FigureCaption>';
                        }
                    }
                    if (this.dataName[i] === 'Subfigure')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            txt = txt + '<Subfigure>';
                        }
                        if (this.data[i][j] === 'Stop')
                        {
                            txt = txt + '</Subfigure>';
                        }
                        if (this.data[i][j] === 'NotNumber')
                            subfigureNumberYN = false;
                        if (this.data[i][j] === 'Number')
                        {
                            subfigureNumberYN = true;
                            subfigureNumber = this.dataParameter[i][j];
                        }
                    }
                                        
                    if (this.dataName[i] === 'FigureImageBitmap' || this.dataName[i] === 'InteractiveImageBitmap')
                    {
                        txt = txt + '<FigureImageBitmapBlock style="display:inline-block">';
                        if (subfigureNumberYN)
                            txt = txt + subfigureNumber + ')';
                        if (numberCatalog !== null && typeof this.data[numberCatalog][0] !== 'undefined' && this.data[numberCatalog][0] !== null)
                        {
                            txt = txt + '<img';
                            if (this.data[i][j] !== null && this.data[i][j] !== 'null')
                                txt = txt + ' src="' + this.data[numberCatalog][0] + '/' + this.data[i][j] + '"';
                            txt = txt + ' style="';
                            if (this.dataParameter[i][j][0] > 0)
                                txt = txt + 'width:' + this.dataParameter[i][j][0] +'%;';
                            else
                                if (this.dataParameter[i][j][1] > 0)
                                    txt = txt + 'height:' + this.dataParameter[i][j][1] +'mm;';
                            txt = txt + 'vertical-align: text-top"';
                            if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                txt = txt + ' onclick="javascript:' + this.dataParameter[i][j][3] +'" ';
                            if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                txt = txt + ' id="' + this.dataParameter[i][j][2] +'" ';
                            if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null && this.dataParameter[i][j][4] === false)
                                txt = txt + ' hidden';
                            txt = txt + '>';
                        }
                        txt = txt + '</FigureImageBitmapBlock>';
                                    
                    }
                    
                    if (this.dataName[i] === 'FigureName')
                    {
                        txt = txt + this.data[i][j] + ' ';
                        if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0)
                        {
                            for(k = 0;k < this.dataParameter[i][j].length;k++)
                            {
                                txt = txt + this.dataParameter[i][j][k] + '.';
                            }
                            txt = txt  + ' ';
                        }
                    }
                    if (this.dataName[i] === 'FigureVideo')
                    {
                        txt = txt + '<FigureVideo>';
                        if (subfigureNumberYN)
                            txt = txt + subfigureNumber + ')';
                        txt = txt + '<video ';
                        if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                            txt = txt + 'id="' + this.dataParameter[i][j][2] +'" ';
                        if (this.dataParameter[i][j].length > 6 && typeof this.dataParameter[i][j][6] !== 'undefined' && this.dataParameter[i][j][6] !== null)
                            txt = txt + 'class="' + this.dataParameter[i][j][6] +'" ';
                        if (this.dataParameter[i][j].length > 0 && this.dataParameter[i][j][0] > 0)
                            txt = txt + 'width="' + this.dataParameter[i][j][0] +'%" ';
                        if (this.dataParameter[i][j].length > 1 && this.dataParameter[i][j][1] > 0)
                            txt = txt + 'height="' + this.dataParameter[i][j][1] +'%"';
                        if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null && this.dataParameter[i][j][4])
                            txt = txt + ' autoplay="autoplay"';
                        if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null && this.dataParameter[i][j][5])
                            txt = txt + ' controls="controls"';
                        if (this.dataParameter[i][j].length > 7 && typeof this.dataParameter[i][j][7] !== 'undefined' && this.dataParameter[i][j][7] !== null && this.dataParameter[i][j][7])
                            txt = txt + ' loop="controls"';

                        txt = txt + ' style="vertical-align: text-top">';

                        txt = txt + '<source  src="' + this.data[numberCatalog][0] + '/' + this.data[i][j] + '" ';
                        if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                            txt = txt + 'type="'+ this.dataParameter[i][j][3] +'"';
                        txt = txt + '>';

                        txt = txt + '</video>';
                        txt = txt + '</FigureVideo>';

                    }
					
					if (this.dataName[i] === 'FigureYouTubeVideo')
					{
						txt = txt + '<FigureYouTubeVideo>';
						
/*                            txt = txt + '<iframe src="' + this.data[i][j] + '" style="';
						if (this.dataParameter[i][j][0] > 0)
							txt = txt + 'width:' + this.dataParameter[i][j][0] +'%;';
						else
							if (this.dataParameter[i][j][1] > 0)
								txt = txt + 'height:' + this.dataParameter[i][j][1] +'mm;';
						txt = txt + 'vertical-align: text-top"/>';*/

						txt = txt + '<iframe ';
						if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
							txt = txt + 'id="' + this.dataParameter[i][j][2] +'" ';
						if (this.dataParameter[i][j].length > 6 && typeof this.dataParameter[i][j][6] !== 'undefined' && this.dataParameter[i][j][6] !== null)
							txt = txt + 'class="' + this.dataParameter[i][j][6] +'" ';
						if (this.dataParameter[i][j].length > 0 && this.dataParameter[i][j][0] > 0)
							txt = txt + 'width="' + this.dataParameter[i][j][0] +'" ';
						if (this.dataParameter[i][j].length > 1 && this.dataParameter[i][j][1] > 0)
							txt = txt + 'height="' + this.dataParameter[i][j][1] +'"';
						
						txt = txt + ' src="' + this.data[i][j];
						if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null && this.dataParameter[i][j][4])
							txt = txt + '?autoplay=1';
						else
							txt = txt + '?autoplay=0';
						if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null && this.dataParameter[i][j][5])
							txt = txt + '&controls=1';
						else
							txt = txt + '&controls=0';
						if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][7] !== 'undefined' && this.dataParameter[i][j][7] !== null && this.dataParameter[i][j][7])
						{
							txt = txt + '&loop=1';
							var ind,ind2,tmp__ = '';
							for (ind=this.data[i][j].length-1;ind>0;ind--)
							{
								if(this.data[i][j][ind] == "/")
									break;
							}
							ind2 = ind + 1;
							for (ind=this.data[i][j].length-1;ind>0;ind--)
							{
								if(this.data[i][j][ind] == "/")
									break;
								tmp__ =  this.data[i][j][ind] + tmp__;
							}
							txt = txt + '&playlist=' + tmp__;
						}else
							txt = txt + '&loop=0';
						if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null && this.dataParameter[i][j][3])
							txt = txt + '&mute=1';
						else
							txt = txt + '&mute=0';
				
						txt = txt + '" frameborder="0" allow="picture-in-picture"';


						txt = txt + '>';
						
						
						txt = txt + '</iframe>';
						txt = txt + '</FigureYouTubeVideo>';

					}
                        if (this.dataName[i] === 'FigureGoogleMaps')
                        {
                            txt = txt + '<FigureGoogleMaps>';
                            

                            txt = txt + '<iframe ';
                            if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                txt = txt + 'id="' + this.dataParameter[i][j][2] +'" ';
                            if (this.dataParameter[i][j].length > 6 && typeof this.dataParameter[i][j][6] !== 'undefined' && this.dataParameter[i][j][6] !== null)
                                txt = txt + 'class="' + this.dataParameter[i][j][6] +'" ';
                            if (this.dataParameter[i][j].length > 0 && this.dataParameter[i][j][0] > 0)
                                txt = txt + 'width="' + this.dataParameter[i][j][0] +'" ';
                            if (this.dataParameter[i][j].length > 1 && this.dataParameter[i][j][1] > 0)
                                txt = txt + 'height="' + this.dataParameter[i][j][1] +'"';
							
		                    txt = txt + ' src="' + this.data[i][j];
					
                            txt = txt + '" frameborder="0" allowfullscreen=""';


                            txt = txt + '>';
                            
                            
                            txt = txt + '</iframe>';
                            txt = txt + '</FigureGoogleMaps>';

                        }
					
                        if (this.dataName[i] === 'Frame')
                        {
                            txt = txt + '<FigureIFrame>';
							txt = txt + '<iframe ';
                            if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                txt = txt + 'id="' + this.dataParameter[i][j][2] +'" ';
                            if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                txt = txt + 'class="' + this.dataParameter[i][j][3] +'" ';

                            if (this.dataParameter[i][j].length > 0 && this.dataParameter[i][j][0] > 0)
                                txt = txt + 'width="' + this.dataParameter[i][j][0] +'" ';
                            if (this.dataParameter[i][j].length > 1 && this.dataParameter[i][j][1] > 0)
                                txt = txt + 'height="' + this.dataParameter[i][j][1] +'" ';

		                    txt = txt + ' src="' + this.data[numberCatalog][0] + '/' + this.data[i][j] + '" ';

							txt = txt + '>';

							txt = txt + '<p>Your browser does not support iframes.</p>';
							txt = txt + '</iframe>';
                            txt = txt + '</FigureIFrame>';

                        }

					
                    if (this.dataName[i] === 'Generate')
                    {
                        if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                        {
                            if (this.dataParameter[i][j].length > 9 && typeof this.dataParameter[i][j][9] !== 'undefined' && this.dataParameter[i][j][9] !== null && this.dataParameter[i][j][9] === 'svg')
                            {
                                txt = txt + '<SvgObject id="' + this.data[i][j] + '"';
/*                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 1)
                                {
                                    txt = txt + ' width="'+ this.dataParameter[i][j][0] + '" height="' + this.dataParameter[i][j][1] + '" ';
                                }*/
                                txt = txt + '>';
/*                                if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                {
                                    tabObj = this.dataParameter[i][j][2];
                                    if (typeof tabObj !== 'undefined' && tabObj !== null)
                                    {
                                        ctx = objM.newObject('TDrawSvgContext');
                                        id = this.data[i][j];
                                        if (typeof id !== 'undefined' && id !== null)
                                        {
                                            matrix = objM.newObject('TMatrixTransformation3D');
                                            matrix2 = objM.newObject('TMatrixTransformation3D');
//                                            matrix.SetScaleMatrix3D();
                                            scaleX = this.dataParameter[i][j][0]/this.dataParameter[i][j][3];
                                            scaleY = -this.dataParameter[i][j][1]/this.dataParameter[i][j][4];
                                            scaleZ = this.dataParameter[i][j][5];
                                            matrix.SetScaleMatrix3D(scaleX,scaleY,scaleZ);
                                            matrix2.SetTranslationMatrix(-this.dataParameter[i][j][6],this.dataParameter[i][j][7],this.dataParameter[i][j][8]);
                                            matrix.MatrixMultiplication(matrix2);
                                            ctx.SetTransformation(matrix);
                                            for (k = 0;k < tabObj.length;k++)
                                            {
                                                obj = tabObj[k];
                                                if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                                {
                                                    obj.DrawFigure(ctx);
                                                }
                                            }
                                            txt = txt + ctx.GetContext();
                                        }
                                    }

                                    
                                    //                                    if (this.dataParameter[i][j])
                                }*/
                                txt = txt + '</SvgObject>';
                            }else
                            {
                                txt = txt + '<canvas id="' + this.data[i][j] + '"';
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 1)
                                {
                                    txt = txt + ' width="'+ this.dataParameter[i][j][0] + '" height="' + this.dataParameter[i][j][1] + '" ';
                                }
                                txt = txt + '>';
                                txt = txt + '</canvas>';
                            }
                        }
                    }                    
                    if (this.dataName[i] === 'GenerateThree')
                    {
                        if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                        {
                            txt = txt + '<div style="display: inline-flex">';
                            txt = txt + '<div id="' + this.data[i][j] + '" ';
                            txt = txt + ' >';
                            txt = txt + '</div>';
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 16)
                            {
                                var tmp = this.dataParameter[i][j][16];
                                if (typeof tmp !== 'undefined' && tmp !== null && tmp.length > 0)
                                {
                                    txt = txt + '<div style="text-align:center;font-size: 10pt">';
                                    if (tmp.length > 0 && typeof tmp[2] !== 'undefined' && tmp[2] !== null && tmp[2].IsType('TActionThreeRotateButton'))
                                        txt = txt + '<button id="' + tmp[2].GetId() + '">↑</button><br>';
                                    if (tmp.length > 0 && typeof tmp[0] !== 'undefined' && tmp[0] !== null && tmp[0].IsType('TActionThreeRotateButton'))
                                        txt = txt + '<button id="' + tmp[0].GetId() + '">←</button>';
                                    if (tmp.length > 2 && typeof tmp[1] !== 'undefined' && tmp[1] !== null && tmp[1].IsType('TActionThreeRotateButton'))
                                        txt = txt + '<button id="' + tmp[1].GetId() + '">→</button><br>';
                                    if (tmp.length > 3 && typeof tmp[3] !== 'undefined' && tmp[3] !== null && tmp[3].IsType('TActionThreeRotateButton'))
                                        txt = txt + '<button id="' + tmp[3].GetId() + '">↓</button>';
                                    txt = txt + '</div>';
                                }
                            }
                            txt = txt + '</div>';
                        }
                    }                    
                    if (this.dataName[i] === 'GenerateCanvas')
                    {
                        txt = txt + '<canvas id="' + this.data[i][j] + '"';
                        if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 1)
                        {
                            txt = txt + ' width="'+ this.dataParameter[i][j][0] + '" height="' + this.dataParameter[i][j][1] + '" ';
                        }
                        if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 16)
                            txt = txt + ' class="'+ this.dataParameter[i][j][16] + '" ';
                        txt = txt + '>';
                        txt = txt + '</canvas>';                        
                    }
                    if (this.dataName[i] === 'Timer')
                    {
                        if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null && this.data[i][j].IsType('TTimer'))
                        {
                            this.data[i][j].Start();
                        }
                    }
                    if (this.dataName[i] === 'TableShow' || this.dataName[i] === 'TableEdit')
                    {
                        if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 1)
                            if (typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                if (typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                {
                                    if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                        style = this.dataParameter[i][j][2];
                                    else
                                        style = null;
                                    var lineWidth;
                                    if (this.dataParameter[i][j].length > 14 && typeof this.dataParameter[i][j][14] !== 'undefined' && this.dataParameter[i][j][14] !== null)
                                        lineWidth = this.dataParameter[i][j][14];
                                    else
                                        lineWidth = null;
                                    var id = this.dataParameter[i][j][0];
                                    var data = this.dataParameter[i][j][1];
                                    var ii,jj;
                                    txt = txt + '<table id="' + id + '" ';
                                    if (style !== null)
                                        txt = txt + ' class="slide' + style + '" ';                                    
                                    txt = txt + '>';
                                    var w;
                                    if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                                        w = this.dataParameter[i][j][4];
                                    else
                                        w = null;
                                    var h;
                                    if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null)
                                        h = this.dataParameter[i][j][5];
                                    else
                                        h = null;
                                    var mincolour;
                                    if (this.dataParameter[i][j].length > 6 && typeof this.dataParameter[i][j][6] !== 'undefined' && this.dataParameter[i][j][6] !== null)
                                        mincolour = this.dataParameter[i][j][6];
                                    else
                                        mincolour = null;
                                    var maxcolour;
                                    if (this.dataParameter[i][j].length > 7 && typeof this.dataParameter[i][j][7] !== 'undefined' && this.dataParameter[i][j][7] !== null)
                                        maxcolour = this.dataParameter[i][j][7];
                                    else
                                        maxcolour = null;
                                    var minValue;
                                    if (this.dataParameter[i][j].length > 8 && typeof this.dataParameter[i][j][8] !== 'undefined' && this.dataParameter[i][j][8] !== null)
                                        minValue = this.dataParameter[i][j][8];
                                    else
                                        minValue = null;
                                    var maxValue;
                                    if (this.dataParameter[i][j].length > 9 && typeof this.dataParameter[i][j][9] !== 'undefined' && this.dataParameter[i][j][9] !== null)
                                        maxValue = this.dataParameter[i][j][9];
                                    else
                                        maxValue = null;
                                    var minColourTextValue;
                                    if (this.dataParameter[i][j].length > 10 && typeof this.dataParameter[i][j][10] !== 'undefined' && this.dataParameter[i][j][10] !== null)
                                        minColourTextValue = this.dataParameter[i][j][10];
                                    else
                                        minColourTextValue = null;
                                    var maxColourTextValue;
                                    if (this.dataParameter[i][j].length > 11 && typeof this.dataParameter[i][j][11] !== 'undefined' && this.dataParameter[i][j][11] !== null)
                                        maxColourTextValue = this.dataParameter[i][j][11];
                                    else
                                        maxColourTextValue = null;
                                    var alignTextX;
                                    if (this.dataParameter[i][j].length > 12 && typeof this.dataParameter[i][j][12] !== 'undefined' && this.dataParameter[i][j][12] !== null)
                                        alignTextX = this.dataParameter[i][j][12];
                                    else
                                        alignTextX = null;
                                    var alignTextY;
                                    if (this.dataParameter[i][j].length > 13 && typeof this.dataParameter[i][j][13] !== 'undefined' && this.dataParameter[i][j][13] !== null)
                                        alignTextY = this.dataParameter[i][j][13];
                                    else
                                        alignTextY = null;
                                    var colourStyle = null;
                                    if (this.dataParameter[i][j].length > 16 && typeof this.dataParameter[i][j][16] !== 'undefined' && this.dataParameter[i][j][16] !== null)
                                        colourStyle = this.dataParameter[i][j][16];
                                    var colourMap = null;
                                    if (this.dataParameter[i][j].length > 17 && typeof this.dataParameter[i][j][17] !== 'undefined' && this.dataParameter[i][j][17] !== null)
                                        colourMap = this.dataParameter[i][j][17];
                                    var colourMapMin = null;
                                    if (this.dataParameter[i][j].length > 18 && typeof this.dataParameter[i][j][18] !== 'undefined' && this.dataParameter[i][j][18] !== null)
                                        colourMapMin = this.dataParameter[i][j][18];
                                    var colourMapMax = null;
                                    if (this.dataParameter[i][j].length > 19 && typeof this.dataParameter[i][j][19] !== 'undefined' && this.dataParameter[i][j][19] !== null)
                                        colourMapMax = this.dataParameter[i][j][19];
                                    var textSize;
                                    if (this.dataParameter[i][j].length > 22 && typeof this.dataParameter[i][j][22] !== 'undefined' && this.dataParameter[i][j][22] !== null)
                                        textSize = this.dataParameter[i][j][22];
                                    var colourTmp = null,colourTmp2 = null,YN = false,YN2 = false,k;
                                    for (ii = 0;ii < data.length;ii++)
                                    {
                                        txt = txt + '<tr ';
                                        if (h !== null)
                                            txt = txt + 'style="height:' + h + 'px"';
                                        txt = txt + '>';
                                        for(jj = 0;jj < data[ii].length;jj++)
                                        {
                                            colourTmp = null;
                                            colourTmp2 = null;
                                            var tmp_data;
                                            if (this.dataParameter[i][j].length > 15 && typeof this.dataParameter[i][j][15] !== 'undefined' && this.dataParameter[i][j][15] !== null && this.dataParameter[i][j][15]) 
                                                tmp_data = Hex2Numeric(data[ii][jj]);
                                            else
                                                tmp_data = data[ii][jj];
                                            if (colourStyle === 'colour24bit')
                                            {
                                                colourTmp = objM.newObject('TColourRGBA');
                                                var r = Math.floor(tmp_data/(256*256));
                                                var g = Math.floor((tmp_data & (255*256))/256);
                                                var b = Math.floor(tmp_data & 255);
                                                if (colourTmp !== null)
                                                    colourTmp.SetColourRGBA(Math.floor(tmp_data/(256*256))/255,Math.floor((tmp_data & (255*256))/256)/255,Math.floor(tmp_data & 255)/255,1);
                                            }else
                                            {
                                                var tmp_data;
                                                if (this.dataParameter[i][j].length > 15 && typeof this.dataParameter[i][j][15] !== 'undefined' && this.dataParameter[i][j][15] !== null && this.dataParameter[i][j][15]) 
                                                    tmp_data = Hex2Numeric(data[ii][jj]);
                                                else
                                                    tmp_data = data[ii][jj];
                                                if (minValue !== null && maxValue !== null)
                                                {
                                                    var tmpValue = (tmp_data - minValue)/(maxValue - minValue);
                                                    if (mincolour !== null && maxcolour !== null)
                                                    {
                                                        colourTmp = maxcolour.MeanColour(tmpValue,mincolour);
                                                    }
                                                    if (minColourTextValue !== null && maxColourTextValue !== null)
                                                    {
                                                        if (tmpValue >= 0.5)
                                                            colourTmp2 = maxColourTextValue;
                                                        else
                                                            colourTmp2 = minColourTextValue;
                                                    }
                                                }
                                                if (colourMap !== null && colourMapMin !== null && colourMapMax !== null)
                                                {
                                                    for (k = 0;k < colourMap.length;k++)
                                                    {
                                                        if (tmp_data >= colourMapMin[k] && tmp_data <= colourMapMax[k])
                                                        {
                                                            colourTmp = colourMap[k];
                                                            colourTmp2 = maxColourTextValue;
                                                            break;
                                                        }
                                                    }
                                                }
                                            }
                                            YN = false;YN2 = false;
                                            txt = txt + '<td style="';
                                            if (w !== null && this.dataName[i] === 'TableShow')
                                            {
                                                txt = txt + 'width:' + w + 'px';
                                                YN = true;
                                            }
                                            if (lineWidth !== null)
                                            {
                                                if (YN)
                                                    txt = txt + ';';
                                                txt = txt + 'border:' + lineWidth +'px solid black';
                                                YN = true;
                                            }
                                            if (alignTextX !== null)
                                            {
                                                if (YN)
                                                    txt = txt + ';';
                                                txt = txt + 'text-align:' + alignTextX;
                                                YN = true;
                                            }
                                            txt = txt + '">';
                                            if (this.dataName[i] === 'TableShow')
                                            {
                                                txt = txt + '<div style="';
                                                if (colourTmp !== null)
                                                {
                                                    if (YN2)
                                                        txt = txt + ';';
                                                    txt = txt + 'background-color: #' + colourTmp.Get24bitColourHex();
                                                    YN2 = true;
                                                }
                                                if (colourTmp2 !== null)
                                                {
                                                    if (YN)
                                                        txt = txt + ';';
                                                    txt = txt + 'color: #' + colourTmp2.Get24bitColourHex();
                                                    YN = true;
                                                }
                                                txt = txt + '" ';
                                                if (id !== 'undefined' && id !== null)
                                                    txt = txt + ' id="' + id + '_' + ii + '_' + jj + '" ' ;
                                                if (colourStyle === 'colour24bit')
                                                {
                                                    txt = txt + '><span style="color: red">' + data[ii][jj].substring(0,2) + '</span>';
                                                    txt = txt + '<span style="color: green">' + data[ii][jj].substring(2,4) + '</span>';
                                                    txt = txt + '<span style="color: blue">' + data[ii][jj].substring(4,6) + '</span></div></td>';
                                                }
                                                else
                                                    txt = txt + '>' +  data[ii][jj] + '</div></td>';
                                            }else
                                            {
                                                if (colourStyle === 'colour24bit')
                                                {
                                                    txt = txt  + '<div contenteditable="true" ';
                                                    if (id !== 'undefined' && id !== null)
                                                        txt = txt + ' id="' + id + '_' + ii + '_' + jj + '" ' ;
                                                    txt = txt + ' style="';
                                                    if (colourTmp !== null)
                                                    {
                                                        if (YN2)
                                                            txt = txt + ';';
                                                        txt = txt + 'background-color: #' + colourTmp.Get24bitColourHex();
                                                        YN2 = true;
                                                    }
                                                    if (w !== null)
                                                    {
                                                        if (YN2)
                                                            txt = txt + ';';
                                                        txt = txt + 'width:' + w + 'pt' ;
                                                        YN2 = true;
                                                    }
                                                    if (alignTextX !== null)
                                                    {
                                                        if (YN2)
                                                            txt = txt + ';';
                                                        txt = txt + 'text-align:' + alignTextX;
                                                        YN2 = true;
                                                    }
                                                    if (colourTmp2 !== null)
                                                    {
                                                        if (YN)
                                                            txt = txt + ';';
                                                        txt = txt + 'color: #' + colourTmp2.Get24bitColourHex();
                                                        YN = true;
                                                    }
                                                    txt = txt + '"';
                                                    txt = txt + '>';
                                                    txt = txt + '<span style="color: red">' + data[ii][jj].substring(0,2) + '</span>';
                                                    txt = txt + '<span style="color: green">' + data[ii][jj].substring(2,4) + '</span>';
                                                    txt = txt + '<span style="color: blue">' + data[ii][jj].substring(4,6) + '</span>';
                                                    txt = txt + '</div></td>';
                                                }else
                                                {
                                                    txt = txt  + '<input type="text" value="' + data[ii][jj] + '"';
                                                    if (w !== null)
                                                        txt = txt + ' size="' + w + '" ' ;
                                                    if (id !== 'undefined' && id !== null)
                                                        txt = txt + ' id="' + id + '_' + ii + '_' + jj + '" ' ;
                                                    txt = txt + ' style="';
                                                    if (colourTmp !== null)
                                                    {
                                                        if (YN2)
                                                            txt = txt + ';';
                                                        txt = txt + 'background-color: #' + colourTmp.Get24bitColourHex();
                                                        YN2 = true;
                                                    }
                                                    if (alignTextX !== null)
                                                    {
                                                        if (YN2)
                                                            txt = txt + ';';
                                                        txt = txt + 'text-align:' + alignTextX;
                                                        YN2 = true;
                                                    }
                                                    if (textSize !== null)
                                                    {
                                                        if (YN2)
                                                            txt = txt + ';';
                                                        txt = txt + 'font-size:' + textSize + 'px';
                                                        YN2 = true;
                                                    }
                                                    if (lineWidth !== null || lineWidth === 0)
                                                    {
                                                        if (YN2)
                                                            txt = txt + ';';
                                                        txt = txt + 'border:none';
                                                        YN2 = true;
                                                    }
                                                    if (colourTmp2 !== null)
                                                    {
                                                        if (YN)
                                                            txt = txt + ';';
                                                        txt = txt + 'color: #' + colourTmp2.Get24bitColourHex();
                                                        YN = true;
                                                    }
                                                    txt = txt + '"';
                                                    txt = txt + '></td>';
                                                }

                                            }
                                        }
                                        txt = txt + '</tr>';
                                    }
                                    txt = txt + '</table>';
                                }

                    }
                    if (this.dataName[i] === 'Table')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            tableYN = true;
                            var styleYN = false;
                            
                            txt = txt + '<p>';
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                style = this.dataParameter[i][j][3];
                            else
                                style = null;
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                txt = txt + '<table id="' + this.dataParameter[i][j][0] + '"';
                            else
                                txt = txt + '<table';
                            txt = txt + ' style="';
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 9 && this.dataParameter[i][j][9] !== null)
                            {
                                txt = txt + 'width:' + this.dataParameter[i][j][9];
                                styleYN = true;
                            }
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 10 && this.dataParameter[i][j][10] !== null)
                            {
                                if (styleYN)
                                    txt = txt + ';';
                                txt = txt + 'font-size:' + this.dataParameter[i][j][10];
                                styleYN = true;
                            }
                            txt = txt + '"';
                            if (style !== null)
                                txt = txt + ' class="' + style + '">';                                    
                            else
                                txt = txt + '>';                                    
                                
                        }
                        if (this.data[i][j] === 'Stop')
                        {
                            tableYN = false;
                            style = null;
                            txt = txt + '</table>';
                            txt = txt + '</p>';
                        }
                    }                    
                    if (this.dataName[i] === 'tr')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            txt = txt + '<tr';
                            if (style !== null)
                                txt = txt + ' class="' + style + '">';
                            else
                                txt = txt + '>';                                    

                            
                        }
                        if (this.data[i][j] === 'Stop')
                            txt = txt + '</tr>';
                    }                    
                    if (this.dataName[i] === 'th' || this.dataName[i] === 'th2' )
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            var oldStyle = style;
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                style = this.dataParameter[i][j][1];
                            txt = txt + '<th';
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                txt = txt + ' id="' + this.dataParameter[i][j][0] + '"';

                            txt = txt + ' style="';
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 2 && this.dataParameter[i][j][2] !== null)
                            {
                                txt = txt + 'width:' + this.dataParameter[i][j][2];
                                styleYN = true;
                            }
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 3 && this.dataParameter[i][j][3] !== null)
                            {
                                if (styleYN)
                                    txt = txt + ';';
                                txt = txt + 'font-size:' + this.dataParameter[i][j][3];
                                styleYN = true;
                            }
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 6 && this.dataParameter[i][j][6] !== null && this.dataParameter[i][j][6].IsType('TColourTXT'))
                            {
                                if (styleYN)
                                    txt = txt + ';';
                                var r = 255*this.dataParameter[i][j][6].GetR();
                                var g = 255*this.dataParameter[i][j][6].GetG();
                                var b = 255*this.dataParameter[i][j][6].GetB();
                                txt = txt + 'background-color:rgb(' + r + ',' +  g + ',' +  b + ')';
                                styleYN = true;
                            }
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 7 && this.dataParameter[i][j][7] !== null && this.dataParameter[i][j][7].IsType('TColourTXT'))
                            {
                                if (styleYN)
                                    txt = txt + ';';
                                var r = 255*this.dataParameter[i][j][7].GetR();
                                var g = 255*this.dataParameter[i][j][7].GetG();
                                var b = 255*this.dataParameter[i][j][7].GetB();
                                txt = txt + 'color:rgb(' + r + ',' +  g + ',' +  b + ')';
                                styleYN = true;
                            }
                            txt = txt + '"';
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 4 && this.dataParameter[i][j][4] !== null && this.dataParameter[i][j][4] > 0)
                                txt = txt + ' rowspan="' + this.dataParameter[i][j][4] + '"';
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 5 && this.dataParameter[i][j][5] !== null && this.dataParameter[i][j][5] > 0)
                                txt = txt + ' colspan="' + this.dataParameter[i][j][5] + '"';
                            if (style !== null)
                                txt = txt + ' class="' + style + '">';
                            else
                                txt = txt + '>';
                            style = oldStyle;
                        }
                        if (this.data[i][j] === 'Stop')
                            txt = txt + '</th>';
                    }                    
                    if (this.dataName[i] === 'td' )
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            var oldStyle = style;
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                style = this.dataParameter[i][j][1];
                            txt = txt + '<td';
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                txt = txt + ' id="' + this.dataParameter[i][j][0] + '"';
                            txt = txt + ' style="';
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 2 && this.dataParameter[i][j][2] !== null)
                            {
                                txt = txt + 'width:' + this.dataParameter[i][j][2];
                                styleYN = true;
                            }
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 3 && this.dataParameter[i][j][3] !== null)
                            {
                                if (styleYN)
                                    txt = txt + ';';
                                txt = txt + 'font-size:' + this.dataParameter[i][j][3];
                                styleYN = true;
                            }
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 6 && this.dataParameter[i][j][6] !== null && this.dataParameter[i][j][6].IsType('TColourTXT'))
                            {
                                if (styleYN)
                                    txt = txt + ';';
                                var r = 255*this.dataParameter[i][j][6].GetR();
                                var g = 255*this.dataParameter[i][j][6].GetG();
                                var b = 255*this.dataParameter[i][j][6].GetB();
                                txt = txt + 'background-color:rgb(' + r + ',' +  g + ',' +  b + ')';
                                styleYN = true;
                            }
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 7 && this.dataParameter[i][j][7] !== null && this.dataParameter[i][j][7].IsType('TColourTXT'))
                            {
                                if (styleYN)
                                    txt = txt + ';';
                                var r = 255*this.dataParameter[i][j][7].GetR();
                                var g = 255*this.dataParameter[i][j][7].GetG();
                                var b = 255*this.dataParameter[i][j][7].GetB();
                                txt = txt + 'color:rgb(' + r + ',' +  g + ',' +  b + ')';
                                styleYN = true;
                            }
                            txt = txt + '"';
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 4 && this.dataParameter[i][j][4] !== null && this.dataParameter[i][j][4] > 0)
                                txt = txt + ' rowspan="' + this.dataParameter[i][j][4] + '"';
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 5 && this.dataParameter[i][j][5] !== null && this.dataParameter[i][j][5] > 0)
                                txt = txt + ' colspan="' + this.dataParameter[i][j][5] + '"';
                            if (style !== null)
                                txt = txt + ' class="' + style + '">';
                            else
                                txt = txt + '>';
                            style = oldStyle;
                        }
                        if (this.data[i][j] === 'Stop')
                            txt = txt + '</td>';
                    }                    
                    if (this.dataName[i] === 'Equation')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                numberEquation = this.dataParameter[i][j][1];
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                txt = txt + '<table id="' + this.dataParameter[i][j][0] + '"';
                            else
                                txt = txt + '<table';
                            txt = txt + ' style="width:100%">';                                    
                            txt = txt + '<tr>';
//                            txt = txt + '<td style="text-align:center">';
                            txt = txt + '<td class="EquationAlign">';
                            
                            txt = txt + '\\(';
//                            tableYN = true;
/*                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                style = this.dataParameter[i][j][3];
                            else
                                style = null;
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                txt = txt + '<table id="' + this.dataParameter[i][j][0] + '"';
                            else
                                txt = txt + '<table';
                            if (style !== null)
                                txt = txt + ' class="' + style + '">';                                    
                            else
                                txt = txt + '>';*/
                                
                        }
                        if (this.data[i][j] === 'Stop')
                        {
                            txt = txt + '\\)';
                            txt = txt + '</td>';
                            txt = txt + '<td style="text-align:left" class="EquationNumeration">';
                            
                            if (typeof numberEquation !== 'undefined' && numberEquation !== null && numberEquation.length > 0)
                            {
                                txt = txt  + '(';
                                txt = txt + numberEquation[0];
                                for(k = 1;k < numberEquation.length;k++)
                                {
                                    txt = txt + '.' + numberEquation[k];
                                }
                                txt = txt  + ')';
                            }
                            
                            txt = txt + '</td>';
                            txt = txt + '</tr>';
                            txt = txt + '</table>';
                            numberEquation = null;
/*                            tableYN = false;
                            style = null;
                            txt = txt + '</table>';
                            txt = txt + '</p>';*/
                        }
                    }                    
                    if (this.dataName[i] === 'SubEquation')
                    {
                        txt = txt + this.data[i][j];
                    }
                    
                    if (this.dataName[i] === 'Paragraph' && enumYN === 0 && itemizeYN === 0 && figureYN === 0 && tableYN === false)
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                txt = txt + '<p class="' + this.dataParameter[i][j][1] + '">';
                            else
                                txt = txt + '<p>';
                        }
                        if (this.data[i][j] === 'Stop')
                            txt = txt + '</p>';
                    }
                    if (this.dataName[i] === 'PT')
                        txt = txt + this.data[i][j];
                    if (this.dataName[i] === 'Symbol')
                    {
                        if (this.data[i][j] === 'Dash')
                            txt = txt +'–';
                        if (this.data[i][j] === 'Hash')
                            txt = txt +'#';
                        if (this.data[i][j] === 'Underscore')
                            txt = txt +'_';
                        if (this.data[i][j] === 'Backslash')
                            txt = txt +'\\';
                        if (this.data[i][j] === 'Br' || this.data[i][j] === 'br')
                            txt = txt +'<br>';
                        if (this.data[i][j] === 'Space')
                            txt = txt +'&nbsp;';
                        if (this.data[i][j] === 'Less')
                            txt = txt +'&lt;';
                        if (this.data[i][j] === 'Greater')
                            txt = txt +'&gt;';
                        if (this.data[i][j] === 'Percent')
                            txt = txt +'%';
                    }
                    if (this.dataName[i] === 'SpaceLength')
                    {
                        if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                        {
                            txt = txt + '<span style="display:inline-block; width: ' + this.data[i][j] + ';"></span>';
                        }
                    }
                    if (this.dataName[i] === 'FormStart')
                    {
                        txt = txt + '<form>';
                        formStart = true;
                    }
                    if (this.dataName[i] === 'FormStop')
                    {
                        txt = txt + '</form>';
                        formStart = false;
                    }
                    if (this.dataName[i] === 'RadioButton')
                    {
                        if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                        {
                            if (formStart === false)
                                txt = txt + '<br>';
                            formStart = false;
                            txt = txt + '<input type="radio" id="' + this.data[i][j] + '" ';
                            if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                txt = txt + 'name="' + this.dataParameter[i][j][2] + '" ';
                            if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                            {
                                if (this.dataParameter[i][j][3])
                                    txt = txt + 'checked ';
                            }
                            if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                            {
                                if (typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null)
                                    txt = txt + ' onclick="' + this.dataParameter[i][j][4] + "(this,event,'" + this.dataParameter[i][j][5] + "'" + ')"';
                            }
                            txt = txt + '> ';
                            
                        }
                    }
                    if (this.dataName[i] === 'CheckBox')
                    {
                        if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                        {
                            if (formStart === false)
                                txt = txt + '<br>';
                            formStart = false;
                            txt = txt + '<input type="checkbox" id="' + this.data[i][j] + '" ';
                            if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                txt = txt + 'name="' + this.dataParameter[i][j][2] + '" ';
                            if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                            {
                                if (this.dataParameter[i][j][3])
                                    txt = txt + 'checked ';
                            }
                            if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                            {
                                if (typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null)
                                    txt = txt + ' onclick="' + this.dataParameter[i][j][4] + "(this,event,'" + this.dataParameter[i][j][5] + "'" + ')"';
                            }
                            txt = txt + '> ';
                            
                        }
                    }
                    if (this.dataName[i] === 'Rectangle')
                    {
                        if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                            if (typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                            {
                                txt = txt + '<svg style="background:#' + this.dataParameter[i][j][2].Get24bitColourHex() + ';width:' + this.dataParameter[i][j][0] + 'ex;height:' + this.dataParameter[i][j][1] + 'ex"></svg>';
                            }
                    }

                    if (this.dataName[i] === 'Edit')
                    {
                        if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                        {
                            if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                            {
                                txt = txt + '<input type="text" id="' + this.data[i][j] + '" value="' + this.dataParameter[i][j][0] + '" ';
                                if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null && this.dataParameter[i][j][1] > 0)
                                    txt = txt + 'size="' + this.dataParameter[i][j][1] + '"';
                                if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                    txt = txt + ' class="' + this.dataParameter[i][j][2] + '"';
                                txt = txt + ' style="';
                                if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null && this.dataParameter[i][j][3].IsType('TColourRGBA'))
                                    txt = txt + 'background-color:#' + this.dataParameter[i][j][3].Get24bitColourHex() + ';';
                                if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null && this.dataParameter[i][j][4].IsType('TColourRGBA'))
                                    txt = txt + 'color:#' + this.dataParameter[i][j][4].Get24bitColourHex() + ';';
                                txt = txt + '">';
                            }
                        }
                    }
                    if (this.dataName[i] === 'TextArea')
                    {
                        if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                        {
                            if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                            {
                                txt = txt + '<textarea id="' + this.data[i][j] + '" ';
                                if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null && this.dataParameter[i][j][1] > 0)
                                    txt = txt + 'cols="' + this.dataParameter[i][j][1] + '"';
                                if (this.dataParameter[i][j].length > 10 && typeof this.dataParameter[i][j][10] !== 'undefined' && this.dataParameter[i][j][10] !== null && this.dataParameter[i][j][10] > 0)
                                    txt = txt + 'rows="' + this.dataParameter[i][j][10] + '"';
                                if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                    txt = txt + ' class="' + this.dataParameter[i][j][2] + '"';
                                if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null)
                                    txt = txt + ' onchange="' + this.dataParameter[i][j][5] + "(this,event,'" + this.data[i][j] + "'" + ')"';
                                if (this.dataParameter[i][j].length > 6 && typeof this.dataParameter[i][j][6] !== 'undefined' && this.dataParameter[i][j][6] !== null)
                                    txt = txt + ' onkeypress="' + this.dataParameter[i][j][6] + "(this,event,'" + this.data[i][j] + "'" + ')"';
                                if (this.dataParameter[i][j].length > 7 && typeof this.dataParameter[i][j][7] !== 'undefined' && this.dataParameter[i][j][7] !== null)
                                    txt = txt + ' onkeydown="' + this.dataParameter[i][j][7] + "(this,event,'" + this.data[i][j] + "'" + ')"';
                                if (this.dataParameter[i][j].length > 8 && typeof this.dataParameter[i][j][8] !== 'undefined' && this.dataParameter[i][j][8] !== null)
                                    txt = txt + ' onkeyup="' + this.dataParameter[i][j][8] + "(this,event,'" + this.data[i][j] + "'" + ')"';
                                txt = txt + ' style="';
                                if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null && this.dataParameter[i][j][3].IsType('TColourRGBA'))
                                    txt = txt + 'background-color:#' + this.dataParameter[i][j][3].Get24bitColourHex() + ';';
                                if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null && this.dataParameter[i][j][4].IsType('TColourRGBA'))
                                    txt = txt + 'color:#' + this.dataParameter[i][j][4].Get24bitColourHex() + ';';
                                txt = txt + '">';
                                txt = txt + this.dataParameter[i][j][0];
                                txt = txt + '</textarea>';
                            }
                        }
                    }
                    if (this.dataName[i] === 'Button')
                    {
                        if (this.dataParameter[i][j].length > 0)// && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                        {
                            if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                            {
                                txt = txt + '<button ';
                                txt = txt + 'id="' + this.data[i][j] + '" ';
                                if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                    txt = txt + ' class="' + this.dataParameter[i][j][0] + '"';
                                if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                                    txt = txt + ' onclick="' + this.dataParameter[i][j][4] + '(this,event)"';
                                txt = txt + ' style="';
                                if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null && this.dataParameter[i][j][1].IsType('TColourRGBA'))
                                    txt = txt + 'background-color:#' + this.dataParameter[i][j][1].Get24bitColourHex() + ';';
                                if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null && this.dataParameter[i][j][2].IsType('TColourRGBA'))
                                    txt = txt + 'color:#' + this.dataParameter[i][j][2].Get24bitColourHex() + ';';
                                txt = txt + '">';
                                if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                    txt = txt + this.dataParameter[i][j][3];
                                txt = txt + '</button>';
                            }
                        }
                    }
                    if (this.dataName[i] === 'ButtonLoadImage')
                    {
                        if (this.dataParameter[i][j].length > 0)// && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                        {
                            if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                            {
                                txt = txt + '<input type="file" ';
                                txt = txt + 'id="' + this.data[i][j] + '" ';
                                txt = txt + '>';
//                                    txt = txt + '<div id="result" class="result"><p>This demo works only in browsers with support for the <a href="https://developer.mozilla.org/en/DOM/window.URL">URL</a> or <a href="https://developer.mozilla.org/en/DOM/FileReader">FileReader</a> API.</p></div>';

//                                    var txt2 = "$('#" + this.data[i][j] + "').on('change', dropChangeHandlerLoadFile)";
//                                    eval(txt2);

//                                    dropChangeHandlerLoadFile
/*                                    txt = txt + '<button ';
                                txt = txt + 'id="' + this.data[i][j] + '" ';
                                if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                    txt = txt + ' class="' + this.dataParameter[i][j][0] + '"';
                                if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                                    txt = txt + ' onclick="' + this.dataParameter[i][j][4] + '(this,event)"';
                                txt = txt + ' style="';
                                if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null && this.dataParameter[i][j][1].IsType('TColourRGBA'))
                                    txt = txt + 'background-color:#' + this.dataParameter[i][j][1].Get24bitColourHex() + ';';
                                if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null && this.dataParameter[i][j][2].IsType('TColourRGBA'))
                                    txt = txt + 'color:#' + this.dataParameter[i][j][2].Get24bitColourHex() + ';';
                                txt = txt + '">';
                                if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                    txt = txt + this.dataParameter[i][j][3];
                                txt = txt + '</button>';*/
                            }
                        }
                    }
                    if (this.dataName[i] === 'Slider')
                    {
                        if (this.dataParameter[i][j].length > 0)// && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                        {
                            if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                            {
                                txt = txt + '<input type="range" ';
                                txt = txt + 'id="' + this.data[i][j] + '" ';
                                if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                    txt = txt + ' class="' + this.dataParameter[i][j][0] + '"';
                                if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                    txt = txt + ' value="' + this.dataParameter[i][j][1] + '"';
                                if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                    txt = txt + ' min="' + this.dataParameter[i][j][2] + '"';
                                if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                    txt = txt + ' max="' + this.dataParameter[i][j][3] + '"';
                                if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                                    txt = txt + ' step="' + this.dataParameter[i][j][4] + '"';
                                if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null)
                                    txt = txt + ' onclick="' + this.dataParameter[i][j][5] + '(this,event)"';
                                if (this.dataParameter[i][j].length > 8 && typeof this.dataParameter[i][j][8] !== 'undefined' && this.dataParameter[i][j][8] !== null)
                                    txt = txt + ' onchange="' + this.dataParameter[i][j][8] + '(this,event)"';
                                if (this.dataParameter[i][j].length > 6 && typeof this.dataParameter[i][j][6] !== 'undefined' && this.dataParameter[i][j][6] !== null)
                                    txt = txt + ' style="width: ' + this.dataParameter[i][j][6] + '"';
                                txt = txt + '>';
                            }
                        }
                    }
                    if (this.dataName[i] === 'ParagraphText')
                    {
                        if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined')// && this.dataParameter[i][j][0] !== null)
                        {
                            if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                            {
                                txt = txt + '<span id="' + this.data[i][j] + '" ';
                                if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                    txt = txt + ' class="' + this.dataParameter[i][j][2] + '"';
                                txt = txt + ' style="';
                                if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null && this.dataParameter[i][j][3].IsType('TColourRGBA'))
                                    txt = txt + 'background-color:#' + this.dataParameter[i][j][3].Get24bitColourHex() + ';';
                                if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null && this.dataParameter[i][j][4].IsType('TColourRGBA'))
                                    txt = txt + 'color:#' + this.dataParameter[i][j][4].Get24bitColourHex() + ';';
                                txt = txt + '">';
                                if (this.dataParameter[i][j][0] !== null)
                                    txt = txt + this.dataParameter[i][j][0];
                                txt = txt + '</span>';
                            }
                        }
                    }
                    if (this.dataName[i] === 'ParagraphImage')
                    {
                        if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                        {
                            if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                            {
                                txt = txt + '<img id="' + this.data[i][j] + '" ';
                                if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                    txt = txt + ' class="' + this.dataParameter[i][j][2] + '"';
                                if (this.dataParameter[i][j][0] !== null)
                                    txt = txt + ' src="' + this.dataParameter[i][j][0] + '"';
                                if ((typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null) || (typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null))
                                {
                                    txt = txt + ' style="';
                                    if (typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                    {
                                        txt = txt + 'width:' + this.dataParameter[i][j][3] + 'ex;';
                                    }
                                    if (typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                                    {
                                        txt = txt + 'height:' + this.dataParameter[i][j][4] + 'ex';
                                    }
                                    txt = txt + '" ';
                                }
                                txt = txt + '>';
                            }
                        }
                    }
                    if (this.dataName[i] === 'Emph')
                    {
                        if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null)
                        {
                            if (this.data[i][j] === 'Start' && this.dataParameter[i][j].length > 0)
                            {
                                if (typeof this.dataParameter[i][j][0]  !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                {
                                    tmp2 = parseInt(this.dataParameter[i][j][0]);
                                    if (tmp2 >= 0)
                                        txt = txt + '<Emph' + tmp2 + '>';
                                    else
                                    {
                                        if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1]  !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                            txt = txt + '<Emph class="' + this.dataParameter[i][j][1] + '">';
                                        else
                                            txt = txt + '<Emph>';
                                    }
                                }
                            }
                            if (this.data[i][j] === 'Stop')
                            {
                                tmp2 = parseInt(this.dataParameter[i][j]);
                                if (tmp2 >= 0)
                                    txt = txt + '</Emph' + tmp2 + '>';
                                else
                                    txt = txt + '</Emph>';
                            }
                        }
                    }
                    if (this.dataName[i] === 'Code')
                    {
                        if (this.data[i][j] === 'Start' && this.dataParameter[i][j].length > 0)
                        {
                            if (typeof this.dataParameter[i][j][0]  !== 'undefined' && this.dataParameter[i][j][0] !== null && this.dataParameter[i][j][0] >= 0)
                                txt = txt + '<Code' + this.dataParameter[i][j][0] + '>';
                            else
                            {
                                if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1]  !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                {
                                    txt = txt + '<Code class="' + this.dataParameter[i][j][1] + '">';                                    
                                }
                            }
                        }
                        if (this.data[i][j] === 'Stop')
                        {
                            if  (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j] >= 0)
                            {
                                tmp2 = parseInt(this.dataParameter[i][j]);
                                txt = txt + '</Code' + tmp2 + '>';
                            }else
                                txt = txt + '</Code>';
                        }
                    }
                    if (this.dataName[i] === 'Href')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            txt = txt + '<a href="';
                            if (this.dataParameter[i][j][0] === 'email')
                               txt = txt + 'mailto:';
                            txt = txt + this.dataParameter[i][j][1] + '" class="'+ this.dataParameter[i][j][0] + '"';
                            if (this.dataParameter[i][j][0] === 'file')
                                txt = txt + ' target="_blank" style="display: inline;"';
                            txt = txt + '>';
                        }
                        if (this.data[i][j] === 'Stop')
                            txt = txt + '</a>';
                    }
                    if (this.dataName[i] === 'LocalHref')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            txt = txt + '<a href="' + this.data[numberCatalog][0] + '/' ;
                            txt = txt + this.dataParameter[i][j][1] + '" class="'+ this.dataParameter[i][j][0] + '"';
                            if (this.dataParameter[i][j][0] === 'file')
                                txt = txt + ' target="_blank" style="display: inline;"';
                                txt = txt + ' onClick="window.location.assign(' + "'" +  tmpHref + '/' + this.data[numberCatalog][0] + '/' + this.dataParameter[i][j][1] + "'" + ");" + ' ">';
                        }
                        if (this.data[i][j] === 'Stop')
                            txt = txt + '</a>';
                    }
                    if (this.dataName[i] === 'PE')
                    {
                        if (this.data[i][j] === 'Start')
                            txt = txt + '\\(';                        
                        if (this.data[i][j] === 'Stop')
                            txt = txt + '\\)';                        
                    }
                }                
            }
        }
        return txt;
    };

};

THTMLParagraphs.prototype = new TGenerateHTML();

function TTeXParagraphs(){
    
    var type = 'TTeXParagraphs';
    TTeXParagraphs.prototype.InitConstructor = function(){
        TGenerateTeX.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();


    TTeXParagraphs.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TGenerateTeX.prototype.IsType.call(this,_type);
    };

    TTeXParagraphs.prototype.Init = function(_object){
        TGenerateTeX.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TTeXParagraphs'))
        {
        }
    };
    
    TTeXParagraphs.prototype.GetTXT = function(){
        var txt = '';
        if (this.GetSlide())
        {
        }else
        {
            var i,j,ii,currentLevel = 0,YN,enumYN = 0,itemizeYN = 0,figureLabel = '',paragraphEnterYN = true;
            var subfigureNumberYN = false,subfigureNumber,tmp,maxCol,numberCol,tableCaptionYN,tableLine = '',figureLabelYN;
            var numberCatalog = this.Find('ImageCatalog');
            var tabObj,ctx,id,matrix,matrix2,scaleX,scaleY,scaleZ,obj,k,lbraceFigure=false;
            var startRadioButtoEmph = false
            var objM = this.GetObjectManager();
            if (objM === null)
                return;
            
            for (i = 0;i < this.data.length;i++)
            {
                for (j = 0;j < this.data[i].length;j++)
                {
                    if (this.dataName[i] === 'Title')
                    {
                        currentLevel = this.dataParameter[i][j][0];
                        YN = true;
                        switch(parseInt(currentLevel))
                        {
                            case 0:
                                txt = txt + '\\chapter';
                                break;
                            case 1:
                                txt = txt + '\\section';
                                break;
                            case 2:
                                txt = txt + '\\subsection';
                                break;
                            case 3:
                                txt = txt + '\\subsubsection';
                                break;
                            case 4:
                                txt = txt + '\\paragraph';
                                break;
                            case 5:
                                txt = txt + '\\subparagraph';
                                break;
                            default:
                                YN = false;
                        }
                        if (YN)
                        {
                            txt = txt + '{' + this.data[i][j] + '}\n\n';
                            if (this.dataParameter[i][j][3] !== null)
                            {
                                switch(parseInt(currentLevel))
                                {
                                    case 0:
                                        txt = txt + '\\chaptermark{' + this.dataParameter[i][j][3] + '}\n\n';
                                        break;
                                }
                            }
                        }
                        
                    }
                    if (this.dataName[i] === 'Enum')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            txt = txt + '\\begin{enumerate}\n';
                            enumYN++;
                        }
                        if (this.data[i][j] === 'Stop')
                        {
                            txt = txt + '\\end{enumerate}\n\n';
                            enumYN--;
                            if (enumYN < 0)
                                enumYN = 0;
                        }
                    }
                    if (this.dataName[i] === 'Itemize')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            txt = txt + '\\begin{itemize}\n';
                            itemizeYN++;
                        }
                        if (this.data[i][j] === 'Stop')
                        {
                            txt = txt + '\\end{itemize}\n\n';
                            itemizeYN--;
                            if (itemizeYN < 0)
                                itemizeYN = 0;
                        }
                    }
                    if (this.dataName[i] === 'Item')
                    {
                        if (this.data[i][j] === 'Start')
                            txt = txt + '\\item ';
//                        if (this.data[i][j] === 'Stop')
//                            txt = txt + '</li>';                        
                    }
                    
                    if (this.dataName[i] === 'GenerateThree')
                    {
                        if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                        {
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 17)
                            {
//                                var tmp2 = this.dataParameter[i][j][17];
                                var tmp2 = this.imageCatalog;
                                if (subfigureNumberYN)
                                {
                                    txt = txt + '\\subfigure[)]{';
                                }
                                if (this.dataParameter[i][j].length > 18 && typeof this.dataParameter[i][j][18] !== 'undefined' && this.dataParameter[i][j][18] !== null)
                                {
                                    tmp = this.dataParameter[i][j][18]/100;
                                    txt = txt + '\\includegraphics[width='+ tmp + '\\linewidth]{' + tmp2 + '/'+ this.data[i][j] + '.png}';
                                }else
                                {
/*                                    if (this.dataParameter[i][j][1] > 0)
                                    {
                                        tmp = this.dataParameter[i][j][1];
                                        txt = txt + '\\includegraphics[height=' + tmp + 'mm]{' + tmp2 + '/' + this.data[i][j] + '.png}';
                                    }else
                                        txt = txt + '\\includegraphics{' + tmp2 + '/' + this.data[i][j] + '.png}';*/
                                }
                                if (subfigureNumberYN)
                                    txt = txt + '}\n';
                                else
                                    txt = txt + '\n';
                            }
                            
                            
/*                            txt = txt + '<div style="display: inline-flex">';
                            txt = txt + '<div id="' + this.data[i][j] + '" ';
                            txt = txt + ' >';
                            txt = txt + '</div>';
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 16)
                            {
                                var tmp = this.dataParameter[i][j][16];
                                if (typeof tmp !== 'undefined' && tmp !== null && tmp.length > 0)
                                {
                                    txt = txt + '<div style="text-align:center;font-size: 10pt">';
                                    if (tmp.length > 0 && typeof tmp[2] !== 'undefined' && tmp[2] !== null && tmp[2].IsType('TActionThreeRotateButton'))
                                        txt = txt + '<button id="' + tmp[2].GetId() + '">↑</button><br>';
                                    if (tmp.length > 0 && typeof tmp[0] !== 'undefined' && tmp[0] !== null && tmp[0].IsType('TActionThreeRotateButton'))
                                        txt = txt + '<button id="' + tmp[0].GetId() + '">←</button>';
                                    if (tmp.length > 2 && typeof tmp[1] !== 'undefined' && tmp[1] !== null && tmp[1].IsType('TActionThreeRotateButton'))
                                        txt = txt + '<button id="' + tmp[1].GetId() + '">→</button><br>';
                                    if (tmp.length > 3 && typeof tmp[3] !== 'undefined' && tmp[3] !== null && tmp[3].IsType('TActionThreeRotateButton'))
                                        txt = txt + '<button id="' + tmp[3].GetId() + '">↓</button>';
                                    txt = txt + '</div>';
                                }
                            }
                            txt = txt + '</div>';*/
                        }
                    }                    
                    if (this.dataName[i] === 'GenerateCanvas')
                    {
                        if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                        {
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null)
                            {
//                                var tmp2 = this.dataParameter[i][j][17];
                                var tmp2 = this.imageCatalog;
                                if (subfigureNumberYN)
                                {
                                    txt = txt + '\\subfigure[)]{';
                                }
                                if (this.dataParameter[i][j].length > 11 && typeof this.dataParameter[i][j][11] !== 'undefined' && this.dataParameter[i][j][11] !== null)
                                {
                                    tmp = this.dataParameter[i][j][11]/100;
                                    txt = txt + '\\includegraphics[width='+ tmp + '\\linewidth]{' + tmp2 + '/'+ this.data[i][j] + '.png}';
                                }else
                                {
                                }
                                if (subfigureNumberYN)
                                    txt = txt + '}\n';
                                else
                                    txt = txt + '\n';
                            }
                                                        
                        }
                    }
                    if (this.dataName[i] === 'TableShow' || this.dataName[i] === 'TableEdit')
                    {
                        if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 1)
                            if (typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                if (typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                {
                                    if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                        style = this.dataParameter[i][j][2];
                                    else
                                        style = null;
                                    var lineWidth;
                                    if (this.dataParameter[i][j].length > 14 && typeof this.dataParameter[i][j][14] !== 'undefined' && this.dataParameter[i][j][14] !== null)
                                        lineWidth = this.dataParameter[i][j][14];
                                    else
                                        lineWidth = null;
                                    var id = this.dataParameter[i][j][0];
                                    var data = this.dataParameter[i][j][1];
                                    var ii,jj;
/*                                    txt = txt + '<table id="' + id + '" ';
                                    if (style !== null)
                                        txt = txt + ' class="slide' + style + '" ';                                    
                                    txt = txt + '>';*/
                                    var w;
                                    if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                                        w = this.dataParameter[i][j][4];
                                    else
                                        w = null;
                                    var h;
                                    if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null)
                                        h = this.dataParameter[i][j][5];
                                    else
                                        h = null;
                                    var mincolour;
                                    if (this.dataParameter[i][j].length > 6 && typeof this.dataParameter[i][j][6] !== 'undefined' && this.dataParameter[i][j][6] !== null)
                                        mincolour = this.dataParameter[i][j][6];
                                    else
                                        mincolour = null;
                                    var maxcolour;
                                    if (this.dataParameter[i][j].length > 7 && typeof this.dataParameter[i][j][7] !== 'undefined' && this.dataParameter[i][j][7] !== null)
                                        maxcolour = this.dataParameter[i][j][7];
                                    else
                                        maxcolour = null;
                                    var minValue;
                                    if (this.dataParameter[i][j].length > 8 && typeof this.dataParameter[i][j][8] !== 'undefined' && this.dataParameter[i][j][8] !== null)
                                        minValue = this.dataParameter[i][j][8];
                                    else
                                        minValue = null;
                                    var maxValue;
                                    if (this.dataParameter[i][j].length > 9 && typeof this.dataParameter[i][j][9] !== 'undefined' && this.dataParameter[i][j][9] !== null)
                                        maxValue = this.dataParameter[i][j][9];
                                    else
                                        maxValue = null;
                                    var minColourTextValue;
                                    if (this.dataParameter[i][j].length > 10 && typeof this.dataParameter[i][j][10] !== 'undefined' && this.dataParameter[i][j][10] !== null)
                                        minColourTextValue = this.dataParameter[i][j][10];
                                    else
                                        minColourTextValue = null;
                                    var maxColourTextValue;
                                    if (this.dataParameter[i][j].length > 11 && typeof this.dataParameter[i][j][11] !== 'undefined' && this.dataParameter[i][j][11] !== null)
                                        maxColourTextValue = this.dataParameter[i][j][11];
                                    else
                                        maxColourTextValue = null;
                                    var alignTextX;
                                    if (this.dataParameter[i][j].length > 12 && typeof this.dataParameter[i][j][12] !== 'undefined' && this.dataParameter[i][j][12] !== null)
                                        alignTextX = this.dataParameter[i][j][12];
                                    else
                                        alignTextX = null;
                                    var alignTextY;
                                    if (this.dataParameter[i][j].length > 13 && typeof this.dataParameter[i][j][13] !== 'undefined' && this.dataParameter[i][j][13] !== null)
                                        alignTextY = this.dataParameter[i][j][13];
                                    else
                                        alignTextY = null;
                                    var colourStyle = null;
                                    if (this.dataParameter[i][j].length > 16 && typeof this.dataParameter[i][j][16] !== 'undefined' && this.dataParameter[i][j][16] !== null)
                                        colourStyle = this.dataParameter[i][j][16];
                                    var colourMap = null;
                                    if (this.dataParameter[i][j].length > 17 && typeof this.dataParameter[i][j][17] !== 'undefined' && this.dataParameter[i][j][17] !== null)
                                        colourMap = this.dataParameter[i][j][17];
                                    var colourMapMin = null;
                                    if (this.dataParameter[i][j].length > 18 && typeof this.dataParameter[i][j][18] !== 'undefined' && this.dataParameter[i][j][18] !== null)
                                        colourMapMin = this.dataParameter[i][j][18];
                                    var colourMapMax = null;
                                    if (this.dataParameter[i][j].length > 19 && typeof this.dataParameter[i][j][19] !== 'undefined' && this.dataParameter[i][j][19] !== null)
                                        colourMapMax = this.dataParameter[i][j][19];
//                                        var lineWidth;
                                    var wTeX;
                                    if (this.dataParameter[i][j].length > 20 && typeof this.dataParameter[i][j][20] !== 'undefined' && this.dataParameter[i][j][20] !== null)
                                        wTeX = this.dataParameter[i][j][20];
                                    else
                                        wTeX = null;
                                    var hTeX;
                                    if (this.dataParameter[i][j].length > 21 && typeof this.dataParameter[i][j][21] !== 'undefined' && this.dataParameter[i][j][21] !== null)
                                        hTeX = this.dataParameter[i][j][21];
                                    else
                                        hTeX = null;
                                    var colourTmp = null,colourTmp2 = null,YN = false,YN2 = false,k;
                                    var tmp;
                                    if (wTeX !== null)
                                    {
                                        switch(alignTextX)
                                        {
                                            case 'left':
                                                tmp = 'L';
                                                break;
                                            case 'right':
                                                tmp = 'R';
                                                break;
                                            case 'center':
                                                tmp = 'C';
                                                break;
                                            default:
                                                tmp = 'L';
                                        }
                                        tmp = tmp + '{' + wTeX + 'cm}';
                                    }else
                                        switch(alignTextX)
                                        {
                                            case 'left':
                                                tmp = 'l';
                                                break;
                                            case 'right':
                                                tmp = 'r';
                                                break;
                                            case 'center':
                                                tmp = 'c';
                                                break;
                                            default:
                                                tmp = 'l';
                                        }
                                    txt = txt + '{\n';
                                    if (colourStyle !== 'colour24bit')
                                    {
                                        if (mincolour !== null)
                                            txt = txt + '\\definecolor{minColour}{HTML}{' +  mincolour.Get24bitColourHex() +'}\n';
                                        if (maxcolour !== null)
                                            txt = txt + '\\definecolor{maxColour}{HTML}{' +  maxcolour.Get24bitColourHex() +'}\n';
                                        if (minColourTextValue !== null)
                                            txt = txt + '\\definecolor{minTextColour}{HTML}{' +  minColourTextValue.Get24bitColourHex() +'}\n';
                                        if (maxColourTextValue !== null)
                                            txt = txt + '\\definecolor{maxTextColour}{HTML}{' +  maxColourTextValue.Get24bitColourHex() +'}\n';
                                        if (colourMap !== null && colourMapMin !== null && colourMapMax !== null)
                                        {
                                            for (ii = 0;ii < colourMap.length;ii++)
                                                txt = txt + '\\definecolor{mapcolour' + ii + '}{HTML}{' +  colourMap[ii].Get24bitColourHex() +'}\n';                                                
                                        }
                                    }
                                    txt = txt + '\\begin{tabular}{';
                                    if (lineWidth > 0)
                                    {
                                        txt = txt + '|';
                                        if (data.length > 0)
                                            for (ii = 0;ii < data[0].length;ii++)
                                                txt = txt + tmp + '|';
                                    }else
                                        if (data.length > 0)
                                            for (ii = 0;ii < data[0].length;ii++)
                                                txt = txt + tmp;
                                    if (wTeX !== null)
                                        txt = txt + 'N}\n';
                                    else
                                        txt = txt + '}\n';
                                    for (ii = 0;ii < data.length;ii++)
                                    {
                                        if (lineWidth > 0)
                                            txt = txt +  '\\hline\n';
                                        var YNMapColour;
                                        for(jj = 0;jj < data[ii].length;jj++)
                                        {
                                            if (colourStyle !== 'colour24bit')
                                            {
                                                var tmp_data;
                                                if (this.dataParameter[i][j].length > 15 && typeof this.dataParameter[i][j][15] !== 'undefined' && this.dataParameter[i][j][15] !== null && this.dataParameter[i][j][15]) 
                                                    tmp_data = Hex2Numeric(data[ii][jj]);
                                                else
                                                    tmp_data = data[ii][jj];
                                                YNMapColour = false;
                                                if (colourMap !== null && colourMapMin !== null && colourMapMax !== null)
                                                {
                                                    for (k = 0;k < colourMap.length;k++)
                                                    {
                                                        if (tmp_data >= colourMapMin[k] && tmp_data <= colourMapMax[k])
                                                        {
                                                            YNMapColour = true;
                                                            break;
                                                        }
                                                    }
                                                }
                                                if (YNMapColour)
                                                {
                                                    txt = txt + '\\cellcolor{mapcolour' + k + '}';
                                                }else
                                                {
                                                    var tmpValue = 100*(tmp_data - minValue)/(maxValue - minValue);
                                                    if (mincolour !== null && maxcolour !== null)
                                                    {
                                                        var tmpValue2 = 100 - tmpValue;
                                                        txt = txt + '\\cellcolor{minColour!' + tmpValue2 + '!maxColour}';
                                                    }
                                                    if (minColourTextValue !== null && maxColourTextValue !== null)
                                                        if (tmpValue >= 50)
                                                            txt = txt + '\\color{maxTextColour}';
                                                        else
                                                            txt = txt + '\\color{minTextColour}';
                                                }
                                            }
                                            if (colourStyle === 'colour24bit')
                                            {
                                                txt = txt + '\\color{red}' +  data[ii][jj].substring(0,2);
                                                txt = txt + '\\color{green}' +  data[ii][jj].substring(2,4);
                                                txt = txt + '\\color{blue}' +  data[ii][jj].substring(4,6);
                                            }else
                                                txt = txt + data[ii][jj];
                                            if (jj !== data[ii].length - 1 || wTeX !== null)
                                                txt = txt + '&';
                                        }
                                        txt = txt + '\\\\';
                                        if (hTeX !== null)
                                            txt = txt + '[' + hTeX + 'cm]';
                                        txt = txt + '\n';
                                    }
                                    if (lineWidth > 0)
                                        txt = txt +  '\\hline\n';
                                    txt = txt + '\\end{tabular}\n';
                                    txt = txt + '}\n';
                                }

                    }
                    if (this.dataName[i] === 'Table')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            maxCol = 0;
                            paragraphEnterYN = false;
                            tableCaptionYN = false;
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length >= 2)
                            {
                                if(typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                                    tableCaptionYN = this.dataParameter[i][j][4];
                                if(typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                {
                                    maxCol = this.dataParameter[i][j][2];
                                    if (tableCaptionYN)
                                    {
                                        if (this.dataParameter[i][j].length > 8 && typeof this.dataParameter[i][j][8] !== 'undefined' && this.dataParameter[i][j][8] !== null)
                                            txt = txt + '\\begin{table}[' + this.dataParameter[i][j][8] + ']\n';                            
                                        else
                                            txt = txt + '\\begin{table}[htbp]\n';                            
//                                        txt = txt + '\\begin{table}[htbp]\n';
                                        figureLabel =  this.dataParameter[i][j][0];
                                        figureLabelYN = true;
                                    }
                                    txt = txt + '\\begin{tabular}{';
                                    var align = 'l';
                                    tableLine = '';
                                    if(typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null)
                                        switch (this.dataParameter[i][j][5])
                                        {
                                            case 'left':
                                                align = 'l';
                                                break;
                                            case 'center':
                                                align = 'c';
                                                break;
                                            case 'right':
                                                align = 'r';
                                                break;
                                        }
                                    if(typeof this.dataParameter[i][j][7] !== 'undefined' && this.dataParameter[i][j][7] !== null)
                                        switch (this.dataParameter[i][j][7])
                                        {
                                            case 'single':
                                                tableLine = '|';
                                                break;
                                            case 'no':
                                                tableLine = '';
                                                break;
                                        }
                                    txt = txt + tableLine;
                                    for (ii = 0;ii < maxCol;ii++)
                                        txt = txt + align + tableLine;
                                     txt = txt + '}';
                                     if (tableLine === '|')
                                        txt = txt + '\\hline\n';
                                }else
                                    txt = txt + '\\begin{tabular}';
                            }
                        }
                        if (this.data[i][j] === 'Stop')
                        {
                            paragraphEnterYN = true;
                            if (tableCaptionYN)
                            {
                                if (figureLabelYN)
                                    txt = txt + '\\label{' + figureLabel  +'}\n';
                                figureLabelYN = false;
                                txt = txt + '\\end{table}\n\n';
                            }else
                                txt = txt + '\n\\end{tabular}\n\n';
                            tableCaptionYN = false;
                        }
                    }                    
                    if (this.dataName[i] === 'tr')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            txt = txt + '\n';
                            numberCol = 0;
                        }
                        if (this.data[i][j] === 'Stop')
                        {
                            txt = txt + '\\\\';
                            if (tableLine === '|')
                               txt = txt + '\\hline\n';
                        }
                    }                    
                    if (this.dataName[i] === 'th' || this.dataName[i] === 'th2' )
                    {
                        if (this.data[i][j] === 'Start')
                        {
//                            txt = txt + '<th>';
                        }
                        if (this.data[i][j] === 'Stop' && maxCol)
                        {
                            numberCol++;
                            if (numberCol < maxCol)
                                txt = txt + '&';
                        }
                    }                    
                    if (this.dataName[i] === 'td' )
                    {
                        if (this.data[i][j] === 'Start')
                        {
//                            txt = txt + '<th>';
                        }
                        if (this.data[i][j] === 'Stop' && maxCol)
                        {
                            numberCol++;
                            if (numberCol < maxCol)
                                txt = txt + '&';
                        }
                    }                    
                    if (this.dataName[i] === 'Equation')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            txt = txt + '\\begin{equation}\n';
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                txt = txt + '\\label{' + this.dataParameter[i][j][0] + '}\n';
                        }
                        if (this.data[i][j] === 'Stop')
                        {
                            txt = txt + '\\end{equation}\n\n';                            
                        }
                    }                    
                    if (this.dataName[i] === 'SubEquation')
                    {
                        txt = txt + this.data[i][j] + '\n';
                    }

                    
                    if (this.dataName[i] === 'Paragraph')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                txt = txt + '{\\' + this.dataParameter[i][j][1] + '\n';
                        }
                        if (this.data[i][j] === 'Stop')
                        {
                            if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                txt = txt + '}\n';
                            if (paragraphEnterYN)
                            {
                                if (enumYN === 0 && itemizeYN === 0)
                                    txt = txt + '\n\n';
                                else
                                    txt = txt + '\n';
                            }
                        }
                    }
                    if (this.dataName[i] === 'PT')
                        txt = txt + this.data[i][j];
                    if (this.dataName[i] === 'Symbol')
                    {
                        if (this.data[i][j] === 'Dash')
                            txt = txt +'---';
                        if (this.data[i][j] === 'Hash')
                            txt = txt +'\\#';
                        if (this.data[i][j] === 'Underscore')
                            txt = txt +'\\_';
                        if (this.data[i][j] === 'Backslash')
                            txt = txt + '\\textbackslash ';
                        if (this.data[i][j] === 'Br' || this.data[i][j] === 'br')
                            txt = txt + '\\newline ';
                        if (this.data[i][j] === 'Space')
                            txt = txt + '\\hphantom{i} ';
                        if (this.data[i][j] === 'Less')
                            txt = txt +'<';
                         if (this.data[i][j] === 'Greater')
                            txt = txt +'>';
                        if (this.data[i][j] === 'Percent')
                            txt = txt +'\%';
                    }                    
                    if (this.dataName[i] === 'SpaceLength')
                    {
                        if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                        {
                            txt = txt + '\\hspace*{' + this.data[i][j] + '}';
                        }
                    }
                    if (this.dataName[i] === 'Emph')
                    {
                        if (this.data[i][j] === 'Start')
                            txt = txt + '\\emph{';
                        if (this.data[i][j] === 'Stop')
                            txt = txt + '}';
                    }
                    if (this.dataName[i] === 'Code')
                    {
                        if (this.data[i][j] === 'Start')
                            txt = txt + '\\verb¤';
                        if (this.data[i][j] === 'Stop')
                            txt = txt + '¤';
                    }                            
                    if (this.dataName[i] === 'Href')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            txt = txt + '\\href{';
                            if (this.dataParameter[i][j][0] === 'email')
                                txt = txt + 'mailto:';
                            txt = txt + this.dataParameter[i][j][1] + '}{';
                        }
                        if (this.data[i][j] === 'Stop')
                            txt = txt + '}';
                    }                            
                    if (this.dataName[i] === 'LocalHref')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            txt = txt + '\\href{';
                            if (this.dataParameter[i][j][0] === 'email')
                                txt = txt + 'mailto:';
                            txt = txt + this.dataParameter[i][j][1] + '}{';
                        }
                        if (this.data[i][j] === 'Stop')
                            txt = txt + '}';
                    }    
                    if (this.dataName[i] === 'PE')
                    {
                        if (this.data[i][j] === 'Start')
                            txt = txt + '\\(';                        
                        if (this.data[i][j] === 'Stop')
                            txt = txt + '\\)';                        
                    }

                    if (this.dataName[i] === 'Ref')
                    {
                        if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                        {
//                            txt = txt + ' ';
                            txt = txt + '\\ref{';
                            txt = txt + this.data[i][j];
                            txt = txt + '}';
                        }
                    }
                    if (this.dataName[i] === 'FormStart')
                        txt = txt + '\\begin{itemize}\n';
                    if (this.dataName[i] === 'FormStop')
                    {
                        if (startRadioButtoEmph)
                            txt = txt + '}';
//                        txt = txt + '\n';
                        txt = txt + '\\end{itemize}\n';
                        startRadioButtoEmph = false;
                    }
                    if (this.dataName[i] === 'RadioButton' || this.dataName[i] === 'CheckBox')
                    {
                        if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                        {
                            if (startRadioButtoEmph)
                                txt = txt + '}';
                            startRadioButtoEmph = false;
                            txt = txt + '\\item\n';
                            if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                            {
                                if (this.dataParameter[i][j][3])
                                {
                                    startRadioButtoEmph = true;
                                    txt = txt + '\\underline{';
                                }
                            }
                            
                        }
                    }
                    if (this.dataName[i] === 'Rectangle')
                    {
                        if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                            if (typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                            {//this.dataParameter[i][j][2].Get24bitColourHex()
                                txt = txt + '{\\definecolor{mycolor}{rgb}{'+ this.dataParameter[i][j][2].GetColourR() + ','+ this.dataParameter[i][j][2].GetColourG() + ','+ this.dataParameter[i][j][2].GetColourB() + '}';
                                txt = txt + '\\begin{tikzpicture} \\fill[mycolor] (0,0) rectangle (' + this.dataParameter[i][j][0] + 'ex,' + this.dataParameter[i][j][1] + 'ex);\\end{tikzpicture}}';
                            }
                    }
                    if (this.dataName[i] === 'Edit')
                    {
                        if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                        {
                            txt = txt + this.dataParameter[i][j][0];
                        }
                    }
                    if (this.dataName[i] === 'TextArea')
                    {
                        if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                        {
                            txt = txt + this.dataParameter[i][j][0];
                        }
                    }
                    if (this.dataName[i] === 'ParagraphText')
                    {
                        if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                        {
                            txt = txt + this.dataParameter[i][j][0];
                        }
                    }
                        
                    if (this.dataName[i] === 'Figure')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                txt = txt + '\\begin{figure}[' + this.dataParameter[i][j][2] + ']\n';                            
                            else
                                txt = txt + '\\begin{figure}[htbp]\n';                            
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null)
                            {
                                if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                {
                                    figureLabel =  this.dataParameter[i][j][0];
                                    figureLabelYN = true;
                                }else
                                    figureLabelYN = false;
                                if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                {
                                    switch(this.dataParameter[i][j][1])
                                    {
                                        case 'center':
                                            lbraceFigure = true;
                                            txt = txt + '{\n\\centering\n';
                                            break;
                                    }
                                }
                            }else
                                figureLabelYN = false;
                        }
                        if (this.data[i][j] === 'Stop')
                        {
                            if (figureLabelYN)
                                txt = txt + '\\label{' + figureLabel  +'}\n';
                            figureLabelYN = false;
                            if (lbraceFigure)
                            {
                                txt = txt + '}\n';
                            }
                            txt = txt + '\\end{figure}\n\n';
                            lbraceFigure = false;
                        }
                    }
                    if (this.dataName[i] === 'FigureCaption')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            paragraphEnterYN = false;
                            if (tableCaptionYN)
                                txt = txt + '\n\\end{tabular}\n\n';
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null && this.dataParameter[i][j][0] === false)
                            {
                                txt = txt + '\\caption*{';                                    
                            }else
                                txt = txt + '\\cprotect\\caption{';
                        }
                        if (this.data[i][j] === 'Stop')
                        {
                            paragraphEnterYN = true;
                            txt = txt + '}\n';
                                
                        }
                    }
                    if (this.dataName[i] === 'Subfigure')
                    {
/*                        if (this.data[i][j] === 'Start')
                        {
                            txt = txt + '<Subfigure>';
                        }
                        if (this.data[i][j] === 'Stop')
                        {
                            txt = txt + '</Subfigure>';
                        }*/
                        if (this.data[i][j] === 'NotNumber')
                            subfigureNumberYN = false;
                        if (this.data[i][j] === 'Number')
                        {
                            subfigureNumberYN = true;
                            subfigureNumber = this.dataParameter[i][j];
                        }
                    }
                    if (this.dataName[i] === 'FigureImageBitmap' || this.dataName[i] === 'InteractiveImageBitmap')
                    {

                        if (subfigureNumberYN)
                        {
                            txt = txt + '\\subfigure[)]{';
                        }
                        if (numberCatalog !== null && typeof this.data[numberCatalog][0] !== 'undefined' && this.data[numberCatalog][0] !== null)
                        {
                            if (this.dataParameter[i][j][0] > 0)
                            {
                                tmp = this.dataParameter[i][j][0]/100;
                                txt = txt + '\\includegraphics[width='+ tmp + '\\linewidth]{' + this.data[numberCatalog][0] + '/'+ this.data[i][j] + '}';
                            }else
                            {
                                if (this.dataParameter[i][j][1] > 0)
                                {
                                    tmp = this.dataParameter[i][j][1];
                                    txt = txt + '\\includegraphics[height=' + tmp + 'mm]{' + this.data[numberCatalog][0] + '/' + this.data[i][j] + '}';
                                }else
                                    txt = txt + '\\includegraphics{' + this.data[numberCatalog][0] + '/' + this.data[i][j] + '}';
                            }
                        }
                        if (subfigureNumberYN)
                            txt = txt + '}\n';
                        else
                            txt = txt + '\n';
/*                        if (subfigureNumberYN)
                            txt = txt + subfigureNumber + ')';
                        txt = txt + '<img src="'+ this.data[i][j] + '" style="';
                        if (this.dataParameter[i][j][0] > 0)
                            txt = txt + 'width:' + this.dataParameter[i][j][0] +'%;';
                        else
                            if (this.dataParameter[i][j][1] > 0)
                                txt = txt + 'height:' + this.dataParameter[i][j][1] +'px;';
                        txt = txt + 'vertical-align: text-top">';
                        txt = txt + '</FigureImageBitmapBlock>';*/
                                    
                    }
                    if (this.dataName[i] === 'Generate')
                    {
                        if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                        {
                            txt = txt + '\\begin{tikzpicture}[';
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 10)
                            {
//                                if (IsNumeric(this.dataParameter[i][j][10]))
//                                    txt = txt + 'scale=' + this.dataParameter[i][j][10];
 //                               txt = txt + ' domain=0:'+ this.dataParameter[i][j][0];
                            }
                            txt = txt + ']\n';
                            if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                            {
                                tabObj = this.dataParameter[i][j][2];
                                if (typeof tabObj !== 'undefined' && tabObj !== null)
                                {
                                    ctx = objM.newObject('TDrawTikZContext');
                                    id = this.data[i][j];
                                    if (typeof id !== 'undefined' && id !== null)
                                    {
                                        matrix = objM.newObject('TMatrixTransformation3D');
                                        matrix2 = objM.newObject('TMatrixTransformation3D');
//                                        matrix.SetScaleMatrix3D();
                                        scaleX = this.dataParameter[i][j][0]/this.dataParameter[i][j][3];
                                        scaleY = this.dataParameter[i][j][1]/this.dataParameter[i][j][4];
                                        scaleZ = this.dataParameter[i][j][5];
                                        matrix.SetScaleMatrix3D(scaleX,scaleY,scaleZ);
                                        matrix2.SetTranslationMatrix(-this.dataParameter[i][j][6],-this.dataParameter[i][j][7],-this.dataParameter[i][j][8]);
                                        matrix.MatrixMultiplication(matrix2);
//                                        matrix.SetIdentityMatrix();
                                        ctx.SetTransformation(matrix);
                                        for (k = 0;k < tabObj.length;k++)
                                        {
                                            obj = tabObj[k];
                                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                            {
                                                obj.DrawFigure(ctx);
                                            }
                                        }
                                        txt = txt + ctx.GetContext();
                                    }
                                }


                                //                                    if (this.dataParameter[i][j])
                            }
                            txt = txt + '\\end{tikzpicture}\n';
                        }
                    }
/*                    if (this.dataName[i] === 'FigureName')
                    {
                        txt = txt + this.data[i][j] + ' ';
                        if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0)
                        {
                            for(k = 0;k < this.dataParameter[i][j].length;k++)
                            {
                                txt = txt + this.dataParameter[i][j][k] + '.';
                            }
                            txt = txt  + ' ';
                        }
                    }                    */
                
                
                
                }                
            }
        }
        return txt;
    };

};

TTeXParagraphs.prototype = new TGenerateTeX();


function THTMLSlide(){
    
    var type = 'THTMLSlide';
    THTMLSlide.prototype.InitConstructor = function(){
        TGenerateHTML.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetObjectType('HTML');
    };
    this.InitConstructor();

    THTMLSlide.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TGenerateHTML.prototype.IsType.call(this,_type);
    };

    THTMLSlide.prototype.Init = function(_object){
        TGenerateHTML.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('THTMLSlide'))
        {
        }
    };
    
    THTMLSlide.prototype.GetTXT2 = function(){
        var txt = '';
        var objM = this.GetObjectManager();
        if (objM === null)
            return;
        
        if (this.GetSlide())
        {
//            txt = TGenerateHTML.prototype.GetTXT.call(this); 
            var YN = false,i,j,currentLevel = 0,tmp,tmp2,id,titleYN = true;
            var numberCatalog = this.Find('ImageCatalog');
            tmp = this.Find('TitleYN',0);
            if (tmp !== null && this.data[tmp].length > 0 && this.data[tmp][0] === 'No')
                titleYN = false;
            for(i = 0;;i++)
            {
                tmp = this.Find('Title',i);
                if (typeof tmp === 'undefined' || tmp === null || !IsInt(tmp))
                    break;
                for (j = 0;j < this.data[tmp].length;j++)
                {
                    currentLevel = parseInt(this.dataParameter[tmp][j][0]);
                    if (typeof currentLevel !== 'undefined' && currentLevel !== null && IsInt(currentLevel) && currentLevel >= 0 && currentLevel < 2)
                    {
                        if (currentLevel === 1)
                        {
                            YN = true;
                            break;
                        }
                    }
                }
                if (YN)
                    break;
            }

            if (this.GetNumberNote() < 0)
            {
                if (titleYN)
                {
                    for (i = 0;i < this.data.length;i++)
                    {
                        for (j = 0;j < this.data[i].length;j++)
                        {
                            if (this.dataName[i] === 'Title')
                            {
                                currentLevel = parseInt(this.dataParameter[i][j][0]);
                                if (typeof currentLevel !== 'undefined' && currentLevel !== null && IsInt(currentLevel) && currentLevel >= 0 && currentLevel < 2)
                                {
                                    id = this.dataParameter[i][j][1];
                                    switch(currentLevel)
                                    {
                                        case 0:
                                            if(YN)
                                                txt = txt + '<TitleSlidePosition2';
                                            else
                                                txt = txt + '<TitleSlidePosition';
                                            break;
                                        case 1:
                                            txt = txt + '<SubtitleSlidePosition';
                                            break;
                                    }
                                    if (typeof id !== 'undefined' && id !== null)
                                        txt = txt + ' id="'+ id + '"';          
                                    txt = txt + '>';
                                    txt = txt + this.data[i][j];
                                    switch(currentLevel)
                                    {
                                        case 0:
                                            if(YN)
                                                txt = txt + '</TitleSlidePosition2>';
                                            else
                                                txt = txt + '</TitleSlidePosition>';
                                            break;
                                        case 1:
                                            txt = txt + '</SubtitleSlidePosition>';
                                            break;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            var noteYN = false,numberNote = 0,formStart = false,selectStart = false;
            var number2 ,enumYN=0,itemizeYN=0,tabObj,ctx,matrix,matrix2,scaleX,scaleY,scaleZ,k,obj;
            var id_tmp = null,tableYN = false,style = null;
            var formNoEnter = false;
            if (this.GetNumberNote() < 0)
            {
                txt = txt + '<SlideBlock>';
                txt = txt + '<SlideText>';
                number2 = this.Find('Id',0);
                if (number2 !== null)
                    txt = txt + '<SlideCustom_' + this.data[number2][0] + '>';
            }else
                txt = txt + '<SlideNoteBlock>';
                
            
            for (i = 0;i < this.data.length;i++)
            {
                for (j = 0;j < this.data[i].length;j++)
                {
                    if (this.dataName[i] === 'Note')
                    {
                        if (this.data[i][j] === 'Start')
                        {
                            noteYN = true;
                            numberNote = this.dataParameter[i][j];
                        }
                        if (this.data[i][j] === 'Stop')
                            noteYN = false;
                    }
                    if (this.GetNumberNote() < 0 && !noteYN)
                    {
                        if (this.dataName[i] === 'Paragraph' && enumYN === 0 && itemizeYN === 0 && tableYN === false)
                        {
                            if (this.data[i][j] === 'Start')
                            {
                                if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                    txt = txt + '<SlideP class="' + this.dataParameter[i][j][1] + '">';
                                else
                                    txt = txt + '<SlideP>';
                                if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                {
                                    id_tmp = this.dataParameter[i][j][0];
                                    txt = txt + '<Slide_' + id_tmp + '>';                                    
                                }else
                                    id_tmp = null;
                            }
                            if (this.data[i][j] === 'Stop')
                            {
                                if (id_tmp !== null)
                                    txt = txt + '</Slide_' + id_tmp + '>';                                    
                                txt = txt + '</SlideP>';
                            }

                        }
                    }
                    if (this.GetNumberNote() === numberNote && noteYN)
                    {
                        if (this.dataName[i] === 'Paragraph' && enumYN === 0 && itemizeYN === 0)
                        {
                            if (this.data[i][j] === 'Start')
                            {
                                if (typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                    txt = txt + '<SlideNoteP class="' + this.dataParameter[i][j][1] + '">';
                                else
                                    txt = txt + '<SlideNoteP>';
                            }
                            if (this.data[i][j] === 'Stop')
                                txt = txt + '</SlideNoteP>';

                        }
                    }
                    if ((this.GetNumberNote() < 0 && !noteYN) || (this.GetNumberNote() === numberNote && noteYN))
                    {
                        if (this.dataName[i] === 'PT')
                            txt = txt + this.data[i][j];
                        if (this.dataName[i] === 'Symbol')
                        {
                            if (this.data[i][j] === 'Dash')
                                txt = txt +'–';
                            if (this.data[i][j] === 'Hash')
                                txt = txt +'#';
                            if (this.data[i][j] === 'Underscore')
                                txt = txt +'_';
                            if (this.data[i][j] === 'Backslash')
                                txt = txt +'\\';
                            if (this.data[i][j] === 'Br' || this.data[i][j] === 'br')
                                txt = txt +'<br>';
                            if (this.data[i][j] === 'Space')
                                txt = txt +'&nbsp;';
                            if (this.data[i][j] === 'Less')
                                txt = txt +'&lt;';
                            if (this.data[i][j] === 'Greater')
                                txt = txt +'&gt;';
                            if (this.data[i][j] === 'Percent')
                                txt = txt +'%';
                        }                    
                        if (this.dataName[i] === 'SpaceLength')
                        {
                            if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                            {
                                txt = txt + '<span style="display:inline-block; width: ' + this.data[i][j] + ';"></span>';
                            }
                        }
                        if (this.dataName[i] === 'Enum')
                        {
                            if (this.data[i][j] === 'Start')
                            {
                                txt = txt + '<ol class="olSlide">';
                                enumYN++;
                            }
                            if (this.data[i][j] === 'Stop')
                            {
                                txt = txt + '</ol>';                        
                                enumYN--;
                                if (enumYN < 0)
                                    enumYN = 0;
                            }
                        }
                        if (this.dataName[i] === 'Itemize')
                        {
                            if (this.data[i][j] === 'Start')
                            {
                                if (enumYN > 0)
                                    txt = txt + '<ul class="ulSlide2">';
                                else
                                    txt = txt + '<ul class="ulSlide1">';
                                itemizeYN++;
                            }
                            if (this.data[i][j] === 'Stop')
                            {
                                txt = txt + '</ul>';
                                itemizeYN--;
                                if (itemizeYN < 0)
                                    itemizeYN = 0;
                            }
                        }
                        if (this.dataName[i] === 'Item')
                        {
                            if (this.data[i][j] === 'Start')
                            {
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                    txt = txt + '<li class="slide' +  this.dataParameter[i][j][0] + '">';
                                else
                                    txt = txt + '<li>';
                            }
                            if (this.data[i][j] === 'Stop')
                            {
                                txt = txt + '</li>';
                            }
                        }
                        if (this.dataName[i] === 'Equation')
                        {
                            if (this.data[i][j] === 'Start')
                            {
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                    txt = txt + '<table id="' + this.dataParameter[i][j][0] + '"';
                                else
                                    txt = txt + '<table';
                                txt = txt + ' style="width:100%">';                                    
                                txt = txt + '<tr>';
                                txt = txt + '<td class="EquationAlign" ';
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                    txt = txt + 'id="Eq' + this.dataParameter[i][j][0] + '"';

                                txt = txt + '>\\(';
                            }
                            if (this.data[i][j] === 'Stop')
                            {
                                txt = txt + '\\)';
                                txt = txt + '</td>';
                                txt = txt + '<td style="text-align:left" class="EquationNumeration">';


                                txt = txt + '</td>';
                                txt = txt + '</tr>';
                                txt = txt + '</table>';
                            }
                        }                    
                        if (this.dataName[i] === 'SubEquation')
                        {
                            txt = txt + this.data[i][j];
                        }
                        if (this.dataName[i] === 'Emph')
                        {
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null)
                            {
                                if (this.data[i][j] === 'Start' && this.dataParameter[i][j].length > 0)
                                {
                                    if (typeof this.dataParameter[i][j][0]  !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                    {
                                        tmp2 = parseInt(this.dataParameter[i][j][0]);
                                        if (tmp2 >= 0)
                                            txt = txt + '<SlideEmph' + tmp2 + '>';
                                        else
                                        {
                                            if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1]  !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                                txt = txt + '<SlideEmph class="slide' + this.dataParameter[i][j][1] + '">';
                                            else
                                                txt = txt + '<SlideEmph>';
                                        }
                                    }
                                }
                                if (this.data[i][j] === 'Stop')
                                {
                                    tmp2 = parseInt(this.dataParameter[i][j]);
                                    if (tmp2 >= 0)
                                        txt = txt + '</SlideEmph' + tmp2 + '>';
                                    else
                                        txt = txt + '</SlideEmph>';
                                }
                            }
                        }
                        if (this.dataName[i] === 'Code')
                        {
                            if (this.data[i][j] === 'Start' && this.dataParameter[i][j].length > 0)
                            {
                                if (typeof this.dataParameter[i][j][0]  !== 'undefined' && this.dataParameter[i][j][0] !== null && this.dataParameter[i][j][0] >= 0)
                                    txt = txt + '<SlideCode' + this.dataParameter[i][j][0] + '>';
                                else
                                {
                                    if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1]  !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                    {
                                        txt = txt + '<SlideCode class="' + this.dataParameter[i][j][1] + '">';                                    
                                    }
                                }
                            }
                            if (this.data[i][j] === 'Stop')
                            {
                                if  (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j] >= 0)
                                {
                                    tmp2 = parseInt(this.dataParameter[i][j]);
                                    txt = txt + '</SlideCode' + tmp2 + '>';
                                }else
                                    txt = txt + '</SlideCode>';
                            }
                        }
                        if (this.dataName[i] === 'Href')
                        {
                            if (this.data[i][j] === 'Start')
                            {
                                txt = txt + '<a href="';
                                if (this.dataParameter[i][j][0] === 'email')
                                   txt = txt + 'mailto:';
                                txt = txt + this.dataParameter[i][j][1] + '" class="Slide'+ this.dataParameter[i][j][0] + '"';
                                if (this.dataParameter[i][j][0] === 'file')
                                    txt = txt + ' target="_blank" style="display: inline;"';
                                txt = txt + '>';
                            }
                            if (this.data[i][j] === 'Stop')
                                txt = txt + '</a>';
                        }
                        if (this.dataName[i] === 'LocalHref')
                        {
                            if (this.data[i][j] === 'Start')
                            {
								var tmpHref = window.location.href;
								var n = tmpHref.lastIndexOf("/");
								tmpHref = tmpHref.substring(0,n);
                                txt = txt + '<a href="' + tmpHref  + '/' + this.data[numberCatalog][0] + '/';
                                txt = txt + this.dataParameter[i][j][1] + '" class="Slide'+ this.dataParameter[i][j][0] + '"';
                                if (this.dataParameter[i][j][0] === 'file')
                                    txt = txt + ' target="_blank" style="display: inline;"';
                                txt = txt + ' onClick="window.location.assign(' + "'" +  tmpHref + '/' + this.data[numberCatalog][0] + '/' + this.dataParameter[i][j][1] + "'" + ");" + ' ">';
                            }
                            if (this.data[i][j] === 'Stop')
                                txt = txt + '</a>';
                        }
                        if (this.dataName[i] === 'PE')
                        {
                            if (this.data[i][j] === 'Start')
                                txt = txt + '\\(';                        
                            if (this.data[i][j] === 'Stop')
                                txt = txt + '\\)';                        
                        }

                        if (this.dataName[i] === 'FigureImageBitmap' || this.dataName[i] === 'InteractiveImageBitmap')
                        {
                            txt = txt + '<SlideFigureImageBitmap>';
                            
/*                            if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                txt = txt + '<img src="' + this.data[numberCatalog][0] + '/'+ this.data[i][j] + '" class="' + this.dataParameter[i][j][2] +'">';
                            else
                                txt = txt + '<img src="' + this.data[numberCatalog][0] + '/'+ this.data[i][j] + '">';*/
                            txt = txt + '<img';
                            if (this.data[i][j] !== null && this.data[i][j] !== 'null')
                                txt = txt + ' src="' + this.data[numberCatalog][0] + '/' + this.data[i][j] + '"';
                            txt = txt + ' style="';
                            if (this.dataParameter[i][j][0] > 0)
                                txt = txt + 'width:' + this.dataParameter[i][j][0] +'%;';
                            else
                                if (this.dataParameter[i][j][1] > 0)
                                    txt = txt + 'height:' + this.dataParameter[i][j][1] +'mm;';
                            txt = txt + 'vertical-align: text-top"';
                            if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                txt = txt + ' onclick="javascript:' + this.dataParameter[i][j][3] +'" ';
                            if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                txt = txt + ' id="' + this.dataParameter[i][j][2] +'" ';
                            if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null && this.dataParameter[i][j][4] === false)
                                txt = txt + ' hidden';
                            txt = txt + '>';
                            txt = txt + '</SlideFigureImageBitmap>';

                        }
						
                        if (this.dataName[i] === 'FigureVideo')
                        {
                            txt = txt + '<SlideFigureVideo>';
                            
/*                            txt = txt + '<iframe src="' + this.data[i][j] + '" style="';
                            if (this.dataParameter[i][j][0] > 0)
                                txt = txt + 'width:' + this.dataParameter[i][j][0] +'%;';
                            else
                                if (this.dataParameter[i][j][1] > 0)
                                    txt = txt + 'height:' + this.dataParameter[i][j][1] +'mm;';
                            txt = txt + 'vertical-align: text-top"/>';*/

                            txt = txt + '<video ';
                            if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                txt = txt + 'id="' + this.dataParameter[i][j][2] +'" ';
                            if (this.dataParameter[i][j].length > 6 && typeof this.dataParameter[i][j][6] !== 'undefined' && this.dataParameter[i][j][6] !== null)
                                txt = txt + 'class="' + this.dataParameter[i][j][6] +'" ';
                            if (this.dataParameter[i][j].length > 0 && this.dataParameter[i][j][0] > 0)
                                txt = txt + 'width="' + this.dataParameter[i][j][0] +'%" ';
                            if (this.dataParameter[i][j].length > 1 && this.dataParameter[i][j][1] > 0)
                                txt = txt + 'height="' + this.dataParameter[i][j][1] +'%"';
                            if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null && this.dataParameter[i][j][4])
                                txt = txt + ' autoplay="autoplay"';
                            if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null && this.dataParameter[i][j][5])
                                txt = txt + ' controls="controls"';
                            if (this.dataParameter[i][j].length > 7 && typeof this.dataParameter[i][j][7] !== 'undefined' && this.dataParameter[i][j][7] !== null && this.dataParameter[i][j][7])
                                txt = txt + ' loop="controls"';
                            if (this.dataParameter[i][j].length > 8 && typeof this.dataParameter[i][j][8] !== 'undefined' && this.dataParameter[i][j][8] !== null && this.dataParameter[i][j][8])
                                txt = txt + ' muted'
                            txt = txt + '>';
                            
                            txt = txt + '<source  src="' + this.data[numberCatalog][0] + '/' + this.data[i][j] + '" ';
                            if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                txt = txt + 'type="'+ this.dataParameter[i][j][3] +'"';
                            txt = txt + '>';
                            
                            txt = txt + '</video>';
                            txt = txt + '</SlideFigureVideo>';

                        }


                        if (this.dataName[i] === 'FigureYouTubeVideo')
                        {
                            txt = txt + '<SlideFigureYouTubeVideo>';
                            
/*                            txt = txt + '<iframe src="' + this.data[i][j] + '" style="';
                            if (this.dataParameter[i][j][0] > 0)
                                txt = txt + 'width:' + this.dataParameter[i][j][0] +'%;';
                            else
                                if (this.dataParameter[i][j][1] > 0)
                                    txt = txt + 'height:' + this.dataParameter[i][j][1] +'mm;';
                            txt = txt + 'vertical-align: text-top"/>';*/

                            txt = txt + '<iframe ';
                            if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                txt = txt + 'id="' + this.dataParameter[i][j][2] +'" ';
                            if (this.dataParameter[i][j].length > 6 && typeof this.dataParameter[i][j][6] !== 'undefined' && this.dataParameter[i][j][6] !== null)
                                txt = txt + 'class="' + this.dataParameter[i][j][6] +'" ';
                            if (this.dataParameter[i][j].length > 0 && this.dataParameter[i][j][0] > 0)
                                txt = txt + 'width="' + this.dataParameter[i][j][0] +'" ';
                            if (this.dataParameter[i][j].length > 1 && this.dataParameter[i][j][1] > 0)
                                txt = txt + 'height="' + this.dataParameter[i][j][1] +'"';
							
		                    txt = txt + ' src="' + this.data[i][j];
                            if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null && this.dataParameter[i][j][4])
                                txt = txt + '?autoplay=1';
							else
                                txt = txt + '?autoplay=0';
                            if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null && this.dataParameter[i][j][5])
                                txt = txt + '&controls=1';
							else
                                txt = txt + '&controls=0';
                            if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][7] !== 'undefined' && this.dataParameter[i][j][7] !== null && this.dataParameter[i][j][7])
							{
                                txt = txt + '&loop=1';
								var ind,ind2,tmp__ = '';
								for (ind=this.data[i][j].length-1;ind>0;ind--)
								{
									if(this.data[i][j][ind] == "/")
										break;
								}
								ind2 = ind + 1;
								for (ind=this.data[i][j].length-1;ind>0;ind--)
								{
									if(this.data[i][j][ind] == "/")
										break;
									tmp__ =  this.data[i][j][ind] + tmp__;
								}
                                txt = txt + '&playlist=' + tmp__;
							}else
                                txt = txt + '&loop=0';
                            if (this.dataParameter[i][j].length > 8 && typeof this.dataParameter[i][j][8] !== 'undefined' && this.dataParameter[i][j][8] !== null && this.dataParameter[i][j][8] > 0)
                                txt = txt + '&start=' + this.dataParameter[i][j][8];
                            if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null && this.dataParameter[i][j][3])
                                txt = txt + '&mute=1';
							else
                                txt = txt + '&mute=0';
					
                            txt = txt + '" frameborder="0" allow="picture-in-picture"';


                            txt = txt + '>';
                            
                            
                            txt = txt + '</iframe>';
                            txt = txt + '</SlideFigureYouTubeVideo>';

                        }

                        if (this.dataName[i] === 'FigureGoogleMaps')
                        {
                            txt = txt + '<SlideFigureGoogleMaps>';
                            

                            txt = txt + '<iframe ';
                            if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                txt = txt + 'id="' + this.dataParameter[i][j][2] +'" ';
                            if (this.dataParameter[i][j].length > 6 && typeof this.dataParameter[i][j][6] !== 'undefined' && this.dataParameter[i][j][6] !== null)
                                txt = txt + 'class="' + this.dataParameter[i][j][6] +'" ';
                            if (this.dataParameter[i][j].length > 0 && this.dataParameter[i][j][0] > 0)
                                txt = txt + 'width="' + this.dataParameter[i][j][0] +'" ';
                            if (this.dataParameter[i][j].length > 1 && this.dataParameter[i][j][1] > 0)
                                txt = txt + 'height="' + this.dataParameter[i][j][1] +'"';
							
		                    txt = txt + ' src="' + this.data[i][j];
					
                            txt = txt + '" frameborder="0" allowfullscreen=""';


                            txt = txt + '>';
                            
                            
                            txt = txt + '</iframe>';
                            txt = txt + '</SlideFigureGoogleMaps>';

                        }

                        if (this.dataName[i] === 'Frame')
                        {
                            txt = txt + '<SlideFigureIFrame>';
							txt = txt + '<iframe ';
                            if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                txt = txt + 'id="' + this.dataParameter[i][j][2] +'" ';
                            if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                txt = txt + 'class="' + this.dataParameter[i][j][3] +'" ';

                            if (this.dataParameter[i][j].length > 0 && this.dataParameter[i][j][0] > 0)
                                txt = txt + 'width="' + this.dataParameter[i][j][0] +'" ';
                            if (this.dataParameter[i][j].length > 1 && this.dataParameter[i][j][1] > 0)
                                txt = txt + 'height="' + this.dataParameter[i][j][1] +'" ';

		                    txt = txt + ' src="' + this.data[numberCatalog][0] + '/' + this.data[i][j] + '" ';

							txt = txt + 'scrolling="no">';

							txt = txt + '<p>Your browser does not support iframes.</p>';
							txt = txt + '</iframe>';
                            txt = txt + '</SlideFigureIFrame>';

                        }


                        if (this.dataName[i] === 'SelectStart')
                        {
                            txt = txt + '<select';
                            if (this.data[i][j] !== null && this.data[i][j] !== '')
                            {
                                txt = txt + ' id="' + this.data[i][j] + '"';
                            }
                            if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                txt = txt + ' class="' + this.dataParameter[i][j][0] + '"';
                            if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                txt = txt + ' title="' + this.dataParameter[i][j][1] + '"';
                            if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                txt = txt + ' onchange="' + this.dataParameter[i][j][2] + '(this.value)"';
                            txt = txt + ' >';
                            selectStart = true;
                        }
                        if (this.dataName[i] === 'SelectStop')
                        {
                            txt = txt + '</select>';
                            selectStart = false;
                        }
                        if (this.dataName[i] === 'SelectOption')
                        {
                            if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                            {
//                                if (formStart === false && formNoEnter == false)
//                                    txt = txt + '<br>';
                                selectStart = false;
                                txt = txt + "<option";
                                if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                                    txt = txt + ' value="' + this.dataParameter[i][j][4] + '"';
                                if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                {
                                    if (this.dataParameter[i][j][2])
                                        txt = txt + ' selected';
                                }
                                txt = txt + ">";
                                if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                    txt = txt + this.dataParameter[i][j][3];
                                txt = txt + "</option>";
                            }
                        }
                        
                        
                        if (this.dataName[i] === 'FormStart')
                        {
                            txt = txt + '<form>';
                            formStart = true;
                            if (typeof this.dataParameter[i][j] != 'undefined' && this.dataParameter[i][j] != null)
                                formNoEnter = this.dataParameter[i][j];
                            else
                                formNoEnter = false;
                        }
                        if (this.dataName[i] === 'FormStop')
                        {
                            txt = txt + '</form>';
                            formStart = false;
                        }
                        if (this.dataName[i] === 'RadioButton')
                        {
                            if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                            {
                                if (formStart === false && formNoEnter == false)
                                    txt = txt + '<br>';
                                formStart = false;
                                txt = txt + '<input type="radio" id="' + this.data[i][j] + '" ';
                                if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                    txt = txt + 'name="' + this.dataParameter[i][j][2] + '" ';
                                if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                {
                                    if (this.dataParameter[i][j][3])
                                        txt = txt + 'checked ';
                                }
                                if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                                {
                                    if (typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null)
                                        txt = txt + ' onclick="' + this.dataParameter[i][j][4] + "(this,event,'" + this.dataParameter[i][j][5] + "'" + ')"';
                                }
                                txt = txt + '> ';

                            }
                        }
                        if (this.dataName[i] === 'CheckBox')
                        {
                            if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                            {
                                if (formStart === false && formNoEnter == false)
                                    txt = txt + '<br>';
                                formStart = false;
                                txt = txt + '<input type="checkbox" id="' + this.data[i][j] + '" ';
                                if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                    txt = txt + 'name="' + this.dataParameter[i][j][2] + '" ';
                                if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                {
                                    if (this.dataParameter[i][j][3])
                                        txt = txt + 'checked ';
                                }
                                if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                                {
                                    if (typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null)
                                        txt = txt + ' onclick="' + this.dataParameter[i][j][4] + "(this,event,'" + this.dataParameter[i][j][5] + "'" + ')"';
                                }
                                txt = txt + '> ';

                            }
                        }
                        if (this.dataName[i] === 'Edit')
                        {
                            if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined')// && this.dataParameter[i][j][0] !== null)
                            {
                                if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                                {
                                    txt = txt + '<input type="text" id="' + this.data[i][j] + '" ';
                                    if (this.dataParameter[i][j][0] !== null) 
                                        txt = txt + 'value="' + this.dataParameter[i][j][0] + '" ';
                                    if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null && this.dataParameter[i][j][1] > 0)
                                        txt = txt + 'size="' + this.dataParameter[i][j][1] + '"';
                                    if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                        txt = txt + ' class="' + this.dataParameter[i][j][2] + '"';
                                    if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null)
                                        txt = txt + ' onchange="' + this.dataParameter[i][j][5] + "(this,event,'" + this.data[i][j] + "'" + ')"';
                                    if (this.dataParameter[i][j].length > 6 && typeof this.dataParameter[i][j][6] !== 'undefined' && this.dataParameter[i][j][6] !== null)
                                        txt = txt + ' onkeypress="' + this.dataParameter[i][j][6] + "(this,event,'" + this.data[i][j] + "'" + ')"';
                                    if (this.dataParameter[i][j].length > 7 && typeof this.dataParameter[i][j][7] !== 'undefined' && this.dataParameter[i][j][7] !== null)
                                        txt = txt + ' onkeydown="' + this.dataParameter[i][j][7] + "(this,event,'" + this.data[i][j] + "'" + ')"';
                                    if (this.dataParameter[i][j].length > 8 && typeof this.dataParameter[i][j][8] !== 'undefined' && this.dataParameter[i][j][8] !== null)
                                        txt = txt + ' onkeyup="' + this.dataParameter[i][j][8] + "(this,event,'" + this.data[i][j] + "'" + ')"';
                                    txt = txt + ' style="';
                                    if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null && this.dataParameter[i][j][3].IsType('TColourRGBA'))
                                        txt = txt + 'background-color:#' + this.dataParameter[i][j][3].Get24bitColourHex() + ';';
                                    if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null && this.dataParameter[i][j][4].IsType('TColourRGBA'))
                                        txt = txt + 'color:#' + this.dataParameter[i][j][4].Get24bitColourHex() + ';';
                                    txt = txt + '">';
                                }
                            }
                        }
                        if (this.dataName[i] === 'TextArea')
                        {
                            if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                            {
                                if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                                {
                                    txt = txt + '<textarea id="' + this.data[i][j] + '" ';
                                    if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null && this.dataParameter[i][j][1] > 0)
                                        txt = txt + 'cols="' + this.dataParameter[i][j][1] + '"';
                                    if (this.dataParameter[i][j].length > 10 && typeof this.dataParameter[i][j][10] !== 'undefined' && this.dataParameter[i][j][10] !== null && this.dataParameter[i][j][10] > 0)
                                        txt = txt + 'rows="' + this.dataParameter[i][j][10] + '"';
                                    if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                        txt = txt + ' class="' + this.dataParameter[i][j][2] + '"';
                                    if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null)
                                        txt = txt + ' onchange="' + this.dataParameter[i][j][5] + "(this,event,'" + this.data[i][j] + "'" + ')"';
                                    if (this.dataParameter[i][j].length > 6 && typeof this.dataParameter[i][j][6] !== 'undefined' && this.dataParameter[i][j][6] !== null)
                                        txt = txt + ' onkeypress="' + this.dataParameter[i][j][6] + "(this,event,'" + this.data[i][j] + "'" + ')"';
                                    if (this.dataParameter[i][j].length > 7 && typeof this.dataParameter[i][j][7] !== 'undefined' && this.dataParameter[i][j][7] !== null)
                                        txt = txt + ' onkeydown="' + this.dataParameter[i][j][7] + "(this,event,'" + this.data[i][j] + "'" + ')"';
                                    if (this.dataParameter[i][j].length > 8 && typeof this.dataParameter[i][j][8] !== 'undefined' && this.dataParameter[i][j][8] !== null)
                                        txt = txt + ' onkeyup="' + this.dataParameter[i][j][8] + "(this,event,'" + this.data[i][j] + "'" + ')"';
                                    txt = txt + ' style="';
                                    if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null && this.dataParameter[i][j][3].IsType('TColourRGBA'))
                                        txt = txt + 'background-color:#' + this.dataParameter[i][j][3].Get24bitColourHex() + ';';
                                    if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null && this.dataParameter[i][j][4].IsType('TColourRGBA'))
                                        txt = txt + 'color:#' + this.dataParameter[i][j][4].Get24bitColourHex() + ';';
                                    txt = txt + '">';
                                    txt = txt + this.dataParameter[i][j][0];
                                    txt = txt + '</textarea>';
                                }
                            }
                        }
                        if (this.dataName[i] === 'Button')
                        {
                            if (this.dataParameter[i][j].length > 0)// && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                            {
                                if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                                {
                                    txt = txt + '<button ';
                                    txt = txt + 'id="' + this.data[i][j] + '" ';
                                    if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                        txt = txt + ' class="' + this.dataParameter[i][j][0] + '"';
                                    if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                                        txt = txt + ' onclick="' + this.dataParameter[i][j][4] + '(this,event)"';
                                    txt = txt + ' style="';
                                    if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null && this.dataParameter[i][j][1].IsType('TColourRGBA'))
                                        txt = txt + 'background-color:#' + this.dataParameter[i][j][1].Get24bitColourHex() + ';';
                                    if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null && this.dataParameter[i][j][2].IsType('TColourRGBA'))
                                        txt = txt + 'color:#' + this.dataParameter[i][j][2].Get24bitColourHex() + ';';
                                    txt = txt + '">';
                                    if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                        txt = txt + this.dataParameter[i][j][3];
                                    txt = txt + '</button>';
                                }
                            }
                        }
                        if (this.dataName[i] === 'ButtonLoadImage')
                        {
                            if (this.dataParameter[i][j].length > 0)// && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                            {
                                if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                                {
                                    txt = txt + '<input type="file" ';
                                    txt = txt + 'id="' + this.data[i][j] + '" ';
                                    if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                        txt = txt + ' class="' + this.dataParameter[i][j][0] + '"';
 /*                                   txt = txt + ' style="';
                                    if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null && this.dataParameter[i][j][1].IsType('TColourRGBA'))
                                        txt = txt + 'background-color:#' + this.dataParameter[i][j][1].Get24bitColourHex() + ';';
                                    if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null && this.dataParameter[i][j][2].IsType('TColourRGBA'))
                                        txt = txt + 'color:#' + this.dataParameter[i][j][2].Get24bitColourHex() + ';';*/
                                    txt = txt + '>';
//                                    txt = txt + '<div id="result" class="result"><p>This demo works only in browsers with support for the <a href="https://developer.mozilla.org/en/DOM/window.URL">URL</a> or <a href="https://developer.mozilla.org/en/DOM/FileReader">FileReader</a> API.</p></div>';
                                    
//                                    var txt2 = "$('#" + this.data[i][j] + "').on('change', dropChangeHandlerLoadFile)";
//                                    eval(txt2);
                                    
//                                    dropChangeHandlerLoadFile
/*                                    txt = txt + '<button ';
                                    txt = txt + 'id="' + this.data[i][j] + '" ';
                                    if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                        txt = txt + ' class="' + this.dataParameter[i][j][0] + '"';
                                    if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                                        txt = txt + ' onclick="' + this.dataParameter[i][j][4] + '(this,event)"';
                                    txt = txt + ' style="';
                                    if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null && this.dataParameter[i][j][1].IsType('TColourRGBA'))
                                        txt = txt + 'background-color:#' + this.dataParameter[i][j][1].Get24bitColourHex() + ';';
                                    if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null && this.dataParameter[i][j][2].IsType('TColourRGBA'))
                                        txt = txt + 'color:#' + this.dataParameter[i][j][2].Get24bitColourHex() + ';';
                                    txt = txt + '">';
                                    if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                        txt = txt + this.dataParameter[i][j][3];
                                    txt = txt + '</button>';*/
                                }
                            }
                        }
                        if (this.dataName[i] === 'Slider')
                        {
                            if (this.dataParameter[i][j].length > 0)// && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                            {
                                if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                                {
                                    txt = txt + '<input type="range" ';
                                    txt = txt + 'id="' + this.data[i][j] + '" ';
                                    if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                        txt = txt + ' class="' + this.dataParameter[i][j][0] + '"';
                                    if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                        txt = txt + ' value="' + this.dataParameter[i][j][1] + '"';
                                    if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                        txt = txt + ' min="' + this.dataParameter[i][j][2] + '"';
                                    if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                        txt = txt + ' max="' + this.dataParameter[i][j][3] + '"';
                                    if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                                        txt = txt + ' step="' + this.dataParameter[i][j][4] + '"';
                                    if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null)
                                        txt = txt + ' onclick="' + this.dataParameter[i][j][5] + '(this,event)"';
                                    if (this.dataParameter[i][j].length > 8 && typeof this.dataParameter[i][j][8] !== 'undefined' && this.dataParameter[i][j][8] !== null)
                                        txt = txt + ' onchange="' + this.dataParameter[i][j][8] + '(this,event)"';
                                    if (this.dataParameter[i][j].length > 6 && typeof this.dataParameter[i][j][6] !== 'undefined' && this.dataParameter[i][j][6] !== null)
                                        txt = txt + ' style="width:' + this.dataParameter[i][j][6] + '"';
                                    txt = txt + '>';
                                }
                            }
                        }
                        if (this.dataName[i] === 'ParagraphText')
                        {
                            if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined')// && this.dataParameter[i][j][0] !== null)
                            {
                                if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                                {
                                    txt = txt + '<span id="' + this.data[i][j] + '" ';
                                    if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                        txt = txt + ' class="' + this.dataParameter[i][j][2] + '"';
                                    txt = txt + ' style="';
                                    if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null && this.dataParameter[i][j][3].IsType('TColourRGBA'))
                                        txt = txt + 'background-color:#' + this.dataParameter[i][j][3].Get24bitColourHex() + ';';
                                    if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null && this.dataParameter[i][j][4].IsType('TColourRGBA'))
                                        txt = txt + 'color:#' + this.dataParameter[i][j][4].Get24bitColourHex() + ';';
                                    txt = txt + '">';
                                    if (this.dataParameter[i][j][0] !== null)
                                        txt = txt + this.dataParameter[i][j][0];
                                    txt = txt + '</span>';
                                }
                            }
                        }
                        if (this.dataName[i] === 'ParagraphImage')
                        {
                            if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                            {
                                if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                                {
                                    txt = txt + '<img id="' + this.data[i][j] + '" ';
                                    if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                        txt = txt + ' class="' + this.dataParameter[i][j][2] + '"';
                                    if (this.dataParameter[i][j][0] !== null)
                                        txt = txt + ' src="' + this.dataParameter[i][j][0] + '"';
                                    if ((typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null) || (typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null))
                                    {
                                        txt = txt + ' style="';
                                        if (typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                        {
                                            txt = txt + 'width:' + this.dataParameter[i][j][3] + 'ex;';
                                        }
                                        if (typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                                        {
                                            txt = txt + 'height:' + this.dataParameter[i][j][4] + 'ex';
                                        }
                                        txt = txt + '" ';
                                    }
                                    txt = txt + '>';
                                }
                            }
                        }

                        if (this.dataName[i] === 'Rectangle')
                        {
                            if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                if (typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                {
									txt = txt + '<svg style="width:' + this.dataParameter[i][j][0] + 'ex;height:' + this.dataParameter[i][j][1] + 'ex">'
                                    txt = txt + '<rect width="' + this.dataParameter[i][j][0] + 'ex" height="' + this.dataParameter[i][j][1] + 'ex" style="fill:#' + this.dataParameter[i][j][2].Get24bitColourHex();
									if (typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null && this.dataParameter[i][j][3] > 0)
									{
										txt = txt + ';stroke-width:' + this.dataParameter[i][j][3];
										if (typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
										{
											txt = txt  + ';stroke:#' + this.dataParameter[i][j][4].Get24bitColourHex();
										}
									}
//                                    txt = txt + '<svg style="stroke: maroon;stroke-width: 2px;background:#' + this.dataParameter[i][j][2].Get24bitColourHex() + ';width:' + this.dataParameter[i][j][0] + 'ex;height:' + this.dataParameter[i][j][1] + 'ex"';
//                                    txt = txt + '></svg>';
                                    txt = txt + '"/></svg>';
                                }
                        }

                        if (this.dataName[i] === 'Generate')
                        {
                            if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                            {
                                if (this.dataParameter[i][j].length > 9 && typeof this.dataParameter[i][j][9] !== 'undefined' && this.dataParameter[i][j][9] !== null && this.dataParameter[i][j][9] === 'svg')
                                {
                                    txt = txt + '<SlideSvgObject id="' + this.data[i][j] + '"';
                                    txt = txt + '>';
                                    txt = txt + '</SlideSvgObject>';
/*                                    txt = txt + '<svg id="slide' + this.data[i][j] + '"';
                                    if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 1)
                                    {
                                        txt = txt + ' width="'+ this.dataParameter[i][j][0] + '" height="' + this.dataParameter[i][j][1] + '" ';
                                    }
                                    txt = txt + '>';
                                    if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                    {
                                        tabObj = this.dataParameter[i][j][2];
                                        if (typeof tabObj !== 'undefined' && tabObj !== null)
                                        {
                                            ctx = objM.newObject('TDrawSvgContext');
                                            id = this.data[i][j];
                                            if (typeof id !== 'undefined' && id !== null)
                                            {
                                                matrix = objM.newObject('TMatrixTransformation3D');
                                                matrix2 = objM.newObject('TMatrixTransformation3D');
    //                                            matrix.SetScaleMatrix3D();
                                                scaleX = this.dataParameter[i][j][0]/this.dataParameter[i][j][3];
                                                scaleY = -this.dataParameter[i][j][1]/this.dataParameter[i][j][4];
                                                scaleZ = this.dataParameter[i][j][5];
                                                matrix.SetScaleMatrix3D(scaleX,scaleY,scaleZ);
                                                matrix2.SetTranslationMatrix(-this.dataParameter[i][j][6],this.dataParameter[i][j][7],this.dataParameter[i][j][8]);
                                                matrix.MatrixMultiplication(matrix2);
                                                ctx.SetTransformation(matrix);
                                                for (k = 0;k < tabObj.length;k++)
                                                {
                                                    obj = tabObj[k];
                                                    if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                                    {
                                                        obj.DrawFigure(ctx);
                                                    }
                                                }
                                                txt = txt + ctx.GetContext();
                                            }
                                        }


                                        //                                    if (this.dataParameter[i][j])
                                    }
                                    txt = txt + '</svg>';*/
                                }else
                                {
                                    txt = txt + '<canvas id="slide' + this.data[i][j] + '"';
                                    if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 1)
                                    {
                                        txt = txt + ' width="'+ this.dataParameter[i][j][0] + '" height="' + this.dataParameter[i][j][1] + '" ';
                                    }
                                    txt = txt + '>';
                                    txt = txt + '</canvas>';
                                }
                            }
                        }                    
                        if (this.dataName[i] === 'GenerateThree')
                        {
                            if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                            {
                                txt = txt + '<div style="display: inline-flex">';
                                txt = txt + '<div id="' + this.data[i][j] + '" ';
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 24)
				{
                                    txt = txt + 'class="' + this.dataParameter[i][j][24] + '" ';
				}
                                txt = txt + ' >';
                                txt = txt + '</div>';
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 16)
                                {
                                    var tmp = this.dataParameter[i][j][16];
                                    if (typeof tmp !== 'undefined' && tmp !== null && tmp.length > 0)
                                    {
                                        txt = txt + '<div style="text-align:center;font-size: 10pt">';
                                        if (tmp.length > 0 && typeof tmp[2] !== 'undefined' && tmp[2] !== null && tmp[2].IsType('TActionThreeRotateButton'))
                                            txt = txt + '<button id="' + tmp[2].GetId() + '">↑</button><br>';
                                        if (tmp.length > 0 && typeof tmp[0] !== 'undefined' && tmp[0] !== null && tmp[0].IsType('TActionThreeRotateButton'))
                                            txt = txt + '<button id="' + tmp[0].GetId() + '">←</button>';
                                        if (tmp.length > 2 && typeof tmp[1] !== 'undefined' && tmp[1] !== null && tmp[1].IsType('TActionThreeRotateButton'))
                                            txt = txt + '<button id="' + tmp[1].GetId() + '">→</button><br>';
                                        if (tmp.length > 3 && typeof tmp[3] !== 'undefined' && tmp[3] !== null && tmp[3].IsType('TActionThreeRotateButton'))
                                            txt = txt + '<button id="' + tmp[3].GetId() + '">↓</button>';
                                        txt = txt + '</div>';
                                    }
                                }
                                txt = txt + '</div>';
                            }
                        }                    
                        if (this.dataName[i] === 'GenerateCanvas')
                        {
                            txt = txt + '<canvas id="' + this.data[i][j] + '"';
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 1)
                            {
                                   txt = txt + ' width="'+ this.dataParameter[i][j][0] + '" height="' + this.dataParameter[i][j][1] + '" ';
                            }
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 16)
                                txt = txt + ' class="'+ this.dataParameter[i][j][16] + '" ';
                            txt = txt + '>';
                            txt = txt + '</canvas>';                        
                        }
                        if (this.dataName[i] === 'Timer')
                        {
                            if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null && this.data[i][j].IsType('TTimer'))
                            {
                                this.data[i][j].Start();
                            }
                        }
                        if (this.dataName[i] === 'TableShow' || this.dataName[i] === 'TableEdit')
                        {
                            if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 1)
                                if (typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                    if (typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                    {
                                        if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                            style = this.dataParameter[i][j][2];
                                        else
                                            style = null;
                                        var lineWidth;
                                        if (this.dataParameter[i][j].length > 14 && typeof this.dataParameter[i][j][14] !== 'undefined' && this.dataParameter[i][j][14] !== null)
                                            lineWidth = this.dataParameter[i][j][14];
                                        else
                                            lineWidth = null;
                                        var id = this.dataParameter[i][j][0];
                                        var data = this.dataParameter[i][j][1];
                                        var ii,jj;
                                        txt = txt + '<table id="' + id + '" ';
                                        if (style !== null)
                                            txt = txt + ' class="slide' + style + '" ';                                    
                                        txt = txt + '>';
                                        var w;
                                        if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                                            w = this.dataParameter[i][j][4];
                                        else
                                            w = null;
                                        var h;
                                        if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null)
                                            h = this.dataParameter[i][j][5];
                                        else
                                            h = null;
                                        var mincolour;
                                        if (this.dataParameter[i][j].length > 6 && typeof this.dataParameter[i][j][6] !== 'undefined' && this.dataParameter[i][j][6] !== null)
                                            mincolour = this.dataParameter[i][j][6];
                                        else
                                            mincolour = null;
                                        var maxcolour;
                                        if (this.dataParameter[i][j].length > 7 && typeof this.dataParameter[i][j][7] !== 'undefined' && this.dataParameter[i][j][7] !== null)
                                            maxcolour = this.dataParameter[i][j][7];
                                        else
                                            maxcolour = null;
                                        var minValue;
                                        if (this.dataParameter[i][j].length > 8 && typeof this.dataParameter[i][j][8] !== 'undefined' && this.dataParameter[i][j][8] !== null)
                                            minValue = this.dataParameter[i][j][8];
                                        else
                                            minValue = null;
                                        var maxValue;
                                        if (this.dataParameter[i][j].length > 9 && typeof this.dataParameter[i][j][9] !== 'undefined' && this.dataParameter[i][j][9] !== null)
                                            maxValue = this.dataParameter[i][j][9];
                                        else
                                            maxValue = null;
                                        var minColourTextValue;
                                        if (this.dataParameter[i][j].length > 10 && typeof this.dataParameter[i][j][10] !== 'undefined' && this.dataParameter[i][j][10] !== null)
                                            minColourTextValue = this.dataParameter[i][j][10];
                                        else
                                            minColourTextValue = null;
                                        var maxColourTextValue;
                                        if (this.dataParameter[i][j].length > 11 && typeof this.dataParameter[i][j][11] !== 'undefined' && this.dataParameter[i][j][11] !== null)
                                            maxColourTextValue = this.dataParameter[i][j][11];
                                        else
                                            maxColourTextValue = null;
                                        var alignTextX;
                                        if (this.dataParameter[i][j].length > 12 && typeof this.dataParameter[i][j][12] !== 'undefined' && this.dataParameter[i][j][12] !== null)
                                            alignTextX = this.dataParameter[i][j][12];
                                        else
                                            alignTextX = null;
                                        var alignTextY;
                                        if (this.dataParameter[i][j].length > 13 && typeof this.dataParameter[i][j][13] !== 'undefined' && this.dataParameter[i][j][13] !== null)
                                            alignTextY = this.dataParameter[i][j][13];
                                        else
                                            alignTextY = null;
                                        var colourStyle = null;
                                        if (this.dataParameter[i][j].length > 16 && typeof this.dataParameter[i][j][16] !== 'undefined' && this.dataParameter[i][j][16] !== null)
                                            colourStyle = this.dataParameter[i][j][16];
                                        var colourMap = null;
                                        if (this.dataParameter[i][j].length > 17 && typeof this.dataParameter[i][j][17] !== 'undefined' && this.dataParameter[i][j][17] !== null)
                                            colourMap = this.dataParameter[i][j][17];
                                        var colourMapMin = null;
                                        if (this.dataParameter[i][j].length > 18 && typeof this.dataParameter[i][j][18] !== 'undefined' && this.dataParameter[i][j][18] !== null)
                                            colourMapMin = this.dataParameter[i][j][18];
                                        var colourMapMax = null;
                                        if (this.dataParameter[i][j].length > 19 && typeof this.dataParameter[i][j][19] !== 'undefined' && this.dataParameter[i][j][19] !== null)
                                            colourMapMax = this.dataParameter[i][j][19];
                                        var textSize = null;
                                        if (this.dataParameter[i][j].length > 22 && typeof this.dataParameter[i][j][22] !== 'undefined' && this.dataParameter[i][j][22] !== null)
                                            textSize = this.dataParameter[i][j][22];
                                        var colourTmp = null,colourTmp2 = null,YN = false,YN2 = false,k;
                                        for (ii = 0;ii < data.length;ii++)
                                        {
                                            txt = txt + '<tr ';
                                            if (h !== null)
                                                txt = txt + 'style="height:' + h + 'px"';
                                            txt = txt + '>';
                                            for(jj = 0;jj < data[ii].length;jj++)
                                            {
                                                colourTmp = null;
                                                colourTmp2 = null;
                                                var tmp_data;
                                                if (this.dataParameter[i][j].length > 15 && typeof this.dataParameter[i][j][15] !== 'undefined' && this.dataParameter[i][j][15] !== null && this.dataParameter[i][j][15]) 
                                                    tmp_data = Hex2Numeric(data[ii][jj]);
                                                else
                                                    tmp_data = data[ii][jj];
                                                if (colourStyle === 'colour24bit')
                                                {
                                                    colourTmp = objM.newObject('TColourRGBA');
                                                    var r = Math.floor(tmp_data/(256*256));
                                                    var g = Math.floor((tmp_data & (255*256))/256);
                                                    var b = Math.floor(tmp_data & 255);
                                                    if (colourTmp !== null)
                                                        colourTmp.SetColourRGBA(Math.floor(tmp_data/(256*256))/255,Math.floor((tmp_data & (255*256))/256)/255,Math.floor(tmp_data & 255)/255,1);
                                                }else
                                                {
                                                    var tmp_data;
                                                    if (this.dataParameter[i][j].length > 15 && typeof this.dataParameter[i][j][15] !== 'undefined' && this.dataParameter[i][j][15] !== null && this.dataParameter[i][j][15]) 
                                                        tmp_data = Hex2Numeric(data[ii][jj]);
                                                    else
                                                        tmp_data = data[ii][jj];
                                                    if (minValue !== null && maxValue !== null)
                                                    {
                                                        var tmpValue = (tmp_data - minValue)/(maxValue - minValue);
                                                        if (mincolour !== null && maxcolour !== null)
                                                        {
                                                            colourTmp = maxcolour.MeanColour(tmpValue,mincolour);
                                                        }
                                                        if (minColourTextValue !== null && maxColourTextValue !== null)
                                                        {
                                                            if (tmpValue >= 0.5)
                                                                colourTmp2 = maxColourTextValue;
                                                            else
                                                                colourTmp2 = minColourTextValue;
                                                        }
                                                    }
                                                    if (colourMap !== null && colourMapMin !== null && colourMapMax !== null)
                                                    {
                                                        for (k = 0;k < colourMap.length;k++)
                                                        {
                                                            if (tmp_data >= colourMapMin[k] && tmp_data <= colourMapMax[k])
                                                            {
                                                                colourTmp = colourMap[k];
                                                                colourTmp2 = maxColourTextValue;
                                                                break;
                                                            }
                                                        }
                                                    }
                                                }
                                                YN = false;YN2 = false;
                                                txt = txt + '<td style="';
                                                if (w !== null && this.dataName[i] === 'TableShow')
                                                {
                                                    txt = txt + 'width:' + w + 'px';
                                                    YN = true;
                                                }
                                                if (lineWidth !== null)
                                                {
                                                    if (YN)
                                                        txt = txt + ';';
                                                    txt = txt + 'border:' + lineWidth +'px solid black';
                                                    YN = true;
                                                }
                                                if (alignTextX !== null)
                                                {
                                                    if (YN)
                                                        txt = txt + ';';
                                                    txt = txt + 'text-align:' + alignTextX;
                                                    YN = true;
                                                }
                                                txt = txt + '">';
                                                if (this.dataName[i] === 'TableShow')
                                                {
                                                    txt = txt + '<div style="';
                                                    if (colourTmp !== null)
                                                    {
                                                        if (YN2)
                                                            txt = txt + ';';
                                                        txt = txt + 'background-color: #' + colourTmp.Get24bitColourHex();
                                                        YN2 = true;
                                                    }
                                                    if (colourTmp2 !== null)
                                                    {
                                                        if (YN)
                                                            txt = txt + ';';
                                                        txt = txt + 'color: #' + colourTmp2.Get24bitColourHex();
                                                        YN = true;
                                                    }
                                                    txt = txt + '" ';
                                                    if (id !== 'undefined' && id !== null)
                                                        txt = txt + ' id="' + id + '_' + ii + '_' + jj + '" ' ;
                                                    if (colourStyle === 'colour24bit')
                                                    {
                                                        txt = txt + '><span style="color: red">' + data[ii][jj].substring(0,2) + '</span>';
                                                        txt = txt + '<span style="color: green">' + data[ii][jj].substring(2,4) + '</span>';
                                                        txt = txt + '<span style="color: blue">' + data[ii][jj].substring(4,6) + '</span></div></td>';
                                                    }
                                                    else
                                                        txt = txt + '>' +  data[ii][jj] + '</div></td>';
                                                }else
                                                {
                                                    if (colourStyle === 'colour24bit')
                                                    {
                                                        txt = txt  + '<div contenteditable="true" ';
                                                        if (id !== 'undefined' && id !== null)
                                                            txt = txt + ' id="' + id + '_' + ii + '_' + jj + '" ' ;
                                                        txt = txt + ' style="';
                                                        if (colourTmp !== null)
                                                        {
                                                            if (YN2)
                                                                txt = txt + ';';
                                                            txt = txt + 'background-color: #' + colourTmp.Get24bitColourHex();
                                                            YN2 = true;
                                                        }
                                                        if (w !== null)
                                                        {
                                                            if (YN2)
                                                                txt = txt + ';';
                                                            txt = txt + 'width:' + w + 'pt' ;
                                                            YN2 = true;
                                                        }
                                                        if (alignTextX !== null)
                                                        {
                                                            if (YN2)
                                                                txt = txt + ';';
                                                            txt = txt + 'text-align:' + alignTextX;
                                                            YN2 = true;
                                                        }
                                                        if (colourTmp2 !== null)
                                                        {
                                                            if (YN)
                                                                txt = txt + ';';
                                                            txt = txt + 'color: #' + colourTmp2.Get24bitColourHex();
                                                            YN = true;
                                                        }
                                                        txt = txt + '"';
                                                        txt = txt + '>';
                                                        txt = txt + '<span style="color: red">' + data[ii][jj].substring(0,2) + '</span>';
                                                        txt = txt + '<span style="color: green">' + data[ii][jj].substring(2,4) + '</span>';
                                                        txt = txt + '<span style="color: blue">' + data[ii][jj].substring(4,6) + '</span>';
                                                        txt = txt + '</div></td>';
                                                    }else
                                                    {
                                                        txt = txt  + '<input type="text" value="' + data[ii][jj] + '"';
                                                        if (w !== null)
                                                            txt = txt + ' size="' + w + '" ' ;
                                                        if (id !== 'undefined' && id !== null)
                                                            txt = txt + ' id="' + id + '_' + ii + '_' + jj + '" ' ;
                                                        txt = txt + ' style="';
                                                        if (colourTmp !== null)
                                                        {
                                                            if (YN2)
                                                                txt = txt + ';';
                                                            txt = txt + 'background-color: #' + colourTmp.Get24bitColourHex();
                                                            YN2 = true;
                                                        }
                                                        if (alignTextX !== null)
                                                        {
                                                            if (YN2)
                                                                txt = txt + ';';
                                                            txt = txt + 'text-align:' + alignTextX;
                                                            YN2 = true;
                                                        }
                                                        if (textSize !== null)
                                                        {
                                                            if (YN2)
                                                                txt = txt + ';';
                                                            txt = txt + 'font-size:' + textSize + 'px';
                                                            YN2 = true;
                                                        }
                                                        if (lineWidth !== null || lineWidth === 0)
                                                        {
                                                            if (YN2)
                                                                txt = txt + ';';
                                                            txt = txt + 'border:none';
                                                            YN2 = true;
                                                        }
                                                        if (colourTmp2 !== null)
                                                        {
                                                            if (YN)
                                                                txt = txt + ';';
                                                            txt = txt + 'color: #' + colourTmp2.Get24bitColourHex();
                                                            YN = true;
                                                        }
                                                        txt = txt + '"';
                                                        txt = txt + '></td>';
                                                    }
                                        
                                                }
                                            }
                                            txt = txt + '</tr>';
                                        }
                                        txt = txt + '</table>';
                                    }

                        }
                        if (this.dataName[i] === 'Table')
                        {
                            if (this.data[i][j] === 'Start')
                            {
                                var styleYN = false;
                                tableYN = true;

                                txt = txt + '<SlideP>';
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                    style = this.dataParameter[i][j][3];
                                else
                                    style = null;
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                    txt = txt + '<table id="' + this.dataParameter[i][j][0] + '"';
                                else
                                    txt = txt + '<table';
                                txt = txt + ' style="';
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 9 && this.dataParameter[i][j][9] !== null)
                                {
                                    txt = txt + 'width:' + this.dataParameter[i][j][9];
                                    styleYN = true;
                                }
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 10 && this.dataParameter[i][j][10] !== null)
                                {
                                    if (styleYN)
                                        txt = txt + ';';
                                    txt = txt + 'font-size:' + this.dataParameter[i][j][10];
                                    styleYN = true;
                                }
                                txt = txt + '"';
                                if (style !== null)
                                    txt = txt + ' class="slide' + style + '">';                                    
                                else
                                    txt = txt + '>';                                    

                            }
                            if (this.data[i][j] === 'Stop')
                            {
                                tableYN = false;
                                style = null;
                                txt = txt + '</table>';
                                txt = txt + '</SlideP>';
                            }
                        }                    
                        if (this.dataName[i] === 'tr')
                        {
                            if (this.data[i][j] === 'Start')
                            {
                                txt = txt + '<tr';
                                if (style !== null)
                                    txt = txt + ' class="slide' + style + '">';
                                else
                                    txt = txt + '>';                                    

                            }
                            if (this.data[i][j] === 'Stop')
                                txt = txt + '</tr>';
                        }                    
                        if (this.dataName[i] === 'th' || this.dataName[i] === 'th2' )
                        {
                            if (this.data[i][j] === 'Start')
                            {
                                var oldStyle = style;
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                    style = this.dataParameter[i][j][1];
                                txt = txt + '<th';
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                   txt = txt + ' id="' + this.dataParameter[i][j][0] + '"';
                                txt = txt + ' style="';
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 2 && this.dataParameter[i][j][2] !== null)
                                {
                                    txt = txt + 'width:' + this.dataParameter[i][j][2];
                                    styleYN = true;
                                }
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 3 && this.dataParameter[i][j][3] !== null)
                                {
                                    if (styleYN)
                                        txt = txt + ';';
                                    txt = txt + 'font-size:' + this.dataParameter[i][j][3];
                                    styleYN = true;
                                }
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 6 && this.dataParameter[i][j][6] !== null && this.dataParameter[i][j][6].IsType('TColourTXT'))
                                {
                                    if (styleYN)
                                        txt = txt + ';';
                                    var r = 255*this.dataParameter[i][j][6].GetR();
                                    var g = 255*this.dataParameter[i][j][6].GetG();
                                    var b = 255*this.dataParameter[i][j][6].GetB();
                                    txt = txt + 'background-color:rgb(' + r + ',' +  g + ',' +  b + ')';
                                    styleYN = true;
                                }
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 7 && this.dataParameter[i][j][7] !== null && this.dataParameter[i][j][7].IsType('TColourTXT'))
                                {
                                    if (styleYN)
                                        txt = txt + ';';
                                    var r = 255*this.dataParameter[i][j][7].GetR();
                                    var g = 255*this.dataParameter[i][j][7].GetG();
                                    var b = 255*this.dataParameter[i][j][7].GetB();
                                    txt = txt + 'color:rgb(' + r + ',' +  g + ',' +  b + ')';
                                    styleYN = true;
                                }
                                txt = txt + '"';
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 4 && this.dataParameter[i][j][4] !== null && this.dataParameter[i][j][4] > 0)
                                    txt = txt + ' rowspan="' + this.dataParameter[i][j][4] + '"';
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 5 && this.dataParameter[i][j][5] !== null && this.dataParameter[i][j][5] > 0)
                                    txt = txt + ' colspan="' + this.dataParameter[i][j][5] + '"';
                                if (style !== null)
                                    txt = txt + ' class="slide' + style + '">';
                                else
                                    txt = txt + '>';
                                style = oldStyle;
                            }
                            if (this.data[i][j] === 'Stop')
                                txt = txt + '</th>';
                        }                    
                        if (this.dataName[i] === 'td' )
                        {
                            if (this.data[i][j] === 'Start')
                            {
                                var oldStyle = style;
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                    style = this.dataParameter[i][j][1];
                                txt = txt + '<td';
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                    txt = txt + ' id="' + this.dataParameter[i][j][0] + '"';
                                txt = txt + ' style="';
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 2 && this.dataParameter[i][j][2] !== null)
                                {
                                    txt = txt + 'width:' + this.dataParameter[i][j][2];
                                    styleYN = true;
                                }
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 3 && this.dataParameter[i][j][3] !== null)
                                {
                                    if (styleYN)
                                        txt = txt + ';';
                                    txt = txt + 'font-size:' + this.dataParameter[i][j][3];
                                    styleYN = true;
                                }
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 6 && this.dataParameter[i][j][6] !== null && this.dataParameter[i][j][6].IsType('TColourTXT'))
                                {
                                    if (styleYN)
                                        txt = txt + ';';
                                    var r = 255*this.dataParameter[i][j][6].GetR();
                                    var g = 255*this.dataParameter[i][j][6].GetG();
                                    var b = 255*this.dataParameter[i][j][6].GetB();
                                    txt = txt + 'background-color:rgb(' + r + ',' +  g + ',' +  b + ')';
                                    styleYN = true;
                                }
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 7 && this.dataParameter[i][j][7] !== null && this.dataParameter[i][j][7].IsType('TColourTXT'))
                                {
                                    if (styleYN)
                                        txt = txt + ';';
                                    var r = 255*this.dataParameter[i][j][7].GetR();
                                    var g = 255*this.dataParameter[i][j][7].GetG();
                                    var b = 255*this.dataParameter[i][j][7].GetB();
                                    txt = txt + 'color:rgb(' + r + ',' +  g + ',' +  b + ')';
                                    styleYN = true;
                                }
                                txt = txt + '"';
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 4 && this.dataParameter[i][j][4] !== null && this.dataParameter[i][j][4] > 0)
                                    txt = txt + ' rowspan="' + this.dataParameter[i][j][4] + '"';
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 5 && this.dataParameter[i][j][5] !== null && this.dataParameter[i][j][5] > 0)
                                    txt = txt + ' colspan="' + this.dataParameter[i][j][5] + '"';
                                if (style !== null)
                                    txt = txt + ' class="slide' + style + '" >';
                                else
                                    txt = txt + '>';
                                style = oldStyle;
                            }
                            if (this.data[i][j] === 'Stop')
                                txt = txt + '</td>';
                        }                    



                    }
                }
            }

            if (this.GetNumberNote() < 0)
            {
                if (number2 !== null)
                    txt = txt + '</SlideCustom_' + this.data[number2][0] + '>';
                txt = txt + '</SlideText>';
                txt = txt + '</SlideBlock>';
            }else
                txt = txt + '<SlideNoteBlock>';
        }else
        {
        }
        return txt;
    };

};

THTMLSlide.prototype = new TGenerateHTML();


function TTeXSlide(){
    
    var type = 'TTeXSlide';
    TTeXSlide.prototype.InitConstructor = function(){
        TGenerateTeX.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.SetObjectType('TeX');
    };
    this.InitConstructor();

    TTeXSlide.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TGenerateTeX.prototype.IsType.call(this,_type);
    };

    TTeXSlide.prototype.Init = function(_object){
        TGenerateTeX.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TTeXSlide'))
        {
        }
    };
    
    TTeXSlide.prototype.GetTXT = function(){
        var txt = '';
        var objM = this.GetObjectManager();
        if (objM === null)
            return;
        
        if (this.GetSlide())
        {
//            if (this.GetNumberNote() < 0)
            {
                var i,j,tmp2,enumYN = 0,itemizeYN = 0,noteYN = false;
                var numberCatalog = this.Find('ImageCatalog'),tmp,maxCol = 0,ii,numberCol=0;
                var paragraphEnterYN = true,lbraceFigure = false;
                var tabObj,ctx,matrix,matrix2,scaleX,scaleY,scaleZ,id,k,obj,startRadioButtoEmph;

                txt = txt + '\\begin{frame}[fragile]\n';

                for (i = 0;i < this.data.length;i++)
                {
                    for (j = 0;j < this.data[i].length;j++)
                    {
                        if (this.dataName[i] === 'Note')
                        {
                            if (this.data[i][j] === 'Start')
                                noteYN = true;
                            if (this.data[i][j] === 'Stop')
                                noteYN = false;
                        }
                        if (!noteYN)
                        {
                            if (this.dataName[i] === 'Paragraph')
                            {
                                if (this.data[i][j] === 'Stop')
                                {
                                    if (paragraphEnterYN)
                                    {
                                        if (enumYN === 0 && itemizeYN === 0)
                                            txt = txt + '\n\n';
                                        else
                                            txt = txt + '\n';
                                    }
                                }
                            }
                            if (this.dataName[i] === 'PT')
                                txt = txt + this.data[i][j];
                            if (this.dataName[i] === 'Symbol')
                            {
                                if (this.data[i][j] === 'Dash')
                                    txt = txt +'---';
                                if (this.data[i][j] === 'Hash')
                                    txt = txt +'\\#';
                                if (this.data[i][j] === 'Underscore')
                                    txt = txt +'\\_';
                                if (this.data[i][j] === 'Backslash')
                                    txt = txt + '\\textbackslash ';
                                if (this.data[i][j] === 'Br' || this.data[i][j] === 'br')
                                    txt = txt + '\\newline ';
                                if (this.data[i][j] === 'Space')
                                    txt = txt + '\\hphantom{i} ';
                                if (this.data[i][j] === 'Less')
                                    txt = txt +'<';
                                if (this.data[i][j] === 'Greater')
                                    txt = txt +'>';
                                if (this.data[i][j] === 'Percent')
                                    txt = txt +'\%';
                            }                    
                            if (this.dataName[i] === 'SpaceLength')
                            {
                                if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                                {
                                    txt = txt + '\\hspace*{' + this.data[i][j] + '}';
                                }
                            }
                            if (this.dataName[i] === 'Emph')
                            {
                                if (this.data[i][j] === 'Start')
                                    txt = txt + '\\emph{';
                                if (this.data[i][j] === 'Stop')
                                    txt = txt + '}';
                            }
                            if (this.dataName[i] === 'Code')
                            {
                                if (this.data[i][j] === 'Start')
                                    txt = txt + '\\verb¤';
                                if (this.data[i][j] === 'Stop')
                                    txt = txt + '¤';
                            }                            
                            if (this.dataName[i] === 'Href')
                            {
                                if (this.data[i][j] === 'Start')
                                {
                                    txt = txt + '\\href{';
                                    if (this.dataParameter[i][j][0] === 'email')
                                        txt = txt + 'mailto:';
                                    txt = txt + this.dataParameter[i][j][1] + '}{';
                                }
                                if (this.data[i][j] === 'Stop')
                                    txt = txt + '}';
                            }                            
                            if (this.dataName[i] === 'LocalHref')
                            {
                                if (this.data[i][j] === 'Start')
                                {
                                    txt = txt + '\\href{';
                                    if (this.dataParameter[i][j][0] === 'email')
                                        txt = txt + 'mailto:';
                                    txt = txt + this.dataParameter[i][j][1] + '}{';
                                }
                                if (this.data[i][j] === 'Stop')
                                    txt = txt + '}';
                            }
                            if (this.dataName[i] === 'Rectangle')
                            {
                                if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                    if (typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                    {//this.dataParameter[i][j][2].Get24bitColourHex()
                                        txt = txt + '{\\definecolor{mycolor}{rgb}{'+ this.dataParameter[i][j][2].GetColourR() + ','+ this.dataParameter[i][j][2].GetColourG() + ','+ this.dataParameter[i][j][2].GetColourB() + '}';
                                        txt = txt + '\\begin{tikzpicture} \\fill[mycolor] (0,0) rectangle (' + this.dataParameter[i][j][0] + 'ex,' + this.dataParameter[i][j][1] + 'ex);\\end{tikzpicture}}';
                                    }
                            }
                            if (this.dataName[i] === 'Edit')
                            {
                                if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                {
                                    txt = txt + this.dataParameter[i][j][0];
                                }
                            }
                            if (this.dataName[i] === 'TextArea')
                            {
                                if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                {
                                    txt = txt + this.dataParameter[i][j][0];
                                }
                            }
                            if (this.dataName[i] === 'ParagraphText')
                            {
                                if (this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                {
                                    txt = txt + this.dataParameter[i][j][0];
                                }
                            }
                            if (this.dataName[i] === 'FormStart')
                                txt = txt + '\\begin{itemize}\n';
                            if (this.dataName[i] === 'FormStop')
                            {
                                if (startRadioButtoEmph)
                                    txt = txt + '}';
        //                        txt = txt + '\n';
                                txt = txt + '\\end{itemize}\n';
                                startRadioButtoEmph = false;
                            }
                            if (this.dataName[i] === 'RadioButton' || this.dataName[i] === 'CheckBox')
                            {
                                if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                                {
                                    if (startRadioButtoEmph)
                                        txt = txt + '}';
                                    startRadioButtoEmph = false;
                                    txt = txt + '\\item\n';
                                    if (this.dataParameter[i][j].length > 3 && typeof this.dataParameter[i][j][3] !== 'undefined' && this.dataParameter[i][j][3] !== null)
                                    {
                                        if (this.dataParameter[i][j][3])
                                        {
                                            startRadioButtoEmph = true;
                                            txt = txt + '\\underline{';
                                        }
                                    }

                                }
                            }

                            
                            if (this.dataName[i] === 'Enum')
                            {
                                if (this.data[i][j] === 'Start')
                                {
                                    txt = txt + '\\begin{enumerate}\n';
                                    enumYN++;
                                }
                                if (this.data[i][j] === 'Stop')
                                {
                                    txt = txt + '\\end{enumerate}\n';
                                    enumYN--;
                                    if (enumYN < 0)
                                        enumYN = 0;
                                }
                            }
                            if (this.dataName[i] === 'Itemize')
                            {
                                if (this.data[i][j] === 'Start')
                                {
                                    txt = txt + '\\begin{itemize}\n';
                                    itemizeYN++;
                                }
                                if (this.data[i][j] === 'Stop')
                                {
                                    txt = txt + '\\end{itemize}\n';
                                    itemizeYN--;
                                    if (itemizeYN < 0)
                                        itemizeYN = 0;
                                }
                            }
                            if (this.dataName[i] === 'Item')
                            {
                                if (this.data[i][j] === 'Start')
                                    txt = txt + '\\item ';
        //                        if (this.data[i][j] === 'Stop')
        //                            txt = txt + '</li>';                        
                            }
                            if (this.dataName[i] === 'PE')
                            {
                                if (this.data[i][j] === 'Start')
                                    txt = txt + '\\(';                        
                                if (this.data[i][j] === 'Stop')
                                    txt = txt + '\\)';                        
                            }
                            if (this.dataName[i] === 'Equation')
                            {
                                if (this.data[i][j] === 'Start')
                                {
                                    txt = txt + '\\begin{equation*}\n';
                                    if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 0 && typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                        txt = txt + '\\label{' + this.dataParameter[i][j][0] + '}\n';
                                }
                                if (this.data[i][j] === 'Stop')
                                {
                                    txt = txt + '\\end{equation*}\n\n';                            
                                }
                            }                    
                            if (this.dataName[i] === 'SubEquation')
                            {
                                txt = txt + this.data[i][j] + '\n';
                            }
                            
                            if (this.dataName[i] === 'Figure')
                            {
                                if (this.data[i][j] === 'Start')
                                {
                                    if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                        txt = txt + '\\begin{figure}[' + this.dataParameter[i][j][2] + ']\n';                            
                                    else
                                        txt = txt + '\\begin{figure}[htbp]\n';                            
//                                    txt = txt + '\\begin{figure}[htbp]\n';                            
                                    if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null)
                                    {
                                        if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                        {
                                            switch(this.dataParameter[i][j][1])
                                            {
                                                case 'center':
                                                    lbraceFigure = true;
                                                    txt = txt + '{\n\\centering\n';
                                                    break;
                                            }
                                        }
                                    }
                                }
                                if (this.data[i][j] === 'Stop')
                                {
                                    if (lbraceFigure)
                                    {
                                        txt = txt + '}\n';
                                    }
                                    txt = txt + '\\end{figure}\n\n';
                                    lbraceFigure = false;
                                }
                            }
                            if (this.dataName[i] === 'Generate')
                            {
                                if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                                {
/*                                if (this.dataParameter[i][j].length > 1 && typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                {
                                    switch(this.dataParameter[i][j][1])
                                    {
                                        case 'center':
                                            lbraceFigure = true;
                                            txt = txt + '{\n\\centering\n';
                                            break;
                                    }
                                }*/
                                    txt = txt + '\\begin{tikzpicture}[';
                                    if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 10)
                                    {
                                       if (IsNumeric(this.dataParameter[i][j][0]) && IsNumeric(this.dataParameter[i][j][1]))
                                        {
                                             var scale = this.dataParameter[i][j][11]/this.dataParameter[i][j][0];
                                             txt = txt + 'scale=' + scale + '\\textwidth';
                     //                        txt = txt + 'x=' + this.dataParameter[i][j][0]/1000 + ',y=' + this.dataParameter[i][j][0]/1000;
                                        }
                /*                        if (IsNumeric(this.dataParameter[i][j][10]))
                                            txt = txt + 'scale=' + this.dataParameter[i][j][10];*/
                                    }
                                    txt = txt + ']\n';
                                    if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                    {
                                        tabObj = this.dataParameter[i][j][2];
                                        if (typeof tabObj !== 'undefined' && tabObj !== null)
                                        {
                                            ctx = objM.newObject('TDrawTikZContext');
                                            id = this.data[i][j];
                                            if (typeof id !== 'undefined' && id !== null)
                                            {
                                                matrix = objM.newObject('TMatrixTransformation3D');
                                                matrix2 = objM.newObject('TMatrixTransformation3D');
/*                                                scaleX = this.dataParameter[i][j][0]/this.dataParameter[i][j][3];
                                                scaleY = this.dataParameter[i][j][1]/this.dataParameter[i][j][4];
                                                scaleZ = this.dataParameter[i][j][5];
                                                matrix.SetScaleMatrix3D(scaleX,scaleY,scaleZ);
                                                matrix2.SetTranslationMatrix(this.dataParameter[i][j][6],this.dataParameter[i][j][7],this.dataParameter[i][j][8]);
                                                matrix.MatrixMultiplication(matrix2);
                                                ctx.SetTransformation(matrix);*/
                                                scaleX = this.dataParameter[i][j][0]/(this.dataParameter[i][j][3]);
                                                scaleY = this.dataParameter[i][j][1]/(this.dataParameter[i][j][4]);
                                                scaleZ = this.dataParameter[i][j][5];
                                                matrix.SetScaleMatrix3D(scaleX,scaleY,scaleZ);
                                                matrix2.SetTranslationMatrix(-this.dataParameter[i][j][6],-this.dataParameter[i][j][7],-this.dataParameter[i][j][8]);
                                                matrix.MatrixMultiplication(matrix2);
                                                ctx.SetTransformation(matrix);

//                                                matrix.SetTranslationMatrix(-this.dataParameter[i][j][6],-this.dataParameter[i][j][7],-this.dataParameter[i][j][8]);
//                                                ctx.SetTransformation(matrix);
                                                
                                                for (k = 0;k < tabObj.length;k++)
                                                {
                                                    obj = tabObj[k];
                                                    if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TObjectFigure'))
                                                    {
                                                        obj.DrawFigure(ctx);
                                                    }
                                                }
                                                txt = txt + ctx.GetContext();
                                            }
                                        }


                                        //                                    if (this.dataParameter[i][j])
                                    }
                                    txt = txt + '\\end{tikzpicture}\n';
                                }
                            }
                            if (this.dataName[i] === 'GenerateThree')
                            {
                                if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                                {
                                    if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 17)
                                    {
        //                                var tmp2 = this.dataParameter[i][j][17];
                                        var tmp2 = this.imageCatalog;
                                        if (this.dataParameter[i][j].length > 18 && typeof this.dataParameter[i][j][18] !== 'undefined' && this.dataParameter[i][j][18] !== null)
                                        {
                                            tmp = this.dataParameter[i][j][18]/100;
                                            txt = txt + '\\includegraphics[width='+ tmp + '\\linewidth]{' + tmp2 + '/'+ this.data[i][j] + '.png}';
                                        }else
                                        {
                                        }
                                        txt = txt + '\n';
                                    }

                                }
                            }                    
                            if (this.dataName[i] === 'GenerateCanvas')
                            {
                                if (typeof this.data[i][j] !== 'undefined' && this.data[i][j] !== null)
                                {
                                    if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null)
                                    {
        //                                var tmp2 = this.dataParameter[i][j][17];
                                        var tmp2 = this.imageCatalog;
                                        if (this.dataParameter[i][j].length > 11 && typeof this.dataParameter[i][j][11] !== 'undefined' && this.dataParameter[i][j][11] !== null)
                                        {
                                            tmp = this.dataParameter[i][j][11]/100;
                                            txt = txt + '\\includegraphics[width='+ tmp + '\\linewidth]{' + tmp2 + '/'+ this.data[i][j] + '.png}';
                                        }else
                                        {
                                        }
                                        txt = txt + '\n';
                                    }

                                }
                            }                    
                            if (this.dataName[i] === 'TableShow' || this.dataName[i] === 'TableEdit')
                            {
                                if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length > 1)
                                    if (typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null)
                                        if (typeof this.dataParameter[i][j][1] !== 'undefined' && this.dataParameter[i][j][1] !== null)
                                        {
                                            if (this.dataParameter[i][j].length > 2 && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                                style = this.dataParameter[i][j][2];
                                            else
                                                style = null;
                                            var lineWidth;
                                            if (this.dataParameter[i][j].length > 14 && typeof this.dataParameter[i][j][14] !== 'undefined' && this.dataParameter[i][j][14] !== null)
                                                lineWidth = this.dataParameter[i][j][14];
                                            else
                                                lineWidth = null;
                                            var id = this.dataParameter[i][j][0];
                                            var data = this.dataParameter[i][j][1];
                                            var ii,jj;
        /*                                    txt = txt + '<table id="' + id + '" ';
                                            if (style !== null)
                                                txt = txt + ' class="slide' + style + '" ';                                    
                                            txt = txt + '>';*/
                                            var w;
                                            if (this.dataParameter[i][j].length > 4 && typeof this.dataParameter[i][j][4] !== 'undefined' && this.dataParameter[i][j][4] !== null)
                                                w = this.dataParameter[i][j][4];
                                            else
                                                w = null;
                                            var h;
                                            if (this.dataParameter[i][j].length > 5 && typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null)
                                                h = this.dataParameter[i][j][5];
                                            else
                                                h = null;
                                            var mincolour;
                                            if (this.dataParameter[i][j].length > 6 && typeof this.dataParameter[i][j][6] !== 'undefined' && this.dataParameter[i][j][6] !== null)
                                                mincolour = this.dataParameter[i][j][6];
                                            else
                                                mincolour = null;
                                            var maxcolour;
                                            if (this.dataParameter[i][j].length > 7 && typeof this.dataParameter[i][j][7] !== 'undefined' && this.dataParameter[i][j][7] !== null)
                                                maxcolour = this.dataParameter[i][j][7];
                                            else
                                                maxcolour = null;
                                            var minValue;
                                            if (this.dataParameter[i][j].length > 8 && typeof this.dataParameter[i][j][8] !== 'undefined' && this.dataParameter[i][j][8] !== null)
                                                minValue = this.dataParameter[i][j][8];
                                            else
                                                minValue = null;
                                            var maxValue;
                                            if (this.dataParameter[i][j].length > 9 && typeof this.dataParameter[i][j][9] !== 'undefined' && this.dataParameter[i][j][9] !== null)
                                                maxValue = this.dataParameter[i][j][9];
                                            else
                                                maxValue = null;
                                            var minColourTextValue;
                                            if (this.dataParameter[i][j].length > 10 && typeof this.dataParameter[i][j][10] !== 'undefined' && this.dataParameter[i][j][10] !== null)
                                                minColourTextValue = this.dataParameter[i][j][10];
                                            else
                                                minColourTextValue = null;
                                            var maxColourTextValue;
                                            if (this.dataParameter[i][j].length > 11 && typeof this.dataParameter[i][j][11] !== 'undefined' && this.dataParameter[i][j][11] !== null)
                                                maxColourTextValue = this.dataParameter[i][j][11];
                                            else
                                                maxColourTextValue = null;
                                            var alignTextX;
                                            if (this.dataParameter[i][j].length > 12 && typeof this.dataParameter[i][j][12] !== 'undefined' && this.dataParameter[i][j][12] !== null)
                                                alignTextX = this.dataParameter[i][j][12];
                                            else
                                                alignTextX = null;
                                            var alignTextY;
                                            if (this.dataParameter[i][j].length > 13 && typeof this.dataParameter[i][j][13] !== 'undefined' && this.dataParameter[i][j][13] !== null)
                                                alignTextY = this.dataParameter[i][j][13];
                                            else
                                                alignTextY = null;
                                            var colourStyle = null;
                                            if (this.dataParameter[i][j].length > 16 && typeof this.dataParameter[i][j][16] !== 'undefined' && this.dataParameter[i][j][16] !== null)
                                                colourStyle = this.dataParameter[i][j][16];
                                            var colourMap = null;
                                            if (this.dataParameter[i][j].length > 17 && typeof this.dataParameter[i][j][17] !== 'undefined' && this.dataParameter[i][j][17] !== null)
                                                colourMap = this.dataParameter[i][j][17];
                                            var colourMapMin = null;
                                            if (this.dataParameter[i][j].length > 18 && typeof this.dataParameter[i][j][18] !== 'undefined' && this.dataParameter[i][j][18] !== null)
                                                colourMapMin = this.dataParameter[i][j][18];
                                            var colourMapMax = null;
                                            if (this.dataParameter[i][j].length > 19 && typeof this.dataParameter[i][j][19] !== 'undefined' && this.dataParameter[i][j][19] !== null)
                                                colourMapMax = this.dataParameter[i][j][19];
        //                                        var lineWidth;
                                            var wTeX;
                                            if (this.dataParameter[i][j].length > 20 && typeof this.dataParameter[i][j][20] !== 'undefined' && this.dataParameter[i][j][20] !== null)
                                                wTeX = this.dataParameter[i][j][20];
                                            else
                                                wTeX = null;
                                            var hTeX;
                                            if (this.dataParameter[i][j].length > 21 && typeof this.dataParameter[i][j][21] !== 'undefined' && this.dataParameter[i][j][21] !== null)
                                                hTeX = this.dataParameter[i][j][21];
                                            else
                                                hTeX = null;
                                            var colourTmp = null,colourTmp2 = null,YN = false,YN2 = false,k;
                                            var tmp;
                                            if (wTeX !== null)
                                            {
                                                switch(alignTextX)
                                                {
                                                    case 'left':
                                                        tmp = 'L';
                                                        break;
                                                    case 'right':
                                                        tmp = 'R';
                                                        break;
                                                    case 'center':
                                                        tmp = 'C';
                                                        break;
                                                    default:
                                                        tmp = 'L';
                                                }
                                                tmp = tmp + '{' + wTeX + 'cm}';
                                            }else
                                                switch(alignTextX)
                                                {
                                                    case 'left':
                                                        tmp = 'l';
                                                        break;
                                                    case 'right':
                                                        tmp = 'r';
                                                        break;
                                                    case 'center':
                                                        tmp = 'c';
                                                        break;
                                                    default:
                                                        tmp = 'l';
                                                }
                                            txt = txt + '\n\\begin{figure}[htbp]';
                                            txt = txt + '\n{\n';
                                            if (colourStyle !== 'colour24bit')
                                            {
                                                if (mincolour !== null)
                                                    txt = txt + '\\definecolor{minColour}{HTML}{' +  mincolour.Get24bitColourHex() +'}\n';
                                                if (maxcolour !== null)
                                                    txt = txt + '\\definecolor{maxColour}{HTML}{' +  maxcolour.Get24bitColourHex() +'}\n';
                                                if (minColourTextValue !== null)
                                                    txt = txt + '\\definecolor{minTextColour}{HTML}{' +  minColourTextValue.Get24bitColourHex() +'}\n';
                                                if (maxColourTextValue !== null)
                                                    txt = txt + '\\definecolor{maxTextColour}{HTML}{' +  maxColourTextValue.Get24bitColourHex() +'}\n';
                                                if (colourMap !== null && colourMapMin !== null && colourMapMax !== null)
                                                {
                                                    for (ii = 0;ii < colourMap.length;ii++)
                                                        txt = txt + '\\definecolor{mapcolour' + ii + '}{HTML}{' +  colourMap[ii].Get24bitColourHex() +'}\n';                                                
                                                }
                                            }
                                            txt = txt + '\\begin{tabular}{';
                                            if (lineWidth > 0)
                                            {
                                                txt = txt + '|';
                                                if (data.length > 0)
                                                    for (ii = 0;ii < data[0].length;ii++)
                                                        txt = txt + tmp + '|';
                                            }else
                                                if (data.length > 0)
                                                    for (ii = 0;ii < data[0].length;ii++)
                                                        txt = txt + tmp;
                                            if (wTeX !== null)
                                                txt = txt + 'N}\n';
                                            else
                                                txt = txt + '}\n';
                                            for (ii = 0;ii < data.length;ii++)
                                            {
                                                if (lineWidth > 0)
                                                    txt = txt +  '\\hline\n';
                                                var YNMapColour;
                                                for(jj = 0;jj < data[ii].length;jj++)
                                                {
                                                    if (colourStyle !== 'colour24bit')
                                                    {
                                                        var tmp_data;
                                                        if (this.dataParameter[i][j].length > 15 && typeof this.dataParameter[i][j][15] !== 'undefined' && this.dataParameter[i][j][15] !== null && this.dataParameter[i][j][15]) 
                                                            tmp_data = Hex2Numeric(data[ii][jj]);
                                                        else
                                                            tmp_data = data[ii][jj];
                                                        YNMapColour = false;
                                                        if (colourMap !== null && colourMapMin !== null && colourMapMax !== null)
                                                        {
                                                            for (k = 0;k < colourMap.length;k++)
                                                            {
                                                                if (tmp_data >= colourMapMin[k] && tmp_data <= colourMapMax[k])
                                                                {
                                                                    YNMapColour = true;
                                                                    break;
                                                                }
                                                            }
                                                        }
                                                        if (YNMapColour)
                                                        {
                                                            txt = txt + '\\cellcolor{mapcolour' + k + '}';
                                                        }else
                                                        {
                                                            var tmpValue = 100*(tmp_data - minValue)/(maxValue - minValue);
                                                            if (mincolour !== null && maxcolour !== null)
                                                            {
                                                                var tmpValue2 = 100 - tmpValue;
                                                                txt = txt + '\\cellcolor{minColour!' + tmpValue2 + '!maxColour}';
                                                            }
                                                            if (minColourTextValue !== null && maxColourTextValue !== null)
                                                                if (tmpValue >= 50)
                                                                    txt = txt + '\\color{maxTextColour}';
                                                                else
                                                                    txt = txt + '\\color{minTextColour}';
                                                        }
                                                    }
                                                    if (colourStyle === 'colour24bit')
                                                    {
                                                        txt = txt + '\\color{red}' +  data[ii][jj].substring(0,2);
                                                        txt = txt + '\\color{green}' +  data[ii][jj].substring(2,4);
                                                        txt = txt + '\\color{blue}' +  data[ii][jj].substring(4,6);
                                                    }else
                                                        txt = txt + data[ii][jj];
                                                    if (jj !== data[ii].length - 1 || wTeX !== null)
                                                        txt = txt + '&';
                                                }
                                                txt = txt + '\\\\';
                                                if (hTeX !== null)
                                                    txt = txt + '[' + hTeX + 'cm]';
                                                txt = txt + '\n';
                                            }
                                            if (lineWidth > 0)
                                                txt = txt +  '\\hline\n';
                                            txt = txt + '\\end{tabular}\n';
                                            txt = txt + '}\n';
                                            txt = txt + '\\end{figure}\n';
                                        }

                            }
                            if (this.dataName[i] === 'Table')
                            {
                                if (this.data[i][j] === 'Start')
                                {
                                    maxCol = 0;
                                    paragraphEnterYN = false;
                                    if (typeof this.dataParameter[i][j] !== 'undefined' && this.dataParameter[i][j] !== null && this.dataParameter[i][j].length >= 2)
                                    {
                                        if(typeof this.dataParameter[i][j][0] !== 'undefined' && this.dataParameter[i][j][0] !== null && typeof this.dataParameter[i][j][2] !== 'undefined' && this.dataParameter[i][j][2] !== null)
                                        {
                                            maxCol = this.dataParameter[i][j][2];
                                            txt = txt + '\\begin{tabular}{';
                                            var align = 'l';
                                            var tableLine = '';
                                            if(typeof this.dataParameter[i][j][5] !== 'undefined' && this.dataParameter[i][j][5] !== null)
                                                switch (this.dataParameter[i][j][5])
                                                {
                                                    case 'left':
                                                        align = 'l';
                                                        break;
                                                    case 'center':
                                                        align = 'c';
                                                        break;
                                                    case 'right':
                                                        align = 'r';
                                                        break;
                                                }
                                            if(typeof this.dataParameter[i][j][7] !== 'undefined' && this.dataParameter[i][j][7] !== null)
                                                switch (this.dataParameter[i][j][7])
                                                {
                                                    case 'single':
                                                        tableLine = '|';
                                                        break;
                                                    case 'no':
                                                        tableLine = '';
                                                        break;
                                                }
                                            txt = txt + tableLine;
                                            for (ii = 0;ii < maxCol;ii++)
                                                txt = txt + align + tableLine;
                                             txt = txt + '}';
                                             if (tableLine === '|')
                                                txt = txt + '\\hline\n';
                                        }else
                                            txt = txt + '\\begin{tabular}';
                                    }
                                }
                                if (this.data[i][j] === 'Stop')
                                {
                                    paragraphEnterYN = true;
                                    txt = txt + '\n\\end{tabular}\n\n';
                                }
                            }                    
                            if (this.dataName[i] === 'tr')
                            {
                                if (this.data[i][j] === 'Start')
                                {
                                    txt = txt + '\n';
                                    numberCol = 0;
                                }
                                if (this.data[i][j] === 'Stop')
                                {
                                    txt = txt + '\\\\';
                                    if (tableLine === '|')
                                       txt = txt + '\\hline\n';
                                }
                            }                    
                            if (this.dataName[i] === 'th' || this.dataName[i] === 'th2' )
                            {
                                if (this.data[i][j] === 'Start')
                                {
        //                            txt = txt + '<th>';
                                }
                                if (this.data[i][j] === 'Stop' && maxCol)
                                {
                                    numberCol++;
                                    if (numberCol < maxCol)
                                        txt = txt + '&';
                                }
                            }                    
                            if (this.dataName[i] === 'td' )
                            {
                                if (this.data[i][j] === 'Start')
                                {
        //                            txt = txt + '<th>';
                                }
                                if (this.data[i][j] === 'Stop' && maxCol)
                                {
                                    numberCol++;
                                    if (numberCol < maxCol)
                                        txt = txt + '&';
                                }
                            }                    
                            if (this.dataName[i] === 'FigureImageBitmap' || this.dataName[i] === 'InteractiveImageBitmap')
                            {

                                if (numberCatalog !== null && typeof this.data[numberCatalog][0] !== 'undefined' && this.data[numberCatalog][0] !== null)
                                {
                                    if (this.dataParameter[i][j][0] > 0)
                                    {
                                        tmp = this.dataParameter[i][j][0]/100;
                                        txt = txt + '\\includegraphics[width='+ tmp + '\\linewidth]{' + this.data[numberCatalog][0] + '/'+ this.data[i][j] + '}\n\n';
                                    }else
                                    {
                                        if (this.dataParameter[i][j][1] > 0)
                                        {
                                            tmp = this.dataParameter[i][j][1];
                                            txt = txt + '\\includegraphics[height=' + tmp + 'mm]{' + this.data[numberCatalog][0] + '/' + this.data[i][j] + '}\n\n';
                                        }else
                                            txt = txt + '\\includegraphics{' + this.data[numberCatalog][0] + '/' + this.data[i][j] + '}\n\n';
                                    }
                                }

                            }
                            
                        }
                    }
                }

                txt = txt + '\\end{frame}\n';
            }        
        }else
        {
        }
        return txt;
    };

};

TTeXSlide.prototype = new TGenerateTeX();


function TTeXTableOfContens(){
    
    var type = 'TTeXTableOfContens';
    TTeXTableOfContens.prototype.InitConstructor = function(){
        TGenerateTeX.prototype.InitConstructor.call(this);
        this.SetType(type);
    };
    this.InitConstructor();

    TTeXTableOfContens.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TGenerateTeX.prototype.IsType.call(this,_type);
    };

    TTeXTableOfContens.prototype.Init = function(_object){
        TGenerateTeX.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TTeXTableOfContens'))
        {
        }
    };
    
    TTeXTableOfContens.prototype.GetTXT = function(){
        var txt = '';
        if (this.GetSlide())
        {
            var i,j,number = this.Find('Title',0);
            txt = txt + '\\begin{frame}\n';
            if (number !== null)
            {
                for (i = 0;i < this.data[number].length;i++)
                {
                    if (parseInt(this.dataParameter[number][i][0]) === -1)
                    {
                        txt = txt + '\\frametitle{' + this.data[number][i] + '}\n';
                        break;
                    }
                }
            }
            txt = txt + '\\tableofcontents[currentsection]\n';
            txt = txt + '\\end{frame}\n';
        }else
        {
            txt = txt + '\\tableofcontents\n';
        }
        return txt;
    };

};

TTeXTableOfContens.prototype = new TGenerateTeX();


function TTeXTitlePageObject(){
    
    var type = 'TTeXTitlePageObject';
    TTeXTitlePageObject.prototype.InitConstructor = function(){
        TGenerateTeX.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.numberOfAuthors = 0;
    };
    this.InitConstructor();

    TTeXTitlePageObject.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TGenerateTeX.prototype.IsType.call(this,_type);
    };

    TTeXTitlePageObject.prototype.Init = function(_object){
        TGenerateTeX.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TTeXTitlePageObject'))
        {
            if (typeof _object.numberOfAuthors !== 'undefined' && _object.numberOfAuthors !== null && IsInt(_object.numberOfAuthors))
            {
                this.numberOfAuthors = _object.numberOfAuthors;
            }            
        }
    };
    
    TTeXTitlePageObject.prototype.PrepareTXT = function(type,style,_number){
        var txt = '';
        if (typeof type !== 'undefined' && type !== null && typeof style !== 'undefined' && style !== null)
        {
            var number = this.Find(type,_number);
            if (number !== null)
            {
                var i;
                for (i = 0;i < this.data[number].length;i++)
                {
                    txt = txt + '  {' + style + ' ' + this.data[number][i] + '\\par}\n';
                }
            }
        }
        return txt;
    };    

    TTeXTitlePageObject.prototype.PrepareTXT2 = function(type,_number, delimiter){
        var txt = '';
        if (typeof type !== 'undefined' && type !== null)
        {
            var tmp, i;
            var number = this.Find(type,_number);
            if (number !== null)
            {
                for (i = 0;i < this.data[number].length;i++)
                {
                    txt = txt + this.data[number][i];
                    if (i !== this.data[number].length - 1 && typeof delimiter !== 'undefined' && delimiter !== null)
                        txt = txt + delimiter;
                    txt = txt + ' ';
                }
            }
        }
        return txt;
    };    

    TTeXTitlePageObject.prototype.GetUniqueData = function(type,_number){
        var data_ = [];
        if (typeof type !== 'undefined' && type !== null && typeof _number !== 'undefined' && _number !== null)
        {
            var i,j,k,number,YN;
            for (i = 0,k = 0;i < this.numberOfAuthors;i++)
            {
                number = this.Find(type,i);
                if (number !== null)
                {
                    if (this.data[number].length > 0 && typeof this.data[number][_number] !== 'undefined' && this.data[number][_number] !== null)
                    {
                        YN = true;
                        for (j = 0;j < data_.length;j++)
                        {
                            if (this.data[data_[j]][_number] === this.data[number][_number])
                            {
                                YN = false;
                                break;
                            }
                        }
                        if (YN)
                            data_[k++] = number;
                    }
                }            
            }
        }
        return data_;
    };

    TTeXTitlePageObject.prototype.GetTXT = function(){
        var txt = '',i;
        txt = txt + '\\begin{titlepage}\n';
        txt = txt + '  \\centering\n';
        var tmp = this.GetUniqueData('AffiliationWork',0);
        for(i = 0;i < tmp.length;i++)
        {
            if (this.data[tmp[i]].length > 0 && typeof this.data[tmp[i]][0] !== 'undefined' && this.data[tmp[i]][0] !== null)
            {
                if (typeof this.data[tmp[i]][0] !== 'undefined' && this.data[tmp[i]][0] !== null)
                {
                    txt = txt + '  {\\scshape\\LARGE ' + this.data[tmp[i]][0] +  ' \\par}\n';
                    if (this.data[tmp[i]].length > 1 && typeof this.data[tmp[i]][1] !== 'undefined' && this.data[tmp[i]][1] !== null)
                    {
                        if (typeof this.data[tmp[i]][1] !== 'undefined' && this.data[tmp[i]][1] !== null)
                        {
                            txt = txt + '  {\\scshape\\large ' + this.data[tmp[i]][1] +  ' \\par}\n';                    
                        }
                    }
                }
            }
        }
        txt = txt + '  \\vspace{1cm}\n';
        txt = txt + this.PrepareTXT('TitlePaper','\\huge\\bfseries');
        txt = txt + this.PrepareTXT('Subtitle','\\LARGE\\bfseries');
        txt = txt + '  \\vspace{1cm}\n';
        for (i = 0;i < this.numberOfAuthors;i++)
        {
            txt = txt + '  {\\Large\\itshape ';
            txt = txt + this.PrepareTXT2('AuthorName',i);
            txt = txt + ' ' + this.PrepareTXT2('AuthorSurname',i);
            txt = txt + '\\par}\n';
        }
        txt = txt + '  \\vfill\n';
        txt = txt + '  {\\large \\today\\par}\n';
        txt = txt + '\\end{titlepage}\n';
        return txt;
    };

    TTeXTitlePageObject.prototype.Add = function(type,text){
        TGenerateTeX.prototype.Add.call(this,type,text);
        if (type === 'AuthorSurname')
            this.numberOfAuthors++;
    };
};


TTeXTitlePageObject.prototype = new TGenerateTeX();


function TTeXPresentationTitlePageObject(){
    
    var type = 'TTeXPresentationTitlePageObject';
    TTeXPresentationTitlePageObject.prototype.InitConstructor = function(){
        TGenerateTeX.prototype.InitConstructor.call(this);
        this.SetType(type);
        this.numberOfAuthors = 0;
    };
    this.InitConstructor();

    TTeXPresentationTitlePageObject.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TGenerateTeX.prototype.IsType.call(this,_type);
    };

    TTeXPresentationTitlePageObject.prototype.Init = function(_object){
        TGenerateTeX.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TTeXPresentationTitlePageObject'))
        {
            if (typeof _object.numberOfAuthors !== 'undefined' && _object.numberOfAuthors !== null && IsInt(_object.numberOfAuthors))
            {
                this.numberOfAuthors = _object.numberOfAuthors;
            }            
        }
    };
    
    TTeXPresentationTitlePageObject.prototype.PrepareTXT = function(type,style,_number){
        var txt = '';
        if (typeof type !== 'undefined' && type !== null && typeof style !== 'undefined' && style !== null)
        {
            var number = this.Find(type,_number);
            if (number !== null)
            {
                var i;
                for (i = 0;i < this.data[number].length;i++)
                {
                    txt = txt + '  {' + style + ' ' + this.data[number][i] + '}\n';
                }
            }
        }
        return txt;
    };    

    TTeXPresentationTitlePageObject.prototype.PrepareTXT2 = function(type,_number, delimiter){
        var txt = '';
        if (typeof type !== 'undefined' && type !== null)
        {
            var tmp, i;
            var number = this.Find(type,_number);
            if (number !== null)
            {
                for (i = 0;i < this.data[number].length;i++)
                {
                    txt = txt + this.data[number][i];
                    if (i !== this.data[number].length - 1 && typeof delimiter !== 'undefined' && delimiter !== null)
                        txt = txt + delimiter;
                    if (i < this.data[number].length - 1)
                        txt = txt + ' ';
                }
            }
        }
        return txt;
    };    


    TTeXPresentationTitlePageObject.prototype.GetTXT = function(){
        var txt = '',i,tmp,tmp2,k;
        
        txt = txt + '  \\title{' + this.PrepareTXT2('TitlePaper') + '}\n';
        txt = txt + '  \\subtitle{' + this.PrepareTXT2('Subtitle') + '}\n';

        txt = txt + '  \\author{';
        for (i = 0,k = 0;i < this.numberOfAuthors;i++)
        {
            tmp = this.PrepareTXT2('AuthorSurname',i); 
            if (typeof tmp !== 'undefined' && tmp !== null && tmp.length > 0)
            {
                k++;
                if (i > 0)
                    txt = txt + ', ';
            }
            txt = txt + this.PrepareTXT2('AuthorName',i);
            txt = txt + ' ' + tmp;
        }
        txt = txt + '}\n';

        txt = txt + '  \\institute{';
        for (i = 0;i < this.numberOfAuthors;i++)
        {
            tmp = this.PrepareTXT2('AffiliationWork',i,','); 
            if (typeof tmp !== 'undefined' && tmp !== null && tmp.length > 0)
            {
                if (i > 0)
                    txt = txt + '\\and\n';
                if (k > 1)
                {
                    tmp2 = i + 1;
                    txt = txt + '    \\inst{' + tmp2 + '}\n';
                }
                txt = txt + '    ' + tmp + '\\\n';
            }
        }
        txt = txt + '}\n';
        
        txt = txt + '\\frame{\\titlepage}\n';
//        txt = txt + '\\begin{frame}\n';
//        txt = txt + '\\end{frame}\n';
        
        return txt;
    };

    TTeXPresentationTitlePageObject.prototype.Add = function(type,text){
        TGenerateTeX.prototype.Add.call(this,type,text);
        if (type === 'AuthorSurname')
            this.numberOfAuthors++;
    };
};


TTeXPresentationTitlePageObject.prototype = new TGenerateTeX();

function TGenerateObject(){
    
    var type = 'TGenerateObject';
    TGenerateObject.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        
        this.SetType(type);
        this.slideYN = false;
        this.drawObject = null;
        this.txt = [];
    };
    this.InitConstructor();

    TGenerateObject.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };

    TGenerateObject.prototype.Init = function(_object){
        TObject.prototype.Init.call(this,_object);
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _object !== 'undefined' && _object !== null && _object.IsType('TGenerateObject'))
        {
            var i;
            if (typeof _object.slideYN !== 'undefined' && _object.slideYN !== null)
                this.slideYN = _object.slideYN;
            if (typeof _object.drawObject !== 'undefined' && _object.drawObject !== null && _object.drawObject.IsType('TGenerateObject2'))
                this.drawObject = objM.copy(_object.drawObject);
            if (typeof _object.txt !== 'undefined' && _object.txt !== null)
            {
                this.txt = new String(_object.txt);
                this.txt = this.txt.toString();
            }
        }
    };

    TGenerateObject.prototype.Title = function(_txt,levels,level,id){
        return '';        
    };


    TGenerateObject.prototype.GetTXT = function(){
        this.txt = '';
        if (this.drawObject !== null)
            this.txt = this.txt + this.drawObject.GetTXT();
        return this.txt;
    };
    
    TGenerateObject.prototype.SetThisObject = function(){
        if (this.drawObject !== null)
            this.drawObject.SetThisObject();
    };
    

    TGenerateObject.prototype.Enter = function(){
        return '';        
    };

    TGenerateObject.prototype.Paragraph = function(_txt){
        return '';        
    };

    TGenerateObject.prototype.Equation = function(_txt,levels,_numberEquation){
        return '';        
    };

    TGenerateObject.prototype.GetSymbol = function(_symbol){
        return '';
    };

    TGenerateObject.prototype.GetEmphStart = function(_number){
        return '';
    };

    TGenerateObject.prototype.GetEmphStop = function(_number){
        return '';
    };
    
    TGenerateObject.prototype.GetEquationParagraphStart = function() {
        return '';        
    };

    TGenerateObject.prototype.GetEquationParagraphStop = function() {
        return '';        
    };

    TGenerateObject.prototype.FigureCaption = function(_txt,_figureName,levels,_numberFigure){
        return '';        
    };

    TGenerateObject.prototype.Figure = function(_caption,_picture,id){
        return '';        
    };

    TGenerateObject.prototype.GetFigureReference = function(_txt,reference) {
        return '';        
    };

    TGenerateObject.prototype.SetSlide = function(YN) {
        if (typeof YN !== 'undefined' && YN !== null)
            this.slideYN = YN;
    };

    TGenerateObject.prototype.GetSlide = function() {
        return this.slideYN;
    };

    TGenerateObject.prototype.PersonalDataStart = function(){
    };

    TGenerateObject.prototype.PersonalDataStop = function(){
    };

    TGenerateObject.prototype.Find = function(text,table){
        if (typeof text !== 'undefined' && text !== null && typeof table !== 'undefined' && table !== null)
        {
            var i;
            for (i = 0;i < table.length;i++)
            {
                if (text === table[i])
                    return i;
            }
        }
        return null;
    };

    TGenerateObject.prototype.FindTitlePage = function(text){
        if (typeof text !== 'undefined' && text !== null)
        {
            return this.Find(text,this.titlePage);
        }
        return null;
    };

    TGenerateObject.prototype.FindTableOfContens = function(text){
        if (typeof text !== 'undefined' && text !== null)
        {
            return this.Find(text,this.tableOfContens);
        }
        return null;
    };
    
    TGenerateObject.prototype.CreateTitlePageObject = function(){
        return null;
    };

    TGenerateObject.prototype.CreateTableOfContensObject = function(){
        return null;
    };

    TGenerateObject.prototype.Add = function(type,text,parameter){
        if (text !== null && typeof text !== 'undefined')
        {
            if (this.drawObject !== null)
                this.drawObject.Add(type,text,parameter);
        }
    };

    TGenerateObject.prototype.SetTypeDrawObject = function(_type){
        var objM = this.GetObjectManager();
        if (objM !== null && typeof _type !== 'undefined' && _type !== null)
            this.drawObject = objM.newObject(_type); 
        if (_type === null)
        {
            this.drawObject = null;
        }
    };

    TGenerateObject.prototype.GetDrawObject = function(){
        return this.drawObject;
    };

}

TGenerateObject.prototype = new TObject();

function THTMLObject(){
    
    var type = 'THTMLObject';
    THTMLObject.prototype.InitConstructor = function(){
        TGenerateObject.prototype.InitConstructor.call(this);
        
        this.SetType(type);
            
    };
    this.InitConstructor();

    THTMLObject.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TGenerateObject.prototype.IsType.call(this,_type);
    };

    THTMLObject.prototype.Init = function(_object){
        TGenerateObject.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('THTMLObject'))
        {
        }
    };

    THTMLObject.prototype.Enter = function(){
        this.txt = this.txt + '<br>';
    };

    THTMLObject.prototype.Title = function(_txt,levels,level,id){
        if (typeof _txt !== 'undefined' && _txt !== null && typeof level !== 'undefined' && level !== null && IsInt(level))
        {
            var tmp = level + 1;
            this.txt = this.txt + '<h' + tmp;
            if (typeof id !== 'undefined' && id !== null)
                this.txt = this.txt + ' id="'+ id + '"';          
            this.txt = this.txt + '>';
            if (typeof levels !== 'undefined' && levels !== null)
            {
                var i;
                for (i = 0;i < levels.length && i <= level;i++)
                {
                    this.txt = this.txt + levels[i] + '.';
                }
                this.txt = this.txt + ' ';
            }
            this.txt = this.txt + _txt;
            this.txt = this.txt + '</h' + tmp + '>';            
        }
    };

    THTMLObject.prototype.Paragraph = function(_txt){
        if (typeof _txt !== 'undefined' && _txt !== null)
        {
            this.txt = this.txt + '<p>';
            this.txt = this.txt + _txt;
            this.txt = this.txt + '</p>';            
        }
    };

    THTMLObject.prototype.Equation = function(_txt,levels,_numberEquation){
        if (typeof levels !== 'undefined' && levels !== null && levels.length > 0)
            chapterNumber = levels[0];
        if (typeof _numberEquation !== 'undefined' && _numberEquation !== null)
            numberEquation = _numberEquation;
        if (typeof _txt !== 'undefined' && _txt !== null)
        {
            this.txt = this.txt + this.GetEquationParagraphStart();
            this.txt = this.txt + _txt;
            this.txt = this.txt + this.GetEquationParagraphStop();            
        }
    };

    THTMLObject.prototype.GetSymbol = function(_symbol){
        if (typeof _symbol !== 'undefined' && _symbol !== null)
            if (_symbol === 'Dash')
                return '–';
            if (_symbol === 'Hash')
                return '#';
            if (_symbol === 'Underscore')
                return '_';
            if (_symbol === 'Percent')
                return '%';
        return '';
    };

    THTMLObject.prototype.GetEmphStart = function(_number){
        if (typeof _number !== 'undefined' && _number !== null && IsInt(_number))
        {
            var tmp = _number;
            return '<Emph' + tmp + '>';
        }
        return '';
    };

    THTMLObject.prototype.GetEmphStop = function(_number){
        if (typeof _number !== 'undefined' && _number !== null && IsInt(_number))
        {
            var tmp = _number;
            return '</Emph' + tmp + '>';
        }
        return '';
    };

    THTMLObject.prototype.GetEquationParagraphStart = function() {
        return '\\(';        
    };

    THTMLObject.prototype.GetEquationParagraphStop = function() {
        return '\\)';        
    };

    THTMLObject.prototype.FigureCaption = function(_txt,figureName,levels,_numberFigure){
        if (typeof _txt !== 'undefined' && _txt !== null)
        {
            var txt = '<FigureCaption';
//            if (typeof id !== 'undefined' && id !== null)
//                txt = txt + ' id="'+ id + '"';          
            txt = txt + '>';
            if (typeof figureName !== 'undefined' && figureName !== null)
                txt = txt + figureName + ' ';
            if (typeof levels !== 'undefined' && levels !== null && levels.length > 0 && typeof _numberFigure !== 'undefined' && _numberFigure !== null && IsInt(_numberFigure))
                txt = txt + levels[0] + '.' + _numberFigure + '. ';
            txt = txt + _txt;
            txt = txt + '</FigureCaption>';
            return txt;
        }
        return '';
    };

    THTMLObject.prototype.Figure = function(_caption,_picture,id){
        if (typeof _caption !== 'undefined' && _caption !== null)
        {
            this.txt = this.txt + '<Figure';
            if (typeof id !== 'undefined' && id !== null)
                this.txt = this.txt + ' id="'+ id + '"';          
            this.txt = this.txt + '>';
            this.txt = this.txt + _caption;
            this.txt = this.txt + '<\Figure>';            
        }
    };

    THTMLObject.prototype.GetFigureReference = function(_txt,reference) {
        if (typeof _txt !== 'undefined' && _txt !== null)
        {
            var txt = '<a href="#';
            if (typeof reference !== 'undefined' && reference !== null)
            {
                txt = txt + reference;
                txt = txt + '" class="' + reference;  
            }
            txt = txt + '">';
            txt = txt + '<ReferenceFigure>';
            txt = txt + _txt;
            txt = txt + '</ReferenceFigure>';
            txt = txt + '</a>';
            return txt;
        }
        return '';
    };

    THTMLObject.prototype.PersonalDataStart = function(){
        if (this.GetSlide())
            this.txt = this.txt + '<SlidePersonalData>';
    };

    THTMLObject.prototype.PersonalDataStop = function(){
        if (this.GetSlide())
            this.txt = this.txt + '</SlidePersonalData>';
    };

    THTMLObject.prototype.CreateTitlePageObject = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.newObject('THTMLTitlePageObject');
        return null;
    };

    THTMLObject.prototype.CreateTableOfContensObject = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.newObject('THTMLTableOfContens');
        return null;
    };
    
    THTMLObject.prototype.DrawFigure = function(ctx){
        var obj = this.GetDrawObject();
        var objM = this.GetObjectManager();
        if (objM !== null && typeof obj !== 'undefined' && obj !== null && obj.IsType('TGenerateHTML') && typeof ctx !== 'undefined' && ctx !== null && ctx.IsType('TDrawContext'))
        {
            ctx.SetScale(1);
//            ctx_.SetContext(ctx);
            var matrix = objM.newObject('TMatrixTransformation3D');
            matrix.SetTranslationMatrix(0,0,0);
//                var matrix2 = objM.newObject('TMatrixTransformation2D');
//                var matrix3 = objM.newObject('TMatrixTransformation2D');
//                matrix.SetTranslationMatrix(this.width/2,this.height/2);
//                matrix2.SetScaleMatrix(this.scale);
//                matrix3.SetTranslationMatrix(this.x,this.y);
//                matrix.MatrixMultiplication(matrix2);
//                matrix.MatrixMultiplication(matrix3);
            ctx.SetTransformation(matrix);            
        
            obj.DrawFigure(ctx);
        }
    };

    THTMLObject.prototype.DrawThreeFigure = function(scene){
        var obj = this.GetDrawObject();
        var objM = this.GetObjectManager();
        if (objM !== null && typeof obj !== 'undefined' && obj !== null && obj.IsType('TGenerateHTML') && typeof scene !== 'undefined' && scene !== null && scene.IsType('TThreeScene'))
        {
            scene.SetScale(1);
            var matrix = objM.newObject('TMatrixTransformation3D');
            matrix.SetTranslationMatrix(0,0,0);

            scene.SetTransformation(matrix);            
        
            obj.DrawThreeFigure(scene);
        }
    };

    THTMLObject.prototype.DrawCanvasFigure = function(scene){
        var obj = this.GetDrawObject();
        var objM = this.GetObjectManager();
        if (objM !== null && typeof obj !== 'undefined' && obj !== null && obj.IsType('TGenerateHTML') && typeof scene !== 'undefined' && scene !== null && scene.IsType('TCanvasScene'))
        {
            scene.SetScale(1);
//            scene.SetCorrectScale(1);
            var matrix = objM.newObject('TMatrixTransformation3D');
            matrix.SetTranslationMatrix(0,0,0);

            scene.SetTransformation(matrix);            
        
            obj.DrawCanvasFigure(scene);
        }
    };
};

THTMLObject.prototype = new TGenerateObject();

function TTeXObject(){
    
    var type = 'TTeXObject';
    TTeXObject.prototype.InitConstructor = function(){
        TGenerateObject.prototype.InitConstructor.call(this);
        
        this.SetType(type);
//        this.txt = '';
            
    };
    this.InitConstructor();

    TTeXObject.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TGenerateObject.prototype.IsType.call(this,_type);
    };

    TTeXObject.prototype.Init = function(_object){
        TGenerateObject.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('THTMLObject'))
        {
//            if (typeof _object.txt !== 'undefined' && _object.txt !== null)
//            {
//                this.txt = new String(_object.txt);
//                this.txt = this.txt.toString();
//            }
        }
    };

    TTeXObject.prototype.CreateTitlePageObject = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
        {
            if (this.GetSlide())
                return objM.newObject('TTeXPresentationTitlePageObject');
            else
                return objM.newObject('TTeXTitlePageObject');
        }
        return null;
    };

    TTeXObject.prototype.CreateTableOfContensObject = function(){
        var objM = this.GetObjectManager();
        if (objM !== null)
            return objM.newObject('TTeXTableOfContens');
        return null;
    };
    
    TTeXObject.prototype.DrawThreeFigure = function(scene){
        var obj = this.GetDrawObject();
        var objM = this.GetObjectManager();
        if (objM !== null && typeof obj !== 'undefined' && obj !== null && obj.IsType('TGenerateTeX') && typeof scene !== 'undefined' && scene !== null && scene.IsType('TDrawContext'))
        {
            scene.SetScale(1);
            var matrix = objM.newObject('TMatrixTransformation3D');
            matrix.SetTranslationMatrix(0,0,0);

            scene.SetTransformation(matrix);            
        
            obj.DrawThreeFigure(scene);
        }
    };
    
    TTeXObject.prototype.DrawCanvasFigure = function(scene){
        var obj = this.GetDrawObject();
        var objM = this.GetObjectManager();
        if (objM !== null && typeof obj !== 'undefined' && obj !== null && obj.IsType('TGenerateTeX') && typeof scene !== 'undefined' && scene !== null && scene.IsType('TDrawContext'))
        {
            scene.SetScale(1);
//            scene.SetCorrectScale(2);
            var matrix = objM.newObject('TMatrixTransformation3D');
            matrix.SetTranslationMatrix(0,0,0);

            scene.SetTransformation(matrix);            
        
            obj.DrawCanvasFigure(scene);
        }
    };
    
    TTeXObject.prototype.GetImageCatalog = function(){
        var obj = this.GetDrawObject();
        if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TGenerateTeX'))
            return obj.GetImageCatalog();
        return null;
    };
    
    TTeXObject.prototype.SetImageCatalog = function(catalog){
        var obj = this.GetDrawObject();
        if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TGenerateTeX'))
            obj.SetImageCatalog(catalog);
    };
};

TTeXObject.prototype = new TGenerateObject();

function TRead(){
    
    var type = 'TRead';
    TRead.prototype.InitConstructor = function(){
        TObjectMultilanguage.prototype.InitConstructor.call(this);
        
        this.SetType(type);
        this.dataType = [];
        this.listFile = null;
            
    };
    this.InitConstructor();

    TRead.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObjectMultilanguage.prototype.IsType.call(this,_type);
    };


    TRead.prototype.Init = function(_object){
        TObjectMultilanguage.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TRead'))
        {
            if (typeof _object.dataType !== 'undefined' && _object.dataType !== null)
            {
                var i;            
                this.dataType = [];
                for (i = 0;i < _object.dataType;i++)
                {
                    this.dataType[i] = new String(_object.dataType[i]);
                    this.dataType[i] = this.dataType[i].toString();
                }
            }
            if (typeof _object.listFile !== 'undefined' && _object.listFile !== null && _object.listFile.IsType('TListString'))
                this.listFile = _object.listFile;
        }
    };

    TRead.prototype.EmptyDataType = function(){
        this.dataType = [];
    };

    TRead.prototype.AddDataType = function(_dataType){
        if (typeof _dataType !== 'undefined' && _dataType !== null)
        {
            this.dataType[this.dataType.length] = new String(_dataType);
            this.dataType[this.dataType.length - 1] = this.dataType[this.dataType.length - 1].toString();
        }
    };

    TRead.prototype.SetListFile = function(_listFile){
        if (_listFile === null)
            this.listFile = null;
            if (typeof _listFile !== 'undefined' && _listFile !== null && _listFile.IsType('TListString'))
                this.listFile = _listFile;
    };

    TRead.prototype.Read = function(object,fun,imageCatalog){
        
    };

    TRead.prototype.GetListFile = function(){
        return this.listFile;
    };
}

TRead.prototype = new TObjectMultilanguage();


function TReadXML(){
    
    var type = 'TReadXML';
    TReadXML.prototype.InitConstructor = function(){
        TRead.prototype.InitConstructor.call(this);
        
        this.SetType(type);
            
    };
    this.InitConstructor();

    TReadXML.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TRead.prototype.IsType.call(this,_type);
    };


    TReadXML.prototype.Init = function(_object){
        TRead.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TReadXML'))
        {
        }
    };

    TReadXML.prototype.Read_ = function(_dataType,object,objM,fun,imageCatalog){
        if (typeof object !== 'undefined' && object !== null && object.IsType('TReadPaperData') && objM !== null)
        {
            var list,elem,object_,file_,file = [],i = 0;
            list = this.GetListFile();
            if (list !== null)
            {
                for (elem = list.First();elem !== null;elem = list.Next())
                {
                    if(elem !== null)
                    {
                        object_ = elem.GetObject();
                        if (typeof object_ !== 'undefined' && object_ !== null && object_.IsType('TStringData'))
                        {
                            file_ = object_.GetStringData();
                            if (file_ !== null)
                            {        
                                file[i++] = file_;
                            }
                        }
                    }
                }
                if (i > 0)
                {
                    var xmlhttp = new XMLHttpRequest();
                    var str_json = JSON.stringify(file);

                    xmlhttp.onreadystatechange=function() {
                        if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
                            var data = JSON.parse(xmlhttp.responseText);
                            if (typeof data !== 'undefined' && data !== null)
                            {
                                var j,ii,jj,k,YN,obj,kk = 0,kkFileName,tmp,defaultLanguage = null,figureStyleAlignX = null;
                                for (j = 0;j < data.length;j++)
                                {
                                    if (typeof data[j] !== 'undefined' && data[j] !== null)
                                    {
                                        var tag,tag_,parser = new DOMParser();
                                        var tag2,tag2_,attr;
                                        var xmlDoc = parser.parseFromString(data[j],"text/xml");
                                        var tagDocument = FindTag(xmlDoc.getElementsByTagName("PGDocument"));
                                        var tagData = FindTag(tagDocument.getElementsByTagName("Body"));
                                        if (tagData !== null)
                                        {
                                            tag_ = FindTags(tagData.getElementsByTagName("Page"));
                                            if (tag_ !== null)
                                            {
                                                for (ii = 0;ii < tag_.length;ii++)
                                                {
                                                    tag = tag_[ii];
                                                    tag2_ = tag.childNodes;//FindTags(tag.getElementsByTagName("Element"));
                                                    if (tag2_ !== null)
                                                    {
                                                        for (jj = 0;jj < tag2_.length;jj++)
                                                        {
                                                            tag2 = tag2_[jj];                                                           
                                                            
                                                            if (tag2 !== null && tag2.nodeType === 1)
                                                            {
                                                                if (tag2.nodeName === 'Language')
                                                                {
                                                                    attr = tag2.getAttribute('default');
                                                                    if (attr !== null)
                                                                    {
                                                                        if (attr === 'none')
                                                                            defaultLanguage = null;
                                                                        else
                                                                            defaultLanguage = attr;
                                                                    }
                                                                }
                                                                if (tag2.nodeName === 'FigureStyle')
                                                                {
                                                                    attr = tag2.getAttribute('alignX');
                                                                    if (attr !== null)
                                                                    {
                                                                        switch(attr)
                                                                        {
                                                                            case 'center':
                                                                                figureStyleAlignX = attr;
                                                                                break;
                                                                            default:
                                                                                figureStyleAlignX = null;
                                                                        }
                                                                    }
                                                                }
                                                                if (tag2.nodeName === 'Element')
                                                                {
                                                                    attr = tag2.getAttribute('type');
                                                                    if (attr !== null)
                                                                    {
                                                                        if (_dataType === null || _dataType.length === 0)
                                                                        {
                                                                            YN = true;
                                                                        }else
                                                                        {
                                                                            YN = false;
                                                                            for (k = 0;k < _dataType.length;k++)
                                                                                if (attr === _dataType[k])
                                                                                {
                                                                                    YN = true;
                                                                                    break;
                                                                                }
                                                                        }
                                                                        if (YN)
                                                                        {
                                                                            obj = object.GetElement(kk);
                                                                            if (typeof obj === 'undefined' || obj === null)
                                                                            {
                                                                                obj = objM.newObject('T'+attr);
                                                                                if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                                                                                {
                                                                                    obj.SetDefaultLanguage(defaultLanguage);
                                                                                    obj.SetImageCatalog(imageCatalog);
                                                                                    obj.SetVariables(object.GetVariables());
                                                                                    if (obj.IsType('TDrawFigure'))
                                                                                        obj.SetAlignX(figureStyleAlignX);
                                                                                    object.AddElement(obj,kk);
    //                                                                                obj.SetReferenceName(object.GetReferenceName());
    //                                                                                obj.SetReferenceValue(object.GetReferenceValue());
                                                                                }
                                                                            }
                                                                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                                                                            {
                                                                                obj.ReadXML(tag2);
                                                                                object.SetVariables(obj.GetVariables());
                                                                            }
                                                                            kk++;
                                                                        }


                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        
                                    }
                                }
                                
/*                                if (typeof object !== 'undefined' && object !== null && object.IsType('TPage'))
                                {
                                    object.ActualizeId();
                                    object.LinkMethod();
                                    object.ActualizeVisible();
                                    object.ActualizeLocaleString();
                                    setTimeout(function(){ 
                                        object.ActualizeId();
                                        object.LinkMethod();
                                        object.ActualizeVisible();
                                        object.ActualizeLocaleString();
                                    }, 1000);
                                }*/
                                if (typeof fun !== 'undefined' && fun !== null)
                                {
                                    fun();
                                }
                            }
                        }
                    };        

                    xmlhttp.open("POST", "php/LoadDataXML.php", true);
                    xmlhttp.setRequestHeader("Content-type", "application/json");
                    xmlhttp.send(str_json)  ;      
        
        //        window.open('data:text/csv;charset=utf-8,' + escape(txt));       
                    
                }
            }            
        }
        
    };

    TReadXML.prototype.Read = function(object,fun,imageCatalog){
        TRead.prototype.Read.call(this,object);
        var objM = this.GetObjectManager();
        this.Read_(this.dataType,object,objM,fun,imageCatalog);
    };
}

TReadXML.prototype = new TRead();


function TReadSlideXML(){
    
    var type = 'TReadSlideXML';
    TReadSlideXML.prototype.InitConstructor = function(){
        TRead.prototype.InitConstructor.call(this);
        
        this.SetType(type);
            
    };
    this.InitConstructor();

    TReadSlideXML.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TRead.prototype.IsType.call(this,_type);
    };


    TReadSlideXML.prototype.Init = function(_object){
        TRead.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TReadXML'))
        {
        }
    };

    TReadSlideXML.prototype.Read_ = function(_dataType,object,objM,fun,imageCatalog){
        if (typeof object !== 'undefined' && object !== null && object.IsType('TPresentationManager') && objM !== null)
        {
            var list,elem,object_,file_,file = [],i = 0;
            list = this.GetListFile();
            if (list !== null)
            {
                for (elem = list.First();elem !== null;elem = list.Next())
                {
                    if(elem !== null)
                    {
                        object_ = elem.GetObject();
                        if (typeof object_ !== 'undefined' && object_ !== null && object_.IsType('TStringData'))
                        {
                            file_ = object_.GetStringData();
                            if (file_ !== null)
                            {        
                                file[i++] = file_;
                            }
                        }
                    }
                }
                if (i > 0)
                {
                    var xmlhttp = new XMLHttpRequest();
                    var str_json = JSON.stringify(file);

                    xmlhttp.onreadystatechange=function() {
                        if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
                            var data = JSON.parse(xmlhttp.responseText),tmp;
                            if (typeof data !== 'undefined' && data !== null)
                            {
                                var j,ii,jj,k,kk,YN,obj,kkFileName = 0,kkSlide = 0,kkTitle = 0,tag2_,tag22_,jjj;
                                var YNSlide,object_,attr,defaultLanguage = null;
                                var variables = [],i_var = 0,variable = null,var_tmp;
                                var actualTitle = [],tmpTitleLevel,slideTitleNumber,figureStyleAlignX = null;
                                for (j = 0;j < data.length;j++)
                                {
                                    if (typeof data[j] !== 'undefined' && data[j] !== null)
                                    {
                                        var tag,tag_,parser = new DOMParser();
                                        var tag2,tag3,attr,tmp;
                                        var xmlDoc = parser.parseFromString(data[j],"text/xml");
                                        var tagDocument = FindTag(xmlDoc.getElementsByTagName("SLDocument"));
                                        var tagData = FindTag(tagDocument.getElementsByTagName("Body"));
                                        var tableTableOfContents = [];
                                        if (tagData !== null)
                                        {
                                            tag_ = tagData.childNodes;
                                            if (tag_ !== null)
                                            {
                                                for (ii = 0;ii < tag_.length;ii++)
                                                {
                                                    if (tag_[ii].nodeType === 1)
                                                    {
                                                        if (tag_[ii].nodeName === 'Language')
                                                        {
                                                            attr = tag_[ii].getAttribute('default');
                                                            if (attr !== null)
                                                            {
                                                                if (attr === 'none')
                                                                    defaultLanguage = null;
                                                                else
                                                                    defaultLanguage = attr;
                                                            }
                                                        }
                                                        if (tag_[ii].nodeName === 'FigureStyle')
                                                        {
                                                            attr = tag_[ii].getAttribute('alignX');
                                                            if (attr !== null)
                                                            {
                                                                switch(attr)
                                                                {
                                                                    case 'center':
                                                                        figureStyleAlignX = attr;
                                                                        break;
                                                                    default:
                                                                        figureStyleAlignX = null;
                                                                }
                                                            }
                                                        }
                                                        if (tag_[ii].nodeName === 'ImageFileName')
                                                        {
                                                            tag = tag_[ii];
                                                            attr = null;
/*                                                            if (tag !== null)
                                                                attr = tag.getAttribute('type');
                                                            if (attr !== null && attr === 'Image')
                                                            {
                                                                tmp = 'TImageFileName';
                                                            }else
                                                                tmp = 'TFileName';*/
                                                            tmp = 'TImageFileName';
                                                            obj = object.GetFileName(kkFileName);
                                                            if (typeof obj === 'undefined' || obj === null)
                                                            {
                                                                obj = objM.newObject(tmp);
                                                                if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                                                                {
                                                                    obj.SetDefaultLanguage(defaultLanguage);
                                                                    object.SetFileName(obj,kkFileName);
                                                                }
                                                            }
                                                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                                                            {
                                                                obj.ReadXML(tag);
                                                            }
                                                            kkFileName++;
                                                        }
                                                        if (tag_[ii].nodeName === 'Background')
                                                        {
                                                            tag = tag_[ii];
                                                            if (tag !== null)
                                                            {
                                                                tag2 = tag.getAttribute('fileBackground');
                                                                if (tag2 !== null)
                                                                {
                                                                    tmp = object.FindFileName(tag2);
                                                                    object.SetDefaultBackground(tmp);
                                                                }
                                                            }
                                                            
                                                        }
                                                        if (tag_[ii].nodeName === 'Element')
                                                        {
                                                            tag = tag_[ii];
                                                            if (tag !== null)
                                                            {
                                                                tag2 = tag.getAttribute('type');
                                                                if (tag2 !== null && (tag2 === 'Var' || tag2 === 'Fun'))
                                                                {
                                                                    if (tag2 === 'Fun')
                                                                        variable = objM.newObject('TFun');
                                                                    else
                                                                        variable = objM.newObject('TVar');
                                                                    if (variable !== null)
                                                                    {
                                                                        variable.ReadXML(tag);
                                                                        var_tmp = variable.GetVariables();
                                                                        if (var_tmp !== null && var_tmp.length > 0)
                                                                            variables[i_var++] = var_tmp[0];
                                                                    }
                                                                }
                                                            }
                                                            
                                                        }
                                                        if (tag_[ii].nodeName === 'Title')
                                                        {
                                                            tag = tag_[ii];
                                                            obj = object.GetTitle(kkTitle);
                                                            if (typeof obj === 'undefined' || obj === null)
                                                            {
                                                                obj = objM.newObject('TPageElementPresentationTitle');
                                                                if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                                                                    object.SetTitle(obj,kkTitle);
                                                            }
                                                            if (typeof obj !== 'undefined' && obj !== null && obj.IsType('TPageElement'))
                                                            {
                                                                obj.SetDefaultLanguage(defaultLanguage);
                                                                obj.ReadXML(tag);
                                                                tmpTitleLevel = obj.GetLevel();
                                                                tmpTitleLevel = parseInt(tmpTitleLevel);
                                                                if (typeof tmpTitleLevel === 'undefined' || tmpTitleLevel === null)
                                                                    tmpTitleLevel = 0;
                                                                var tmp = actualTitle,kk;
                                                                actualTitle = [];
                                                                for (kk = 0;kk < tmpTitleLevel;kk++)
                                                                    actualTitle[kk] = tmp[kk];
                                                                actualTitle[tmpTitleLevel] = obj;
                                                                for (kk = 0;kk < tableTableOfContents.length;kk++)
                                                                {
                                                                    if (tableTableOfContents[kk] !== null)
                                                                    {
                                                                        tmp = tableTableOfContents[kk].GetSlideElement(kkTitle);
                                                                        if (tmp === null)
                                                                            tableTableOfContents[kk].AddSlideElement(obj);
                                                                    }
                                                                }
                                                            }
                                                            kkTitle++;
                                                        }
                                                        if (tag_[ii].nodeName === 'Slide')
                                                        {
                                                            tag = tag_[ii];
                                                            if (tag !== null)
                                                            {
                                                                tag2 = tag.getAttribute('id');
                                                                if (tag2 !== null)
                                                                {
                                                                    YNSlide = true;
                                                                    if (tag2 === 'TitlePresentation')
                                                                    {
                                                                        obj = object.GetSection(kkSlide);
                                                                        if (typeof obj === 'undefined' || obj === null)
                                                                        {
                                                                            obj = objM.newObject('TPresentationTitle');
                                                                            if (typeof obj !== 'undefined' && obj !== null)
                                                                            {
                                                                                obj.SetDefaultLanguage(defaultLanguage);
                                                                                tag3 = tag.getAttribute('fileBackground');
                                                                                obj.SetBackgroundId(tag3);
                                                                                obj.SetId(tag2);
                                                                                object.SetSection(obj,kkSlide);
                                                                            }
                                                                        }          
                                                                        YNSlide = true;
                                                                    }
                                                                    if (tag2 === 'TableOfContents')
                                                                    {
                                                                        obj = object.GetSection(kkSlide);
                                                                        if (typeof obj === 'undefined' || obj === null)
                                                                        {
                                                                            obj = objM.newObject('TPresentationTableOfContents');
                                                                            if (typeof obj !== 'undefined' && obj !== null)
                                                                            {
                                                                                obj.SetDefaultLanguage(defaultLanguage);
                                                                                tag3 = tag.getAttribute('fileBackground');
                                                                                obj.SetBackgroundId(tag3);
                                                                                obj.SetId(tag2);
                                                                                object.SetSection(obj,kkSlide);
                                                                            }
                                                                        }
                                                                        tableTableOfContents = object.FindTableOfContens();
                                                                        YNSlide = true;
                                                                    }
                                                                    if (YNSlide)
                                                                    {
                                                                        obj = object.GetSection(kkSlide);
                                                                        if (typeof obj === 'undefined' || obj === null)
                                                                        {
                                                                            obj = objM.newObject('TPresentationSlide');
                                                                            if (typeof obj !== 'undefined' && obj !== null)
                                                                            {
                                                                                obj.SetVariables(variables);
                                                                                obj.SetDefaultLanguage(defaultLanguage);
                                                                                slideTitleNumber = 0;
                                                                                for (k = 0;k < actualTitle.length;k++)
                                                                                {
                                                                                    if (typeof actualTitle[k] === 'undefined' || actualTitle[k] === null)
                                                                                    {
                                                                                        break;
                                                                                    }else
                                                                                    {
                                                                                        tmp = obj.GetSlideElement(slideTitleNumber++);
                                                                                        if (tmp === null)
                                                                                            obj.AddSlideElement(actualTitle[k]);
                                                                                    }
                                                                                    
                                                                                }
                                                                                tag3 = tag.getAttribute('fileBackground');
                                                                                obj.SetBackgroundId(tag3);
                                                                                obj.SetId(tag2);
                                                                                obj.SetTimeOut(tag.getAttribute('timeOut'));
                                                                                tag3 = tag.getAttribute('title');
                                                                                if (typeof tag3 !== 'undefined' && tag3 !== null)
                                                                                {
                                                                                    if (tag3 === 'Yes')
                                                                                        obj.SetTitleYN(true);
                                                                                    if (tag3 === 'No')
                                                                                        obj.SetTitleYN(false);
                                                                                }
                                                                                object.SetSection(obj,kkSlide);
                                                                            }
                                                                        }else
                                                                        {
                                                                            slideTitleNumber = 0;
                                                                            for (k = 0;k < actualTitle.length;k++)
                                                                            {
                                                                                if (typeof actualTitle[k] === 'undefined' || actualTitle[k] === null)
                                                                                {
                                                                                    break;
                                                                                }else
                                                                                {
                                                                                    slideTitleNumber++;
                                                                                }                                                                                
                                                                            }                                                                            
                                                                        }
                                                                        tag22_ = tag.childNodes;
                                                                        if (tag22_ !== null)
                                                                        {
                                                                            for (jjj = 0;jjj < tag22_.length;jjj++)
                                                                            {
                                                                                if (tag22_[jjj].nodeType === 1)
                                                                                {
                                                                                    if (tag22_[jjj].nodeName === 'Element')
                                                                                    {
                                                                                        tag2 = tag22_[jjj];
                                                                                        attr = tag2.getAttribute('type');
                                                                                        if (attr !== null)
                                                                                        {
                                                                                            if (_dataType === null || _dataType.length === 0)
                                                                                            {
                                                                                                YN = true;
                                                                                            }else
                                                                                            {
                                                                                                YN = false;
                                                                                                for (k = 0;k < _dataType.length;k++)
                                                                                                    if (attr === _dataType[k])
                                                                                                    {
                                                                                                        YN = true;
                                                                                                        break;
                                                                                                    }
                                                                                            }
                                                                                        }
                                                                                        if (YN)
                                                                                        {
                                                                                            object_ = obj.GetSlideElement(slideTitleNumber);
                                                                                            if (typeof object_ === 'undefined' || object_ === null)
                                                                                            {
                                                                                                object_ = objM.newObject('T'+attr);
                                                                                                if (typeof object_ !== 'undefined' && object_ !== null && object_.IsType('TPageElement'))
                                                                                                {
                                                                                                    object_.SetVariables(obj.GetVariables());
                                                                                                    object_.SetDefaultLanguage(defaultLanguage);
                                                                                                    object_.SetImageCatalog(imageCatalog);
                                                                                                    if (object_.IsType('TDrawFigure'))
                                                                                                        object_.SetAlignX(figureStyleAlignX);
                                                                                                    if (object_.IsType('TTimeOut'))
                                                                                                        obj.SetTimeOutObject(object_);
                                                                                                    obj.AddSlideElement(object_,slideTitleNumber);
                                                                                                    if (obj.IsType('TPresentationTableOfContents'))
                                                                                                        kkTitle++;
//                                                                                                    object_.SetReferenceName(obj.GetReferenceName());
//                                                                                                    object_.SetReferenceValue(obj.GetReferenceValue());
                                                                                                }
                                                                                            }
                                                                                            if (typeof object_ !== 'undefined' && object_ !== null && object_.IsType('TPageElement'))
                                                                                            {
                                                                                                object_.ReadXML(tag2);
                                                                                                obj.SetVariables(object_.GetVariables());
                                                                                            }
                                                                                            slideTitleNumber++;
                                                                                        }
                                                                                            
                                                                                        
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            kkSlide++;
                                                        }
                                                    }
                                                    continue;
                                                }
                                            }
                                        }
                                        
                                    }
                                }
                                
                                if (typeof object !== 'undefined' && object !== null && object.IsType('TPresentationManager'))
                                {
                                    object.ActualizeData();

                                }
                                if (typeof fun !== 'undefined' && fun !== null)
                                {
                                    fun();
                                }
                            }
                        }
                    };        

                    xmlhttp.open("POST", "php/LoadDataXML.php", true);
                    xmlhttp.setRequestHeader("Content-type", "application/json");
                    xmlhttp.send(str_json)  ;      
        
        //        window.open('data:text/csv;charset=utf-8,' + escape(txt));       
                    
                }
            }            
        }
        
    };

    TReadSlideXML.prototype.Read = function(object,fun,imageCatalog){
        TRead.prototype.Read.call(this,object);
        var objM = this.GetObjectManager();
        this.Read_(this.dataType,object,objM,fun,imageCatalog);
    };
}

TReadSlideXML.prototype = new TRead();

function TMultilanguageManager(){

    var type = 'TMultilanguageManager';
    TMultilanguageManager.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        
        this.SetType(type);
        this.nameLanguage = [];
        this.currentLanguage = -1;
        this.listObject = null;
            
    };
    this.InitConstructor();

    TMultilanguageManager.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };

    TMultilanguageManager.prototype.Init = function(_object){
        TObject.prototype.Init.call(this,_object);
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TMultilanguageManager'))
        {
            var i;
            if (typeof _object.currentLanguage !== 'undefined' && _object.currentLanguage !== null && IsInt(_object.currentLanguage))
                this.currentLanguage = _object.currentLanguage;
            if (typeof _object.nameLanguage !== 'undefined' && _object.nameLanguage !== null)
            {
                this.nameLanguage = [];
                for (i = 0;i < _object.nameLanguage;i++)
                {
                    this.nameLanguage[i] = new String (_object.nameLanguage[i]);
                    this.nameLanguage[i] = this.nameLanguage[i].toString();
                }
            }
        }
    };
    
    TMultilanguageManager.prototype.AddLanguage = function(name){
        if (typeof name !== 'undefined' && name !== null)
        {
            this.nameLanguage[this.nameLanguage.length] = new String(name);
            this.nameLanguage[this.nameLanguage.length - 1] = this.nameLanguage[this.nameLanguage.length - 1].toString();
            if (this.currentLanguage < 0)
                this.currentLanguage = 0;
        }
    };

    TMultilanguageManager.prototype.AddObject = function(_object){
        if (typeof _object !== 'undefined' && _object !== null && _object.IsType('TObjectMultilanguage'))
        {
            if (this.listObject === null)
            {
                var objM = this.GetObjectManager();
                if (objM !== null)
                {
                    this.listObject = objM.newObject('TListMultilanguageObject');
                }
            }
            this.listObject.Add(_object);
            _object.ChangeCurrentLanguageNumber(this.currentLanguage);
        }
    };

    TMultilanguageManager.prototype.NumberLanguage = function(_language){
        if (typeof _language === 'undefined' || _language === null)
        {
            return this.currentLanguage;
        }else
        {
            var i;
            for (i = 0;i < this.nameLanguage.length;i++)
                if (this.nameLanguage[i] === _language)
                    return i;
        }
        return null;
    };
    
    TMultilanguageManager.prototype.ChangeCurrentLanguage = function(_language){
        if (typeof _language !== 'undefined' && _language !== null)
        {
            this.currentLanguage = this.NumberLanguage(_language);
            if (this.listObject !== null)
                this.listObject.ChangeCurrentLanguageNumber(this.currentLanguage);
        }
    };

    TMultilanguageManager.prototype.GetCurrentLanguage = function(){
        return this.currentLanguage;
    };
    
    TMultilanguageManager.prototype.GetCurrentNameLanguage = function(){
        return this.nameLanguage[this.currentLanguage];
    };
}

TMultilanguageManager.prototype = new TObject();


function TObjectManager(){
    
    var type = 'TObjectManager';
    TObjectManager.prototype.InitConstructor = function(){
        TObject.prototype.InitConstructor.call(this);
        
        this.SetType(type);
        this.languageManager = null;
            
    };
    this.InitConstructor();

    TObjectManager.prototype.copy = function(_object){
        //TODO: Implement Me 
        if (typeof _object === 'undefined' || _object === null)
            return null;
        var obj = this.newObject(_object.GetType());
        if (obj !== null)
            obj.Init(_object);
        return obj;

    };

    TObjectManager.prototype.newObject = function(_type){
        if (typeof _type === 'undefined' && _type !== null)
            return null;

            
        var obj = new window[_type]();
        if (obj !== null)
        {
            obj.SetObjectManager(this);
            obj.InitConstructor2();
            if (obj.IsType('TObjectMultilanguage') && this.languageManager !== null)
                obj.SetLanguageManager(this.languageManager);
        }
        return obj;
    };
    
    TObjectManager.prototype.IsType = function(_type){
        if (typeof _type !== 'undefined' && _type !== null)
        {
            if (_type === type)
                return true;
        }
        return TObject.prototype.IsType.call(this,_type);
    };

    TObjectManager.prototype.SetLanguageManager = function(manager){
        if (typeof manager !== 'undefined' && manager !== null && manager.IsType('TMultilanguageManager'))
        {
            this.languageManager = manager;
        }
        if (manager === null)
            this.languageManager = null;
    };

}

TObjectManager.prototype = new TObject();
