<?php require_once('Connections/db_login.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['Username'])) {
  $loginUsername=$_POST['Username'];
  $password=$_POST['Password'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "index2.html";
  $MM_redirectLoginFailed = "f.html";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_db_login, $db_login);
  
  $LoginRS__query=sprintf("SELECT Username, Password FROM tb_login WHERE Username=%s AND Password=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $db_login) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
	if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
<html>
<head>
<title>index1</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- ImageReady Preload Script (index1.psd) -->
<script type="text/javascript">
<!--

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		index1_Layer_2_over = newImage("images/index1_Layer-2-over.gif");
		index1_Layer_2_over006 = newImage("images/index1_Layer-2-over-06.gif");
		index1_Layer_2_over009 = newImage("images/index1_Layer-2-over-09.gif");
		index1_Layer_2_over011 = newImage("images/index1_Layer-2-over-11.gif");
		index1_Layer_2_over013 = newImage("images/index1_Layer-2-over-13.gif");
		index1_Layer_2_over015 = newImage("images/index1_Layer-2-over-15.gif");
		index1_Layer_2_over017 = newImage("images/index1_Layer-2-over-17.gif");
		preloadFlag = true;
	}
}

// -->
</script>
<!-- End Preload Script -->
<style type="text/css">
body,td,th {
	font-size: 24px;
}
</style>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="preloadImages();">
<!-- ImageReady Slices (index1.psd) -->
<table width="801" height="1001" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
	<tr>
		<td colspan="9">
			<img src="images/index1_01.gif" width="800" height="201" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="1" height="201" alt=""></td>
	</tr>
	<tr>
		<td colspan="2" rowspan="2">
			<a href="#"
				onmouseover="changeImages('index1_Layer_2', 'images/index1_Layer-2-over.gif'); return true;"
				onmouseout="changeImages('index1_Layer_2', 'images/index1_Layer-2.gif'); return true;"
				onmousedown="changeImages('index1_Layer_2', 'images/index1_Layer-2-over.gif'); return true;"
				onmouseup="changeImages('index1_Layer_2', 'images/index1_Layer-2-over.gif'); return true;">
				<img name="index1_Layer_2" src="images/index1_Layer-2.gif" width="112" height="43" border="0" alt=""></a></td>
		<td colspan="2">
			<a href="#"
				onmouseover="changeImages('index1_Layer_2005', 'images/index1_Layer-2-over-06.gif', 'index1_Layer_2008', 'images/index1_Layer-2-over-09.gif'); return true;"
				onmouseout="changeImages('index1_Layer_2005', 'images/index1_Layer-2-05.gif', 'index1_Layer_2008', 'images/index1_Layer-2-08.gif'); return true;"
				onmousedown="changeImages('index1_Layer_2005', 'images/index1_Layer-2-over-06.gif', 'index1_Layer_2008', 'images/index1_Layer-2-over-09.gif'); return true;"
				onmouseup="changeImages('index1_Layer_2005', 'images/index1_Layer-2-over-06.gif', 'index1_Layer_2008', 'images/index1_Layer-2-over-09.gif'); return true;">
				<img name="index1_Layer_2005" src="images/index1_Layer-2-05.gif" width="158" height="1" border="0" alt=""></a></td>
		<td colspan="5">
			<img src="images/index1_04.gif" width="530" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="1" height="1" alt=""></td>
	</tr>
	<tr>
		<td>
			<a href="#"
				onmouseover="changeImages('index1_Layer_2005', 'images/index1_Layer-2-over-06.gif', 'index1_Layer_2008', 'images/index1_Layer-2-over-09.gif'); return true;"
				onmouseout="changeImages('index1_Layer_2005', 'images/index1_Layer-2-05.gif', 'index1_Layer_2008', 'images/index1_Layer-2-08.gif'); return true;"
				onmousedown="changeImages('index1_Layer_2005', 'images/index1_Layer-2-over-06.gif', 'index1_Layer_2008', 'images/index1_Layer-2-over-09.gif'); return true;"
				onmouseup="changeImages('index1_Layer_2005', 'images/index1_Layer-2-over-06.gif', 'index1_Layer_2008', 'images/index1_Layer-2-over-09.gif'); return true;">
				<img name="index1_Layer_2008" src="images/index1_Layer-2-08.gif" width="150" height="42" border="0" alt=""></a></td>
		<td colspan="2" rowspan="2">
			<a href="#"
				onmouseover="changeImages('index1_Layer_2010', 'images/index1_Layer-2-over-11.gif'); return true;"
				onmouseout="changeImages('index1_Layer_2010', 'images/index1_Layer-2-10.gif'); return true;"
				onmousedown="changeImages('index1_Layer_2010', 'images/index1_Layer-2-over-11.gif'); return true;"
				onmouseup="changeImages('index1_Layer_2010', 'images/index1_Layer-2-over-11.gif'); return true;">
				<img name="index1_Layer_2010" src="images/index1_Layer-2-10.gif" width="132" height="43" border="0" alt=""></a></td>
		<td rowspan="2">
			<a href="#"
				onmouseover="changeImages('index1_Layer_2012', 'images/index1_Layer-2-over-13.gif'); return true;"
				onmouseout="changeImages('index1_Layer_2012', 'images/index1_Layer-2-12.gif'); return true;"
				onmousedown="changeImages('index1_Layer_2012', 'images/index1_Layer-2-over-13.gif'); return true;"
				onmouseup="changeImages('index1_Layer_2012', 'images/index1_Layer-2-over-13.gif'); return true;">
				<img name="index1_Layer_2012" src="images/index1_Layer-2-12.gif" width="133" height="43" border="0" alt=""></a></td>
		<td rowspan="2">
			<a href="#"
				onmouseover="changeImages('index1_Layer_2014', 'images/index1_Layer-2-over-15.gif'); return true;"
				onmouseout="changeImages('index1_Layer_2014', 'images/index1_Layer-2-14.gif'); return true;"
				onmousedown="changeImages('index1_Layer_2014', 'images/index1_Layer-2-over-15.gif'); return true;"
				onmouseup="changeImages('index1_Layer_2014', 'images/index1_Layer-2-over-15.gif'); return true;">
				<img name="index1_Layer_2014" src="images/index1_Layer-2-14.gif" width="137" height="43" border="0" alt=""></a></td>
		<td colspan="2" rowspan="2">
			<a href="#"
				onmouseover="changeImages('index1_Layer_2016', 'images/index1_Layer-2-over-17.gif'); return true;"
				onmouseout="changeImages('index1_Layer_2016', 'images/index1_Layer-2-16.gif'); return true;"
				onmousedown="changeImages('index1_Layer_2016', 'images/index1_Layer-2-over-17.gif'); return true;"
				onmouseup="changeImages('index1_Layer_2016', 'images/index1_Layer-2-over-17.gif'); return true;">
				<img name="index1_Layer_2016" src="images/index1_Layer-2-16.gif" width="136" height="43" border="0" alt=""></a></td>
		<td>
			<img src="images/spacer.gif" width="1" height="42" alt=""></td>
	</tr>
	<tr>
		<td colspan="3" rowspan="2">
			<img src="images/index1_10.gif" width="262" height="72" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="1" height="1" alt=""></td>
	</tr>
	<tr>
		<td colspan="6">
			<img src="images/index1_11.gif" width="538" height="71" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="1" height="71" alt=""></td>
	</tr>
	<tr>
		<td rowspan="2">
			<img src="images/index1_12.gif" width="96" height="684" alt=""></td>
		<td colspan="7" align="center" valign="top" bgcolor="#F0DDDD"><p>&#3618;&#3636;&#3609;&#3604;&#3637;&#3605;&#3657;&#3629;&#3609;&#3619;&#3633;&#3610;&#3648;&#3586;&#3657;&#3634;&#3626;&#3641;&#3656;&#3648;&#3623;&#3655;&#3610;&#3652;&#3595;&#3605;&#3660;</p>
	    <p>&#3585;&#3619;&#3640;&#3603;&#3634;&#3585;&#3619;&#3629;&#3585; &#3594;&#3639;&#3656;&#3629;&#3649;&#3621;&#3632;&#3619;&#3627;&#3633;&#3626;&#3612;&#3656;&#3634;&#3609;</p>
	    <p>&#3594;&#3656;&#3629;&#3591;LOGIN&#3604;&#3657;&#3634;&#3609;&#3621;&#3656;&#3634;&#3591;&#3588;&#3656;&#3632;</p>
	    <p>&nbsp;</p>
	    <table width="369" border="0">
	      <tr>
	        <td width="359" align="center"><p>&nbsp;</p>
<form name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
  <p>LOGIN</p>
  <p>Username
    <label for="Username"></label>
    <input type="text" name="Username" id="Username">
  </p>
  <p>Password
    <label for="Password"></label>
    <input type="text" name="Password" id="Password">
  </p>
  <p>
    <input type="submit" name="button" id="button" value="&#3605;&#3585;&#3621;&#3591;">
    <input type="reset" name="button2" id="button2" value="&#3618;&#3585;&#3648;&#3621;&#3636;&#3585;">
  </p>
</form>
<p>&nbsp;</p></td>
          </tr>
	      </table>
	    <p>&nbsp;</p></td>
		<td rowspan="2">
<img src="images/index1_14.gif" width="94" height="684" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="1" height="554" alt=""></td>
	</tr>
	<tr>
		<td colspan="7">
			<img src="images/index1_15.gif" width="610" height="130" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="1" height="130" alt=""></td>
	</tr>
	<tr>
		<td>
			<img src="images/spacer.gif" width="96" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="16" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="150" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="8" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="124" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="133" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="137" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="42" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="94" height="1" alt=""></td>
		<td></td>
	</tr>
</table>
<!-- End ImageReady Slices -->
</body>
</html>