<%@ page language="java" contentType="text/html;charset=Shift_JIS" import="designer.ood"%>
<%@ page import = "java.util.*"%>
<%@ page import = "java.io.*"%>
<html>
<head>
	<title>OpenOLAP Designer</title>
	<meta http-equiv="Content-Type" content="text/html;charset=Shift_JIS">
	<script language="JavaScript" src="../js/standard.js"></script>
	<script language="JavaScript" src="jsp/js/registration.js"></script>
	<link rel="stylesheet" type="text/css" href="jsp/css/common.css">
	<LINK REL="SHORTCUT ICON" href="images/favicon.ico"> 
	<style type="text/css">
	<!--
		body {
			background-image : url("images/bg.gif");
			text-align : center;
		}
		
		th,td{
			color : navy;
		}
		th {
			text-align : right;
		}
		
		td {
			padding-left : 20px;
		}

		/* Button Login*/
		input.normal_login, input.up_login, input.out_login{
			width : 97;
			height : 28;
			background : url("images/button/login.gif") no-repeat;
			border-style : none;
			font-family : Arial;
			color : navy;
		}

		input.over_login, input.down_login{
			width : 97;
			height : 28;
			background : url("images/button/login_r.gif") no-repeat;
			border-style : none;
			font-family : Arial;
			color : white;
		}

		/* Button Reset */
		input.normal_reset, input.up_reset, input.out_reset{
			width : 97;
			height : 28;
			background : url("images/button/reset.gif") no-repeat;
			border-style : none;
			font-family : Arial;
			color : navy;
		}

		input.over_reset, input.down_reset{
			width : 97;
			height : 28;
			background : url("images/button/reset_r.gif") no-repeat;
			border-style : none;
			font-family : Arial;
			color : white;
		}


	-->
	</style>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="JavaScript:onloadSet();IE6check();">
<form name="form_main" id="form_main" method="post" action="">
<table width="600" border="0" align="center" bgcolor="white" height="100%" cellpadding="0" cellspacing="0">
	<tr>
	<td align="center">
	<h1 style="margin-bottom:0">
<img src="images/login_title.jpg"><br>

	</h1>
	<table width="321" style="margin-bottom:50">
	</table>
	<table id="tableForm" style="display:block;">
		<tr>
			<th>メタユーザー</th>
			<td>
				<input type="text" name="txt_name" value="" size="20">
			</td>
		</tr>
		<tr>
			<th>パスワード</th>
			<td>
				<input type="password" name="txt_pwd" value="" size="20">
			</td>
		</tr>
		<tr>
			<th>メタスキーマ</th>
			<td>
				<input type="text" name="txt_schema" value="" size="20">
			</td>
		</tr>
		<tr>
			<th>コネクトソース</th>
			<td>
				<input type="text" name="txt_dsn" value="" size="60">
			</td>
		</tr>



		<tr>
			<th></th>
			<td>
				<select name="loginInfoList" id="loginInfoList" style='' onChange='JavaScript:onloadSet();'>
<%
	String fileName="login.ini";
	String strPath=application.getRealPath(request.getServletPath());
	if(System.getProperty("os.name").substring(0,4).equals("Wind")) {
		strPath=strPath.substring(0,strPath.lastIndexOf("\\") + 1)+fileName;
	} else {  
		strPath=strPath.substring(0,strPath.lastIndexOf("/") + 1)+fileName;
	}

	try{
		FileInputStream fis = new FileInputStream(strPath);
		InputStreamReader isr = new InputStreamReader(fis,"Shift_JIS");
		BufferedReader br = new BufferedReader(isr);

		String line="";
		String ListName="";
		String UserName="";
		String SchemaName="";
		String ConnectDSN="";

		line = br.readLine();
		while(line != null){
			line = br.readLine();
			if (line!=null || ("").equals(line)){

				if(line.indexOf("DESIGNER_CLASSES_PATH")==0){
					session.putValue("DESIGNER_CLASSES_PATH",line.substring(22));
				}
				if(line.indexOf("JDBC_DRIVER")==0){
					session.putValue("JDBC_DRIVER",line.substring(12));
				}

				if(line.indexOf("LIST_NAME")==0){
					ListName=line.substring(10);
				}
				if(line.indexOf("USER_NAME")==0){
					UserName=line.substring(10);
				}
				if(line.indexOf("SCHEMA_NAME")==0){
					SchemaName=line.substring(12);
				}
				if(line.indexOf("CONNECT_SOURCE")==0){
					ConnectDSN=line.substring(15);
					out.println("<option userName='"+UserName+"' loginDsn='"+ConnectDSN+"' schemaName='"+SchemaName+"'>"+ListName+"</option>");
				}


			}
		}
		br.close();

	}catch(FileNotFoundException e){
		out.println("<option userName='' loginDsn='' schemaName=''>---------------</option>");
	}catch(IOException e){
		out.println("<option userName='' loginDsn='' schemaName=''>---------------</option>");
	}
