/*
#
#  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.2 $   $Date: 2006-11-06 21:44:24-05 $ 
#
*/

// 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) 
{
  //IE support
  if (document.selection)
  {
     myField.focus();
     sel = document.selection.createRange();
     sel.text = '<'+myValue+'>' + sel.text + '</'+myValue+'>';
  }
  //MOZILLA/NETSCAPE support
  else if (myField.selectionStart || myField.selectionStart == '0') 
  {
     var startPos = myField.selectionStart;
     var endPos = myField.selectionEnd;
     var seltext = myField.value.substring (startPos, endPos-startPos);
     
     myField.value = myField.value.substring(0, startPos)
                   + '<'+myValue+'>' + seltext + '</'+myValue+'>'
                   + myField.value.substring(endPos, myField.value.length);
  } 
  else 
  {
     myField.value += '<'+myValue+'>' + '</'+myValue+'>';;
  }
} // 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


/***********************************************
* 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)
***********************************************/



