function createCaret(textEl) {
	if (textEl.createTextRange)
		textEl.caretPos = document.selection.createRange().duplicate();
}

function insertCode(openTag, tagData, closeTag) {
	
	
	var	imailMsg_obj = document.getElementById("imail_msg");
	
	
	text = openTag + "  " + tagData + "  " + closeTag;
	if(imailMsg_obj.createTextRange && imailMsg_obj.caretPos)
		{
			 var caretPos = imailMsg_obj.caretPos;
			 
			 caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
			 imailMsg_obj.focus();
		}
		else
		{
	            imailMsg_obj.value  += text;
                imailMsg_obj.focus();		
		}
	//var tagData = imailMsg_obj.value ;	
}


function imail_storeCaret(textEl) {

        if (textEl.createTextRange) 
			textEl.caretPos = document.selection.createRange().duplicate();			
}


function putButton(toolTip, textdis, openTag, tagData, closeTag) {
	document.write("<input class=fb type=button value=\"" +textdis+ "\"  onClick=\"javascript:insertCode(\'"+openTag+"\', \'"+tagData+"\', \'"+closeTag+"\');\" onMouseOver=\"document.all.imail_tooltip.innerHTML='"+toolTip+"';\" onMouseOut=\"document.all.imail_tooltip.innerHTML='';\"  onfocus=\"document.all.imail_msg.focus();\" >");
}




function imailForward()
{
	document.imail_farward.submit();
	return false ;
}

function imailReply()
{
	document.imail_reply.submit();
	return false ;
}



function imailDelete()
{
	document.getElementById("imailAction").value = "delete" ;
	document.imail_from.submit();
	
}

function imailSent_delete()
{
	document.getElementById("imailSent_action").value = "deleteIMS" ;
	document.imail_sent_from.submit();
	
}




