/*
    The objects in this file encaplsulate ajax responses from server,
    in administration pages and player info area.
*/

var AjaxResponse = function (object) {
                        this._messages = new Array();
                        this._group = null;
                        this._user = null;
                        this._media = null;
                        this._metaFieldsManager = null;
                        this._mediaLinks = null;
                        this._mediaList = null;
                        this.init(object.responseXML);
                    }

AjaxResponse.prototype =
{
        init : function(xml)
                {
                    if (xml == undefined) {
                        // In restricted mode, we don't receive an XML response if session expired.
                        this._messages.push("Um erro aconteceu. A sua sess‹o pode ter acabado. Neste caso, faŤa login de novo.");
                        return;
                    }
                    this._messages = this.getAllChildrenContents(xml, "message");
                    this._success = this.getFirstChildContent(xml, "success") == 'true';

                    if (this.isChildPresent(xml, "groupInfo")) {
                        this.initGroup(this.getFirstChildElement(xml, "groupInfo"));
                    }
                    if (this.isChildPresent(xml, "userInfo")) {
                        this.initUser(this.getFirstChildElement(xml, "userInfo"));
                    }
                    if (this.isChildPresent(xml, "metasInfo")) {
                        this.initMetaFieldsManager(this.getFirstChildElement(xml, "metasInfo"));
                    }
                    if (this.isChildPresent(xml, "mediaInfo")) {
                        this.initMedia(this.getFirstChildElement(xml, "mediaInfo"));
                    }
                    if (this.isChildPresent(xml, "mediaList")) {
                        this.initMediaList(this.getFirstChildElement(xml, "mediaList"));
                    }
                    if (this.isChildPresent(xml, "mediaLinks")) {
                        this.initMediaLinks(this.getFirstChildElement(xml, "mediaLinks"));
                    }
                },

        initGroup : function (groupTag)
                        {
                            var id = this.getFirstChildContent(groupTag, "id");
                            var name = this.getFirstChildContent(groupTag, "name");
                            var members = new Array(0);
                            var membersTags = $A(groupTag.getElementsByTagName("member"));
                            for (var i=0; i<membersTags.length; i++) {
                                var member = membersTags[i];
                                var memberId = this.getFirstChildContent(member, "id");
                                var memberLogin = this.getFirstChildContent(member, "login");
                                var memberFirstName = this.getFirstChildContent(member, "firstName");
                                var memberLastName = this.getFirstChildContent(member, "lastName");
                                var memberEmail = this.getFirstChildContent(member, "email");
                                var memberCellPhone = this.getFirstChildContent(member, "cellPhone");
                                var memberRole = this.getFirstChildContent(member, "role");
                                var memberStatus = this.getFirstChildContent(member, "status");
                                members.push(new User(memberId, memberLogin, memberFirstName, memberLastName, memberEmail, memberCellPhone, memberRole, memberStatus, "", new Array(0), new Array(0)));
                            }
                            this._group = new Group(id, name, members);
                        },

        initUser : function (userTag)
                        {
                            var id = this.getFirstChildContent(userTag, "id");
                            var login = this.getFirstChildContent(userTag, "login");
                            var firstName = this.getFirstChildContent(userTag, "firstName");
                            var lastName = this.getFirstChildContent(userTag, "lastName");
                            var email = this.getFirstChildContent(userTag, "email");
                            var cellPhone = this.getFirstChildContent(userTag, "cellPhone");
                            var role = this.getFirstChildContent(userTag, "role");
                            var status = this.getFirstChildContent(userTag, "status");
                            var photo = this.getFirstChildContent(userTag, "photo");
                            var abilities = new Array(0);
                            var abilityTags = $A(userTag.getElementsByTagName("ability"));
                            abilityTags.each( function(ability){
                                abilities.push(ability.firstChild.nodeValue);
                            });
                            var groups = new Array(0);
                            var memberOfTags = $A(userTag.getElementsByTagName("memberOf"));
                            memberOfTags.each( function(group){
                                groups.push(new Group(group.firstChild.nodeValue, ""));
                            });
                            this._user = new User(id, login, firstName, lastName, email, cellPhone, role, status, photo, abilities, groups);
                        },

        initMedia : function (mediaTag)
                        {
                            this._media = this.parseMedia(mediaTag);
                        },

        parseMedia : function (mediaTag)
                        {
                            var id = this.getFirstChildContent(mediaTag, "id");
                            var title = this.getFirstChildContent(mediaTag, "title");

                            var m = new Media(id, title);
                            m.setStreamable(this.getFirstChildContent(mediaTag, "streamable") == "true");
                            m.setDescription(this.getFirstChildContent(mediaTag, "description"));
                            m.setKeyWords(this.getFirstChildContent(mediaTag, "keyWords"));
                            m.setOwner(this.getFirstChildContent(mediaTag, "owner"));
                            m.setOwnerId(this.getFirstChildContent(mediaTag, "ownerId"));
                            m.setOwnerHasProfile(this.getFirstChildContent(mediaTag, "ownerHasProfile") == 'true');
                            m.setOwnerSmartName(this.getFirstChildContent(mediaTag, "ownerSmartName"));
                            m.setType(this.getFirstChildContent(mediaTag, "type"));
                            m.setPlayRepExtension(this.getFirstChildContent(mediaTag, "playRepExtension"));
                            m.setExtension(this.getFirstChildContent(mediaTag, "extension"));
                            m.setThumbnailPath(this.getFirstChildContent(mediaTag, "thumbnailPath"));
                            m.setThumbnailTypePath(this.getFirstChildContent(mediaTag, "thumbnailTypePath"));
                            m.setRatio(this.getFirstChildContent(mediaTag, "ratio"));
                            m.setUploadDate(this.getFirstChildContent(mediaTag, "uploadDate"));
                            m.setExpireDate(this.getFirstChildContent(mediaTag, "expireDate"));
                            m.setNComments(this.getFirstChildContent(mediaTag, "nComments"));
                            m.setPlayMBR(this.getFirstChildContent(mediaTag, "mbrPlay") == "true");
                            if (this.isChildPresent(mediaTag, "textEmbedHTML")) m.setTextEmbedHTML(this.getFirstChildContent(mediaTag, "textEmbedHTML"));
                            if (this.isChildPresent(mediaTag, "thumbEmbedHTML")) m.setThumbEmbedHTML(this.getFirstChildContent(mediaTag, "thumbEmbedHTML"));
                            if (this.isChildPresent(mediaTag, "fullEmbedHTML")) m.setFullEmbedHTML(this.getFirstChildContent(mediaTag, "fullEmbedHTML"));
                            m.setPlaylist(this.getFirstChildContent(mediaTag, "isPlaylist") == "true");
                            m.setVisibilityType(this.getFirstChildContent(mediaTag, "visibilityType"));
                            if (this.isChildPresent(mediaTag, "visibilityGroups")) {
                                m.setVisibilityGroups(this.getAllChildrenContents(this.getFirstChildElement(mediaTag, "visibilityGroups"), "groupName"));
                            }
                            if (this.isChildPresent(mediaTag, "size")) {
                                m.setSize(this.getFirstChildContent(mediaTag, "size"));
                                m.setDownloadType(this.getFirstChildContent(mediaTag, "downloadType"));
                            }

                            for (var i=1; i<=14; i++)
                            {
                                var meta = this.getFirstChildContent(mediaTag, "meta"+i);
                                if (meta != null && meta != "") {
                                    eval("m.setMeta"+i+"(meta);");
                                }
                            }
                            return m;
                        },
        initMediaList : function (mediaListTag)
                        {
                            var values = new Array();
                            var tags = $A(mediaListTag.getElementsByTagName("mediaItem"));
                            var realThis = this;
                            tags.each( function(mediaTag) {
                                var media = realThis.parseMedia(mediaTag);
                                if (realThis.isChildPresent(mediaTag, "mediaItemLinks")) {
                                    media.setMediaLinks(realThis.parseMediaLinks(realThis.getFirstChildElement(mediaTag, "mediaItemLinks")));
                                }
                                values.push(media);
                            });
                            this._mediaList = values;
                        },
        initMetaFieldsManager : function (metasTag)
                        {
                            var activeArray = new Array();
                            var descArray = new Array();
                            for (var i = 1; i<=14; i++)
                            {
                                var desc = this.getFirstChildContent(metasTag, "meta"+i+"Desc");
                                activeArray[i] = (desc != null);
                                descArray[i] = desc;
                            }
                            this._metaFiedsManager = new MetaFieldsManager(activeArray, descArray);
                        },
        initMediaLinks : function (mediaLinksTag)
                        {
                            this._mediaLinks = this.parseMediaLinks(mediaLinksTag);
                        },
        parseMediaLinks : function (mediaLinksTag)
                        {
                            var downloadLink, playLink, emailLink, seeProfileLink, editLink, deleteLink;
                            
                            if (this.isChildPresent(mediaLinksTag, "download")) {
                                downloadLink = this.parseLink(this.getFirstChildElement(mediaLinksTag, "download"));
                            }
                            if (this.isChildPresent(mediaLinksTag, "play")) {
                                playLink = this.parseLink(this.getFirstChildElement(mediaLinksTag, "play"));
                            }
                            if (this.isChildPresent(mediaLinksTag, "email")) {
                                emailLink = this.parseLink(this.getFirstChildElement(mediaLinksTag, "email"));
                            }
                            if (this.isChildPresent(mediaLinksTag, "see")) {
                                seeProfileLink = this.parseLink(this.getFirstChildElement(mediaLinksTag, "see"));
                            }
                            if (this.isChildPresent(mediaLinksTag, "modify")) {
                                editLink = this.parseLink(this.getFirstChildElement(mediaLinksTag, "modify"));
                            }
                            if (this.isChildPresent(mediaLinksTag, "delete")) {
                                deleteLink = this.parseLink(this.getFirstChildElement(mediaLinksTag, "delete"));
                            }
                            return new MediaLinks(playLink, downloadLink, emailLink, seeProfileLink, editLink, deleteLink);
                        },

        parseLink : function (linkElement)
                        {
                            var link = new Link();
                            if (this.isChildPresent(linkElement, "href")) {
                                link.setHref(this.getFirstChildContent(linkElement, "href"));
                            }
                            if (this.isChildPresent(linkElement, "onclick")) {
                                link.setOnclick(this.getFirstChildContent(linkElement, "onclick"));
                            }
                            if (this.isChildPresent(linkElement, "onmouseover")) {
                                link.setOnmouseover(this.getFirstChildContent(linkElement, "onmouseover"));
                            }
                            if (this.isChildPresent(linkElement, "onmouseout")) {
                                link.setOnmouseout(this.getFirstChildContent(linkElement, "onmouseout"));
                            }
                            return link;
                        },

        hasGroup : function()
                        {
                            return this._group != null;
                        },

        hasUser : function()
                        {
                            return this._user != null;
                        },

        hasMedia : function()
                        {
                            return this._media != null;
                        },

        hasMediaList : function()
                        {
                            return this._mediaList != null;
                        },

        hasMediaLinks : function()
                        {
                            return this._mediaLinks != null;
                        },

        hasMessage : function()
                        {
                            return this._messages != null && this._messages.length != 0;
                        },

        isSuccess : function()
                        {
                            return this._success;
                        },

        getGroup : function()
                        {
                            return this._group;
                        },

        getUser : function()
                        {
                            return this._user;
                        },

        getMedia : function()
                        {
                            return this._media;
                        },

        getMediaList : function()
                        {
                            return this._mediaList;
                        },

        getMediaLinks : function()
                        {
                            return this._mediaLinks;
                        },

        getMetaFieldsManager : function()
                        {
                            return this._metaFiedsManager;
                        },

        getMessages : function()
                        {
                            return this._messages;
                        },

        /*
            Returns an Array of the contents of all children with the given name,
            under the given element.
            Returns an empty Array if there is no child with this tag name.
            Returns an empty string if the child tag content is null.
            @param xmlElement and xml element
            @param childName the tag name of the children we are looking for
        */
        getAllChildrenContents : function (xmlElement, childTagName)
                        {
                            var values = new Array();
                            var tags = $A(xmlElement.getElementsByTagName(childTagName));
                            tags.each( function(tag) {
                                var firstChild = tag.firstChild;
                                if (firstChild != null && firstChild.nodeValue != '') values.push(firstChild.nodeValue);
                            });
                            return values;
                        },


        /*
            Returns the content of the first child tag of the given name, under the given element.
            Returns null if there is no child with this tag name.
            Returns an empty string if the child tag content is null.
            Example : <parent><a>AAA</a><b>BBB</b></parent>
                      getFirstChildContent(parentTag, 'b') -> 'BBB'
            @param xmlElement and xml element
            @param childName the tag name of the child we are looking for
        */
        getFirstChildContent : function (xmlElement, childTagName)
                        {
                            var firstChildElement = this.getFirstChildElement(xmlElement, childTagName);
                            if (firstChildElement == null) return null;
                            var firstChildElementFirstChild = firstChildElement.firstChild;
                            return firstChildElementFirstChild == null ? '' : firstChildElementFirstChild.nodeValue;
                        },

        /*
            Returns the first child element of the given name, under the given element.
            Returns null if there is no child with this tag name.
            Example : <parent><a>AAA</a><b>BBB</b></parent>
                      getFirstChildElement(parentTag, 'b') -> b Node
            @param xmlElement and xml element
            @param childName the tag name of the child we are looking for
        */
        getFirstChildElement : function (xmlElement, childTagName)
                        {
                            if (!this.isChildPresent(xmlElement, childTagName)) return null;
                            return xmlElement.getElementsByTagName(childTagName)[0];
                        },

        /*
            Returns true if at list one child element with the given name is present in the XML object.
            @param xmlElement and xml element
            @param childName the tag name of the child we are looking for
        */
        isChildPresent : function (xmlElement, childTagName)
                        {
                            return xmlElement.getElementsByTagName(childTagName).length > 0;
                        }

}


