101 lines
2.1 KiB
JavaScript
101 lines
2.1 KiB
JavaScript
|
// Determine browser type (Netscape 6 or IE 5.5).
|
||
|
|
||
|
var isIE = ((navigator.userAgent.indexOf("MSIE") > 0)
|
||
|
||(navigator.userAgent.indexOf("Opera") > 0)) ? 1 : 0;
|
||
|
var isNS6 = (navigator.userAgent.indexOf("Gecko") > 0) ? 1 : 0;
|
||
|
var isNS4 = ((navigator.appName.indexOf("Netscape")==0)
|
||
|
&&(navigator.userAgent.indexOf("Mozilla/4") == 0)) ? 1 : 0;
|
||
|
|
||
|
|
||
|
//if (isNS4==0)
|
||
|
// alert("This skin has been designed for Netscape 4.x.");
|
||
|
|
||
|
|
||
|
function getPageOffsetLeft(el) {
|
||
|
|
||
|
// Return the true x coordinate of an element relative to the page.
|
||
|
|
||
|
return el.offsetLeft + (el.offsetParent ? getPageOffsetLeft(el.offsetParent) : 0);
|
||
|
}
|
||
|
|
||
|
function getPageOffsetTop(el) {
|
||
|
|
||
|
// Return the true y coordinate of an element relative to the page.
|
||
|
|
||
|
return el.offsetTop + (el.offsetParent ? getPageOffsetTop(el.offsetParent) : 0);
|
||
|
}
|
||
|
|
||
|
function buttonClick(button, menuName) {
|
||
|
|
||
|
if (!button.menu)
|
||
|
{
|
||
|
if (isNS4)
|
||
|
button.menu = document.layers[menuName];
|
||
|
else
|
||
|
button.menu = document.getElementById(menuName);
|
||
|
}
|
||
|
|
||
|
// Toggle the button's state.
|
||
|
if (button.menu.isDepressed)
|
||
|
resetButton(button);
|
||
|
else
|
||
|
depressButton(button);
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
|
||
|
function depressButton(button) {
|
||
|
|
||
|
if (isNS4)
|
||
|
{
|
||
|
button.menu.left = (window.innerWidth-100);
|
||
|
button.menu.top = 0;
|
||
|
button.menu.visibility = "show";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
// Position the associated drop down menu under the button and
|
||
|
// show it. Note that the position must be adjusted according to
|
||
|
// browser, styling and positioning.
|
||
|
|
||
|
x = getPageOffsetLeft(button);
|
||
|
y = getPageOffsetTop(button) + button.offsetHeight;
|
||
|
if (isIE) {
|
||
|
x -= 15;
|
||
|
y += 2;
|
||
|
}
|
||
|
if (isNS6) {
|
||
|
x--;
|
||
|
y--;
|
||
|
}
|
||
|
button.menu.style.left = x + "px";
|
||
|
button.menu.style.top = y + "px";
|
||
|
button.menu.style.visibility = "visible";
|
||
|
}
|
||
|
// Set button state and let the world know which button is
|
||
|
// active.
|
||
|
|
||
|
button.menu.isDepressed = true;
|
||
|
}
|
||
|
|
||
|
function resetButton(button) {
|
||
|
|
||
|
if (button.menu)
|
||
|
{
|
||
|
if (isNS4)
|
||
|
button.menu.visibility = "hide";
|
||
|
else
|
||
|
// button.menu.style.display = "none";
|
||
|
button.menu.style.visibility = "hidden";
|
||
|
}
|
||
|
|
||
|
// Set button state and clear active menu global.
|
||
|
button.menu.isDepressed = false;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|