function modifyItem(sRef)
{
  var width = (window.innerWidth) ? window.innerWidth : document.body.clientWidth;
  var body = document.body;
  var html = document.documentElement;
  var height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);

  var layer = document.createElement('div');
  layer.style.zIndex = 8;
  layer.id = 'layer';
  layer.style.position = 'absolute';
  layer.style.top = '0px';
  layer.style.left = '0px';
  layer.style.height = height + 'px';
  layer.style.width = '100%';
  layer.style.backgroundColor = 'black';
  layer.style.opacity = '0.70';
  layer.style.filter += ("progid:DXImageTransform.Microsoft.Alpha(opacity=70)");
  layer.style.display = 'block';
  document.body.appendChild(layer);  

  var div = document.createElement('div');
  div.style.zIndex = 9;
  div.id = 'box';
  div.style.position = 'absolute';
  div.style.top = '190px';
  div.style.left = (width / 2) - (623 / 2) + 'px'; 
  div.style.height = '270px';
  div.style.width = '623px';
  div.style.backgroundColor = '#6d5331';
  div.style.border = '2px solid white';
  div.style.padding = '5px';
  document.body.appendChild(div);

  var a = document.createElement('a');
  a.innerHTML = '<form><table width="100%" border="0" cellpadding="5" cellspacing="0">' +
    '<tr><td colspan="2" align="center"><font size="4">Modify Item</font></td></tr>' +
    '<tr><td>Reference:</td><td><b><div id="reference"></div></b></td></tr>' +
    '<tr><td>Bible Version:</td><td><select id="version">' +
    '<option value="KJ21">21st Century King James Version</option>' +
    '<option value="ASV">American Standard Version</option>' +
    '<option value="AMP">Amplified Bible</option>' +
    '<option value="CEV">Contemporary English Version</option>' +
    '<option value="DARBY">Darby Translation</option>' +
    '<option value="ESV">English Standard Version</option>' +
    '<option value="HCSB">Holman Christian Standard Bible</option>' +
    '<option value="KJV">King James Version</option>' +
    '<option value="NASB">New American Standard Bible</option>' +
    '<option value="NCV">New Century Version</option>' +
    '<option value="NIV" selected="selected">New International Version</option>' +
    '<option value="NIVUK">New International Version - UK</option>' +
    '<option value="NIRV">New International Reader\'s Version</option>' +
    '<option value="NKJV">New King James Version</option>' +
    '<option value="NLT">New Living Translation</option>' +
    '<option value="MSG">The Message</option>' +
    '<option value="TNIV">Today\'s New International Version</option>' +
    '<option value="WYC">Wycliffe New Testament</option>' +
    '<option value="WE">Worldwide English (New Testament)</option>' +
    '<option value="YLT">Young\'s Literal Translation</option></select></td></tr>' +
    '<tr><td valign="top">Scripture:</td>' +
    '<td><textarea id="scripture" name="script" rows="7" cols="60"></textarea></td></tr>' +
    '<tr><td colspan="2" align="right"><table border="0" cellpadding="5" cellspacing="0">' +
    '<tr><td><button id="OK" type="button" onClick="okModifyItem(\'' + sRef + '\');">&nbsp; OK &nbsp;</button></td>' +
    '<td><button id="Cancel" type="button" onClick="closeModifyItem();">Cancel</button></td>' +
    '</tr></table></td></tr></table></form>';
  div.appendChild(a);

  document.getElementById('reference').innerHTML = sRef;

  var xmlhttp = getXmlHttpObject();
  xmlhttp.open('POST', 'itemdata.php?ref=' + sRef + '&field=Scripture', false);
  xmlhttp.send(null);
  document.forms[0].script.value = xmlhttp.responseText;

  document.getElementById('description').focus();
}
function okModifyItem(sRef) 
{
  var sDesc = '';
  var sVer  = document.getElementById('version').value;
  var sText = document.getElementById('scripture').value;
  countWords(sText);

  var xmlhttp = getXmlHttpObject();
  xmlhttp.open('POST', 'modifyitem.php?ref=' + sRef + '&desc=' + sDesc + '&ver=' + sVer + '&text=' + sText + '&words=' + iWords, false);
  xmlhttp.send(null);
  closeModifyItem();
  window.location.reload();
}
function closeModifyItem() 
{
  document.body.removeChild(document.getElementById('layer'));
  document.body.removeChild(document.getElementById('box'));
}
