Hacked By AnonymousFox

Current Path : C:/AppServ/www/mfu/webengine/mod_calendar/
Upload File :
Current File : C:/AppServ/www/mfu/webengine/mod_calendar/calendar.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>Web Engine : <?=$System_Variable_Title?></title>
<!-- InstanceEndEditable --> 
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<!-- InstanceBeginEditable name="head" -->
<script type="text/JavaScript">
<!--
function MM_scanStyles(obj, prop) { //v8.0
  var inlineStyle = null; var ccProp = prop; var dash = ccProp.indexOf("-");
  while (dash != -1){ccProp = ccProp.substring(0, dash) + ccProp.substring(dash+1,dash+2).toUpperCase() + ccProp.substring(dash+2); dash = ccProp.indexOf("-");}
  inlineStyle = eval("obj.style." + ccProp);
  if(inlineStyle) return inlineStyle;
  var ss = document.styleSheets;
  for (var x = 0; x < ss.length; x++) { var rules = ss[x].cssRules;
	for (var y = 0; y < rules.length; y++) { var z = rules[y].style;
	  if(z[prop] && (rules[y].selectorText == '*[ID"' + obj.id + '"]')) {
        return z[prop];
  }  }  }  return "";
}

function MM_getProp(obj, prop) { //v8.0
  if (!obj) return ("");
  if (prop == "L") return obj.offsetLeft;
  else if (prop == "T") return obj.offsetTop;
  else if (prop == "W") return obj.offsetWidth;
  else if (prop == "H") return obj.offsetHeight;
  else {
    if (typeof(window.getComputedStyle) == "undefined") {
	    if (typeof(obj.currentStyle) == "undefined"){
		    if (prop == "P") return MM_scanStyles(obj,"position");
        else if (prop == "Z") return MM_scanStyles(obj,"z-index");
        else if (prop == "V") return MM_scanStyles(obj,"visibility");
	    } else {
	      if (prop == "P") return obj.currentStyle.position;
        else if (prop == "Z") return obj.currentStyle.zIndex;
        else if (prop == "V") return obj.currentStyle.visibility;
	    }
    } else {
	    if (prop == "P") return window.getComputedStyle(obj,null).getPropertyValue("position");
      else if (prop == "Z") return window.getComputedStyle(obj,null).getPropertyValue("z-index");
      else if (prop == "V") return window.getComputedStyle(obj,null).getPropertyValue("visibility");
    }
  }
}
//-->
</script>
<!-- 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="../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','../images/bullet/lang_over_02_1.gif','../images/bullet/lang_over_01_1.gif','../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="../system/setlanguage.php?setlang=Thai&&action=setlanguage" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('TopBarTh','','../images/bullet/lang_over_04.gif',1)"><? if($System_Session_Language=="Thai"){$Use = "_over";} else { $Use = "_nor";}?><img src="../images/bullet/lang<?=$Use?>_04.gif" alt="Thai Language" name="TopBarTh" border="0"></a><a href="../system/setlanguage.php?setlang=Eng&&action=setlanguage" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('TopBarEn','','../images/bullet/lang_over_03.gif',1)"><? if($System_Session_Language=="Eng"){$Use = "_over";} else { $Use = "_nor";}?>
                <img src="../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="../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="../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="../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="../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="../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="../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="../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="../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="../images/rare1.gif" bgcolor="#EACFD3" style="background-position:top; background-repeat:repeat-x; "><img src="../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="../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="../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="../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="../images/object/border_03.gif"><img src="../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="table_col3"><img src="../images/blank.gif" width="10" height="2"></td>
                      </tr>
                      <form action="?" method="post" name="myPageRedirectForm" id="myPageRedirectForm">
                        <input name="GroupID" type="hidden" id="GroupID" value="<?=$GroupID?>">
                        <input name="SystemModuleKey" type="hidden" id="SystemModuleKey" value="<?=$SystemModuleKey?>">
                        <input name="SystemMenuID" type="hidden" id="SystemMenuID" value="<?=$SystemMenuID?>">
                        <tr> 
                          <td height="20" align="right"> <table height="20" border="0" cellpadding="0" cellspacing="0">
                              <tr><td width="5" align="left" valign="bottom" class="bar_tab_disable"><img src="images/tab-w.gif" width="1" height="1"></td>
                                <td width="100" align="center" class="bar_tab_disable"><a href="#" class="link_headbar" onClick="
document.myPageRedirectForm.action='index.php';
document.myPageRedirectForm.submit();
								"><b>List View</b></a></td>
                                <td width="20" class="bar_tab_disable"><img src="images/tab-w-slop-down.gif" width="20" height="20"></td>
                                <td width="5" align="left" valign="bottom" class="table_col3"><img src="images/tab-w.gif" width="1" height="1"></td>
                                <td width="120" align="center" class="table_col3"><strong><!--<a href="#" onClick="
document.myPageRedirectForm.action='calendar.php';
document.myPageRedirectForm.submit();
">--><font color="#660000">Calendar View</font><!--</a>--></strong></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"></td>
                                <td width="100" align="center" class="bar_tab_disable"><a href="#" class="link_headbar" onClick="
document.myPageRedirectForm.action='group.php';
document.myPageRedirectForm.submit();
								"><b>Group</b></a></td>
                                <td width="20" class="bar_tab_disable"><img src="images/tab-w-slop-down.gif" width="20" height="20"></td>
                                <td width="30">&nbsp;</td>
                              </tr>
                            </table></td>
                        </tr>
                      </form>
                    </table>
                    <script language="JavaScript" src="../lib/popup.js" type="text/JavaScript"></script>
                    <? 
## 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";
$myModule_Table = $myModule_Table1;
$SystemModule_OrderBy = $myModule_Table."_ID";
#########################################################

if($myDate=="") { $myDate=getDateNow(); }
if($myTime=="") { $myTime=getTimeNow(); }

?>
                    <? 
