/*******************************************************/
/* Min / Max Layout Setup, Overall SiteWide Essentials */
/*******************************************************/
var layout;
var fullyloaded = false;

// browser checking (for advanced dhtml sometimes necessary)
ns4 = document.layers;
ie4 = document.all;
ie6only = (document.implementation != null) && (document.implementation.hasFeature != null);
nn6 = document.getElementById && !document.all;
ff = navigator.userAgent.indexOf('Firefox');
safari = (document.childNodes) && (!document.all) && (!navigator.taintEnabled) && (!navigator.accentColorName);
function getExplorerVersion() {
	var ieVers = parseFloat(navigator.appVersion);
	if( navigator.appName != 'Microsoft Internet Explorer' ) return ieVers;
	var tempVers = navigator.appVersion;
	var i = tempVers.indexOf( 'MSIE ' );
	if( i >= 0 ) {
		tempVers = tempVers.substring( i+5 );
		ieVers = parseFloat( tempVers ); 
	}
	return ieVers;
}
ieold=(navigator.appName == "Microsoft Internet Explorer") && (getExplorerVersion() <= 6);
// ie6 has an annoyingly well documented bug for loading cursor on mouseover.  This is a somewhat elegant fix for it
if (ie6only) {
	try {
	  document.execCommand("BackgroundImageCache", false, true);
	} catch(err) {}
}
// ie6 and previous does not maintain minimum width in fluid mode.   this fixes that.
function resi() {
	if (ieold) {
		if (document.body.parentNode.clientWidth < 964) {
			document.body.className='fixed';
		} else if (layout=='fluid') {
			document.body.className='fluid';
		}
	}
}
if (ieold) { window.onresize=resi; }

// get the object on the page.
function findObj(n, d) {
	var p,i,x;
	if(!d) { d=document; }
	if((p=n.indexOf("?"))>0&&parent.frames.length) { 
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) { x=d.all[n]; }
	for (i=0;!x&&i<d.forms.length;i++) { x=d.forms[i][n]; }
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) {
		x=findObj(n,d.layers[i].document);
	}
	if(!x && d.getElementById) { x=d.getElementById(n); }
	return x;
}
// setup the layout for the site (fixed or fluid)
function layoutSetup(ln, an, ac) {
	var today = new Date();
	var exp = new Date();
	exp.setTime(today.getTime() + 1000*60*24*60*365);
 	if (document.body) { document.body.className=ln; }
 	if ( (x=findObj('layout_size')) != null ) { x.innerHTML=an; x.className=ac; }
 	layout=ln;
	document.cookie='layout='+ln+'; expires=' + exp.toGMTString();
}
// switch the layout of the page to and from fixed and fluid
function layoutSwitch(toChange) {
	if (toChange==1) { layout = (layout=='fixed') ? 'fluid' : 'fixed'; }
	if (layout=='fluid') {
		layoutSetup('fluid','Minimize Site','min_size');
	} else {
		layoutSetup('fixed','Maximize Site','max_size');
	}
	window.onresize = onResizeFixAllElements;
	if (safari) {
		onResizeFixLogoInNetscap();
	}
}

var d;
function setupLayout() {
	fullyloaded = true;
    if (document.body) {
        layout = document.body.className;
	}
    //  old method  //  layout = document.cookie.substring(12, 7);
	var layout2 = readCookie('layout');
	if (layout2 == null) {
		layout2 = 'fixed';
	}
	if (layout != layout2) {
    	layoutSwitch(0);
	}
	// set up resizing of ajax search
	document.getElementById('asdtdd').onmousedown=setupdrag;
	d = document.getElementById('ajaxsearchdrop');
	
	preloadQtImages();
}

// fix logo shift in Netscape
function onResizeFixLogoInNetscap() {
	document.getElementById('logo_top').style.left = findPosX(document.getElementById('header')) + 'px';
}

