/*
 overlibmws_draggable.js plug-in module - Copyright Foteos Macrides 2002=2005
   For support of the DRAGGABLE feature.
   Initial: August 24, 2002 - Last Revised: December 21, 2004
 See the Change History and Command Reference for overlibmws via:

	http://www.macridesweb.com/oltest/

 Published under an open source license: http://www.macridesweb.com/oltest/license.html
*/

OLloaded=0;
OLregCmds('draggable');

// DEFAULT CONFIGURATION
if(OLud('draggable'))var ol_draggable=1;
// END CONFIGURATION

var o3_draggable=0,o3_dragging=0,OLmMv,OLcX,OLcY,OLnewX,OLnewY,OLcbX,OLcbY;

function OLloadDraggable(){
OLload('draggable');
}

// For commandline parser.
function OLparseDraggable(pf,i,ar){
var k=i;
if(k<ar.length){if(Math.abs(ar[k])==DRAGGABLE){OLtoggle(ar[k],pf+'draggable');return k;}}
return -1;
}

function OLcheckDrag(){
if(o3_draggable&&o3_sticky&&(o3_frame==self)){if(!o3_dragging)OLinitDrag();}
else{o3_draggable=0;if(o3_dragging)OLclearDrag();}
}

function OLinitDrag(){
if(!o3_dragging){OLmMv=OLdw.onmousemove;
if(OLns4){
document.captureEvents(Event.MOUSEDOWN|Event.CLICK);
document.onmousedown=OLgrabEl;
document.onclick=function(e){return routeEvent(e);}
}else{over.onmousedown=OLgrabEl;over.style.cursor="move";}
o3_dragging=1;}
}

function OLgrabEl(e){
var e=(e)?e:event;
var cKy=(OLns4?e.modifiers&Event.ALT_MASK:(!OLop7)?e.altKey:e.ctrlKey);
if(cKy){if(!OLns4)over.style.cursor="auto";
document.onmouseup=function(){if(!OLns4){if(!OLns4)over.style.cursor="move";}}
return(OLns4?routeEvent(e):true);}
OLmMv(e);
if(OLns4){OLcX=e.pageX;OLcY=e.pageY;
}else{OLcX=OLx-(parseInt(over.style.left));OLcY=OLy-(parseInt(over.style.top));
if((OLshadowPI)&&bkdrop&&o3_shadow){
OLcbX=OLx-(parseInt(bkdrop.style.left));OLcbY=OLy-(parseInt(bkdrop.style.top));}}
if(OLns4)document.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
OLdw.onmousemove=OLmoveEl;
document.onmouseup=function(){OLdw.onmousemove=OLmMv;document.onmouseup=null;}
return (OLns4?routeEvent(e):false);
}

function OLmoveEl(e){
OLmMv(e);
if(OLns4){OLnewX=e.pageX;OLnewY=e.pageY;over.moveBy(OLnewX-OLcX,OLnewY-OLcY);
if((OLshadowPI)&&bkdrop&&o3_shadow)bkdrop.moveBy(OLnewX-OLcX,OLnewY-OLcY);
OLcX=OLnewX;OLcY=OLnewY;}else{OLrepositionTo(over,OLx-OLcX,OLy-OLcY);
if((OLiframePI)&&OLie55&&OLifsP1)OLrepositionTo(OLifsP1,OLx-OLcX,OLy-OLcY);
if((OLshadowPI)&&bkdrop&&o3_shadow){OLrepositionTo(bkdrop,OLx-OLcbX,OLy-OLcbY);
if((OLiframePI)&&OLie55&&OLifsSh)OLrepositionTo(OLifsSh,OLx-OLcbX,OLy-OLcbY);}}
if(OLhidePI)OLhideUtil(0,1,1,0,0,0);
return false;
}

function OLclearDrag(){
if(o3_dragging){if(OLns4){
document.releaseEvents(Event.MOUSEDOWN|Event.MOUSEUP|Event.CLICK);
document.onmousedown=document.onmouseup=document.onclick=null;
}else{over.onmousedown=null;over.style.cursor="auto";}
o3_dragging=0;}
}

OLregRunTimeFunc(OLloadDraggable);
OLregCmdLineFunc(OLparseDraggable);

OLdraggablePI=1;
OLloaded=1;

