
var emoLayer = '';
var onOverEmo = false;

function hideEmo()
{
	if(document.getElementById(emoLayer))
	{
		if((document.getElementById(emoLayer).style.visibility == 'visible') && (onOverEmo == false))
		{
			hideLayer(emoLayer);
		}
	}
}

function emolayer_show(tooltipId, parentId, posX, devY){

	hideLayer(tooltipId);
	
    it = document.getElementById(tooltipId);
    img = document.getElementById(parentId); 
    
    it.style.top = devY + img.offsetTop + 'px';
    it.style.left = posX + img.offsetLeft + 'px';    
    
    it.style.visibility = 'visible'; 
}

function  hideLayer(id){
    it = document.getElementById(id); 
    it.style.visibility = 'hidden'; 
}

//myField accepts an object reference, myValue accepts the text string to add 
function insertAtCursor(myField, myValue) { 
	//IE support 
	if (document.selection) { 
	myField.focus(); 
	
	//in effect we are creating a text range with zero 
	//length at the cursor location and replacing it 
	//with myValue 
	sel = document.selection.createRange(); 
	sel.text = myValue; 
	} 
	//Mozilla/Firefox/Netscape 7+ support 
	else if (myField.selectionStart || (myField.selectionStart == '0')) { 
	
	//Here we get the start and end points of the 
	//selection. Then we create substrings up to the 
	//start of the selection and from the end point 
	//of the selection to the end of the field value. 
	//Then we concatenate the first substring, myValue, 
	//and the second substring to get the new value. 
	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; 
	}
}

document.onmousedown = hideEmo;
