Hacked By AnonymousFox

Current Path : C:/AppServ/www/new_msd/webengine/mod_circle/
Upload File :
Current File : C:/AppServ/www/new_msd/webengine/mod_circle/index__.php

<? 
include("../lib/session.php");
include("../lib/config.php");
include("../lib/connect.php");
include("../lib/function.php");
?>
<html><!-- InstanceBegin template="/Templates/WebEngine-Adminpanel1.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title> <?=$System_Variable_Title?>
</title>
<!-- InstanceEndEditable --> 
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable --> 
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<link href="../../webengine/css/mystyle.css" rel="stylesheet" type="text/css">  
</head> 
<body bgcolor="#E9E6DF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('../../images/thai.gif','../../images/eng.gif','../../images/chaina.gif','../../images/object/topbar-thai-over.gif','../../images/object/topbar-english-over.gif','../../webengine/images/bullet/lang_over_02_1.gif','../../webengine/images/bullet/lang_over_01_1.gif','../../webengine/images/bullet/lang_over_03.gif')">

<table width="95%" height="26" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="1" bgcolor="#A13626"><img src="../../images/blank.gif" width="1" height="1"></td>
    <td background="../../images/main/main-t-bg.gif" bgcolor="#831B0E"><table width="100%" height="26" border="0" cellpadding="0" cellspacing="0">
          <tr> 
            <td width="867" valign="top"><img src="../../images/main/logo.gif" width="273" height="70" alt="กระทรวงศึกษาธิการ" />&nbsp;</td>
            <td width="115" align="right" valign="top"><a href="../../webengine/system/setlanguage.php?setlang=Thai&&action=setlanguage" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('TopBarTh','','../../webengine/images/bullet/lang_over_04.gif',1)"><? if($System_Session_Language=="Thai"){$Use = "_over";} else { $Use = "_nor";}?><img src="../../webengine/images/bullet/lang<?=$Use?>_04.gif" alt="Thai Language" name="TopBarTh" border="0"></a><a href="../../webengine/system/setlanguage.php?setlang=Eng&&action=setlanguage" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('TopBarEn','','../../webengine/images/bullet/lang_over_03.gif',1)"><? if($System_Session_Language=="Eng"){$Use = "_over";} else { $Use = "_nor";}?>
                <img src="../../webengine/images/bullet/lang<?=$Use?>_03.gif" alt="English Language" name="TopBarEn"border="0"></a> </td>
          </tr>
    </table></td><td width="1" bgcolor="#A13626"><img src="../../images/blank.gif" width="1" height="1"></td>
  </tr>
</table>
<table width="95%" height="6" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr> 
    <td width="1" bgcolor="#A13626"><img src="../../images/blank.gif" width="1" height="1"></td>
    <td width="587" bgcolor="#A13626"><img src="../../images/blank.gif" width="1" height="1"></td>
    <td width="1" bgcolor="#A13626"><img src="../../images/blank.gif" width="1" height="1"></td>
  </tr>
</table>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr> 
    <td width="1" bgcolor="#A13626"><img src="../../images/blank.gif" width="1" height="1"></td>
    <td align="center" valign="top"><table width="100%" height="480" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="215" align="center" valign="top" bgcolor="#9C9994" style="background-repeat:repeat-x; "><br>
            <!--Start Menu ----------------------------------------------------------------------------------->
        	<? if(strlen($System_Session_User_ID)==0) { ?>
            <? if($alert=="yes") { ?>
            <table width="90%" border="0" cellpadding="1" cellspacing="0" class="messagebox_alert">
              <form name="myLoginForm" method="post" action="../../system/login.php" onSubmit="
with(document.myLoginForm) {
	if(inputUserName.value=='') {
		inputUserName.focus();
		return false;
	}
	if(inputPassword.value=='') {
		inputPassword.focus();
		return false;
	}
}">
                <tr align="center"> 
                  <td height="40" colspan="2">Incorrect your<br>
                    UserName or Password.</td>
                </tr>
              </form>
            </table>
            <br>
            <? } ?>            
            <table width="97%" height="18" border="0" cellpadding="0" cellspacing="0">
              <tr> 
                <td width="8"><img src="../../images/blank.gif" width="1" height="1"></td>
                <td ><strong><font color="#FFFFFF">&nbsp;<img src="../../images/object/bar-icon.gif" width="9" height="5" align="absmiddle">&nbsp;เข้าสู่ระบบ</font></strong></td>
              </tr>
            </table> 
            <table width="100%" height="3" border="0" cellpadding="0" cellspacing="0">
              <tr> 
                <td><img src="../../images/blank.gif" width="1" height="1"></td>
              </tr>
            </table>
            <table width="97%" border="0" cellpadding="0" cellspacing="0" bgcolor="#DFDFDF">
              <tr> 
                <td width="6" height="6"><img src="../../images/object/dot-border-1.gif" width="6" height="6"></td>
                <td height="6" background="../../images/object/dot-border-2.gif"><img src="../../images/blank.gif" width="1" height="1"></td>
                <td width="6" height="6"><img src="../../images/object/dot-border-3.gif" width="6" height="6"></td>
              </tr>
              <tr> 
                <td width="6" background="../../images/object/dot-border-4.gif"><img src="../../images/blank.gif" width="1" height="1"></td>
                <td align="center" valign="top">
<table width="100%" height="120" border="0" cellpadding="0" cellspacing="0">
                    <tr> 
                      <td height="80" align="center" valign="middle"> 
                        <form name="myLoginForm" method="post" action="../../webengine/system/login.php" onSubmit=" 
with(document.myLoginForm) {
	if(inputUserName.value=='') {
		inputUserName.focus();
		return false;
	}
	if(inputPassword.value=='') {
		inputPassword.focus();
		return false;
	}
}
				">
                          <table border="0" cellspacing="0" cellpadding="1">
                            <tr> 
                              <td height="18" colspan="2" valign="bottom"><font color="#990000"><strong>Username</strong></font><font color="#990000">&nbsp;</font></td>
                            </tr>
                            <tr> 
                              <td width="10">&nbsp;</td>
                              <td> <input name="inputUserName" type="text" class="input_left" id="inputUserName" size="20" maxlength="50"></td>
                            </tr>
                            <tr> 
                              <td height="18" colspan="2" valign="bottom"><font color="#990000"><strong>Password</strong></font><font color="#990000">&nbsp;</font></td>
                            </tr>
                            <tr> 
                              <td width="10">&nbsp;</td>
                              <td><input name="inputPassword" type="password" class="input_left" id="inputPassword" size="20" maxlength="50"></td>
                            </tr>
                            <tr> 
                              <td width="10">&nbsp;</td>
                              <td align="right"><input name="Submit" type="submit" class="button_60" value="LogIn"></td>
                            </tr>
                          </table>
                        </form></td>
                    </tr>
                  </table></td>
                <td width="6" background="../../images/object/dot-border-5.gif"><img src="../../images/blank.gif" width="1" height="1"></td>
              </tr>
              <tr> 
                <td width="6" height="6"><img src="../../images/object/dot-border-6.gif" width="6" height="6"></td>
                <td height="6" background="../../images/object/dot-border-7.gif"><img src="../../images/blank.gif" width="1" height="1"></td>
                <td width="6" height="6"><img src="../../images/object/dot-border-8.gif" width="6" height="6"></td>
              </tr>
            </table>
            <br>
            <? } else { ?>
            <? if($SystemMenuID=="") { $SystemMenuID=-1; } ?>
            <table width="205" height="21" border="0" align="center" cellpadding="0" cellspacing="0" background="../../webengine/images/bg-search.gif" style="background-repeat:repeat-x; ">
              <tr>
                <td width="5%" >&nbsp;</td> 
                <td width="95%" height="43" ><strong><font color="#FFFFFF">&nbsp;<img src="../../images/object/bar-icon.gif" width="9" height="5" align="absmiddle">&nbsp;เมนูหลัก</font></strong></td>
              </tr>
            </table> 
            <table width="205" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr> 
                <td bgcolor="#F3F3F3"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <form action="../../Templates/" method="get" name="myMenuForm" id="myMenuForm">
                      <input type="hidden" name="SystemMenuID">
                      <input type="hidden" name="SystemModuleKey">
                      <input type="hidden" name="System_EXID" value="<?=$System_EXID?>">
                    </form>
                    <? if($System_Session_User_ID>0) { ?> 
                    <tr> 
                      <td height="1" class="menu_table_bg_hilight"><img src="../../images/blank.gif" width="1" height="1"></td>
                    </tr>
                    <tr>
                      <td height="1" class="menu_table_bg_normal" onMouseOver="this.className='menu_table_bg_over'; " onMouseOut="this.className='menu_table_bg_normal'; " onClick="document.myMenuForm.action='../home/index.php'; document.myMenuForm.submit();">
					  <table width="100%" height="24" border="0" cellpadding="2" cellspacing="0" class="menu_table_text">
        <tr>
          <td width="22" align="center"><img src="../../webengine/images/icon/ico516.gif" width="16" height="14"></td>
          <td>Home</td>
        </tr>
    </table></td>
                    </tr>
                    <tr> 
                      <td height="1" class="menu_table_bg_hilight"><img src="../../images/blank.gif" width="1" height="1"></td>
                    </tr>
                    <tr> 
                      <td height="22" class="menu_table_bg_normal" onMouseOver="this.className='menu_table_bg_over'; " onMouseOut="this.className='menu_table_bg_normal'; " onClick="
document.myMenuForm.action='../system/user_information.php'; 
document.myMenuForm.SystemMenuID.value=-3;
document.myMenuForm.submit();
"><table width="100%" height="25" border="0" cellpadding="2" cellspacing="0">
                          <tr> 
                            <td width="22" align="center"><img src="../../webengine/images/icon/ico559.gif" width="15" height="16"></td>
                            <td> 
                              <? if($SystemMenuID==-3) { ?>
                              <b><font color="#990000">User Information</font></b> 
                              <? } else { ?>
                              User Information 
                              <? } ?>
                            </td>
                          </tr>
                        </table></td>
                    </tr>
                    <? } ?>
                    <!---------------------------------------------------------------------------->
                    <? if($System_Session_Level=="Admin") { ?>
                    <tr> 
                      <td height="1" class="menu_table_bg_hilight"><img src="../../images/blank.gif" width="1" height="1"></td>
                    </tr>
                    <tr> 
                      <td height="22" class="menu_table_bg_normal" onMouseOver="this.className='menu_table_bg_over'; " onMouseOut="this.className='menu_table_bg_normal'; " onClick="
document.myMenuForm.action='../system/user_management.php'; 
document.myMenuForm.SystemMenuID.value=-4;
document.myMenuForm.submit();
"><table width="100%" height="25" border="0" cellpadding="2" cellspacing="0">
                          <tr> 
                            <td width="22" align="center"><img src="../../webengine/images/icon/ico051.gif" width="13" height="19"></td>
                            <td> 
                              <? if($SystemMenuID==-4) { ?>
                              <b><font color="#990000">Manage User Admin</font></b> 
                              <? } else { ?>
                              Manage User Admin 
                              <? } ?>
                            </td>
                          </tr>
                        </table></td>
                    </tr>
                    <? } ?>
                    <!---------------------------------------------------------------------------->
                    <? if($System_Session_User_ID==0) { ?>
                    <tr> 
                      <td height="1" class="menu_table_bg_hilight"><img src="../../images/blank.gif" width="1" height="1"></td>
                    </tr>
                    <tr> 
                      <td height="22" class="menu_table_bg_normal" onMouseOver="this.className='menu_table_bg_over'; " onMouseOut="this.className='menu_table_bg_normal'; " onClick="
document.myMenuForm.action='../mod_dmenu/index.php'; 
document.myMenuForm.SystemMenuID.value=-2;
document.myMenuForm.submit();
"><table width="100%" height="25" border="0" cellpadding="2" cellspacing="0">
                          <tr> 
                            <td width="22" align="center"><img src="../../webengine/images/icon/ico509.gif" width="16" height="13"></td>
                            <td> 
                              <? if($SystemMenuID==-2) { ?>
                              <b><font color="#990000">Menu Bulider</font></b> 
                              <? } else { ?>
                              Menu Bulider 
                              <? } ?>
                            </td>
                          </tr>
                        </table></td>
                    </tr>
                    <? } ?>
                    <? if($System_Session_User_ID>0) { ?>
                    <?
$sql = "SELECT * FROM ".$System_TableName_Menu." WHERE ".$System_TableName_Menu."_ParentID=0 AND ".$System_TableName_Menu."_Language = '$System_Session_Language' ORDER BY ".$System_TableName_Menu."_Order ASC ";
$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
$MenuRecordCount=MYSQL_NUMROWS($Query);

$index=1;
if($MenuRecordCount>0) {
	while($index<$MenuRecordCount+1) {
		$Row=MYSQL_FETCH_ARRAY($Query);
		
		// checking for User Permission
		
		$myUserID = $System_Session_User_ID;
		$myMenuID = $Row[$System_TableName_Menu."_ID"];
		$myMenuPermission = getUserPermissionOnMenu($myUserID,$myMenuID);

		if($Row[$System_TableName_Menu."_Type"]=="Group") {
			$isUserOnGroup=isUserOnGroup($myUserID,$myMenuID);
		} else {
			$isUserOnGroup=1;
		}
		if( strlen($myMenuPermission)>0 && $myMenuPermission!="NA" && $isUserOnGroup>0) {
		?>
                    <tr> 
                      <td height="1" class="menu_table_bg_hilight"><img src="../../images/blank.gif" width="1" height="1"></td>
                    </tr>
                    <tr> 
                      <td height="22" class="menu_table_bg_normal" onMouseOver="this.className='menu_table_bg_over'; " onMouseOut="this.className='menu_table_bg_normal'; " onClick="
<? if($Row[$System_TableName_Menu."_ModuleType"]=="Group") { ?>
	menuHideSubShow('idMenuSub<?=$Row[$System_TableName_Menu."_ID"]?>');
<? } else { ?>
with(document.myMenuForm) {
	SystemMenuID.value=<?=$Row[$System_TableName_Menu."_ID"]?>; 
	SystemModuleKey.value='<?=$Row[$System_TableName_Menu."_ModuleKey"]?>'; 
	action='<?=$Row[$System_TableName_Menu."_LinkPath"]?>'; 
	submit();
}
<? } ?>
"><table width="100%" height="25" border="0" cellpadding="2" cellspacing="0">
                          <tr> 
                            <td width="22" align="center"><? if($Row[$System_TableName_Menu."_Icon"]==""){ ?>
                              <img src="../../webengine/images/icon/145.gif">							<? }else{ ?>
							<img src="<?=$Row[$System_TableName_Menu."_Icon"]?>"><? } ?></td>
                            <td> 
                              <? if($SystemMenuID==$Row[$System_TableName_Menu."_ID"]) { ?>
                              <b><font color="#990000"> 
                              <?=$Row[$System_TableName_Menu."_Name".$System_Session_Language]?>
                              </font></b> 
                              <? } else { ?>
                              <?=$Row[$System_TableName_Menu."_Name".$System_Session_Language]?>
                              <? } ?>
                            </td>
                            <? if($Row[$System_TableName_Menu."_ModuleType"]=="Group") { ?>
                            <td width="14" align="left"><img src="../../webengine/images/arrow1.gif" width="13" height="10"></td>
                            <? } ?>
                          </tr>
                        </table></td>
                    </tr>
                    <?
		$ParentID=$Row[$System_TableName_Menu."_ID"];
		
		$sql1 = "SELECT * FROM ".$System_TableName_Menu." WHERE ".$System_TableName_Menu."_ParentID='$ParentID' ORDER BY ".$System_TableName_Menu."_Order ASC ";
		$Query1=MYSQL_DB_QUERY($System_DataBase_Name,$sql1) OR DIE("Error: เกิดความผิดพลาด <br>$sql1<br>\n");
		$RecordCount1=MYSQL_NUMROWS($Query1);
	
		// checking for this sub menu active
		$sql2 = "SELECT * FROM ".$System_TableName_Menu." WHERE ".$System_TableName_Menu."_ID='$SystemMenuID' AND ".$System_TableName_Menu."_ParentID='$ParentID' ";
		
		$Query2=MYSQL_DB_QUERY($System_DataBase_Name,$sql2) OR DIE("Error: เกิดความผิดพลาด <br>$sql2<br>\n");
		$isActiveMenu=MYSQL_NUMROWS($Query2);

		if($RecordCount1>0) {
		?>
                    <tr id="idMenuSub<?=$ParentID?>" <? if($isActiveMenu==0) { ?> style="display:none" <? } ?>> 
                      <td height="22" align="left" class="menu_table_bg_sub" > 
                        <table width="100%"  border="0" cellspacing="0" cellpadding="0">
<tr height="8" >
                            <td height="8" background="../../webengine/images/rare1.gif" bgcolor="#EACFD3" style="background-position:top; background-repeat:repeat-x; "><img src="../../webengine/images/spacer.gif" width="24" height="8" /></td>
</tr>
</table><?
		$index1=1;
		
		while($index1<$RecordCount1+1) {
			$Row1=MYSQL_FETCH_ARRAY($Query1);
			$myID=$Row1[$System_TableName_Menu."_ID"];

			// checking for User Permission
			$myUserID = $System_Session_User_ID;
			$myMenuID = $myID;
			$myMenuPermission = getUserPermissionOnMenu($myUserID,$myMenuID);
			if( strlen($myMenuPermission)>0 && $myMenuPermission!="NA") {

				?>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="menu_table_bg_sub" onMouseOver="this.className='menu_table_bg_oversub'; " onMouseOut="this.className='menu_table_bg_sub'; " >
                          <tr> 
                            <td width="4">&nbsp;</td>
                            <td width="171" align="left"><table width="100%" height="25" border="0" cellpadding="1" cellspacing="0"  
 onClick="
with(document.myMenuForm) {
	SystemMenuID.value=<?=$Row1[$System_TableName_Menu."_ID"]?>; 
	SystemModuleKey.value='<?=$Row1[$System_TableName_Menu."_ModuleKey"]?>'; 
	action='<?=$Row1[$System_TableName_Menu."_LinkPath"]?>'; 
	submit();
}
">
                                <tr> 
                                  <td width="22" align="left"><? if($Row1[$System_TableName_Menu."_Icon"]==""){ ?>-<? }else{ ?><img src="<?=$Row1[$System_TableName_Menu."_Icon"]?>"><? }?></td>
                                  <td align="left"> 
                                    <? if($SystemMenuID==$Row1[$System_TableName_Menu."_ID"]) { ?>
                                    <b><font color="#990000"> 
                                    <?=$Row1[$System_TableName_Menu."_Name".$System_Session_Language]?>
                                    </font></b> 
                                    <? } else { ?>
							  <font color="#6666AA"><?=$Row1[$System_TableName_Menu."_Name".$System_Session_Language]?></font>
                                    <? } ?>                                  </td>
                                </tr>
                            </table></td>
                          </tr>
                          <tr align="left">
                            <td colspan="2"><img src="../../webengine/images/line3.gif" width="195"></td>
                          </tr>
                        </table>
                      <? 
					} // if Permission
					$index1++;
				} // while
			 } // if RecordCount1
			 ?>                      </td>
                    </tr>
                    <?
		} // if myMenuPermission
		$index++;
	} // while
} // if RecordCount
?>
                    <? } ?>
                    <tr> 
                      <td height="1" class="menu_table_bg_hilight"><img src="../../images/blank.gif" width="1" height="1"></td>
                    </tr>
                    <tr> 
                      <td height="22" class="menu_table_bg_normal" onMouseOver="this.className='menu_table_bg_over'; " onMouseOut="this.className='menu_table_bg_normal'; " onClick="document.myMenuForm.action='../system/logout.php'; document.myMenuForm.submit();"><table width="100%" height="25" border="0" cellpadding="2" cellspacing="0">
                          <tr> 
                            <td width="22" align="center"><img src="../../webengine/images/icon/ico569.gif" width="13" height="13"></td>
                            <td>Logout</td>
                          </tr>
                        </table>
                      </td>
                    </tr>
            </table></td>
              </tr>
            </table>
            
            <table width="205" height="30" border="0" align="center" cellpadding="0" cellspacing="0" background="../../webengine/images/bg-search2.gif">
              <tr>
                <td>&nbsp;</td>
              </tr>
            </table>
            <? } ?>
            <script language="JavaScript" type="text/JavaScript">
