home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2004 August
/
Chip_2004-08_cd1.bin
/
program
/
delphi
/
adresy
/
ee_soubory
/
Utils.js
< prev
Wrap
Text File
|
2004-05-11
|
6KB
|
256 lines
var
Menus, // Textdescription of all menus.
themenu, // Current menu on screen.
themenuStyle, // The style member of the current menu.
thestring; // Helper for browser detection.
Images = new Array();
//-------------------------------------------------------------------------------------------------
function PreloadImages()
{
for (i = 0; i < PreloadImages.arguments.length;i++)
{
Images[i] = new Image();
Images[i].src = PreloadImages.arguments[i];
};
};
//-------------------------------------------------------------------------------------------------
function GetObject(Name)
{
if (is.DOM1 || is.opera6)
{
this.obj = document.getElementById(Name);
this.style = this.obj.style;
}
else
if (is.ie)
{
this.obj = document.all[Name];
this.style = this.obj.style;
}
else
if (is.nav)
{
this.obj = GetObjectNetscape4(document, Name);
this.style = this.obj;
};
};
//-------------------------------------------------------------------------------------------------
function GetObjectNetscape4(obj, Name)
{
var
x = obj.layers;
var
thereturn;
for (var i = 0; i < x.length; i++)
{
if (x[i].id == Name)
thereturn = x[i];
else
if (x[i].layers.length)
{
var
tmp = getObjNN4(x[i],name);
if (tmp)
thereturn = tmp;
}
}
return thereturn;
};
//-------------------------------------------------------------------------------------------------
// fade-in/out effect
var
FadeObject;
var
DoMenuFade = false;
//-------------------------------------------------------------------------------------------------
function InitFade(which)
{
if (which.style.MozOpacity > 0)
which.style.MozOpacity = 0
else
if (which.filters && which.filters[0].opacity > 0)
which.filters[0].opacity = 0;
};
//-------------------------------------------------------------------------------------------------
function FadeIn(which)
{
if (window.highlighting)
clearInterval(highlighting);
if (FadeObject)
{
InitFade(FadeObject);
FadeObject.style.visibility = "hidden";
};
InitFade(which);
which.style.visibility = "visible";
FadeObject = which;
highlighting = setInterval("FadeStep(FadeObject, 20)", 50)
};
//-------------------------------------------------------------------------------------------------
function FadeOut(which)
{
if (window.highlighting)
clearInterval(highlighting);
FadeObject = which;
highlighting = setInterval("FadeStep(FadeObject, -20)", 50)
};
//-------------------------------------------------------------------------------------------------
function FadeStep(which, step)
{
if (step > 0)
{
if (which.style.MozOpacity < 1)
which.style.MozOpacity = parseFloat(which.style.MozOpacity) + step / 100
else
if (which.filters && which.filters[0].opacity < 100)
which.filters[0].opacity += step
else
if (window.highlighting)
clearInterval(highlighting);
}
else
{
if (which.style.MozOpacity > 0)
which.style.MozOpacity = parseFloat(which.style.MozOpacity) + step / 100
else
if (which.filters && which.filters[0].opacity > 0)
which.filters[0].opacity += step
else
if (window.highlighting)
{
clearInterval(highlighting);
which.style.visibility = "hidden";
FadeObject = null;
};
};
};
//-------------------------------------------------------------------------------------------------
function DelayHideMenu()
{
ClearShowMenu();
delayhide = setTimeout("hidemenu()", 500)
};
//-------------------------------------------------------------------------------------------------
function clearhidemenu()
{
if (window.delayhide)
clearTimeout(delayhide)
};
//-------------------------------------------------------------------------------------------------
function hidemenu()
{
if (window.themenu)
{
if ((is.ie || is.nav6up || is.opera) && DoMenuFade)
FadeOut(window.themenu)
else
if (is.DOM1)
themenuStyle.visibility = "hidden"
else
themenu.visibility = "hide";
window.themenu = null;
};
};
//-------------------------------------------------------------------------------------------------
function ClearShowMenu()
{
if (window.delayshow)
clearTimeout(delayshow)
};
//-------------------------------------------------------------------------------------------------
function DoShowMenu()
{
if ((is.nav6up || is.ie || is.opera) && DoMenuFade)
FadeIn(themenu)
else
{
if (themenu.style.MozOpacity)
themenu.style.MozOpacity = 1
else
if (themenu.filters && themenu.filters[0].opacity)
themenu.filters[0].opacity = 100;
if (is.DOM1)
themenuStyle.visibility = "visible"
else
themenu.visibility = "show";
};
};
//-------------------------------------------------------------------------------------------------
function dropit(e, whichone, x, y)
{
var
NewMenu,
WasVisible;
WasVisible = (window.themenu);
clearhidemenu();
NewMenu = is.DOM1 || is.opera6 ? document.getElementById(whichone) : eval(whichone);
if (WasVisible && (NewMenu == window.themenu))
return;
hidemenu();
themenu = NewMenu;
themenuStyle = is.DOM1 || is.opera6 ? themenu.style : themenu;
themenuoffsetX = (is.ie) ? document.body.scrollLeft : 0;
themenuoffsetY = (is.ie) ? document.body.scrollTop : 0;
if (is.opera || is.ie)
{
themenuStyle.left = x;
themenuStyle.top = (is.opera) ? y + 8 : y;
}
else
{
themenuStyle.left = (e.pageX - e.layerX) + x + 'px';
themenuStyle.top = e.pageY - e.layerY + y + 'px';
};
if (WasVisible)
DoShowMenu()
else
delayshow = setTimeout("DoShowMenu()", 200);
return true;
};
//-------------------------------------------------------------------------------------------------