<{* $Revision: 1.18.2.1.2.10 $ *}>
<!-- begin of xnpbook_register_block.html -->

<script type="text/javascript" src="js/prototype.js">
</script>
<script type="text/javascript">
//<![CDATA[
// return true if all required parameters are filled
function onSubmitItemType( form1 ){
  result = true;
  if( form1.publisher.value == '' ){
    alert( "<{$smarty.const._MD_XNPBOOK_PUBLISHER_REQUIRED}>" );
    result = false;
  }
  if( form1.publicationDateYear.value == '' ){
    alert( "<{$smarty.const._MD_XNPBOOK_YEAR_REQUIRED}>" );
    result = false;
  }
  <{$xnpbook_author.table_name}>.trimFields();
  return result;
}

// amazon complete request
function xnpbook_amazon_complete() {
  var el = document.getElementById( 'xnpbook_complete_button' );
  el.disabled = true;
<{if $is_register }>
  var form = document.getElementById( 'xoonips_registerform' );
<{else}>
  var form = document.getElementById( 'xoonips_editform' );
<{/if}>
  var asin = form.isbn.value;
  var url = '<{$smarty.const.XOONIPS_URL}>/backend.php?itemtype=xnpbook&action=amazon_ecs';
  var params = 'asin=' + asin;
  var myAjax = new Ajax.Request( url, {
    method: 'get',
    parameters: params,
    requestHeaders: ['Referer', '<{$myurl}>'],
    onComplete: xnpbook_amazon_oncomplete,
    onFailure: xnpbook_amazon_onfailure
  } );
  return false;
}

function xnpbook_amazon_oncomplete( request ) {
  if ( ! request.responseText.isJSON() ) {
    alert( 'informal result returend from backend query : ' + request.responseText );
 } else {
    xnpbook_amazon_fillin( request );
  }
  var el = document.getElementById( 'xnpbook_complete_button' );
  el.disabled = false;
}

function xnpbook_amazon_onfailure( request ) {
  alert( 'failed to request backend query' );
  var el = document.getElementById( 'xnpbook_complete_button' );
  el.disabled = false;
}

function xnpbook_amazon_fillin( request ) {
  var json = eval( '(' + request.responseText + ')' );
  if ( typeof ( json.error ) == 'string' ) {
    alert( json.error );
  } else {
    <{if $is_register }>
    var form = document.getElementById( 'xoonips_registerform' );
    <{else}>
    var form = document.getElementById( 'xoonips_editform' );
    <{/if}>
    form.title.value = json.title;
    form.publisher.value = json.publisher;
    form.url.value = json.url;
    form.publicationDateYear.value = json.year;
    <{$xnpbook_author.table_name}>.deleteAllFields();
    for ( var i = 0; i < json.author.length; i++ ) {
      <{$xnpbook_author.table_name}>.setField( i, json.author[i] );
    }
  }
  return true;
}

//]]>
</script>
<{$system_message}>
<table class="outer">
  <!-- Basic Information -->
  <tr>
    <td class="head"><{$basic.doi.name}></td>
    <td class="<{cycle name="oddeven" values="odd,even"}>"><{$basic.doi.value}></td>
  </tr>
  <tr>
    <td width="30%" class="head"><{$basic.lang.name}></td>
    <td class="<{cycle name="oddeven"}>"><{$basic.lang.value}></td>
  </tr>
  <tr>
    <td class="head"><{$smarty.const._MD_XNPBOOK_ISBN_LABEL}></td>
    <td class="<{cycle name="oddeven"}>">
     <input type="text" name="isbn" value="<{$detail.isbn.value}>"/>
     <button id="xnpbook_complete_button" class="formButton" type="button" onclick="xnpbook_amazon_complete();"><{$smarty.const._MD_XNPBOOK_ISBN_COMPLETE_LABEL}></button>
    </td>
  </tr>
  <tr>
    <td width="30%" class="head"><{$basic.title.name}></td>
    <td class="<{cycle name="oddeven"}>"><{$basic.title.value}></td>
  </tr>
  <tr>
    <td class="head"><{$basic.keywords.name}></td>
    <td class="<{cycle name="oddeven"}>"><{$basic.keywords.value}></td>
  </tr>
  <tr>
    <td class="head"><{$basic.description.name}></td>
    <td class="<{cycle name="oddeven"}>"><{$basic.description.value}></td>
  </tr>