var Group = function (groupId, groupName, membersArray)
        {
            this._id = groupId;
            this._name = groupName;
            this._members = membersArray;
        }
Group.prototype =
{
        getId : function() { return this._id; },
        setId : function(id) { this._id = id; },
        getName : function() { return this._name; },
        getNameEscaped : function() { return this._name.escapeHTML(); },
        setName : function(name) { this._name = name; },
        getMembers : function() { return this._members; },
        setMembers : function(members) { this._members = members; },
        getNMembers : function() { return this._members.length}
}




var User = function (id, login, firstName, lastName, email, cellPhone, role, status, photo, abilities, groups)
        {
            this._id = id;
            this._login = login;
            this._firstName = firstName;
            this._lastName = lastName;
            this._email = email;
            this._cellPhone = cellPhone;
            this._role = role;
            this._status = status;
            this._photo = photo;
            this._abilities = abilities;
            this._groups = groups;
        }
User.prototype =
{
        getId : function() { return this._id; },
        setId : function(id) { this._id = id; },
        getLogin : function() { return this._login; },
        getLoginEscaped : function() { return this._login.escapeHTML(); },
        setLogin : function(login) { this._login = login; },
        getFirstName : function() { return this._firstName; },
        getFirstNameEscaped : function() { return this._firstName.escapeHTML(); },
        setFirstName : function(firstName) { this._firstName = firstName; },
        getLastName : function() { return this._lastName; },
        getLastNameEscaped : function() { return this._lastName.escapeHTML(); },
        setLastName : function(lastName) { this._lastName = lastName; },
        getEmail : function() { return this._email; },
        getEmailEscaped : function() { return this._email.escapeHTML(); },
        setEmail : function(email) { this._email = email; },
        getCellPhone : function() { return this._cellPhone; },
        getCellPhoneEscaped : function() { return this._cellPhone.escapeHTML(); },
        setCellPhone : function(cellPhone) { this._cellPhone = cellPhone; },
        getRole : function() { return this._role; },
        setRole : function(role) { this._role = role; },
        getStatus : function() { return this._status; },
        setStatus : function(status) { this._status = status; },
        getPhoto : function() { return this._photo; },
        setPhoto : function(photo) { this._photo = photo; },
        getAbilities : function() { return this._abilities; },
        setAbilities : function(abilities) { this._abilities = abilities; },
        getGroups : function() { return this._groups; },
        setGroups : function(groups) { this._groups = groups; },
        isActive : function() {return this.getStatus().toLowerCase() == 'active'},
        getFullName : function() {
            if (this._firstName == '') return this.getLastName();
            if (this._lastName == '') return this.getFirstName();
            return this._firstName + ' ' + this._lastName;
        }
}



