i am using javascript to display a pop up div layer. i am using a link to activate the div layer. the link directs to the javascript function ShowMe(), below is the javascript I have. As you can see, the layer name is hard coded in write now, but I want to pass it to the javascript, possibly by ShowMe('layer1'). However the part that assigns the name runs on mousedown before ShowMe() runs. I cant think of a way to arrange this so the name can be passed in dynamically, any suggestions
isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
DoIt=false;
function ddInit(e)
{
TWD=isIE ? "BODY" : "HTML";
TWD1=isIE ? document.all.theLayer : document.getElementById("theLayer");
TWD2=isIE ? event.srcElement : e.target;
while (TWD2.id!="titleBar"&&TWD2.tagName!=TWD)
{
TWD2=isIE ? TWD2.parentElement : TWD2.parentNode;
}
if (TWD2.id=="titleBar")
{
offsetx=isIE ? event.clientX : e.clientX;
offsety=isIE ? event.clientY : e.clientY;
nowX=parseInt(TWD1.style.left);
nowY=parseInt(TWD1.style.top);
ddEnabled=true;
document.onmousemove=dd;
}
}
function dd(e)
{
if (!ddEnabled) return;
TWD1.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx;
TWD1.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
return false;
}
function ddN4(TWD3)
{
if (!isN4) return;
N4=eval(TWD3);
N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
N4.onmousedown=function(e)
{
N4.captureEvents(Event.MOUSEMOVE);
N4x=e.x;
N4y=e.y;
}
N4.onmousemove=function(e)
{
if (DoIt)
{
N4.moveBy(e.x-N4x,e.y-N4y);
return false;
}
}
N4.onmouseup=function()
{
N4.releaseEvents(Event.MOUSEMOVE);
}
}
function hideMe()
{
ddInit;
if (isIE||isNN) TWD1.style.visibility="hidden";
else if (isN4) document.theLayer.visibility="hide";
}
function showMe(layerName)
{
if (isIE||isNN) TWD1.style.visibility="visible";
else if (isN4) document.theLayer.visibility="show";
}
document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");
isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
DoIt=false;
function ddInit(e)
{
TWD=isIE ? "BODY" : "HTML";
TWD1=isIE ? document.all.theLayer : document.getElementById("theLayer");
TWD2=isIE ? event.srcElement : e.target;
while (TWD2.id!="titleBar"&&TWD2.tagName!=TWD)
{
TWD2=isIE ? TWD2.parentElement : TWD2.parentNode;
}
if (TWD2.id=="titleBar")
{
offsetx=isIE ? event.clientX : e.clientX;
offsety=isIE ? event.clientY : e.clientY;
nowX=parseInt(TWD1.style.left);
nowY=parseInt(TWD1.style.top);
ddEnabled=true;
document.onmousemove=dd;
}
}
function dd(e)
{
if (!ddEnabled) return;
TWD1.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx;
TWD1.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
return false;
}
function ddN4(TWD3)
{
if (!isN4) return;
N4=eval(TWD3);
N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
N4.onmousedown=function(e)
{
N4.captureEvents(Event.MOUSEMOVE);
N4x=e.x;
N4y=e.y;
}
N4.onmousemove=function(e)
{
if (DoIt)
{
N4.moveBy(e.x-N4x,e.y-N4y);
return false;
}
}
N4.onmouseup=function()
{
N4.releaseEvents(Event.MOUSEMOVE);
}
}
function hideMe()
{
ddInit;
if (isIE||isNN) TWD1.style.visibility="hidden";
else if (isN4) document.theLayer.visibility="hide";
}
function showMe(layerName)
{
if (isIE||isNN) TWD1.style.visibility="visible";
else if (isN4) document.theLayer.visibility="show";
}
document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");