// hide all dhtml items that might be present on the page.
function onResizeFixAllElements() {
	dcOnPage++;
	if (nn6 && ff == -1) {
		onResizeFixLogoInNetscap();
	}
	hideDblClkBox();
	hideOldHighlightColors();
	closeAjMenu();
	hideDropBox();
}
















/************************************************************/
/* General Functions (Used For Multiple Pieces of The Site) */
/************************************************************/

// Finds an elements absolute x and y on the page
function findPosX(obj) {
    var curleft = 0;
	
    if (obj.offsetParent) {
        while (1) {
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.x) {
        curleft+=obj.x;
    }
    return curleft;
}
function findPosY(obj) {
    var curtop = 0;
	
    if (obj.offsetParent) {
        while (1) {
            curtop+=obj.offsetTop;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.y) {
        curtop+=obj.y;
    }
    return curtop;
}

// Get the height and width of an element on the page
function getElementWidth(elem) {
	if (ns4) {
		var elem = getObjNN4(document, Elem);
		return elem.clip.width;
	} else {
		if (op5) {
			xPos = elem.style.pixelWidth;
		} else {
			xPos = elem.offsetWidth;
		}
		return xPos;
	}
}
function getElementHeight(elem) {
	if (ns4) {
		var elem = getObjNN4(document, Elem);
		return elem.clip.height;
	} else {
		if (op5) {
			xPos = elem.style.pixelHeight;
		} else {
			try {
				xPos = elem.offsetHeight;
			} catch(err) {
				// default font height for the site - if we can't get the offsetHeight
				xPos = 13;
			}
		}
		return xPos;
	}
}

// replaces text input boxes with nothing if appropriate
function inputTrValue(witem, wtext) {
	if (witem.value == wtext) { witem.value=''; }
}
function inputExValue(witem, wtext) {
	if (witem.value == '') {
		witem.value=wtext;
	}
}

// reading and writing cookies
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

// bookmarking urls on the site
function bookmarkthis(url, title) {
	if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
		window.external.AddFavorite(url,title);
	} else if (navigator.appName == "Netscape") {
		alert("Press (CTRL-D) to bookmark this page.");
	}
}












/**************************************/
/* SearchType DropDown At Top Of Site */
/**************************************/
var dropshown = false;
function showHideDrop() {
	if (dropshown) {
		hideDropBox();
	} else {
		showDropBox();
		window.onresize = onResizeFixAllElements;
	}
}
function addDropListener() {
	if (document.body.addEventListener) {
		document.body.addEventListener('click', hideDropBox, true);
	} else if (document.body.attachEvent) {
		document.body.attachEvent('onmousedown', hideDropBoxToClick);
	}
}
function removeDropListener() {
	if (document.body.addEventListener) {
		//document.body.addEventListener('click', hideDropBox, true);
	} else if (document.body.attachEvent) {
		document.body.detachEvent('onmousedown', hideDropBoxToClick);
	}
}
function hideDropBoxToClick() {
	hideDropBox();
	clearTimeout(t);
}
var t;
function rollDropOn(el) {
	removeDropListener();
	el.style.backgroundColor='#DBF1FF';
	clearTimeout(t);
}
function rollDropOff(el) {
	addDropListener();
	if (el.innerHTML.indexOf('<') > -1) {
		el.style.backgroundColor='#EDF8FF';
	} else {
		el.style.backgroundColor='#FFFFFF';
	}
	t=setTimeout("hideDropBoxToClick()",400);
}
function selectThis(newselection) {
	regexp= new RegExp("<[^>]*>");
	newselection = newselection.replace(regexp,"");
	document.getElementById('dmform').source.value=newselection;
	document.getElementById('selectedDrop').innerHTML = newselection;
	hideDropBox();
	dropshown = false;
	dropBoxChangeAction(newselection);
	removeDropListener();
}
function hideDropBox() {
  dropshown = false;
  if (ns4) {
     document.customselectdrop.visibility = "hide";
  } else if (ie4) {
     document.all['customselectdrop'].style.visibility = "hidden";
  } else if (nn6) {
     document.getElementById('customselectdrop').style.visibility = "hidden";
  }
  removeDropListener();
  document.getElementById('customselect').tabindex=2;
}
function showDropBox(e) {
  dropshown = true;
  writeDropMenu();
  var dele = document.getElementById('customselect');
  if (ns4) {
     document.customselectdrop.visibility = "show";
     document.customselectdrop.top = findPosY(dele) + 21 + 'px';
	 document.customselectdrop.left = findPosX(dele) + 'px';
  } else if (ie4) {
     document.all['customselectdrop'].style.visibility = "visible";
     document.all['customselectdrop'].style.top = findPosY(dele) + 21 + 'px';
     document.all['customselectdrop'].style.left = findPosX(dele) + 'px';
  } else if (nn6) {
     document.getElementById('customselectdrop').style.visibility = "visible";
     document.getElementById('customselectdrop').style.top = findPosY(dele) + 21 + 'px';
     document.getElementById('customselectdrop').style.left = findPosX(dele) + 'px';
  }
}
function writeDropMenu() {
	var dmcontent = '';
	var dmcontypes = new Array("Glossary","Reference","Dictionary","Encyclopedia","Web");
	var dmcursel = document.getElementById('selectedDrop').innerHTML;
	for (i=0; i<dmcontypes.length; i++) {
		showdmcheck = '';
		showdmdefcolor = 'FFFFFF';
		if(dmcursel == dmcontypes[i]) {
			showdmcheck = '<img src="images/dropmenucheck.gif" width="15" height="8" alt="" />';
			showdmdefcolor = 'EDF8FF';
		}
		dmcontent = dmcontent + '<div style="padding:5px; background-Color:#'+showdmdefcolor+'; cursor:default;" onMouseOver="rollDropOn(this);" onMouseOut="rollDropOff(this);" onClick="selectThis(this.innerHTML);">' + showdmcheck + dmcontypes[i] + '</div>';
	}
	document.getElementById('customselectdrop').innerHTML=dmcontent;
}

function dropBoxChangeAction(s) {
	
	if (s == 'Glossary') {
		window.document.forms.dmform.action = '/glossary.php';
	} else if (s == 'Reference') {
		window.document.forms.dmform.action = '/reference.php';		
	} else if (s == 'Dictionary') {
		window.document.forms.dmform.action = '/dictionary.php';
	} else if (s == 'Encyclopedia') {
		window.document.forms.dmform.action = '/encyclopedia-search.php';
	} else if (s == 'Web') {
		window.document.forms.dmform.action = '/web.php';
	} else {
		window.document.forms.dmform.action = '/reference.php';		
	}

}





































/******************************************************************************************/
/* AJAX [1 of 3]: Building the AJAX Search Box / Figuring Out Where On The Page To Put It */
/******************************************************************************************/
var ns4 = document.layers;
var op5 = (navigator.userAgent.indexOf("Opera 5")!=-1) ||(navigator.userAgent.indexOf("Opera/5")!=-1);
var maximumAjWidth = 557;
var ajcurrent = '';
var ajminwid = 284;
var mindragx = ajminwid;
var ajminhei = 200;
var mindragy = ajminhei;
function ajglossary(ajinput, minallowed, maxallowed) {
	
	return false;
	
	maximumAjWidth = maxallowed;
	ajminwid = minallowed;
	showAjMenu(ajinput);
}
function closeAjMenu() {
	if (ns4) {
		document.ajaxsearchdrop.visibility = "hide";
	} else if (ie4) {
		document.all['ajaxsearchdrop'].style.visibility = "hidden";
	} else if (nn6) {
		document.getElementById('ajaxsearchdrop').style.visibility = "hidden";
	}
}
function showAjMenu(ajinputcont) {
	hideOldHighlightColors();
	dcOnPage++;
	hideDblClkBox();
	window.onresize = onResizeFixAllElements; // closeAjMenu
	ajcurrent = ajinputcont;
	ajinput = document.getElementById(ajinputcont);
	if (ff > -1) {
		pixeladjust = 0;
		if (document.body.className == 'fixed') {
			pixelwid = -1;
			pixelwid = -2;
		} else {
			pixelwid = -2;
		}
	} else {
		pixeladjust = 0;
		pixelwid = -2;
	}
	pixdown = 24;
	if (ajinputcont == 'inp_keywords') {
		pixelwid = pixelwid + 113;
	}
	document.getElementById('foundSearchResults').innerHTML='';
	if (typeof readCookie(ajcurrent+"wid") == "string" && typeof readCookie(ajcurrent+"hei") == "string") {
		document.getElementById('ajaxsearchdrop').style.width = readCookie(ajcurrent+"wid") + "px";
		document.getElementById('ajaxsearchdrop').style.height = readCookie(ajcurrent+"hei") + "px";
	} else {
		document.getElementById('ajaxsearchdrop').style.width = ajminwid + "px";
		document.getElementById('ajaxsearchdrop').style.height = ajminhei + "px";
	}
	if (ns4) {
		document.ajaxsearchdrop.top = Math.max(findPosY(ajinput) + pixdown) + 'px';
		document.ajaxsearchdrop.left = Math.max(findPosX(ajinput) - pixeladjust) + 'px';
		document.ajaxsearchdrop.visibility = "show";
	} else if (ie4) {
		document.all['ajaxsearchdrop'].style.top = Math.max(findPosY(ajinput) + pixdown) + 'px';
		document.all['ajaxsearchdrop'].style.left = Math.max(findPosX(ajinput) - pixeladjust) + 'px';
		document.all['ajaxsearchdrop'].style.visibility = "visible";
	} else if (nn6) {
		document.getElementById('ajaxsearchdrop').style.top = Math.max(findPosY(ajinput) + pixdown) + 'px';
		document.getElementById('ajaxsearchdrop').style.left = Math.max(findPosX(ajinput) - pixeladjust) + 'px';
		document.getElementById('ajaxsearchdrop').style.visibility = "visible";
	}
}

/**************************************************/
/* AJAX [2 of 3]: Resizing of The AJAX Search Box */
/**************************************************/
function setupdrag(e) {
	var t=document.getElementById('asdtdd');
	d.etarget=this; //remember div mouse is currently held down on ("handle" or "resize" div)
	var e=window.event || e;
	d.curwidth = document.getElementById('ajaxsearchdrop').style.width.replace(/px/, "");
	d.curheight = document.getElementById('ajaxsearchdrop').style.height.replace(/px/, "");
	d.initmousex=e.clientX;
	d.initmousey=e.clientY;
	d.initx=parseInt(t.offsetLeft);
	d.inity=parseInt(t.offsetTop);
	document.onmousemove=getdistance;
	document.onmouseup=function() {
		stopresize();
	}
	return false;
}
function getdistance(e) {
	var etarget=d.etarget;
	var e=window.event || e;
	d.distancex=e.clientX-d.initmousex + d.initx + 23;
	d.distancey=e.clientY-d.initmousey + d.inity + 20;
	
	/* debugging of this tricky item       <div id="output"></div>
	document.getElementById('output').innerHTML = '' + '<br />e.clientX:' + e.clientX + ', e.clientY:' + e.clientY + '<br />mindragx:' + mindragx + ', mindragy:' + mindragy + '<br />d.distancex:' + d.distancex + ', d.distancey:' + d.distancey + "<br>" + '<br />d.initmousex:' + d.initmousex + ', d.initmousey:' + d.initmousey + "<br>" + '<br />width:' + document.getElementById('ajaxsearchdrop').style.width.replace(/px/, "") + '<br />height:' + document.getElementById('ajaxsearchdrop').style.height.replace(/px/, "");			*/
					
	if (d.distancex > mindragx && d.distancex < maximumAjWidth) {
		d.style.width=d.distancex + 'px';
	} else if (d.distancex >= maximumAjWidth) {
		d.style.width=maximumAjWidth + 'px';
	} else {
		d.style.width=mindragx + 'px';
	}
	if (d.distancey > mindragy) {
		d.style.height=d.distancey + 'px';
	} else {
		d.style.height=mindragy + 'px';
	}
	return false; //cancel default dragging behavior
}
function stopresize() {
	createCookie(ajcurrent+"wid", document.getElementById('ajaxsearchdrop').style.width.replace(/px/, "")-0, 30);
	createCookie(ajcurrent+"hei", document.getElementById('ajaxsearchdrop').style.height.replace(/px/, "")-0, 30);
	d.etarget=null; //clean up
	document.onmousemove=null;
	document.onmouseup=null;
}

/*************************************************************************************/
/* AJAX [3 of 3]: Actual AJAX Functionality For Retrieving Related Glossary Searches */
/*************************************************************************************/
var checking = false;
var checkvalue = '';
function showGoDef() {
	return '<a href="javascript:;" onClick="closeAjMenu();" style="font:11px Verdana;">Close</a>';
}
function loadFragmentInToElement(fragment_url, element_id, fullcheck) {
    var element = document.getElementById(element_id);
	
	if (typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	} else {
		xmlhttp = new ActiveXObject("MSXML2.XMLHTTP.3.0");
	}
	
    xmlhttp.open("GET", fragment_url);
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            element.innerHTML = xmlhttp.responseText;
			if (fullcheck == true) {
				document.getElementById('showGo').innerHTML = showGoDef();
			}
			checking = false;
        }
    }
    xmlhttp.send(null);
}
function removePrefixFromCookie(onwhat) {
	findat = onwhat.indexOf(":");
	if(findat > -1 && findat < onwhat.length) {
		onwhat = onwhat.substring(findat+1, onwhat.length);
	}
	//alert("cookieing: " + onwhat);
	return onwhat;
}
function checkIt(thedu) {
	createCookie("sq", removePrefixFromCookie(thedu), 2);
	checkvalue = thedu;
	if (thedu == '') {
		closeAjMenu();
	} else {
		if (checking == true && thedu.substring(0,4) == 'top:') {
			loadIt(thedu, false);
		} else if (thedu.substring(0,4) == 'top:' && thedu.length == 4) {
			loadIt(thedu, false);
		} else if (thedu.substring(0,4) == 'top:') {
			showGoButton();
			loadIt(thedu, false);
		} else {
			document.getElementById('showGo').innerHTML = showGoDef();
			loadIt(thedu, false);
		}
	}
}
function showLoading() {
	document.getElementById('showGo').innerHTML = '<table cellpadding=0 cellspacing=0 align="right" style="margin-bottom:5px; _margin-bottom:-3px;"><tr><td valign=middle style=padding-left:4px><img src=images/ajsearchdrop/ajax-loader.gif width=16 height=16></td><td valign=middle style=padding-left:8px>loading&nbsp;All&nbsp;results</td></tr></table>';
}
function showGoButton() {
	document.getElementById('showGo').innerHTML = '<table cellpadding=0 cellspacing=0 align="right" style="margin-bottom:5px; _margin-bottom:-3px;"><tr><td><img src=images/transparent.gif width=16 height=16></td><td valign=middle>&raquo;</td><td valign=middle style=padding-left:2px><a href="javascript:;" onClick="javascript: showLoading(); loadIt(checkvalue, true); return false;">View&nbsp;All&nbsp;Results</a></td></tr></table>';
}
function loadIt(thedu, fullcheck) {
	checking = true;
	var ran_number=Math.floor(Math.random()*500000);
	if (thedu.length > 0) {
		// to eventually be http://ajax.glossary.com/ajsearch.cfm  [error - ajax functionality needs to be on the same domain!!]
		loadFragmentInToElement('http://www.glossary.com/ajax/ajsearch.cfm?query=' + thedu + '&rn=' + ran_number + '&fc=' + fullcheck, 'foundSearchResults', fullcheck);
	} else {
		document.getElementById('foundSearchResults').innerHTML = '';
	}
}
function searchthis(thisvalue) {
	document.getElementById(ajcurrent).childNodes.item(0).value=thisvalue;
	createCookie("sq", removePrefixFromCookie(thisvalue), 2);
	showGoButton();
	loadIt(aform.searchquery.value, false);
}
function showbigpic(bp, e) {
	document.getElementById('bignamepic').innerHTML = '<img src="images/ajsearchdrop/andrew.gif" width="82" height="100" alt="">';
	showObject(e);
}
function hideObject() {
	if (ns4) {
		document.bignamepic.visibility = "hide";
	} else if (ie4) {
		document.all['bignamepic'].style.visibility = "hidden";
	} else if (nn6) {
		document.getElementById('bignamepic').style.visibility = "hidden";
	}
}
function showObject(e) {
	var topto = 0;
	if (document.documentElement.scrollTop && document.documentElement.scrollTop > 0) {
		topto = document.documentElement.scrollTop;
		} else if (window.pageYOffset && window.pageYOffset > 0) {
	topto = window.pageYOffset;
	} else if (document.body.scrollTop && document.body.scrollTop > 0) {
		topto = document.body.scrollTop;
	}
	if (ns4) {
		document.bignamepic.visibility = "show";
	} else if (ie4) {
		document.all['bignamepic'].style.visibility = "visible";
	} else if (nn6) {
		document.getElementById('bignamepic').style.visibility = "visible";
	}
}














