<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="com.csc.library.entry.HelpEntry,com.csc.library.system.*,com.csc.library.utilities.*"%>
<%@ page import="com.csc.library.entry.*,com.csc.library.database.*,com.csc.library.session.*,org.jdom.*,java.util.*"  %>
<%session.invalidate();%>
<%
      InitialEnvironment en = new InitialEnvironment("GLOBAL");
       Element root=en.getRootElement();
       List list = root.getChildren("DATABASE");
       List listchild=null;
       Iterator it = list.iterator();
       Iterator it2=null;
       Element em=null,emchild=null;
       String nodename="",companyid="",display="",dbname="",option="",selected="";
       if(it.hasNext()){
          em=(Element)it.next();
             listchild=em.getChildren();
             it2=listchild.iterator();
             while(it2.hasNext()){
                    emchild=(Element)it2.next();
                    nodename=emchild.getName();
                    if((String.valueOf(nodename.charAt(0))).equalsIgnoreCase("D")&&(String.valueOf(nodename.charAt(1))).equalsIgnoreCase("B")&&!nodename.equalsIgnoreCase("DBLIST")){
                        companyid=emchild.getAttributeValue("companyid");
                        display=emchild.getAttributeValue("display");
                        dbname=emchild.getAttributeValue("name");
                        selected=(emchild.getAttributeValue("default")!=null)?"selected":"";
                        //out.println(nodename+" "+dbname+"  "+display+" "+companyid+"<br>");
                        if(companyid!=null&& display!=null )
                            option+="<option value=\""+nodename+"-"+companyid+"\" "+selected+">"+display+"</option>";
                        else
                            option+="<option >"+dbname+"</option>";
                    }
             }
       }
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HR Information Center</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<style type="text/css">
<!--
	* { margin: 0; padding: 0; }
	img { border: 0; }
	html, body { height:100%; min-height: 100%; }
	body{ background: url(IMAGES/EMPVIEW/BG.gif); }
	#wrapper { margin: 0 auto; height: 100%; }
	#content { width: 805px; margin: auto; }
	#table_login { margin: auto; }
	#table_login td { font-family: Tahoma; font-size: 13px; font-weight: bold; color: #fff; }
	span#th, span#en{ margin-right: 0 10px 0 0; }
	.column-label { padding: 5px 20px 5px 5px; text-align: right; }
	.column-input { padding: 5px10px 5px 0; }
	.username, .password { color: #333333;vertical-align: middle;width: 150px;border: 1px solid #666;  }
	.username { background: #FFFFFF url(IMAGES/EMPVIEW/ICONS/USER16.gif) no-repeat 3px center !important; padding: 2px 2px 2px 20px;}
	.password { background: #FFFFFF url(IMAGES/EMPVIEW/ICONS/LOCK16.gif) no-repeat 3px center !important; padding: 2px 2px 2px 20px;}
	.button-line { text-align: center; margin: 0 auto; }
	#dbcom { padding: 2px;color: #333; min-width: 174px; vertical-align: middle;border: 1px solid #666; }
.style1 {color: #000000}
.style2 {color: #FFFFFF}
-->
</style>
<script language="JavaScript" type="text/javascript" src="JS/AC_RunActiveContent.js"></script>
<script language="JavaScript" type="text/JavaScript"><!--
	function getCheckedValue(radioObj) {
		var radioLength = radioObj.length;
		if(radioLength == undefined) {
			if(radioObj.checked) {
				return radioObj.value;
			}
		} else {
			for(var i = 0; i < radioLength; i++) {
				if(radioObj[i].checked) {
					return radioObj[i].value;
				}
			}
		}
		return "";
	}
	function recruit(){
		with(document.cscform){
			action="RECLOGIN.jsp";
			__cmd.value="login";
			submit();
		}
	}
	function isagency(){
	  with(document.cscform){
		   action="LOGIN";
		  __cmd.value="login";
		  if( __user.value !="" && __password !=""){
			  if(__isagent.checked==true){
				   __agencyid.value=prompt("กรุณาใส่รหัสพนักงานของท่านเอง","");
				   __agencyname.value=prompt("กรุณาใส่ Username ของท่านเอง","");
			  }
			  return true;
		 }
	  }
	  return false;
	}
	function clear(){
		with(document.cscform){
			 reset();
		}
	}
//--></script>
</head>

<body onLoad="document.cscform.__user.focus()">
<table id="wrapper" width="100%" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <td bgcolor="#FFFFFF">
    <form name="cscform" method="post" action="LOGIN" onsubmit="return isagency();" autocomplete="off">
        <input type="hidden" name="__cmd" value="" />
        <input type="hidden" name="__agencyname" value="" />
        <input type="hidden" name="__agencyid" value="" />


    <div id="content">
        <div class="flash"></div>
        <div>
           <table id="Table_01" width="800" height="600" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td rowspan="3">
			<img src="IMAGES/LOGIN-HON_01.jpg" width="55" height="600" alt=""></td>
		<td>
			<img src="IMAGES/LOGIN-HON_02.jpg" width="405" height="217" alt=""></td>
		<td rowspan="3">
			<img src="IMAGES/LOGIN-HON_03.jpg" width="120" height="600" alt=""></td>
		<td rowspan="3">
			<img src="IMAGES/LOGIN-HON_04.jpg" width="124" height="600" alt=""></td>
		<td rowspan="3">
			<img src="IMAGES/LOGIN-HON_05.jpg" width="96" height="600" alt=""></td>
	</tr>
	<tr>
		<td>
			<table width="405" height="270" border="0" cellpadding="2" cellspacing="0" bgcolor="#CC0000" id="table_login">
                  <tr>
                        <td width="150" class="column-label"><label for="dbcom"><span class="style2">Database :</span></label></td>
                        <td class="column-input">
                            <select name="__dbcomp" id="dbcom">
                              <%=option%>
                            </select>
                         </td>
                      </tr>
                      <tr>
                        <td class="column-label"><label for="username"><span class="style2">Username :</span></label></td>
                        <td class="column-input"><input type="text" name="__user" id="username" class="username" size="20" maxlength="20" autocomplete="off" /></td>
                      </tr>
                      <tr>
                        <td class="column-label"><label for="password"><span class="style2">Password :</span></label></td>
                        <td class="column-input"><input type="password" name="__password" id="password" class="password" size="20" maxlength="20" autocomplete="off" /></td>
                      </tr>
                      <tr>
                        <td class="column-label"><label><span class="style2">Language :</span></label></td>
                        <td class="column-input">
                            <span id="th"><input name="__lang" id="lang_th" type="radio" value="THA" checked="checked" />
                            <span class="style1">&nbsp;
                            <label for="lang_th"><span class="style2">Thai</span></label>
                            </span></span><span class="style1">&nbsp;&nbsp;
                            </span><span id="en">
                            <input name="__lang" id="lang_en" type="radio" value="ENG" />
                            <span class="style1">&nbsp;                            <span class="style2">
                            <label for="lang_en">English</label>
                            </span>
                            <label for="lang_en"></label>
                            </span>
                            <label for="lang_en"></label></span></td>
                    </tr>
                      <tr>
                        <td class="column-label">&nbsp;</td>
                        <td class="column-input"><input type="checkbox" name="__isagent" id="isagent" value="1" />
                          <span class="style1">&nbsp;
                          <label for="isagent"><span class="style2">ทำงานแทน</span></label>
                        </span>                          <label for="isagent"></label></td>
                    </tr>
                      <tr>
                        <td colspan="2">&nbsp;</td>
                      </tr>
                      <tr>
                        <td colspan="2"><div class="button-line">
                        <input name="login" type="image" src="IMAGES/EMPVIEW/BUTTON/OK.gif" />
                       <a href="javascript:clear();"><img src="IMAGES/EMPVIEW/BUTTON/CANCEL.gif" alt="Cancel" width="60" height="23" /></a>

                       <!-- ส่วนนี้ต้องเปลี่ยนวิธีการLoginใหม่ ใช้แบบนี้ชั่วคราวไปก่อน -->
                       <a href="javascript:recruit();"><img src="IMAGES/EMPVIEW/BUTTON/RECRUIT.gif" alt="Recruitment" width="100" height="23" /></a>
                        <!-- ///// -->

                     </div>
                     </td>
                      </tr>
                    </table>
            </td>
	</tr>
	<tr>
		<td>
			<img src="IMAGES/LOGIN-HON_07.jpg" width="405" height="113" alt=""></td>
	</tr>
</table>
          </div>
          <div class="flash"></div>
      </div>
    </form>
    </td>
  </tr>
</table>
</body>
</html>