	

	/*
		Dijlh WYSIWYG Editor v1.0
			Copyright Dijlh(c) 2007-2009 by Ahmed Kh. Zamil (ahmed_baghdad@yahoo.com)
	*/

	function createEditor(idNo)
	{
		var ht = '				<table border="1" width="100%" height="100%" id="table13" style="border-width: 0px">\n';
		ht += '					<tr>\n';
		ht += '						<td height="20px" style="border-style: none; border-width: medium">\n';
		ht += '						<table border="1" width="100%" id="table14" style="border-width: 0px">\n';
		ht += '							<tr>\n';
		ht += '								<td width="25" style="border-style: none; border-width: medium">\n';
		ht += '								<select id="SFont" onChange="exCmd(this, \'fontName\',this[this.selectedIndex].value); this.selectedIndex=0" style="font-family: Tahoma; font-size: 10pt; font-weight: bold; color: #6699FF; border: 2px solid #6699FF; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px" name="D1">\n';
		ht += '								<option value="">Font\n';
		ht += '			                     <option value="Arial, Helvetica">Arial\n';
		ht += '			                     <option value="Verdana, Arial, Helvetica">Verdana\n';
		ht += '			                     <option value="Times New Roman, Times, Serif">Times\n';
		ht += '			                     <option value="Tahoma">Tahoma\n';
		ht += '			                     <option value="Comic Sans MS">Comic\n';
		ht += '			                     <option value="MS Sans Serif, sans-serif">Sans-Serif\n';
		ht += '				                 <option value="Courier New, Courier, Monospace">Courier\n';
		ht += '             	   				 <option value="Trebuchet MS, Arial, Helvetica">Trebuchet\n';
		ht += '								</select></td>\n';
		ht += '								<td width="25" style="border-style: none; border-width: medium">\n';
		ht += '								<select id="SSize" onChange="exCmd(this, \'fontSize\',this[this.selectedIndex].value); this.selectedIndex=0" style="font-family: Tahoma; font-size: 10pt; font-weight: bold; color: #6699FF; border: 2px solid #6699FF; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px" name="D2">\n';
		ht += '   								<option value="">Size\n';
		ht += '			                     <option value="1">1\n';
		ht += '			                     <option value="2">2\n';
		ht += '			                     <option value="3">3\n';
		ht += '			                     <option value="4">4\n';
		ht += '			                     <option value="5">5\n';
		ht += '			                     <option value="6">6\n';
		ht += '			                     <option value="7">7\n';
		ht += '								</select></td>\n';
		ht += '								<td width="25" style="border-style: none; border-width: medium">\n';
		ht += '								<img class="smile" onclick="exCmd(this, \'Bold\', true)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/bold.gif"></td>\n';
		ht += '								<td style="border-style: none; border-width: medium" width="25">\n';
		ht += '								<img class="smile" onclick="exCmd(this, \'Underline\', true)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/underline.gif"></td>\n';
		ht += '								<td style="border-style: none; border-width: medium" width="25">\n';
		ht += '								<img class="smile" onclick="exCmd(this, \'Italic\', true)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/italic.gif"></td>\n';
		ht += '								<!-- <td style="border-style: none; border-width: medium" width="25">\n';
		ht += '								<img class="smile" onclick="showDlg(this, \'FSmiles\', event)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/smiles.gif"></td>\n';
		ht += '								-->\n';
		ht += '								<td style="border-style: none; border-width: medium" width="25">\n';
		ht += '								<img class="smile" onclick="showDlg(this, \'FColors\', event)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/font.gif"></td>\n';
		ht += '								<td style="border-style: none; border-width: medium" width="25">\n';
		ht += '								<img class="smile" onclick="exCmd(this, \'JustifyLeft\')" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/left_just.gif" width="25" height="24"></td>\n';
		ht += '								<td style="border-style: none; border-width: medium" width="25">\n';
		ht += '								<img class="smile" onclick="exCmd(this, \'JustifyCenter\')" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/centre.gif" width="25" height="24"></td>\n';
		ht += '								<td style="border-style: none; border-width: medium" width="25">\n';
		ht += '								<img class="smile" onclick="exCmd(this, \'JustifyRight\')" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/right_just.gif" width="25" height="24"></td>\n';
		ht += '								<td style="border-style: none; border-width: medium" width="25">\n';
		ht += '								<img class="smile" onclick="exCmd(this, \'indent\')" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/indent.gif" width="25" height="24"></td>\n';
		ht += '								<td style="border-style: none; border-width: medium" width="25">\n';
		ht += '								<img class="smile" onclick="exCmd(this, \'outdent\')" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/outdent.gif" width="25" height="24"></td>\n';
		
		ht += '								<td style="border-style: none; border-width: medium" width="25">\n';
		ht += '								<img class="smile" onclick="exCmd(this, \'createlink\')" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/hyperlink.png" width="25" height="24"></td>\n';
		
		ht += '								<td style="border-style: none; border-width: medium" width="25">\n';
		ht += '								<img class="smile" onclick="showDlg(this, \'FUpload\', event)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/upload.gif" width="25" height="24"></td>\n';
		ht += '								<td style="border-style: none; border-width: medium">\n';
			ht += '<iframe id="iUpload' + idNo + '" name="iUpload' + idNo + '" style="visibility: hidden; width: 1px; height: 1px; display: none"></iframe>\n';
		ht += '								</td>\n';
		ht += '							</tr>\n';
		ht += '						</table>\n';
		ht += '						</td>\n';
		ht += '					</tr>\n';
		ht += '					<tr>\n';
		ht += '						<td valign="top" style="border-style: none; border-width: medium">\n';
		ht += '							<table border="1" height="100%" width="100%" id="table15" style="border-width: 0px">\n';
		ht += '							<tr>\n';
		ht += '								<td style="border-style: none; border-width: medium">\n';
		ht += '										<iframe id="iEditor' + idNo + '" name="I1" width="100%" height="99%" style="border:1px dotted #3399FF; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px" border="0" frameborder="0">\n';
		ht += '										Your browser does not support inline frames or is currently configured not to display inline frames.\n';
		ht += '								</iframe></td>\n';
		ht += '							</tr>\n';
		ht += '							<tr>\n';
		ht += '								<td height="20px" style="border-style: none; border-width: medium">\n';
//		<!-- <input onclick="preview(this)" type="button"  value="Preview"> -->
//		ht += '										<input type="submit" value="Submit" class="deditor"> <input onclick="clearContent(this)" type="button" value="Clear" class="deditor"></td>\n';
		ht += '							</tr>\n';
		ht += '						</table>\n';
		
			ht += '<div id="FUpload" class="dialog" style="padding:1px; border:1px solid #F8F8F8; position: absolute; left: 0px; top: 0px; width:218px; background-color:#7DBEFF; height:61px; visibility: hidden" >\n';
		ht += '<table width="100%" cellspacing="0" cellpadding="0">\n';
		ht += '		<tr>\n';
		ht += '			<td><b><font face="Tahoma" size="2" color="#FFFFFF">Select filename:\n';
		ht += '			</font></b>\n';
		ht += '			</td>\n';
		ht += '		</tr>\n';
		ht += '		<tr>\n';
		ht += '			<td width="10">\n';
		ht += '					<form id="upload_form" action="dupload.php" target="iUpload' + idNo + '" method="POST" enctype="multipart/form-data" style="margin-top: 0; margin-bottom: 0">\n';
		ht += '					<input size=25 type="file" name="file" id="upload_field" onChange="doUpload(this)" class="deditor"></form>\n';
		ht += '			</td>\n';
		ht += '		</tr>\n';
		ht += '		<tr>\n';
		ht += '		<td>\n';
		ht += '							<b><font face="Tahoma" size="1" color="#F8F8F8">\n';
		ht += '							JPG, JPEG, GIF, PNG, WM, WMV, WMA, ASF, RM, RA, \n';
		ht += '							RV, RAM, MP3, MPG, MPEG</font></b></td>\n';
		ht += '		</tr>\n';
		ht += '	</table>\n'; 		
		ht += '	<table width="100%" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">\n';
		ht += '	<tr>\n';
		ht += '	<td>\n';
		ht += '	<img id="upload_img" style="visibility: hidden" border="0" src="deditor/indicator.gif" width="16" height="16">\n';
		ht += '	<b><font id="upload_status" size="1" face="Tahoma" color="#7DBEFF">\n';
		ht += '	 No file selected</font></b></td>\n';
		ht += '	</tr>\n';
		ht += '	</table>\n';
		ht += '</div>\n';
		
		
		ht += '<div id="FSmiles" class="dialog" style="position: absolute; left: 0px; top: -300px; visibility: hidden">\n';
/*			ht += '<table width="102" height="102" id="table16" cellpadding="0" bordercolor="#C0C0C0" cellspacing="0" style="border-collapse: collapse" border="1">\n';
		ht += '	<tr>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/1.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/2.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/3.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/4.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/5.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/6.gif" width="17" height="17"></td>\n';
		ht += '	</tr>\n';
		ht += '	<tr>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/7.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/8.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/9.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/10.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/11.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/12.gif" width="17" height="17"></td>\n';
		ht += '	</tr>\n';
		ht += '	<tr>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/13.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/14.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/15.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="1" src="deditor/16.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/17.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/18.gif" width="17" height="17"></td>\n';
		ht += '	</tr>\n';
		ht += '	<tr>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/19.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/20.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/21.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/22.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/23.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/24.gif" width="17" height="17"></td>\n';
		ht += '	</tr>\n';
		ht += '	<tr>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/25.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/26.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/27.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/28.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/29.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/30.gif" width="17" height="17"></td>\n';
		ht += '	</tr>\n';
		ht += '	<tr>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/31.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/32.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/33.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/34.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/35.gif" width="17" height="17"></td>\n';
		ht += '		<td>\n';
		ht += '		<img class="smile" onclick="insertImg(this, this.src)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'smile\'" border="0" src="deditor/36.gif" width="17" height="17"></td>\n';
		ht += '	</tr>\n';
		ht += '</table>\n';
		*/
		ht += '</div>\n';
		
		

		
		ht += '<div id="FColors" class="dialog" style="position: absolute; left: 0px; top: -300px; visibility: hidden" >\n';
			ht += '<table width="102" height="102" id="table17" cellpadding="0" bordercolor="#C0C0C0" cellspacing="0" style="border-collapse: collapse" border="1">\n';
		ht += '	<tr>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#336699"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#3366CC"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#003399"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#0000CC"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#000066"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#333399"><img src="deditor/trans.gif"></td>\n';
		ht += '	</tr>\n';
		ht += '	<tr>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#006666"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#009999"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#33CCCC"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#00CCFF"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#0066FF"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#3333CC"><img src="deditor/trans.gif"></td>\n';
		ht += '	</tr>\n';
		ht += '	<tr>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#00CC66"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#00FF00"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#CCCCFF"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#9999FF"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#9966FF"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#CC00FF"><img src="deditor/trans.gif"></td>	\n';
		ht += '	</tr>\n';
		ht += '	<tr>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#99FF66"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#FFFFCC"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#FF99CC"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#FF66CC"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#FF3399"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#660066"><img src="deditor/trans.gif"></td>\n';
		ht += '	</tr>\n';
		ht += '	<tr>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#FFFF66"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#FF9966"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#FF9933"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#FF5050"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#CC0066"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#660033"><img src="deditor/trans.gif"></td>\n';
		ht += '	</tr>\n';
		ht += '	<tr>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#FFCC00"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#CC3300"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#CC6600"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#FF3300"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#800000"><img src="deditor/trans.gif"></td>\n';
		ht += '			<td class="color" onclick="exCmd(this, \'foreColor\',this.bgColor)" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'color\'" width="17" height="17" bgcolor="#000000">	<img src="deditor/trans.gif"></td>\n';
		ht += '	</tr>\n';
		ht += '</table>\n';
		ht += '</div>\n';
		
		ht += '						</td>\n';
		ht += '					</tr>\n';
		ht += '				</table>\n';
	
		var el = document.createElement("div");
		el.id = "dEditor" + idNo;
		el.dir="ltr";
		el.style.width = "100%";
		el.style.height = "400px";
		el.innerHTML = ht;
	
		return el;
	}

	var skiphide = false;
	var myPath = window.location.toString().substr(0,window.location.toString().lastIndexOf("/")).toLowerCase();
	var tid = 0;	
	var editors = new Array();
	
	function initializeDEditor()
	{
	
		var cont = "<html><head><style>p { margin-top: 0; margin-bottom: 0 }</style></head><body style=\"margin-top: 3; margin-bottom: 0; margin-left=0\"></body></html>"
		var tAreas = document.getElementsByTagName("textarea");
		for (var i = 0; i < tAreas.length; i++)
		{
			
			tAreas[i].style.width = "1px";
			tAreas[i].style.height = "1px";
			tAreas[i].style.visibility = "hidden";
			
			var pIndex = editors.length;
			var el = createEditor(pIndex);
			
			editors[pIndex] = tAreas[i];
			tAreas[i].parentNode.insertBefore(el, tAreas[i]);
			var nFrame;
			
			if (window.frames.item)
				nFrame = window.frames.item("iEditor" + pIndex);
				//nFrame = window.frames["iEditor" + pIndex];
			else
				nFrame = document.getElementById("iEditor" + pIndex).contentWindow;
			
			nFrame.document.designMode = "on";
			nFrame.document.write(cont);
			nFrame.document.body.innerHTML = getSafeHTML(editors[i].value);
			nFrame.document.onclick = hidedlgs;
			nFrame.document.onmouseup = refreshContent;
	
			nFrame.document.body.onpaste = delayRefresh;
			nFrame.document.body.oncut = delayRefresh;
			nFrame.document.body.ondrop = delayRefresh;
			nFrame.document.body.ondrag = refreshContent;
			nFrame.document.onkeypress = refreshContent;
			nFrame.document.onkeydown = refreshContent;
			nFrame.document.onkeyup = refreshContent;
			nFrame.document.body.ondragover = refreshContent;
			nFrame.document.body.ondragend = delayRefresh;
		}
		
		if(window.addEventListener){ // Mozilla, Netscape, Firefox
			document.addEventListener('click', hidedlgs, false);
		} else { // IE
			document.attachEvent("onclick", hidedlgs);
		}

		hidedlgs();
	}
	
	function delayRefresh()
	{
		setTimeout(refreshContent, 100);
	}
	
	function refreshContent()
	{
		for (var i = 0; i < editors.length; i++)
		{
			editors[i].value = getContent(i);
		}
	}
	
	function searchForElement(obj, id)
	{
		for (var i = 0; i < obj.childNodes.length; i++)
		{			
			if (obj.childNodes.item(i).id)
			{
				if (obj.childNodes.item(i).id.indexOf(id) != -1)
				{
					return obj.childNodes.item(i);
				}
				else
				{
					var rt = searchForElement(obj.childNodes.item(i), id);
					if (rt != null)
						return rt;
				}
			} else
			{
					var rt = searchForElement(obj.childNodes.item(i), id);
					if (rt != null)
						return rt;			
			}
		}
	}
	
	function clearContent(obj)
	{
		var pid = getContainerId(obj);
		if (window.frames.item)
			window.frames.item("iEditor" + pid).document.body.innerHTML = "";
		else
			document.getElementById("iEditor" + pid).contentWindow.document.body.innerHTML = "";
		editors[pid].value = "";
		if (editors[pid].form != null)
			editors[pid].form.reset();
	}
	
	function getContainerId(obj)
	{
		var p = obj.parentNode;
		
		while (p != null)
		{
			if (p.id.substr(0,7) == "dEditor")
			{
				//alert(p.id.substr(7));
				return parseInt(p.id.substr(7));
			}
			p = p.parentNode;
		}
	}

	function getContainerElement(obj)
	{
		var p = obj.parentNode;
	
		while (p != null)
		{
			if (p.id.substr(0,7) == "dEditor")
			{
				return p;
			}
			p = p.parentNode;
		}
	}
		
	function preview()
	{
		window.open("source_preview.htm", "DPreview");
	}
	
	function exCmd(by, command, value)
	{
        if ((command == 'foreSize' || command == 'fontName') && value == '')
        	return;

		var p;
		if (window.frames.item)
			p = window.frames.item("iEditor" + getContainerId(by));
		else
			p = document.getElementById("iEditor" + getContainerId(by)).contentWindow;

		p.focus();
        
		if (p.document.selection)
		{
			var s = p.document.selection.createRange();
			s.execCommand (command, false, value);
  
		}
		else
		{
			if (command == 'createlink')
				value = prompt("Enter page URL", "http://");
			
			p.document.execCommand (command, false, value);
		}
  		refreshContent();
	}
	
	function insertImg(by, src)
	{
	
		var p;
		
		if (window.frames.item)
			p = window.frames.item("iEditor" + getContainerId(by));
		else
			p = document.getElementById("iEditor" + getContainerId(by)).contentWindow;

		p.focus();
        
		if (p.document.selection)
		{
			var s = p.document.selection.createRange();
			s.execCommand ("insertImage", false, src);
		}
		else
		{			
			p.document.execCommand ("insertImage", false, src);
		}

        refreshContent();
	}
	
	function getSafeHTML(inp)
	{
			var ht = inp;
			// Windows Media
	        	ht = ht.replace(/<OBJECT classid=\"clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6\"([^>]*?)><param name=\"URL\" value=\"[^>]*\/uploads_store\/([^>]*?)\"[^>]*><\/OBJECT>/gi ,
						 "<IMG title=\"wm $2\" src=\"" + myPath + "/deditor/wm.gif" + "\"$1>");

			// Real Player
	        	ht = ht.replace(/<OBJECT classid=\"clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA\"([^>]*?)><param name=\"SRC\" value=\"[^>]*\/uploads_store\/([^>]*?)\"[^>]*><\/OBJECT>/gi ,
						 "<IMG title=\"rm $2\" src=\"" + myPath + "/deditor/rm.gif" + "\"$1>");
			return ht;
	}
	
	function getContent(idNo)
	{
			var ht;
			
			if (window.frames.item)
				ht = window.frames.item("iEditor" + idNo).document.body.innerHTML;
			else
				ht = document.getElementById("iEditor" + idNo).contentWindow.document.body.innerHTML;

        	// Windows Media
        	ht = ht.replace(/<IMG([^>]*)TITLE=\"WM ([^>]*?)\"([^>]*)SRC=\"([^>]*)\"([^>]*)>/gi ,
						 "<object classid=\"clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6\" $1 $3 $5><param name=\"URL\" value=\"" + myPath + "/uploads_store/$2\"></object>");

			// Real Player
        	ht = ht.replace(/<IMG([^>]*)TITLE="RM ([^>]*?)\"([^>]*)SRC=\"([^>]*)\"([^>]*)>/gi ,
						 "<object classid=\"clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA\" $1 $3 $5 ><param name=\"SRC\" value=\"" + myPath + "/uploads_store/$2\"></object>");

	    var st, ed =0;
	
		while(((st = ht.indexOf('<', ed)) > -1) && ((ed = ht.indexOf('>', st)) > -1))
		{
			var mt = st;
			while ((mt=ht.indexOf("=", mt)) < ed)
			{			    
			    if (mt == -1)
			        break;
			     
				if (ht.charAt(mt+1) != '"')
				{
					var md = ht.indexOf(' ', mt);

					if (md == -1 || md > ed)
					    md = ed;
					    
					ht = ht.substr(0, mt+1) + '"' + ht.substring(mt+1,md) + '"' + ht.substr(md);
					
					mt = md+2;
					st += 2;
					ed += 2;
				}
				else
				{
				    mt++;
				}
			}
		}
		
		return ht;
	}
    
	function isUploaded(idNo)
	{

			var iE; //= window.frames.item("iEditor" + idNo);
			var iU; //= window.frames.item("iUpload" + idNo);
			
			if (window.frames.item)
			{
				iE = window.frames.item("iEditor" + idNo);
				iU = window.frames.item("iUpload" + idNo);
			}else
			{
				iE = document.getElementById("iEditor" + idNo).contentWindow;
				iU = document.getElementById("iUpload" + idNo).contentWindow;
			}
	
		//if (window.frames.item("iUpload" + idNo).document.body.innerText != "")
		//alert(iU.document);
		//alert(iU.document.body);
		//alert(iU.document.body.textContent);
		
		var txtRt = iU.document.body.textContent ? iU.document.body.textContent : iU.document.body.innerText;
		//alert(txtRt);
		if (txtRt != "" && txtRt != null)
		{
			
			var p = document.getElementById("dEditor" + idNo);
			//alert(p);
			var uField = searchForElement(p, "upload_field");
			var uForm = searchForElement(p, "upload_form");
			var fU = searchForElement(p, "FUpload");
			var uImg = searchForElement(p, "upload_img");
			var uStatus = searchForElement(p, "upload_status");
			
			
			
			if (txtRt.substr(0,3) == "OK:")
			{
					switch (txtRt.substr(txtRt.lastIndexOf(".")+1).toLowerCase())
				{
					case "jpg": case "png": case "gif": case "jpeg":

   						iE.focus();// document.body.focus();
						if (iE.document.selection)
						{
							var s = iE.document.selection.createRange();
							s.execCommand ("insertImage", false,  "uploads_store/" + txtRt.substr(3));
						} else
						{
							iE.document.execCommand ("insertImage", false,  "uploads_store/" + txtRt.substr(3));
						}
						break;
						
					case "wm": case "wmv": case "wma": case "mp3": case "asf": case "mpg": case "mpeg":
				        iE.focus(); //document.body.focus();
						if (iE.document.selection)
						{
							var s = iE.document.selection.createRange();
						    s.execCommand ("insertImage", false, myPath + '/deditor/wm.gif');
						}
						else
						{
							iE.document.execCommand ("insertImage", false, myPath + '/deditor/wm.gif');
						}
						
						for (var i = 0; i < iE.document.images.length; i++)
								if (iE.document.images.item(i).title.length == 0 && iE.document.images.item(i).src==myPath + '/deditor/wm.gif')
							{
								iE.document.images.item(i).title = "wm " + txtRt.substr(3);
								iE.document.images.item(i).width = 235;
								iE.document.images.item(i).height = 235;
								iE.document.images.item(i).style.height = "235px";
								iE.document.images.item(i).style.width = "235px";
							}
						break;
						
					case "rm": case "rv": case "ra": case "ram":
				        iE.focus(); //document.body.focus();
						if (iE.document.selection)
						{
							var s = iE.document.selection.createRange();
						    s.execCommand ("insertImage", false, myPath + '/deditor/rm.gif');
						}
						else
						{
							iE.document.execCommand ("insertImage", false, myPath + '/deditor/rm.gif');
						}
						for (var i = 0; i < iE.document.images.length; i++)
								if (iE.document.images.item(i).title.length == 0 && iE.document.images.item(i).src==myPath + '/deditor/rm.gif')
							{
								iE.document.images.item(i).title = "rm " + txtRt.substr(3);
								iE.document.images.item(i).width = 235;
								iE.document.images.item(i).height = 235;
								iE.document.images.item(i).style.height = "235px";
								iE.document.images.item(i).style.width = "235px";
							}
						break;
				}
				
				refreshContent();
			}
			else
				alert(txtRt);
			
			uField.disabled = false;
			uForm.reset();
		
			clearInterval(tid);
			tid = 0;
			
			uImg.style.visibility = "hidden";
			fU.style.visibility = "hidden";
			uStatus.innerHTML = "No file selected";
			
		}
	}
	
	function isOrIsIn(obj, objP)
	{
		if (obj == objP) 
			return true;
		
		var p = obj.parentNode;
		
		while (p != null)
		{
			if (p == objP)
				return true;
			else
				p = p.parentNode;
		}
		
		return false;
	}

	function hidedlgs()
	{

		if (skiphide)
			return;
		
		var divs = document.getElementsByTagName("div");
		for (var i = 0; i < divs.length; i++)
		{
			if (divs[i].id == "FSmiles" || divs[i].id == "FColors")
				divs[i].style.visibility = "hidden";
			else if (divs[i].id == "FUpload")
			{
				var p = getContainerElement(divs[i]);
				//alert(divs[i]);
				var img = searchForElement(p, "upload_img")
				
				if (img.style.visibility == "hidden")
				{
					if (window.event==null)
					{
						divs[i].style.visibility = "hidden";
						continue;
					}
					
					var ob = document.elementFromPoint(window.event.x, window.event.y);
					
					if (ob!=null)
					{
						if (!isOrIsIn(ob, divs[i]))
						  divs[i].style.visibility = "hidden";
					}
				}
			}
		}
		
	}


	function showDlg(by, id, ev)
	{

		if (id == "FUpload" && tid != 0)
			return;
			
		var obj = searchForElement(getContainerElement(by), id)
		
		if (obj.style.visibility=="")
		{
		 	obj.style.visibility="hidden";
		 	return;
		}
		
		hidedlgs();
		
        var top = ev ? ev.clientY : window.event.clientY;
        var left = ev ? ev.clientX : window.event.clientX;
		
		var sl = document.body.scrollLeft;
	    var st = document.body.scrollTop;

        obj.style.left = (left + sl - 10) + "px";
        obj.style.top = (top + st + 10) + "px";
        
		obj.style.visibility="";
		
		skiphide=true;
		setTimeout("skiphide=false;",100);

	}
	
	function doUpload(obj)
	{
		var p = getContainerElement(obj);
		var uForm = searchForElement(p, "upload_form");
		var uField = searchForElement(p, "upload_field");
		var uImg = searchForElement(p, "upload_img");
		var uStatus = searchForElement(p, "upload_status");
		var pid = parseInt(p.id.substr(7));
		
		var re_text = /\.gif|\.jpg|\.jpeg|\.png|\.wm|\.wmv|\.wma|\.asf|\.mp3|\.rm|\.ra|\.rv|\.ram|\.mpg|\.mpeg/i;
		var filename = uField.value;
		/* Checking file type */
		if (filename.search(re_text) == -1)
		{
		     alert("File does not have (JPG, JPEG, GIF, PNG, WM, WMV, WMA, ASF, MP3, RM, RA, RV, RAM, MPG, MPEG) extension");
		     uForm.reset();
		     return false;
		}
		uForm.submit();
		uImg.style.visibility = "";
		uStatus.innerHTML = "uploading, please wait...";
		uField.disabled = true;
		if (window.frames.item)
			window.frames.item("iUpload" + pid).document.body.innerHTML = "";
		else
			document.getElementById("iUpload" + pid).contentWindow.document.body.innerHTML = "";
			
		tid = setInterval('isUploaded(' + pid + ');', 200);
		return true;
	}