var agt = window.navigator.userAgent.toLowerCase();
var ie = (agt.indexOf("msie") != -1) ? true: false;
var moz = (agt.indexOf("gekko") != -1 || agt.indexOf("khtml") != -1) ? true: false;
var khtml = (agt.indexOf("khtml") != -1) ? true: false;
var isSafari = false;
if (agt.indexOf("safari") != -1 && agt.indexOf("version/3") < 0) {
    moz = false;
    isSafari = true;
};
var isOpera = (agt.indexOf("opera") != -1 && !isSafari) ? true: false;
var t = top.document;
if (typeof(editNode) == "undefined") {
    var editNode = editMode = editorMenu = editableDocument = closeMenuContacts = top.tmpWiki = top.tmpWikiTitle = null;
    top.designMode = false;
    var closeEditor;
    var usedUrls = new Array();
}
top.authExtensions = new Array(".jpg", "jpeg", ".gif", ".png");
var autNodes = new Array("img", "a", "div", "p", "b", "u", "i", "strong", "br");
var fbid = new Array("script", "noscript", "frame", "style", "form");
var autAtt = new Array("href", "src");
var RemAtt = new Array("onclick", "ondblclick", "onchange", "onfocus", "onkeydown", "onkeypress", "onkeyup", "onmousedown", "onmousemove", "onmouseout", "onmouseover", "onmouseup", "id", "class", "height", "width", "border", "name", "action", "nowrap", "lang");
function editor(objRef, id, name, action, tgt, mode, elemId, extCss, minWidth, minHeight) {
    top.edit = true;
    this.objRef = objRef;
    this.id = (id != null && id != "") ? id: "0";
    this.name = (name != null && name != "") ? name: "wiki";
    this.action = (action != null && action != "") ? action: "/datas/saveWiki.jsp";
    this.tgt = (tgt) ? tgt: "stdfrm";
    this.extCss = (extCss) ? extCss: false;
    this.buttonpath = "/shared/gui/editor/buttons/";
    this.altMail=false;
    this.mode = (mode != null && mode != "") ? mode: "normal";
    if(mode=="altmail"){
    this.mode="mail";
    this.altMail=true;
    }
    this.minWidth = (minWidth != null && minWidth != "") ? minWidth: false;
    this.minHeight = (minHeight != null && minHeight != "") ? minHeight: false;
    editMode = this.mode;
}
editor.prototype.build = function(cancelDatas, cssClass) {
    this.form = top.document.createElement("FORM");
    if (cssClass) this.form.className = cssClass;
    this.form.name = this.name;
    this.form.action = this.action;
    this.form.method = "post";
    this.form.target = "stdfrm";
    this.form.id = "wikiform";
    this.form.enctype = "application/x-www-form-urlencoded";
    this.form.acceptCharset = "UTF-8";
    this.editortitle = top.document.createElement("INPUT");
    this.editortitle.name = "wikititle";
    this.editortitle.type = "hidden";
    this.editortitle.value = "";
    this.form.appendChild(this.editortitle);
    this.editordata = top.document.createElement("INPUT");
    this.editordata.name = "wikidatas";
    this.editordata.type = "hidden";
    this.editordata.value = "";
    this.form.appendChild(this.editordata);
    this.editorid = top.document.createElement("INPUT");
    this.editorid.name = "id";
    this.editorid.type = "hidden";
    this.editorid.value = this.id;
    this.form.appendChild(this.editorid);
    if(this.altMail){
    this.headerBar = top.document.createElement("DIV");
    this.headerBar.name="sendtofriendheader";
    this.headerBar.className="header headerSize3";
    this.form.appendChild(this.headerBar);
    this.headerContent = top.document.createElement("DIV");
    this.headerContent.className="header_content";
    this.headerBar.appendChild(this.headerContent);
    this.headerIcon = top.document.createElement("DIV");
    this.headerIcon.className="headerIcon";
    this.headerContent.appendChild(this.headerIcon);
    this.headerIconSpan = top.document.createElement("SPAN");
    this.headerIconSpan.className="headerIcon_reply";
    this.headerIcon.appendChild(this.headerIconSpan);
    this.headerTitle = top.document.createElement("DIV");
    this.headerTitle.className="headerTitle";
    this.headerContent.appendChild(this.headerTitle);
    this.headerIconH3 = top.document.createElement("H3");
    this.headerTitle.appendChild(this.headerIconH3);
    this.headerIconH3.appendChild(top.document.createTextNode(_sendtofriends));
    this.clearHeader = top.document.createElement("DIV");
    this.clearHeader.className="clear";
    this.headerContent.appendChild(this.clearHeader);
    }
    this.mainBody = top.document.createElement("DIV");
    this.mainBody.className = "editor";
    if (this.extCss) this.mainBody.className = "editor " + this.extCss;
    if (this.minWidth) this.mainBody.style.minWidth = this.minWidth;
    if (this.minHeight) this.mainBody.style.minHeight = this.minHeight;
    if (editMode != "publish") {
        this.form.appendChild(this.mainBody);
    };

    this.topBAR = top.document.createElement("DIV");
    this.topBAR.id = "topbar";
    this.topBAR.className = "topbar";
    editorMenu = this.topBAR;
    this.mainBody.appendChild(this.topBAR);

    this.datasDIV = top.document.createElement("DIV");
    this.datasDIV.className = "eddatas";
    this.mainBody.appendChild(this.datasDIV);
    this.datas();
    this.editBar();
    return (this.mode != "publish") ? this.form: this.mainBody;
}

