/* SpryMenuBar.js - Revision: Spry Preview Release 1.4 */
// Copyright (c) 2006. Adobe Systems Incorporated.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of Adobe Systems Incorporated nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
/*******************************************************************************
SpryMenuBar.js
This file handles the JavaScript for Spry Menu Bar. You should have no need
to edit this file. Some highlights of the MenuBar object is that timers are
used to keep submenus from showing up until the user has hovered over the parent
menu item for some time, as well as a timer for when they leave a submenu to keep
showing that submenu until the timer fires.
*******************************************************************************/
var Spry;
if(!Spry)
{
Spry = {};
}
if(!Spry.Widget)
{
Spry.Widget = {};
}
// Constructor for Menu Bar
// element should be an ID of an unordered list (
tag)
// preloadImage1 and preloadImage2 are images for the rollover state of a menu
Spry.Widget.MenuBar = function(element, opts)
{
this.init(element, opts);
};
Spry.Widget.MenuBar.prototype.init = function(element, opts)
{
this.element = this.getElement(element);
// represents the current (sub)menu we are operating on
this.currMenu = null;
var isie = (typeof document.all != 'undefined' && typeof window.opera == 'undefined' && navigator.vendor != 'KDE');
if(typeof document.getElementById == 'undefined' || (navigator.vendor == 'Apple Computer, Inc.' && typeof window.XMLHttpRequest == 'undefined') || (isie && typeof document.uniqueID == 'undefined'))
{
// bail on older unsupported browsers
return;
}
// load hover images now
if(opts)
{
for(var k in opts)
{
var rollover = new Image;
rollover.src = opts[k];
}
}
if(this.element)
{
this.currMenu = this.element;
var items = this.element.getElementsByTagName('li');
for(var i=0; i 5)
layer.style.top = ((menu.parentNode.offsetTop - ((Objetos * 20) / 2 )) - 40) + 'px';
else
layer.style.top = menu.parentNode.offsetTop + 'px';
}
else
{
var ul = menu.getElementsByTagName('ul');
var el = menu.getElementsByTagName('li');
Objetos = 0;
for(i=0;i 5)
layer.style.top = ((0 - ((Objetos * 20) / 2 )) - 10) +'px';
else
layer.style.top = '0px';
}
//layer.style.top = menu.offsetTop + 'px';
//layer.style.top = '0px';
layer.style.width = menu.offsetWidth + 'px';
layer.style.height = menu.offsetHeight + 'px';
};
// removeIframeLayer for Menu Bar
// removes an IFRAME underneath a menu to reveal any form controls and ActiveX
Spry.Widget.MenuBar.prototype.removeIframeLayer = function(menu)
{
var layers = menu.parentNode.getElementsByTagName('iframe');
while(layers.length > 0)
{
layers[0].parentNode.removeChild(layers[0]);
}
};
// clearMenus for Menu Bar
// root is the top level unordered list ( tag)
Spry.Widget.MenuBar.prototype.clearMenus = function(root)
{
var menus = root.getElementsByTagName('ul');
for(var i=0; i (menu.parentNode.offsetTop + 20 + 246))
{
menu.style.top = menu.parentNode.offsetTop +'px';
}
else
{
menu.style.top = ((document.getElementById('PosicaoAlfa').style.top.replace('px','') - ObjetosHeight) - 256) +'px';
}
}
}
else
{
//Adicionado Para posicionar o menu
var ul = menu.getElementsByTagName('ul');
var el = menu.getElementsByTagName('li');
Objetos = 0;
for(i=0;i 20)
{
menu.style.top = '0px';
}
else
{
menu.style.top = ((document.getElementById('PosicaoAlfa').style.top.replace('px','') - ObjetosHeight)) +'px';
}
*/
//menu.style.top = menu.parentNode.offsetTop + 'px';
menu.style.top = '0px';
}
if(typeof document.uniqueID != "undefined")
{
/* comentado por dalton em 3-12-08
this.createIframeLayer(menu);
*/
}
}
this.addClassName(this.element, "MenuBarActive");
};
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var MouseX = 0;
var MouseY = 0;
var PageY = 0;
var PageX = 0;
function setPageCoords(){
var myPageX;
var myPageY;
if(document.documentElement.scrollLeft>=0){
myPageX=document.documentElement.scrollLeft;
myPageY=document.documentElement.scrollTop;
}else if(document.body.scrollLeft>=0){
myPageX=document.body.scrollLeft;
myPageY=document.body.scrollTop;
}else{
myPageX=window.pageXOffset;
myPageY=window.pageYOffset;
}
PageY = myPageY;
PageX = myPageX;
//myFrm.txtPageY.value=myPageY;
}
function getMouseXY(e) {
if (IE)
{ // grab the x-y pos.s if browser is IE
MouseX = event.clientX + document.body.scrollLeft
MouseY = event.clientY + document.body.scrollTop
}
else
{ // grab the x-y pos.s if browser is NS
MouseX = e.pageX
MouseY = e.pageY
}
// catch possible negative values in NS4
if (MouseX < 0){tempX = 0}
if (MouseY < 0){tempY = 0}
// show the position values in the form named Show
// in the text fields named MouseX and MouseY
//document.getElementById('mheight').value = MouseY;
BrowserSize();
return true
}
var browserX = 0;
var browserY = 0;
function BrowserSize() {
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
browserX = window.innerWidth;
browserY = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
browserX = document.documentElement.clientWidth;
browserY = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
browserX = document.body.clientWidth;
browserY = document.body.clientHeight;
}
}
// hideSubmenu for Menu Bar
// remove the proper CSS class on this menu to hide it
Spry.Widget.MenuBar.prototype.hideSubmenu = function(menu)
{
if(menu)
{
this.removeClassName(menu, "MenuBarSubmenuVisible");
if(typeof document.all != 'undefined' && typeof window.opera == 'undefined' && navigator.vendor != 'KDE')
{
menu.style.top = '';
menu.style.left = '';
}
this.removeIframeLayer(menu);
}
};
// initialize for Menu Bar
// create event listeners for the Menu Bar widget so we can properly
// show and hide submenus
Spry.Widget.MenuBar.prototype.initialize = function(listitem, element, isie)
{
var opentime, closetime;
var link = listitem.getElementsByTagName('a')[0];
var submenus = listitem.getElementsByTagName('ul');
var menu = (submenus.length > 0 ? submenus[0] : null);
var hasSubMenu = false;
if(menu)
{
this.addClassName(link, "MenuBarItemSubmenu");
hasSubMenu = true;
}
if(!isie)
{
// define a simple function that comes standard in IE to determine
// if a node is within another node
listitem.contains = function(testNode)
{
// this refers to the list item
if(testNode == null)
{
return false;
}
if(testNode == this)
{
return true;
}
else
{
return this.contains(testNode.parentNode);
}
};
}
// need to save this for scope further down
var self = this;
this.addEventListener(listitem, 'mouseover', function(e)
{
if(self.bubbledTextEvent())
{
// ignore bubbled text events
return;
}
clearTimeout(closetime);
if(self.currMenu == listitem)
{
self.currMenu = null;
}
// show menu highlighting
self.addClassName(link, hasSubMenu ? "MenuBarItemSubmenuHover" : "MenuBarItemHover");
if(menu && !self.hasClassName(menu, "MenuBarSubmenuVisible"))
{
opentime = window.setTimeout(function(){self.showSubmenu(menu);}, 250);
}
}, false);
this.addEventListener(listitem, 'mouseout', function(e)
{
if(self.bubbledTextEvent())
{
// ignore bubbled text events
return;
}
var related = (typeof e.relatedTarget != 'undefined' ? e.relatedTarget : e.toElement);
if(!listitem.contains(related))
{
clearTimeout(opentime);
self.currMenu = listitem;
// remove menu highlighting
self.removeClassName(link, hasSubMenu ? "MenuBarItemSubmenuHover" : "MenuBarItemHover");
if(menu)
{
closetime = window.setTimeout(function(){self.hideSubmenu(menu);}, 600);
}
}
}, false);
};