var MetaFieldsManager = function(activesArray, descriptionsArray)
        {
            this._actives = activesArray;
            this._descriptions = descriptionsArray;
        }
MetaFieldsManager.prototype =
{
    isActive : function(metaN) {
        return this._actives[metaN];
    },
    getDescription: function(metaN) {
        return this._descriptions[metaN];
    }
}


var Media = function (id, title)
        {
            this._id = id;
            this._title = title;
        }
Media.prototype =
{
        getId : function() { return this._id; },
        setId : function(id) { this._id = id; },
        getTitle : function() { return this._title; },
        getTitleEscaped : function() { return this._title.escapeHTML(); },
        setTitle : function(title) { this._title = title; },
        getDescription : function() { return this._description; },
        getDescriptionEscaped : function() { return this._description.escapeHTML(); },
        setDescription : function(description) { this._description = description; },
        getKeyWords : function() { return this._keyWords; },
        getKeyWordsEscaped : function() { return this._keyWords.escapeHTML(); },
        setKeyWords : function(keyWords) { this._keyWords = keyWords; },
        getOwner : function() { return this._owner; },
        getOwnerEscaped : function() { return this._owner.escapeHTML(); },
        setOwner : function(owner) { this._owner = owner; },
        getOwnerId : function() { return this._ownerId; },
        setOwnerId : function(ownerId) { this._ownerId = ownerId; },
        getOwnerHasProfile : function() { return this._ownerHasProfile; },
        setOwnerHasProfile : function(hasProfile) { this._ownerHasProfile = hasProfile; },
        getOwnerSmartName : function() { return this._ownerSmartName.escapeHTML(); },
        setOwnerSmartName : function(smartName) { this._ownerSmartName = smartName; },
        getPlayMBR : function() { return this._playMBR; },
        setPlayMBR : function(mbr) { this._playMBR = mbr; },
        getStreamable : function() { return this._streamable; },
        setStreamable : function(streamable) { this._streamable = streamable; },
        getType : function() { return this._type; },
        setType : function(type) { this._type = type; },
        getPlayRepExtension : function() { return this._playRepExtension; },
        setPlayRepExtension : function(playRepExtension) { this._playRepExtension = playRepExtension; },
        getExtension : function() { return this._extension; },
        setExtension : function(extension) { this._extension = extension; },
        getSize : function() { return this._size; },
        setSize : function(size) { this._size = size; },
        getDownloadType : function() { return this._downloadType; },
        setDownloadType : function(type) { this._downloadType = type; },
        getThumbnailPath : function() { return this._thumbnailPath; },
        setThumbnailPath : function(thumbnailPath) { this._thumbnailPath = thumbnailPath; },
        getThumbnailTypePath : function() { return this._thumbnailTypePath; },
        setThumbnailTypePath : function(thumbnailTypePath) { this._thumbnailTypePath = thumbnailTypePath; },
        getUploadDate : function() { return this._uploadDate; },
        setUploadDate : function(uploadDate) { this._uploadDate = uploadDate; },
        getExpireDate : function() { return this._expireDate; },
        setExpireDate : function(expireDate) { this._expireDate = expireDate; },
        getNComments : function() { return this._nComments; },
        setNComments : function(nComments) { this._nComments = nComments; },
        getVisibilityType : function() { return this._visibilityType; },
        setVisibilityType : function(visibilityType) { this._visibilityType = visibilityType; },
        getVisibilityGroups : function() { return this._visibilityGroups; },
        setVisibilityGroups : function(groups) { this._visibilityGroups = groups; },
        isPlaylist : function() { return this._playlist; },
        setPlaylist : function(isPlaylist) { this._playlist = isPlaylist; },
        getTextEmbedHTML : function() { return this._textEmbedHTML; },
        setTextEmbedHTML : function(html) { this._textEmbedHTML = html.length > 0 ? html : null; },
        getThumbEmbedHTML : function() { return this._thumbEmbedHTML; },
        setThumbEmbedHTML : function(html) { this._thumbEmbedHTML = html.length > 0 ? html : null; },
        getFullEmbedHTML : function() { return this._fullEmbedHTML; },
        setFullEmbedHTML : function(html) { this._fullEmbedHTML = html.length > 0 ? html : null; },
        getRatio : function() { return this._ratio; },
        setRatio : function(ratio) { this._ratio = ratio; },
        getMeta1 : function() { return this._meta1; },
        setMeta1 : function(meta) { this._meta1 = meta; },
        getMeta2 : function() { return this._meta2; },
        setMeta2 : function(meta) { this._meta2 = meta; },
        getMeta3 : function() { return this._meta3; },
        setMeta3 : function(meta) { this._meta3 = meta; },
        getMeta4 : function() { return this._meta4; },
        setMeta4 : function(meta) { this._meta4 = meta; },
        getMeta5 : function() { return this._meta5; },
        setMeta5 : function(meta) { this._meta5 = meta; },
        getMeta6 : function() { return this._meta6; },
        setMeta6 : function(meta) { this._meta6 = meta; },
        getMeta7 : function() { return this._meta7; },
        setMeta7 : function(meta) { this._meta7 = meta; },
        getMeta8 : function() { return this._meta8; },
        setMeta8 : function(meta) { this._meta8 = meta; },
        getMeta9 : function() { return this._meta9; },
        setMeta9 : function(meta) { this._meta9 = meta; },
        getMeta10 : function() { return this._meta10; },
        setMeta10 : function(meta) { this._meta10 = meta; },
        getMeta11 : function() { return this._meta11; },
        setMeta11 : function(meta) { this._meta11 = meta; },
        getMeta12 : function() { return this._meta12; },
        setMeta12 : function(meta) { this._meta12 = meta; },
        getMeta13 : function() { return this._meta13; },
        setMeta13 : function(meta) { this._meta13 = meta; },
        getMeta14 : function() { return this._meta14; },
        setMeta14 : function(meta) { this._meta14 = meta; },
        getMeta : function(metaN) {
            switch(metaN) {
                case 1 : return this.getMeta1();
                case 2 : return this.getMeta2();
                case 3 : return this.getMeta3();
                case 4 : return this.getMeta4();
                case 5 : return this.getMeta5();
                case 6 : return this.getMeta6();
                case 7 : return this.getMeta7();
                case 8 : return this.getMeta8();
                case 9 : return this.getMeta9();
                case 10 : return this.getMeta10();
                case 11 : return this.getMeta11();
                case 12 : return this.getMeta12();
                case 13 : return this.getMeta13();
                case 14 : return this.getMeta14();
                default : return null;
            }
        },
        getMediaLinks : function() { return this._mediaLinks; },
        setMediaLinks : function(mediaLinks) { this._mediaLinks = mediaLinks; }
}


