<%@page session="false" info="login" language="java" pageEncoding="utf-8" contentType="text/html; charset=UTF-8"%>
<%@ page import="java.util.prefs.Preferences" %>
<%@ page import="com.sun.uwc.common.model.UWCResourceBundleModel" %>
<%@ page import="com.sun.uwc.UWCServletBase" %>
<%@ page import="com.sun.uwc.common.util.UWCPreferences" %>
<% String path = request.getContextPath();
   if( path.equals("/") )
        path="";
		     
	String gotoUri = request.getParameter("gotoUri");   
	String nextUri = path + "/auth";
	String isAuthError = (String)request.getAttribute("autherror");
    String isCredError = (String)request.getAttribute("authcredentialserror");
    String defaultDomain = (String)request.getAttribute("defaultdomain");
    String sslAuth = (String)request.getAttribute("sslAuth");
    Integer sslPort = (Integer)request.getAttribute("sslPort");
    String server = (String)request.getServerName();
	String acceptLang = (String)request.getHeader("accept-language");

	String localizedUserNameText = null;
	String localizedPasswordText = null;
	String localizedErrorMesgText = null;
	String localizedMiniCopyRightText = null;
	String localizedShortCopyRightText = null;
	String localizedVersionText = null;
	String localizedVersionAltText = null;
	String localizedLoginImagePath = null;
	String localizedLogoImagePath = null;
	String localizedProductName = null;
	String localizedVersionImagePath = "null";
	String localizedSubmitText = "null";
	String localizedVersionPageTitle = "null";
	String localizedCloseLabel = "null";
	String localizedCloseTitle = "null";

	String englishUserNameText = "UserName:";
	String englishPasswordText = "Password:";
	String englishErrorMesgText = "Authentication Failed<br> Reenter your username and password.";
	String englishMiniCopyRightText = "Copyright © 2004 Sun Microsystems, Inc. All rights reserved. SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms."; 
	String englishShortCopyRightText = "Copyright © 2004 Sun Microsystems, Inc. All rights reserved. SUN PROPRIETARY/CONFIDENTIAL. U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Use is subject to license terms. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.";
	String englishVersionText = "Version";
	String englishVersionAltText = "Display Product Version";
	String englishLoginImagePath = "./uwc/images/login-logo.gif";
	String englishLogoImagePath = "./../images/logo_sun.gif";
	String englishProductName = "Sun Java &#153; System Communications Express";
	String englishVersionImagePath = "./../images/version.gif";
	String englishSubmitText = "Log In";
	String englishVersionPageTitle = "Version Information";
	String englishCloseLabel = "Close";
	String englishCloseTitle = "Close Window";


    if (isAuthError == null)
	    isAuthError = "false";

    if (isCredError == null)
		isCredError = "false";

    if (defaultDomain == null)
    {
		/* 
		 *Should Never come here. The LDAPAuthfilter makes sure that
		 * this value is never null
		 */
		defaultDomain = "sun.com";
    }
	
	if(acceptLang == null)
		acceptLang = "en";

        Preferences tempPref = null;
     try {
        acceptLang = UWCServletBase.configMgr.load(defaultDomain,null, acceptLang);
        tempPref = UWCServletBase.configMgr.getUWCResourceBundle(defaultDomain, acceptLang);
     }catch (Exception e) {
	     /*do nothing */

     }

	 if(tempPref != null)
	 {
		localizedUserNameText = tempPref.get("uwc-common-login-username",englishUserNameText); 
		localizedPasswordText = tempPref.get("uwc-common-login-password",englishPasswordText); 
		localizedErrorMesgText = tempPref.get("uwc-common-login-errormsg",englishErrorMesgText); 
		localizedMiniCopyRightText = tempPref.get("uwc-common-login-copyright",englishMiniCopyRightText); 
		localizedShortCopyRightText = tempPref.get("uwc-common-login-short-copyright",englishShortCopyRightText); 
		localizedVersionText = tempPref.get("uwc-common-login-version",englishVersionText); 
		localizedVersionAltText = tempPref.get("uwc-common-login-versionAlt",englishVersionAltText); 
		localizedLoginImagePath = tempPref.get("uwc-common-login-loginImage",englishLoginImagePath); 
		localizedLogoImagePath = tempPref.get("uwc-common-login-logoImage",englishLogoImagePath); 
		localizedProductName = tempPref.get("uwc-common-login-productName",englishProductName); 
		localizedVersionImagePath = tempPref.get("uwc-common-login-versionImage",englishVersionImagePath); 
        localizedSubmitText = tempPref.get("uwc-common-login", englishSubmitText);
        localizedVersionPageTitle = tempPref.get("uwc-common-version-title", englishVersionPageTitle);
        localizedCloseLabel = tempPref.get("uwc-common-close", englishCloseLabel);
        localizedCloseTitle = tempPref.get("uwc-common-Close-title", englishCloseTitle);

	 }else {
		localizedUserNameText = englishUserNameText;
		localizedPasswordText = englishPasswordText;
		localizedErrorMesgText = englishErrorMesgText;
		localizedMiniCopyRightText = englishMiniCopyRightText;
		localizedShortCopyRightText = englishShortCopyRightText;
		localizedVersionText = englishVersionText;
		localizedVersionAltText = englishVersionAltText;
		localizedLoginImagePath = englishLoginImagePath;
		localizedLogoImagePath = englishLogoImagePath;
		localizedProductName = englishProductName;
		localizedVersionImagePath = englishVersionImagePath;
        localizedSubmitText = englishSubmitText;
        localizedVersionPageTitle = englishVersionPageTitle;
        localizedCloseLabel = englishCloseLabel;
        localizedCloseTitle = englishCloseTitle;
	 }

    if (sslAuth != null && sslAuth.equalsIgnoreCase("true")) {
       StringBuffer sb = new StringBuffer();
       sb.append("https://");
       sb.append(server);
       sb.append(":");
       sb.append(sslPort.intValue());
       sb.append(nextUri);
       nextUri = sb.toString();
    }

	if( gotoUri != null )
		nextUri += "?gotoUri=" + gotoUri;