editor.prototype.datas = function() {
    if (ie || isSafari) {
        this.editZone = top.document.createElement("DIV");
        this.editZone.contentEditable = "true";
        this.editZone.id = "edit";
        this.editZone.className = "wikiedit";
        this.editZone.contentEditable = true;
        //document.designMode="on";
        if (window.attachEvent) {
            this.editZone.attachEvent("onmouseup", this.getEditorAttributes);
        } else {
            this.editZone.addEventListener("mouseup", this.getEditorAttributes, true);
        };

        this.datasDIV.appendChild(this.editZone);
        editNode = this.editZone;
        if (tmpNode && tmpNode.innerHTML) editNode.innerHTML = tmpNode.innerHTML;
    } else {
        this.editZone = document.createElement("iframe");
        this.editZone.className = "ifwikiedit";
        this.editZone.id = "ifwikiedit";
        this.editZone.style.width = "99%";
        editNode = this.editZone;
        this.datasDIV.appendChild(this.editZone);
        this.datasDIV.style.textAlign = "center";
        window.setTimeout(this.setItOn, 80);
    }
}
editor.prototype.setItOn = function() {
    var eNode = editNode.contentWindow.document;
    var extCss = (WIKI.extCss) ? "<link rel='stylesheet' type='text/css' href='/shared/style/external.css'/>\n": "";
    var blank = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n" + extCss + "</head>\n<body leftmargin=\"5\" topmargin=\"5\" style=\"font-size:12px;\"><div style=\"min-height:20px;\" class=\"edblank\"> </div></body>\n</html>";
    eNode.open();
    eNode.write(blank);
    eNode.close();
    if (eNode.body) {
        eNode.body.addEventListener("mouseup", iframeAttributes, true);
    };
    editableDocument = editNode.contentDocument;
    if (editableDocument) {
        editableDocument.addEventListener("mouseup", iframeAttributes, true);
        editableDocument.pageStyle = "@import url(/shared/css/external.css);";
        var eBody = editableDocument.body;
        if (eBody) {
            eBody.className = "wikiedit";
            eBody.style.marginLeft = "5px";
            eBody.id = "edit";
        };
        editableDocument.designMode = "on";
    };
    try {
        editableDocument.designMode = "on";
    } catch(e) {
        window.setTimeout(function() {
            editableDocument.designMode = "on";
        },
        100);
    };
}
editor.prototype.editBar = function() {
    while (this.topBAR.hasChildNodes()) this.topBAR.removeChild(this.topBAR.childNodes[0]);
    if (editMode == "light" || editMode == "LE") {
        this.ligthMode();
    } else if (editMode == "mail") {
        this.mailMode();
    } else if (editMode == "publish") {
        this.publishMode();
    } else if (top.g_mode) {
        if (top.g_mode == "advanced") {
            this.normalMode();
            this.topBAR.appendChild(this.modeButton("advanced"));
        } else {
            this.normalMode();
            this.topBAR.appendChild(this.modeButton("normal"));
        };
    } else if (editMode == "advanced") {
        this.normalMode();
    } else {
        this.normalMode();
    }
}

editor.prototype.normalMode = function(method) {
    editbar = top.document.createElement("DIV");
    editbar.id = "editormenu";
    editbar.className = "edmenubar";
    editbar.appendChild(this.saveBank());
    editbar.appendChild(this.textBank());
    //editbar.appendChild(this.justifyBank());
    if (method == "get") {
        return editbar;
    } else {
        this.topBAR.appendChild(editbar);
    };
}
editor.prototype.publishMode = function(method) {
    editbar = top.document.createElement("DIV");
    editbar.id = "editormenu";
    editbar.className = "edmenubar";
    editbar.appendChild(this.textBank());
    editbar.appendChild(this.linksBank());
    if (method == "get") {
        return editbar;
    } else {
        this.topBAR.appendChild(editbar);
    };
}
editor.prototype.ligthMode = function() {
    editbar = top.document.createElement("DIV");
    editbar.id = "editormenu";
    editbar.className = "edmenubar";
    editbar.appendChild(this.saveBank());
    editbar.appendChild(this.linksBank());
    editbar.appendChild(this.textBank());
    this.topBAR.appendChild(editbar);
}

