function FillText(val,fieldValue)
{
    return "<div id="+fieldValue+" onmousedown='DragStart()' onclick='SetValue()' style='cursor: hand; border: solid 1px #9c9c9c; width: 99%; height: 99%; text-align: center;'>"+val+"</div>"
}
var labelStr;
function DragStart()
{
    dragclear();
    window.drag = 1;
    dragspan = document.createElement('div');
    dragspan.style.position = "absolute";
    dragspan.className="div" ;
    var mousePos = mouseCoords(window.event);
    dragspan.style.left = mousePos.x + 10;
    dragspan.style.top = mousePos.y + 8;
    labelStr = window.event.srcElement.id;
    dragspan.appendChild(document.createTextNode(window.event.srcElement.innerHTML));
    document.body.appendChild(dragspan);
}
function SetValue()
{
    document.all.test.focus();
    var tarobj = document.selection.createRange();
    tarobj.text = labelStr;
    if(window.drag)
    {
        window.drag = 0;
        window.event.returnValue = true;
    }
}
function dragend()
{
    if(window.drag)
    {
        document.body.removeChild(dragspan);
        SetValue();
    }
}
function mouseCoords(ev) {
    if(ev.pageX || ev.pageY) {
        return {x:ev.pageX, y:ev.pageY};
    }
    return {
        x:ev.clientX + document.documentElement.scrollLeft - document.body.clientLeft,
        y:ev.clientY + document.documentElement.scrollTop - document.body.clientTop
    };
}
function dragclear()
{
    if(window.drag)
    {
        document.body.removeChild(dragspan);
        window.drag = 0;
        window.event.returnValue = true;
    }
}
function dragmove()
{
    if(window.drag)
    {
        var ev = ev || window.event;
        var mousePos = mouseCoords(ev);
        ev.returnValue = false;
        dragspan.style.left = mousePos.x + 10;
        dragspan.style.top = mousePos.y + 8;
    }
}
function movePoint()
{
    if(window.drag)
    {
        var rng = event.srcElement.createTextRange();
        rng.moveToPoint(event.x,event.y);
        rng.select();
    }
}