
function WinGetIframeDocs(win)
{iframedocs=[];var iframes=win.frames;for(var i=0;i<iframes.length;i++)
{if((i in Object.prototype))continue;var iframedoc=iframes[i].document;iframedocs.push(iframedoc);}
return iframedocs;}
function BorderSet(obj,style)
{var currBorderStyle=null;if(obj!=null&&obj.style!=null)
{obj.style.borderWidth="thin";obj.style.borderColor="blue";currBorderStyle=obj.style.borderStyle;obj.style.borderStyle=style;}
return currBorderStyle;}
var DRAG_ACTION_NONE=0;var DRAG_ACTION_MOVE=1;var DRAG_ACTION_SIZE=2;function Drag(win1,doc1)
{if(typeof(win1)=="undefined")
win1=window;if(typeof(doc1)=="undefined")
doc1=document;this.win=win1;this.doc=doc1;this.objElem=null;this.objActual=null;this.canmove=true;this.canresize=true;this.working=DRAG_ACTION_NONE;this.modified=false;this.onmousedown=Drag_onMouseDown;this.onmousemove=Drag_onMouseMove;this.onmouseup=Drag_onMouseUp;this.inaction=Drag_inAction;this.cancelaction=Drag_cancelAction;this.add=Drag_add;this.remove=Drag_remove;}
function DragSingleton(win1,doc1)
{if(typeof(win1)=="undefined")
win1=window;if(typeof(doc1)=="undefined")
doc1=document;return new Drag(win1,doc1);}
var drags=[];function DragSingletonDoc(win1,doc1)
{if(typeof(win1)=="undefined")
win1=window;if(typeof(doc1)=="undefined")
doc1=document;for(var i in drags)
{if((i in Object.prototype))continue;if(drags[i].doc==doc1)
{return drags[i];}}
var drag=new Drag(win1,doc1);drags.push(drag);return drag;}
Drag.getDrag=DragSingletonDoc;function Drag_onMouseDown(e)
{e=e||this.win.event;if(!this.canmove&&!this.canresize)
return;var obj=(isFF)?e.target:e.srcElement;if(obj.wrappedJSObject)
obj=obj.wrappedJSObject;if(obj.tagName=="a"||obj.tagName=="A")
{return;}
while
(obj!=obj.parentNode&&obj.parentNode!=null&&typeof obj.dragaction=='undefined')
{obj=obj.parentNode;}
if((typeof obj.dragaction)=='undefined')
{return;}
if(this.working!=DRAG_ACTION_NONE&&this.objElem==obj)
{var ret=this.onmouseup(e);return ret;}
this.objElem=obj;this.working=obj.dragaction||DRAG_ACTION_MOVE;this.objActual=obj.objActual||obj;if(typeof this.objActual=='string')
this.objActual=this.doc.getElementById(this.objActual);if(typeof this.objActual.ondragenter=='function')
{e.dragobj=this;var result=this.objActual.ondragenter(e);if(result==false)
{this.working=DRAG_ACTION_NONE;this.objElem=null;this.objActual=null;return;}}
this.eventStartX=e.clientX;this.eventStartY=e.clientY;if(e.shiftKey)
{this.working=DRAG_ACTION_SIZE;}
if(this.working==DRAG_ACTION_MOVE)
{this.pixelStartX=ObjGetX(this.objActual);this.pixelStartY=ObjGetY(this.objActual);}else
if(this.working==DRAG_ACTION_SIZE)
{this.pixelStartW=ObjGetW(this.objActual);this.pixelStartH=ObjGetH(this.objActual);}
this.oldBorderStyle=BorderSet(this.objActual,"dotted");this._onmousemove=this.onmousemove.bind(this);this._onmouseup=this.onmouseup.bind(this);EventCatch(this.doc,"mousemove",this._onmousemove);EventCatch(this.doc,"mouseup",this._onmouseup);var dragDiv=this.doc.getElementById('NMDragDiv');if(dragDiv)
{dragDiv.style.visibility="visible";}
if(this.objElem.setCapture)
this.objElem.setCapture(true);EventConsume(e);}
function Drag_onMouseMove(e)
{e=e||this.win.event;if((isIE&&e.button!=1))
{var ret=this.onmouseup(e);}else
{ret=this.inaction(e);}
EventConsume(e);return ret;}
function Drag_inAction(e)
{if(!this.objElem||this.working==DRAG_ACTION_NONE)
return false;var obj=e.target||e.srcElement;if(obj.wrappedJSObject)
obj=obj.wrappedJSObject;var X=e.clientX-this.eventStartX;var Y=e.clientY-this.eventStartY;if(this.working==DRAG_ACTION_MOVE)
{ObjMoveTo(this.objActual,X+this.pixelStartX,Y+this.pixelStartY);}
else
if(this.working==DRAG_ACTION_SIZE)
{ObjResizeTo(this.objActual,X+this.pixelStartW,Y+this.pixelStartH);}
return false;}
function Drag_cancelAction(e)
{if(this.working==DRAG_ACTION_MOVE)
ObjMoveTo(this.objActual,this.pixelStartX,this.pixelStartY);else if(this.working==DRAG_ACTION_SIZE)
ObjResizeTo(this.objActual,this.pixelStartW,this.pixelStartH);}
function Drag_onMouseUp(e)
{e=e||this.win.event;this.inaction(e);EventConsume(e);EventRelease(this.doc,"mousemove",this._onmousemove);EventRelease(this.doc,"mouseup",this._onmouseup);var dragDiv=this.doc.getElementById('NMDragDiv');if(dragDiv)
{dragDiv.style.visibility="hidden";}
if(this.working==DRAG_ACTION_NONE)
{return false;}
if(this.objElem.releaseCapture)
this.objElem.releaseCapture();if(typeof this.objActual.ondragend=='function')
{try{e.dragobj=this;var result=this.objActual.ondragend(e);if(result==false)
{this.cancelaction(e);}}catch(err){}}
if(typeof this.objActual.onmoved=='function'&&this.working==DRAG_ACTION_MOVE)
{try{this.objActual.onmoved(e);}catch(err){}}
if(typeof this.objActual.onresized=='function'&&this.working==DRAG_ACTION_SIZE)
{try{this.objActual.onresized(e);}catch(err){}}
this.working=DRAG_ACTION_NONE;BorderSet(this.objActual,this.oldBorderStyle);this.objElem=null;this.objActual=null;this.modified=true;this.lastModified=(new Date()).getTime();return false;}
function Drag_add(obj,dragaction,actualIdObj)
{if(!obj)
return;dragaction=(typeof dragaction=='undefined')?DRAG_ACTION_MOVE:dragaction;obj.dragaction=dragaction;obj.objActual=actualIdObj;this._onmousedown=this.onmousedown.bind(this);EventCatch(obj,"mousedown",this._onmousedown);}
function Drag_remove(obj)
{obj.dragaction=null;obj.objActual=null;EventRelease(obj,"mousedown",this._onmousedown);}
debug("drag.js 1320");