####################################################################
if($action=="view") { 
	$sql="SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ID=".$myCalID;
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
	$Row=MYSQL_FETCH_ARRAY($Query);
	$HTMLsrc = $myModule_Path_HTMLFiles."/".$Row[$myModule_Table."_HtmlFile"];
	
	?>
                    <br>
                    <table width="98%" border="0" cellpadding="0" cellspacing="1" class="table_header">
                      <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 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="myCalID" type="hidden" id="myCalID" value="<?=$myCalID?>">
                      </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" value="edit">
                        <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="myCalID" type="hidden" id="myCalID" value="<?=$myCalID?>">
                        <input name="TotalCheckBoxID" type="hidden" id="TotalCheckBoxID" value="1">
						 <input name="myCalID" type="hidden" id="myCalID" value="<?=$myCalID?>">
                        <tr> 
                          <td bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="2" cellspacing="1">
                              <tr> 
                                <td height="24" colspan="2" align="center" class="menu_table_header">View 
                                  <?=getMenuName($SystemMenuID)?>
                                </td>
                              </tr>
                              <tr> 
                                <td height="22" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Date 
                                  Information</td>
                              </tr>
                              <tr> 
                                <td width="17%" height="22" align="right" class="table_col1">Date 
                                  From&nbsp;</td>
                                <td width="83%" height="22" class="table_col2"> 
                                  <?=ShowDateEn($Row[$myModule_Table."_DateFrom"])?>
                                </td>
                              </tr>
                              <tr> 
                                <td height="22" align="right" class="table_col1">Date 
                                  To&nbsp;</td>
                                <td height="22" class="table_col2"> 
                                  <?=ShowDateEn($Row[$myModule_Table."_DateTo"])?>
                                </td>
                              </tr>
                              <tr> 
                                <td height="22" align="right" class="table_col1">Time&nbsp;</td>
                                <td height="22" class="table_col2"> 
                                  <? if($Row[$myModule_Table."_TimeTo"]=="00:00:00") { ?>
                                  <?=substr($Row[$myModule_Table."_TimeFrom"],0,5)?>
                                  <? } else { ?>
                                  <?=substr($Row[$myModule_Table."_TimeFrom"],0,5)." - ".substr($Row[$myModule_Table."_TimeTo"],0,5)?>
                                  <? } ?>
                                </td>
                              </tr>
							  <tr>
							  <td height="22" align="right" class="table_col1">Group&nbsp;</td>
                                <td height="22" class="table_col2"> 
								<?
								$GroupID = $Row[$myModule_Table."_GroupID"];
								$sql = "SELECT ".$myModule_Table1Group."_Name  FROM ".$myModule_Table1Group." WHERE ".$myModule_Table1Group."_ID = '$GroupID'";
								$QueryG=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
								$RowG = MYSQL_FETCH_ARRAY($QueryG);
								echo $RowG[0];
								?>
                                  
                                </td>
							</tr>
                              <tr> 
                                <td height="22" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Activity 
                                  Information </td>
                              </tr>
                              <tr> 
                                <td height="22" align="right" class="table_col1">Subject&nbsp;</td>
                                <td height="22" class="table_col2"> 
                                  <?=$Row[$myModule_Table."_Subject"]?>
                                </td>
                              </tr>
                              <tr>
                                <td height="22" align="right" class="table_col1">Location&nbsp; </td>
                                <td height="22" class="table_col2"><?=nl2br($Row[$myModule_Table."_Location"])?></td>
                              </tr>
                              <tr>
                                <td height="22" align="right" class="table_col1">Url </td>
                                <td height="22" class="table_col2"><?=$Row[$myModule_Table."_Url"]?></td>
                              </tr>
                              <tr>
                                <td height="22" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Files </td>
                              </tr>
                              <tr>
                                <td height="22" align="right" class="table_col1">Document Files&nbsp;</td>
                                <td height="22" class="table_col2">
								<?
		$sqlFile = "SELECT * FROM ".$myModule_Table1_FileUpload." WHERE ".$myModule_Table1_FileUpload."_CalID = '".$myCalID."'";
	$QueryFile=MYSQL_DB_QUERY($System_DataBase_Name,$sqlFile) or die(mysql_error());				
		while ($RowFile=MYSQL_FETCH_ARRAY($QueryFile)){
						$LinkRelativePath = $myModule_Path_UploadFiles."/".$RowFile[$myModule_Table1_FileUpload."_FileUpload"];
						$DownloadFile = $RowFile[$myModule_Table1_FileUpload."_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_Table1_FileUpload."_FileUploadName"];?>
                        </strong></a>&nbsp;&nbsp;
		<? }?></td>
                              </tr>
                              <tr style="display:none; ">
                                <td height="22" align="right" class="table_col1">Thumbnail Picture</td>
                                <td height="22" class="table_col2"><span class="table_col1">
                                  <?// if($Row[$myModule_Table."_PictureFile"]){?>
                                  <img src="<?=$myModule_Path_ThumbnailPicture?>/<?=$Row[$myModule_Table."_PictureFile"]?>" border="0">
                                  <?// }?>
                                </span></td>
                              </tr>
                              <tr style="display:none; ">
                                <td height="22" align="right" class="table_col1">Picture File name </td>
                                <td height="22" class="table_col2"><?=$Row[$myModule_Table."_PictureFile"]?></td>
                              </tr>
                              <tr> 
                                <td height="22" align="right" class="table_col1">Tag</td>
                                <td height="22" class="table_col2"><?=$Row[$myModule_Table."_Tag"]?> 
                                </td>
                              </tr>
                              <tr> 
                                <td height="22" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Activity 
                                  Detail </td>
                              </tr>
                              <tr align="center" valign="top"> 
                                <td height="350" colspan="2" class="table_col2"><table width="100%" height="300" border="0" align="center" cellpadding=1 cellspacing=1  bordercolorlight="#000000" bordercolordark="#E0E0E0" bgcolor="#AAAAAA" class="table_border" id="htmltool_table">
                                    <tr> 
                                      <td valign="top" bgcolor="#FFFFFF"> 
                                        <?
$filename = $myModule_Path_HTMLFiles."/".$Row[$myModule_Table."_HtmlFile"];
$fd = fopen ($filename, "r");
$contents = fread ($fd, filesize ($filename));
fclose ($fd);
echo $contents;
?>
                                      </td>
                                    </tr>
                                  </table></td>
                              </tr>
							  
                            </table>
                            <table width="100%" height="24" border="0" cellpadding="3" cellspacing="0">
                              <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="button" 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="
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>
                    <? 
####################################################################
 } else if($action=="add") { 
	$HTMLToolContentBG = "#FFFFFF";
	$myTimeArray = explode(":",$myTime);
	$myTimeHH=$myTimeArray [0]*1;
	$myTimeMM=$myTimeArray [1]*1;
	?>
                    <br>
                    <? include("htmltool/header.php"); ?>
                    <!-- 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 -->
                    <table width="98%" border="0" cellpadding="0" cellspacing="1" class="table_header">
                      <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 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" enctype="multipart/form-data">
                        <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 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 bgcolor="#FFFFFF"> <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="22" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Date 
                                  Information 
                                  <input name="inputMod_Calendar_TimeFrom" type="hidden" id="inputMod_Calendar_TimeFrom"> 
                                  <input name="inputMod_Calendar_TimeTo" type="hidden" id="inputMod_Calendar_TimeTo"></td>
                              </tr>
                              <tr> 
                                <td width="140" height="22" align="right" class="table_col1">Date&nbsp;</td>
                                <td height="22" class="table_col2"><table border="0" cellspacing="0" cellpadding="1">
                                    <tr> 
                                      <td nowrap>From&nbsp;</td>
                                      <td><input name="inputMod_Calendar_DateFrom" type="text" class="input_center" id="inputMod_Calendar_DateFrom" value="<?=$myDate?>" size="10" maxlength="10"></td>
                                      <td> <input type="button" class="button_th_normal" onClick="return showCalendar('inputMod_Calendar_DateFrom', 'y-mm-dd');" value=" ... "> 
                                      </td>
                                      <td width="25" align="right"><input name="inputIsDateTo" type="checkbox" id="inputIsDateTo" value="Yes" onClick="if(document.getElementById('idDateTo1').style.display=='') { document.getElementById('idDateTo1').style.display='none'; document.getElementById('idDateTo2').style.display='none'; } else { document.getElementById('idDateTo1').style.display=''; document.getElementById('idDateTo2').style.display=''; } "></td>
                                      <td nowrap>To&nbsp;</td>
                                      <td id="idDateTo1" style="display:none"> 
                                        <input name="inputMod_Calendar_DateTo" type="text" class="input_center" id="inputMod_Calendar_DateTo" value="<?=$myDate?>" size="10" maxlength="10"></td>
                                      <td id="idDateTo2" style="display:none"> 
                                        <input type="button" class="button_th_normal" onClick="return showCalendar('inputMod_Calendar_DateTo', 'y-mm-dd');" value=" ... "></td>
                                    </tr>
                                  </table></td>
                              </tr>
                              <tr> 
                                <td height="22" align="right" class="table_col1">Time&nbsp;</td>
                                <td height="22" class="table_col2"><table border="0" cellspacing="0" cellpadding="1">
                                    <tr> 
                                      <td width="30">From</td>
                                      <td><select name="inputTimeFromHH" class="select" id="inputTimeFromHH">
                                          <? for($i=0;$i<=23;$i++) { if($i<10) { $myi= "0".$i; } else { $myi=$i; } ?>
                                          <option value="<?=$myi?>"<? if($myTimeHH==$i) { echo " selected"; } ?>> 
                                          <?=$myi?>
                                          </option>
                                          <? } ?>
                                        </select></td>
                                      <td><b>:</b></td>
                                      <td><select name="inputTimeFromMM" class="select" id="inputTimeFromMM">
                                          <? for($i=0;$i<=59;$i++) { if($i<10) { $myi= "0".$i; } else { $myi=$i; } ?>
                                          <option value="<?=$myi?>"<? if($myTimeMM==$i) { echo " selected"; } ?>> 
                                          <?=$myi?>
                                          </option>
                                          <? } ?>
                                        </select></td>
                                      <td width="37" align="right"><input name="inputIsTimeTo" type="checkbox" id="inputIsTimeTo" value="Yes" onClick="if(document.getElementById('idTimeTo1').style.display=='') { document.getElementById('idTimeTo1').style.display='none'; document.getElementById('idTimeTo2').style.display='none';  document.getElementById('idTimeTo3').style.display='none'; } else { document.getElementById('idTimeTo1').style.display=''; document.getElementById('idTimeTo2').style.display=''; document.getElementById('idTimeTo3').style.display=''; } "></td>
                                      <td nowrap>To&nbsp;</td>
                                      <td  id="idTimeTo1" style="display:none"><select name="inputTimeToHH" class="select" id="inputTimeToHH">
                                          <? for($i=0;$i<=23;$i++) { if($i<10) { $myi= "0".$i; } else { $myi=$i; } ?>
                                          <option value="<?=$myi?>"<? if($myTimeHH==$i) { echo " selected"; } ?>> 
                                          <?=$myi?>
                                          </option>
                                          <? } ?>
                                        </select></td>
                                      <td  id="idTimeTo2" style="display:none"><b>:</b></td>
                                      <td  id="idTimeTo3" style="display:none"><select name="inputTimeToMM" class="select" id="inputTimeToMM">
                                          <? for($i=0;$i<=59;$i++) { if($i<10) { $myi= "0".$i; } else { $myi=$i; } ?>
                                          <option value="<?=$myi?>"<? if($myTimeMM==$i) { echo " selected"; } ?>> 
                                          <?=$myi?>
                                          </option>
                                          <? } ?>
                                        </select></td>
                                    </tr>
                                  </table></td>
                              </tr>
							  <tr>
							  <td width="140" height="22" align="right" class="table_col1">Group&nbsp;</td>
                                <td height="22" class="table_col2">
								<select name="inputGroupID" id="inputGroupID" class="select">
								
								<? 
								$sql = "SELECT * FROM ".$myModule_Table1Group." WHERE ".$myModule_Table1Group."_Language = '$System_Session_Language'";
								
								$QueryCalendarGroup=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
								while($RowCalendarGroup=MYSQL_FETCH_ARRAY($QueryCalendarGroup)){
								?>
								<option value="<?=$RowCalendarGroup[$myModule_Table1Group."_ID"]?>"><?=$RowCalendarGroup[$myModule_Table1Group."_Name"]?></option>
								<? }?>
								
                                </select></td>
							</tr>
                              <tr> 
                                <td height="22" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Activity 
                                  Information </td>
                              </tr>
                              <tr> 
                                <td width="140" height="22" align="right" class="table_col1">Subject&nbsp;</td>
                                <td height="22" class="table_col2"> <input name="inputMod_Calendar_Subject" type="text" class="input_left" id="inputBasicInput" size="50"  maxlength="250"></td>
                              </tr>
                              <tr> 
                                <td width="140" height="22" align="right" class="table_col1">Location&nbsp;</td>
                                <td height="22" class="table_col2"><textarea name="inputMod_Calendar_Location" cols="50" rows="6" class="input_textarea" id="inputMod_Calendar_Location"></textarea></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="inputMod_Calendar_Url" class="input_left" id="inputMod_Calendar_Url"  value="http://"size="80" maxlength="100"></td>
		  </tr>
                              <tr> 
		<td height="22" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11"> &nbsp;Files</td>
		</tr><tr>
		  <td height="22" align="right" 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="inputFileUpload[]" type="file" class="input_left" id="inputFileUpload" 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="inputFileUpload[]" type="file" class="input_left" id="inputFileUpload" 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($inputFileUpload[0]);
	<?
	for ($index=0;$index<count($inputFileUpload)-1;$index++) {
		echo "insertRow('contentTable');";
	}
	
	for ($index=0;$index<count($inputFileUpload);$index++) {
		$array_visible = "";
		if (count($inputFileUpload)>1) $array_visible = "[".$index."]";
		echo "document.myForm.inputFileUpload".$array_visible.".value = '".$inputFileUpload[$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="inputFileUpload[]" type="file" class="input_left" id="inputFileUpload" 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 previewMemberPhoto(memberid) {
				if (memberid>0) {
					document.getElementById('previewPhotoArea').innerHTML = '<a href="'+ShowSubDomain(memberid)+'" target="_blank"><strong>'+member_name[memberid]+'</strong><br><img src="'+member_photo[memberid]+'" width="80" border="0"></a><br><br><font color="#BBBBBB">&lt;preview image&gt;</font>';
				} else {
					document.getElementById('previewPhotoArea').innerHTML = '';
				}
			}
			*/
			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" class="table_col1"> 
                          Thumbnail 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 style="display:none; "> 
		<td height="22" align="right" class="table_col1">&nbsp;</td>
		<td height="22" class="table_col2">Recommended to use 
		a picture file size as 100x100 pixel ( or a square size 
		picture).</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="PreviewImage" id="PreviewImage"></td>
		<td align="right"><div id="PreviewImageText">&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; Tag</td>
		  </tr>
		<tr> 
		<td height="22" align="right" class="table_col1">Tag </td>
		<td height="22" class="table_col2"><table width="80%" border="0" cellspacing="0" cellpadding="2">
                              <tr> 
                                <td valign="top">&nbsp;</td>
                                <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;
											$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 valign="top">&nbsp;</td>
                                <td align="right" valign="top"><input name="inputEmail" type="text" class="input_left" id="inputEmail" size="22" maxlength="100">
                                &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 valign="top">&nbsp;</td>
                                <td align="center" valign="top">&nbsp;</td>
                                <td align="center" id="previewPhotoArea">&nbsp;</td>
                              </tr>
                            </table></td>
		</tr>
							  <tr> 
                                <td height="22" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Activity 
                                  Detail</td>
                              </tr>
                              <tr align="center" valign="top"> 
                                <td height="300" 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="center" class="table_col3">
                                      <? 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="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 align="center"> 
                                <td height="22" colspan="2" class="table_col1">&nbsp;
</td>
                              </tr>
                            </table>
                            <table width="100%" height="24" border="0" cellpadding="3" cellspacing="0">
                              <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> <script language="JavaScript" type="text/JavaScript">
function isBlank(myObj) { if(myObj.value=='') { return true; } return false; }
function isNumber(myObj) { return !isNaN(myObj.value*1) }
function verifySubmit() {
	with(document.myForm) {
		if(isBlank(inputMod_Calendar_Subject)) {	inputMod_Calendar_Subject.focus(); return false; }
		inputMod_Calendar_TimeFrom.value=inputTimeFromHH.value+":"+inputTimeFromMM.value+":00";
		inputMod_Calendar_TimeTo.value=inputTimeToHH.value+":"+inputTimeToMM.value+":00";
		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> <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>
                    <? 
#########################################################
} else if($action=="addnew") { 
	if(strlen($inputMod_Calendar_DateFrom)!=10) { $inputMod_Calendar_DateFrom="0000-00-00"; }
	if(strlen($inputMod_Calendar_DateTo)!=10) { $inputMod_Calendar_DateTo="0000-00-00"; }
	if($inputIsDateTo=="") { $inputMod_Calendar_DateTo="0000-00-00"; }
	if($inputIsTimeTo=="") { $inputMod_Calendar_TimeTo="00:00:00"; }
	if( strlen($inputMod_Calendar_DateFrom)>0 && strlen($inputMod_Calendar_DateTo)>0 && $inputMod_Calendar_DateFrom!="0000-00-00"  && $inputMod_Calendar_DateTo!="0000-00-00" ) {
		if(strcmp($inputMod_Calendar_DateFrom,$inputMod_Calendar_DateTo)<1) { 
			// Do nothing.
		} else { 
			// Switch Date
			$myTmp = $inputMod_Calendar_DateFrom;
			$inputMod_Calendar_DateFrom = $inputMod_Calendar_DateTo;
			$inputMod_Calendar_DateTo = $myTmp;
		}
	}
	if($inputMod_Calendar_DateTo=="0000-00-00") { $inputMod_Calendar_DateTo=$inputMod_Calendar_DateFrom; }
	$sql = "INSERT INTO ".$myModule_Table."(".$myModule_Table."_ModuleKey,".$myModule_Table."_DateFrom,".$myModule_Table."_DateTo,".$myModule_Table."_TimeFrom,".$myModule_Table."_TimeTo,".$myModule_Table."_Subject,".$myModule_Table."_Location,".$myModule_Table."_Url,".$myModule_Table."_CreateByID,".$myModule_Table."_CreateBy,".$myModule_Table."_CreateDate,".$myModule_Table."_LastUpdate,".$myModule_Table."_Status,".$myModule_Table."_Language ,".$myModule_Table."_GroupID) VALUES('$SystemModuleKey','$inputMod_Calendar_DateFrom','$inputMod_Calendar_DateTo','$inputMod_Calendar_TimeFrom','$inputMod_Calendar_TimeTo','".changeQuot($inputMod_Calendar_Subject)."','".changeQuot($inputMod_Calendar_Location)."','$inputMod_Calendar_Url','$System_Session_User_ID','$System_Session_UserName',NOW(),NOW(),'Enable','$System_Session_Language','$inputGroupID')";
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
	$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_UploadFiles)) { mkdir($myModule_Path_UploadFiles,0777); }

	// ------------------------------------------------

								$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."_HtmlFile='$HTMLFileName' WHERE ".$myModule_Table."_ID=".$MaxID;
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
	
	for($i=0; $i<=count($inputFileUpload); $i++){
					srand(make_seed());
					$myrand = rand(1111,9999);
					$LastFileArray=explode(".",$inputFileUpload_name[$i]);
					$LastFile=$LastFileArray[count($LastFileArray)-1];
					$StrFileName=$MaxID."_".$myrand.".".$LastFile;
					
					if($inputFileUpload[$i]!=""){
					
					if(file_exists($myModule_Path_UploadFiles."/".$StrFileName)) {
							unlink($myModule_Path_UploadFiles."/".$StrFileName);
					}
					//echo $inputFileUpload[$i].",".$myModule_FullPath_UploadFiles."/".$StrFileName;
					if(copy($inputFileUpload[$i],$myModule_Path_UploadFiles."/".$StrFileName)) {
							chmod($myModule_Path_UploadFiles."/".$StrFileName,0777);
					} 
				$sql = " INSERT INTO ".$myModule_Table1_FileUpload."(".$myModule_Table1_FileUpload."_CalID ,".$myModule_Table1_FileUpload."_FileUpload , ".$myModule_Table1_FileUpload."_FileUploadName)".
				" VALUES ($MaxID,'$StrFileName','$LastFileArray[0]') ";
				$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error : เกิดความผิดพลาด <br>$sql<br>\n");
						
					}
		}//end for
	
	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_Table1." SET ".$myModule_Table1."_PictureFile='$ThumbnailPictureName' WHERE ".$myModule_Table1."_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 ".$myModule_TableTag." WHERE ".$myModule_TableTag."_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 ".$myModule_TableTag." (".$myModule_TableTag."_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_Table1." SET ".$myModule_Table1."_Tag='$tag' WHERE ".$myModule_Table1."_ID=".$MaxID;
				$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 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=="edit") { 
	
	$sql="SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ID=".$myCalID;
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
	$Row=MYSQL_FETCH_ARRAY($Query);
	$HTMLsrc = $myModule_Path_HTMLFiles."/".$Row[$myModule_Table."_HtmlFile"];
	$HTMLToolContentBG = "#FFFFFF";
	
	?>
                    <br>
                    <? include("htmltool/header.php"); ?>
                    <!-- 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 -->
                    <table width="98%" border="0" cellpadding="0" cellspacing="1" class="table_header">
                      <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 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" enctype="multipart/form-data">
                        <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 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="myCalID" type="hidden" id="myCalID" value="<?=$myCalID?>">
                        <tr> 
                          <td bgcolor="#FFFFFF"> <table width="98%" 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="22" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Date 
                                  Information 
                                  <input name="inputMod_Calendar_TimeFrom" type="hidden" id="inputMod_Calendar_TimeFrom"> 
                                  <input name="inputMod_Calendar_TimeTo" type="hidden" id="inputMod_Calendar_TimeTo"></td>
                              </tr>
                              <tr> 
                                <td height="22" align="right" class="table_col1">Date&nbsp;</td>
                                <td height="22" class="table_col2"> <table border="0" cellspacing="0" cellpadding="1">
                                    <tr> 
                                      <td nowrap> 
                                        <? $myTmpDate = substr($Row[$myModule_Table."_DateFrom"],0,10); ?>
										<? $myTmpDateTo = substr($Row[$myModule_Table."_DateTo"],0,10); ?>
                                        From&nbsp;</td>
                                      <td><input name="inputMod_Calendar_DateFrom" type="text" class="input_center" id="inputMod_Calendar_DateFrom" value="<? if($myTmpDate!="0000-00-00") { echo $myTmpDate; } ?>" size="10" maxlength="10"> 
                                        <? $myTmpDate = substr($Row[$myModule_Table."_DateTo"],0,10); ?>
                                      </td>
                                      <td> <input type="button" class="button_th_normal" onClick="return showCalendar('inputMod_Calendar_DateFrom', 'y-mm-dd');" value=" ... "> 
                                      </td>
                                      <td width="25" align="right"><input name="inputIsDateTo" type="checkbox" id="inputIsDateTo" value="Yes" onClick="if(document.getElementById('idDateTo1').style.display=='') { document.getElementById('idDateTo1').style.display='none'; document.getElementById('idDateTo2').style.display='none'; } else { document.getElementById('idDateTo1').style.display=''; document.getElementById('idDateTo2').style.display=''; } " <? if($myTmpDate!="0000-00-00") { echo " checked"; } ?>></td>
                                      <td nowrap>To&nbsp;</td>
                                      <td id="idDateTo1" <? if($myTmpDate=="0000-00-00") { ?>style="display:none"<? } ?>> 
                                        <input name="inputMod_Calendar_DateTo" type="text" class="input_center" id="inputMod_Calendar_DateTo" value="<?=$Row[$myModule_Table."_DateTo"]?>" size="10" maxlength="10"></td>
                                      <td id="idDateTo2" <? if($myTmpDate=="0000-00-00") { ?>style="display:none"<? } ?>> 
                                        <input type="button" class="button_th_normal" onClick="return showCalendar('inputMod_Calendar_DateTo', 'y-mm-dd');" value=" ... "></td>
                                    </tr>
                                  </table></td>
                              </tr>
                              <tr> 
                                <td height="22" align="right" class="table_col1"> 
                                  <?
$myTime = explode(":",$Row[$myModule_Table."_TimeFrom"]);
$myTimeHH = $myTime[0]*1;
$myTimeMM = $myTime[1]*1;
?>
                                  Time&nbsp;</td>
                                <td height="22" class="table_col2"><table border="0" cellspacing="0" cellpadding="1">
                                    <tr> 
                                      <td width="30">From</td>
                                      <td><select name="inputTimeFromHH" class="select" id="inputTimeFromHH">
                                          <? for($i=0;$i<=23;$i++) { if($i<10) { $myi= "0".$i; } else { $myi=$i; } ?>
                                          <option value="<?=$myi?>"<? if($myTimeHH==$i) { echo " selected"; } ?>> 
                                          <?=$myi?>
                                          </option>
                                          <? } ?>
                                        </select></td>
                                      <td><b>:</b></td>
                                      <td><select name="inputTimeFromMM" class="select" id="inputTimeFromMM">
                                          <? for($i=0;$i<=59;$i++) { if($i<10) { $myi= "0".$i; } else { $myi=$i; } ?>
                                          <option value="<?=$myi?>"<? if($myTimeMM==$i) { echo " selected"; } ?>> 
                                          <?=$myi?>
                                          </option>
                                          <? } ?>
                                        </select></td>
                                      <td width="37" align="right"> 
                                        <?
$myTime = explode(":",$Row[$myModule_Table."_TimeTo"]);
$myTimeHH = $myTime[0]*1;
$myTimeMM = $myTime[1]*1;
?>
                                      <input name="inputIsTimeTo" type="checkbox" id="inputIsTimeTo" value="Yes" onClick="if(document.getElementById('idTimeTo1').style.display=='') { document.getElementById('idTimeTo1').style.display='none'; document.getElementById('idTimeTo2').style.display='none';  document.getElementById('idTimeTo3').style.display='none'; } else { document.getElementById('idTimeTo1').style.display=''; document.getElementById('idTimeTo2').style.display=''; document.getElementById('idTimeTo3').style.display=''; } " <? if($Row[$myModule_Table."_TimeTo"]!="00:00:00") { echo " checked"; } ?>></td>
                                      <td nowrap>To&nbsp;</td>
                                      <td  id="idTimeTo1" <? if($Row[$myModule_Table."_TimeTo"]=="00:00:00") { ?>style="display:none"<? } ?>><select name="inputTimeToHH" class="select" id="inputTimeToHH">
                                          <? for($i=0;$i<=23;$i++) { if($i<10) { $myi= "0".$i; } else { $myi=$i; } ?>
                                          <option value="<?=$myi?>"<? if($myTimeHH==$i) { echo " selected"; } ?>> 
                                          <?=$myi?>
                                          </option>
                                          <? } ?>
                                        </select></td>
                                      <td  id="idTimeTo2" <? if($Row[$myModule_Table."_TimeTo"]=="00:00:00") { ?>style="display:none"<? } ?>><b>:</b></td>
                                      <td  id="idTimeTo3" <? if($Row[$myModule_Table."_TimeTo"]=="00:00:00") { ?>style="display:none"<? } ?>><select name="inputTimeToMM" class="select" id="inputTimeToMM">
                                          <? for($i=0;$i<=59;$i++) { if($i<10) { $myi= "0".$i; } else { $myi=$i; } ?>
                                          <option value="<?=$myi?>"<? if($myTimeMM==$i) { echo " selected"; } ?>> 
                                          <?=$myi?>
                                          </option>
                                          <? } ?>
                                        </select></td>
                                    </tr>
                                  </table></td>
                              </tr>
							   <tr>
							  <td width="140" height="22" align="right" class="table_col1">Group&nbsp;</td>
                                <td height="22" class="table_col2">
								<select name="inputGroupID" id="inputGroupID" class="select">
								
								<? 
								$sql = "SELECT * FROM ".$myModule_Table1Group;
								
								$QueryCalendarGroup=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
								while($RowCalendarGroup=MYSQL_FETCH_ARRAY($QueryCalendarGroup)){
								?>
								<option value="<?=$RowCalendarGroup[$myModule_Table1Group."_ID"]?>"  <? if($RowCalendarGroup[$myModule_Table1Group."_ID"]==$Row[$myModule_Table."_GroupID"]){ echo "selected";}?>><?=$RowCalendarGroup[$myModule_Table1Group."_Name"]?></option>
								<? }?>
								
                                </select></td>
							</tr>
                              <tr> 
                                <td height="22" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Activity 
                                  Information </td>
                              </tr>
                              <tr> 
                                <td width="140" height="22" align="right" class="table_col1">Subject&nbsp;</td>
                                <td height="22" class="table_col2"> <input name="inputMod_Calendar_Subject" type="text" class="input_left" id="inputYes" size="40"  maxlength="250" value="<?=$Row[$myModule_Table."_Subject"]?>"></td>
                              </tr>
                              <tr> 
                                <td width="140" height="22" align="right" class="table_col1">Location&nbsp;</td>
                                <td height="22" class="table_col2"><textarea name="inputMod_Calendar_Location" cols="50" rows="6" class="input_textarea" id="inputMod_Calendar_Location"><?=$Row[$myModule_Table."_Location"]?></textarea></td>
                              </tr>
							  <tr>
                                <td width="140" height="22" align="right" class="table_col1">Link Url&nbsp;&nbsp;&nbsp; </td>
                                <td height="22" class="table_col2"><input type="text" name="inputMod_Calendar_Url" class="input_left" id="inputMod_Calendar_Url" size="80" maxlength="100" 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">&nbsp;Files</td>
						    </tr>
							  <tr>
                                <td width="140" align="right" 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="inputTypeFile" onClick="document.getElementById('File1').style.display='';document.getElementById('File2').style.display='none';" value="insert" checked>
          เพิ่มไฟล์ ใหม่</td>
                                      <td><input name="inputTypeFile" id="inputTypeFile" type="radio" value="update" onClick="document.getElementById('File2').style.display=''; document.getElementById('File1').style.display='none';">
          แก้ไขเปลี่ยนแปลง ไฟล์เดิม </td>
                                    </tr>
                                    <tr>
                                      <td id="File1" style="display: "><?
		$sqlFile = "SELECT * FROM ".$myModule_Table1_FileUpload." WHERE ".$myModule_Table1_FileUpload."_CalID = '".$myCalID."'";
	$QueryFile=MYSQL_DB_QUERY($System_DataBase_Name,$sqlFile) or die(mysql_error());				
		while ($RowFile=MYSQL_FETCH_ARRAY($QueryFile)){
						$LinkRelativePath = $myModule_Path_UploadFiles."/".$RowFile[$myModule_Table1_FileUpload."_FileUpload"];
						$DownloadFile = $RowFile[$myModule_Table1_FileUpload."_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_Table1_FileUpload."_FileUploadName"];?>
                        </strong></a>&nbsp;&nbsp;
		<? }?>                                          <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>
                                      <td valign="top" id="File2" style="display:none "><table border="0" cellpadding="2" cellspacing="0" id="contentTable2">
                                          <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('contentTable2')" 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 style="display:none;">
                                <td height="22" align="right" class="table_col1">Thumbnail Picture&nbsp; </td>
                                <td height="22" class="table_col2"><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 style="display:none; ">
                                <td height="22" align="right" class="table_col1">&nbsp;</td>
                                <td height="22" class="table_col2">Keep blank to use an old thumbmail picture. Recommended to use a picture file size as 100x100 pixel ( or a square size picture).</td>
						    </tr>
							  <tr style="display:none; ">
                                <td 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" align="right" class="table_col1">&nbsp;</td>
                                <td height="22" class="table_col2"><table width="80%" border="0" cellspacing="0" cellpadding="2">
                                    <tr>
                                      <td valign="top">&nbsp;</td>
                                      <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>
                                                <? $tag = explode(",",$Row[$myModule_Table."_Tag"])?>
                                                <select name="inputSelectAssign[]" size="8" multiple id="inputSelectAssign" style="width:150">
                                                  <?
					  	for($i=0; $i<=count($tag)-2; $i++){
						?>
                                                  <option value="<?=$tag[$i]?>">
                                                  <?=$tag[$i]?>
                                                  </option>
                                                  <?
						}
					  ?>
                                              </select></td>
                                            <td align="center"><table border="0" cellspacing="0" cellpadding="0">
                                                <tr>
                                                  <td><input type="button" name="Button3" 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="Button3" 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;
											//$sql = "SELECT ".$myModule_FriendList."_FriendMemberID FROM ".$myModule_FriendList." WHERE ".$myModule_FriendList."_MemberID=".$Member_Session_User_ID." AND ".$myModule_FriendList."_FriendMemberID NOT IN (0".$blockfriendidstr.")";
											$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"><input type="button" name="Button32" 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.inputListUserAssign);
									  }
									"></td>
                                    </tr>
                                    <tr>
                                      <td valign="top">&nbsp;</td>
                                      <td align="right" valign="top"><input name="inputEmail" type="text" class="input_left" id="inputEmail" size="22" maxlength="100">
&nbsp;</td>
                                      <td align="center" id="previewPhotoArea"><input type="button" name="Button22" value="<< Add" class="button_80" onClick="
									funcMultipleAddNew( elements['inputSelectAssign[]'] , inputEmail.value ); 
									"></td>
                                    </tr>
                                    <tr>
                                      <td valign="top">&nbsp;</td>
                                      <td align="center" valign="top">&nbsp;</td>
                                      <td align="center" id="previewPhotoArea">&nbsp;</td>
                                    </tr>
                                </table></td>
						    </tr>
                              <tr> 
                                <td height="22" colspan="2" class="table_col3">&nbsp;&nbsp;<img src="../images/bullet/box21.gif" width="11" height="11">&nbsp;Activity 
                                  Detail</td>
                              </tr>
                              <tr align="center" valign="top"> 
                                <td height="300" 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="center" class="table_col3">
                                      <? 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="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 align="center"> 
                                <td height="22" colspan="2" class="table_col1">&nbsp;
</td>
                              </tr>
                            </table>
                            <table width="100%" height="24" border="0" cellpadding="3" cellspacing="0">
                              <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> <script language="JavaScript" type="text/JavaScript">
function isBlank(myObj) { if(myObj.value=='') { return true; } return false; }
function isNumber(myObj) { return !isNaN(myObj.value*1) }
function verifySubmit() {
	with(document.myForm) {
		if(isBlank(inputMod_Calendar_Subject)) {	inputMod_Calendar_Subject.focus(); return false; }
		inputMod_Calendar_TimeFrom.value=inputTimeFromHH.value+":"+inputTimeFromMM.value+":00";
		inputMod_Calendar_TimeTo.value=inputTimeToHH.value+":"+inputTimeToMM.value+":00";
		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="Save" onClick="verifySubmit();"> 
                                      </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>
                    <? 
#########################################################
} else if($action=="update") { 
	$MaxID = $myCalID;
	if(strlen($inputMod_Calendar_DateFrom)!=10) { $inputMod_Calendar_DateFrom="0000-00-00"; }
	if(strlen($inputMod_Calendar_DateTo)!=10) { $inputMod_Calendar_DateTo="0000-00-00"; }
	if($inputIsDateTo=="") { $inputMod_Calendar_DateTo="0000-00-00"; }
	if($inputIsTimeTo=="") { $inputMod_Calendar_TimeTo="00:00:00"; }
	if( strlen($inputMod_Calendar_DateFrom)>0 && strlen($inputMod_Calendar_DateTo)>0 && $inputMod_Calendar_DateFrom!="0000-00-00"  && $inputMod_Calendar_DateTo!="0000-00-00" ) {
		if(strcmp($inputMod_Calendar_DateFrom,$inputMod_Calendar_DateTo)<1) { 
			// Do nothing.
		} else { 
			// Switch Date
			$myTmp = $inputMod_Calendar_DateFrom;
			$inputMod_Calendar_DateFrom = $inputMod_Calendar_DateTo;
			$inputMod_Calendar_DateTo = $myTmp;
		}
	}
	if($inputMod_Calendar_DateTo=="0000-00-00") { $inputMod_Calendar_DateTo=$inputMod_Calendar_DateFrom; }
	$sql = "UPDATE ".$myModule_Table." SET ".$myModule_Table."_DateFrom = '$inputMod_Calendar_DateFrom',".$myModule_Table."_DateTo = '$inputMod_Calendar_DateTo',".$myModule_Table."_TimeFrom = '$inputMod_Calendar_TimeFrom',".$myModule_Table."_TimeTo = '$inputMod_Calendar_TimeTo',".$myModule_Table."_Subject = '".changeQuot($inputMod_Calendar_Subject)."',".$myModule_Table."_Location = '".changeQuot($inputMod_Calendar_Location)."',".$myModule_Table."_Url = '$inputMod_Calendar_Url',".$myModule_Table."_LastUpdate=NOW(),".$myModule_Table."_GroupID = '$inputGroupID' WHERE ".$myModule_Table."_ID=".$MaxID;
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
	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_UploadFiles)) { mkdir($myModule_Path_UploadFiles,0777); }

	// ------------------------------------------------
	$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."_HtmlFile"];		
	if(file_exists($myModule_Path_HTMLFiles."/".$HTMLFileName)) {
		unlink($myModule_Path_HTMLFiles."/".$HTMLFileName);
	}
	/*
	$HTMLFileName = $myModule_Table."_HtmlFile-$MaxID-$myrand.html";
	$HTMLToolContent=stripslashes($DataHTML1);
	$fp = fopen ($myModule_Path_HTMLFiles."/".$HTMLFileName, "w+");
	fwrite($fp,$HTMLToolContent);
	fclose($fp);
	$sql = "UPDATE ".$myModule_Table." SET ".$myModule_Table."_HtmlFile='$HTMLFileName' WHERE ".$myModule_Table."_ID=".$MaxID;
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
	*/
	$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."_HtmlFile='$HTMLFileName' WHERE ".$myModule_Table."_ID=".$MaxID;
	$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");

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");
			}			
		}
		
				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_Table1_FileUpload." WHERE ".$myModule_Table1_FileUpload."_CalID = ".$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_Table1_FileUpload."_FileUpload"]);
		}
		$sql="DELETE FROM ".$myModule_Table1_FileUpload." WHERE ".$myModule_Table1_FileUpload."_CalID=".$MaxID;
		$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error : เกิดความผิดพลาด <br>$sql<br>\n");
			
			
			}
				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_UploadFiles."/".$StrFileName)) {
									unlink($myModule_Path_UploadFiles."/".$StrFileName);
							}
							if(copy($inputFile[$i],$myModule_Path_UploadFiles."/".$StrFileName)) {
									chmod($myModule_Path_UploadFiles."/".$StrFileName,0777);
							}
									
									$sql =  " INSERT INTO ".$myModule_Table1_FileUpload."(".$myModule_Table1_FileUpload."_CalID ,".$myModule_Table1_FileUpload."_FileUpload , ".$myModule_Table1_FileUpload."_FileUploadName)".
				" VALUES ($MaxID,'$StrFileName','$LastFileArray[0]') ";
									//die($sql);
									$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error : เกิดความผิดพลาด <br>$sql<br>\n");
								
							}
				}//end for
		}

	?>
                    <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 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=="delete") { 
		if(strlen($myCalID)>0) {
			$sql = "SELECT * FROM ".$myModule_Table." WHERE ".$myModule_Table."_ID=".$myCalID;
			$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."_HtmlFile"])>0) {
				if(file_exists($myModule_Path_HTMLFiles."/".$Row[$myModule_Table."_HtmlFile"])) {
					unlink($myModule_Path_HTMLFiles."/".$Row[$myModule_Table."_HtmlFile"]);
				}
				}
						$sql = "SELECT * FROM ".$myModule_Table1_FileUpload." WHERE ".$myModule_Table1_FileUpload."_CalID=".$myCalID;
					$QueryCal=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
					while($RowCal=MYSQL_FETCH_ARRAY($QueryCal)){
						if(strlen($RowCal[$myModule_Table1_FileUpload."_FileUpload"])>0) {
							if(file_exists($myModule_Path_UploadFiles."/".$RowCal[$myModule_Table1_FileUpload."_FileUpload"])) {
								unlink($myModule_Path_UploadFiles."/".$RowCal[$myModule_Table1_FileUpload."_FileUpload"]);
							}
					}			
				}// end while
			$sql = "DELETE FROM ".$myModule_Table1_FileUpload." WHERE ".$myModule_Table1_FileUpload."_CalID=".$myCalID;
			$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");


			$sql = "DELETE FROM ".$myModule_Table." WHERE ".$myModule_Table."_ID=".$myCalID;
			$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 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") { 
	$sql="UPDATE ".$myModule_Table." SET ".$myModule_Table."_Status='$SelectStatus' WHERE ".$myModule_Table."_ID=".$myCalID;
	$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 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 {

//include("function.php");

if($myDate=="") { $myDate=getDateNow(); }
$myDateArray = explode("-",$myDate);

// Find Start Week Day ##############################################
$today=getdate(mktime(0,0,0,$myDateArray[1],1,$myDateArray[0]));

$NextMonthArray=getdate(mktime(0,0,0,$myDateArray[1]+1,1,$myDateArray[0]));
$Day=$NextMonthArray[mday]; $Month=$NextMonthArray[mon]; $Year=$NextMonthArray[year];
$NextMonth=sprintf("%04d-%02d-%02d",$Year,$Month,$Day);

$PrevMonthArray=getdate(mktime(0,0,0,$myDateArray[1]-1,1,$myDateArray[0]));
$Day=$PrevMonthArray[mday]; $Month=$PrevMonthArray[mon]; $Year=$PrevMonthArray[year];
$PrevMonth=sprintf("%04d-%02d-%02d",$Year,$Month,$Day);

$startWeekDay=$today[wday];
$myDateYear=$today[year];
$myDateMonth=$today[mon];
$endDayOfMonth=getEndDayOfMonth($myDate);

$myStartDateOfMonth = sprintf("%04d-%02d-%02d",$myDateArray[0],$myDateArray[1],1);
$myEndDateOfMonth = sprintf("%04d-%02d-%02d",$myDateArray[0],$myDateArray[1],$endDayOfMonth);

$myCalendarData[0]="";
$myCalendarEventCounter[0]=0;

// Load activity data #################################################
$sql  = "SELECT * FROM ".$myModule_Table." WHERE ";
$sql .= $myModule_Table."_Language='$System_Session_Language' AND ";
$sql .= $myModule_Table."_ModuleKey='$SystemModuleKey' AND ";
$sql .= " ( ";
$sql .= " ( ".$myModule_Table."_DateFrom>='$myStartDateOfMonth' AND ".$myModule_Table."_DateTo='0000-00-00' ) OR ";
$sql .= " ( ".$myModule_Table."_DateFrom>='$myStartDateOfMonth' AND ".$myModule_Table."_DateFrom<='$myEndDateOfMonth' ) OR ";
$sql .= " ( ".$myModule_Table."_DateTo>='$myStartDateOfMonth' AND ".$myModule_Table."_DateTo<='$myEndDateOfMonth' ) OR ";
$sql .= " ( ".$myModule_Table."_DateFrom<='$myStartDateOfMonth' AND ".$myModule_Table."_DateTo>='$myEndDateOfMonth' ) ";
$sql .= " ) ORDER BY ".$myModule_Table."_TimeFrom ASC ";
$Query=MYSQL_DB_QUERY($System_DataBase_Name,$sql) OR DIE("Error: เกิดความผิดพลาด <br>$sql<br>\n");
$RecordCount=MYSQL_NUMROWS($Query);
$index=1;
if($RecordCount>0) {
	while($index<$RecordCount+1) {
		$Row=MYSQL_FETCH_ARRAY($Query);
		if(strcmp($Row[$myModule_Table."_DateFrom"],$myStartDateOfMonth)<1) { 
			$myDateStart=$myStartDateOfMonth;
		} else {
			$myDateStart=$Row[$myModule_Table."_DateFrom"];
		}
		$myStart=substr($myDateStart,8,2)*1;
		if($Row[$myModule_Table."_DateTo"]!="0000-00-00") {
			if(strcmp($myEndDateOfMonth,$Row[$myModule_Table."_DateTo"])<1) { 
				$myDateEnd=$myEndDateOfMonth;
			} else {
				$myDateEnd=$Row[$myModule_Table."_DateTo"];
			}
		} else {
			$myDateEnd="0000-00-00";
		}
		if($myDateEnd=="0000-00-00") {
				$myCalendarEventCounter[$myStart]++;
				$myCalendarData[$myStart].="<table width=100% border=0 cellspacing=0 cellpadding=2><tr class=table_col3><td width=14 align=center><img src=../images/bullet/red-circle-arrow.gif width=9 height=9></td>";
				if($Row[$myModule_Table."_TimeFrom"]=="00:00:00") {
					$myCalendarData[$myStart].="<td><b>Time : All day";
				} else {
					$myCalendarData[$myStart].="<td><b>Time : ".substr($Row[$myModule_Table."_TimeFrom"],0,5);
					if($Row[$myModule_Table."_TimeTo"]!="00:00:00") {
						$myCalendarData[$myStart].=" - ".substr($Row[$myModule_Table."_TimeTo"],0,5);
					}
				}
				$myCalendarData[$myStart].="</b></td>";
				if($System_Session_Permission[$SystemMenuID]=="RW" ){
					$myCalendarData[$myStart].="<td width=16 align=center><a href=# onClick=setSubmit('edit',".$Row[$myModule_Table."_ID"].")><img src=../images/icon/ico425.gif width=16 height=16 border=0></a></td>";
					$myCalendarData[$myStart].="<td width=16 align=center><a href=# onClick=setSubmit('delete',".$Row[$myModule_Table."_ID"].")><img src=../images/icon/ico417.gif width=16 height=16 border=0></a></td>";
				}
				$myCalendarData[$myStart].="</tr></table><table width=95% border=0 cellspacing=0 cellpadding=2><tr> ";
				$myCalendarData[$myStart].="<td><a href=# onClick=setSubmit('view',".$Row[$myModule_Table."_ID"].")>".$Row[$myModule_Table."_Subject"]."</a></td>";
				$myCalendarData[$myStart].="</tr></table>";
		} else {
			$myEnd=substr($myDateEnd,8,2)*1;
			for($i=$myStart;$i<=$myEnd;$i++) {
				$myCalendarEventCounter[$i]++;
				$myCalendarData[$i].="<table width=100% border=0 cellspacing=0 cellpadding=2><tr class=table_col3><td width=14 align=center><img src=../images/bullet/red-circle-arrow.gif width=9 height=9></td>";
				if($Row[$myModule_Table."_TimeFrom"]=="00:00:00") {
					$myCalendarData[$i].="<td><b>Time : All day";
				} else {
					$myCalendarData[$i].="<td><b>Time : ".substr($Row[$myModule_Table."_TimeFrom"],0,5);
					if($Row[$myModule_Table."_TimeTo"]!="00:00:00") {
						$myCalendarData[$i].=" - ".substr($Row[$myModule_Table."_TimeTo"],0,5);
					}
				}
				$myCalendarData[$i].="</b></td>";
				if($System_Session_Permission[$SystemMenuID]=="RW" ){
					$myCalendarData[$i].="<td width=16 align=center><a href=# onClick=setSubmit('edit',".$Row[$myModule_Table."_ID"].")><img src=../images/icon/ico425.gif width=16 height=16 border=0></a></td>";
					$myCalendarData[$i].="<td width=16 align=center><a href=# onClick=setSubmit('delete',".$Row[$myModule_Table."_ID"].")><img src=../images/icon/ico417.gif width=16 height=16 border=0></a></td>";
				 }
				$myCalendarData[$i].="</tr></table><table width=95% border=0 cellspacing=0 cellpadding=2><tr> ";
				$myCalendarData[$i].="<td><a href=# onClick=setSubmit('view',".$Row[$myModule_Table."_ID"].")>".$Row[$myModule_Table."_Subject"]."</a></td>";
				$myCalendarData[$i].="</tr></table>";
			}
		}
		$index++;
	}
} 
echo "<br>";

// Load calendar display #############################################
$mCount=1;
?>
                    <div id="divInformationWindow" style="display:none; position:absolute; top:83px; left:158px; width: 200px; z-index: 1; height: 138px;">
                      <table width="100%" border="0" cellpadding="0" cellspacing="1" class="table_border">
                        <tr> 
                          <td height="22"><table width="100%" height="22" border="0" cellpadding="0" cellspacing="0" class="table_header">
                              <tr> 
                                <td width="28" align="center"><img src="../images/icon/ico439.gif" width="19" height="15"></td>
                                <td align="center"  id="idInformationDataHeader"></td>
                                <td width="22" align="center"><img src="../images/icon/ico215.gif" width="16" height="16" onMouseOver="this.style.cursor='hand'" onClick="document.getElementById('divInformationWindow').style.display='none'; "></td>
                              </tr>
                            </table></td>
                        </tr>
                        <tr> 
                          <td height="120" align="center" valign="top" class="table_row1" id="idInformationData">&nbsp;</td>
                        </tr>
                        <tr> 
                          <td height="26" align="center" class="table_footer"><table border="0" cellspacing="0" cellpadding="2">
                              <tr align="center">
<? if($System_Session_Permission[$SystemMenuID]=="RW" ){ ?> 
                                <td><input name="Button" type="button" class="button_80" value="Add New" onClick="
document.myForm.action.value='add';
document.myForm.submit();
								"></td>
<? }?>
                                <td><input name="Button" type="button" class="button_80" value="Close" onClick="document.getElementById('divInformationWindow').style.display='none'; "></td>
                              </tr>
                            </table></td>
                        </tr>
                      </table>
                    </div>
                    <script language="JavaScript" type="text/JavaScript">
function ShowInformationWindow(myDivName,myData,RefX,RefY) {
	document.getElementById('idInformationData').innerHTML=myData;
	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 border="0" cellpadding="0" cellspacing="1" class="table_header">
                      <form action="?" method="get" 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 name="myDate" type="hidden" id="myDate" value="<?=$myDate?>">
                        <input name="myCalID" type="hidden" id="myCalID" value="0">
                        <tr> 
                          <td bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="0" cellspacing="1">
                              <tr> 
                                <td height="24" colspan="7" align="center" class="menu_table_header"> 
                                  <table width="100%" height="24" border="0" cellpadding="0" cellspacing="0">
                                    <tr> 
                                      <td width="20" align="center" valign="middle" onMouseOver="this.style.cursor='hand'; " onClick="
document.myForm.myDate.value='<?=$PrevMonth?>';
document.myForm.submit();
									  ">&nbsp;<img src="images/prevmonth.gif" width="10" height="10"></td>
                                      <td width="70" align="left" onMouseOver="this.style.cursor='hand'; " onClick="
document.myForm.myDate.value='<?=$PrevMonth?>';
document.myForm.submit();
									  "><font color="#FFFFFF"> 
                                        <?
$myDateText = ShowDateEn($PrevMonth);
echo substr($myDateText,2,strlen($myDateText))
?>
                                        </font></td>
                                      <td align="center"><table border="0" cellspacing="0" cellpadding="2">
                                          <tr> 
                                            <td><select name="inputMonth" class="select" id="inputMonth" onChange="
document.myForm.myDate.value=document.myForm.inputYear.value+'-'+document.myForm.inputMonth.value+'-01';
document.myForm.submit();
											">
                                                <option value="01"<? if($myDateMonth==1) { echo " selected"; } ?>>January</option>
                                                <option value="02"<? if($myDateMonth==2) { echo " selected"; } ?>>February</option>
                                                <option value="03"<? if($myDateMonth==3) { echo " selected"; } ?>>March</option>
                                                <option value="04"<? if($myDateMonth==4) { echo " selected"; } ?>>April</option>
                                                <option value="05"<? if($myDateMonth==5) { echo " selected"; } ?>>May</option>
                                                <option value="06"<? if($myDateMonth==6) { echo " selected"; } ?>>June</option>
                                                <option value="07"<? if($myDateMonth==7) { echo " selected"; } ?>>July</option>
                                                <option value="08"<? if($myDateMonth==8) { echo " selected"; } ?>>August</option>
                                                <option value="09"<? if($myDateMonth==9) { echo " selected"; } ?>>September</option>
                                                <option value="10"<? if($myDateMonth==10) { echo " selected"; } ?>>October</option>
                                                <option value="11"<? if($myDateMonth==11) { echo " selected"; } ?>>November</option>
                                                <option value="12"<? if($myDateMonth==12) { echo " selected"; } ?>>December</option>
                                              </select></td>
                                            <td><select name="inputYear" class="select" id="inputYear" onChange="
document.myForm.myDate.value=document.myForm.inputYear.value+'-'+document.myForm.inputMonth.value+'-01';
document.myForm.submit();
											">
                                                <? for($i=$myDateYear-4;$i<=$myDateYear+4;$i++) { ?>
                                                <option value="<?=$i?>"<? if($myDateYear==$i) { echo " selected"; } ?>> 
                                                <?=$i?>
                                                </option>
                                                <? } ?>
                                              </select></td>
                                          </tr>
                                        </table></td>
                                      <td width="70" align="right" onMouseOver="this.style.cursor='hand'; "  onClick="
document.myForm.myDate.value='<?=$NextMonth?>';
document.myForm.submit();
									  "><font color="#FFFFFF"> 
                                        <?
$myDateText = ShowDateEn($NextMonth);
echo substr($myDateText,2,strlen($myDateText))
?>
                                        </font></td>
                                      <td width="20" align="center" onMouseOver="this.style.cursor='hand'; " onClick="
document.myForm.myDate.value='<?=$NextMonth?>';
document.myForm.submit();
									  "><img src="images/nextmonth.gif" width="10" height="10"></td>
                                    </tr>
                                  </table></td>
                              </tr>
                              <tr> 
                                <td width="70" height="22" align="center" class="table_col3">Sun</td>
                                <td width="70" align="center" class="table_col3">Mon</td>
                                <td width="70" align="center" class="table_col3">Tue</td>
                                <td width="70" align="center" class="table_col3">Wed</td>
                                <td width="70" align="center" class="table_col3">Thu</td>
                                <td width="70" align="center" class="table_col3">Fri</td>
                                <td width="70" height="22" align="center" class="table_col3">Sat</td>
                              </tr>
                              <? 
if($startWeekDay>0) { 
	?>
                              <tr> 
                                <?
	for($i=0;$i<$startWeekDay;$i++) {
	?>
                                <td width="70" height="70" class="table_col2">&nbsp;</td>
                                <? 
	}
for($i;$i<7;$i++) {
	?>
                                <? if($myCalendarEventCounter[$mCount]==0 || $myCalendarEventCounter[$mCount]=="") { ?>
                                <td width="70" height="70" class="table_col1" <? if($System_Session_Permission[$SystemMenuID]=="RW" ){ ?>onMouseOver="myMouseOver(this)" onMouseOut="myMouseOut(this)" 
onClick="
if(confirm('Are you sure to add new event in this day?')) {
	document.myForm.action.value='add';
	document.myForm.myDate.value='<?=sprintf("%04d-%02d-%02d",$myDateYear,$myDateMonth,$mCount)?>';	
	document.myForm.submit();
}
								"
								<? } ?>> 
                                  <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                                    <tr> 
                                      <td width="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                      <td height="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                      <td width="8" height="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                    </tr>
                                    <tr> 
                                      <td width="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                      <td align="right" valign="top"> 
                                        <?=$mCount?>
                                      </td>
                                      <td width="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                    </tr>
                                  </table></td>
                                <? } else { ?>
                                <td width="70" height="70" class="table_col1" onMouseOver="myMouseOver(this)" onMouseOut="myMouseOut(this)" onClick="
document.myForm.myDate.value='<?=sprintf("%04d-%02d-%02d",$myDateYear,$myDateMonth,$mCount)?>';	
document.getElementById('idInformationDataHeader').innerHTML = '<?=ShowDateEn(sprintf("%04d-%02d-%02d",$myDateYear,$myDateMonth,$mCount))?>';
<? if($i>3) { ?>
ShowInformationWindow('divInformationWindow','<?=addslashes($myCalendarData[$mCount])?>',-210,10);
<? } else { ?>
ShowInformationWindow('divInformationWindow','<?=addslashes($myCalendarData[$mCount])?>',10,10);
<? } ?>
								"> <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                                    <tr> 
                                      <td width="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                      <td height="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                      <td width="8" height="8"><img src="images/calendar_cellbg.gif" width="8" height="8"></td>
                                    </tr>
                                    <tr> 
                                      <td width="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                      <td align="right" valign="top"><b> 
                                        <?=$mCount?>
                                        </b></td>
                                      <td width="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                    </tr>
                                    <tr> 
                                      <td width="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                      <td align="center" height="30"><font color="#999999">( 
                                        <?=$myCalendarEventCounter[$mCount]?>
                                        event )</font></td>
                                      <td width="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                    </tr>
                                  </table></td>
                                <? } ?>
                                <?
	$mCount++;
} 
?>
                              </tr>
                              <?
}
$colcount=0;
for($mCount;$mCount<=$endDayOfMonth;$mCount++) {
	if($colcount==0) {
		?>
                              <tr align="center"> 
                                <?
	}
	$colcount++;
	?>
                                <?
	if($myCalendarEventCounter[$mCount]==0 || $myCalendarEventCounter[$mCount]=="") { ?>
                                <td width="70" height="70" class="table_col1" <? if($System_Session_Permission[$SystemMenuID]=="RW" ){ ?>onMouseOver="myMouseOver(this)" onMouseOut="myMouseOut(this)" 
onClick="
if(confirm('Are you sure to add new event in this day?')) {
	document.myForm.action.value='add';
	document.myForm.myDate.value='<?=sprintf("%04d-%02d-%02d",$myDateYear,$myDateMonth,$mCount)?>';	
	document.myForm.submit();
}
								"
								<? } ?>> 
                                  <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                                    <tr> 
                                      <td width="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                      <td height="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                      <td width="8" height="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                    </tr>
                                    <tr> 
                                      <td width="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                      <td align="right" valign="top"> 
                                        <?=$mCount?>
                                      </td>
                                      <td width="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                    </tr>
                                  </table></td>
                                <? } else { ?>
                                <td width="70" height="70" class="table_col1" onMouseOver="myMouseOver(this)" onMouseOut="myMouseOut(this)" onClick="
document.myForm.myDate.value='<?=sprintf("%04d-%02d-%02d",$myDateYear,$myDateMonth,$mCount)?>';	
document.getElementById('idInformationDataHeader').innerHTML = '<?=ShowDateEn(sprintf("%04d-%02d-%02d",$myDateYear,$myDateMonth,$mCount))?>';
<? if($colcount>3) { ?>
ShowInformationWindow('divInformationWindow','<?=addslashes($myCalendarData[$mCount])?>',-210,10);
<? } else { ?>
ShowInformationWindow('divInformationWindow','<?=addslashes($myCalendarData[$mCount])?>',10,10);
<? } ?>
								"> <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                                    <tr> 
                                      <td width="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                      <td height="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                      <td width="8" height="8"><img src="images/calendar_cellbg.gif" width="8" height="8"></td>
                                    </tr>
                                    <tr> 
                                      <td width="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                      <td align="right" valign="top"><b> 
                                        <?=$mCount?>
                                        </b></td>
                                      <td width="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                    </tr>
                                    <tr> 
                                      <td width="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                      <td align="center" height="30"><font color="#999999">( 
                                        <?=$myCalendarEventCounter[$mCount]?>
                                        event )</font></td>
                                      <td width="8"><img src="../images/blank.gif" width="1" height="1"></td>
                                    </tr>
                                  </table></td>
                                <? } ?>
                                <?
	if($colcount==7) {
		?>
                              </tr>
                              <?
		$colcount=0;
	}
}
if($colcount>0) {
	for($colcount;$colcount<7;$colcount++) {
		?>
                              <td width="70" height="70" class="table_col2">&nbsp;</td>
                              <? 
	}
	?>
	</tr>
	<?
}
?>
                            </table></td>
                        </tr>
                      </form>
                    </table>
                    <script language="JavaScript" type="text/JavaScript">
	function myMouseOver(myObj) {
		//myObj.style.cursor='hand'; 
		myObj.className='table_rowover';
		myObj.style.cursor='hand';
	}
	function myMouseOut(myObj) {
		myObj.className='table_col1'; 
	}
	function setSubmit(myAction,myCalID) {
		if(myAction=='delete') { 
			if(confirm("Are you sure to delete this event?")) {
				document.myForm.myCalID.value=myCalID;
				document.myForm.action.value='delete';
				document.myForm.submit();
			}
		}
		if(myAction=='edit') { 
			if(confirm("Are you sure to edit this event?")) {
				document.myForm.myCalID.value=myCalID;
				document.myForm.action.value='edit';
				document.myForm.submit();
			}
		}
		if(myAction=='view') { 
			document.myForm.myCalID.value=myCalID;
			document.myForm.action.value='view';
			document.myForm.submit();
		}
	}
	                </script>                    
                    <br>
                    <br>
                    <br>
                    <br>
                    <br>
                    <br>
                    <? 
}
#########################################################
?>
      <!-- InstanceEndEditable --> 
            <? }  else { echo "&nbsp;&nbsp;&nbsp;"; } ?>		</td>
        <td width="17" valign="top" background="../images/object/border_07.gif"><img src="../images/object/border_17.gif" width="17" height="119"></td>
      </tr>
      <tr>
        <td height="16"><img src="../images/object/border_09.gif" width="20" height="16"></td>
        <td height="16" background="../images/object/border_11.gif"><img src="../images/object/border_11.gif" width="1" height="16"></td>
        <td><img src="../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>
<? 
include("../lib/disconnect.php");
?>

Hacked By AnonymousFox1.0, Coded By AnonymousFox