<{if !empty( $basic.last_update_date.value ) }>
  <tr>
    <td class="head"><{$basic.last_update_date.name}></td>
    <td class="<{cycle name="oddeven"}>"><{$basic.last_update_date.value}></td>
  </tr>
<{/if}>
<{if !empty( $basic.creation_date.value ) }>
  <tr>
    <td class="head"><{$basic.creation_date.name}></td>
    <td class="<{cycle name="oddeven"}>"><{$basic.creation_date.value}></td>
  </tr>
<{/if}>
<{if !empty( $basic.contributor.value ) }>
  <tr>
    <td class="head"><{$basic.contributor.name}></td>
    <td class="<{cycle name="oddeven"}>"><{$basic.contributor.value}></td>
  </tr>
<{/if}>
<{if !empty( $basic.item_type.value ) }>
  <tr>
    <td class="head"><{$basic.item_type.name}></td>
    <td class="<{cycle name="oddeven"}>"><{$basic.item_type.value}></td>
  </tr>
<{/if}>
<{if !empty( $basic.change_log.value ) }>
  <tr>
    <td class="head"><{$basic.change_log.name}></td>
    <td class="<{cycle name="oddeven"}>"><{$basic.change_log.value}></td>
  </tr>
<{/if}>
<{if !empty( $basic.change_logs.value ) }>
  <tr>
    <td class="head"><{$basic.change_logs.name}></td>
    <td class="<{cycle name="oddeven"}>"><{$basic.change_logs.value}></td>
  </tr>
<{/if}>
  <!-- Book Item Detail Information -->
  <tr>
    <td class="head"><{$smarty.const._MD_XNPBOOK_AUTHOR_LABEL}></td>
    <td class="<{cycle name="oddeven"}>">
<{include file='db:xoonips_register_multiple_field.html' vars=$xnpbook_author}>
    </td>
  </tr>
  <tr>
    <td class="head"><{$smarty.const._MD_XNPBOOK_EDITOR_LABEL}></td>
    <td class="<{cycle name="oddeven"}>"><input type="text" name="editor" value="<{$detail.editor.value}>" size="50"/></td>
  </tr>
  <tr>
    <td class="head"><{$smarty.const._MD_XNPBOOK_PUBLISHER_LABEL}><{$smarty.const._MD_XOONIPS_ITEM_REQUIRED_MARK}></td>
    <td class="<{cycle name="oddeven"}>"><input type="text" name="publisher" value="<{$detail.publisher.value}>" size="50"/></td>
  </tr>
  <tr>
    <td class="head"><{$smarty.const._MD_XNPBOOK_YEAR_LABEL}><{$smarty.const._MD_XOONIPS_ITEM_REQUIRED_MARK}></td>
    <td class="<{cycle name="oddeven"}>"><{$basic.publication_year.value}></td>
  </tr>
  <tr>
    <td class="head"><{$smarty.const._MD_XNPBOOK_URL_LABEL}></td>
    <td class="<{cycle name="oddeven"}>"><input size="50" type="text" name="url" value="<{$detail.url.value}>"/></td>
  </tr>
  <tr>
    <td class="head"><{$smarty.const._MD_XNPBOOK_PDF_LABEL}></td>
    <td class="<{cycle name="oddeven"}>"><{$attachment.value}></td>
  </tr>
  <tr>
    <td class="head"><{$attachment_dl_limit.name}></td>
    <td class="<{cycle name="oddeven"}>"><{$attachment_dl_limit.value}></td>
  </tr>
  <tr>
    <td class="head"><{$attachment_dl_notify.name}></td>
    <td class="<{cycle name="oddeven"}>"><{$attachment_dl_notify.value}></td>
  </tr>
  <!-- index -->
  <tr>
    <td class="head"><{$index.name}></td>
    <td class="<{cycle name="oddeven"}>"><{$index.value}></td>
  </tr>
  <!-- related_to -->
  <tr>
    <td class="head"><{$basic.related_to.name}></td>
    <td class="<{cycle name="oddeven"}>"><{$basic.related_to.value}></td>
  </tr>
</table>

<!-- end of xnpbook_register_block.html -->
