/*
#
#  GreatWebScripts    http://www.GreatWebScripts.com
#
#  Copyright (c)2006, GreatWebScripts . All rights reserved.
#
#  No portion of this content may be copied, distributed or reproduced for any
#  reason without the express written consent of the owner. Federal copyright
#  law prohibits unauthorized reproduction by any means and imposes severe fines
#  for violation.
#

#
#  $RCSfile: gwbook.js,v $ $Revision: 1.4 $   $Date: 2008-10-13 20:56:21-04 $
#
*/

// Insert myValue at the cursor position in myField
function insertAtCursor(myField, myValue)
{
  //IE support
  if (document.selection)
  {
     myField.focus();
     sel = document.selection.createRange();
     sel.text = myValue;
  }
  //MOZILLA/NETSCAPE support
  else if (myField.selectionStart || myField.selectionStart == '0')
  {
     var startPos = myField.selectionStart;
     var endPos = myField.selectionEnd;
     myField.value = myField.value.substring(0, startPos)
     + myValue
     + myField.value.substring(endPos, myField.value.length);
  }
  else
  {
     myField.value += myValue;
  }
} // end insertAtCursor


// Insert myValue at the cursor position in myField
function bracketAtCursor (myField, myValue)
{

  myValueArray = myValue.split ("=");
  myValue_command = myValueArray[0];


  //IE support
  if (document.selection)
  {
     myField.focus();
     sel = document.selection.createRange();
     sel.text = '<'+myValue+'>' + sel.text + '</'+myValue_command+'>';
  }
  //MOZILLA/NETSCAPE support
  else if (myField.selectionStart || myField.selectionStart == '0')
  {
     var startPos = myField.selectionStart;
     var endPos = myField.selectionEnd;
     var seltext;

     if (endPos > startPos)
     {
         starttext = myField.value.substring (0, startPos);
         seltext   = myField.value.substring (startPos, endPos);
         endtext   = myField.value.substring (endPos, myField.value.length);
     }
     else
     {
         starttext = myField.value;
         seltext = '';
         endtext = '';
     }

     myField.value = starttext +
                     '<' + myValue+'>' + seltext + '</' + myValue_command + '> ' +
                     endtext;

  }
  else
  {
     myField.value += '<'+myValue+'>' + '</'+myValue_command+'>';;
  }
} // end bracketAtCursor



// Maintains the counter of characters remaning
function textCounter (field, countfield, maxlimit)
{
 // Enforce the maximum value
 if (field.value.length > maxlimit)
 {
   field.value = field.value.substring(0, maxlimit);
 }; // end else to: if (field.value.length > maxlimit)

 // Let 'em know what's left
 countfield.value = maxlimit - field.value.length;

 // And store the position
 storeCaret (field);
} // end textCounter


// Stores the position of the text insertion point
function storeCaret (textEl)
{
 if (textEl.createTextRange)
 {
   textEl.caretPos = document.selection.createRange().duplicate();
 } // end if (textEl.createTextRange)

} // end storeCaret


//
// Transaction Log Deletion
//
function VerifyDeleteTlog (date)
{
    if (date.length > 0) {
      input_box=confirm('Do you want to delete entries dated previous to ' + date + '?');
      return input_box;
    } else {
      alert ('Please Supply a Delete Date (Select an Entry)!');
      return false;
    }
} // end VerifyDeleteTlog

/***********************************************
* Show Hint script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
		
var horizontal_offset="9px" //horizontal offset of hint box from anchor link


var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype)
{
   var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
   var parentEl=what.offsetParent;
   while (parentEl!=null)
   {
      totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
      parentEl=parentEl.offsetParent;
   }
   return totaloffset;
} // end getposOffset

function iecompattest()
{
   return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
} // end iecompattest


function clearbrowseredge(obj, whichedge)
{
   var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
   if (whichedge=="rightedge")
   {
      var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
      dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
      if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
        edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
   }
   else
   {
      var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
      dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
      if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
        edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
   }
   return edgeoffset
} // end clearbrowseredge


function showhint(menucontents, obj, tipwidth)
{
   if ((ie||ns6) && document.getElementById("hintbox"))
   {
      dropmenuobj=document.getElementById("hintbox")
      dropmenuobj.innerHTML=menucontents
      dropmenuobj.style.left=dropmenuobj.style.top=-500
      if (tipwidth!="")
      {
         dropmenuobj.widthobj=dropmenuobj.style
         dropmenuobj.widthobj.width=tipwidth
      }
      dropmenuobj.x=getposOffset(obj, "left")
      dropmenuobj.y=getposOffset(obj, "top")
      dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
      dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
      dropmenuobj.style.visibility="visible"
      obj.onmouseout=hidetip
   }
} // end showhint

function hidetip()
{
   dropmenuobj.style.visibility="hidden"
   dropmenuobj.style.left="-500px"
} // end hidetip


function createhintbox()
{
   var divblock=document.createElement("div")
   divblock.setAttribute("id", "hintbox")
   document.body.appendChild(divblock)
} // end createhintbox

if (window.addEventListener)
   window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
   window.attachEvent("onload", createhintbox)
else if (document.getElementById)
   window.onload=createhintbox

/***********************************************
* Show Hint script (end)
***********************************************/