editor.prototype.mailMode = function() {
    editbar = top.document.createElement("DIV");
    editbar.id = "editormenu";
    editbar.className = "edmenubar";
    this.topBAR.appendChild(editbar);

    sendBar = top.document.createElement("DIV");
    sendBar.style.width = "100%";
    sendBar.style.padding = "3px";
    editbar.appendChild(sendBar);

    toLine = top.document.createElement("DIV");
    sendBar.appendChild(toLine);

    warnAdress = top.document.createElement("DIV");
    sendBar.appendChild(warnAdress);

    sendToLabel = top.document.createElement("DIV");
    sendToLabel.className = "edlabel";
    
    sendToLabel.style.textAlign = (moz) ? "moz-right": "right";
    sendToLabelTxt = top.document.createTextNode(_to);
    sendToLabel.appendChild(sendToLabelTxt);
    if(this.altMail){
    sendToLabel.className = "edlabelcustom";
   	sendToRequired = top.document.createElement("SPAN");
   	sendToRequired.className="required";
	sendToRequired.appendChild(top.document.createTextNode("*"));
	sendToLabel.appendChild(sendToRequired);
    }
    toLine.appendChild(sendToLabel);

    sendToAddress = top.document.createElement("DIV");
    sendToAddress.style.width = "100%";
    sendToInput = top.document.createElement("TEXTAREA");
    sendToInput.name = "sendto";
    sendToInput.id = "sendtoinput";
    sendToInput.className = "edinput";
    sendToAddress.appendChild(sendToInput);
    toLine.appendChild(sendToAddress);
    if (window.attachEvent) {
        sendToInput.attachEvent("onkeyup", this.callContact, true);
    } else if (window.addEventListener) {
        sendToInput.addEventListener("keyup", this.callContact, true);
    };
    if (window.attachEvent) {
        sendToInput.attachEvent("onfocus", this.callContact, true);
    } else if (window.addEventListener) {
        sendToInput.addEventListener("focus", this.callContact, true);
    };
    if (window.attachEvent) {
        sendToInput.attachEvent("onblur", closeMenucontacts, false);
    } else if (window.addEventListener) {
        sendToInput.addEventListener("blur", closeMenucontacts, false);
    };
    if (window.attachEvent) {
        sendToInput.attachEvent("onmouseout", closeMenucontacts, false);
    } else if (window.addEventListener) {
        sendToInput.addEventListener("mouseout", closeMenucontacts, false);
    };

    warn = top.document.createElement("DIV");
    warn.style.display = "none";
    warn.id = "warnadress";
    warn.className = "warnadress";
    warnAdress.appendChild(warn);

    subjectLine = top.document.createElement("DIV");
    sendBar.appendChild(subjectLine);
    subjectLabel = top.document.createElement("DIV");
    subjectLabel.className = "edlabel";
    subjectLabel.style.textAlign = (moz) ? "moz-right": "right";
    subjectLabelTxt = top.document.createTextNode(_subject);
    subjectLabel.appendChild(subjectLabelTxt);
    if(this.altMail){
    subjectLabel.className = "edlabelcustom";
   	subjectRequired = top.document.createElement("SPAN");
   	subjectRequired.className="required";
	subjectRequired.appendChild(top.document.createTextNode("*"));
	subjectLabel.appendChild(subjectRequired);
    }
    subjectLine.appendChild(subjectLabel);

    objToAddress = top.document.createElement("DIV");
    objToAddress.style.width = "100%";
    objToInput = top.document.createElement("TEXTAREA");
    objToInput.name = "object";
    objToInput.className = "edinput";
    objToAddress.appendChild(objToInput);
    subjectLine.appendChild(objToAddress);

    fromLine = top.document.createElement("DIV");
    fromLine.style.display = "none";
    fromLine.id = "fromline";
    sendBar.appendChild(fromLine);
    fromLabel = top.document.createElement("DIV");
    fromLabel.className = "edlabel";
    
    fromLabel.style.textAlign = (moz) ? "moz-right": "right";
    fromLabelTxt = top.document.createTextNode(_from);
    fromLabel.appendChild(fromLabelTxt);
    if(this.altMail){
    fromLabel.className = "edlabelcustom";
   	fromRequired = top.document.createElement("SPAN");
   	fromRequired.className="required";
	fromRequired.appendChild(top.document.createTextNode("*"));
	fromLabel.appendChild(fromRequired);
    }
    fromLine.appendChild(fromLabel);
    fromAddress = top.document.createElement("DIV");
    fromAddress.style.width = "100%";
    fromInput = top.document.createElement("TEXTAREA");
    fromInput.name = "mailfrom";
    fromInput.className = "edinput";
    fromAddress.appendChild(fromInput);
    fromLine.appendChild(fromAddress);

    warnSenderAdress = top.document.createElement("DIV");
    sendBar.appendChild(warnSenderAdress);

    warn = top.document.createElement("DIV");
    warn.style.display = "none";
    warn.id = "warnsender";
    warn.className = "warnadress";
    warnSenderAdress.appendChild(warn);

    tempTxt = top.document.createElement("INPUT");
    tempTxt.type = "hidden";
    tempTxt.name = "temptxt";
    editbar.appendChild(tempTxt);

    recaptchaDiv = top.document.createElement("DIV");
    recaptchaDiv.id = "recaptchaDiv";
    this.mainBody.appendChild(recaptchaDiv);
    //this.mainBody.appendChild(this.captcha());
    this.mainBody.appendChild(this.saveMailBank());
    this.saveDiv.appendChild(this.sendtoAlert());
}
editor.prototype.callContact = function(event) {
    var event = (ie) ? window.event.srcElement: event.target;
    wa = top.document.getElementById("warnadress");
    if (wa) wa.style.display = "none";

    var start = (ie) ? getCharPos(event) : event.selectionStart;
    var address = (event.value) ? event.value: "";
    var s = 0;
    var e = (address) ? address.length: 0;
    var sTxt = eTxt = "";
    var m = address.match(/\w+[.]?\w*@\w+[.]\w+/g);
    var count = (m) ? m.length: 0;
    if (count > 4) ajCaptcha();
    if (address.indexOf(";") > -1) {
        if (address.indexOf(";", start) > 0) {
            e = address.indexOf(";", start);
            eTxt = address.substring(e, address.length);
        };
        if (address.indexOf(";") > 0) {
            tmpe = address.substring(0, start);
            s = tmpe.lastIndexOf(";") + 1;
            sTxt = address.substring(0, s);
        };
        address = address.substring(s, e);
    } else {
        e = address.length;
    };
    var tmpcontacts = new Array();
    if(top.mycontacts){
		for (i = 0; i < top.mycontacts.length; i++) {
			if (top.mycontacts[i].indexOf(address) == 0) tmpcontacts.addElement(top.mycontacts[i]);
		};
	}
    if(document.getElementById("menucontacts")){this.contactslist=document.getElementById("menucontacts");}
    if (tmpcontacts.length > 0) {
        if (!this.contactslist) {
				this.contactslist = top.document.createElement("DIV");
				this.contactslist.style.position = "absolute";
				this.contactslist.id = "menucontacts";
				this.contactslist.className = "subs";
				this.contactslist.style.textAlign = "left";
				if (window.attachEvent) {
					this.contactslist.attachEvent("onmouseout", closeMenucontacts, false);
				} else if (window.addEventListener) {
					this.contactslist.addEventListener("mouseout", closeMenucontacts, false);
				};
				top.document.body.appendChild(this.contactslist);
				$('#menucontacts').mouseout(function() {
				  closeMenucontacts();
				});
        } else {
            while (this.contactslist.hasChildNodes()) this.contactslist.removeChild(this.contactslist.childNodes[0]);
            this.contactslist.style.display = "";
        };
        this.contactslist.style.top = toolkit.getOffsetCoor(event)[toolkit.coor.Y] + event.offsetHeight - 1 + "px";
        this.contactslist.style.left = toolkit.getOffsetCoor(event)[toolkit.coor.X] + 10 + "px";
        this.contactslist.style.width = event.offsetWidth - 10 + "px";
        for (i = 0; i < tmpcontacts.length; i++) {
            addressline = top.document.createElement("DIV");
            addressline.appendChild(top.document.createTextNode(tmpcontacts[i]));
            addressline.tgt = event;
            eTxt = (eTxt.length > 0) ? eTxt: ";";
            addressline.txtvalue = sTxt + tmpcontacts[i] + eTxt;
            if (window.attachEvent) {
                addressline.attachEvent("onmouseover", stopMenucontactsClosure, false);
            } else if (window.addEventListener) {
                addressline.addEventListener("mouseover", stopMenucontactsClosure, false);
            };
            if (window.attachEvent) {
                addressline.attachEvent("onmouseout", closeMenucontacts, false);
            } else if (window.addEventListener) {
                addressline.addEventListener("mouseout", closeMenucontacts, false);
            };
            if (window.attachEvent) {
                addressline.attachEvent("onclick", fillAddress, false);
            } else if (window.addEventListener) {
                addressline.addEventListener("click", fillAddress, false);
            };
            this.contactslist.appendChild(addressline);
        };
    } else if (this.contactslist) {
        top.document.body.removeChild(this.contactslist);
        this.contactslist = null;
    };

    if (document.addEventListener) document.addEventListener('mousedown', closeMenucontacts, true);
    else document.onmousedown = closeMenucontacts;

}
editor.prototype.makeTextButton = function(btId, name, family, cssClass, title, doClick) {
    buttonLI = top.document.createElement("DIV");
    buttonLI.setAttribute("unselectable", "on");
    buttonLI.className = cssClass;
    if (btId) {
        buttonLI.id = "td" + btId;
    };
    this.buttonA = top.document.createElement("A");
    if (btId) this.buttonA.id = btId;

    this.buttonA.setAttribute("unselectable", "on");
    if (title) {
        this.buttonA.appendChild(top.document.createTextNode(title));
    };
    if (name) {
        this.buttonA.name = name;
    };
    if (family) {
        this.buttonA.family = family;
    };
    if (window.attachEvent) {
        if (doClick) {
            this.buttonA.attachEvent("onclick", this.toggleImg);
        };
    } else if (window.addEventListener) {
        if (doClick) {
            this.buttonA.addEventListener("click", this.toggleImg, true);
        };
    };
    buttonLI.appendChild(this.buttonA);
    return buttonLI;
}
editor.prototype.makeButton = function(btId, name, family, imgSrc, title, doClick) {
    buttonLI = top.document.createElement("DIV");
    buttonLI.setAttribute("unselectable", "on");
    buttonLI.unselectable = "on";
    buttonLI.className = "edbutton";
    if (btId) buttonLI.id = "td" + btId;
    this.buttonImg = top.document.createElement("IMG");
    if (btId) this.buttonImg.id = btId;
    this.buttonImg.src = this.buttonpath + imgSrc;
    if (title) this.buttonImg.title = title;
    this.buttonImg.setAttribute("unselectable", "on");
    this.buttonImg.unselectable = "on";
    if (name) this.buttonImg.name = name;
    if (family) this.buttonImg.family = family;
    if (window.attachEvent) {
        if (doClick && family) this.buttonImg.attachEvent("onclick", this.toggleImg);
    } else if (window.addEventListener) {
        if (doClick && family) this.buttonImg.addEventListener("click", this.toggleImg, true);
    };
    buttonLI.appendChild(this.buttonImg);
    return buttonLI;
}
editor.prototype.saveBank = function() {
    this.saveDiv = top.document.createElement("DIV");
    this.saveDiv.className = "editorlist";
    this.saveDiv.appendChild(this.makeTextButton("edSave", "Save", "action", "modify", _editSave, false));
    this.buttonA.objRef = this.objRef;
    if (window.attachEvent) {
        this.buttonA.attachEvent("onclick", this.checkForm, false);
    } else if (window.addEventListener) {
        this.buttonA.addEventListener("click", this.checkForm, false);
    };
    this.saveDiv.appendChild(this.makeTextButton("edCancel", "Cancel", "action", "modify", _cancel, false));
    this.buttonA.objRef = this.objRef;
    if (window.attachEvent) {
        this.buttonA.attachEvent("onclick", this.exitEditor, false);
    } else if (window.addEventListener) {
        this.buttonA.addEventListener("click", this.exitEditor, false);
    };
    return this.saveDiv;
}
editor.prototype.saveMailBank = function() {
if(this.altMail){
this.saveDiv = top.document.createElement("DIV");
this.saveDiv.style.marginTop = "5px";
mention = top.document.createElement("DIV");
mention.className="mention mention_requiredFields";
mentionSpan = top.document.createElement("SPAN");
mentionSpan.appendChild(top.document.createTextNode("*"));
mention.appendChild(mentionSpan);
mention.appendChild(top.document.createTextNode(" : "+_fillField));
this.saveDiv.appendChild(mention);
fbuttons=top.document.createElement("UL");
fbuttons.className = "formButtons_buttons";
this.saveDiv.appendChild(fbuttons);
liSave=top.document.createElement("LI");
liSave.className = "button left";
fbuttons.appendChild(liSave);
saveInput=top.document.createElement("INPUT");
saveInput.className = "inputButton buttonSubmit";
saveInput.type = "SUBMIT";
saveInput.value=_editSend;
if (window.attachEvent) {
        saveInput.attachEvent("onclick", this.checkMail, false);
    } else if (window.addEventListener) {
        saveInput.addEventListener("click", this.checkMail, false);
    };
liSave.appendChild(saveInput);

liCancel=top.document.createElement("LI");
liCancel.className = "button left";
fbuttons.appendChild(liCancel);
cancelInput=top.document.createElement("INPUT");
cancelInput.className = "inputButton buttonSubmit";
cancelInput.style.marginLeft = "5px";
cancelInput.type = "SUBMIT";
cancelInput.value=_cancel;
if (window.attachEvent) {
        cancelInput.attachEvent("onclick", this.cancelMail, false);
    } else if (window.addEventListener) {
        cancelInput.addEventListener("click", this.cancelMail, false);
    };
liCancel.appendChild(cancelInput);
return this.saveDiv;
}
else{

    this.saveDiv = top.document.createElement("DIV");
    this.saveDiv.style.styleFloat = "none";
    this.saveDiv.className = "editorbottom";
    this.saveDiv.appendChild(this.makeTextButton("edSave", "Save", "action", "modify", _editSend, false));
    this.buttonA.objRef = this.objRef;
    if (window.attachEvent) {
        this.buttonA.attachEvent("onclick", this.checkMail, false);
    } else if (window.addEventListener) {
        this.buttonA.addEventListener("click", this.checkMail, false);
    };
    this.saveDiv.appendChild(this.makeTextButton("edCancel", "Cancel", "action", "modify", _cancel, false));
    this.buttonA.objRef = this.objRef;
    if (window.attachEvent) {
        this.buttonA.attachEvent("onclick", this.cancelMail, false);
    } else if (window.addEventListener) {
        this.buttonA.addEventListener("click", this.cancelMail, false);
    };
    return this.saveDiv;
   }
}
editor.prototype.sendtoAlert = function() {
    alertzone = top.document.createElement("DIV");
    alertzone.className = "editoralert";
    alertzone.id = "editorAlert";
    return alertzone;
}
editor.prototype.justifyBank = function() {
    bankTable = top.document.createElement("DIV");
    bankTable.className = "editorlist";
    bankTable.appendChild(this.makeButton("edLeft", "JustifyLeft", "align", "left.gif", _editLeft, true));
    bankTable.appendChild(this.makeButton("edCenter", "JustifyCenter", "align", "center.gif", _editCenter, true));
    bankTable.appendChild(this.makeButton("edRight", "JustifyRight", "align", "right.gif", _editRight, true));
    bankTable.appendChild(this.makeButton("edJustify", "JustifyFull", "align", "justify.gif", _editJustify, true));
    return bankTable;
}

