<?php

/**
 * GrenSladaWritezor Edit page.
 *
 * @license    GNU General Public License Version 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Stanford Ng <stng@theculprit.com>
 */
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
    <title>GrenSladaWritezor :: Edit Page</title>
		<script type="text/javascript" src="./fckeditor/fckeditor.js"></script>
<script language="JavaScript">
<!--

    function saveAndClose(s) {
        
        sText = opener.document.getElementById("wiki__text").value;
        tagStart = sText.indexOf("<EMBEDDED_HTML>");
        if(tagStart==-1) {
            // --- No existing tag, just insert at the current cursor. ---
            opener.insertTags('wiki__text', '<EMBEDDED_HTML>'+s+'</EMBEDDED_HTML>','','');
        } else {
            // --- Replace first EMBEDDED_HTML tag. ---
            leftText = sText.substring(0, tagStart);
            rightText = "";
            tagEnd = sText.indexOf("</EMBEDDED_HTML>");
            if(tagEnd > -1) {
                rightText = sText.substring(tagEnd+"</EMBEDDED_HTML>".length);
            }
            opener.document.getElementById("wiki__text").value = leftText + '<EMBEDDED_HTML>' + s + '</EMBEDDED_HTML>' + rightText;
        }
        close();
    }
    
//-->
</script>
</head>
<body>
    <h2>GrenSladaWritezor :: Edit</h2>
    <script type="text/javascript">
<!--

var oFCKeditor = new FCKeditor( 'GrenText' ) ;
oFCKeditor.Config['CustomConfigurationsPath'] = '../../gren_toolbar_config.js' ;
oFCKeditor.BasePath = './fckeditor/';
oFCKeditor.ToolbarSet = 'GrenToolbar';
sText = opener.document.getElementById("wiki__text").value;
tagStart = sText.indexOf("<EMBEDDED_HTML>");
if(tagStart>-1) {
    tagStart = tagStart + "<EMBEDDED_HTML>".length;
    tagEnd = sText.indexOf("</EMBEDDED_HTML>");
    if(tagEnd == -1) {
        sText = sText.substring(tagStart);
    } else {
        sText = sText.substring(tagStart,tagEnd);
    }
}
oFCKeditor.Value		= sText;
oFCKeditor.Height = "70%";
oFCKeditor.Create() ;
//-->
    </script>
    <a href="javascript:saveAndClose(FCKeditorAPI.GetInstance('GrenText').GetHTML());">Save</a>
	</form>
    <br>
</body>
</html>
