<?php include("../includes/connection.php"); ?>
<?php include("includes/header.php");
include("../includes/func.php");?>
<?php if (empty($_SESSION["admin"])) redirect("index.php?e=1"); ?>
<?php
if (!empty($_POST["Save"])) 
{
	if ($HTTP_GET_VARS[doc_id] !='')
	{
		$sql="update document_master set doc_title='". $_POST["title"] ."',doc_content='". pdbfx("finaltxt")."' where id=". $HTTP_GET_VARS[doc_id] ."";
	
		mysql_query($sql);
	}
	else
	{
		$sql="Insert into document_master(doc_content,doc_title) values('". $_POST["finaltxt"] ."','". $_POST["title"] ."')";
		mysql_query($sql);
	}
}
?>
<?php
		if ($HTTP_GET_VARS[doc_id] !='')
	{
		$sql="select * from document_master where id=". $HTTP_GET_VARS[doc_id] ."";
		$cmd = mysql_query($sql);
		$rs = mysql_fetch_array($cmd);
	}
		
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<SCRIPT language=JavaScript src="include/yusasp_ace.js"></SCRIPT>
<SCRIPT language=JavaScript src="include/yusasp_color.js"></SCRIPT>

</head>

<body>
<!a href="javascript:" onClick="openWin('WYS/demo.php?doc_id=<?php echo $HTTP_GET_VARS[doc_id]; ?>', 'width=695, height=475');" class="BlackAri12B">
<br>
<font size=1>Press CTRL A if you can't see the text</font>
<br>
<!-- <form name="frm" method=post onsubmit="javascript: assignvalue();"> -->
<form name="frm" method=post action="editdoc.php?doc_id=<?php echo $HTTP_GET_VARS[doc_id]; ?>" onsubmit="javascript: assignvalue();">
<?php 
	echo "<font face=arial size=2>You are editing :<strong>".$rs[1]."<br></strong></font><br><br>"; 
?>
<?if ($HTTP_GET_VARS[doc_id] !='1')
	{?>
<font class=BlackAri12>Name Of Document : </font><input type=text size=40 name=title value="<?=$rs[1]?>">
<?}?>
<SCRIPT>
	var ArticleObj = new ACEditor("ArticleObj")
	ArticleObj.width = "100%"
	ArticleObj.height = 400
	ArticleObj.useStyle = false
	ArticleObj.useAsset = false
	ArticleObj.useImage = true
	ArticleObj.usePageProperties = false
	ArticleObj.isFullHTML = false;
	ArticleObj.RUN()
</SCRIPT>
<table border=0 cellspacing=0 cellpadding=0 valign=top align=center>
<DIV style="VISIBILITY: hidden"><TEXTAREA name=txt rows=5 cols=10>
<?php 
	echo $rs[2]; 
?>
</TEXTAREA></DIV></TD></TR>
<input type="hidden" name="finaltxt" value="">

<tr><td align=middle><input name="Save" type="submit" value="Save"><br>
<font face=arial size=1>(Don't Save in HTML View)<font></td></tr>
</table>
</form>
</body>
</html>
<SCRIPT language=javascript>

	ArticleObj.putContent(document.frm.txt.value);

</SCRIPT>
<script>
	function assignvalue()
	{
		//alert (ArticleObj.getContentBody());
		document.frm.finaltxt.value = ArticleObj.getContentBody();
		//document.frmArticle.txtArticleText.value = ArticleTextObj.getContentBody();		
	}
</script>
<?php include("includes/footer.php"); ?>