function menuHideSubShow(myIdName) {
	if(document.getElementById(myIdName).style.display=='none') { 
		document.getElementById(myIdName).style.display=''
	} else {
		document.getElementById(myIdName).style.display='none';
	}
}
			  </script>
          <!--End Menu ----------------------------------------------------------------------------------->          </td>
          <td align="center" valign="top" bgcolor="#E9E6DF"> 
            <table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="16" valign="top" bgcolor="#C4BDB1">&nbsp;</td>
        <td align="center" valign="top" bgcolor="#C4BDB1">&nbsp;</td>
        <td valign="top" bgcolor="#C4BDB1">&nbsp;</td>
      </tr>
      <tr>
        <td width="20" valign="top" background="../../webengine/images/object/border_03.gif"><img src="../../webengine/images/object/border_16.gif" width="20" height="83"></td>
        <td align="center" valign="top" bgcolor="#FFFFFF">
		   <? if(strlen($System_Session_User_ID)>0) { ?>
            <!-- InstanceBeginEditable name="Programmable Region" -->  <br>
<table width="98%" height="22" border="0" cellpadding="2" cellspacing="0" class="table_header">
<tr> 
<td width="30" align="center"><img src="<?=getMenuIcon($SystemMenuID)?>"></td>
<td> 
<?=getMenuName($SystemMenuID)?>
&nbsp;</td>
</tr>
</table>
<table width="97%" border="0" cellpadding="0" cellspacing="0">
<tr> 
<td height="1" class="bar_tab_enable"><img src="../images/blank.gif" width="10" height="2"></td>
</tr>
</table>
<table width="97%" border="0" cellpadding="0" cellspacing="0">
<form action="?" method="get" name="myPageRedirectForm" id="myPageRedirectForm">
<input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
<input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
<input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
<input name="NewsID" type="hidden" id="NewsID" value="" >
<input name="action2" type="hidden" id="action2" >
<tr> 
  <td height="20" align="right">
  <table height="20" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="5" align="left" valign="bottom" class="table_col3"><img src="images/tab-w.gif" width="1" height="1"></td>
      <td width="100" align="center" class="table_col3"> <a href="#" class="link_headbar" onClick="
document.myPageRedirectForm.action='index.php';
document.myPageRedirectForm.submit();
">Content</a></td>
      <td width="20" class="table_col3"><img src="../images/tab-w-slop-down.gif" width="20" height="20"></td>
      <td width="5" align="left" valign="bottom" class="bar_tab_disable" ><img src="images/tab-w.gif" width="1" height="1" class="table_col3"></td>
      <td width="100" align="center" class="bar_tab_disable" ><a href="#" class="link_headbar" onClick="
document.myPageRedirectForm.action='comment.php';
document.myPageRedirectForm.submit();
">Comment</a></td>
      <td width="20" class="bar_tab_disable"><img src="../images/tab-w-slop-down.gif" width="20" height="20" class="bar_tab_disable"></td>
      <td width="30">&nbsp;</td>
    </tr>
  </table>  </td>
</tr>
</form>
</table>
<script language="JavaScript" src="../lib/popup.js" type="text/JavaScript"></script>
<br>
            <? 
## Load Module Configuration Variable ############################################
include("config.php");

## Default Value ############################################
$SystemModule_defaultPageSize = 10;
$SystemModule_defaultPageShow = 1;
$SystemModule_MaxPage = 20;
$SystemModule_ReduceRange = 10; 		// +,- from current page show
$SystemModule_ASCDESC = "DESC";
$SystemModule_OrderBy = $myModule_Table."_Order";

#########################################################
?>
            <!-- import the calendar script -->
            <link rel="stylesheet" type="text/css" href="../css/myCalendarStyle.css">
            <script type="text/javascript" src="lib/calendar.js"></script>
            <script type="text/javascript" src="lib/lang/calendar-th.js"></script>
            <script type="text/javascript" src="lib/loadcalendar.js"></script>
            <!-- end the calendar script -->
            <? 
#########################################################
if ($action=="addnew") { 
$myCheckBoxID=0;
$image_W=getimagesize($inputThumbnailPicture); //Cjeck ขนาดภาพ
$image_H=getimagesize($inputThumbnailPicture);
if($SystemModuleKey=="news2" || $SystemModuleKey=="news5" || $image_W[0]>150){
if($SystemModuleKey=="news1" || $SystemModuleKey=="news3" || $image_W[0]>130){ 
echo "<SCRIPT LANGUAGE=\"JavaScript\">alert(\"use a picture file width over limit\");</SCRIPT>";
?>
<form action="?" method="post" name="myForm" id="myForm">
                      <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                      <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                      <input name="admin" type="hidden" id="admin" value="<?=$admin?>">
                      <input name="action" type="hidden" id="action">
                      <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
                      <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
                      <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
                      <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
                      <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
                    </form>
                    <script language="JavaScript" type="text/JavaScript"> document.myForm.submit(); </script>
	<?
	exit(); }}
	for($i=1;$i<=$TotalCheckBoxID;$i++) {
		$myVar="CheckBoxID".$i;
		if(strlen($$myVar)>0) {
			$myCheckBoxID=$$myVar;
		}
	}
$ASCDESC="ASC";
		if( strlen($inputStartDate)>0 && strlen($inputExpireDate)>0 ) {
			if(strcmp($inputStartDate,$inputExpireDate)<1) { 
				// Do nothing.
			} else { 
				// Switch Date
				$myTmp = $inputStartDate;
				$inputStartDate = $inputExpireDate;
				$inputExpireDate = $myTmp;
			}
		}

		if(strlen($inputStartDate)!=10) { $inputStartDate="0000-00-00 00:00:00"; } else { $inputStartDate = $inputStartDate." 00:00:00"; }
		if(strlen($inputExpireDate)!=10) { $inputExpireDate="0000-00-00 00:00:00"; } else { $inputExpireDate= $inputExpireDate." 00:00:00"; }

		$sql = "SELECT COUNT(*) FROM ".$myModule_Table." WHERE ".$myModule_Table."_ModuleKey='$SystemModuleKey' AND ".$myModule_Table."_Language='$System_Session_Language'  ";
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
		$Row=MYSQL_FETCH_ARRAY($Query);
		$MaxOrder = $Row[0]+1;

		if($inputNewsDate==""){
			$inputNewsDate = "NOW()";
		}else{
		if(strlen($inputNewsDate)!=10) { $inputNewsDate="0000-00-00 00:00:00"; } else { $inputNewsDate= $inputNewsDate." 00:00:00"; }
		}
		
		$sql = "INSERT INTO ".$myModule_Table."
		(".$myModule_Table."_Subject,".$myModule_Table."_GID,".
		$myModule_Table."_Title,".
		$myModule_Table."_From,".
		$myModule_Table."_Url,".
		$myModule_Table."_Marquee,".
		$myModule_Table."_PictureFile,".
		$myModule_Table."_TitleThumbnailPicture,".
		$myModule_Table."_CreateByID,".
		$myModule_Table."_CreateBy,".
		$myModule_Table."_CreateDate,".
		$myModule_Table."_LastUpdate ,".
		$myModule_Table."_StartDate,".
		$myModule_Table."_ExpireDate,".
		$myModule_Table."_Status,".
		$myModule_Table."_ModuleKey,".
		$myModule_Table."_Language,".
		$myModule_Table."_Order) VALUES('".changeQuot($inputSubject)."',
		'$inputGroupID',
		'".changeQuot($inputTitle)."',
		'$inputFrom',
		'$inputUrl',
		'$inputMarquee',
		'',
		'$inputTitleThumbnailPicture',
		$System_Session_User_ID,
		'$System_Session_UserName',
		'$inputNewsDate',
		NOW(),
		'$inputStartDate',
		'$inputExpireDate',
		'Enable',
		'$SystemModuleKey',
		'$System_Session_Language',
		$MaxOrder)";
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
		//echo $sql;
		//die();

		$sql = "SELECT MAX(".$myModule_Table."_ID) FROM ".$myModule_Table;
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
		$Row=MYSQL_FETCH_ARRAY($Query);
		$MaxID = $Row[0];

		srand(make_seed());
		$myrand = rand(1111,9999);

		// Check to create module data directory. ---------
		if(!is_dir($System_RelativePath_Upload."/".$SystemModuleKey)) { mkdir($System_RelativePath_Upload."/".$SystemModuleKey,0777); }
		if(!is_dir($myModule_Path_ThumbnailPicture)) { mkdir($myModule_Path_ThumbnailPicture,0777); }
		if(!is_dir($myModule_Path_HTMLFiles)) { mkdir($myModule_Path_HTMLFiles,0777); }
		if(!is_dir($myModule_Path_ImageLibrary)) { mkdir($myModule_Path_ImageLibrary,0777); }
		if(!is_dir($myModule_Path_FileUpload)) { mkdir($myModule_Path_FileUpload,0777); }
		if(!is_dir($myModule_Path_GalleryThumbnail)) { mkdir($myModule_Path_GalleryThumbnail,0777); }
		if(!is_dir($myModule_Path_Gallery)) { mkdir($myModule_Path_Gallery,0777); }
		if(!is_dir($myModule_Path_Video)) { mkdir($myModule_Path_Video,0777); }
		// ------------------------------------------------
		
	include"function_mod.php";
		///////--  Attach Files  ------------//
	 if( isset( $_FILES[inputFile][tmp_name] ) ){
				for($i=0; $i < count( $_FILES[inputFile][tmp_name] );  $i++){
					$exts = explode(".", $_FILES[inputFile][name][$i]);
					$ext = strtolower(($exts[count($exts) - 1]));	
					$tmpName = $_FILES[inputFile][tmp_name][$i];
					$fileName = $_FILES[inputFile][name][$i];     				
					$fileSize = imgGetFileSize($_FILES[inputFile][size][$i]);
					$myrand = rand(1111,9999);
					$path =  $MaxID."-".$myrand."." . $ext;										
					$paths= $myModule_Path_FileUpload ."/". $path;				
				if ($_FILES[InputFile][error][$i]==0) {
					 if ($_FILES[inputFile][type][$i])	$mimeType = $_FILES[inputFile][type][$i];												
					 else  $mimeType = "application/unknown";					
						if( move_uploaded_file($_FILES[inputFile][tmp_name][$i], $paths) ){							
						//sql
							$insert[$myModule_Table_FileUploadOnNews."_NewsID"] = "$MaxID";
							$insert[$myModule_Table_FileUploadOnNews."_FileUpload"] = "'$path'";
							$insert[$myModule_Table_FileUploadOnNews."_UploadFileName"] = "'$fileName'";		
							$sql="INSERT INTO ".$myModule_Table_FileUploadOnNews." (".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
							mysql_query($sql) or die("Error: เกิดความผิดพลาด <br>$sql<br>\n");
						}
				}											
			}
			unset($insert);
		 }//end check file.
		 //------- end add file ---------
		
		 
		 
		 
		/*
		for($i=0; $i<=count($inputFile); $i++){
					srand(make_seed());
					$myrand = rand(1111,9999);
		
					$LastFileArray=explode(".",$inputFile_name[$i]);
					$LastFile=$LastFileArray[count($LastFileArray)-1];
					$StrFileName=$MaxID."_".$myrand.".".$LastFile;
					
					if($inputFile[$i]!=""){
					
					if(file_exists($myModule_Path_FileUpload."/".$StrFileName)) {
							unlink($myModule_Path_FileUpload."/".$StrFileName);
					}
					if(move_uploaded_file($_FILES['inputFile[$i]']['tmp_name'],$myModule_Path_FileUpload."/".$StrFileName)) {
							chmod($myModule_Path_FileUpload."/".$StrFileName,0777);
					}
				$sql = " INSERT INTO ".$myModule_Table_FileUploadOnNews."(".$myModule_Table_FileUploadOnNews."_NewsID ,".$myModule_Table_FileUploadOnNews."_FileUpload , ".$myModule_Table_FileUploadOnNews."_UploadFileName)".
				" VALUES ($MaxID,'$StrFileName','$LastFileArray[0]') ";
				$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error : เกิดความผิดพลาด <br>$sql<br>\n");
						
					}
		}//end for
		*/
		
	//---------by tom
	if(isset($_FILES['inputThumbnailPicture'])) {
				if($_FILES['inputThumbnailPicture']['error']==0){				
					$exts = explode(".", $_FILES['inputThumbnailPicture']['name']);
					$ext = strtolower(($exts[count($exts) - 1]));	
					$ImageType = $ext;
				$ThumbnailPictureName = "$MaxID-$myrand.$ImageType";
				if(file_exists($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName)) {
					unlink($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName);
				}
				if(move_uploaded_file($_FILES['inputThumbnailPicture']['tmp_name'],$myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName)) {
					chmod($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName,0777);
				}
				$sql = "UPDATE ".$myModule_Table." SET ".$myModule_Table."_PictureFile='$ThumbnailPictureName' WHERE ".$myModule_Table."_ID=".$MaxID;
				$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
			}
		}
		///--------by tom
	/*	if(is_file($inputThumbnailPicture)) {
			$ImageData = getimagesize($inputThumbnailPicture);
			if($ImageData!=NULL) {
				if($ImageData[2]==1) { 
					$ImageType="gif";
				} elseif($ImageData[2]==2) {
					$ImageType="jpg";
				}
				$ThumbnailPictureName = "$MaxID-$myrand.$ImageType";
				if(file_exists($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName)) {
					unlink($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName);
				}
				if(copy($inputThumbnailPicture,$myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName)) {
					chmod($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName,0777);
				}
				$sql = "UPDATE ".$myModule_Table." SET ".$myModule_Table."_PictureFile='$ThumbnailPictureName' WHERE ".$myModule_Table."_ID=".$MaxID;
				$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
			}
		}
		*/
		if($HTMLToolContent!=""){
								$HTMLFileName = "$MaxID-$myrand.html";
								$HTMLToolContent=stripslashes($HTMLToolContent);
								$fp = fopen ($myModule_Path_HTMLFiles."/".$HTMLFileName, "w+");
								fwrite($fp,$HTMLToolContent);
								fclose($fp);
								$sql = "UPDATE ".$myModule_Table." SET ".$myModule_Table."_HTMLFileName='$HTMLFileName' WHERE ".$myModule_Table."_ID=".$MaxID;
								$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
				}//ADD HTML 
				
				for ($index=0;$index<count($inputSelectAssign);$index++) {
						$sql = "SELECT * FROM ".$System_Tag." WHERE ".$System_Tag."_Detail = '$inputSelectAssign[$index]'";
						$QueryTag=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
						$RowTag=MYSQL_FETCH_ARRAY($QueryTag);
							if($RowTag[0]==""){
								$sql="INSERT INTO ".$System_Tag." (".$System_Tag."_Detail) VALUES('$inputSelectAssign[$index]')";
								$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
							}
				
							$tag.=$inputSelectAssign[$index].",";
							}
				
				$sql = "UPDATE ".$myModule_Table." SET ".$myModule_Table."_Tag='$tag' WHERE ".$myModule_Table."_ID=".$MaxID;
				$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
// Search All Site 
if($_SESSION[System_Session_Language]=="Thai"){
$Lang="th";
}elseif($_SESSION[System_Session_Language]=="Eng"){
$Lang="en";
}
include ("config.php");
$insert[$myModule_SearchAllSite."_RecordID"] = "'".$MaxID."'";
	$insert[$myModule_SearchAllSite."_ModuleKey"] = "'".$SystemModuleKey."'";
	$insert[$myModule_SearchAllSite."_Language"] = "'".$_SESSION[System_Session_Language]."'";
	$insert[$myModule_SearchAllSite."_Content"] = "'".strip_tags($inputSubject)." , ".strip_tags($inputTitle)." , ".strip_tags($HTMLToolContent)."'";
	if($inputUrl){
		$insert[$myModule_SearchAllSite."_Path"] = "'".$inputUrl."'";
	}else{
		$insert[$myModule_SearchAllSite."_Path"] = "'".$myModule_Path_Search."'";
	}
	$insert[$myModule_SearchAllSite."_Status"] = "'Enable'";
	$sql2 = "INSERT INTO ".$myModule_SearchAllSite."(".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
	$Query2 = mysql_query($sql2);
	
//gen XML -------------------------------

$sql = "SELECT * FROM ".$myModule_Table."  WHERE (" . $myModule_Table."_Status='Enable' OR ".$myModule_Table."_Status='Home')".
					" AND " . $myModule_Table . "_ModuleKey='$SystemModuleKey'" . 
					" AND " . $myModule_Table . "_Language='Thai'" . 
					" AND ((".$myModule_Table."_StartDate='0000-00-00 00:00:00' AND ".  $myModule_Table."_ExpireDate='0000-00-00 00:00:00') " .
					" OR (".$myModule_Table."_StartDate='0000-00-00 00:00:00' AND TO_DAYS(".$myModule_Table."_ExpireDate) >= TO_DAYS(NOW()))" .
					" OR (TO_DAYS(".$myModule_Table."_StartDate) <= TO_DAYS(NOW()) AND ".  $myModule_Table."_ExpireDate='0000-00-00 00:00:00' )" .
					" OR (TO_DAYS(".$myModule_Table."_StartDate) <= TO_DAYS(NOW()) AND TO_DAYS(".$myModule_Table."_ExpireDate)>=TO_DAYS(NOW()))) ";
//die($sql);
$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
$aFieldReq = array();
//$aFieldReq = split(";", $sFieldReq);

// ######### INITIAL VARIABLE USE FOR STRING RSS #########
$strRSSHeader = "";
$strRSSBody = "";
$iCount = 0;

// Generate XML TAG..
		$strRSSHeader .= "&lt;?xml version=\"1.0\" encoding=\"windows-874\"?&gt;\n";
		$strRSSHeader .= "&lt;rss version=\"2.0\"&gt;\n";
		$strRSSHeader .= "&lt;channel&gt;\n";
		//if ($SystemModuleKey=="thainews") {
			$strRSSHeader .= "&lt;title&gt;moe.go.th - Moe News&lt;/title&gt;\n";
		//} else {
			//$strRSSHeader .= "&lt;title&gt;SkypeThailand.Com - Skype World Wide News&lt;/title&gt;\n";
		//}
		$strRSSHeader .= "&lt;link&gt;http://www.moe.go.th/moe/th/news/&lt;/link&gt;\n";
		$strRSSHeader .= "&lt;description&gt;Online Update&lt;/description&gt;\n";
		$strRSSHeader .= "&lt;language&gt;th-TH&lt;/language&gt;\n";
			
			while ($Row = mysql_fetch_array($Query)){
						//$LinkPath=$System_FullPath."http://golf/skypethailand/th/news/news_detail.php?nID=".$Row[$myModule_Table."_ID"]."&chk=".$SystemModuleKey;
							$strRSSHeader .= "\n&lt;item&gt;\n";
							$strRSSHeader .= "&lt;title&gt;".$Row[$myModule_Table."_Subject"]."&lt;/title&gt;\n";
							$strRSSHeader .= "&lt;link&gt;".$System_FullPath."/th/news/detail.php?NewsID=".$Row[$myModule_Table."_ID"]."&amp;Key=".$SystemModuleKey."&lt;/link&gt;\n";
							$strRSSHeader .= "&lt;description&gt;".$Row[$myModule_Table."_Title"]."&lt;/description&gt;\n";
							$strRSSHeader .= "&lt;pubDate&gt;".$Row[$myModule_Table."_LastUpdate"]."&lt;/pubDate&gt;\n";
							$strRSSHeader .= "&lt;/item&gt;\n";
			
}	// END WHILE
		
		$strRSSHeader .= "&lt;/channel&gt;\n";
		$strRSSHeader .= "&lt;/rss&gt;\n";
		
		
		$XMLFileName = "$SystemModuleKey.xml";
		$HTMLToolContent=stripslashes($strRSSHeader);
		$fp = fopen ($myModule_Path_HTMLFiles."/".$XMLFileName, "w+");
		fwrite($fp,str_replace("&gt;",">",str_replace("&lt;","<",$strRSSHeader)));
		fclose($fp);

///// gallery//////
for($i=1;$i<=10;$i++){
			$inputGallery=$_FILES['inputGallery_'.$i]['tmp_name'];
			if(is_file($inputGallery)) {
				$ImageData = getimagesize($inputGallery);
			if($ImageData!=NULL) {
				if($ImageData[2]==1) { 
					$ImageType="gif";
				} elseif($ImageData[2]==2) {
					$ImageType="jpg";
				}
				$image=cropImage($inputGallery,100,100);
				srand(make_seed());
				$myrand = rand(1111,9999);
				$ThumbnailPictureName = "$MaxID-$i-$myrand.$ImageType";
				if(file_exists($myModule_Path_GalleryThumbnail."/".$ThumbnailPictureName)) {
					unlink($myModule_Path_GalleryThumbnail."/".$ThumbnailPictureName);
				}
				if($ImageType=="gif"){
				if(imagegif($image,$myModule_Path_GalleryThumbnail."/".$ThumbnailPictureName)) {
					chmod($myModule_Path_GalleryThumbnail."/".$ThumbnailPictureName,0777);
				}
			}
			if($ImageType=="jpg"){
				if(imagejpeg($image,$myModule_Path_GalleryThumbnail."/".$ThumbnailPictureName)) {
					chmod($myModule_Path_GalleryThumbnail."/".$ThumbnailPictureName,0777);
				}
			}
			srand(make_seed());
			$myrand = rand(1111,9999);
			$PictureName = "$MaxID-$i-$myrand.$ImageType";
			$minHeight=450;
			$minWidth=800;
			if($ImageData[1]>$minHeight || $ImageData[0]>$minWidth){
				if($minWidth/$ImageData[0]>$minHeight/$ImageData[1]){
					$image=cropImage($inputGallery,$minWidth,$ImageData[1]*$minWidth/$ImageData[0]);
				}else{
					$image=cropImage($inputGallery,$ImageData[0]*$minHeight/$ImageData[1],$minHeight);
				}
				if(file_exists($myModule_Path_Gallery."/".$PictureName)) {
					unlink($myModule_Path_Gallery."/".$PictureName);
				}
				if($ImageType=="gif"){
					if(imagegif($image,$myModule_Path_Gallery."/".$PictureName)) {
						chmod($myModule_Path_Gallery."/".$PictureName,0777);
					}
				}
				if($ImageType=="jpg"){
					if(imagejpeg($image,$myModule_Path_Gallery."/".$PictureName)) {
						chmod($myModule_Path_Gallery."/".$PictureName,0777);
					}
				}
			}else{
				if(copy($inputGallery,$myModule_Path_Gallery."/".$PictureName)){
					chmod($myModule_Path_Gallery."/".$PictureName,0777);
				}
			}
				$sql = "INSERT INTO ".$myModule_Table_Gallery."(".$myModule_Table_Gallery."_NewsID ,".$myModule_Table_Gallery."_Thumbnail ,".$myModule_Table_Gallery."_Picture ,".$myModule_Table_Gallery."_Status) VALUES ('$MaxID','$ThumbnailPictureName','$PictureName','Enable')";
				$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
			}
			}
		}

///////////// Video Gallery
for($i=1;$i<=10;$i++){
	$inputVideo=$_FILES['inputVideo_'.$i]['tmp_name'];
	if(is_file($inputVideo)) {
		$inputVideoName=$_FILES['inputVideo_'.$i]['name'];
		srand(make_seed());
		$myrand = rand(1111,9999);
		$VideoName = "$MaxID-$myrand-$inputVideoName";
		if(copy($inputVideo,$myModule_Path_Video."/".$VideoName)){
			chmod($myModule_Path_Video."/".$VideoName,0777);
		}
		if($_REQUEST['inputVideoName_'.$i]!="")
			$Name=$_REQUEST['inputVideoName_'.$i];
		else
			$Name=$inputVideoName;
		$sql = "INSERT INTO ".$myModule_Table_Video."(".$myModule_Table_Video."_NewsID ,".$myModule_Table_Video."_Video,".$myModule_Table_Video."_Name ,".$myModule_Table_Video."_Status) VALUES ('$MaxID','$VideoName','$Name','Enable')";
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
	}
}


//gen XML -------------------------------

$sql = "SELECT * FROM ".$myModule_Table."  WHERE (" . $myModule_Table."_Status='Enable' OR ".$myModule_Table."_Status='Home')".
					" AND " . $myModule_Table . "_ModuleKey='$SystemModuleKey'" . 
					" AND " . $myModule_Table . "_Language='Thai'" . 
					" AND ((".$myModule_Table."_StartDate='0000-00-00 00:00:00' AND ".  $myModule_Table."_ExpireDate='0000-00-00 00:00:00') " .
					" OR (".$myModule_Table."_StartDate='0000-00-00 00:00:00' AND TO_DAYS(".$myModule_Table."_ExpireDate) >= TO_DAYS(NOW()))" .
					" OR (TO_DAYS(".$myModule_Table."_StartDate) <= TO_DAYS(NOW()) AND ".  $myModule_Table."_ExpireDate='0000-00-00 00:00:00' )" .
					" OR (TO_DAYS(".$myModule_Table."_StartDate) <= TO_DAYS(NOW()) AND TO_DAYS(".$myModule_Table."_ExpireDate)>=TO_DAYS(NOW()))) ";
//die($sql);
$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
$aFieldReq = array();
//$aFieldReq = split(";", $sFieldReq);

// ######### INITIAL VARIABLE USE FOR STRING RSS #########
$strRSSHeader = "";
$strRSSBody = "";
$iCount = 0;

// Generate XML TAG..
		$strRSSHeader .= "&lt;?xml version=\"1.0\" encoding=\"windows-874\"?&gt;\n";
		$strRSSHeader .= "&lt;rss version=\"2.0\"&gt;\n";
		$strRSSHeader .= "&lt;channel&gt;\n";
		//if ($SystemModuleKey=="thainews") {
			$strRSSHeader .= "&lt;title&gt;moe.go.th - Moe News&lt;/title&gt;\n";
		//} else {
			//$strRSSHeader .= "&lt;title&gt;SkypeThailand.Com - Skype World Wide News&lt;/title&gt;\n";
		//}
		$strRSSHeader .= "&lt;link&gt;http://www.moe.go.th/moe/th/news/&lt;/link&gt;\n";
		$strRSSHeader .= "&lt;description&gt;Online Update&lt;/description&gt;\n";
		$strRSSHeader .= "&lt;language&gt;th-TH&lt;/language&gt;\n";
			
			while ($Row = mysql_fetch_array($Query)){
						//$LinkPath=$System_FullPath."http://golf/skypethailand/th/news/news_detail.php?nID=".$Row[$myModule_Table."_ID"]."&chk=".$SystemModuleKey;
							$strRSSHeader .= "\n&lt;item&gt;\n";
							$strRSSHeader .= "&lt;title&gt;".$Row[$myModule_Table."_Subject"]."&lt;/title&gt;\n";
							$strRSSHeader .= "&lt;link&gt;".$System_FullPath."/th/news/detail.php?NewsID=".$Row[$myModule_Table."_ID"]."&amp;Key=".$SystemModuleKey."&lt;/link&gt;\n";
							$strRSSHeader .= "&lt;description&gt;".$Row[$myModule_Table."_Title"]."&lt;/description&gt;\n";
							$strRSSHeader .= "&lt;pubDate&gt;".$Row[$myModule_Table."_LastUpdate"]."&lt;/pubDate&gt;\n";
							$strRSSHeader .= "&lt;/item&gt;\n";
			
}	// END WHILE
		
		$strRSSHeader .= "&lt;/channel&gt;\n";
		$strRSSHeader .= "&lt;/rss&gt;\n";
		
		
		$XMLFileName = "$SystemModuleKey.xml";
		$HTMLToolContent=stripslashes($strRSSHeader);
		$fp = fopen ($myModule_Path_HTMLFiles."/".$XMLFileName, "w+");
		fwrite($fp,str_replace("&gt;",">",str_replace("&lt;","<",$strRSSHeader)));
		fclose($fp);

		?>
            <form action="?" method="post" name="myForm" id="myForm">
              <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
              <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
              <input name="action" type="hidden" id="action">
              <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
              <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
              <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
              <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
              <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
              <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
            </form>
            <script language="JavaScript" type="text/JavaScript">document.myForm.submit(); </script>
            <? 
} 
?>
            <? 
####################################################################
if($action=="add") { 
	$HTMLToolContentBG = "#FFFFFF";
?>
		<? include("htmltool/header.php"); ?>
		<table width="98%" border="0" cellpadding="0" cellspacing="1">
		<form action="?" method="post" name="myReturnForm" id="myReturnForm">
		<input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
		<input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
		<input name="action" type="hidden" id="action" value="">
		<input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
		<input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
		<input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
		<input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
		<input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
		<input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
		</form>
		<form action="?" method="post" enctype="multipart/form-data" name="myForm" id="myForm">
		<input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
		<input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
		<input name="action" type="hidden" id="action" value="addnew">
		<input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
		<input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
		<input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
		<input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
		<input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
		<input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
		<tr> 
		<td class="table_form_bg1"><table width="100%" border="0" cellpadding="2" cellspacing="1">
		<tr> 
		<td height="24" colspan="2" align="center" class="menu_table_header">Add 
		New 
		<?=getMenuName($SystemMenuID)?>		</td>
		</tr>
		<tr> 
		<td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp; Header 
		Information </td>
		</tr>
		<? if($SystemModuleKey=="news_buy"){?>
		<tr>
		  <td height="22" align="right" class="table_col1">Group&nbsp; </td>
		  <td height="22" class="table_col2"><? 
			  include('config.php');
			   $sql = "SELECT * FROM ".$myModule_TableGroup;
			   $QueryG=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
			 ?>
			  <select  class="select"name="inputGroupID" id="inputGroupID">
			  <?
			    while($RowG=MYSQL_FETCH_ARRAY($QueryG)){
			  ?>
			  <option value="<?=$RowG[$myModule_TableGroup."_ID"]?>"><?=$RowG[$myModule_TableGroup."_Name"]?></option>
			  <? }?>
			  </select></td>
		  </tr>
		  <? }?>
		<tr> 
		                <td width="140" height="22" align="right" class="table_col1">Subject&nbsp;</td>
		<td height="22" class="table_col2"> <input name="inputSubject" type="text" class="input_left" id="inputSubject" size="80"></td>
		</tr>
		<tr> 
		                <td height="22" width="140" align="right" class="table_col1"> 
                          Title&nbsp; </td>
		<td height="22" class="table_col2"><textarea name="inputTitle" cols="78" rows="6" class="input_textarea" id="inputTitle"></textarea></td>
		</tr>
		<tr>
		  <td height="22" align="right" class="table_col1">News Date&nbsp; </td>
		  <td height="22" class="table_col2"><input name="inputNewsDate" type="text" class="input_center" id="inputNewsDate" value="<?
		$myTmpDate = substr($Row[$myModule_Table."_StartDate"],0,10);
		if($myTmpDate!="0000-00-00") { echo $myTmpDate; }
		?>" size="10" maxlength="10"> <input type="reset" class="button_normal" onClick="return showCalendar('inputNewsDate', 'y-mm-dd');" value=" ... "></td>
		  </tr>
		<tr>
		  <td height="22" align="right" class="table_col1">Resource/From</td>
		  <td height="22" class="table_col2"><input type="text" name="inputFrom" class="input_left" id="inputFrom" size="80"></td>
		  </tr>
		<tr>
		  <td height="22" align="right" class="table_col1">Link Url&nbsp; </td>
		  <td height="22" class="table_col2"><input type="text" name="inputUrl" class="input_left" id="inputUrl" size="80"></td>
		  </tr>
		<tr>
		  <td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp; Thumbnail Picture</td>
		  </tr>
		  <tr> 
		                <td width="140" height="22" align="right" class="table_col1"> 
                           Picture&nbsp; </td>
		                <td height="22" class="table_col2"><input name="inputThumbnailPicture" type="file" class="input_left" id="inputThumbnailPicture" contenteditable="false" size="35" accept="application/msexcel" onChange="
		myfile = this.value;
		if(myfile!='') {
		myfile = myfile.toLowerCase();
		Temp = myfile.charAt(myfile.length-4) + myfile.charAt(myfile.length-3) + myfile.charAt(myfile.length-2) + myfile.charAt(myfile.length-1);
		if(Temp=='.jpg' || Temp=='.gif' || Temp=='jpeg') {
		document.getElementById('PreviewImage').src=myfile;
		document.getElementById('PreviewImageText').innerHTML= document.getElementById('PreviewImage').width + 'x' + document.getElementById('PreviewImage').height + ' pixel';
		} else {
		alert('System allow to upload image files only.');
		this.focus();
		}
		} else {
		alert('Please click Browse button to select thumbnail picture file.');
		this.focus();
		}
		" onMouseOut="
		if(document.getElementById('PreviewImage').width>1 && document.getElementById('PreviewImage').height>1) {
		document.getElementById('PreviewImageText').innerHTML= document.getElementById('PreviewImage').width + 'x' + document.getElementById('PreviewImage').height + ' pixel';
		}
		"></td>
		</tr>
		<tr> 
		<td height="22" align="right" class="table_col1">&nbsp;</td>
		<td height="22" class="table_col2">&nbsp;</td>
		</tr>
		<tr> 
		<td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp; Attach Files</td>
		</tr>
		<tr style="display:none;">
		  <td height="22" align="right" class="table_col1">Scrolling&nbsp; </td>
		  <td height="22" class="table_col2">&nbsp;
		    <input name="inputMarquee" type="radio" id="inputMarquee" value="Enable">
		    Enable&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		    <input name="inputMarquee" type="radio" id="inputMarquee" value="Disable" checked>
		    Disable</td>
		  </tr>
		<tr>
		  <td height="22" align="right" valign="top" class="table_col1">Document Files&nbsp;</td>
		  <td height="22" class="table_col2"><table border="0" cellpadding="2" cellspacing="0" id="contentTable">
                            <tr>
                              <td><input name="inputFile[]" type="file" class="input_left" id="inputFile" size="35"></td>
                              <td align="center"><img src="../system/images/bullet/minus_disable.gif" width="11" height="11"></td>
                            </tr>
                            <tr>
                              <td align="right">&nbsp;</td>
                              <td align="center"><img src="../system/images/bullet/ico481.gif" width="16" height="10" onMouseOver="this.style.cursor='hand'" onClick="insertRow('contentTable')" alt="add"></td>
                            </tr>
                          </table>
						  <script language="JavaScript" type="text/JavaScript">
function insertRow(tableName) {
	var myObj=document.getElementById(tableName);
	var myNumRow = myObj.rows.length;
	var myNumCol = myObj.rows[0].cells.length;
	myObj.insertRow(myNumRow-1);
	for(i=0;i<myNumCol;i++) {
		myObj.rows[myNumRow-1].insertCell();
	}
	myObj.rows[myNumRow-1].cells[0].innerHTML = '<input name="inputFile[]" type="file" class="input_left" id="inputFile" size="35">';
	myObj.rows[myNumRow-1].cells[1].align  = "center";
	myObj.rows[myNumRow-1].cells[1].innerHTML = '<img src="../system/images/bullet/minus.gif" width="11" height="11" onMouseOver="this.style.cursor=\'hand\'" onClick="deleteRow(\'ContentTable\','+(myNumRow-1)+')">';

	formatTable(tableName);
}

function deleteRow(tableName,myRowDelete) {
	var myObj=document.getElementById(tableName);
	myObj.deleteRow(myRowDelete);
	formatTable(tableName);
}

function formatTable(tableName) {
	var myObj=document.getElementById(tableName);
	var myNumRow = myObj.rows.length;
	var myNumCol = myObj.rows[0].cells.length;
	if(myNumRow>2) {
		for(i=0;i<myNumRow-1;i++) {
			myObj.rows[i].cells[1].innerHTML = '<img src="../system/images/bullet/minus.gif" width="11" height="11" onMouseOver="this.style.cursor=\'hand\'" onClick="deleteRow(\'contentTable\','+i+')" alt="delete">';
		}
	} else {
		myObj.rows[0].cells[1].innerHTML = '<img src="../system/images/bullet/minus_disable.gif" width="11" height="11">';
	}
}

function funcMultipleAddNew(myListObj,myText) {
	if(myText!='') myListObj.options[myListObj.options.length] = new Option(myText,myText,0,false);
}
						  </script>
						  <span class="mytable_col2">
						  <script language="JavaScript" type="text/JavaScript">
restoreContentData();

function restoreContentData() {
//alert($inputFile[0]);
	<?
	for ($index=0;$index<count($inputFile)-1;$index++) {
		echo "insertRow('contentTable');";
	}
	
	for ($index=0;$index<count($inputFile);$index++) {
		$array_visible = "";
		if (count($inputFile)>1) $array_visible = "[".$index."]";
		echo "document.myForm.inputFile".$array_visible.".value = '".$inputFile[$index]."';";
	}
	?>
}

function insertRow(tableName) {
	var myObj=document.getElementById(tableName);
	var myNumRow = myObj.rows.length;
	var myNumCol = myObj.rows[0].cells.length;
	myObj.insertRow(myNumRow-1);
	for(i=0;i<myNumCol;i++) {
		myObj.rows[myNumRow-1].insertCell();
	}
	myObj.rows[myNumRow-1].cells[0].innerHTML = '<input name="inputFile[]" type="file" class="input_left" id="inputFile" size="35">';
	myObj.rows[myNumRow-1].cells[1].align  = "center";
	myObj.rows[myNumRow-1].cells[1].innerHTML = '<img src="../system/images/bullet/minus.gif" width="11" height="11" onMouseOver="this.style.cursor=\'hand\'" onClick="deleteRow(\'ContentTable\','+(myNumRow-1)+')">';

	formatTable(tableName);
}

function deleteRow(tableName,myRowDelete) {
	var myObj=document.getElementById(tableName);
	myObj.deleteRow(myRowDelete);
	formatTable(tableName);
}

function formatTable(tableName) {
	var myObj=document.getElementById(tableName);
	var myNumRow = myObj.rows.length;
	var myNumCol = myObj.rows[0].cells.length;
	if(myNumRow>2) {
		for(i=0;i<myNumRow-1;i++) {
			myObj.rows[i].cells[1].innerHTML = '<img src="../system/images/bullet/minus.gif" width="11" height="11" onMouseOver="this.style.cursor=\'hand\'" onClick="deleteRow(\'contentTable\','+i+')" alt="delete">';
		}
	} else {
		myObj.rows[0].cells[1].innerHTML = '<img src="../system/images/bullet/minus_disable.gif" width="11" height="11">';
	}
}

function AddList(fromList,toList) {
				var array_insert_value = new Array();
				var array_insert_name = new Array();
				var mysize = 0;
				for (i=0;i<fromList.options.length;i++) {
					if (fromList.options[i].selected) {
						found = false;
						for (j=0;j<toList.options.length;j++) {
							if (toList.options[j].value==fromList.options[i].value) found = true;
						}
						if (!found) {
							array_insert_name[mysize] = fromList.options[i].text;
							array_insert_value[mysize] = fromList.options[i].value;
							mysize++;
						}
					}
				}
				for (i=0;i<array_insert_value.length;i++) toList.options[toList.options.length] = new Option(array_insert_name[i],array_insert_value[i]);
			}
			function funcMultipleRemoveOnly(myListObj) {
				var Len = myListObj.options.length;
				
				if(Len>0) {
					for(var i=0;i<Len;i++) {
						if (myListObj.options[i]!=null && myListObj.options[i].selected) {
							myListObj.options[i--] = null;
							
						}
					}
				}
			}
									  </script>
						  </span></td>
		  </tr>
		<tr style="display:none;"> 
		<td width="140" height="22" align="right" valign="top" class="table_col1">Preview&nbsp;		</td>
		<td height="22" valign="top" class="table_col2">
		<div  style="height:100;width:435;overflow:auto" align="left" valign="middle">
		<table border="0" cellspacing="0" cellpadding="2" style="display:none;">
		<tr> 
		<td width="120" align="center" valign="middle"><img src="images/blank.gif" name="PreviewImage" id="PreviewImage"></td>
		<td align="right"><div id="PreviewImageText">&nbsp;</div></td>
		</tr>
		</table>
		</div></td>
		</tr>
		<tr>
		  <td height="22" colspan="2" valign="top" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp; Gallery</td>
		  </tr>
		<tr> 
		                <td width="140" height="22" align="right" valign="top" class="table_col1">
                          Picture &nbsp; </td>
		<td height="22" class="table_col2"><div id="GalleryFile"><div id="pic1"><input name="inputGallery_1" type="file" class="input_left" id="inputGallery_1" size="35" accept="application/msexcel" onChange="
		myfile = this.value;
		if(myfile!='') {
		myfile = myfile.toLowerCase();
		Temp = myfile.charAt(myfile.length-4) + myfile.charAt(myfile.length-3) + myfile.charAt(myfile.length-2) + myfile.charAt(myfile.length-1);
		if(Temp=='.jpg' || Temp=='.gif' || Temp=='jpeg') {
		document.getElementById('PreviewGallery').src=myfile;
		document.getElementById('PreviewGalleryText').innerHTML= document.getElementById('PreviewGallery').width + 'x' + document.getElementById('PreviewGallery').height + ' pixel';
		addGallery(1);
		} else {
		alert('System allow to upload image files only.');
		this.focus();
		}
		} else {
		alert('Please click Browse button to select thumbnail picture file.');
		this.focus();
		}
		" onMouseOut="
		if(document.getElementById('PreviewGallery').width>1 && document.getElementById('PreviewGallery').height>1) {
		document.getElementById('PreviewGalleryText').innerHTML= document.getElementById('PreviewGallery').width + 'x' + document.getElementById('PreviewGallery').height + ' pixel';
		}"></div>
		<div id="pic2"></div>
		<div id="pic3"></div>
		<div id="pic4"></div>
		<div id="pic5"></div>
		<div id="pic6"></div>
		<div id="pic7"></div>
		<div id="pic8"></div>
		<div id="pic9"></div>
		<div id="pic10"></div>
		</div></td>
		</tr>
		<tr >
		  <td height="22" align="right" valign="top" class="table_col1">&nbsp;</td>
		  <td height="22" valign="top" class="table_col2">System allow to upload image files only.( *.gif , *.jpg ) </td>
		  </tr>
		<tr style="display:none; "> 
		<td width="140" height="22" align="right" valign="top" class="table_col1">Preview&nbsp;		</td>
		<td height="22" valign="top" class="table_col2"><div  style="height:100;width:435;overflow:auto" align="left" valign="middle">
		<table border="0" cellspacing="0" cellpadding="2">
		<tr> 
		<td width="120" align="center" valign="middle"><img src="images/blank.gif" name="PreviewGallery" id="PreviewGallery"></td>
		<td align="right"><div id="PreviewGalleryText">&nbsp;</div></td>
		</tr>
		</table>
		</div></td>
		</tr>
		<tr>
		  <td height="22" colspan="2" valign="top" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp; Clip Video </td>
		  </tr>
		<tr>
		  <td height="10" align="right" class="table_col1">Video </td>
		  <td height="10" class="table_col2"><div id="vdo1">Name: <input name="inputVideoName_1" type="text" id="inputVideoName_1" size="20" class="input_left">&nbsp;&nbsp;<input name="inputVideo_1" type="file" class="input_left" id="inputVideo_1" contenteditable="false" size="35" accept="application/msexcel" onChange="
		myfile = this.value;
		if(myfile!='') {
		myfile = myfile.toLowerCase();
		Temp = myfile.charAt(myfile.length-4) + myfile.charAt(myfile.length-3) + myfile.charAt(myfile.length-2) + myfile.charAt(myfile.length-1);
		if(Temp=='.flv' || Temp=='.wmv') {
		addVideo(1);
		} else {
		alert('System allow to upload video files only(*.flv or *.wmv).');
		this.focus();
		}
		} else {
		alert('Please click Browse button to select video file.');
		this.focus();
		} 
		">
		</div>
		<div id="vdo2"></div>
		<div id="vdo3"></div>
		<div id="vdo4"></div>
		<div id="vdo5"></div>
		<div id="vdo6"></div>
		<div id="vdo7"></div>
		<div id="vdo8"></div>
		<div id="vdo9"></div>
		<div id="vdo10"></div>				</td>
		  </tr>
		<tr>
		  <td height="11" align="right" class="table_col1">&nbsp;</td>
		  <td height="11" class="table_col2">System allow to upload video files only(*.flv or *.wmv).&nbsp;</td>
		  </tr>
		  <tr>
		  <td height="22" colspan="2" valign="top" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp; Tag</td>
		  </tr>
		<tr> 
		<td height="22" colspan="2" class="table_col2"><br>		  <table width="80%" border="0" align="center" cellpadding="2" cellspacing="0">
                              <tr> 
                                <td align="center" valign="top"><table border="0" cellspacing="0" cellpadding="0">
                                    <tr> 
                                      <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
                                          <tr> 
                                            <td height="20" align="center" bgcolor="#7093C2"><strong><font color="#FFFFFF">Tag</font></strong></td>
                                          </tr>
                                        </table>
                                        <select name="inputSelectAssign[]" size="8" multiple id="inputSelectAssign" style="width:150">
									    </select></td>
                                      <td align="center"><table border="0" cellspacing="0" cellpadding="0">
                                          <tr> 
                                            <td><input type="button" name="Button" value="<< Add" class="button_80" onClick="
									AddList(document.myForm.inputListUserAssign,document.myForm.inputSelectAssign);
									"></td>
                                          </tr>
                                          <tr> 
                                            <td height="50">&nbsp;</td>
                                          </tr>
                                          <tr> 
                                            <td><input type="button" name="Button" value="Delete >>" class="button_80" onClick="
									  var found = 0;
									  for (i=0;i<document.myForm.inputSelectAssign.options.length;i++) {
										if (document.myForm.inputSelectAssign.options[i].selected) found = 1;
									  }
									  if (found==1) {
										  funcMultipleRemoveOnly(document.myForm.inputSelectAssign);
									  }
									"></td>
                                          </tr>
                                        </table></td>
                                      <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
                                          <tr> 
                                            <td height="20" align="center" bgcolor="#7093C2"><strong><font color="#FFFFFF">Tag ทั้งหมด</font></strong></td>
                                          </tr>
                                        </table>
                                        <select name="inputListUserAssign[]" size="8" multiple id="inputListUserAssign" style="width:150">
                                          <?
										$sql = "SELECT * FROM ".$myModule_TableTag." ORDER BY ".$myModule_TableTag."_Detail  ASC";											
										$Query_Tag = mysql_query($sql);
										while ($Row_Tag = mysql_fetch_array($Query_Tag)) { ?>
                                          <option value="<?=$Row_Tag[$myModule_TableTag."_Detail"]?>" >
                                          <?=$Row_Tag[$myModule_TableTag."_Detail"]?>
                                          </option>
                                          <? } ?>
                                        </select></td>
                                    </tr>
                                  </table>                                                                    </td>
                                <td align="center" valign="bottom" id="previewPhotoArea"><input type="button" name="Button32" value="Delete >>" class="button_80" onClick="
									  var found = 0;
									  for (i=0;i<document.myForm.inputListUserAssign.options.length;i++) {
										if (document.myForm.inputListUserAssign.options[i].selected) found = 1;
									  }
									  if (found==1) {
										  funcMultipleRemoveOnly(document.myForm.inputListUserAssign);
									  }
									"></td>
                              </tr>
                              <tr>
                                <td align="right" valign="top"><input name="inputEmail" type="text" class="input_left" id="inputEmail" size="22">
                                &nbsp;</td>
                                <td align="center" id="previewPhotoArea"><input type="button" name="Button2" value="<< Add" class="button_80" onClick="
									funcMultipleAddNew( elements['inputSelectAssign[]'] , inputEmail.value ); 
									"></td>
                              </tr>
                              <tr>
                                <td align="center" valign="top">&nbsp;</td>
                                <td align="center" id="previewPhotoArea">&nbsp;</td>
                              </tr>
                            </table></td>
		</tr>
		<tr> 
		<td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Content</td>
		</tr>
		<tr align="center" valign="top"> 
		<td colspan="2" class="table_col2"><table width="100%" height="500" border="0" align="center" cellpadding=1 cellspacing=1  bordercolorlight="#000000" bordercolordark="#E0E0E0" bgcolor="#AAAAAA" class="table_border" id="htmltool_table">
          <tr>
            <td height="50" align="left" class="table_col2">
              <? include("htmltool/toolbar.php"); ?>            </td>
          </tr>
          <tr>
            <td align="center" class="table_col2">
              <? include("htmltool/textarea.php"); ?>            </td>
          </tr>
        </table><script language="JavaScript" type="text/JavaScript">
fnInit(idContent);
</script>		  <!-----script language="JavaScript" type="text/JavaScript">
		fnInit(idContent);
		</script------------------></td>
		</tr>
		<tr align="left" valign="top"> 
		<td colspan="2" align="right" class="table_col2">Use <span class="text_hilight">Shift+Enter</span> 
		to make a new row.</td>
		</tr>
		<tr> 
		<td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Expiration</td>
		</tr>
		<tr> 
		<td height="22" align="right" class="table_col1">Start 
		Date&nbsp; </td>
		<td height="22" class="table_col2"><input name="inputStartDate" type="text" class="input_center" id="inputStartDate" size="10" maxlength="10"> 
		<input type="reset" class="button_normal" onClick="return showCalendar('inputStartDate', 'y-mm-dd');" value=" ... "></td>
		</tr>
		<tr> 
		<td height="22" align="right" class="table_col1">Expire 
		Date&nbsp; </td>
		<td height="22" class="table_col2"><input name="inputExpireDate" type="text" class="input_center" id="inputExpireDate" size="10" maxlength="10"> 
		<input type="reset" class="button_normal" onClick="return showCalendar('inputExpireDate', 'y-mm-dd');" value=" ... "></td>
		</tr>
		<tr> 
		<td height="22" align="right" class="table_col1">&nbsp;</td>
		<td height="22" class="table_col2">Keep blank to alway 
		on.</td>
		</tr>
		</table>
		<table width="100%" height="24" border="0" cellpadding="3" cellspacing="0" class="table_button_bottom">
		<tr align="right"> 
		<td height="30" colspan="4" align="center" class="table_footer"> 
		<table width="60%" border="0" cellspacing="0" cellpadding="2">
		<tr align="left"> 
		<td width="25%"><script language="JavaScript" type="text/JavaScript">
		function isBlank(myObj) { if(myObj.value=='') { return true; } return false; }
		function verifySubmit() {
		with(document.myForm) {
		if(isBlank(inputSubject)) {	inputSubject.focus(); return false; }
		//if(isBlank(inputTitle)) {	inputTitle.focus(); return false; }
		//if(isBlank(inputThumbnailPicture)) {	inputThumbnailPicture.focus(); return false; }
		myfile = inputThumbnailPicture.value;
		if(myfile!='') {
		myfile = myfile.toLowerCase();
		Temp = myfile.charAt(myfile.length-4) + myfile.charAt(myfile.length-3) + myfile.charAt(myfile.length-2) + myfile.charAt(myfile.length-1);
		if(Temp=='.jpg' || Temp=='.gif' || Temp=='jpeg') {
		document.getElementById('PreviewImage').src=myfile;
		document.getElementById('PreviewImageText').innerHTML= document.getElementById('PreviewImage').width + 'x' + document.getElementById('PreviewImage').height + ' pixel';
		} else {
		alert('System allow to upload image files only.');
		document.myForm.inputThumbnailPicture.focus();
		return false; 
		
		}
		}
					
		}
		
		for (var i=0;i<document.myForm.inputSelectAssign.length;i++) {
						document.myForm.inputSelectAssign.options[i].selected = true;
					}
		fnSave();
		document.myForm.submit();
		}
		</script> <input name="btAdd" type="button" class="button_80" id="btAdd" value="Add" onClick="verifySubmit();"> 
		</td>
		<td width="25%" align="left">
		<input name="btReset2" type="reset" class="button_80" id="btReset2" value="Reset" onClick="
		document.getElementById('PreviewImage').src='images/blank.gif';
		document.getElementById('PreviewImageText').innerHTML='';
		">
		</td>
		<td> <input name="btCalcel" type="button" class="button_80" id="btCalcel" onClick="
		if(confirm('Are you sure to return to list?')) {
		document.myReturnForm.submit();
		}
		" value="Cancel"> </td>
		</tr>
		</table></td>
		</tr>
		</table></td>
		</tr>
		</form>
		</table>
		<br>
		<br>
		<br>
		<br>
		<br>
		<br>
		<br>
		<? 
#########################################################
} else if ($action=="edit") { 
	if(!isset($myCheckBoxID))
	$myCheckBoxID=0;
	for($i=1;$i<=$TotalCheckBoxID;$i++) {
		$myVar="CheckBoxID".$i;
		if(strlen($$myVar)>0) {
			$myCheckBoxID=$$myVar;
		}
	}
	$sql="SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ID=".$myCheckBoxID;
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
	$Row=MYSQL_FETCH_ARRAY($Query);
	$HTMLsrcSTR=$Row[$myModule_Table."_HTMLFileName"];
	$HTMLsrc = $myModule_Path_HTMLFiles."/".$Row[$myModule_Table."_HTMLFileName"];
	//debug($HTMLsrc );
	$HTMLToolContentBG = $Row[$myModule_Table."_BackgroudColor"];
?>
		<? include("htmltool/header.php"); ?>
		<table width="98%" border="0" cellpadding="0" cellspacing="1">
		<form action="?" method="post" name="myReturnForm" id="myReturnForm">
		<input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
		<input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
		<input name="action" type="hidden" id="action">
		<input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
		<input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
		<input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
		<input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
		<input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
		<input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
		</form>
		<form action="?" method="post" enctype="multipart/form-data" name="myForm" id="myForm">
		<input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
		<input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
		<input name="action" type="hidden" id="action" value="update">
		<input type="hidden" id="PID" name="PID" value="">
		<input type="hidden" id="NID" name="NID" value="">
		<input type="hidden" id="FileName" name="FileName" value="">
		<input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
		<input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
		<input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
		<input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
		<input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
		<input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
		<input name="CheckBoxID1" type="hidden" id="CheckBoxID1" value="<?=$myCheckBoxID?>">
		<tr> 
		<td class="table_form_bg1">
		<table width="100%" border="0" cellpadding="2" cellspacing="1">
		<tr> 
		<td height="24" colspan="2" align="center" class="menu_table_header">Edit 
		<?=getMenuName($SystemMenuID)?>		</td>
		</tr>
		<tr> 
		<td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Header 
		Information </td>
		</tr>
		<? if($SystemModuleKey=="news_buy"){?>
		<tr>
		  <td height="22" align="right" class="table_col1">Group&nbsp; </td>
		  <td width="480" height="22" class="table_col2"><? 
			  include('config.php');
			   $sql = "SELECT * FROM ".$myModule_TableGroup;
			   $QueryG=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
			 ?>
			  <select  class="select"name="inputGroupID" id="inputGroupID">
			  <?
			    while($RowG=MYSQL_FETCH_ARRAY($QueryG)){
			  ?>
			  <option value="<?=$RowG[$myModule_TableGroup."_ID"]?>" <? if($RowG[$myModule_TableGroup."_ID"]==$Row[$myModule_Table."_GID"]){ echo "selected"; }?>><?=$RowG[$myModule_TableGroup."_Name"]?></option>
			  <? }?>
			  </select></td>
		  </tr>
		  <? }?>
		<tr> 
                        <td width="92" height="22" align="right" class="table_col1"><span class="text_require">*</span> 
                          Subject&nbsp;</td>
		<td height="22" class="table_col2"> <input name="inputSubject" type="text" class="input_left" id="inputSubject" value="<?=$Row[$myModule_Table."_Subject"]?>" size="80"></td>
		</tr>
		<tr> 
		                <td width="92" height="22" align="right" class="table_col1"> 
                          Title&nbsp; </td>
		                <td height="22" class="table_col2"><textarea name="inputTitle" cols="78" rows="6" class="input_textarea" id="inputTitle"><?=$Row[$myModule_Table."_Title"]?></textarea></td>
		</tr>
		<tr>
		  <td height="22" align="right" class="table_col1">News Date&nbsp; </td>
		  <td height="22" class="table_col2"><input name="inputNewsDate" type="text" class="input_center" id="inputNewsDate" value="<?
		$myTmpDate = substr($Row[$myModule_Table."_CreateDate"],0,10);
		if($myTmpDate!="0000-00-00") { echo $myTmpDate; }
		?>" size="10"> <input type="reset" class="button_normal" onClick="return showCalendar('inputNewsDate', 'y-mm-dd');" value=" ... "></td>
		  </tr>
		<tr>
		  <td height="22" align="right" class="table_col1">Resource/From</td>
		  <td height="22" class="table_col2"><input type="text" name="inputFrom" class="input_left" id="inputFrom" size="80" value="<?=$Row[$myModule_Table."_From"]?>"></td>
		  </tr>
		<tr>
		  <td height="22" align="right" class="table_col1">Link Url&nbsp;&nbsp;&nbsp; </td>
		  <td height="22" class="table_col2"><input type="text" name="inputUrl" class="input_left" id="inputUrl" size="80" value="<?=$Row[$myModule_Table."_Url"]?>"></td>
		  </tr>
		<tr> 
		<td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11"> Attach &nbsp;Files</td>
		</tr>
		<tr>
		  <td align="right" valign="top" class="table_col1">Document Files</td>
		  <td class="table_col2"><table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="2">
            <tr>
              <td width="50%"><input name="inputTypeFile" type="radio" id="inputTypeFile1" onClick="document.getElementById('File1').style.display='';document.getElementById('File2').style.display='none';" value="insert" checked>
            <label for="inputTypeFile1" style="cursor:pointer;">เพิ่มไฟล์ ใหม่</label></td>
              </tr>
            <tr>
              <td id="File1"><?
		$sqlFile = "SELECT * FROM ".$myModule_Table_FileUploadOnNews." WHERE ".$myModule_Table_FileUploadOnNews."_NewsID = '".$myCheckBoxID."'";
		$QueryFile=MYSQL_DB_QUERY($System_DataBase_Name,$sqlFile) or die(mysql_error());				
		while ($RowFile=MYSQL_FETCH_ARRAY($QueryFile)){
						$LinkRelativePath = $myModule_Path_FileUpload."/".$RowFile[$myModule_Table_FileUploadOnNews."_FileUpload"];
						$DownloadFile = $RowFile[$myModule_Table_FileUploadOnNews."_FileUpload"];
						$ImageType = strstr($DownloadFile,'.');
						if($ImageType==".pdf"){
							$TypeImgFile="../../images/bullet/pdf.gif";
						}elseif($ImageType==".txt"){
							$TypeImgFile="../../images/bullet/file.gif";
						}elseif($ImageType==".xls"){
							$TypeImgFile="../../images/bullet/excel.gif";
						}elseif($ImageType==".ppt"){
							$TypeImgFile="../../images/bullet/pp.gif";
						}elseif($ImageType==".rtf" || $ImageType==".doc"){
							$TypeImgFile="../../images/bullet/word.gif";
						}elseif($ImageType==".rar"){
							$TypeImgFile="../../images/bullet/rar.gif";
						}else{
							$TypeImgFile="../../images/bullet/application.gif";
						}
		?><a href="<?=$LinkRelativePath?>" target="_blank"><strong><br>
                &nbsp;<img src="<?=$TypeImgFile?>" border="0">&nbsp;
                <?=$RowFile[$myModule_Table_FileUploadOnNews."_UploadFileName"];?>
                </strong></a><a href="#" onClick="if(confirm('Are you sure to delete this file?'))
						{
							document.myForm.FileName.value='<?=$RowFile[$myModule_Table_FileUploadOnNews."_FileUpload"]?>';
							document.myForm.PID.value='<?=$RowFile[$myModule_Table_FileUploadOnNews."_NewsID"]?>';
							document.myForm.NID.value='<?=$Row[$myModule_Table."_ID"]?>';
							document.myForm.action.value='deleteFile';
							document.myForm.submit();
						}
					"><img src="../images/icon/ico417.gif" border=0 alt="Delete"></a>&nbsp;&nbsp;
                <? }?><br>
                <table border="0" cellpadding="2" cellspacing="0" id="contentTable">
                  <tr>
                    <td><input name="inputFile[]" type="file" class="input_left" id="inputFile[]" size="35"></td>
                    <td align="center"><img src="../system/images/bullet/minus_disable.gif" width="11" height="11"></td>
                  </tr>
                  <tr>
                    <td align="right">&nbsp;</td>
                    <td align="center"><img src="../system/images/bullet/ico481.gif" width="16" height="10" onMouseOver="this.style.cursor='hand'" onClick="insertRow('contentTable')" alt="add"></td>
                  </tr>
                </table>
                <span class="mytable_col2">
                <script language="JavaScript" type="text/JavaScript">
restoreContentData();

function restoreContentData() {
//alert($inputFile[0]);
	<?
	for ($index=0;$index<count($inputFile)-1;$index++) {
		echo "insertRow('contentTable');";
	}
	
	for ($index=0;$index<count($inputFile);$index++) {
		$array_visible = "";
		if (count($inputFile)>1) $array_visible = "[".$index."]";
		echo "document.myForm.inputFile".$array_visible.".value = '".$inputFile[$index]."';";
	}
	?>
}

function insertRow(tableName) {
	var myObj=document.getElementById(tableName);
	var myNumRow = myObj.rows.length;
	var myNumCol = myObj.rows[0].cells.length;
	myObj.insertRow(myNumRow-1);
	for(i=0;i<myNumCol;i++) {
		myObj.rows[myNumRow-1].insertCell();
	}
	myObj.rows[myNumRow-1].cells[0].innerHTML = '<input name="inputFile[]" type="file" class="input_left" id="inputFile" size="35">';
	myObj.rows[myNumRow-1].cells[1].align  = "center";
	myObj.rows[myNumRow-1].cells[1].innerHTML = '<img src="../system/images/bullet/minus.gif" width="11" height="11" onMouseOver="this.style.cursor=\'hand\'" onClick="deleteRow(\'ContentTable\','+(myNumRow-1)+')">';

	formatTable(tableName);
}

function deleteRow(tableName,myRowDelete) {
	var myObj=document.getElementById(tableName);
	myObj.deleteRow(myRowDelete);
	formatTable(tableName);
}

function formatTable(tableName) {
	var myObj=document.getElementById(tableName);
	var myNumRow = myObj.rows.length;
	var myNumCol = myObj.rows[0].cells.length;
	if(myNumRow>2) {
		for(i=0;i<myNumRow-1;i++) {
			myObj.rows[i].cells[1].innerHTML = '<img src="../system/images/bullet/minus.gif" width="11" height="11" onMouseOver="this.style.cursor=\'hand\'" onClick="deleteRow(\'contentTable\','+i+')" alt="delete">';
		}
	} else {
		myObj.rows[0].cells[1].innerHTML = '<img src="../system/images/bullet/minus_disable.gif" width="11" height="11">';
	}
}
function funcMultipleAddNew(myListObj,myText) {
	if(myText!='') myListObj.options[myListObj.options.length] = new Option(myText,myText,0,false);
}
						  </script>
                </span></td>
              </tr>
          </table>
					    <script language="JavaScript" type="text/JavaScript">
restoreContentData();

function restoreContentData() {
//alert($inputFile[0]);
	<?
	for ($index=0;$index<count($inputFile)-1;$index++) {
		echo "insertRow('contentTable');";
	}
	
	for ($index=0;$index<count($inputFile);$index++) {
		$array_visible = "";
		if (count($inputFile)>1) $array_visible = "[".$index."]";
		echo "document.myForm.inputFile".$array_visible.".value = '".$inputFile[$index]."';";
	}
	?>
}

function insertRow(tableName) {
	var myObj=document.getElementById(tableName);
	var myNumRow = myObj.rows.length;
	var myNumCol = myObj.rows[0].cells.length;
	myObj.insertRow(myNumRow-1);
	for(i=0;i<myNumCol;i++) {
		myObj.rows[myNumRow-1].insertCell();
	}
	myObj.rows[myNumRow-1].cells[0].innerHTML = '<input name="inputFile[]" type="file" class="input_left" id="inputFile" size="35">';
	myObj.rows[myNumRow-1].cells[1].align  = "center";
	myObj.rows[myNumRow-1].cells[1].innerHTML = '<img src="../system/images/bullet/minus.gif" width="11" height="11" onMouseOver="this.style.cursor=\'hand\'" onClick="deleteRow(\'ContentTable\','+(myNumRow-1)+')">';

	formatTable(tableName);
}

function deleteRow(tableName,myRowDelete) {
	var myObj=document.getElementById(tableName);
	myObj.deleteRow(myRowDelete);
	formatTable(tableName);
}

function formatTable(tableName) {
	var myObj=document.getElementById(tableName);
	var myNumRow = myObj.rows.length;
	var myNumCol = myObj.rows[0].cells.length;
	if(myNumRow>2) {
		for(i=0;i<myNumRow-1;i++) {
			myObj.rows[i].cells[1].innerHTML = '<img src="../system/images/bullet/minus.gif" width="11" height="11" onMouseOver="this.style.cursor=\'hand\'" onClick="deleteRow(\'contentTable\','+i+')" alt="delete">';
		}
	} else {
		myObj.rows[0].cells[1].innerHTML = '<img src="../system/images/bullet/minus_disable.gif" width="11" height="11">';
	}
}

function AddList(fromList,toList) {
				var array_insert_value = new Array();
				var array_insert_name = new Array();
				var mysize = 0;
				for (i=0;i<fromList.options.length;i++) {
					if (fromList.options[i].selected) {
						found = false;
						for (j=0;j<toList.options.length;j++) {
							if (toList.options[j].value==fromList.options[i].value) found = true;
						}
						if (!found) {
							array_insert_name[mysize] = fromList.options[i].text;
							array_insert_value[mysize] = fromList.options[i].value;
							mysize++;
						}
					}
				}
				for (i=0;i<array_insert_value.length;i++) toList.options[toList.options.length] = new Option(array_insert_name[i],array_insert_value[i]);
			}
			function funcMultipleRemoveOnly(myListObj) {
				var Len = myListObj.options.length;
				if(Len>0) {
					for(var i=0;i<Len;i++) {
						if (myListObj.options[i]!=null && myListObj.options[i].selected) {
							myListObj.options[i--] = null;
						}
					}
				}
			}</script></td>
		  </tr>
		<tr>
		  <td height="22" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11"> Thumbnail &nbsp;Picture</td>
		  </tr>
		<tr> 
		<td width="92" height="22" align="right" valign="top" class="table_col1">		Picture&nbsp; </td>
		<td height="22" class="table_col2"><?
				if($Row[$myModule_Table."_PictureFile"]!=""){
				echo "<table border=0><tr>";
				echo "<td align=right valign=bottom background=".$myModule_FullPath_ThumbnailPicture."/".$Row[$myModule_Table."_PictureFile"]." width=100 height=100>";
				echo " <a href='#' onclick='
					if(confirm(\"Are you sure to delete this picture?\"))
						{
							document.myForm.PID.value=\"".$Row[$myModule_Table."_ID"]."\";
							document.myForm.NID.value=\"".$Row[$myModule_Table."_ID"]."\";
							document.myForm.action.value=\"deletePicture2\";
							document.myForm.submit();
						}
					'><img src='../images/icon/ico417.gif' border=0 alt='Delete'></a>";
					echo "</td>";
					echo "</tr>";
					echo "</table>";
					}
		?>
		  <br>	
		      <input name="inputThumbnailPicture" type="file" class="input_left" id="inputThumbnailPicture" size="35" contenteditable="false" accept="application/msexcel" onChange="
				myfile = document.myForm.inputThumbnailPicture.value;
				if(myfile!='') {
				myfile = myfile.toLowerCase();
				Temp = myfile.charAt(myfile.length-4) + myfile.charAt(myfile.length-3) + myfile.charAt(myfile.length-2) + myfile.charAt(myfile.length-1);
				if(Temp=='.jpg' || Temp=='.gif' || Temp=='jpeg') {
				document.getElementById('PreviewNewImage').src=myfile;
				document.getElementById('PreviewNewImageText').innerHTML= document.getElementById('PreviewNewImage').width + 'x' + document.getElementById('PreviewNewImage').height + ' pixel';
				} else {
				alert('System allow to upload image files only.');
				document.myForm.inputThumbnailPicture.focus();
				}
				} else {
				alert('Please click Browse button to select thumbnail picture file.');
				document.myForm.inputThumbnailPicture.focus();
				}
				" value="Preview" onMouseOut="
				if(document.getElementById('PreviewNewImage').width>1 && document.getElementById('PreviewNewImage').height>1) {
				document.getElementById('PreviewNewImageText').innerHTML= document.getElementById('PreviewNewImage').width + 'x' + document.getElementById('PreviewNewImage').height + ' pixel';
				}
		"></td></tr>
		<tr> 
		<td height="22" align="right" class="table_col1">&nbsp;</td>
		<td height="22" class="table_col2">Recommended to use a picture file size as 102x64 pixel </td>
		</tr>
		<tr style="display:none;"> 
		<td width="92" height="22" align="right" valign="top" class="table_col1">&nbsp;</td>
		<td height="22" valign="top" class="table_col2"><div  style="height:100;width:435;overflow:auto" align="left" valign="middle">
		<table border="0" cellspacing="0" cellpadding="2">
		<tr> 
		<td width="120" align="center" valign="middle"><img src="../images/blank.gif" name="PreviewImage" border="0" id="PreviewNewImage"></td>
		<td align="right"><div id="PreviewNewImageText">&nbsp;</div></td>
		</tr>
		</table>
		</div></td>
		</tr>
		<tr>
		  <td height="22" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp; Gallery<a href="<?=$LinkRelativePath?>" target="_blank"><strong>
		    <?=$RowFile[$myModule_Table_FileUploadOnNews."_FileUpload"];?>
		  </strong></a></td>
		  </tr>
		<tr>
		<td width="92" height="22" align="right" valign="top" class="table_col1">
                          Gallery&nbsp; </td>
		<td align="left" valign="top" class="table_col2">
		<?
			$sqlGallery="SELECT * FROM ".$myModule_Table_Gallery." WHERE ".$myModule_Table_Gallery."_NewsID='".$Row[$myModule_Table."_ID"]."' AND ".$myModule_Table_Gallery."_Status='Enable'";
			$resultGallery=mysql_query($sqlGallery);
			echo "<table border=0><tr>";
			$i=1;
			while($record=mysql_fetch_array($resultGallery)){
				echo "<td align=right valign=bottom background=".$myModule_Path_GalleryThumbnail."/".$record[$myModule_Table_Gallery."_Thumbnail"]." width=100 height=100>";
				echo "<a href=".$myModule_Path_Gallery."/".$record[$myModule_Table_Gallery."_Picture"]." target='_blank'><img src='../images/icon/ico416.gif' border=0 alt='View'></a>";
				echo " <a href='#' onclick='
					if(confirm(\"Are you sure to delete this picture?\"))
						{
							document.myForm.PID.value=\"".$record[$myModule_Table_Gallery."_ID"]."\";
							document.myForm.NID.value=\"".$Row[$myModule_Table."_ID"]."\";
							document.myForm.action.value=\"deletePicture\";
							document.myForm.submit();
						}
					'><img src='../images/icon/ico417.gif' border=0 alt='Delete'></a>";
				echo "</td>";
				$i++;
				if($i==6){
					$i=1;
					echo "</tr><tr>";
				}
			}
			echo "</tr></table>";
		?></td></tr>
		<tr> 
		                <td width="92" height="22" align="right" valign="top" class="table_col1">                          </td>
		<td height="22" class="table_col2">
		<div id="GalleryFile">
		<div id="pic1"><input name="inputGallery_1" type="file" class="input_left" id="inputGallery_1" size="35" accept="application/msexcel" onChange="
		myfile = this.value;
		if(myfile!='') {
		myfile = myfile.toLowerCase();
		Temp = myfile.charAt(myfile.length-4) + myfile.charAt(myfile.length-3) + myfile.charAt(myfile.length-2) + myfile.charAt(myfile.length-1);
		if(Temp=='.jpg' || Temp=='.gif' || Temp=='jpeg') {
		document.getElementById('PreviewGallery').src=myfile;
		document.getElementById('PreviewGalleryText').innerHTML= document.getElementById('PreviewGallery').width + 'x' + document.getElementById('PreviewGallery').height + ' pixel';
		addGallery(1);
		} else {
		alert('System allow to upload image files only.');
		this.focus();
		}
		} else {
		alert('Please click Browse button to select thumbnail picture file.');
		this.focus();
		}
		" onMouseOut="
		if(document.getElementById('PreviewGallery').width>1 && document.getElementById('PreviewGallery').height>1) {
		document.getElementById('PreviewGalleryText').innerHTML= document.getElementById('PreviewGallery').width + 'x' + document.getElementById('PreviewGallery').height + ' pixel';
		}"></div>
		<div id="pic2"></div>
		<div id="pic3"></div>
		<div id="pic4"></div>
		<div id="pic5"></div>
		<div id="pic6"></div>
		<div id="pic7"></div>
		<div id="pic8"></div>
		<div id="pic9"></div>
		<div id="pic10"></div>
		</div></td>
		</tr>
		<tr> 
		<td height="22" align="right" class="table_col1">&nbsp;</td>
		<td height="22" class="table_col2">Keep blank if you don't want to add new picture into gallery.</td>
		</tr>
		<tr style="display:none;"> 
		<td width="92" height="22" align="right" valign="top" class="table_col1">Preview&nbsp;		</td>
		<td height="22" valign="top" class="table_col2"><div  style="height:100;width:435;overflow:auto" align="left" valign="middle">
		<table border="0" cellspacing="0" cellpadding="2">
		<tr> 
		<td width="120" align="center" valign="middle"><img src="images/blank.gif" name="PreviewGallery" id="PreviewGallery"></td>
		<td align="right"><div id="PreviewGalleryText">&nbsp;</div></td>
		</tr>
		</table>
		</div></td>
		</tr>
				<tr>
		  <td height="22" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp; Clip Video </td>
		  </tr>
		<tr>
		  <td height="22" align="right" valign="top" class="table_col1">Video </td>
		 <td height="22" class="table_col2">
		 <?
			$sqlVideo="SELECT * FROM ".$myModule_Table_Video." WHERE ".$myModule_Table_Video."_NewsID='".$Row[$myModule_Table."_ID"]."' AND ".$myModule_Table_Video."_Status='Enable'";
			$resultVideo=mysql_query($sqlVideo);
			while($record=mysql_fetch_array($resultVideo)){
				echo "<a href='#' onClick=\"Popup('popupVideo','popup_vdo.php?VideoSRc=".$myModule_Path_Video."/".$record[$myModule_Table_Video."_Video"]."',400,300,1);\">";
				echo $record[$myModule_Table_Video."_Name"];
				echo "</a>&nbsp;&nbsp;&nbsp;";
				echo " <a href='#' onclick='
					if(confirm(\"Are you sure to delete this video?\"))
						{
							document.myForm.PID.value=\"".$record[$myModule_Table_Video."_ID"]."\";
							document.myForm.NID.value=\"".$Row[$myModule_Table."_ID"]."\";
							document.myForm.action.value=\"deleteVideo\";
							document.myForm.submit();
						}
					'><img src='../images/icon/ico417.gif' border=0 alt='Delete'></a>";
				echo "</br>";
			}
		?></td>
		 </tr>
		 <tr>
		  <td height="22" align="right" class="table_col1"></td>
		  <td height="22" class="table_col2"><div id="vdo1">Name: <input name="inputVideoName_1" type="text" id="inputVideoName_1" size="20" class="input_left">&nbsp;&nbsp;<input name="inputVideo_1" type="file" class="input_left" id="inputVideo_1" contenteditable="false" size="35" accept="application/msexcel" onChange="
		myfile = this.value;
		if(myfile!='') {
		myfile = myfile.toLowerCase();
		Temp = myfile.charAt(myfile.length-4) + myfile.charAt(myfile.length-3) + myfile.charAt(myfile.length-2) + myfile.charAt(myfile.length-1);
		if(Temp=='.flv' || Temp=='.wmv') {
			addVideo(1);
		} else {
		alert('System allow to upload video files only(*.flv or *.wmv).');
		this.focus();
		}
		} else {
		alert('Please click Browse button to select video file.');
		this.focus();
		}
		">
		</div>
		<div id="vdo2"></div>
		<div id="vdo3"></div>
		<div id="vdo4"></div>
		<div id="vdo5"></div>
		<div id="vdo6"></div>
		<div id="vdo7"></div>
		<div id="vdo8"></div>
		<div id="vdo9"></div>
		<div id="vdo10"></div></td>
		  </tr>
		  <tr>
		  <td height="22" colspan="2" valign="top" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp; Tag</td>
		  </tr>
		<tr> 
		<td height="22" colspan="2" class="table_col2"><table width="80%" border="0" align="center" cellpadding="2" cellspacing="0">
                              <tr> 
                                <td align="center" valign="top"><table border="0" cellspacing="0" cellpadding="0">
                                    <tr> 
                                      <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
                                          <tr> 
                                            <td height="20" align="center" bgcolor="#7093C2"><strong><font color="#FFFFFF">Tag</font></strong></td>
                                          </tr>
                                        </table>
                                        <select name="inputSelectAssign[]" size="8" multiple id="inputSelectAssign" style="width:150">
									    </select></td>
                                      <td align="center"><table border="0" cellspacing="0" cellpadding="0">
                                          <tr> 
                                            <td><input type="button" name="Button" value="<< Add" class="button_80" onClick="
									AddList(document.myForm.inputListUserAssign,document.myForm.inputSelectAssign);
									"></td>
                                          </tr>
                                          <tr> 
                                            <td height="50">&nbsp;</td>
                                          </tr>
                                          <tr> 
                                            <td><input type="button" name="Button" value="Delete >>" class="button_80" onClick="
									  var found = 0;
									  for (i=0;i<document.myForm.inputSelectAssign.options.length;i++) {
										if (document.myForm.inputSelectAssign.options[i].selected) found = 1;
									  }
									  if (found==1) {
										  funcMultipleRemoveOnly(document.myForm.inputSelectAssign);
									  }
									"></td>
                                          </tr>
                                        </table></td>
                                      <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
                                          <tr> 
                                            <td height="20" align="center" bgcolor="#7093C2"><strong><font color="#FFFFFF">Tag ทั้งหมด</font></strong></td>
                                          </tr>
                                        </table>
                                        <select name="inputListUserAssign[]" size="8" multiple id="inputListUserAssign" style="width:150">
                                          <?
										  	$sql = "SELECT * FROM ".$myModule_TableTag." ORDER BY ".$myModule_TableTag."_Detail  ASC";
											$Query_Tag = mysql_query($sql);
										 ?>
                                          <? while ($Row_Tag = mysql_fetch_array($Query_Tag)) { ?>
                                          <option value="<?=$Row_Tag[$myModule_TableTag."_Detail"]?>" >
                                          <?=$Row_Tag[$myModule_TableTag."_Detail"]?>
                                          </option>
                                          <? } ?>
                                        </select></td>
                                    </tr>
                                  </table>                                                                    </td>
                                <td align="center" valign="bottom" id="previewPhotoArea"><input type="button" name="Button32" value="Delete >>" class="button_80" onClick="
									  var found = 0;
									  for (i=0;i<document.myForm.inputListUserAssign.options.length;i++) {
										if (document.myForm.inputListUserAssign.options[i].selected) found = 1;
									  }
									  if (found==1) {
										  funcMultipleRemoveOnly(document.myForm.inputListUserAssign);
									  }
									"></td>
                              </tr>
                              <tr>
                                <td align="right" valign="top"><input name="inputEmail" type="text" class="input_left" id="inputEmail" size="22">
                                &nbsp;</td>
                                <td align="center" id="previewPhotoArea"><input type="button" name="Button2" value="<< Add" class="button_80" onClick="
									funcMultipleAddNew( elements['inputSelectAssign[]'] , inputEmail.value ); 
									"></td>
                              </tr>
                              <tr>
                                <td align="center" valign="top">&nbsp;</td>
                                <td align="center" id="previewPhotoArea">&nbsp;</td>
                              </tr>
                            </table></td>
		</tr>
		<tr> 
		<td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Content</td>
		</tr>
		<tr align="center" valign="top"> 
		<td colspan="2" class="table_col2"><table width="100%" height="500" border="0" align="center" cellpadding=1 cellspacing=1  bordercolorlight="#000000" bordercolordark="#E0E0E0" bgcolor="#AAAAAA" class="table_border" id="htmltool_table">
          <tr>
            <td height="50" align="left" class="table_col2">
              <? include("htmltool/toolbar.php"); ?>            </td>
          </tr>
          <tr>
            <td align="center" class="table_col2">
              <? include("htmltool/textarea.php"); ?>            </td>
          </tr>
        </table><script language="JavaScript" type="text/JavaScript">
fnInit(idContent);
</script>		  </td>
		</tr>
		<tr align="right" valign="top"> 
		<td colspan="2" class="table_col2">Use <span class="text_hilight">Shift+Enter</span> 
		to make a new row.</td>
		</tr>
		<tr> 
		<td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Expiration</td>
		</tr>
		<tr> 
		<td height="22" align="right" class="table_col1">Start 
		Date&nbsp; </td>
		<td height="22" class="table_col2"><input name="inputStartDate" type="text" class="input_center" id="inputStartDate" value="<?
		$myTmpDate = substr($Row[$myModule_Table."_StartDate"],0,10);
		if($myTmpDate!="0000-00-00") { echo $myTmpDate; }
		?>" size="10"> <input type="reset" class="button_normal" onClick="return showCalendar('inputStartDate', 'y-mm-dd');" value=" ... "></td>
		</tr>
		<tr> 
		<td height="22" align="right" class="table_col1">Expire 
		Date&nbsp; </td>
		<td height="22" class="table_col2"><input name="inputExpireDate" type="text" class="input_center" id="inputExpireDate" size="10" value="<?
		$myTmpDate = substr($Row[$myModule_Table."_ExpireDate"],0,10);
		if($myTmpDate!="0000-00-00") { echo $myTmpDate; }
		?>"> <input type="reset" class="button_normal" onClick="return showCalendar('inputExpireDate', 'y-mm-dd');" value=" ... "></td>
		</tr>
		<tr> 
		<td height="22" align="right" class="table_col1">&nbsp;</td>
		<td height="22" class="table_col2">Keep blank to alway 
		on.</td>
		</tr>
		</table>
		<table width="100%" height="24" border="0" cellpadding="3" cellspacing="0" class="table_button_bottom">
		<tr align="right"> 
		<td height="30" colspan="4" align="center" class="table_footer"> 
		<table width="60%" border="0" cellspacing="0" cellpadding="2">
		<tr align="left"> 
		<td width="25%"><script language="JavaScript" type="text/JavaScript">
		function isBlank(myObj) { if(myObj.value=='') { return true; } return false; }
		function verifySubmit() {
		with(document.myForm) {
		if(isBlank(inputSubject)) {	inputSubject.focus(); return false; }
		//if(isBlank(inputTitle)) {	inputTitle.focus(); return false; }
		myfile = inputThumbnailPicture.value;
		if(myfile!='') {
		myfile = myfile.toLowerCase();
		Temp = myfile.charAt(myfile.length-4) + myfile.charAt(myfile.length-3) + myfile.charAt(myfile.length-2) + myfile.charAt(myfile.length-1);
		if(Temp=='.jpg' || Temp=='.gif' || Temp=='jpeg') {
		document.getElementById('PreviewNewImage').src=myfile;
		document.getElementById('PreviewNewImageText').innerHTML= document.getElementById('PreviewNewImage').width + 'x' + document.getElementById('PreviewNewImage').height + ' pixel';
		} else {
		alert('System allow to upload image files only.');
		document.myForm.inputThumbnailPicture.focus();
		return false; 
		}
		}
		}
		for (var i=0;i<document.myForm.inputSelectAssign.length;i++) {
						document.myForm.inputSelectAssign.options[i].selected = true;
					}
		fnSave();
		document.myForm.submit();
		}
		</script> <input name="btSave" type="button" class="button_80" id="btSave" value="Save" onClick="verifySubmit();"> 
		</td>
		<td width="25%"><input name="btReset2" type="reset" class="button_80" id="btReset2" value="Reset" onClick="
		document.getElementById('PreviewNewImage').src='images/blank.gif';
		document.getElementById('PreviewNewImageText').innerHTML='';
		">
		</td>
		<td> <input name="btCalcel" type="button" class="button_80" id="btCalcel" onClick="
		if(confirm('Are you sure to return to list?')) {
		document.myReturnForm.submit();
		}
		" value="Cancel"> </td>
		</tr>
		</table></td>
		</tr>
		</table></td>
		</tr>
		</form>
		</table>
				<? 
#########################################################
} else if ($action=="update") { 
$image_W=getimagesize($inputThumbnailPicture); //Cjeck ขนาดภาพ
$image_H=getimagesize($inputThumbnailPicture);
if ($image_W[0]>150) { 
echo "<SCRIPT LANGUAGE=\"JavaScript\">alert(\"use a picture file size as  width='150' pixel.\");</SCRIPT>";
?>
<form action="?" method="post" name="myForm" id="myForm">
                      <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                      <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                      <input name="admin" type="hidden" id="admin" value="<?=$admin?>">
                      <input name="action" type="hidden" id="action">
					  <input type="hidden" id="PID" name="PID" value="">
                      <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
                      <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
                      <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
                      <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
                      <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
                    </form>
                    <script language="JavaScript" type="text/JavaScript"> document.myForm.submit(); </script>
	<?
	exit(); }
		if( strlen($inputStartDate)>0 && strlen($inputExpireDate)>0 ) {
			if(strcmp($inputStartDate,$inputExpireDate)<1) { 
				// Do nothing.
			} else { 
				// Switch Date
				$myTmp = $inputStartDate;
				$inputStartDate = $inputExpireDate;
				$inputExpireDate = $myTmp;
			}
		}

		if(strlen($inputStartDate)!=10) { $inputStartDate="0000-00-00 00:00:00"; } else { $inputStartDate = $inputStartDate." 00:00:00"; }
		if(strlen($inputExpireDate)!=10) { $inputExpireDate="0000-00-00 00:00:00"; } else { $inputExpireDate= $inputExpireDate." 00:00:00"; }

		$MaxID = $CheckBoxID1;

		srand(make_seed());
		$myrand = rand(1111,9999);

		// Check to create module data directory. ---------
		if(!is_dir($System_RelativePath_Upload."/".$SystemModuleKey)) { mkdir($System_RelativePath_Upload."/".$SystemModuleKey,0777); }
		if(!is_dir($myModule_Path_ThumbnailPicture)) { mkdir($myModule_Path_ThumbnailPicture,0777); }
		if(!is_dir($myModule_Path_HTMLFiles)) { mkdir($myModule_Path_HTMLFiles,0777); }
		if(!is_dir($myModule_Path_ImageLibrary)) { mkdir($myModule_Path_ImageLibrary,0777); }
		if(!is_dir($myModule_Path_GalleryThumbnail)) { mkdir($myModule_Path_GalleryThumbnail,0777); }
		if(!is_dir($myModule_Path_Gallery)) { mkdir($myModule_Path_Gallery,0777); }
		if(!is_dir($myModule_Path_Video)) { mkdir($myModule_Path_Video,0777); }
		// ------------------------------------------------
//-- by tom	
	if(isset($_FILES['inputThumbnailPicture'])) {
				if($_FILES['inputThumbnailPicture']['error']==0){				
					$sql = "SELECT ".$myModule_Table."_PictureFile FROM ".$myModule_Table." WHERE ".$myModule_Table."_ID = ".$MaxID;
					$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
					$Row=mysql_fetch_array($query);
					$exts = explode(".", $_FILES['inputThumbnailPicture']['name']);
					$ext = strtolower(($exts[count($exts) - 1]));	
					$ImageType = $ext;
				//-- Delete file old	
				$ThumbnailPictureName=$Row[$myModule_Table."_PictureFile"];
				if(file_exists($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName)) {
						unlink($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName);
				}
				//-- end Delete file old
				$ThumbnailPictureName = "$MaxID-$myrand.$ImageType";
				if(file_exists($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName)) {
					unlink($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName);
				}
				if(move_uploaded_file($_FILES['inputThumbnailPicture']['tmp_name'],$myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName)) {
					chmod($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName,0777);
				}			
				$sql = "UPDATE ".$myModule_Table." SET ".$myModule_Table."_PictureFile='$ThumbnailPictureName' WHERE ".$myModule_Table."_ID=".$MaxID;
				$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
			}			
		}		
//-- by tom
	/*	if(is_file($inputThumbnailPicture)) {
		$sql = "SELECT ".$myModule_Table."_PictureFile FROM ".$myModule_Table." WHERE ".$myModule_Table."_ID = ".$MaxID;
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
		while($RowUnlinkImg = MYSQL_FETCH_ARRAY($Query)){
		unlink($myModule_Path_ThumbnailPicture."/".$RowUnlinkImg[0]);
		}
			$ImageData = getimagesize($inputThumbnailPicture);
			if($ImageData!=NULL) {
				if($ImageData[2]==1) { 
					$ImageType="gif";
				} elseif($ImageData[2]==2) {
					$ImageType="jpg";
				}
				$ThumbnailPictureName = "$MaxID-$myrand.$ImageType";
				if(file_exists($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName)) {
					unlink($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName);
				}
				if(copy($inputThumbnailPicture,$myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName)) {
					chmod($myModule_Path_ThumbnailPicture."/".$ThumbnailPictureName,0777);
				}
				$sql = "UPDATE ".$myModule_Table." SET ".$myModule_Table."_PictureFile='$ThumbnailPictureName' WHERE ".$myModule_Table."_ID=".$MaxID;
				$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
			}			
		}
 */
		$sql = "SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ID=".$MaxID;
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
		$Row=MYSQL_FETCH_ARRAY($Query);

		$HTMLFileName = $Row[$myModule_Table."_HTMLFileName"];		
		$Picture = $Row[$myModule_Table."_PictureFile"];		
		if(file_exists($myModule_Path_HTMLFiles."/".$HTMLFileName)) {
			unlink($myModule_Path_HTMLFiles."/".$HTMLFileName);
			//unlink($myModule_Path_HTMLFiles."/".$Picture);
		}
						$HTMLFileName = "$MaxID-$myrand.html";
								$HTMLToolContent=stripslashes($HTMLToolContent);
								$fp = fopen ($myModule_Path_HTMLFiles."/".$HTMLFileName, "w+");
								fwrite($fp,$HTMLToolContent);
								fclose($fp);
								

		$sql = "UPDATE ".$myModule_Table." SET ".
		$myModule_Table."_HTMLFileName='$HTMLFileName', ".
		$myModule_Table."_Subject='".changeQuot($inputSubject)."', ".
		$myModule_Table."_Title='".changeQuot($inputTitle)."' ,".
		$myModule_Table."_From='$inputFrom', ".
		$myModule_Table."_Url='$inputUrl', ".
		$myModule_Table."_GID='$inputGroupID', ".
		$myModule_Table."_TitleThumbnailPicture='$inputTitleThumbnailPicture', ".
		$myModule_Table."_HTMLFileName='$HTMLFileName', ".
		$myModule_Table."_CreateByID=$System_Session_User_ID,".
		$myModule_Table."_CreateBy='$System_Session_UserName' ,".
		$myModule_Table."_CreateDate='$inputNewsDate' ,".
		$myModule_Table."_StartDate='$inputStartDate', ".
		$myModule_Table."_ExpireDate='$inputExpireDate' ,".
		$myModule_Table."_LastUpdate=NOW()  WHERE ".$myModule_Table."_ID=".$MaxID;
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");


				for ($index=0;$index<count($inputSelectAssign);$index++) {
							$sql = "SELECT * FROM ".$System_Tag." WHERE ".$System_Tag."_Detail = '$inputSelectAssign[$index]'";
							$QueryTag=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
							$RowTag=MYSQL_FETCH_ARRAY($QueryTag);
								if($RowTag[0]==""){
									$sql="INSERT INTO ".$System_Tag." (".$System_Tag."_Detail) VALUES('$inputSelectAssign[$index]')";
									$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
								}
						$tag.=$inputSelectAssign[$index].",";
						}
				$sql = "UPDATE ".$myModule_Table." SET ".$myModule_Table."_Tag='$tag' WHERE ".$myModule_Table."_ID=".$MaxID;
				$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
		
		if(count($inputFile)>0){
			if($inputTypeFile=="update"){
		$sql = "SELECT * FROM ".$myModule_Table_FileUploadOnNews." WHERE ".$myModule_Table_FileUploadOnNews."_NewsID = ".$MaxID;
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error : เกิดความผิดพลาด <br>$sql<br>\n");
		while($RowUnlink=MYSQL_FETCH_ARRAY($Query)){
				unlink($myModule_Path_FileUpload."/".$RowUnlink[$myModule_Table_FileUploadOnNews."_FileUpload"]);
		}
		$sql="DELETE FROM ".$myModule_Table_FileUploadOnNews." WHERE ".$myModule_Table_FileUploadOnNews."_NewsID=".$MaxID;
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error : เกิดความผิดพลาด <br>$sql<br>\n");
			
			
			}
			
			include"function_mod.php";
		///////--  Attach Files  ------------//
	 if( isset( $_FILES[inputFile][tmp_name] ) ){
				for($i=0; $i < count( $_FILES[inputFile][tmp_name] );  $i++){
					$exts = explode(".", $_FILES[inputFile][name][$i]);
					$ext = strtolower(($exts[count($exts) - 1]));	
					$tmpName = $_FILES[inputFile][tmp_name][$i];
					$fileName = $_FILES[inputFile][name][$i];     				
					$fileSize = imgGetFileSize($_FILES[inputFile][size][$i]);
					$myrand = rand(1111,9999);
					$path =  $MaxID."-".$myrand."." . $ext;										
					$paths= $myModule_Path_FileUpload ."/". $path;				
				if ($_FILES[InputFile][error][$i]==0) {
					 if ($_FILES[inputFile][type][$i])	$mimeType = $_FILES[inputFile][type][$i];												
					 else  $mimeType = "application/unknown";					
						if( move_uploaded_file($_FILES[inputFile][tmp_name][$i], $paths) ){							
						//sql
							$insert[$myModule_Table_FileUploadOnNews."_NewsID"] = "$MaxID";
							$insert[$myModule_Table_FileUploadOnNews."_FileUpload"] = "'$path'";
							$insert[$myModule_Table_FileUploadOnNews."_UploadFileName"] = "'$fileName'";		
							$sql="INSERT INTO ".$myModule_Table_FileUploadOnNews." (".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
							mysql_query($sql) or die("Error: เกิดความผิดพลาด <br>$sql<br>\n");
						}
				}											
			}//end for
			unset($insert);
		 }//end if check file.
		 //------- end add file ---------
			
			/*
				for($i=0; $i<=count($inputFile); $i++){
							srand(make_seed());
							$myrand = rand(1111,9999);
							$LastFileArray=explode(".",$inputFile_name[$i]);
							$LastFile=$LastFileArray[count($LastFileArray)-1];
							$StrFileName=$MaxID."_".$myrand.".".$LastFile;
							
							if($inputFile[$i]!=""){
								if(file_exists($myModule_Path_FileUpload."/".$StrFileName)) {
									unlink($myModule_Path_FileUpload."/".$StrFileName);
							}
							if(move_uploaded_file($_FILES['inputFile[$i]']['tmp_name'],$myModule_Path_FileUpload."/".$StrFileName)) {
									chmod($myModule_Path_FileUpload."/".$StrFileName,0777);
							}
									
									$sql =  " INSERT INTO ".$myModule_Table_FileUploadOnNews."(".$myModule_Table_FileUploadOnNews."_NewsID ,".$myModule_Table_FileUploadOnNews."_FileUpload , ".$myModule_Table_FileUploadOnNews."_UploadFileName)".
				" VALUES ($MaxID,'$StrFileName','$LastFileArray[0]') ";
									//die($sql);
									$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error : เกิดความผิดพลาด <br>$sql<br>\n");
								
							}
				}//end for
				
				*/
		}
//Search All Site
if($_SESSION[System_Session_Language]=="Thai"){
$Lang="th";
}elseif($_SESSION[System_Session_Language]=="Eng"){
$Lang="en";
}
include("config.php");
$sql_Search="SELECT * FROM ".$myModule_SearchAllSite." WHERE ".$myModule_SearchAllSite."_ModuleKey='".$SystemModuleKey."' AND ".$myModule_SearchAllSite."_RecordID='".$MaxID."'";
$Query_Search=mysql_query($sql_Search);
$Num_Search=mysql_num_rows($Query_Search);
if($Num_Search!=0){
	
		$updateS[] = $myModule_SearchAllSite."_ModuleKey='".$SystemModuleKey."' ";
		if($inputUrl){
			$updateS[] = $myModule_SearchAllSite."_Path='".$inputUrl."'";
		}else{
			$updateS[] = $myModule_SearchAllSite."_Path='".$myModule_Path_Search."'";
		}
		$updateS[] = $myModule_SearchAllSite."_Content='".strip_tags($inputSubject)." , ".htmlspecialchars(strip_tags($inputTitle))." , ".strip_tags($HTMLToolContent)."'";
		$sql="UPDATE ".$myModule_SearchAllSite." SET ".implode(" , " , $updateS)." WHERE ".$myModule_SearchAllSite."_RecordID='".$MaxID."'";
		@$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Updated Error: <br>$sql<br>\n");
		
	}else{ //IF Num_search >0
		$insert[$myModule_SearchAllSite."_RecordID"] = "'".$MaxID."'";
		$insert[$myModule_SearchAllSite."_ModuleKey"] = "'".$SystemModuleKey."'";
		$insert[$myModule_SearchAllSite."_Language"] = "'".$_SESSION[System_Session_Language]."'";
		$insert[$myModule_SearchAllSite."_Content"] = "'".strip_tags($inputSubject)." , ".strip_tags($inputTitle)." , ".strip_tags($HTMLToolContent)."'";
		if($inputUrl){
			$insert[$myModule_SearchAllSite."_Path"] = "'".$inputUrl."'";
		}else{
			$insert[$myModule_SearchAllSite."_Path"] = "'".$myModule_Path_Search."'";
		}
		$insert[$myModule_SearchAllSite."_Status"] = "'Enable'";
		$sql2 = "INSERT INTO ".$myModule_SearchAllSite."(".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
		$Query2 = mysql_query($sql2);
	}

//gen XML -------------------------------

$sql = "SELECT * FROM ".$myModule_Table."  WHERE (" . $myModule_Table."_Status='Enable' OR ".$myModule_Table."_Status='Home')".
					" AND " . $myModule_Table . "_ModuleKey='$SystemModuleKey'" . 
					" AND " . $myModule_Table . "_Language='Thai'" . 
					" AND ((".$myModule_Table."_StartDate='0000-00-00 00:00:00' AND ".  $myModule_Table."_ExpireDate='0000-00-00 00:00:00') " .
					" OR (".$myModule_Table."_StartDate='0000-00-00 00:00:00' AND TO_DAYS(".$myModule_Table."_ExpireDate) >= TO_DAYS(NOW()))" .
					" OR (TO_DAYS(".$myModule_Table."_StartDate) <= TO_DAYS(NOW()) AND ".  $myModule_Table."_ExpireDate='0000-00-00 00:00:00' )" .
					" OR (TO_DAYS(".$myModule_Table."_StartDate) <= TO_DAYS(NOW()) AND TO_DAYS(".$myModule_Table."_ExpireDate)>=TO_DAYS(NOW()))) ";
//die($sql);
$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
$aFieldReq = array();
//$aFieldReq = split(";", $sFieldReq);

// ######### INITIAL VARIABLE USE FOR STRING RSS #########
$strRSSHeader = "";
$strRSSBody = "";
$iCount = 0;

// Generate XML TAG..
		$strRSSHeader .= "&lt;?xml version=\"1.0\" encoding=\"windows-874\"?&gt;\n";
		$strRSSHeader .= "&lt;rss version=\"2.0\"&gt;\n";
		$strRSSHeader .= "&lt;channel&gt;\n";
		//if ($SystemModuleKey=="thainews") {
			$strRSSHeader .= "&lt;title&gt;moe.go.th - Moe News&lt;/title&gt;\n";
		//} else {
			//$strRSSHeader .= "&lt;title&gt;SkypeThailand.Com - Skype World Wide News&lt;/title&gt;\n";
		//}
		$strRSSHeader .= "&lt;link&gt;http://www.moe.go.th/moe/th/news/&lt;/link&gt;\n";
		$strRSSHeader .= "&lt;description&gt;Online Update&lt;/description&gt;\n";
		$strRSSHeader .= "&lt;language&gt;th-TH&lt;/language&gt;\n";
			
			while ($Row = mysql_fetch_array($Query)){
						//$LinkPath=$System_FullPath."http://golf/skypethailand/th/news/news_detail.php?nID=".$Row[$myModule_Table."_ID"]."&chk=".$SystemModuleKey;
							$strRSSHeader .= "\n&lt;item&gt;\n";
							$strRSSHeader .= "&lt;title&gt;".$Row[$myModule_Table."_Subject"]."&lt;/title&gt;\n";
							$strRSSHeader .= "&lt;link&gt;".$System_FullPath."/th/news/detail.php?NewsID=".$Row[$myModule_Table."_ID"]."&amp;Key=".$SystemModuleKey."&lt;/link&gt;\n";
							$strRSSHeader .= "&lt;description&gt;".$Row[$myModule_Table."_Title"]."&lt;/description&gt;\n";
							$strRSSHeader .= "&lt;pubDate&gt;".$Row[$myModule_Table."_LastUpdate"]."&lt;/pubDate&gt;\n";
							$strRSSHeader .= "&lt;/item&gt;\n";
			
}	// END WHILE
		
		$strRSSHeader .= "&lt;/channel&gt;\n";
		$strRSSHeader .= "&lt;/rss&gt;\n";
		
		
		$XMLFileName = "$SystemModuleKey.xml";
		$HTMLToolContent=stripslashes($strRSSHeader);
		$fp = fopen ($myModule_Path_HTMLFiles."/".$XMLFileName, "w+");
		fwrite($fp,str_replace("&gt;",">",str_replace("&lt;","<",$strRSSHeader)));
		fclose($fp);
				
///////update gallery
		
		$sqlGallery="SELECT COUNT(*) FROM ".$myModule_Table_Gallery." WHERE ".$myModule_Table_Gallery."_NewsID='".$Row[$myModule_Table."_ID"]."' AND ".$myModule_Table_Gallery."_Status='Enable'";
			$resultGallery=mysql_query($sqlGallery);
			$record=mysql_fetch_array($resultGallery);
			$num=$record[0];
		for($i=1;$i<=10;$i++){
			$inputGallery=$_FILES['inputGallery_'.$i]['tmp_name'];
			if(is_file($inputGallery)) {
				$ImageData = getimagesize($inputGallery);
			if($ImageData!=NULL) {
				if($ImageData[2]==1) { 
					$ImageType="gif";
				} elseif($ImageData[2]==2) {
					$ImageType="jpg";
				}
				$image=cropImage($inputGallery,100,100);
				srand(make_seed());
				$myrand = rand(1111,9999);
				$n=$num+$i;
				$ThumbnailPictureName = "$MaxID-$n-$myrand.$ImageType";
				if(file_exists($myModule_Path_GalleryThumbnail."/".$ThumbnailPictureName)) {
					unlink($myModule_Path_GalleryThumbnail."/".$ThumbnailPictureName);
				}
				if($ImageType=="gif"){
				if(imagegif($image,$myModule_Path_GalleryThumbnail."/".$ThumbnailPictureName)) {
					chmod($myModule_Path_GalleryThumbnail."/".$ThumbnailPictureName,0777);
				}
			}
			if($ImageType=="jpg"){
				if(imagejpeg($image,$myModule_Path_GalleryThumbnail."/".$ThumbnailPictureName)) {
					chmod($myModule_Path_GalleryThumbnail."/".$ThumbnailPictureName,0777);
				}
			}
			srand(make_seed());
			$myrand = rand(1111,9999);
			$PictureName = "$MaxID-$n-$myrand.$ImageType";
			$minHeight=450;
			$minWidth=800;
			if($ImageData[1]>$minHeight || $ImageData[0]>$minWidth){
				if($minWidth/$ImageData[0]<$minHeight/$ImageData[1]){
					$image=cropImage($inputGallery,$minWidth,$ImageData[1]*$minWidth/$ImageData[0]);
				}else{
					$image=cropImage($inputGallery,$ImageData[0]*$minHeight/$ImageData[1],$minHeight);
				}
				if(file_exists($myModule_Path_Gallery."/".$PictureName)) {
					unlink($myModule_Path_Gallery."/".$PictureName);
				}
				if($ImageType=="gif"){
					if(imagegif($image,$myModule_Path_Gallery."/".$PictureName)) {
						chmod($myModule_Path_Gallery."/".$PictureName,0777);
					}
				}
				if($ImageType=="jpg"){
					if(imagejpeg($image,$myModule_Path_Gallery."/".$PictureName)) {
						chmod($myModule_Path_Gallery."/".$PictureName,0777);
					}
				}
			}else{
				if(copy($inputGallery,$myModule_Path_Gallery."/".$PictureName)){
					chmod($myModule_Path_Gallery."/".$PictureName,0777);
				}
			}
				$sql = "INSERT INTO ".$myModule_Table_Gallery."(".$myModule_Table_Gallery."_NewsID ,".$myModule_Table_Gallery."_Thumbnail ,".$myModule_Table_Gallery."_Picture ,".$myModule_Table_Gallery."_Status) VALUES ('$MaxID','$ThumbnailPictureName','$PictureName','Enable')";
				$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
			}
			}
		}
		
		///////////// Video Gallery
	for($i=1;$i<=10;$i++){
		$inputVideo=$_FILES['inputVideo_'.$i]['tmp_name'];
		if(is_file($inputVideo)) {
			$inputVideoName=$_FILES['inputVideo_'.$i]['name'];
			srand(make_seed());
			$myrand = rand(1111,9999);
			$VideoName = "$MaxID-$myrand-$inputVideoName";
			if(copy($inputVideo,$myModule_Path_Video."/".$VideoName)){
				chmod($myModule_Path_Video."/".$VideoName,0777);
			}
			if($_REQUEST['inputVideoName_'.$i]!="")
				$Name=$_REQUEST['inputVideoName_'.$i];
			else
				$Name=$inputVideoName;
			$sql = "INSERT INTO ".$myModule_Table_Video."(".$myModule_Table_Video."_NewsID ,".$myModule_Table_Video."_Video,".$myModule_Table_Video."_Name ,".$myModule_Table_Video."_Status) VALUES ('$MaxID','$VideoName','$Name','Enable')";
			$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
		}
	}
		
//gen XML -------------------------------

$sql = "SELECT * FROM ".$myModule_Table."  WHERE (" . $myModule_Table."_Status='Enable' OR ".$myModule_Table."_Status='Home')".
					" AND " . $myModule_Table . "_ModuleKey='$SystemModuleKey'" . 
					" AND " . $myModule_Table . "_Language='Thai'" . 
					" AND ((".$myModule_Table."_StartDate='0000-00-00 00:00:00' AND ".  $myModule_Table."_ExpireDate='0000-00-00 00:00:00') " .
					" OR (".$myModule_Table."_StartDate='0000-00-00 00:00:00' AND TO_DAYS(".$myModule_Table."_ExpireDate) >= TO_DAYS(NOW()))" .
					" OR (TO_DAYS(".$myModule_Table."_StartDate) <= TO_DAYS(NOW()) AND ".  $myModule_Table."_ExpireDate='0000-00-00 00:00:00' )" .
					" OR (TO_DAYS(".$myModule_Table."_StartDate) <= TO_DAYS(NOW()) AND TO_DAYS(".$myModule_Table."_ExpireDate)>=TO_DAYS(NOW()))) ";
//die($sql);
$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
$aFieldReq = array();
//$aFieldReq = split(";", $sFieldReq);

// ######### INITIAL VARIABLE USE FOR STRING RSS #########
$strRSSHeader = "";
$strRSSBody = "";
$iCount = 0;

// Generate XML TAG..
		$strRSSHeader .= "&lt;?xml version=\"1.0\" encoding=\"windows-874\"?&gt;\n";
		$strRSSHeader .= "&lt;rss version=\"2.0\"&gt;\n";
		$strRSSHeader .= "&lt;channel&gt;\n";
		//if ($SystemModuleKey=="thainews") {
			$strRSSHeader .= "&lt;title&gt;moe.go.th - Moe News&lt;/title&gt;\n";
		//} else {
			//$strRSSHeader .= "&lt;title&gt;SkypeThailand.Com - Skype World Wide News&lt;/title&gt;\n";
		//}
		$strRSSHeader .= "&lt;link&gt;http://www.moe.go.th/moe/th/news/&lt;/link&gt;\n";
		$strRSSHeader .= "&lt;description&gt;Online Update&lt;/description&gt;\n";
		$strRSSHeader .= "&lt;language&gt;th-TH&lt;/language&gt;\n";
			
			while ($Row = mysql_fetch_array($Query)){
						//$LinkPath=$System_FullPath."http://golf/skypethailand/th/news/news_detail.php?nID=".$Row[$myModule_Table."_ID"]."&chk=".$SystemModuleKey;
							$strRSSHeader .= "\n&lt;item&gt;\n";
							$strRSSHeader .= "&lt;title&gt;".$Row[$myModule_Table."_Subject"]."&lt;/title&gt;\n";
							$strRSSHeader .= "&lt;link&gt;".$System_FullPath."/th/news/detail.php?NewsID=".$Row[$myModule_Table."_ID"]."&amp;Key=".$SystemModuleKey."&lt;/link&gt;\n";
							$strRSSHeader .= "&lt;description&gt;".$Row[$myModule_Table."_Title"]."&lt;/description&gt;\n";
							$strRSSHeader .= "&lt;pubDate&gt;".$Row[$myModule_Table."_LastUpdate"]."&lt;/pubDate&gt;\n";
							$strRSSHeader .= "&lt;/item&gt;\n";
			
}	// END WHILE
		
		$strRSSHeader .= "&lt;/channel&gt;\n";
		$strRSSHeader .= "&lt;/rss&gt;\n";
		
		
		$XMLFileName = "$SystemModuleKey.xml";
		$HTMLToolContent=stripslashes($strRSSHeader);
		$fp = fopen ($myModule_Path_HTMLFiles."/".$XMLFileName, "w+");
		fwrite($fp,str_replace("&gt;",">",str_replace("&lt;","<",$strRSSHeader)));
		fclose($fp);

?>
            <form action="?" method="post" name="myForm" id="myForm">
              <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
              <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
              <input name="action" type="hidden" id="action">
              <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
              <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
              <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
              <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
              <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
              <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
            </form>
            <script language="JavaScript" type="text/JavaScript"> document.myForm.submit(); </script>
            <? 
#########################################################
} else if ($action=="view") { 
	$myCheckBoxID=0;
	for($i=1;$i<=$TotalCheckBoxID;$i++) {
		$myVar="CheckBoxID".$i;
		if(strlen($$myVar)>0) {
			$myCheckBoxID=$$myVar;
		}
	}
	$sql="SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ID=".$myCheckBoxID;
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
	$Row=MYSQL_FETCH_ARRAY($Query);
?>
		<table width="98%" border="0" cellpadding="0" cellspacing="1">
		<form action="?" method="post" name="myForm" id="myForm">
		<input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
		<input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
		<input name="action" type="hidden" id="action">
		<input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
		<input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
		<input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
		<input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
		<input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
		<input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
		<input name="CheckBoxID1" type="hidden" id="CheckBoxID1" value="<?=$myCheckBoxID?>">
		<input name="TotalCheckBoxID" type="hidden" id="TotalCheckBoxID" value="1">
		<tr> 
		<td class="table_form_bg1"><table width="100%" border="0" cellpadding="2" cellspacing="1" >
		<tr align="center"> 
		<td height="24" colspan="2" align="center" class="menu_table_header"> 
		<?=getMenuName($SystemMenuID)?>
		Information</td>
		</tr>
		<tr> 
		<td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Header 
		Information </td>
		</tr>
		<tr> 
		<td width="15%" height="22" align="center" class="table_col1"><? if($Row[$myModule_Table."_PictureFile"]){?><img src="<?=$myModule_Path_ThumbnailPicture?>/<?=$Row[$myModule_Table."_PictureFile"]?>" border="0" width="100"><? }?></td>
		<td height="22" class="table_col2"> <span class="text_bold"> 
		<?=$Row[$myModule_Table."_Subject"]?>
		</span><br> 
		<?=nl2br($Row[$myModule_Table."_Title"])?>		</td>
		</tr>
		<tr>
		  <td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Files</td>
		  </tr>
		  <tr> 
		<td height="30" align="right" valign="top" class="table_col1">Document Files&nbsp; </td>
		<td height="30" class="table_col2">
		<?
		$sqlFile = "SELECT * FROM ".$myModule_Table_FileUploadOnNews." WHERE ".$myModule_Table_FileUploadOnNews."_NewsID = '".$myCheckBoxID."'";
	$QueryFile=MYSQL_DB_QUERY($System_DataBase_Name,$sqlFile) or die(mysql_error());				
		while ($RowFile=MYSQL_FETCH_ARRAY($QueryFile)){
						$LinkRelativePath = $myModule_Path_FileUpload."/".$RowFile[$myModule_Table_FileUploadOnNews."_FileUpload"];
						$DownloadFile = $RowFile[$myModule_Table_FileUploadOnNews."_FileUpload"];
						$ImageType = strstr($DownloadFile,'.');							
						if($ImageType==".pdf"){
							$TypeImgFile="../../images/bullet/pdf.gif";
						}elseif($ImageType==".txt"){
							$TypeImgFile="../../images/bullet/file.gif";
						}elseif($ImageType==".xls"){
							$TypeImgFile="../../images/bullet/excel.gif";
						}elseif($ImageType==".ppt"){
							$TypeImgFile="../../images/bullet/pp.gif";
						}elseif($ImageType==".rtf"){
							$TypeImgFile="../../images/bullet/word.gif";
						}elseif($ImageType==".rar"){
							$TypeImgFile="../../images/bullet/rar.gif";
						}else{
							$TypeImgFile="../../images/bullet/application.gif";
						}
		?><br><a href="<?=$LinkRelativePath?>" target="_blank"><strong>
                        &nbsp;<img src="<?=$TypeImgFile?>" border="0" alt="<?=$ImageType?>">&nbsp;<?=$RowFile[$myModule_Table_FileUploadOnNews."_UploadFileName"];?>
                        </strong></a>&nbsp;&nbsp;
		<? }?></td>
		</tr>
		  <tr>
		    <td height="26" colspan="2" class="table_col3">&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Gallery</td>
		    </tr>
		  <tr align="left">
		    <td height="26" colspan="2" class="table_col2">
			<?
			$sqlGallery="SELECT ".$myModule_Table_Gallery."_Thumbnail , ".$myModule_Table_Gallery."_Picture FROM ".$myModule_Table_Gallery." WHERE ".$myModule_Table_Gallery."_NewsID='".$Row[$myModule_Table."_ID"]."' AND ".$myModule_Table_Gallery."_Status='Enable'";
			$resultGallery=mysql_query($sqlGallery);
			$TotalGallery=mysql_num_rows($resultGallery);
			if($TotalGallery!=""){echo "<table border=0><tr>";
			$i=1;
			while($record=mysql_fetch_array($resultGallery)){
				echo "<td>";
				echo "<a href=".$myModule_Path_Gallery."/".$record[$myModule_Table_Gallery."_Picture"]." target='_blank'>";
				echo "<img src=".$myModule_Path_GalleryThumbnail."/".$record[$myModule_Table_Gallery."_Thumbnail"]." border=0>";
				echo "</a>";
				echo "</td>";
				$i++;
				if($i==6){
					$i=1;
					echo "</tr><tr>";
				}
			}
			echo "</tr></table>";
			}else{  //No TotalGallery
			echo "<center>Find Not Found.</center>";
			}
		?></td>
		    </tr>
			<tr>
		    <td height="26" colspan="2" class="table_col3">&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Video</td>
		    </tr>
		  <tr>
		    <td height="26" colspan="2" align="left" class="table_col2">
			<?
			$sqlVideo="SELECT * FROM ".$myModule_Table_Video." WHERE ".$myModule_Table_Video."_NewsID='".$Row[$myModule_Table."_ID"]."' AND ".$myModule_Table_Video."_Status='Enable'";
			$resultVideo=mysql_query($sqlVideo);
			$TotalVideo=mysql_num_rows($resultVideo);
			if($TotalVideo!=""){
			while($record=mysql_fetch_array($resultVideo)){
				echo "<a href='#' onClick=\"Popup('popupVideo','popup_vdo.php?VideoSRc=".$myModule_Path_Video."/".$record[$myModule_Table_Video."_Video"]."',500,400,1);\">";
				echo $record[$myModule_Table_Video."_Name"];
				echo "</a>";
				echo "</br>";
			}
			}else{ //Find Not Found VDO
			echo "<center>Find Not Found.</center>";
			}
		?> <img src="../../webengine/images/icon/ico495.gif" border="0"></td>
		    </tr>
		  <tr> 
		<td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Content</td>
		</tr>
		</table>
		<table width="100%" height="100" border="0" cellpadding="2" cellspacing="0" class="table_htmldisplay">
		<tr> 
		<td align="left" valign="top"> 
		<?
		$filename = $myModule_Path_HTMLFiles."/".$Row[$myModule_Table."_HTMLFileName"];
		$fd = fopen ($filename, "r");
		//if (filesize ($filename) > 0) {
			$contents = @fread ($fd, filesize ($filename));
		//}
		fclose ($fd);
		echo $contents;
		?>
		</td>
		</tr>
		</table>
		<table width="100%" border="0" cellpadding="2" cellspacing="1" >
		<tr> 
		<td height="26" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Expiration</td>
		</tr>
		<tr> 
		<td height="22" align="right" class="table_col1">Start 
		Date&nbsp; </td>
		<td height="22" class="table_col2"> 
		<?
		$myTmpDate = substr($Row[$myModule_Table."_StartDate"],0,10);
		if($myTmpDate=="0000-00-00") { echo "No start date limit."; } else { echo $myTmpDate; }
		?>
		</td>
		</tr>
		<tr> 
		<td height="22" align="right" class="table_col1">Expire 
		Date&nbsp; </td>
		<td height="22" class="table_col2"> 
		<?
		$myTmpDate = substr($Row[$myModule_Table."_ExpireDate"],0,10);
		if($myTmpDate=="0000-00-00") { echo "No expire date limit."; } else { echo $myTmpDate; }
		?>
		</td>
		</tr>
		<tr> 
		<td height="27" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;More 
		Information</td>
		</tr>
		<tr> 
		<td width="105" height="22" align="right" class="table_col1">Create 
		Date&nbsp; </td>
		<td height="22" class="table_col2"> 
		<?=$Row[$myModule_Table."_CreateDate"]?>
		</td>
		</tr>
		<tr> 
		<td height="22" align="right" class="table_col1">Last 
		Update &nbsp; </td>
		<td height="22" class="table_col2"> 
		<?=$Row[$myModule_Table."_LastUpdate"]?>
		</td>
		</tr>
		<tr> 
		<td height="22" align="right" class="table_col1">Update 
		By &nbsp; </td>
		<td height="22" class="table_col2"> 
		<?=$Row[$myModule_Table."_CreateBy"]?>
		</td>
		</tr>
		<tr> 
		<td height="22" align="right" class="table_col1">Status 
		&nbsp; </td>
		<td height="22" class="table_col2"> 
		<?=$Row[$myModule_Table."_Status"]					?>
		</td>
		</tr>
		</table>
		<table width="100%" height="24" border="0" cellpadding="3" cellspacing="0" class="table_button_bottom">
		<tr align="right"> 
		<td height="30" colspan="4" align="center" class="table_footer"> 
		<table width="300" border="0" cellspacing="0" cellpadding="2">
		<tr align="center"> 
		<? if($System_Session_Permission[$SystemMenuID]=="RW" ){ ?>
		<td> <input name="btEdit" type="submit" class="button_80" id="btEdit" value="Edit" onClick="
		document.myForm.action.value='edit';
		document.myForm.submit();
		"> </td>
		<? } ?>
		<td> <input name="btCalcel" type="button" class="button_80" id="btCalcel" onClick="
		document.myForm.submit();
		" value="Cancel"> </td>
		</tr>
		</table></td>
		</tr>
		</table></td>
		</tr>
		</form>
		</table>
		<? 
#########################################################
} else if ($action=="delete") { 
	for($i=1;$i<=$TotalCheckBoxID;$i++) {
		$myVar="CheckBoxID".$i;
		if(strlen($$myVar)>0) {
			$sql = "SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ID=".$$myVar;
			$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
			$Row=MYSQL_FETCH_ARRAY($Query);
			if(strlen($Row[$myModule_Table."_PictureFile"])>0) {
				if(file_exists($myModule_Path_ThumbnailPicture."/".$Row[$myModule_Table."_PictureFile"])) {
					unlink($myModule_Path_ThumbnailPicture."/".$Row[$myModule_Table."_PictureFile"]);
				}
			}			
			if(strlen($Row[$myModule_Table."_HTMLFileName"])>0) {
				if(file_exists($myModule_Path_HTMLFiles."/".$Row[$myModule_Table."_HTMLFileName"])) {
					unlink($myModule_Path_HTMLFiles."/".$Row[$myModule_Table."_HTMLFileName"]);
				}
			}			
			$sql = "DELETE FROM ".$myModule_Table." WHERE ".$myModule_Table."_ID=".$$myVar;
			$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
			//Search All Site
			$sql = "DELETE FROM ".$myModule_SearchAllSite." WHERE ".$myModule_SearchAllSite."_ModuleKey='".$SystemModuleKey."' AND ".$myModule_SearchAllSite."_RecordID='".$$myVar."'";
			$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");	
			// Delete attach file
	$sql = "SELECT * FROM ".$myModule_Table_FileUploadOnNews." WHERE ".$myModule_Table_FileUploadOnNews."_NewsID = ".$$myVar;
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error : เกิดความผิดพลาด <br>$sql<br>\n");
		while($RowUnlink=MYSQL_FETCH_ARRAY($Query)){
				unlink($myModule_Path_FileUpload."/".$RowUnlink[$myModule_Table_FileUpload."_FileUpload"]);
		}
		$sql="DELETE FROM ".$myModule_Table_FileUploadOnNews." WHERE ".$myModule_Table_FileUploadOnNews."_NewsID=".$$myVar;
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error : เกิดความผิดพลาด <br>$sql<br>\n");
		}
	}
//gen XML -------------------------------

$sql = "SELECT * FROM ".$myModule_Table."  WHERE (" . $myModule_Table."_Status='Enable' OR ".$myModule_Table."_Status='Home')".
					" AND " . $myModule_Table . "_ModuleKey='$SystemModuleKey'" . 
					" AND " . $myModule_Table . "_Language='Thai'" . 
					" AND ((".$myModule_Table."_StartDate='0000-00-00 00:00:00' AND ".  $myModule_Table."_ExpireDate='0000-00-00 00:00:00') " .
					" OR (".$myModule_Table."_StartDate='0000-00-00 00:00:00' AND TO_DAYS(".$myModule_Table."_ExpireDate) >= TO_DAYS(NOW()))" .
					" OR (TO_DAYS(".$myModule_Table."_StartDate) <= TO_DAYS(NOW()) AND ".  $myModule_Table."_ExpireDate='0000-00-00 00:00:00' )" .
					" OR (TO_DAYS(".$myModule_Table."_StartDate) <= TO_DAYS(NOW()) AND TO_DAYS(".$myModule_Table."_ExpireDate)>=TO_DAYS(NOW()))) ";
//die($sql);
$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
$aFieldReq = array();
//$aFieldReq = split(";", $sFieldReq);

// ######### INITIAL VARIABLE USE FOR STRING RSS #########
$strRSSHeader = "";
$strRSSBody = "";
$iCount = 0;

// Generate XML TAG..
		$strRSSHeader .= "&lt;?xml version=\"1.0\" encoding=\"windows-874\"?&gt;\n";
		$strRSSHeader .= "&lt;rss version=\"2.0\"&gt;\n";
		$strRSSHeader .= "&lt;channel&gt;\n";
		//if ($SystemModuleKey=="thainews") {
			$strRSSHeader .= "&lt;title&gt;moe.go.th - moe News&lt;/title&gt;\n";
		//} else {
			//$strRSSHeader .= "&lt;title&gt;SkypeThailand.Com - Skype World Wide News&lt;/title&gt;\n";
		//}
		$strRSSHeader .= "&lt;link&gt;http://www.moe.go.th/moe/th/news/&lt;/link&gt;\n";
		$strRSSHeader .= "&lt;description&gt;Online Update&lt;/description&gt;\n";
		$strRSSHeader .= "&lt;language&gt;th-TH&lt;/language&gt;\n";
			
			while ($Row = mysql_fetch_array($Query)){
						//$LinkPath=$System_FullPath."http://golf/skypethailand/th/news/news_detail.php?nID=".$Row[$myModule_Table."_ID"]."&chk=".$SystemModuleKey;
							$strRSSHeader .= "\n&lt;item&gt;\n";
							$strRSSHeader .= "&lt;title&gt;".$Row[$myModule_Table."_Subject"]."&lt;/title&gt;\n";
							$strRSSHeader .= "&lt;link&gt;".$System_FullPath."/th/news/detail.php?NewsID=".$Row[$myModule_Table."_ID"]."&amp;Key=".$SystemModuleKey."&lt;/link&gt;\n";
							$strRSSHeader .= "&lt;description&gt;".$Row[$myModule_Table."_Title"]."&lt;/description&gt;\n";
							$strRSSHeader .= "&lt;pubDate&gt;".$Row[$myModule_Table."_LastUpdate"]."&lt;/pubDate&gt;\n";
							$strRSSHeader .= "&lt;/item&gt;\n";
			
}	// END WHILE
		
		$strRSSHeader .= "&lt;/channel&gt;\n";
		$strRSSHeader .= "&lt;/rss&gt;\n";
		
		
		$XMLFileName = "$SystemModuleKey.xml";
		$HTMLToolContent=stripslashes($strRSSHeader);
		$fp = fopen ($myModule_Path_HTMLFiles."/".$XMLFileName, "w+");
		fwrite($fp,str_replace("&gt;",">",str_replace("&lt;","<",$strRSSHeader)));
		fclose($fp);

?>

            <form action="?" method="post" name="myForm" id="myForm">
              <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
              <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
              <input name="action" type="hidden" id="action">
              <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
              <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
              <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
              <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
              <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
              <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
            </form>
            <script language="JavaScript" type="text/JavaScript"> document.myForm.submit(); </script>
     
		    <? 
##################################################################   
} else if ($action=="setmarquee") { 
$myCheckBoxID=0;
	for($i=1;$i<=$TotalCheckBoxID;$i++) {
		$myVar="CheckBoxID".$i;
		if(strlen($$myVar)>0) {
			$myCheckBoxID=$$myVar;
		}
	}
	$sql="UPDATE ".$myModule_Table." SET ".$myModule_Table."_Marquee='$SelectMarquee' WHERE ".$myModule_Table."_ID=".$myCheckBoxID;
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
?>
            <form action="?" method="post" name="myForm" id="myForm">
              <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
              <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
              <input name="action" type="hidden" id="action">
              <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
              <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
              <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
              <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
              <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
              <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
            </form>
            <script language="JavaScript" type="text/JavaScript"> document.myForm.submit(); </script>
            <? 


			
#########################################################
} else if ($action=="setstatus") { 
	$myCheckBoxID=0;
	for($i=1;$i<=$TotalCheckBoxID;$i++) {
		$myVar="CheckBoxID".$i;
		if(strlen($$myVar)>0) {
			$myCheckBoxID=$$myVar;
		}
	}
	$sql="UPDATE ".$myModule_Table." SET ".$myModule_Table."_Status='$SelectStatus' WHERE ".$myModule_Table."_ID=".$myCheckBoxID;
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
?>
            <form action="?" method="post" name="myForm" id="myForm">
              <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
              <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
              <input name="action" type="hidden" id="action">
              <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
              <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
              <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
              <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
              <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
              <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
            </form>
            <script language="JavaScript" type="text/JavaScript"> document.myForm.submit(); </script>
            <? 
#########################################################
} else if ($action=="deleteFile") { 
	$sql="SELECT * FROM ".$myModule_Table_FileUploadOnNews." WHERE ".$myModule_Table_FileUploadOnNews."_NewsID='".$PID."' AND ".$myModule_Table_FileUploadOnNews."_FileUpload='".$FileName."' ";
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
	$RowFile=mysql_fetch_array($Query);
	if(file_exists($myModule_Path_FileUpload."/".$FileName)) {
					unlink($myModule_Path_FileUpload."/".$FileName);
		}
		$sql="DELETE  FROM ".$myModule_Table_FileUploadOnNews." WHERE ".$myModule_Table_FileUploadOnNews."_NewsID = '$PID' AND ".$myModule_Table_FileUploadOnNews."_FileUpload='".$FileName."' ";
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
?>

            <form action="?" method="post" name="myForm" id="myForm">
              <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
              <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
              <input name="action" type="hidden" id="action" value="edit">
			  <input name="myCheckBoxID" type="hidden" id="myCheckBoxID" value="<?=$NID?>">
              <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
              <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
              <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
              <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
              <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
              <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
            </form>
            <script language="JavaScript" type="text/JavaScript"> document.myForm.submit(); </script>
			<? 
#########################################################
} else if ($action=="deletePicture") {  
	$sql="SELECT * FROM ".$myModule_Table_Gallery." WHERE ".$myModule_Table_Gallery."_ID='".$PID."' ";
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
	$RowPicture=mysql_fetch_array($Query);
	if(file_exists($myModule_Path_Gallery."/".$RowPicture[$myModule_Table_Gallery."_Thumbnail"])) {
					unlink($myModule_Path_Gallery."/".$RowPicture[$myModule_Table_Gallery."_Thumbnail"]);
		}
			if(file_exists($myModule_Path_Gallery."/".$RowPicture[$myModule_Table_Gallery."_Picture"])) {
					unlink($myModule_Path_Gallery."/".$RowPicture[$myModule_Table_Gallery."_Picture"]);
		}
		$sql="DELETE  FROM ".$myModule_Table_Gallery." WHERE ".$myModule_Table_Gallery."_ID = '$PID'";
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
?>
            <form action="?" method="post" name="myForm" id="myForm">
              <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
              <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
              <input name="action" type="hidden" id="action" value="edit">
			  <input name="myCheckBoxID" type="hidden" id="myCheckBoxID" value="<?=$NID?>">
              <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
              <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
              <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
              <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
              <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
              <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
            </form>
            <script language="JavaScript" type="text/JavaScript"> document.myForm.submit(); </script>
<? 
#########################################################
}else if ($action=="deletePicture2") {  
		$sql = "UPDATE ".$myModule_Table." SET ".$myModule_Table."_PictureFile='' WHERE ".$myModule_Table."_ID=".$PID;
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
?>
            <form action="?" method="post" name="myForm" id="myForm">
              <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
              <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
              <input name="action" type="hidden" id="action" value="edit">
			  <input name="myCheckBoxID" type="hidden" id="myCheckBoxID" value="<?=$NID?>">
              <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
              <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
              <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
              <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
              <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
              <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
            </form>
            <script language="JavaScript" type="text/JavaScript"> document.myForm.submit(); </script>
<? 
#########################################################
} else if ($action=="deleteVideo") { 
$sql="SELECT * FROM ".$myModule_Table_Video." WHERE ".$myModule_Table_Video."_ID='".$PID."' ";
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
	$RowVideo=mysql_fetch_array($Query);
	if(file_exists($myModule_Path_Video."/".$RowVideo[$myModule_Table_Video."_Video"])) {
					unlink($myModule_Path_Video."/".$RowVideo[$myModule_Table_Video."_Video"]);
		}
		$sql="DELETE  FROM ".$myModule_Table_Video." WHERE ".$myModule_Table_Video."_ID = '$PID'";
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
?>
            <form action="?" method="post" name="myForm" id="myForm">
              <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
              <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
              <input name="action" type="hidden" id="action" value="edit">
			  <input name="myCheckBoxID" type="hidden" id="myCheckBoxID" value="<?=$NID?>">
              <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
              <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
              <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
              <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
              <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
              <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
            </form>
            <script language="JavaScript" type="text/JavaScript"> document.myForm.submit(); </script>
<? 
#########################################################
} else if ($action=="setmove") { 
	$myCheckBoxID=0;
	for($i=1;$i<=$TotalCheckBoxID;$i++) {
		$myVar="CheckBoxID".$i;
		if(strlen($$myVar)>0) {
			$myCheckBoxID=$$myVar;
		}
	}
	$sql = "SELECT * FROM". $myModule_Table.
	
	$sql="UPDATE ".$myModule_Table." SET ".$myModule_Table."_ModuleKey='$SelectMove' WHERE ".$myModule_Table."_ID=".$myCheckBoxID;
	//die($sql);
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
?>
            <form action="?" method="post" name="myForm" id="myForm">
              <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
              <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
              <input name="action" type="hidden" id="action">
              <input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
              <input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
              <input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
              <input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
              <input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
              <input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
            </form>
            <script language="JavaScript" type="text/JavaScript"> document.myForm.submit(); </script>
            
			<? 
//########################################################
} else if ($action=="makeordering") { 
	$sql = "SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ModuleKey='$SystemModuleKey'  AND " .$myModule_Table."_Language='$System_Session_Language'";
	if($GroupID!=""){
	$sql=$sql." AND ".$myModule_Table."_GID=".$GroupID;
	}
	$sql=$sql." Order by ".$myModule_Table."_Order $ASCDESC ";
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
	$RecordCount=MYSQL_NUMROWS($Query);
?>
<table width="500" border="0" cellpadding="0" cellspacing="1">
<form action="?" method="post" name="myRedirectForm" id="myRedirectForm">
<input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
<input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
<input name="action" type="hidden" id="action">
<input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
<input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
<input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
<input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
<input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
<input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
</form>
<form action="?" method="post" name="myForm" id="myForm">
<input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
<input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
<input name="action" type="hidden" id="action">
<input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
<input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
<input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
<input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
<input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
<input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
<tr> 
<td class="table_form_bg1"><table width="100%" border="0" cellpadding="2" cellspacing="1" class="mytable_inner">
<tr align="center"> 
<td height="24" colspan="2" align="center" class="menu_table_header">Make Ordering <?=getMenuName($SystemMenuID)?></td>
</tr>
<tr> 
<td width="100" align="right" valign="top" class="table_col1"><br> 
<?=getMenuName($SystemMenuID)?>
List&nbsp;</td>
<td height="40" align="left" class="table_col2"> <table height="60" border="0" cellpadding="2" cellspacing="0">
<tr> 
<td align="center"> <select name="listUser[]" size="15" multiple class="input_textarea" id="listUser" style="width:200">
<?
if($RecordCount>0) {
	$index=1;
	while($index<$RecordCount+1) {
		$Row=MYSQL_FETCH_ARRAY($Query);
		echo "<option value=\"".$Row[$myModule_Table."_ID"]."\">";
			echo $Row[$myModule_Table."_Subject"];
		echo "</option>\n";
		$index++;
	}
}
?>
</select> </td>
<td valign="top"><table height="100%" border="0" cellpadding="1" cellspacing="0">
<tr> 
<td height="10"><input type="button"  class="button_100" id="RemoveUp" name="RemoveUp"  value="Move Up" onClick="funcMultipleMoveUp(document.myForm.elements['listUser[]'])"></td>
</tr>
<tr> 
<td><script language="JavaScript" type="text/JavaScript">
function funcMultipleSelectAll(myListObj) {
	var Len = myListObj.options.length;
	if(Len>0) 
		for(var i=0;i<Len;i++)
		   myListObj.options[i].selected=true;
}
function funcMultipleMoveUp(myListObj) {
	var Len = myListObj.options.length;
	var tmpID,tmpValue;
	if(Len>0) 
		for(var i=1;i<Len;i++)
	    	if (myListObj.options[i]!=null && myListObj.options[i].selected==true) {
					if(!myListObj.options[i-1].selected) {
					   myListObj.options[i].selected=false;
					   tmpID = myListObj.options[i].value;
					   tmpValue = myListObj.options[i].text;
					   myListObj.options[i].value = myListObj.options[i-1].value;
					   myListObj.options[i].text = myListObj.options[i-1].text;
					   myListObj.options[i-1].value = tmpID;
					   myListObj.options[i-1].text = tmpValue;
					   myListObj.options[i-1].selected=true;
				}
			}
}
function funcMultipleMoveDown(myListObj) {
	var Len = myListObj.options.length;
	var tmpID,tmpValue;
	if(Len>0) 
		for(var i=Len-2;i>=0;i--)
	    	if (myListObj.options[i]!=null && myListObj.options[i].selected==true) {
					if(!myListObj.options[i+1].selected) {
					   myListObj.options[i].selected=false;
					   tmpID = myListObj.options[i].value;
					   tmpValue = myListObj.options[i].text;
					   myListObj.options[i].value = myListObj.options[i+1].value;
					   myListObj.options[i].text = myListObj.options[i+1].text;
					   myListObj.options[i+1].value = tmpID;
					   myListObj.options[i+1].text = tmpValue;
					   myListObj.options[i+1].selected=true;
				}
			}
}
								  </script> </td>
</tr>
<tr> 
<td height="10"><input type="button"  class="button_100" id="MoveDown" name="MoveDown"  value="Move Down" onClick="funcMultipleMoveDown(document.myForm.elements['listUser[]'])"></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" height="24" border="0" cellpadding="3" cellspacing="0" class="table_button_bottom">
<tr align="right"> 
<td height="30" colspan="4" align="center" class="table_footer"> 
<table width="300" border="0" cellspacing="0" cellpadding="2">
<tr align="center"> 
<td> <input name="btSave" type="button" class="button_80" id="btSave" value="Save"  onClick="
if(confirm('Are you sure to save a change?')) {
document.myForm.action.value='updateordering';
funcMultipleSelectAll(document.myForm.elements['listUser[]']);
document.myForm.submit();
}
"> </td>
<td> <input name="btCalcel" type="button" class="button_80" id="btCalcel" onClick="
if(confirm('Are you sure to return to list?')) {
document.myRedirectForm.submit();
}
" value="Cancel"> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</form>
</table>
<br>
<? 
//########################################################
} else if ($action=="updateordering") { 
$index=1;
if($listUser!="") {
	while (list ($key, $val) = each ($listUser)) {
	$valueOrder=($CountList-$index)+1;
		$sql="UPDATE ".$myModule_Table." SET ".$myModule_Table."_Order='$valueOrder' WHERE ".$myModule_Table."_ID=".$val;
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
		$index++;
	}
}
?>
<form action="?" method="post" name="myForm" id="myForm">
<input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
<input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
<input name="action" type="hidden" id="action">
<input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
<input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
<input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
<input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
<input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
<input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">

</form>
            <script language="JavaScript" type="text/JavaScript"> document.myForm.submit(); </script>
<?	
#########################################################
} else { ?>
            <?
# Check to set default value #########################
if($PageSize=="") { $PageSize = $SystemModule_defaultPageSize; }
if($PageShow=="") { $PageShow = $SystemModule_defaultPageShow; }
//if($ASCDESC=="") { $ASCDESC = "DESC"; } 
$ASCDESC = "DESC";
if($OrderBy=="") { $OrderBy = $myModule_Table."_Order"; } 
//$OrderBy = $SystemModule_ID;
if($action=="switchorder") { 
	if($ASCDESC=="DESC") { $ASCDESC = "ASC"; }  else { $ASCDESC="DESC"; } 
} 
if($PageSearch!="") { $PageSearch=trim($PageSearch); }

# Count total record size #########################
if($PageSearch=="") { //debug($System_Session_Language);
	$sql = "SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ModuleKey='$SystemModuleKey'  AND ".$myModule_Table."_Language='$System_Session_Language'  ";
} else {
	$sql = "SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ModuleKey='$SystemModuleKey' AND ".$myModule_Table."_Language='$System_Session_Language'   AND ( ".
	$myModule_Table."_Subject LIKE '%$PageSearch%' OR ".
	$myModule_Table."_Title LIKE '%$PageSearch%' ) ";
}

if($inputStartDateSearch!="" && $inputExpireDateSearch!="") {
$sql = $sql." AND (".$myModule_Table."_CreateDate BETWEEN ".$inputStartDateSearch." AND ".$inputExpireDateSearch." )";
//die($sql);
}
if($GroupID!=""){
$sql = $sql." AND ".$myModule_Table."_GID = ".$GroupID; 
}

$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
$TotalRecordCount=MYSQL_NUMROWS($Query);

# Find max page size #########################
if($TotalRecordCount>$PageSize) {
	$NoOfPage= ceil($TotalRecordCount/$PageSize);
} else {
	$NoOfPage=1;
}
# Recover page show into range #########################
if($PageShow>$NoOfPage) { $PageShow=$NoOfPage; }

# Select only paging range #########################
$RecordStart = ($PageShow-1)*$PageSize;
$sql=$sql." ORDER BY $OrderBy $ASCDESC LIMIT $RecordStart , $PageSize";
$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
$RecordCount=MYSQL_NUMROWS($Query);
?>
            <script language="JavaScript" type="text/JavaScript">
function Paging_CheckAll(objCheckHeader,txtCheckBoxFirstName,intTotalItems) {
	if(intTotalItems>0)
		for(i=1;i<=intTotalItems;i++)
			document.getElementById(txtCheckBoxFirstName+i).checked = objCheckHeader.checked;			
	return true;
}
function Paging_CheckAllHandle(objCheckHeader,txtCheckBoxFirstName,intTotalItems) {
	var isCheckedAll = true;
	if(intTotalItems>0)
		for(i=1;i<=intTotalItems;i++)
			if(!document.getElementById(txtCheckBoxFirstName+i).checked) 
				isCheckedAll = false;
	objCheckHeader.checked = isCheckedAll;
	return true;
}
function Paging_CountChecked(txtCheckBoxFirstName,intTotalItems) {
	var intChecked = 0;
	if(intTotalItems>0)
		for(i=1;i<=intTotalItems;i++)
			if(document.getElementById(txtCheckBoxFirstName+i).checked) 
				intChecked ++;
	return intChecked ;
}
function Paging_CheckedThisItem(objCheckHeader,indexing,txtCheckBoxFirstName,intTotalItems) {
	if(intTotalItems>0)
		for(i=1;i<=intTotalItems;i++)
			if(i==indexing) {
				document.getElementById(txtCheckBoxFirstName+i).checked = true;
			} else {
				document.getElementById(txtCheckBoxFirstName+i).checked = false;
			}
	objCheckHeader.checked = false;
	return true;
}
</script>
		<div id="divDataPicker" style="display:none; position:absolute; top:-115px; left:180px; width: 200px; z-index: 1;Filter:Alpha(opacity=95)"> 
		<table width="100%" border="1" cellpadding="0" cellspacing="0" class="layer_bg1">
		<form action="?" method="post" name="myStatusForm" id="myStatusForm">
		<input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
		<input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
		<input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
		<tr> 
		<td height="22"><table width="100%" height="22" border="0" cellpadding="0" cellspacing="0" class="menu_table_header">
		<tr> 
		<td width="28" align="center"><img src="../images/icon/ico439.gif" width="19" height="15"></td>
		<td align="center">Select Status</td>
		<td width="22" align="center"><img src="../images/icon/ico215.gif" width="16" height="16" onMouseOver="this.style.cursor='hand'" onClick="document.getElementById('divDataPicker').style.display='none'; "></td>
		</tr>
		</table></td>
		</tr>
		<tr> 
		<td height="120" align="center" class="table_row1"><br> <table width="120" border="0" cellpadding="2" cellspacing="0">
		<tr> 
		<td width="26" height="22" align="center"><input name="toolbarStatus" type="radio" class="form_checkbox" value="Enable" checked></td>
		<td height="22" class="text_bold">Enable</td>
		</tr>
		<tr> 
		<td width="26" height="22" align="center"><input name="toolbarStatus" type="radio" class="form_checkbox" value="Home" checked></td>
		<td height="22" class="text_bold">Home page</td>
		</tr>
		<tr> 
		<td width="26" height="22" align="center"><input name="toolbarStatus" type="radio" class="form_checkbox" value="Disable"></td>
		<td height="22" class="text_bold">Disable</td>
		</tr>
		</table>
		<br> <table border="0" cellspacing="0" cellpadding="6">
		<tr> 
		<td><input name="btSave" type="button" class="button_th_60" id="btSave" value="Save" onClick="
		if(document.myStatusForm.toolbarStatus[0].checked) {
		document.myForm.SelectStatus.value=document.myStatusForm.toolbarStatus[0].value;
		}
		if(document.myStatusForm.toolbarStatus[1].checked) {
		document.myForm.SelectStatus.value=document.myStatusForm.toolbarStatus[1].value;
		}
		if(document.myStatusForm.toolbarStatus[2].checked) {
		document.myForm.SelectStatus.value=document.myStatusForm.toolbarStatus[2].value;
		}
		document.myForm.action.value='setstatus';
		Paging_CheckedThisItem(document.myForm.CheckBoxAll, StatusIndex ,'CheckBoxID', document.myForm.TotalCheckBoxID.value );
		document.myForm.submit();
		"></td>
		<td><input name="btClose" type="button" class="button_th_60" id="btClose" value="Close" onClick="document.getElementById('divDataPicker').style.display='none';"></td>
		</tr>
		</table></td>
		</tr>
		</form>
		</table>
		</div>
		    <script language="JavaScript" type="text/JavaScript">
		var StatusIndex=0;
		function ShowDataPicker(myDivName,RefX,RefY) {
		document.getElementById(myDivName).style.display=''; 
		document.getElementById(myDivName).style.left = document.body.scrollLeft + window.event.clientX + RefX;
		document.getElementById(myDivName).style.top = document.body.scrollTop + window.event.clientY + RefY;
		}
		</script>
		 <script language="JavaScript" type="text/JavaScript">
		 
		var StatusIndex=0;
		function ShowDataPicker(myDivName,RefX,RefY) {
		document.getElementById(myDivName).style.display=''; 
		document.getElementById(myDivName).style.left = document.body.scrollLeft + window.event.clientX + RefX;
		document.getElementById(myDivName).style.top = document.body.scrollTop + window.event.clientY + RefY;
		}
		</script>
		<table width="95%" height="22" border="0" cellpadding="2" cellspacing="0">
		<form action="?" method="post" name="myHeaderButton" id="myHeaderButton" onSubmit="return false;">
		<input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
		<input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
		<input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
		<input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
		<tr valign="bottom"> 
		<td width="40%" valign="bottom"> <table border="0" cellspacing="0" cellpadding="2">
		<tr> 
		<?
					$sql_permission="SELECT * FROM ".$System_TableName_Menu.
			" LEFT JOIN ".$System_TableName_StaffOnPermission." ON ".$System_TableName_Menu."_ID=".$System_TableName_StaffOnPermission."_MenuID".
			" WHERE ".$System_TableName_StaffOnPermission."_StaffID=".$System_Session_User_ID;
			$Query_permission = mysql_query($sql_permission);
			while ($Row_Permission = mysql_fetch_array($Query_permission)) {
					if ($Row_Permission[$System_TableName_StaffOnPermission."_Permission"]<>"") {
						$System_Session_Permission[$Row_Permission[$System_TableName_StaffOnPermission."_MenuID"]] = $Row_Permission[$System_TableName_StaffOnPermission."_Permission"];
					} else {
						$System_Session_Permission[$Row_Permission[$System_TableName_StaffOnPermission."_MenuID"]] = "NA";
					}
			}
		?>
		<?  //debug($SystemMenuID);
		if($System_Session_Permission[$SystemMenuID]=="RW" ){ ?>
		<td><input name="btAdd2" type="button" class="button_80" id="btAdd2" value="Add New" onClick="
		document.myForm.action.value='add';
		document.myForm.submit();
		"></td>
		<? } ?>
		<td><input name="btView" type="button" class="button_60" id="btView" onClick="
		if(Paging_CountChecked('CheckBoxID',document.myForm.TotalCheckBoxID.value)==1) {
		document.myForm.action.value='view';
		document.myForm.submit();
		} else {
		alert('Please checked 1 item to view this record.');
		}
		" value="View"></td>
		<? if($System_Session_Permission[$SystemMenuID]=="RW" ){ ?>
		<td><input name="btEdit" type="button" class="button_60" id="btEdit" onClick="
		if(Paging_CountChecked('CheckBoxID',document.myForm.TotalCheckBoxID.value)==1) {
		document.myForm.action.value='edit';
		document.myForm.submit();
		} else {
		alert('Please checked 1 item to edit this record.');
		}
		" value="Edit"></td><? } ?>
		<? 
		$sql_staff="SELECT * FROM ".$System_TableName_Staff." WHERE ".$System_TableName_Staff."_ID='".$System_Session_User_ID."'";
		$Query_staff=MYSQL_DB_QUERY($System_DataBase_Name,$sql_staff);
		$Row_staff=MYSQL_FETCH_ARRAY($Query_staff);
		if($System_Session_Permission[$SystemMenuID]=="RW" && $Row_staff[$System_TableName_Staff."_Level"]=="Admin"){ ?>
		<td><input name="btDelete" type="button" class="button_60" id="btDelete" onClick="
		if(Paging_CountChecked('CheckBoxID',document.myForm.TotalCheckBoxID.value)>0) {
		if(confirm('Are you sure to delete selected record?')) {
		document.myForm.action.value='delete';
		document.myForm.submit();
		}
		} else {
		alert('Please checked 1 or more item to delete record.');
		}
		" value="Delete">
		</td>
		<? } ?>
		</tr>
		</table></td>
		<td width="60%" align="right">&nbsp;</td>
		</tr>
		</form>
		</table>
		<table width="98%" height="26" border="0" cellpadding="0" cellspacing="0" class="table_toolbar">
		<form action="?" method="post" name="myToolbarForm" id="myToolbarForm" onSubmit="return false;">
		<input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
		<input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
		<input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
		<tr> 
		<td width="5" align="left" valign="top"> <img src="../images/bgborder1w.gif" width="5" height="5"></td>
		<td valign="bottom"> <table border="0" cellpadding="2" cellspacing="0" class="toolbar">
		<tr> 
		<td width="10">&nbsp;</td>
		<td>Page</td>
		<td> 
		<? 
		if($NoOfPage>1) { 
		?>
		<select name="toolbarPageShow" class="select" onChange="document.myForm.PageShow.value=this.value; document.myForm.submit(); ">
		<? 
		if($NoOfPage<$SystemModule_MaxPage) {
		// Show page list #########################
		for($i=1;$i<=$NoOfPage;$i++) { 
		echo "<option value=\"$i\"";
		if($i==$PageShow) { echo " selected"; }
		echo ">$i</option>";
		} 
		}  else {
		// # If total page count greater than default max page  value then reduce page select size #########################
		$starti = $PageShow-$SystemModule_ReduceRange;
		if($starti<1) { $starti=1; }
		$endi = $PageShow+$SystemModule_ReduceRange;
		if($endi>$NoOfPage) { $endi=$NoOfPage; }
		//#####################
		for($i=$starti ;$i<=$endi;$i++) { 
		echo "<option value=\"$i\"";
		if($i==$PageShow) { echo " selected"; }
		echo ">$i</option>";
		} 
		}
		?>
		</select> 
		<? 
		} else { 
		echo "1";
		}
		?>
		</td>
		<td>of 
		<?=$NoOfPage?>
		</td>
		<td width="10">&nbsp;</td>
		<td>Page size</td>
		<td> <input name="toolbarPageSize" type="text" class="input_center" id="toolbarPageSize" value="<?=$PageSize?>" size="3" maxlength="3"></td>
		<td> <input name="btChangePageSize" type="button" class="button_normal" id="btChangePageSize" value=" Go " onClick="
		if(isNaN(document.myToolbarForm.toolbarPageSize.value*1)) {
		document.myToolbarForm.toolbarPageSize.value='<?=$PageSize?>';
		document.myToolbarForm.toolbarPageSize.focus();
		return false;
		}
		if(document.myToolbarForm.toolbarPageSize.value<=0) {
		document.myToolbarForm.toolbarPageSize.value='<?=$PageSize?>';
		document.myToolbarForm.toolbarPageSize.focus();
		return false;
		}
		document.myForm.PageSize.value=document.myToolbarForm.toolbarPageSize.value; 
		document.myForm.submit(); 
		"> </td>
		</tr>
		</table></td>
		<td align="right" valign="bottom"> <table border="0" cellpadding="0" cellspacing="0">
		<tr> 
		<td>Found 
		<?=$TotalRecordCount?>
		record(s)</td>
		<td width="10">&nbsp;</td>
		<? if($PageShow>1) { ?>
		<td width="21" align="center"> <img src="../images/controlpage/playset_start.gif" width="21" height="21" 
		onMouseOver="this.src='../images/controlpage/playset_start_active.gif'; this.style.cursor='hand';" 
		onMouseOut="this.src='../images/controlpage/playset_start.gif';" 
		onClick="document.myForm.PageShow.value=1; document.myForm.submit();"></td>
		<? } else { ?>
		<td width="21" align="center"><img src="../images/controlpage/playset_start_disable.gif" width="21" height="21"></td>
		<? } ?>
		<? if($PageShow>1) { ?>
		<td width="21" align="center"> <img src="../images/controlpage/playset_backward.gif" width="21" height="21" 
		onMouseOver="this.src='../images/controlpage/playset_backward_active.gif'; this.style.cursor='hand';" 
		onMouseOut="this.src='../images/controlpage/playset_backward.gif';" 
		onClick="document.myForm.PageShow.value--; document.myForm.submit();"></td>
		<? } else { ?>
		<td width="21" align="center"><img src="../images/controlpage/playset_backward_disable.gif" width="21" height="21"></td>
		<? } ?>
		<td width="21" align="center"> <img src="../images/controlpage/playset_stop.gif" width="21" height="21" 
		onMouseOver="this.src='../images/controlpage/playset_stop_active.gif'; this.style.cursor='hand';" 
		onMouseOut="this.src='../images/controlpage/playset_stop.gif';" 
		onClick="
		with(document.myForm) {
		GroupID.value='';
		PageShow.value='';
		PageSize.value='';
		ASCDESC.value='';
		OrderBy.value='';
		PageSearch.value='';
		submit();
		}
		"></td>
		<? if($PageShow<$NoOfPage) { ?>
		<td width="21" align="center"> <img src="../images/controlpage/playset_forward.gif" width="21" height="21" 
		onMouseOver="this.src='../images/controlpage/playset_forward_active.gif'; this.style.cursor='hand';" 
		onMouseOut="this.src='../images/controlpage/playset_forward.gif';" 
		onClick="document.myForm.PageShow.value++; document.myForm.submit();"></td>
		<? } else { ?>
		<td width="10" align="center"><img src="../images/controlpage/playset_forward_disable.gif" width="21" height="21"></td>
		<? } ?>
		<? if($PageShow<$NoOfPage) { ?>
		<td width="10" align="center"><img src="../images/controlpage/playset_end.gif" width="21" height="21" 
		onMouseOver="this.src='../images/controlpage/playset_end_active.gif'; this.style.cursor='hand';" 
		onMouseOut="this.src='../images/controlpage/playset_end.gif';" 
		onClick="document.myForm.PageShow.value='<?=$NoOfPage?>'; document.myForm.submit();"></td>
		<? } else { ?>
		<td width="10" align="center"><img src="../images/controlpage/playset_end_disable.gif" width="21" height="21"></td>
		<? } ?>
		</tr>
		</table></td>
		<td width="5" align="right" valign="top"><img src="../images/bgborder2w.gif" width="5" height="5"></td>
		</tr>
		</form>
		</table>
		<table width="98%" border="0" cellpadding="0" cellspacing="1">
		<tr> 
		<td bgcolor="#e7e7e7"> <table width="100%" border="0" cellpadding="1" cellspacing="1">
		<form action="?" method="post" name="myForm" id="myForm">
		<input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
		<input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
		<input name="action" type="hidden" id="action">
		<input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
		<input name="PageSize" type="hidden" id="PageSize" value="<?=$PageSize?>">
		<input name="PageShow" type="hidden" id="PageShow" value="<?=$PageShow?>">
		<input name="ASCDESC" type="hidden" id="ASCDESC" value="<?=$ASCDESC?>">
		<input name="OrderBy" type="hidden" id="OrderBy" value="<?=$OrderBy?>">
		<input name="PageSearch" type="hidden" id="PageSearch" value="<?=$PageSearch?>">
		<input name="inputStartDateSearch" type="hidden" id="inputStartDateSearch" value="<?=$inputStartDateSearch?>">
		<input name="inputExpireDateSearch" type="hidden" id="inputExpireDateSearch" value="<?=$inputExpireDateSearch?>">
		<input name="SelectStatus" type="hidden" id="SelectStatus">
		<input name="SelectMarquee" type="hidden" id="SelectMarquee">
		<input name="SelectMove" type="hidden" id="SelectMove">
		<tr align="center" class="menu_table_header"> 
		<td width="26" height="30"><input name="CheckBoxAll" type="checkbox" class="form_checkbox" id="CheckBoxAll" value="Yes" onClick="Paging_CheckAll(this,'CheckBoxID',document.myForm.TotalCheckBoxID.value)"></td>
		<td width="35" height="30" align="center"> 
		<? 
		$myOrderBy = $myModule_Table."_Order";
		if($OrderBy==$myOrderBy) { 
		if($ASCDESC=="DESC") { ?>
		<img src="../images/controlpage/desc_order.gif" width="7" height="7"> 
		<? }
		if($ASCDESC=="ASC") { ?>
		<img src="../images/controlpage/asc_order.gif" width="7" height="7"> 
		<? }
		} 
		?>
		<a href="#" class="link_headbar" onClick="
		with(document.myForm) { 
		<? if($OrderBy==$myOrderBy) { echo "action.value='switchorder';\n"; } ?>
		OrderBy.value='<?=$myOrderBy?>';
		submit(); 
		}
		">No.</a></td>
		<td width="100" height="30"> Picture</td>
		<td width="313" height="30"> 
		<? 
		$myOrderBy = $myModule_Table."_Subject";
		if($OrderBy==$myOrderBy) { 
		if($ASCDESC=="DESC") { ?>
		<img src="../images/controlpage/desc_order.gif" width="7" height="7"> 
		<? }
		if($ASCDESC=="ASC") { ?>
		<img src="../images/controlpage/asc_order.gif" width="7" height="7"> 
		<? }
		} 
		?>
		<a href="#" class="link_headbar" onClick="
		with(document.myForm) { 
		<? if($OrderBy==$myOrderBy) { echo "action.value='switchorder';\n"; } ?>
		OrderBy.value='<?=$myOrderBy?>';
		submit(); 
		}
		">Subject</a></td>
		<td width="89" height="30"> 
		<? 
		$myOrderBy = $myModule_Table."_StartDate";
		if($OrderBy==$myOrderBy) { 
		if($ASCDESC=="DESC") { ?>
		<img src="../images/controlpage/desc_order.gif" width="7" height="7"> 
		<? }
		if($ASCDESC=="ASC") { ?>
		<img src="../images/controlpage/asc_order.gif" width="7" height="7"> 
		<? }
		} 
		?>
		<a href="#" class="link_headbar" onClick="
		with(document.myForm) { 
		<? if($OrderBy==$myOrderBy) { echo "action.value='switchorder';\n"; } ?>
		OrderBy.value='<?=$myOrderBy?>';
		submit(); 
		}
		"> Date Limit</a> / <br> 
		<? 
		$myOrderBy = $myModule_Table."_LastUpdate";
		if($OrderBy==$myOrderBy) { 
		if($ASCDESC=="DESC") { ?>
		<img src="../images/controlpage/desc_order.gif" width="7" height="7"> 
		<? }
		if($ASCDESC=="ASC") { ?>
		<img src="../images/controlpage/asc_order.gif" width="7" height="7"> 
		<? }
		} 
		?>
		<a href="#" class="link_headbar" onClick="
		with(document.myForm) { 
		<? if($OrderBy==$myOrderBy) { echo "action.value='switchorder';\n"; } ?>
		OrderBy.value='<?=$myOrderBy?>';
		submit(); 
		}
		"> Last Update</a></td>
		<td width="100" height="30" valign="top"> 
		<? 
		$myOrderBy = $myModule_Table."_Status";
		if($OrderBy==$myOrderBy) { 
		if($ASCDESC=="DESC") { ?>
		<img src="../images/controlpage/desc_order.gif" width="7" height="7"> 
		<? }
		if($ASCDESC=="ASC") { ?>
		<img src="../images/controlpage/asc_order.gif" width="7" height="7"> 
		<? }
		} 
		?>
		<a href="#" class="link_headbar" onClick="
		with(document.myForm) { 
		<? if($OrderBy==$myOrderBy) { echo "action.value='switchorder';\n"; } ?>
		OrderBy.value='<?=$myOrderBy?>';
		submit(); 
		}
		">Status</a> / <br>
		Action</td>
		</tr>
		<?
		$index=1;
		if($RecordCount>0) {
		while($index<$RecordCount+1) {
		if($myClassRow=="table_row1") { $myClassRow="table_row2"; } else { $myClassRow="table_row1";  }
		$Row=MYSQL_FETCH_ARRAY($Query);
		?>
		<tr class="<?=$myClassRow?>" onMouseOver="this.className='table_rowover'" onMouseOut="this.className='<?=$myClassRow?>'"> 
		<td width="26" height="85" align="center"> <input name="CheckBoxID<?=$index?>" type="checkbox" class="form_checkbox" id="CheckBoxID<?=$index?>" onClick="Paging_CheckAllHandle(document.myForm.CheckBoxAll,'CheckBoxID',document.myForm.TotalCheckBoxID.value)" value="<?=$Row[$myModule_Table."_ID"]?>"></td>
		<td width="35" height="85" align="center"> 
		<? if($ASCDESC=="ASC"){echo $RecordStart+$index;}else{echo ($TotalRecordCount-($RecordStart+$index)+1);} ?>
		</td>
		<td width="100" height="85" align="center" valign="middle"><a href="#" onClick="
		Paging_CheckedThisItem( document.myForm.CheckBoxAll, <?=$index?>, 'CheckBoxID', document.myForm.TotalCheckBoxID.value );
		document.myForm.action.value='view';
		document.myForm.submit();
		">
<? if($Row[$myModule_Table."_PictureFile"]!=""){?>
<?  $filename = $myModule_Path_ThumbnailPicture."/".$Row[$myModule_Table."_PictureFile"];
		list($width, $height, $type, $attr) = getimagesize("$filename");// ?? dimension
?>		
		<img src="<?=$myModule_Path_ThumbnailPicture?>/<?=$Row[$myModule_Table."_PictureFile"]?>" width="100" border="0"></a></td>
		<? }?>
		<td height="85" valign="top"> <span class="text_bold"> 
		<a href="#" onClick="
		Paging_CheckedThisItem( document.myForm.CheckBoxAll, <?=$index?>, 'CheckBoxID', document.myForm.TotalCheckBoxID.value );
		document.myForm.action.value='view';
		document.myForm.submit();
		"> 
		<?=$Row[$myModule_Table."_Subject"]?>
		</a></span><br> 
		<?
		if(strlen($Row[$myModule_Table."_Title"])>100) {
		echo substr($Row[$myModule_Table."_Title"],0,100)."...";
		}  else {
		echo $Row[$myModule_Table."_Title"];
		}
		?>
<br>		<table width="100%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="14%" class="text_bold">&nbsp;Tag :</td>
            <td width="86%" height="15"><?=$Row[$myModule_Table."_Tag"]?></td>
          </tr>
          <tr>
            <td class="text_bold">&nbsp;Link :</td>
            <td height="15">&nbsp;&nbsp;<? echo ($Row[$myModule_Table."_Url"]<>"") ? "<a href='" . $Row[$myModule_Table."_Url"] . "' target=_blank>" . $Row[$myModule_Table."_Url"] . "</a>" : " - ";?></td>
          </tr>
        </table></td>
		<td width="89" height="85" align="center" valign="middle"> 
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<? if(substr($Row[$myModule_Table."_StartDate"],0,10)!="0000-00-00") { ?>
		<tr> 
		<td align="center">
		<?
		echo "<font class=text_td_date>Date Start</font><br>&nbsp;&nbsp;";
		echo substr($Row[$myModule_Table."_StartDate"],0,10);
		?>
		</td>
		</tr>
		<? } ?>
		<? if(substr($Row[$myModule_Table."_ExpireDate"],0,10)!="0000-00-00") { ?>
		<tr> 
		<td align="center">
		<?
		echo "<font class=text_td_date>Date Expire</font><br>&nbsp;&nbsp;";
		echo substr($Row[$myModule_Table."_ExpireDate"],0,10);
		?>
		</td>
		</tr>
		<? } ?>
		<? if(substr($Row[$myModule_Table."_StartDate"],0,10)=="0000-00-00" && substr($Row[$myModule_Table."_ExpireDate"],0,10)=="0000-00-00") { ?>
		<tr> 
		<td align="center">
		<?
		echo "<font class=text_td_date>Date Limit</font><br>&nbsp;&nbsp;Alway On";
		?>
		</td>
		</tr>
		<? } ?>
		<tr> 
		<td align="center">
		<?
		echo "<font class=text_td_date>Last Update</font><br>&nbsp;&nbsp;";
		echo str_replace(" ", "<br>&nbsp;&nbsp;", $Row[$myModule_Table."_LastUpdate"]);
		?>
		</td>
		</tr>
		</table></td>
		<td height="85" align="center" valign="middle"> 
		<img src="../images/icon/ico442.gif" width="8" height="14">&nbsp; 
		<? if($System_Session_Permission[$SystemMenuID]=="RW" ){ ?>
		<span onMouseOver="this.style.cursor='hand'" onClick="
		if('<?=$Row[$myModule_Table."_Status"]?>'=='Enable') {
		document.myStatusForm.toolbarStatus[0].checked=true;
		}
		if('<?=$Row[$myModule_Table."_Status"]?>'=='Home') {
		document.myStatusForm.toolbarStatus[1].checked=true;
		}
		if('<?=$Row[$myModule_Table."_Status"]?>'=='Disable') {
		document.myStatusForm.toolbarStatus[2].checked=true;
		}
		StatusIndex = <?=$index?>;
		ShowDataPicker('divDataPicker',-230,-150)
		"> 
		<? } 
		if ($Row[$myModule_Table."_Status"]=="Enable") echo "<font class=text_row_enable>";
		else echo "<font class=text_row_disable>";
		?>
		<?=$Row[$myModule_Table."_Status"]?>
		</font></span>
		<br> 
		<table border="0" cellspacing="0" cellpadding="1">
		<tr align="center" valign="bottom"> 
		<? if($System_Session_Permission[$SystemMenuID]=="RW" ){ ?>
		<td width="16"> <img src="../images/icon/makeordering.gif" alt="Move Up" width="15" height="14" border="0" onMouseOver="this.style.cursor='hand'" onClick="
		document.myForm.action.value='makeordering';
		document.myForm.submit();
		"> </td>
		<? } ?>
		<td><img src="../images/icon/ico416.gif" alt="View" width="16" height="21" border="0" onMouseOver="this.style.cursor='hand'" onClick="
		Paging_CheckedThisItem( document.myForm.CheckBoxAll, <?=$index?>, 'CheckBoxID', document.myForm.TotalCheckBoxID.value );
		document.myForm.action.value='view';
		document.myForm.submit();
		"></td>
		<? if($System_Session_Permission[$SystemMenuID]=="RW" ){ ?>
		<td><img src="../images/icon/ico425.gif" alt="Edit" width="16" height="16" border="0" onMouseOver="this.style.cursor='hand'" onClick="
		if(confirm('Are you sure to edit this record?')) {
		Paging_CheckedThisItem( document.myForm.CheckBoxAll, <?=$index?>, 'CheckBoxID', document.myForm.TotalCheckBoxID.value );
		document.myForm.action.value='edit';
		document.myForm.submit();
		}
		"></td><? }?>
		<? if($System_Session_Permission[$SystemMenuID]=="RW" && $Row_staff[$System_TableName_Staff."_Level"]=="Admin"){ ?>
		<td><img src="../images/icon/ico417.gif" alt="Delete" width="16" height="16" border="0" onMouseOver="this.style.cursor='hand'" onClick="
		if(confirm('Are you sure to delete this record?')) {
		Paging_CheckedThisItem( document.myForm.CheckBoxAll, <?=$index?>, 'CheckBoxID', document.myForm.TotalCheckBoxID.value );
		document.myForm.action.value='delete';
		document.myForm.submit();
		}
		"></td><? } ?>
		<? if($System_Session_Permission[$SystemMenuID]=="RW" ){ ?>
		<td>
		<a href="#" class="link_headbar" onClick="
document.myPageRedirectForm.action='comment.php';
document.myPageRedirectForm.NewsID.value='<?=$Row[$myModule_Table."_ID"]?>';
document.myPageRedirectForm.action2.value='viewdetail';
document.myPageRedirectForm.submit();
"><img src="../images/icon/ico521.gif" alt="Comment" width="16" height="14" border="0" >
		</a>
		
		</td>
		<? } ?>
		</tr>
		</table></td>
		</tr>
		<?
		$index++;
		}
		} else {  ?>
		<tr class="table_row1"> 
		<td height="80" colspan="6" align="center"> Data not found!</td>
		</tr>
		<? } ?>
		<input name="TotalCheckBoxID" type="hidden" id="TotalCheckBoxID" value="<?=$index-1?>">
		</form>
		</table>
		<table width="100%" height="24" border="0" cellpadding="3" cellspacing="0" class="table_button_bottom2">
		<form action="?" method="post" name="mySearchForm" id="mySearchForm" onSubmit="return false;">
		<input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
		<input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
		<input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
		<tr align="right"> 
		<td colspan="4" align="right" class="table_footer"> <table border="0" cellpadding="2" cellspacing="0" class="table_footer">
		<tr>
		<td>Start Date Search</td>
		<td><input name="toolbarStartDateSearch" type="text" class="input_center" id="toolbarStartDateSearch" size="10" maxlength="10"> <input type="reset" class="button_normal" onClick="return showCalendar('toolbarStartDateSearch', 'y-mm-dd');" value=" ... "></td>
		<td>Expire Date Search</td>
		<td><input name="toolbarExpireDateSearch" type="text" class="input_center" id="toolbarExpireDateSearch" size="10" maxlength="10"> <input type="reset" class="button_normal" onClick="return showCalendar('toolbarExpireDateSearch', 'y-mm-dd');" value=" ... "></td>
		<td><input name="toolbarPageSearch" type="text" class="input_left" id="toolbarPageSearch" value="<?=$PageSearch?>" size="20" maxlength="50"></td>
		<td><input name="btPageSearch" type="button" class="button_60" id="btPageSearch" value="Search" onClick="
		document.myForm.PageSearch.value=document.mySearchForm.toolbarPageSearch.value;
		document.myForm.inputStartDateSearch.value=document.mySearchForm.toolbarStartDateSearch.value; 
		document.myForm.inputExpireDateSearch.value=document.mySearchForm.toolbarExpireDateSearch.value;
		document.myForm.submit();
		"></td>
		</tr>
		</table></td>
		</tr>
		</form>
		            <script language="javascipt" type="text/javascript">
		if('<?=$GroupID?>'!=""){
		
		document.mySearchForm.GroupID.value='<?=$GroupID?>';
		
		}
		</script>
		</table></td>
		</tr>
		</table>
		<table width="95%" height="22" border="0" cellpadding="2" cellspacing="0">
		<form action="?" method="post" name="myFooterButton" id="myFooterButton" onSubmit="return false;">
		<input type="hidden" id="GroupID" name="GroupID" value="<?=$GroupID?>">
		<input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
		<input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
		<tr> 
		<td valign="top"><table border="0" cellspacing="0" cellpadding="2">
		<tr> 
		<? if($System_Session_Permission[$SystemMenuID]=="RW" ){ ?>
		<td><input name="btAdd" type="button" class="button_80" id="btAdd" value="Add New" onClick="
		document.myForm.action.value='add';
		document.myForm.submit();
		"></td>
		<? } ?>
		<td><input name="btView" type="button" class="button_60" id="btView" onClick="
		if(Paging_CountChecked('CheckBoxID',document.myForm.TotalCheckBoxID.value)==1) {
		document.myForm.action.value='view';
		document.myForm.submit();
		} else {
		alert('Please checked 1 item to view this record.');
		}
		" value="View"></td>
		<? if($System_Session_Permission[$SystemMenuID]=="RW" ){ ?>
		<td><input name="btEdit" type="button" class="button_60" id="btEdit" onClick="
		if(Paging_CountChecked('CheckBoxID',document.myForm.TotalCheckBoxID.value)==1) {
		document.myForm.action.value='edit';
		document.myForm.submit();
		} else {
		alert('Please checked 1 item to edit this record.');
		}
		" value="Edit"></td><? }?>
		<? if($System_Session_Permission[$SystemMenuID]=="RW" && $Row_staff[$System_TableName_Staff."_Level"]=="Admin"){ ?>
		<td><input name="btDelete" type="button" class="button_60" id="btDelete" onClick="
		if(Paging_CountChecked('CheckBoxID',document.myForm.TotalCheckBoxID.value)>0) {
		if(confirm('Are you sure to delete selected record?')) {
		document.myForm.action.value='delete';
		document.myForm.submit();
		}
		} else {
		alert('Please checked 1 or more item to delete record.');
		}
		" value="Delete"></td>
		<? } ?>
		</tr>
		</table></td>
		</tr>
		</form>
		</table>
		<br>
		<? 
		}
		#########################################################
		?>
		<br>
            <!-- InstanceEndEditable --> 
            <? }  else { echo "&nbsp;&nbsp;&nbsp;"; } ?>		</td>
        <td width="17" valign="top" background="../../webengine/images/object/border_07.gif"><img src="../../webengine/images/object/border_17.gif" width="17" height="119"></td>
      </tr>
      <tr>
        <td height="16"><img src="../../webengine/images/object/border_09.gif" width="20" height="16"></td>
        <td height="16" background="../../webengine/images/object/border_11.gif"><img src="../../webengine/images/object/border_11.gif" width="1" height="16"></td>
        <td><img src="../../webengine/images/object/border_13.gif" width="17" height="16"></td>
      </tr>
    </table></td>
        </tr>
      </table></td>
    <td width="1" bgcolor="#A13626"><img src="../../images/blank.gif" width="1" height="1"></td> 
  </tr>
</table>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="4" height="3" align="center" bgcolor="#A13626"><img src="../../images/blank.gif" width="1" height="1"></td>
    <td height="3" align="center" bgcolor="#A13626"><img src="../../images/blank.gif" width="1" height="1"></td>
    <td width="4" height="3" align="center" bgcolor="#A13626"><img src="../../images/blank.gif" width="1" height="1"></td>
  </tr>
  <tr> 
    <td width="4" height="30" align="left" valign="bottom" background="../../images/main/main-t-bg.gif">&nbsp;</td>
    <td height="30" align="center" background="../../images/main/main-t-bg.gif">&nbsp;</td>
    <td width="4" height="30" align="right" valign="bottom" background="../../images/main/main-t-bg.gif">&nbsp;</td>
  </tr>
</table>
<table width="95%" height="22" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td align="left"><font color="#666666">Copyrights <img src="../../images/web/copyright.gif" width="8" height="9"> 
      2008  MOE. All rights are reserved.</font></td>
    <td align="right"><font color="#666666">Powered by <strong><a href="http://www.net-com.co.th">Net-Com</a></strong></font></td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>
<script language="JavaScript" type="text/JavaScript">
		function addGallery(n){
		n=n+1;
		document.getElementById('pic'+n).innerHTML = "<input name=\"inputGallery_"+ n +"\" type=\"file\" class=\"input_left\" id=\"inputGallery_"+ n +"\" size=\"35\" accept=\"application/msexcel\" onChange=\"myfile = this.value;if(myfile!=\'\') {myfile = myfile.toLowerCase();Temp = myfile.charAt(myfile.length-4) + myfile.charAt(myfile.length-3) + myfile.charAt(myfile.length-2) + myfile.charAt(myfile.length-1);if(Temp==\'.jpg\' || Temp==\'.gif\' || Temp==\'jpeg\') {document.getElementById(\'PreviewGallery\').src=myfile;document.getElementById(\'PreviewGalleryText\').innerHTML= document.getElementById(\'PreviewGallery\').width + \'x\' + document.getElementById(\'PreviewGallery\').height + \' pixel\';addGallery("+ n +");} else {alert(\'System allow to upload image files only.\');this.focus();}} else {alert(\'Please click Browse button to select thumbnail picture file.\');this.focus();}\" onMouseOut=\"if(document.getElementById(\'PreviewGallery\').width>1 && document.getElementById(\'PreviewGallery\').height>1) {document.getElementById(\'PreviewGalleryText\').innerHTML= document.getElementById(\'PreviewGallery\').width + \'x\' + document.getElementById(\'PreviewGallery\').height + \' pixel\';}\">";
		} 
		function addVideo(n){
		n=n+1;
		document.getElementById('vdo'+n).innerHTML = " Name: <input name=\"inputVideoName_"+n+"\" type=\"text\" id=\"inputVideoName_"+n+"\" size=\"20\" class=\"input_left\">&nbsp;&nbsp;<input name=\"inputVideo_"+ n +"\" type=\"file\" class=\"input_left\" id=\"inputVideo_"+ n +"\" size=\"35\" accept=\"application/msexcel\" onChange=\"myfile = this.value;if(myfile!=\'\') {myfile = myfile.toLowerCase();Temp = myfile.charAt(myfile.length-4) + myfile.charAt(myfile.length-3) + myfile.charAt(myfile.length-2) + myfile.charAt(myfile.length-1);if(Temp==\'.flv\' || Temp==\'.wmv\') {addVideo("+ n +");} else {alert(\'System allow to upload video files only(*.flv or *.wmv).\');this.focus();}} else {alert(\'Please click Browse button to select video file.\');this.focus();}\">";
		} 
		</script>
<? 
include("../lib/disconnect.php");
?>

Hacked By AnonymousFox1.0, Coded By AnonymousFox