/*********************/
/* Double Click Menu */
/*********************/
var IEorOP = (navigator.appName=='Microsoft Internet Explorer' && navigator.userAgent.indexOf("Opera")==-1?1:0);
var limitDblClick = 1;
var dcOnPage = 0;
var clicklocxy = new Array();
function loadword(e) {
	dcOnPage = dcOnPage + 1;
	
	//if (limitDblClick) { limitDblClick=1; return; }
	
	if (!IEorOP) {
		selectedText = document.getSelection();
		
		clicklocxy = getEventClickXYCoords(e);
		if(selectedText.substring(selectedText.length-1, selectedText.length) == " ") {
			showspace = " ";
		}
		var testtrimed = selectedText.replace(/\W/gi,"");
		testtrimed = testtrimed.replace(/\n*/gi,"");
		testtrimed = testtrimed.replace(/\s*/gi,"");
		if (testtrimed.length > 0) {
			openglossary(selectedText);
		}
	} else {
		selectedText = document.selection.createRange();
		if (document.selection.type == 'Text' && selectedText.text != '') {
			var theText = selectedText.text;
			var showspace = "";
			if(theText.substring(theText.length-1, theText.length) == " ") {
				showspace = " ";
			}
			var testtrimed = theText.replace(/\W/gi,"");
			testtrimed = testtrimed.replace(/\n*/gi,"");
			testtrimed = testtrimed.replace(/\s*/gi,"");
			if (testtrimed.length > 0) {
				selectedText.pasteHTML(' <span id="highl' + dcOnPage + '" style="background-Color:#ffe589; color:#000000;">' + selectedText.text.replace(/^\s*|\s*$/g,"") + '</span>' + showspace);
				openglossary(theText);
			}
		}
	}
}
function getEventClickXYCoords(e) {
	var topto = 0;
	if (document.documentElement.scrollTop && document.documentElement.scrollTop > 0) {
		topto = document.documentElement.scrollTop;
	} else if (window.pageYOffset && window.pageYOffset > 0) {
		topto = window.pageYOffset;
	} else if (document.body.scrollTop && document.body.scrollTop > 0) {
		topto = document.body.scrollTop;
	}
	if (safari) {
		topto = 0;
	}
	if (ns4) {
		clicklocxy[0] = e.pageX;
		clicklocxy[1] = e.pageY + topto;
	} else if (ie4) {
		clicklocxy[0] = e.clientX;
		clicklocxy[1] = e.clientY + topto;
	} else if (nn6) {
		clicklocxy[0] = e.clientX;
		clicklocxy[1] = e.clientY + topto;
	}
	return clicklocxy;
}
function openglossary(text) {
	if (nn6 == false) {
		if (document.getElementById('highl' + dcOnPage) || document.getElementById('highl' + dcOnPage).innerHTML != '') {
			var hldiv = document.getElementById('highl' + dcOnPage);
			hideDropBox();
			closeAjMenu();
			showDblClkBox(findPosX(hldiv), findPosY(hldiv), text);
		} else {
			hideDropBox();
			closeAjMenu();
			showDblClkBox(clicklocxy[0], clicklocxy[1], text);
		}
	} else {
		hideDropBox();
		closeAjMenu();
		showDblClkBox(clicklocxy[0], clicklocxy[1], text);
	}
}
function hideOldHighlightColors() {
	if (dcOnPage > 0) {
		for (i=1; i<=dcOnPage; i++) {
			if (i != dcOnPage) {
				if (document.getElementById('highl' + i)) {
					document.getElementById('highl' + i).style.backgroundColor=''; // set it to nothing.  you would think #FFFFFF, but nothing allows background images
					document.getElementById('highl' + i).style.color='';
				}
			}
		}
	}
}
function hideDblClkBox() {
	hideOldHighlightColors();
	if (ns4) {
		document.dblclkdrop.visibility = "hide";
	} else if (ie4) {
		document.all['dblclkdrop'].style.visibility = "hidden";
	} else if (nn6) {
		document.getElementById('dblclkdrop').style.visibility = "hidden";
	}
}
function showDblClkBox(atPosX,atPosY,text) {
	hideOldHighlightColors();
	writeDblClkMenu(text);
	// fix the menu from poping up too far right
	var offsetxmaxat = findPosX(document.getElementById('customselect'));
	if (atPosX+100 > offsetxmaxat) {
		atPosX = atPosX - 200;
	}
	var offYHeight = getElementHeight(document.getElementById('highl' + dcOnPage)) + 3;
	if (ns4) {
		document.dblclkdrop.visibility = "show";
		document.dblclkdrop.top = atPosY + offYHeight + 'px';
		document.dblclkdrop.left = atPosX + 'px';
	} else if (ie4) {
		document.all['dblclkdrop'].style.visibility = "visible";
		document.all['dblclkdrop'].style.top = atPosY + offYHeight + 'px';
		document.all['dblclkdrop'].style.left = atPosX + 'px';
	} else if (nn6) {
		document.getElementById('dblclkdrop').style.visibility = "visible";
		document.getElementById('dblclkdrop').style.top = atPosY + offYHeight + 'px';
		document.getElementById('dblclkdrop').style.left = atPosX + 'px';
	}
}
function rollDblClkOn(el) {
	el.style.backgroundColor='#cbd5ec';
}
function rollDblClkOff(el) {
	el.style.backgroundColor='';
}
function goToPage(whword,whpage) {
	if (whpage == 'pronunciation') {
		pronunciationBlock(whword);
	} else {
		document.location=whpage+'.php?q='+whword;
	}
}
function writeDblClkMenu(text) {
	var dmcontent = '<table cellpadding="0" cellspacing="0"><tr><td colspan="3"><a href="javascript:;" onClick="hideDblClkBox(); dcOnPage++; hideOldHighlightColors();"><img src="images/clickmenu/clktop5.gif" width="251" height="32" alt="" border=0></a></td></tr><tr><td width="5" background="images/clickmenu/clkleft.gif"><img src="images/clickmenu/clkleft.gif" width="5" height="1" alt=""></td><td width="240" style="background-Color:#dde7ff; background-image:url(images/clickmenu/clkbg.gif); background-repeat:repeat-x;">';
	var dmcontypes = new Array("Overview","---","Glossary","Encyclopedia","Dictionary","Web Glossary","Categories","---","Web Search","---","Print View","Save To My Bibliography","Pronunciation","Send To A Friend");
	var dmcontypel = new Array("reference","---","glossary","encyclopedia","dictionary","web","category","---","websearch","---","printview","bibliography","pronunciation","sendtoafriend");
	for (i=0; i<dmcontypes.length; i++) {
		showdmcheck = '';
		var extrastyle = '';
		if (dmcontypes[i] == "Send To A Friend") {
			extrastyle = ' margin-bottom:10px;';
		}
		var dropright = '';
		if (dmcontypes[i] == "Categories") {
			dropright = '<span style="float:right;"><a href=""><img src="images/clickmenu/dropright.gif" width="36" height="13" alt="" border=0></a></span>';
		}
		var actualtext = text.replace(/^\s*|\s*$/g,"");
		var shextra = "";
		if (i < 9 && i != 6 || i == 12) {
			showtxt = actualtext;
			if (showtxt.length > 12) {
				showtxt = showtxt.substring(0,10) + "...";
			} 
			shextra = ': <span style="color:#bbbbbb;">&nbsp;\'' + showtxt + '\'</span>';
		}
		var extrastylennff = '';
		var thumbico = dmcontypes[i].replace(/\s*/g,"").toLowerCase();
		if (!ie4) {
			extrastylennff = 'background:url(images/clickmenu/ico' + thumbico + '.gif); background-repeat:no-repeat;';
		}
		if (dmcontypes[i] != "---") {
			dmcontent = dmcontent + '<div style="padding:5px; cursor:pointer; font-family:Verdana; font-size:11px; line-height:11px;' + extrastyle + '" onMouseOver="rollDblClkOn(this);" onMouseOut="rollDblClkOff(this);" onClick="goToPage(\'' + actualtext + '\', \'' + dmcontypel[i] + '\');" style="background:url(images/clickmenu/ico' + thumbico + '.gif); background-repeat:no-repeat; background-position:0px 3px;"><div style="padding-left:40px; ' + extrastylennff + '">' + dropright + dmcontypes[i] + shextra + '</div></div>';
		} else {
			dmcontent = dmcontent + '<hr style="height:1px; color:#b7bbc1; margin:8px; _margin:0px; padding:0px; text-align:center; width:220px;" size="1px" color="#b7bbc1">';
		}
	}
	dmcontent = dmcontent + '</td><td width="6" background="images/clickmenu/clkright.gif"><img src="images/clickmenu/clkright.gif" width="6" height="1" alt=""></td></tr><tr><td colspan="3"><img src="images/clickmenu/clkbot5.gif" width="251" height="6" alt=""></td></tr></table>';
	document.getElementById('dblclkdrop').innerHTML=dmcontent;
}












/*********************************************/
/* Pronunciation Block (not yet implemented) */
/*********************************************/
function pronunciationBlock(forwords) {
	alert('dhtml pronunciate block: ' + forwords);
}












/******************************************************/
/* Bookmark Link At Top Of Site (not yet implemented) */
/******************************************************/
function popbookmarks(e) {
	alert('dhtml bookmarks popdown here');
}

function bookmarksite(title,url) {

	if (window.sidebar) { // firefox

		window.sidebar.addPanel(title, url, "");
	
	} else if (window.opera && window.print) { // opera

		var elem = document.createElement('a');

		elem.setAttribute('href',url);

		elem.setAttribute('title',title);

		elem.setAttribute('rel','sidebar');

		elem.click();

	} else if(document.all) { // ie
	
		window.external.AddFavorite(url, title);
	
	}
	//<a href="javascript:bookmarksite('HawaiiOahuMaui.com, your online resource for hawaii', 'http://HawaiiOahuMaui.com')">Add to Favorites</a>
	//<a href="#" onclick="bookmarksite('HawaiiOahuMaui.com, your online resource for hawaii', 'http://HawaiiOahuMaui.com');return false;">Add to Favorites js link test</a>
}