%>

				</select>
			</td>
		</tr>

	</table>

	<div id="divSubmitBtn" style="display;block;" class="command">
		<input type="button" name="" value="" class="normal_login" onClick="login();" onMouseOver="className='over_login'" onMouseDown="className='down_login'" onMouseUp="className='up_login'" onMouseOut="className='out_login'">
		<input type="button" name="" value="" class="normal_reset" onClick="resetText();" onMouseOver="className='over_reset'" onMouseDown="className='down_reset'" onMouseUp="className='up_reset'" onMouseOut="className='out_reset'">
	</div>
</td>
</tr>
</table>
</form>
</body>
</html>

<script language="JavaScript">
function IE6check(){
	if(navigator.appVersion.indexOf("MSIE 6")==-1){
		document.all.tableForm.style.display="none";
		document.all.divSubmitBtn.innerHTML="OpenOLAPのサポートブラウザは　Microsoft Internet Explorer 6　となっております。";
	}
}



function login(){

//navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) 


		if(document.form_main.txt_name.value==""){
			showMsg("LOG01");
			document.form_main.txt_name.focus();
			document.form_main.txt_name.select();
			return;
	//	}else if(document.form_main.txt_pwd.value==""){
	//		document.form_main.txt_pwd.focus();
	//		document.form_main.txt_pwd.select();
	//		return;
		}else if(document.form_main.txt_schema.value==""){
			showMsg("LOG02");
			document.form_main.txt_schema.focus();
			document.form_main.txt_schema.select();
			return;
		}else if(document.form_main.txt_dsn.value==""){
			showMsg("LOG03");
			document.form_main.txt_dsn.focus();
			document.form_main.txt_dsn.select();
			return;
		}

		document.form_main.action = "loginCertify.jsp";
		document.form_main.target = "_self";
		document.form_main.submit();
//location.href="OpenOLAP.html";

}

function resetText(){
		document.form_main.txt_name.value = "";
		document.form_main.txt_pwd.value = "";
		document.form_main.txt_schema.value = "";
		document.form_main.txt_dsn.value = "";
		document.form_main.txt_name.focus();
		document.form_main.txt_name.select();
}

function onloadSet(){
		if(document.form_main.loginInfoList.selectedIndex!=-1){
			document.form_main.txt_name.value=document.form_main.loginInfoList.options[document.form_main.loginInfoList.selectedIndex].userName;
			document.form_main.txt_pwd.value="";
			document.form_main.txt_schema.value=document.form_main.loginInfoList.options[document.form_main.loginInfoList.selectedIndex].schemaName;
			document.form_main.txt_dsn.value=document.form_main.loginInfoList.options[document.form_main.loginInfoList.selectedIndex].loginDsn;
			if(document.form_main.txt_name.value==""){
				document.form_main.txt_name.focus();
				document.form_main.txt_name.select();
			}else{
				document.form_main.txt_pwd.focus();
				document.form_main.txt_pwd.select();
			}
		}else{
			document.form_main.txt_name.focus();
			document.form_main.txt_name.select();
		}
}
</script>

