
var rootDomain = ".";

///////////////////////////////////////////////////////////////////////////////////////////////
// check browser
var Browser = new Object();
var ua = navigator.userAgent.toLowerCase(); 

Browser.isGecko = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
Browser.isMozilla = (Browser.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
Browser.isIE = window.ActiveXObject ? true : false;
Browser.isMozilla = Browser.isFirefox = (ua.indexOf("firefox")!=-1);
Browser.isSafari = (ua.indexOf("safari")!=-1);
Browser.isOpera = (ua.indexOf("opera")!=-1);

// check the DOM compatibility - http://www.quirksmode.org/dom/w3c_core.html
if (Browser.isMozilla) {
	HTMLElement.prototype.removeNode = function() {
		this.parentNode.removeChild(this);
	}
}

// 주어진 스트링을 Dom Object 형으로 변환한다.
function stringToXml (str, contentType) {
      if (typeof ActiveXObject != "undefined") {
         var d = new ActiveXObject("MSXML.DomDocument");
         d.loadXML(str);
         return d;
      } 
      else if (typeof XMLHttpRequest != "undefined")
		return (new DOMParser()).parseFromString(str, "text/xml"); 		      
}

function xmlToString(thexml){
	if(thexml.xml){
		// MSIE
		xmlString = thexml.xml;
	}else{
		// Gecko
		xmlString = (new XMLSerializer).serializeToString(thexml);
	}
	return xmlString;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////
// String Manipulation

var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

function encode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   do {
      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);

      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;

      if (isNaN(chr2)) {
         enc3 = enc4 = 64;
      } else if (isNaN(chr3)) {
         enc4 = 64;
      }

      output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + 
         keyStr.charAt(enc3) + keyStr.charAt(enc4);
   } while (i < input.length);
   
   return output;
}

function decode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

   do {
      enc1 = keyStr.indexOf(input.charAt(i++));
      enc2 = keyStr.indexOf(input.charAt(i++));
      enc3 = keyStr.indexOf(input.charAt(i++));
      enc4 = keyStr.indexOf(input.charAt(i++));

      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;

      output = output + String.fromCharCode(chr1);

      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }
   } while (i < input.length);

   return output;
}

function htmlEncode(s) {
	return s.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}

function convertTextToHTML(s) {
	s = s.replace(/\&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\n/g, "<br>");
	return s;
}
function convertHTMLToText(s) {
	s = s.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/<br>/g,"\n");
	return s;
}

