Decode, все работает, спасибо.
<div id='gray' onmousedown="if (event.target.id != 'gray') return; drag_object(event, event.target)"; style=" position:absolute; border:1px solid blue; background-color: #C0C0C0; width:100px; height:100px; cursor:pointer" >
<div style="border:1px solid red; background-color:#33FF66; width:40px; height:40px" id="green"></div>
</div>
<script>
//document.getElementById('gray').onmousedown = function(event){drag_object(event, this)}
function drag_object( evt, obj ){
evt = evt || window.event;
obj.clicked = true;
obj.mousePosX = evt.clientX;
obj.mousePosY = evt.clientY;
if( evt.preventDefault ) evt.preventDefault();
else evt.returnValue = false;
document.onmouseup = function(){ obj.clicked = false;}
document.onmousemove = function( evt )
{
evt = evt || window.event;
if( obj.clicked )
{
posLeft = !obj.style.left ? obj.offsetLeft : parseInt( obj.style.left );
posTop = !obj.style.top ? obj.offsetTop : parseInt( obj.style.top );
mousePosX = evt.clientX;
mousePosY = evt.clientY;
obj.style.left = posLeft + mousePosX - obj.mousePosX + 'px';
obj.style.top = posTop + mousePosY - obj.mousePosY + 'px';
obj.mousePosX = mousePosX;
obj.mousePosY = mousePosY;
}
}
}
function setcookie( name, value, timeout )
{
timeout = timeout || 1000*60*60*24;
expires = (new Date((new Date).getTime() + timeout)).toUTCString();
document.cookie = name + '=' + value + ';expires=' + expires;
}
</script>