editor.prototype.linksBank = function() {
    bankTable = top.document.createElement("DIV");
    bankTable.className = "editorlist";
    bankTable.appendChild(this.makeButton("edCreateLink", "CreateLink", "action", "link.gif", _editCreateLink, true));
    return bankTable;
}
editor.prototype.textBank = function() {
    bankTable = top.document.createElement("DIV");
    bankTable.className = "editorlist";
    bankTable.appendChild(this.makeButton("edBold", "Bold", "richtext", "bold.gif", _editBold, true));
    bankTable.appendChild(this.makeButton("edItalic", "Italic", "richtext", "italic.gif", _editItalic, true));
    bankTable.appendChild(this.makeButton("edUnderline", "Underline", "richtext", "underline.gif", _editUnderline, true));
    return bankTable;
}
editor.prototype.setMode = function(event) {
    var tgt = event = (ie) ? window.event.srcElement: event.target;
    top.g_mode = event.switchTo;
    eval("top." + event.obj + ".editBar()");
}
editor.prototype.toggleImg = function(event) {
    var topEditor = event = (ie) ? window.event.srcElement: event.target;
    if (ie) {
        document.execCommand(event.name);
    } else {
        if (event.name == "CreateLink") {
            var myUrl = prompt("URL", ["http://"]);
            if (myUrl == null || myUrl.length < 10) {
                if (editableDocument) editableDocument.execCommand("CreateLink", false);
                else document.execCommand("CreateLink", false);

            } else {
                if (editableDocument) editableDocument.execCommand("CreateLink", false, myUrl);
                else document.execCommand("CreateLink", false, myUrl);
            }

        } else {
            editableDocument.execCommand(event.name, false, null);
        };
    }
    while (topEditor.nodeName != "FORM") {
        topEditor = topEditor.parentNode;
    };
    datas = findInChildren(null, topEditor, "edit", 0);
    if (ie || isSafari) {
        if (datas) {
            datas.focus();
        }
    } else {
        editNode.contentWindow.focus();
    };
    if (event.family != "action") {
        if (event.family == "align") top.resetFamily(event, "align");
        if (event.family == "ulist") top.resetFamily(event, "ulist");
        if (!isSafari) event.parentNode.className = (event.parentNode.className == "edbutton") ? "edactive": "edbutton";
    }
}
editor.prototype.publish = function(frm) {
    f = (frm) ? frm: top.document.forms['publish'];
    if (!ie && !isSafari) {
        startContainer = (editNode.contentWindow.document.getElementById("startContainer")) ? editNode.contentWindow.document.getElementById("startContainer") : editNode.contentWindow.document.body;
    };
    datas = (ie || isSafari) ? findInChildren(null, top.document.body, "edit", 0) : startContainer;
    modDatas(datas, 0);
    if (top.document.getElementById("textedit")) {
        if (ie || khtml || isOpera) {
            top.document.getElementById("textedit").value = (hasText(datas)) ? datas.innerHTML: "";
        } else {
            top.document.getElementById("textedit").innerHTML = (hasText(datas)) ? datas.innerHTML: "";
        }
    };
    if (f) {
        for (i = 0; i < f.elements.length; i++) {
            if (f.elements[i].name == "urls") {
                f.elements[i].value = usedUrls.join('____WIKIO-SEP____');
            }
        }
    };
    top.designMode = false;
    top.edit = false;
}
editor.prototype.bio = function(frm) {
    f = (frm) ? frm: top.document.forms['register'];
    if (!ie && !isSafari) {
        startContainer = (editNode.contentWindow.document.getElementById("startContainer")) ? editNode.contentWindow.document.getElementById("startContainer") : editNode.contentWindow.document.body;
    };
    datas = (ie || isSafari) ? findInChildren(null, top.document.body, "edit", 0) : startContainer;
    modDatas(datas, 0);
    if (top.document.getElementById("textedit")) {
        top.document.getElementById("textedit").value = (hasText(datas)) ? datas.innerHTML: "";
    };
    if (f) {
        for (i = 0; i < f.elements.length; i++) {
            if (f.elements[i].name == "urls") {
                f.elements[i].value = usedUrls.join('____WIKIO-SEP____');
            }
        }
    };
    top.designMode = false;
    top.edit = false;
}
editor.prototype.getText = function() {
    if (!ie && !isSafari) {
        startContainer = (editNode.contentWindow.document.getElementById("startContainer")) ? editNode.contentWindow.document.getElementById("startContainer") : editNode.contentWindow.document.body;
    };
    datas = (ie || isSafari) ? findInChildren(null, top.document.body, "edit", 0) : startContainer;
    tmpTextNode = top.document.createElement("DIV");
    this.vacuum(tmpTextNode, datas, 0);
    return tmpTextNode.innerHTML;
}
editor.prototype.checkForm = function(event) {
    var e = (ie) ? window.event.srcElement: event.target;
    var myform = datas = e;
    while (myform.nodeName != "FORM") {
        myform = myform.parentNode;
    };
    wikiTd = myform.parentNode;
    rstTitle = eval("top." + e.objRef);
    for (i = 0; i < myform.elements.length; i++) {
        if (myform.elements[i].id == "textedit") {
            var dest = myform.elements[i];
        }
        if (myform.elements[i].name == "wikidatas") {
            var dest = myform.elements[i];
        };
        if (myform.elements[i].name == "wikititle") {
            top.tmpWikiTitle = myform.elements[i].value;
        }
    };
    if (!ie && !isSafari) startContainer = (editNode.contentWindow.document.getElementById("startContainer")) ? editNode.contentWindow.document.getElementById("startContainer") : editNode.contentWindow.document.body;
    datas = (ie || isSafari) ? findInChildren(null, myform, "edit", 0) : startContainer;
    modDatas(datas, 0);
    rstTitle = eval("top." + e.objRef);
    if (dest) dest.value = top.tmpWiki = datas.innerHTML;
    myform.submit();
    top.designMode = false;
    while (wikiTd.hasChildNodes()) {
        wikiTd.removeChild(wikiTd.childNodes[0]);
    };
    wikiContent = top.document.createElement("DIV");
    wikiContent.id = "wikitgt";
    wikiContent.innerHTML = top.tmpWiki;
    wikiTd.appendChild(wikiContent);
}
editor.prototype.checkMail = function(event) {
    var e = (ie) ? window.event.srcElement: event.target;
    var subj = null;
    var tTxt = "";
    var send = true;
    checkAlert = "";
    var myform = datas = e;
    closeContact();
    while (myform.nodeName != "FORM") {
        myform = myform.parentNode;
    };
    wikiTd = myform.parentNode;
    rstTitle = eval("top." + e.objRef);
    for (i = 0; i < myform.elements.length; i++) {
        if (myform.elements[i].name == "temptxt") {
            tTxt = myform.elements[i];
        };
        if (myform.elements[i].name == "wikidatas") {
            var dest = myform.elements[i];
        };
        if (myform.elements[i].name == "object") {
            if (myform.elements[i].value.length == 0) {
                send = false;
                //checkAlert+=_fillsubject;
                if (top.confirm(_wanttofillsubject)) {
                    myform.elements[i].value = _noSubject;
                    top.WIKI.checkMail(event);
                } else {
                    myform.elements[i].focus();
                }
            } else {
                subj = myform.elements[i];
            };
        };
    };
    if (checkAlert.length == 0) {
        if (!ie && !isSafari) startContainer = (editNode.contentWindow.document.getElementById("startContainer")) ? editNode.contentWindow.document.getElementById("startContainer") : editNode.contentWindow.document.body;
        datas = (ie || isSafari) ? findInChildren(null, myform, "edit", 0) : startContainer;
        modMailDatas(datas, 0);
        if (dest) dest.value = datas.innerHTML;
    } else {
        alert(checkAlert);
    };
    if (send) {
        myform.submit();
        if ('function' == typeof myform.afterSubmit) {
            myform.afterSubmit();
        };
    };
}
editor.prototype.exitEditor = function(event) {
    var event = (ie) ? window.event.srcElement: event.target;
    var myform = datas = event;
    while (myform.nodeName != "FORM") {
        myform = myform.parentNode;
    };
    wikiTd = myform.parentNode;
    while (wikiTd.hasChildNodes()) wikiTd.removeChild(wikiTd.childNodes[0]);
    wikiContent = top.document.createElement("DIV");
    wikiContent.id = "wikitgt";
    wikiContent.innerHTML = top.tmpWiki;
    wikiTd.appendChild(wikiContent);
    top.designMode = false;
    top.edit = false;
    top.tmpWiki = top.tmpWikiTitle = null;
}
editor.prototype.cancelMail = function(event) {
    var event = (ie) ? window.event.srcElement: event.target;
    var myform = datas = event;
    while (myform.nodeName != "FORM") {
        myform = myform.parentNode;
    };
    wikiTd = myform.parentNode;
    wikiTd.removeChild(myform);
    top.designMode = false;
    top.edit = false;
    top.tmpWiki = top.tmpWikiTitle = null;
    closeContact();
    if(top.Recaptcha) top.Recaptcha.reload();
}
editor.prototype.exitFromDoc = function() {
    wikiReceiver = top.document.getElementById("wiki");
    if (wikiReceiver) {
        while (wikiReceiver.hasChildNodes()) {
            wikiReceiver.removeChild(wikiReceiver.childNodes[0]);
        };
        wikiContent = top.document.createElement("DIV");
        wikiContent.id = "wikitgt";
        wikiContent.className = "wikitgt";
        wikiContent.innerHTML = top.tmpWiki;
        wikiReceiver.appendChild(wikiContent);
    }
    top.designMode = false;
    top.edit = false;
}
editor.prototype.closeWiki = function() {
    wiki = top.document.getElementById("wikiform");
    if (wiki && wiki.parentNode) {
        closeContact();
        closeEditorMenu();
        wiki.parentNode.removeChild(wiki);
    }
    top.designMode = false;
    top.edit = false
}
editor.prototype.vacuum = function(parentNode, node, id) {
    var k = id + '_';
    if (node && node.nodeType == 1 && node.hasChildNodes()) {
        for (var k = 0; k < node.childNodes.length; k++) this.vacuum(parentNode, node.childNodes[k], k);
    } else {
        parentNode.appendChild(top.document.createTextNode(node.nodeValue));
    }
}
editor.prototype.toggleSelect = function(event) {
    var event = (ie) ? window.event.srcElement: event.target;
    if (ie || isSafari) {
        document.execCommand(event.name, false, event.options[event.selectedIndex].value);
    } else {
        editableDocument.execCommand(event.name, false, event.options[event.selectedIndex].value);
    }
}
editor.prototype.toggleValue = function(event) {
    var event = (ie) ? window.event.srcElement: event.target;
    if (ie || isSafari) {
        document.execCommand(event.name, false, event.value);
    } else {
        editableDocument.execCommand(event.name, false, event.value);
    }
}
editor.prototype.overWrite = function(event) {
    var event = (ie) ? window.event.srcElement: event.target;
    if (ie || isSafari) {
        document.execCommand(event.name);
    } else {
        editableDocument.execCommand(event.name, false, null);
    };
    event.className = (event.className == "edswitch1") ? "edswitch0": "edswitch1";
    if (ie || isSafari) {
        event.tgt.focus();
    } else {
        editNode.contentWindow.focus();
    };
}
editor.prototype.insertImage = function(event, newItem) {
    var event = (ie) ? window.event.srcElement: event.target;
    if (ie || isSafari) {
        document.execCommand("InsertImage", newItem, event.src);
    } else {
        editableDocument.execCommand("InsertImage", newItem, event.src);
    };
    if ((ie || isSafari) && event.tgt) {
        event.tgt.focus();
    } else {
        editNode.contentWindow.focus();
    }
}
editor.prototype.getEditorAttributes = function(event) {
    var topEditor = event = (ie) ? window.event.srcElement: event.target;
    try {
        if (top.aText) {
            top.setCssName("txtzone", "");
            top.aText = false;
        }
        while (topEditor.nodeName != "FORM") {
            topEditor = topEditor.parentNode;
        };
        EM = STRONG = U = align = null;
        if (ie) {
            var cRange = document.selection.createRange();
            var para = sel = cRange.parentElement();
        } else if (isOpera || isSafari) {
            var cRange = window.getSelection().getRangeAt(0);
            var para = sel = cRange.parentElement();
        };
        while (para.nodeName != "P" && para.nodeName != "DIV") {
            para = para.parentNode;
        };
        if (para.getAttribute("ALIGN")) {
            align = para.getAttribute("ALIGN");
        };
        top.resetFamily(top.editorMenu, "align");
        while ((sel.nodeName != "P" && sel.nodeName != "DIV") && (sel.parentNode && (sel.parentNode.nodeName != "p" && sel.parentNode.nodeName != "DIV"))) {
            if (sel.getAttribute("ALIGN")) {
                align = sel.getAttribute("ALIGN");
            };
            if (sel.nodeName == "EM") {
                EM = true;
            };
            if (sel.nodeName == "STRONG") {
                STRONG = true;
            };
            if (sel.nodeName == "U") {
                U = true;
            };
            sel = sel.parentNode;
        };
        if (align) {
            switch (align) {
            case "left":
                findInChildren(null, topEditor, "JustifyLeft", 0).parentNode.className = "edactive";
                break;
            case "center":
                findInChildren(null, topEditor, "JustifyCenter", 0).parentNode.className = "edactive";
                break;
            case "right":
                findInChildren(null, topEditor, "JustifyRight", 0).parentNode.className = "edactive";
                break;
            case "justify":
                findInChildren(null, topEditor, "JustifyFull", 0).parentNode.className = "edactive";
                break;
            }
        };
        top.frmCtrl = false;
    } catch(e) {
        return false;
    }
}
function closeWiki(confirm){if(top.WIKI){top.WIKI.closeWiki();}}
function closeEditorTimeOut(event) {
    closeEditor = window.setTimeout("closeEditorMenu()", 500);
}
function stopEditorClosure(event) {
    window.clearTimeout(closeEditor);
    closeEditor = null;
}
function closeEditorMenu(event) {
    if (openedEditorWindow) t.body.removeChild(openedEditorWindow);
    openedEditorWindow = null;
}
function closeMenucontacts(event) {
    if (!closeMenuContacts) closeMenuContacts = window.setTimeout("closeContact()", 500);
}
function stopMenucontactsClosure(event) {
    if (closeMenuContacts) window.clearTimeout(closeMenuContacts);
    closeMenuContacts = null;
}
function closeContact() {
   $("#menucontacts").hide();
}
function fillAddress(event) {
    var event = (ie) ? window.event.srcElement: event.target;
    event.tgt.value = event.txtvalue;
    event.tgt.focus();
}
function getCharPos(event) {
    event.focus();
    var range = event.createTextRange();
    range.moveToBookmark(document.selection.createRange().getBookmark());
    range.moveEnd('character', event.value.length);
    return event.value.length - range.text.length;
}
function modDatas(fromNode, id, authtype) {
    var k = id + '_';
    for (k = 0; k < fromNode.childNodes.length; k++) {
        n = fromNode.childNodes[k];
        nName = n.nodeName.toLowerCase();
        if (n.nodeType == 1) {

            for (var attName = 0; attName < n.attributes.length; attName++) {
                if (n.attributes[attName].specified && RemAtt.contains(n.attributes[attName].nodeName.toLowerCase())) {
                    n.removeAttribute(n.attributes[attName].nodeName);
                } else if (n.attributes[attName].specified && n.attributes[attName].nodeName.toLowerCase() == "href" && n.nodeName.toLowerCase() == "a") {
                    if (n.attributes[attName].specified && n.attributes[attName].value.indexOf("javascript:") < 0) {
                        if (!usedUrls.contains(trim(n.attributes[attName].value))) {
                            usedUrls.addElement(trim(n.attributes[attName].value));
                        }
                    } else {
                        n.removeAttribute(n.attributes[attName].nodeName);
                    }
                } else if (n.attributes[attName].specified && n.attributes[attName].nodeName.toLowerCase() == "style") {
                    var bBold = n.style.fontWeight == "bold";
                    var bItalic = n.style.fontStyle == "italic";
                    var bUnderline = n.style.textDecoration == "underline";
                    n.removeAttribute(n.attributes[attName].nodeName);
                    if (bBold) n.style.fontWeight = "bold";
                    if (bItalic) n.style.fontStyle = "italic";
                    if (bUnderline) n.style.textDecoration = "underline";
                }
            }
            if (nName == "img" && (n.width < 50 || n.height < 50)) n.parentNode.removeChild(n);
        };
        if (fbid.contains(nName)) {
            n.parentNode.removeChild(n);
        };
        if (n.href && n.href.substring(0, _editSelfUrl.length) != _editSelfUrl) {
            n.setAttribute("target", "_blank");
            n.setAttribute("rel", "nofollow");
        };
        if (n.href) {
            try {
                n.href = trim(n.href)
            } catch(e) {}
        };
        if (n.nodeType == 7 || (n.nodeType == 8 && (!authtype || authtype != 8))) {
            n.parentNode.removeChild(n);
        };
        if (n.childNodes.length > 0) {
            modDatas(n, k);
        };
    }
}
function modMailDatas(fromNode, id, authtype) {
    var k = id + '_';
    for (k = 0; k < fromNode.childNodes.length; k++) {
        n = fromNode.childNodes[k];
        nName = n.nodeName.toLowerCase();

        if (n.nodeType == 1) {
            for (var attName = 0; attName < n.attributes.length; attName++) {
                att = n.attributes[attName];
                if (att.specified && RemAtt.contains(att.nodeName.toLowerCase())) {
                    if (att.nodeName != "id") n.removeAttribute(att.nodeName);
                };
            }
        };
        if (n.style && n.style.position) {
            n.style.position = "fixed";
        };
        if (nName.indexOf("script") >= 0 || nName.indexOf("frame") >= 0) {
            n.parentNode.removeChild(n);
        };
        if (n.href && n.href.substring(0, _editSelfUrl.length) != _editSelfUrl) {
            n.setAttribute("target", "_blank");
        };
        if (n.nodeType == 7 || (n.nodeType == 8 && (!authtype || authtype != 8))) {
            n.parentNode.removeChild(n);
        };
        if (n.childNodes.length > 0) {
            modMailDatas(n, k);
        };
    }
}
function iframeAttributes(event) {
    var event = event.target;
    try {
        if (top.aText) {
            top.setCssName("txtzone", "");
            top.aText = false;
        }
        var EM = STRONG = U = align = null;
        while (event.nodeName != "BODY") {
            if (!align && event && event.style && event.style.textAlign) align = event.style.textAlign;
            if (!STRONG && event && ((event.style && event.style.fontWeight == "bold") || event.nodeName == "STRONG" || event.nodeName == "B")) STRONG = true;
            if (!U && event && ((event.style && event.style.textDecoration.toLowerCase().indexOf("underline") >= 0) || event.nodeName == "U")) U = true;
            if (!EM && event && ((event.style && event.style.fontStyle.toLowerCase().indexOf("italic") >= 0) || event.nodeName == "I")) EM = true;
            event = event.parentNode;
        }
        if (findInChildren(event, top.editorMenu, "tdedBold", 0)) findInChildren(event, top.editorMenu, "tdedBold", 0).className = (STRONG) ? "edactive": "edbutton";
        if (findInChildren(event, top.editorMenu, "tdedItalic", 0)) findInChildren(event, top.editorMenu, "tdedItalic", 0).className = (EM) ? "edactive": "edbutton";
        if (findInChildren(event, top.editorMenu, "tdedUnderline", 0)) findInChildren(event, top.editorMenu, "tdedUnderline", 0).className = (U) ? "edactive": "edbutton";
        if (findInChildren(event, top.editorMenu, "tdedLeft", 0)) findInChildren(event, top.editorMenu, "tdedLeft", 0).className = (align && align == "left") ? "edactive": "edbutton";
        if (findInChildren(event, top.editorMenu, "tdedCenter", 0)) findInChildren(event, top.editorMenu, "tdedCenter", 0).className = (align && align == "center") ? "edactive": "edbutton";
        if (findInChildren(event, top.editorMenu, "tdedRight", 0)) findInChildren(event, top.editorMenu, "tdedRight", 0).className = (align && align == "right") ? "edactive": "edbutton";
        if (findInChildren(event, top.editorMenu, "tdedJustify", 0)) findInChildren(event, top.editorMenu, "tdedJustify", 0).className = (align && align == "justify") ? "edactive": "edbutton";
        top.frmCtrl = false;
    } catch(e) {}
}