function HangleCut( text, num, suffix )
{
	if( text == null )
		return text;
    var result = "";
    var temp = "";
    var count = 0;
    for( var i=0 ; i<text.length; i++ )
    {
        temp = text.substr( i, 1 );        
        if( temp.charCodeAt(0) > 128 )
        {
            count += 2;
        }
        else
        {
            count ++;
        }
        if( count > num )
        {
            return result + suffix;
        }
        result += temp;
    }
    return text;    
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// position manipulation 
function getAbsXY(oElement){
    if (oElement == undefined)  return false;
    oElement = getElement(oElement);
    if (oElement == null)      return false;
    var absXY = {X:0, Y:0};
    var tElm = oElement;
    do{
        absXY.X += tElm.offsetLeft;
        absXY.Y += tElm.offsetTop;
        tElm = tElm.offsetParent;
    }while(tElm)
    return absXY;
}

function getElement(obj){
    var elm = null
    if (obj == null)    return elm;
    if (typeof(obj) == "string")
        elm = document.getElementById(obj);
    else if (obj.type == undefined)
        elm = obj;
    else if (obj.type != undefined){
        if (window.event)      var obj = window.event;
        if (Browser.isIE == true)     elm = obj.srcElement;
        else if(Browser.isFX == true) elm = obj.target;
    }
    return elm;
}

function getChildrenByTagName(node, tagName) {
	var ln = node.childNodes.length;
	var arr = [];	
	for (var z=0; z<ln; z++) {
		if (node.childNodes[z].nodeName==tagName) arr.push(node.childNodes[z]);
	}
	return arr;
}

function loadPopup( obj) {
	var divPopup = $(POPUP_PANEL); //divPopup
    divPopup.style.width= obj.nSetupWidth+'px';
    divPopup.style.height= obj.nSetupHeight+'px';
    divPopup.style.left= document.body.clientWidth/2 + document.body.scrollLeft - obj.nSetupWidth/2 +'px';
    divPopup.style.top= (120 + document.body.scrollTop) +'px';
    divPopup.innerHTML = obj.sSetupContent;
	divPopup.style.visibility='visible';	
	divPopup.style.display='';	
}

function unloadPopup( sObjId) {
	var obj = $(POPUP_PANEL); 
    divPopup.style.width= '0px';
    divPopup.style.height= '0px';
    divPopup.style.left= '0px';
    divPopup.style.top= '0px';
//    divPopup.innerHTML = "";
	divPopup.style.visibility='hidden';	
	divPopup.style.display='none';	
}



function stripHTML(oldString) { 
return oldString.replace(/<[^>]*>/g, ""); 
}

//AJAX ??(2005.09.12 ???)
var ajax_req;
var ajax_divname;

function ajax_html_call(url,div_name){
	
    if (window.XMLHttpRequest) {
        ajax_req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        ajax_req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    ajax_divname = div_name;
	ajax_req.onreadystatechange = processRequestTEXT;
	
	url = url+"&refreshtime="+String(new Date().getTime());
	
    ajax_req.open("POST", url, true);
    //ajax_req.setRequestHeader( "Cache-Control", "no-store, no-cache, must-revalidate" ); // for realtime
    //ajax_req.setRequestHeader( "Pragma", "no-cache" ); // HTTP/1.0
    //ajax_req.setRequestHeader( "Connection", "Keep-Alive" );        

    ajax_req.send("");
}
function processRequestTEXT() {
    if (ajax_req.readyState == 4) {
        if (ajax_req.status == 200) {
			response = ajax_req.responseText;
			document.getElementById(ajax_divname).innerHTML  = response;
        } else {
          alert ( "Error : ajax_req.status != 200" );
		}
    }
}
/////////////////////////////////////////////////////////////////////////////////////////////
//-->


// Definition of each of the 12 node types:
// Node 1 = ELEMENT                   Node 2 = ATTRIBUTE
// Node 3 = TEXT                      Node 4 = CDATA SECTION
// Node 5 = ENTITY REFERENCE          Node 6 = ENTITY
// Node 7 = PROCESSING INSTRUCTION    Node 8 = COMMENT
// Node 9 = DOCUMENT                  Node 10= DOCUMENT TYPE
// Node 11= DOCUMENT FRAGMENT         Node 12= NOTATION

function showTree() {         //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  objXMLDoc = document.all("BookList").XMLDocument;     // Get XML doc
  divResults.innerHTML = showChildNodes(objXMLDoc, 0);  // Show node info
} //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv


function showChildNodes(objNode, intLevel) {      //^^^^^^^^^^^^^^^^^^^^^^^^
	
//  if (Browser.isIE)
//  	return;
  if (Browser.isFirefox)
  	return;

  var strNodes = '';                    // Accumulates description
  var intCount = 0;                     // No. of Child nodes
  var intNode = 0;                      // Index for child nodes

 
  if ( objNode.nodeType != 3 ) {
        strNodes += '<BR>';
        for (intIndent = 0; intIndent < intLevel; intIndent++) {
          strNodes += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
        }
        if(objNode.nodeType == 4)
        	strNodes += '<B>value('+objNode.nodeType+'): &nbsp;'   + objNode.data + '<B>';
        else
        	strNodes += '<B>name('+objNode.nodeType+'): &nbsp;'   + objNode.nodeName + '<B>';
        if ( intLevel == 2) {
           strNodes += '-----------------------------------';
        }             
     } else {
       strNodes += ': &nbsp; <B>value('+objNode.nodeType+'):<FONT COLOR="#FF0000">' +
       objNode.nodeValue + '</FONT><B>';
  }

  intCount = objNode.childNodes.length;
  if (intCount > 0) {
    for (intNode = 0; intNode < intCount; intNode++) {
      strNodes += showChildNodes(objNode.childNodes(intNode), intLevel + 1);
    }
  }
  return strNodes;
} //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//------------------------------------------------------------------------------

/* Implementation of Tooltips object for presenting user feedback
http://www.jnetiq.com/jttl_home.html

//import the tooltip library.
//You will need to modify src if jttl.js is in a different directory
<script src="jttl/jttl.js"></script>  

// initialize a basic Tooltip object once the document has fully loaded
<script type="text/JavaScript">
var objTooltip;
function init()
{
if (typeof(Tooltips) == "function")
{
objTooltip = new Tooltips();
objTooltip.registerElements(document.body);
objTooltip.activate();
}
}
</script>

*/

// constructor for Tooltips object

function Tooltips()
{
  this.active=false;                  // active==true --> tool tips are on; 

  this.ref=null;                      // reference to dynamically created tooltip div element

  this.gHighlightCol="";               // a string specifying the color to which the background of the element generating the onmouseover event is to be set

  this.lHighlightCol="";

  this.highlightHintCol="";

  this.gMouseStatic=false;

  this.lMouseStatic;

  this.paddingT=1;                    // default padding top

  this.paddingR=5;                    // default padding right

  this.paddingB=1;                    // default padding bottom

  this.paddingL=5;                    // default padding left

  this.targetSettings="";             // variable for storing initial style settings of the element generating the onmouseover event

  this.delayOn=0;                     // the hint is only displayed once the mouse has been stationary for the specified time (ms)

  this.gAllowMouseOverHint=false;     // if true, the user can move the mouse over the hint div

  this.lAllowMouseOverHint;

  this.gDelayOff=0;                   // default (global) delay before hint is removed following onmouseout

  this.lDelayOff;                     // actual delay to be used. NB. may be set on a per hint (local) basis.

  this.overTimer=null;                // reference to setTimer called in onmouseover method

  this.outTimer=null;                 // reference to setTimer called in ommouseout method

  this.fromElem=null;                 // reference to element activating onMouseOut handler

  this.nToggle = false;
}



/* Tooltips.prototype.setAllowMouseOverHint
 *
 * calling this instance method with the value true
 * causes the browser to keep displaying hint box
 * when moving from the target element to hint
 */

Tooltips.prototype.setAllowMouseOverHint = function(myBool)
{
  this.gAllowMouseOverHint=myBool;
}



/* Tooltips.prototype.setPadding
 *
 * sets the padding of the hint div in pixels
 * parameters refer to the top, right, bottom and left borders respectively
 */ 

Tooltips.prototype.setPadding = function(T,R,B,L)
{
  this.paddingT=T;
  this.paddingR=R;
  this.paddingB=B;
  this.paddingL=L;
}



/* Tooltips.prototype.requireStaticMouse
 *
 * when mouseStatic==true,
 * the hint is not displayed until the mouse is static for delayOn ms
 */

Tooltips.prototype.requireMouseStatic = function()
{
  this.gMouseStatic=true;
}



/* Tooltips.prototype.setDelayOn
 *
 * set delay in ms before hint is displayed following onmouseover
 * to be extended so that hint is only displayed if the mouse is stationary for T ms
 */

Tooltips.prototype.setDelayOn = function(T)
{
  this.delayOn=parseInt(T);
}



/* Tooltips.prototype.setDelayOff
 *
 * set delay in ms before hint is removed following onmouseout
 */

Tooltips.prototype.setDelayOff = function(T)
{
  this.gDelayOff=parseInt(T);
}



/* Tooltips.prototype.setParentTextColor
 *
 * this method sets any text within an element with a hint attribute to the specified color
 */
Tooltips.prototype.setParentTextColor = function(colCode)
{
  if(colCode!="" && colCode.search(/^#[a-fA-F0-9]{6}/)==0)
    this.highlightHintCol=colCode;
}



/* Tooltips.prototype.setParentColor
 *
 * instance method for activating highlighting of target element
 * if called, backgroundColor of target element is set to colCode by the doHighlight method
 * additional highlighting options to be added in due course
 */

Tooltips.prototype.setParentColor = function(colCode)
{
  if(colCode!="" && colCode.search(/^#[a-fA-F0-9]{6}/)==0)
    this.gHighlightCol=colCode;
}

/* Tooltips.prototype.doHighlight
 *
 * instance method for implementing highlighting of target element
 */

Tooltips.prototype.doHighlight = function(e)
{
  this.targetSettings=e.style.backgroundColor;
  e.style.backgroundColor=this.lHighlightCol;
}



/* Tooltips.prototype.undoHighlight
 *
 * sets highlighting of target element to its original state
 */

Tooltips.prototype.undoHighlight = function(e)
{
  e.style.backgroundColor=this.targetSettings;
}



/* Tooltips.prototype.registerElements
 *
 * instance method for assigning onmouseover and onmouseout event handlers
 * handlers are assigned to all descendants of the parameter 'container' that have a hint attribute
 * if no parameter is passed, the entire document body is scanned
 */

Tooltips.prototype.registerElements = function(container)
{
  // define a reference to the calling object that can be accessed from the nested recursive funtion traverse()
  var caller=this;

  // if no parameter is passed, do not register any handlers for this Tooltips object

  if(container!=null) traverse(container);

  // recursive function to traverse document elements and assign event handlers
  function traverse(e)
  {
    var child=e.childNodes;
    for(var i=0;i<child.length;i++)
      traverse(child[i]);

    if((e.nodeType == 1) && (e.getAttribute("hint")))
    {
      if((navigator.appName.indexOf("Microsoft") != -1))                 // add event handlers using IE model
      {
        e.attachEvent("onmouseover",function(){caller.doMouseOver(e)});
        e.attachEvent("onmouseout",function(){caller.doMouseOut(e)});
        e.attachEvent("onmousemove",function(){caller.doMouseMove(e)});
      }
      else                                                               // add event handlers using DOM level 2 model
      {
        e.addEventListener("mouseover",function(e){caller.doMouseOver(e)},false);
        e.addEventListener("mouseout",function(e){caller.doMouseOut(e)},false);
        e.addEventListener("mousemove",function(e){caller.doMouseMove(e)},false);
      }

      // highlight parent text if appropriate
      var styleStr,tempStr,parentTextColor;
      if(styleStr=e.getAttribute("hintStyle"))
      {
        // check if container text color is specified
        tempStr=styleStr.match(/parent-text-color:#[0-9,a-f]{6}/i);
        if(tempStr!=null)
          parentTextColor=tempStr[0].match(/#[0-9,a-f]{6}/i);
      }

      if(parentTextColor==undefined)
        parentTextColor=caller.highlightHintCol;

      if(parentTextColor!="") e.style.color=parentTextColor;
    }
  }
}



/* Tooltips.prototype.activate
 *
 * calling this method activates display of tool tips
 */

Tooltips.prototype.activate = function() {this.active=true;}



/* Tooltips.prototype.deactivate
 *
 * calling this method deactivates display of tool tips
 */

Tooltips.prototype.deactivate = function() {this.active=false;}



/* Tooltips.prototype.getGeometry
 *
 * utility function called by onmouseover event handler
 * returns an object used in positioning hint div
 */

Tooltips.prototype.getGeometry = function(e)
{
  var mouseX,mouseY,winHeight,winWidth;

  // identify target element, and determine mouse position and window size
  // works for both IE and Gecko browsers
  if((navigator.appName.indexOf("Microsoft") != -1))  	           // if IE
  {
    if(document.compatMode && document.compatMode=="CSS1Compat")   // if running in standards compliant mode,
    {                                                              // then use the following measurements
      mouseX=e.clientX+document.documentElement.scrollLeft;
      mouseY=e.clientY+document.documentElement.scrollTop;
      winHeight=document.documentElement.clientHeight;
      winWidth=document.documentElement.clientWidth;
    }
    else
    {
      mouseX=e.clientX+document.body.scrollLeft;                   // otherwise the following measurements should be used
      mouseY=e.clientY+document.body.scrollTop;
      winHeight=document.body.clientHeight;
      winWidth=document.body.clientWidth;
    }
  }
  else							           // if not IE (Gecko assumed)
  {
    mouseX=e.clientX+pageXOffset;
    mouseY=e.clientY+pageYOffset;
    if(document.compatMode && document.compatMode=="CSS1Compat")
      winHeight=document.documentElement.clientHeight;
    else winHeight=document.body.clientHeight;
    winWidth=document.body.offsetWidth;
  }
  var geom=new Object();
  geom.mouseX=mouseX;
  geom.mouseY=mouseY;
  geom.winX=e.clientX;
  geom.winY=e.clientY;
  geom.winHeight=winHeight;
  geom.winWidth=winWidth;

  // default offsets from mouse position to tool tip div
/*
	$("debugTip").innerHTML = 'm('+geom.mouseX +','+geom.mouseY+')'+
		',w('+geom.winX +','+geom.winY+')'+
		',size('+geom.winHeight +','+geom.winWidth+')'+
		$("debugTip").innerHTML;
*/		
  geom.hOffset=0;
  geom.vOffset=0;

  return geom;
}



/* Tooltips.prototype.doMouseOver
 *
 * onmouseover event handler
 * creates tool tip div and positions next to cursor
 * also highlights target element if this option is set
 * returns an object used in positioning hint div
 */

Tooltips.prototype.doMouseOver=function(e)
{
  // identify the element processing this event

  // if IE then e corresponds to the element processing the event
  if((navigator.appName.indexOf("Microsoft") != -1))
  {
    var targ=e;
    e=event;
  }
  else 
  	var targ=e.currentTarget;

  // if a hint is already assigned to the element processing this event,
  // then cancel any outTimers and stop propogation

  if(this.outTimer) clearTimeout(this.outTimer);                                    // interrupt any delayed mouseout actions
  this.outTimer=null;

  if(this.active && (!this.ref || targ!=this.ref.parentNode || this.ref.style.visibility=="hidden"))
  {
    var geom=this.getGeometry(e);

    // first make sure existing hints are cleared
    if(this.overTimer) clearTimeout(this.overTimer);                                // interrupt any delayed mouseover actions                                  
    if (this.ref) this.ref.parentNode.removeChild(this.ref);                        // remove hint div
    if(this.lHighlightCol!="" && this.fromElem) this.undoHighlight(this.fromElem);  // undo highlighting
    this.ref=null;this.fromElem=null;                                               // reset variables
    this.lDelayOff=null;this.lMouseStatic=null;
    this.lAllowMouseOverHint=null;this.lHighlightCol=null;

    var paddingT,paddingR,paddingB,paddingL;
    var borderWidthT,borderWidthR,borderWidthB,borderWidthL;
    var borderColorT, borderColorR,borderColorB,borderColorL;
    var fontColor,fontFamily,fontSize,backgroundColor,divWidth,divHeight;
    var delayOn;
    var styleStr,tempStr;

    // read custom style settings, if any

    if(styleStr=targ.getAttribute("hintstyle"))
    {
      // check if border-width is specified
      tempStr=styleStr.match(/border-width:\d+,\d+,\d+,\d+/i);
      if(tempStr!=null)
      {
        tempStr=tempStr[0].match(/\d+/g);
        borderWidthT=tempStr[0];
        borderWidthR=tempStr[1];
        borderWidthB=tempStr[2];
        borderWidthL=tempStr[3];
      }

      // check if padding is specified
      tempStr=styleStr.match(/padding:\d+,\d+,\d+,\d+/i);
      if(tempStr!=null)
      {
        tempStr=tempStr[0].match(/\d+/g);
        paddingT=tempStr[0];
        paddingR=tempStr[1];
        paddingB=tempStr[2];
        paddingL=tempStr[3];
      }

      // check if border-color is specified
      tempStr=styleStr.match(/border-color:#[0-9,a-f]{6},#[0-9,a-f]{6},#[0-9,a-f]{6},#[0-9,a-f]{6}/i);
      if(tempStr!=null)
      {
        tempStr=tempStr[0].match(/#[0-9,a-f,A-F]{6}/g);
        borderColorT=tempStr[0];
        borderColorR=tempStr[1];
        borderColorB=tempStr[2];
        borderColorL=tempStr[3];
      }

      // check if font color is specified
      tempStr=styleStr.match(/color:#[0-9,a-f]{6}/i);
      if(tempStr!=null)
        fontColor=tempStr[0].match(/#[0-9,a-f]{6}/i);

      // check if font-family is specified
      tempStr=styleStr.match(/font-family:[A-Z\-\,]+/i);
      if(tempStr!=null)
        fontFamily=tempStr[0].split(":")[1];

      // check if font-size is specified
      tempStr=styleStr.match(/font-size:[0-9]+/i);
      if(tempStr!=null)
        fontSize=tempStr[0].match(/[0-9]+/);

      // check if background color is specified
      tempStr=styleStr.match(/background-color:#[0-9,a-f]{6}/i);
      if(tempStr!=null)
        backgroundColor=tempStr[0].match(/#[0-9,a-f]{6}/i);

      // check if container color is specified
      tempStr=styleStr.match(/parent-color:#[0-9,a-f]{6}/i);
      if(tempStr!=null)
        this.lHighlightCol=tempStr[0].split(":")[1];

      // check if onset delay is specified
      tempStr=styleStr.match(/delayOn:\d+/i);
      if(tempStr!=null)
        delayOn=tempStr[0].match(/\d+/);

      // check if offset delay is specified
      tempStr=styleStr.match(/delayOff:\d+/i);
      if(tempStr!=null)
        this.lDelayOff=tempStr[0].match(/\d+/);

      // check if mouseStatic is specified
      tempStr=styleStr.match(/mouseStatic:\w+/);
      if(tempStr!=null)
        this.lMouseStatic=tempStr[0].split(":")[1];

      // check if mouseOver is specified
      tempStr=styleStr.match(/mouseOver:\w+/);
      if(tempStr!=null)
        this.lAllowMouseOverHint=tempStr[0].split(":")[1];

      // check if div width is specified
      tempStr=styleStr.match(/width:[0-9]+/i);
      if(tempStr!=null)
        divWidth=tempStr[0].match(/[0-9]+/);
      else 
      	divWidth = null;  

      // check if div width is specified
      tempStr=styleStr.match(/height:[0-9]+/i);
      if(tempStr!=null)
        divHeight=tempStr[0].match(/[0-9]+/);
      else 
      	divHeight = null;  
    }


    // insert defaults if values not already set

    if(borderWidthT==undefined)
    {
        borderWidthT=1;
        borderWidthR=2;
        borderWidthB=2;
        borderWidthL=1;
    }

    if(borderColorT==undefined)
    {
        borderColorT="#AAAAAA";
        borderColorR="#000000";
        borderColorB="#000000";
        borderColorL="#AAAAAA";
    }

    if(paddingT==undefined)
    {
        paddingT=this.paddingT;
        paddingR=this.paddingR;
        paddingB=this.paddingB;
        paddingL=this.paddingL;
    }

    if(fontColor==undefined)
      fontColor="#000000";

    if(fontFamily==undefined)
      fontFamily="Verdana,Arial,Helvetica";

    if(fontSize==undefined)
      fontSize=11;

    if(backgroundColor==undefined)
      backgroundColor="#F6F3F9";

    if(!this.lHighlightCol)
      this.lHighlightCol=this.gHighlightCol;

    if(delayOn==undefined)
      delayOn=this.delayOn;

    if(!this.lDelayOff)
      this.lDelayOff=this.gDelayOff;

    if(!this.lMouseStatic)
      this.lMouseStatic=this.gMouseStatic;

    if(!this.lAllowMouseOverHint)
      this.lAllowMouseOverHint=this.gAllowMouseOverHint;


    // generate hint
    // create tool tip div element
    var toolTip=document.createElement("div");
    toolTip.className="toolTip";
    // set CSS attributes
    toolTip.style.position="absolute";
//    toolTip.style.whiteSpace="nowrap";
    toolTip.style.cursor = "pointer";
    toolTip.style.zIndex=100;
    toolTip.style.margin="0px";
    toolTip.style.paddingTop=paddingT+"px";
    toolTip.style.paddingBottom=paddingB+"px";
    toolTip.style.paddingLeft=paddingL+"px";
    toolTip.style.paddingRight=paddingR+"px";
    toolTip.style.fontSize=fontSize+"px";
    toolTip.style.fontFamily=fontFamily;
    toolTip.style.backgroundColor=backgroundColor;
    toolTip.style.color=fontColor;
    toolTip.style.borderTop="solid " + borderWidthT + "px " + borderColorT;
    toolTip.style.borderRight="solid " + borderWidthR + "px " + borderColorR;
    toolTip.style.borderBottom="solid " + borderWidthB + "px " + borderColorB;
    toolTip.style.borderLeft="solid "+ borderWidthL + "px " + borderColorL;
	if(divWidth != null)
	    toolTip.style.width=divWidth+"px";
	if(divHeight != null)
	    toolTip.style.height=divHeight+"px";

    var hintStr=targ.getAttribute("hint");
    // insert '<' & '>' characters for Opera
    hintStr=hintStr.replace(/&lt;/g,"<");
    hintStr=hintStr.replace(/&gt;/g,">");
    toolTip.innerHTML=hintStr;

    var caller=this;
    if((navigator.appName.indexOf("Microsoft") != -1))                        // add event handlers using IE model
      toolTip.attachEvent("onmouseover",function(){caller.mouseOverHint()});
    else                                                                      // add event handlers using level 2 DOM
      toolTip.addEventListener("mouseover",function(e){caller.mouseOverHint(e)},false);

    if((navigator.appName.indexOf("Microsoft") != -1))                        // add event handlers using IE model
      toolTip.attachEvent("onmouseout",function(){caller.mouseOutHint()});
    else                                                                      // add event handlers using level 2 DOM
      toolTip.addEventListener("mouseout",function(e){caller.mouseOutHint(e)},false);

    toolTip.style.visibility = "hidden";                                      // we do not yet want toolTip div to appear
    document.getElementsByTagName("body")[0].appendChild(toolTip);            // but we need to append it to get its dimensions


    // store reference to tool tip div in Tooltips class variable
    this.ref=toolTip;
    this.fromElem=targ;

    var correction=toolTip.offsetWidth-paddingL-paddingR-borderWidthL-borderWidthR;                    // correction in Gecko to ensure hint div is correct width

    // determine suitable position for tool tip div
    // test to see if default position too close to bottom edge of window and adjust if necessary
    var dy=geom.winHeight-geom.winY-geom.vOffset-toolTip.offsetHeight;
    if(dy<0) 
    	toolTip.style.top= Math.max(geom.mouseY-toolTip.offsetHeight-geom.vOffset,0)+15+"px";
    else 
    	toolTip.style.top=Math.max(geom.mouseY+geom.vOffset,0)-15+"px";

    // test to see if default position too close to right edge of window and adjust if necessary
    var dx=geom.winWidth-geom.winX-geom.hOffset-toolTip.offsetWidth;
      if(dx<0) toolTip.style.left=Math.max(geom.mouseX-toolTip.offsetWidth-geom.hOffset,0)+"px";
        else toolTip.style.left=Math.max(geom.mouseX+geom.hOffset,0)+"px";
	//alert(divWidth);	
    // make sure hint div is correct width
    //toolTip.style.width=correction+"px";
/*    
	if(divWidth != null)
	    toolTip.style.width=divWidth+"px";
	if(divHeight != null)
	    toolTip.style.height=divHeight+"px";
*/	
    var func=addHint(this);  // create and reference a function object we can pass to setTimeout

    this.overTimer=setTimeout(func,delayOn);
  }

  // inner function which returns a function object which operates on a Tooltip instance
  function addHint(me)
  {
    return function()
    {
      if(me.lHighlightCol!="") me.doHighlight(me.fromElem);
      if(me.ref) me.ref.style.visibility="visible";
      me.overTimer=null;
    }
  }
  if(e.stopPropagation) e.stopPropagation()
    else e.cancelBubble=true;
}



/* Tooltips.prototype.doMouseOut
 *
 * onmouseout event handler
 * removes an existing tool tip div
 * also undoes any highlighting on target element
 */

Tooltips.prototype.doMouseOut=function(e)
{
  // identify the element processing this event and the element we moved to
  // if IE then e corresponds to the element processing the event

  if((navigator.appName.indexOf("Microsoft") != -1))  {
    var targ=e;
    var toElem=event.toElement;
    e=event;
  }
  else  {
    var targ=e.currentTarget;
    var toElem=e.relatedTarget;
  }

  // if the element we moved to is a descendant of the element processing the event,
  // then only stop propogation

  if(!this.isAncester(targ,toElem))
  {
    if(this.overTimer) clearTimeout(this.overTimer);                              // cancel any existing mouseover timer

    if(this.ref)                                                                  // if there is a hint div, remove it
    {
      var func=doOut(this);
      if (this.active) this.outTimer = setTimeout(func,this.lDelayOff);
        else func();                                                              // if not active, must have been called from 
    }
  }                                                                               // deactivate method; remove hint without delay
	
  function doOut(me)
  {
    return function()
    {
      if (me.ref) {me.ref.parentNode.removeChild(me.ref);me.ref=null;}
      if(me.lHighlightCol!="") me.undoHighlight(me.fromElem);
    }
  }

  if(this.active)
  {
    if(e.stopPropagation) e.stopPropagation()
      else e.cancelBubble=true;
  }
}




/* Tooltips.prototype.doMouseMove
 *
 * onmousemove event handler
 * ensures that hint is not displayed if mouse is moved
 * before this.delayOn has elapsed
 */

Tooltips.prototype.doMouseMove=function(e)
{
  if(this.overTimer && this.lMouseStatic)                    // if hint is to be made visible following delay,
  {                       
    if (this.ref) this.ref.parentNode.removeChild(this.ref);
    this.ref=null;
    this.doMouseOver(e); 
  }

  if(this.active)
  {
    if((navigator.appName.indexOf("Microsoft") != -1))
      e=event;
    if(e.stopPropagation) e.stopPropagation()
      else e.cancelBubble=true;
  }
}



/* Tooltips.prototype.isAncester
 *
 * utility function
 * returns true if param 2 is a descendant of param 1
 */

Tooltips.prototype.isAncester=function(x,y)
{
  while((y!=null) && (x!=y) && (y!=document.documentElement))
    y=y.parentNode;
  return (x==y);
}



/* Tooltips.prototype.mouseOverHint
 *
 * mouseover handler for hint div
 *
 */

Tooltips.prototype.mouseOverHint=function(e)
{
  var targ;
  if(!e)
  {
    targ=event.srcElement;
    event.cancelBubble=true;
  }
  else
  {
    targ=e.target;
    if( e.target.getAttribute("class") != "toolTip" ) {
    	if(e.stopPropagation) e.stopPropagation();
    } else
    {
		//$("debugTip").innerHTML = ("/"+e.target.getAttribute("class")+this.nToggle + $("debugTip").innerHTML );
		/*
    	if( this.nToggle == true )  
    	{
    		if( this.ref != null ){
			this.ref.style.visibility = "hidden";
			}
			Tooltips.prototype.doMouseOver(e);
	    }	
    	this.nToggle = !this.nToggle;
    	*/
	}	
    	
  }

  if(!this.lAllowMouseOverHint)
  {
    clearTimeout(this.outTimer);
    if (this.ref) this.ref.parentNode.removeChild(this.ref);                          // remove hint div
    if(this.lHighlightCol!="" && this.fromElem) this.undoHighlight(this.fromElem);    // undo highlighting
    this.ref=null;this.outTimer=null;this.fromElem=null;                              // reset variables

  }

  else if(targ==this.ref)
    clearTimeout(this.outTimer);
}



/* Tooltips.prototype.mouseOutHint
 *
 * mouseout handler for hint div
 *
 */

Tooltips.prototype.mouseOutHint=function(e)
{
//	$("debugTip").innerHTML = ("/moH"+e.target.getAttribute("class")+this.nToggle + $("debugTip").innerHTML );
  if(!e) e=event;
  var toElem=null;
  if(e.relatedTarget) toElem=e.relatedTarget;
    else if(e.toElement) toElem=e.toElement;
  if(!this.isAncester(this.ref,toElem))
    this.doMouseOut(e);
  if(e.stopPropagation) e.stopPropagation();
    else e.cancelBubble=true;
}



function getMyHomeCookieVal (offset)
{
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1) endstr = document.cookie.length;
   return document.cookie.substring(offset, endstr);
}

function getMyHomeCookie (name)
{
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) {   //while open
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return getMyHomeCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break;
   }    //while close
   return null;
}

function setMyHomeCookie(name, value)
{
   var argv = setMyHomeCookie.arguments;
   var argc = setMyHomeCookie.arguments.length;
   var expires = (2 < argc) ? argv[2] : null;
   var path = (3 < argc) ? argv[3] : null;
   var domain = (4 < argc) ? argv[4] : null;
   var secure = (5 < argc) ? argv[5] : false;
   

   var today = null;
   if(expires!=null) {
      var today = new Date();
      today.setDate( today.getDate() + parseInt( expires ) );
   }



   var cookieVal = name + "=" + value +
     ((today == null) ? "" : ("; expires="+today.toGMTString())) +
     ((path == null) ? "" : ("; path=" + path)) +
     ((domain == null) ? "" : ("; domain=" + domain)) +
     ((secure == true) ? "; secure" : "");

	document.cookie  = cookieVal
}


function getUniqueID() {
	var year = new Date().getYear()+"";
	var month = new Date().getMonth()+1+"";
	if(month.length<2) month += "0"+month;
	var dval = new Date().getTime() * 1;
	var rval = new Number(new String(Math.random()).substring(6)) * 1;
	var semiId = year+month+String(dval+ rval);

	return semiId;
}


function convertFromAjaxString(string) {
	var rtVal = string;
	rtVal = rtVal.substr(1);
	rtVal = rtVal.substring(0, rtVal.length-1);

	return rtVal;
}