/********************************************************************************
Class WSDictionary
********************************************************************************/
function WSDictionary() {
	this.self = this;
	this.timerID = null;
	this.startDictionaryTimer =  function(e, oWSEE) {
		if (this.timerID == null) {
			if (oWSEE) {
				if (oWSEE.config.sMode == "min") {
					return false;
				}
				var oElement = WSDomUtils.getEventElement(e);
				if (!oElement) {
					return false;
				}
				var sWord = WSUtils.getEscapedWord(oElement.innerHTML);
				if (sWord.length < 2 && !oWSEE.isAlpha(sWord)) {
					return true;
				}
				var nIndex = oWSEE.getElementIndex(oElement);
				if (nIndex < 0) {
					nIndex = oWSEE.nSelectedIndex;
				}
				var nLangType = 0;
				if (nIndex >= 0) {
					var nLangType = oWSEE.vEnrichment[nIndex].nLangType;
				}
				var oMousePos = oWSEE.getMousePos(e);
				oWSEE.setLastPointedInfo(e, oMousePos, sWord, nLangType, nIndex, oElement);
				var sFunc = "onQueryDictionary(\"" + sWord + "\"," + nLangType + ")";
				this.word = sWord;
				this.langType = nLangType;
				this.currentEngine = oWSEE;
				if (oWSEE.config.enableDictionary) {
					timerID = setTimeout(function(){self.queryDictionary();}, 2000);
					//timerID = setTimeout("WSSharedEnrichmentEngine.queryDictionary()", 2000);
				}	
			}
		}
	}
	this.queryDictionary = function() {
		var oWSEE = this.currentEngine;
		this.stopDictionaryTimer();
		if (oWSEE) {
			oWSEE.queryDictionary(this.word, this.langType);
		}
	}
	this.stopDictionaryTimer = function() {
		if (this.timerID) {
			clearTimeout(this.timerID);
		}
		timerID = null;
	}
}

var WSSharedEnrichmentEngine = new WSDictionary();