%>  


<HTML><HEAD><TITLE> <%= localizedProductName %></TITLE>

<SCRIPT src="./uwc/js/browserVersion.js" type=text/javascript></SCRIPT>
<SCRIPT type=text/javascript>
  if (is_ie5up) // IE5
  {
   document.write("<LINK href=./uwc/css/css_ie5win.css type=text/css rel=stylesheet>") 
  }
  else if (is_gecko) // Netscape 6/7 or Mozilla
  {
   document.write("<LINK href=./uwc/css/css_ns6up.css type=text/css rel=stylesheet>") 
  }
  else  // All others
  {
   document.write("<LINK href=./uwc/css/css_ns6up.css type=text/css rel=stylesheet>") 
  }
var copyRight = null;
var productName = null;
var logoImagePath = null;
var versionImagePath = null;
var versionPageTitle = null;
var closeLabel = null;
var closeTitle = null;


function handleLoad()
{
copyRight="<%= localizedShortCopyRightText%>";
productName="<%= localizedProductName%>";
logoImagePath="<%= localizedLogoImagePath%>";
versionImagePath="<%= localizedVersionImagePath%>";
versionPageTitle="<%= localizedVersionPageTitle%>";
closeLabel="<%=localizedCloseLabel%>";
closeTitle="<%=localizedCloseTitle%>";
document.form1.username.focus();

}


function handleSubmit() {
	document.form1.submit();
}


function handleError() {
	if (<%=isAuthError.equals("true")%> || <%=isCredError.equals("true") %> ) {
		document.write('<DIV class=logErr>');
		document.write('<table cellspacing=0 cellpadding=0 border=0>');
		document.write('<tbody>');
	    document.write('<tr>');
		document.write('<td valign=top width="28"><img src="./uwc/images/Error_Large.gif" alt="" width="21" height="22">&nbsp;&nbsp;</td>');
		document.write("<td width='233'> <span class=AlrtErrTxt> <%=localizedErrorMesgText %></span> </td>");

		document.write('</tr>');
		document.write('</tbody>');
		document.write('</table>');
		document.write('</DIV>');
	}

}

</SCRIPT>


</HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 
marginwidth="0" marginheight="0" onload='handleLoad()'>
<FORM name=form1  action="<%=nextUri%>" method="POST">
<input type="hidden" name="fromlogin" value="true">
<TABLE title="" cellSpacing=0 cellPadding=0 align=center border=0>
  <TBODY>
  <TR>
      <TD width="50%"><img src="./uwc/images/spacer.gif" width="1" height="1"></TD>
      <TD height="64"><img src="./uwc/images/spacer.gif" width="1" height="1"></TD>
      <TD width="50%"><img src="./uwc/images/spacer.gif" width="1" height="1"></TD>
    </TR>
  <TR>
    <TD>&nbsp;</TD>
      <TD vAlign=center noWrap>
        <table title="" cellspacing=0 cellpadding=0 width="100%" border=0>
          <tbody> 
          <tr> 
            <td><img height=12 alt="" 
            src="./uwc/images/Separator_dark_plus8_right.gif" width=10><a 
            class=MstLnk onBlur="window.status=''; return true" 
            onMouseOver="window.status='<%=localizedVersionAltText%>'; return true" 
            title="<%=localizedVersionText%>" 
            onFocus="window.status='<%=localizedVersionAltText%>'; return true" 
            onMouseOut="window.status=''; return true" 
            href="javascript:void(0)"  onClick="window.open('<%=path%>/uwc/common/version.jsp','version','resizable=yes,width=725,height=460')"><%=localizedVersionText %></a><img height=12 alt="" 
            src="./uwc/images/Separator_dark_plus8_left.gif" width=10></td>

          </tr>
          <tr> 
            <td colspan="2"><img src="./uwc/images/spacer.gif" width="1" height="6"></td>
          </tr>
          </tbody> 
        </table>
      </TD>
    <TD>&nbsp;</TD></TR>
  <TR>
      <TD bgColor=#BCD1F6><img src="./uwc/images/spacer.gif" width="1" height="1"></TD>
      <TD bgColor=#BCD1F6 vAlign=center align=middle  
    height="280">
        <table title="" cellspacing=0 cellpadding=0 width="100%" 
      background="./uwc/images/spacer.gif" border=0>
          <tbody> 
          <tr> 

            <td valign=top width=497 bgcolor=#ffffff><img src="./uwc/images/S1MC_login.gif" width="609" height="42"> 
              <table cellspacing=0 cellpadding=0 border=0>
                <tbody> 
                <tr> 
                  <td>&nbsp;</td>
                  <td> 
					<script>
						handleError();
					 </script>
                  </td>
                </tr>
                <tr> 
                  <td class="LabelCell"> <span class="Lbl6"><label for=username><%= localizedUserNameText %></label></span> </td>
                  <td> <span class=PropInput> 
                    <input id=username tabindex=1 name=username>
                    </span> </td>
                </tr>
                <tr> 
                  <td class="LabelCell"> <span class=Lbl6><label for=password><%= localizedPasswordText %></label></span> 
                  </td>
                  <td> <span class=PropLabel> 
                    <input type=password id=password tabindex=2 
                  name=password>
                    </span> </td>
                </tr>
                <tr> 
                  <td><img height=15 alt="" src="./uwc/images/spacer.gif" 
                  width=1> </td>
                  <td class=logBtn> 
                    <input class=Btn1Def id=button onBlur="this.className='Btn1Def'" onMouseOver="this.className='Btn1DefHov'" title="<%=localizedSubmitText %>" onFocus="this.className='Btn1DefHov'" onClick='handleSubmit(); return false;' tabindex=3 onMouseOut="this.className='Btn1Def'" type=submit value="<%=localizedSubmitText %>" name=Button2>
                  </td>
                </tr>
                </tbody> 
              </table>
            </td>
            <td width=15><img height=245 alt="" 
            src="./uwc/images/spacer.gif" width=16></td>
            <td valign=top width=186 bgcolor=#594fbf><img height=79 
            alt="Sun Microsystems, Inc." 
            src="<%=localizedLoginImagePath %>" width=186></td>

          </tr>
          </tbody>
        </table>
      </TD>
      <TD bgColor=#BCD1F6><img src="./uwc/images/spacer.gif" width="1" height="1"></TD>
    </TR>
  <TR>
      <TD><img src="./uwc/images/spacer.gif" width="1" height="1"></TD>
    <TD>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD>
            <DIV class=logCpy><SPAN class=logTxtCpy><%=localizedMiniCopyRightText%></SPAN>
			</DIV>
		   </TD>
		 </TR>
		 </TBODY>
	   </TABLE>
	  </TD>
    <TD>&nbsp;<img src="./uwc/images/spacer.gif"></TD></TR></TBODY></TABLE></FORM></BODY></HTML>
