<%--
  /**
   * Copyright (c) 2003 by Sun Microsystems, Inc. All rights reserved.
   * Use is subject to license terms.
   *
   * "@(#)sm_profile_import.jsp    1.10    03/10/07     SMI"
   */
 --%>
<%@ include file="/layout/toptags.jsp"%>
<!-- locale stuff -->
<html:html locale="true">
<!-- end locale stuff -->

<!-- HTML -->
<head>
   <%@include file="/layout/page_head_section.jsp"%>
   <title>
      <bean:message  key="storage.mgmt.profile.import.crumb"/>
   </title>
   <!-- Place Java Script Here -->
<script language="javascript">
function updateFocus(input) {
  document.forms[0].loadedFile.focus();
}

//function that attempts to minimize number of problems 
//that can occur when netscape submits directory.
function validateFile() {

        var checkFile = document.forms[0].loadedFile.value;
	var length = document.forms[0].loadedFile.value.length - 1;

	if(length < 0) {
		alert("<bean:message key="error.no.file.selected"/>");
		return false;
	}
	 
	if(checkFile.charAt(length) == '/' ||
	        (is_win && (checkFile.charAt(length) == '\\' || 
			(length > 1 && checkFile.charAt(length-1) ==  '\\' && checkFile.charAt(length) == '.') ||
			(length > 2 && checkFile.charAt(length-2) ==  '\\' && checkFile.charAt(length-1) == '.' && checkFile.charAt(length) == '.'))
		) || 
		(length > 1 && checkFile.charAt(length-1) ==  '/' && checkFile.charAt(length) == '.') ||
		(length > 2 && checkFile.charAt(length-2) ==  '/' && checkFile.charAt(length-1) == '.' && checkFile.charAt(length) == '.') ||
		checkFile == '.' ||
		checkFile == '..'
	  ) {
		alert("<bean:message key="error.not.a.file"/>");
		return false;
	} 
	return true;
}

</script>
</head>

<%@include file="/layout/bodytag.jsp"%>
<%@include file="/layout/top.jsp"%>
<%@include file="/layout/breadcrumb.jsp"%>

<html:form action="root.menu.item0.item3import.do" method="POST" enctype="multipart/form-data">

<% try { %>
<!-- hidden element which specifies the action for this form -->
<input type="hidden" name="request_action" value="<%=request.getAttribute("request_action")%>">

<div class="content-layout">
  <%@ include file="/layout/spacer.jsp" %>
  <%@ include file="/layout/user_messages.jsp"%>
  <%@ include file="/layout/spacer.jsp"%>
  
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td>
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
          <tr>
            <td nowrap>
              <div class="major-category-text">
                <bean:message key="storage.mgmt.profile.import.header"/> 
              </div>
            </td>
            <td valign="bottom" width="99%">
              <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                  <td class="property-separator" valign="bottom"><img alt border="0" height="2" src="/images/general/dot.gif" width="1"></td>
                </tr>
              </table>
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td>
         <img alt border="0" height="5" src="/images/general/dot.gif" width="1"></td>
    </tr>
    <tr>
      <td>
          <bean:message key="storage.mgmt.profile.import.msg"/>
      </td>
    </tr>
    <tr>
      <td>
         <img alt border="0" height="10" src="/images/general/dot.gif" width="1">
      </td>
    </tr>
  </table>
  <%@ include file="/layout/spacer.jsp" %>

  <table border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td nowrap>
        <table border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td align="left" valign="middle">
              <table border="0" cellpadding="0" cellspacing="0">
                <tr>                  
                  <td>
                    <table border="0" cellpadding="1" cellspacing="0" class="button-link-enabled-text">
                      <tr>
                        <td>
                          <table>
                            <tr>
                              <td align="center" valign="middle" nowrap> 
                                 <component:button text="button.load" href="javascript:if(validateFile()) {submitForm('load');}" title="button.load" isEnabled="<%= !readOnly %>" />
                              </td>
                            </tr>
                          </table>
                        </td>
                      </tr>
                    </table>
                  </td>
                  <td width="10"><img alt width="10" height="1" border="0" src="images/general/dot.gif"></td>                  
                </tr>
              </table>
            </td>
            
            <td>
              <table border="0" cellpadding="0" cellspacing="0">
                <tr>                  
                  <td>
                    <table border="0" cellpadding="1" cellspacing="0" class="button-link-enabled-text">
                      <tr>
                        <td>
                          <table>
                            <tr>
                              <td align="center" valign="middle" nowrap>         
                                 <component:button text="button.cancel" href="javascript:document.forms[0].action='root.menu.item0.item3.do';document.forms[0].submit();" title="button.cancel" isEnabled="<%= !readOnly %>" />
                              </td>
                            </tr>
                          </table>
                        </td>
                      </tr>
                    </table>
                  </td>
                  <td width="10"><img alt width="10" height="1" border="0" src="images/general/dot.gif"></td>                  
                </tr>
              </table>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
 
  <!-- Import file selection table -->
  <table>
    <tr>
       <td>
          <img alt border="0" src="images/general/dot.gif" width="1" height="5">
       </td>
    </tr>
    <tr>
       <td nowrap>
          <table class="back-table" border="0" cellspacing="0" cellpadding="1" width="100%">
            <tr>
              <td>
                 <table class="front-table" border="0" cellspacing="0" cellpadding="2" width="100%">
                   <!-- begin column header row -->
                   <tr class="header-row">
                     <td nowrap  colspan="2">
                       <div class="table-header-text">
                          <bean:message key="storage.mgmt.profile.import.table.title" />
                       </div>
                     </td>
                  </tr>
                  <!-- end column header row -->
                  <tr> 
                     <td>
		         <html:file name="importProfile" property="loadedFile" size="46" maxlength="256" onclick="javascript:updateFocus('loadedFile')"/>
                     </td> 
                  </tr>
                </table>
              </td>
            </tr>
         </table>
       </td>
     </tr>
  </table>
  <!-- End of Profile summary table -->
</div>
<script language="javascript">
   updateFocus();
</script>
<% } catch (Exception e) {Trace.error(this, "JSP Page", e.toString());} %>
</html:form>

</body>
</div>
</html:html> 
