function closePopUp(toClose){
	changeProp(toClose,'','style.visibility','hidden','LAYER');
	changeProp(toClose,'','style.top','100','LAYER');
	changeProp(toClose,'','style.left','200','LAYER');
	popUp = false;
}

function findObj(n, d) { 
  var p,i,x;
  if(!d) d=document;
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document;
	n=n.substring(0,p);
	}
  if(!(x=d[n])&&d.all) x=d.all[n]; 
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n);
  return x;
}

function changeProp(objName,x,theProp,theValue) { 
  var obj = findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
}



function dragLayer(objName,x,hL,hT,hW,hH,toFront,dropBack,cU,cD,cL,cR,targL,targT,tol,dropJS,et,dragJS) { //v3.0

  var i,j,aLayer,retVal,curDrag=null,NS=(navigator.appName=='Netscape'), curLeft, curTop;
  if (!document.all && !document.layers) return false;
  retVal = true; if(!NS && event) event.returnValue = true;
  if (dragLayer.arguments.length > 1) {
    curDrag = findObj(objName); if (!curDrag) return false;
    if (!document.allLayers) { document.allLayers = new Array();
      with (document) if (NS) { for (i=0; i<layers.length; i++) allLayers[i]=layers[i];
        for (i=0; i<allLayers.length; i++) if (allLayers[i].document && allLayers[i].document.layers)
          with (allLayers[i].document) for (j=0; j<layers.length; j++) allLayers[allLayers.length]=layers[j];
      } else for (i=0;i<all.length;i++) if (all[i].style&&all[i].style.position) allLayers[allLayers.length]=all[i];}
    curDrag.dragOK=true; curDrag.dragOKtargL=targL; curDrag.dragOKtargT=targT;
    curDrag.dragOKtol=Math.pow(tol,2); curDrag.dragOKhLeft=hL; curDrag.dragOKhTop=hT;
    curDrag.dragOKhWidth=hW; curDrag.dragOKhHeight=hH; curDrag.dragOKtoFront=toFront;
    curDrag.dragOKdropBack=dropBack; curDrag.dragOKdropJS=dropJS;
    curDrag.dragOKeveryTime=et; curDrag.dragOKdragJS=dragJS;
    curDrag.dragOKoldZ = (NS)?curDrag.zIndex:curDrag.style.zIndex;
    curLeft= (NS)?curDrag.left:curDrag.style.pixelLeft; curDrag.dragOKstartL = curLeft;
    curTop = (NS)?curDrag.top:curDrag.style.pixelTop; curDrag.dragOKstartT = curTop;
    curDrag.dragOKbL=(cL<0)?null:curLeft-cL; curDrag.dragOKbT=(cU<0)?null:curTop -cU;
    curDrag.dragOKbR=(cR<0)?null:curLeft+cR; curDrag.dragOKbB=(cD<0)?null:curTop +cD;
    curDrag.dragOKLEFTRIGHT=0; curDrag.dragOKUPDOWN=0; curDrag.dragOKSNAPPED=false; //use in your JS!
    document.onmousedown = dragLayer; document.onmouseup = dragLayer;
    if (NS) document.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  } else {
    var theEvent = ((NS)?objName.type:event.type);
    if (theEvent == 'mousedown') {
      var mouseX = (NS)?objName.pageX : event.clientX + document.body.scrollLeft;
      var mouseY = (NS)?objName.pageY : event.clientY + document.body.scrollTop;
      var maxDragZ=null; document.dragOKmaxZ = 0;
      for (i=0; i<document.allLayers.length; i++) { aLayer = document.allLayers[i];
        var aLayerZ = (NS)?aLayer.zIndex:aLayer.style.zIndex;
        if (aLayerZ > document.dragOKmaxZ) document.dragOKmaxZ = aLayerZ;
        var isVisible = (((NS)?aLayer.visibility:aLayer.style.visibility).indexOf('hid') == -1);
        if (aLayer.dragOK != null && isVisible) with (aLayer) {
          var parentL=0; var parentT=0;
          if (!NS) { parentLayer = aLayer.parentElement;
            while (parentLayer != null && parentLayer.style.position) {
              parentL += parentLayer.offsetLeft; parentT += parentLayer.offsetTop;
              parentLayer = parentLayer.parentElement; } }
          var tmpX=mouseX-(((NS)?pageX:style.pixelLeft+parentL)+dragOKhLeft);
          var tmpY=mouseY-(((NS)?pageY:style.pixelTop +parentT)+dragOKhTop);
          var tmpW = dragOKhWidth;  if (tmpW <= 0) tmpW += ((NS)?clip.width :offsetWidth);
          var tmpH = dragOKhHeight; if (tmpH <= 0) tmpH += ((NS)?clip.height:offsetHeight);
          if ((0 <= tmpX && tmpX < tmpW && 0 <= tmpY && tmpY < tmpH) && (maxDragZ == null
              || maxDragZ <= aLayerZ)) { curDrag = aLayer; maxDragZ = aLayerZ; } } }
      if (curDrag) {
        document.onmousemove = dragLayer; if (NS) document.captureEvents(Event.MOUSEMOVE);
        curLeft = (NS)?curDrag.left:curDrag.style.pixelLeft;
        curTop = (NS)?curDrag.top:curDrag.style.pixelTop;
        dragOKoldX = mouseX - curLeft; dragOKoldY = mouseY - curTop;
        document.dragOKcurDrag = curDrag;  curDrag.dragOKSNAPPED=false;
        if(curDrag.dragOKtoFront) {
          eval('curDrag.'+((NS)?'':'style.')+'zIndex=document.dragOKmaxZ+1');
          if (!curDrag.dragOKdropBack) document.dragOKmaxZ++; }
        retVal = false; if(!NS) event.returnValue = false;
    } } else if (theEvent == 'mousemove') {
      if (document.dragOKcurDrag) with (document.dragOKcurDrag) {
        var mouseX = (NS)?objName.pageX : event.clientX + document.body.scrollLeft;
        var mouseY = (NS)?objName.pageY : event.clientY + document.body.scrollTop;
        newLeft = mouseX-dragOKoldX; newTop  = mouseY-dragOKoldY;
        if (dragOKbL!=null) newLeft = Math.max(newLeft,dragOKbL);
        if (dragOKbR!=null) newLeft = Math.min(newLeft,dragOKbR);
        if (dragOKbT!=null) newTop  = Math.max(newTop ,dragOKbT);
        if (dragOKbB!=null) newTop  = Math.min(newTop ,dragOKbB);
        dragOKLEFTRIGHT = newLeft-dragOKstartL; dragOKUPDOWN = newTop-dragOKstartT;
        if (NS) {left = newLeft; top = newTop;}
        else {style.pixelLeft = newLeft; style.pixelTop = newTop;}
        if (dragOKdragJS) eval(dragOKdragJS);
        retVal = false; if(!NS) event.returnValue = false;
    } } else if (theEvent == 'mouseup') {
      document.onmousemove = null;
      if (NS) document.releaseEvents(Event.MOUSEMOVE);
      if (NS) document.captureEvents(Event.MOUSEDOWN); //for mac NS
      if (document.dragOKcurDrag) with (document.dragOKcurDrag) {
        if (typeof dragOKtargL =='number' && typeof dragOKtargT == 'number' &&
            (Math.pow(dragOKtargL-((NS)?left:style.pixelLeft),2)+
             Math.pow(dragOKtargT-((NS)?top:style.pixelTop),2))<=dragOKtol) {
          if (NS) {left = dragOKtargL; top = dragOKtargT;}
          else {style.pixelLeft = dragOKtargL; style.pixelTop = dragOKtargT;}
          dragOKSNAPPED = true; dragOKLEFTRIGHT = dragOKstartL-dragOKtargL; dragOKUPDOWN = dragOKstartT-dragOKtargT; }
        if (dragOKeveryTime || dragOKSNAPPED) eval(dragOKdropJS);
        if(dragOKdropBack) {if (NS) zIndex = dragOKoldZ; else style.zIndex = dragOKoldZ;}
        retVal = false; if(!NS) event.returnValue = false; }
      document.dragOKcurDrag = null;
    }
    if (NS) document.routeEvent(objName);
  } return retVal;
}