var MediaLinks = function (playLink, downloadLink, emailLink, seeProfileLink, editLink, deleteLink)
        {
            this._playLink = playLink;
            this._downloadLink = downloadLink;
            this._emailLink = emailLink;
            this._seeProfileLink = seeProfileLink;
            this._editLink = editLink;
            this._deleteLink = deleteLink;
        }
MediaLinks.prototype =
{
    canPlay : function() {return this._playLink != null; },
    canSeeProfile : function() {return this._seeProfileLink != null; },
    canDownload : function() {return this._downloadLink != null; },
    canEmail : function() {return this._emailLink != null; },
    canEdit : function() {return this._editLink != null; },
    canDelete : function() {return this._deleteLink != null; },

    getPlayLink : function() {return this._playLink;},
    getDownloadLink : function() {return this._downloadLink;},
    getEmailLink : function() {return this._emailLink;},
    getSeeProfileLink : function() {return this._seeProfileLink;},
    getEditLink : function() {return this._editLink;},
    getDeleteLink : function() {return this._deleteLink;}
}


var Link = function () {}
Link.prototype =
{
    hasHref : function() {return this._href != null && this._href != '';},
    hasOnclick : function() {return this._onclick != null && this._onclick != '';},
    hasOnmouseover : function() {return this._onmouseover != null && this._onmouseover != '';},
    hasOnmouseout : function() {return this._onmouseout != null && this._onmouseout != '';},
    hasTitle : function() {return this._title != null && this._title != '';},

    getHref : function() {return this._href;},
    getOnclick : function() {return this._onclick;},
    getOnmouseover : function() {return this._onmouseover;},
    getOnmouseout : function() {return this._onmouseout;},
    getTitle : function() {return this._title;},

    setHref : function(val) {this._href = val;},
    setOnclick : function(val) {this._onclick = val;},
    setOnmouseover : function(val) {this._onmouseover = val;},
    setOnmouseout : function(val) {this._onmouseout = val;},
    setTitle : function(val) {this._title = val;},

    copyToLinkElement : function(linkElement) {
                            linkElement.href = this.getHref();
                            linkElement.onclick = this.getOnclick();
                            linkElement.onmouseover = this.getOnmouseover();
                            linkElement.onmouseout = this.getOnmouseout();
                            if (this.getTitle() != null && this.getTitle().length != 0) linkElement.title = this.getTitle();
                        }

}