// overly simplistic test for IE
isIE = (document.all ? true : false);
// both IE5 and NS6 are DOM-compliant
isDOM = (document.getElementById ? true : false);
// get the true offset of anything on NS4, IE4/5 & NS6, even if it's in a table!
function getAbsX(elt) { return (elt.x) ? elt.x : getAbsPos(elt,"Left"); }
function getAbsY(elt) { return (elt.y) ? elt.y : getAbsPos(elt,"Top"); }
function getAbsPos(elt,which) {
iPos = 0;
while (elt != null) {
iPos += elt["offset" + which];
elt = elt.offsetParent;
}
return iPos;
}
function getDivStyle(divname) {
var style;
if (isDOM) { style = document.getElementById(divname).style; }
else { style = isIE ? document.all[divname].style
: document.layers[divname]; } // NS4
return style;
}
function hideElement(divname) {
getDivStyle(divname).visibility = 'hidden';
}
// annoying detail: IE and NS6 store elt.top and elt.left as strings.
function moveBy(elt,deltaX,deltaY) {
elt.left = parseInt(elt.left) + deltaX;
elt.top = parseInt(elt.top) + deltaY;
}
function toggleVisible(divname) {
divstyle = getDivStyle(divname);
if (divstyle.visibility == 'visible' || divstyle.visibility == 'show') {
divstyle.visibility = 'hidden';
} else {
//fixPosition(divname);
divstyle.visibility = 'visible';
}
}
function setPosition(elt,positionername,xOffset,yOffset) {
var positioner;
if (isIE) {
positioner = document.all[positionername];
} else {
if (isDOM) {
positioner = document.getElementById(positionername);
} else {
// not IE, not DOM (probably NS4)
// if the positioner is inside a netscape4 layer this will *not* find it.
// I should write a finder function which will recurse through all layers
// until it finds the named image...
positioner = document.images[positionername];
}
}
elt.position = "absolute";
var tmp;
if (typeof xOffset != "undefined" && xOffset != null) {
tmp = getAbsX(positioner) + xOffset;
elt.left = tmp + "px";
} else {
elt.left = getAbsX(positioner);
}
if (typeof yOffset != "undefined" && yOffset != null) {
tmp = setY(positionername) + yOffset;
elt.top = tmp + "px";
} else {
elt.top = setY(positionername) + "px";
}
}
// fixPosition() attaches the element named eltname
// to an image named eltname+'Pos'
//
function fixPosition(divname,xOffset,yOffset) {
divstyle = getDivStyle(divname);
positionerImgName = divname + 'Pos';
setPosition(divstyle,positionerImgName,xOffset,yOffset);
}
function toggleDatePicker(eltName,formElt, xOffset, yOffset) {
//alert("tdp.eltName: " + eltName);
var x = formElt.indexOf('.');
var formName = formElt.substring(0,x);
//alert("tdp.formName: " + formName);
var formEltName = formElt.substring(x+1);
//alert("tdp.formEltName: " + formEltName);
fixPosition(eltName, xOffset, yOffset);
newCalendar(eltName,document.getElementById(formEltName), true);
toggleVisible(eltName);
}
// fixPositions() puts everything back in the right place after a resize.
//function fixPositions()
//{
// add a fixPosition call here for every element
// you think might get stranded in a resize/reflow.
// fixPosition('daysOfMonth');
// fixPosition('daysOfMonth2');
//} 