var _watchMenu = function() { timeTilFire--; if ( timeTilFire > 0 ) return; timeTilFire = timeTilFireStart; //hide all open menus that shouldn't be open... for ( i in openMenus ) { if ( openMenus[i] && !overMenus[i] ) closeMenu(i); } }; var closeMenu = function(id) { if ( animation == 1 ) $('li[menunum='+id+'] > ul').slideUp('fast'); else $('li[menunum='+id+'] > ul').fadeOut('fast'); openMenus[id] = false; }; var showMenu = function(id) { //hide all open menus that shouldn't be open... for ( i in openMenus ) { if ( openMenus[i] && !overMenus[i] ) closeMenu(i); } if ( animation == 1 ) { position = $('li[menunum='+id+'] > ul').parent('li:eq(0)').offset(); pheight = $('li[menunum='+id+'] > ul').parent('li:eq(0)').height(); $('li[menunum='+id+'] > ul').css({ position: 'absolute', left: '0px', top: pheight+'px' }); $('li[menunum='+id+'] > ul').slideDown('fast'); } else { $('li[menunum='+id+'] > ul').fadeIn('fast'); } openMenus[id] = true; timeTilFire = timeTilFireStart; }; var menuTimeout = 10; var timeTilFireStart = 100; var timeTilFire = 100; var animation = 0; var openMenus = [ ]; var overMenus = [ ]; var lastMouseOverMenu = null; var mouseInMenu = null; var inmenubar = false; function wtShowMenu() { if(lastMouseOverMenu == mouseInMenu && mouseInMenu != null) { $('> ul', mouseInMenu).show(); inmenubar = true; } else { inmenubar = false; } } function setupFlyouts() { $('div#navigation ul').hover(function() {}, function() { inmenubar = false; } ); $('div#navigation ul.menu li').hover(function(){ mouseInMenu = this; lastMouseOverMenu = this; if(inmenubar) { wtShowMenu(); } else { setTimeout("wtShowMenu()", 300); } // $('> ul',this).show(); }, function(){ mouseInMenu = null; $('> ul',this).hide(); }); } function _setupFlyouts() { //add the classes to show that there are submenus //assign an identifier to each sub menu $('div#navigation ul.menu li').attr('menunum','-2'); $('div#navigation ul.menu ul').hide(); $('div#navigation ul.menu ul').each(function(i){ var id = i+1; $(this).parent().addClass('parent'); $(this).parent().attr('menunum',id); }); if ( $('link[href=styles/menu.top.css]').length > 0 ) animation = 1; setInterval(_watchMenu,menuTimeout); $('div#navigation ul.menu li[menunum]').hover(function(){ id = $(this).attr('menunum'); overMenus[id] = id; setTimeout(function(){ showMenu(id); },100); },function(){ timeTilFire = timeTilFireStart; id = $(this).attr('menunum'); overMenus[id] = false; }); } /* small parts of this gal code are loosely based on Thickbox */ var gallength = 0; function setupGallery() { gallength = $('div.gallery a').length; if ( gallength > 0 ) gallength--; $('div.gallery a').each(function(i){ $(this).attr('target',''); //get rid of target if it is set... $(this).attr('galindex',i); $(this).click(function(){ galleryShowImage(i); return false; //prevent browser going to link }); }); } /* thanks, Thickbox =) */ function tb_getPageSize() { var de = document.documentElement; var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight; arrayPageSize = [w,h]; return arrayPageSize; } function galleryShowImage(i,noappend) { href = $('div.gallery a:eq('+i+')').attr('href'); caption = $('div.gallery a:eq('+i+') img').attr('alt'); if ( !caption ) caption = $('div.gallery a:eq('+i+') strong').text(); if ( !noappend ) $('body').append('
'); $('div#galOverlay').css({backgroundImage: 'url(behaviour/loader.gif)'}); img = new Image(); img.onload = function() { img.onload = null; var pagesize = tb_getPageSize(); var x = pagesize[0] - 150; var y = pagesize[1] - 150; var imageWidth = img.width; var imageHeight = img.height; if (imageWidth > x) { imageHeight = imageHeight * (x / imageWidth); imageWidth = x; if (imageHeight > y) { imageWidth = imageWidth * (y / imageHeight); imageHeight = y; } } else if (imageHeight > y) { imageWidth = imageWidth * (y / imageHeight); imageHeight = y; if (imageWidth > x) { imageHeight = imageHeight * (x / imageWidth); imageWidth = x; } } galWIDTH = imageWidth + 30; galHEIGHT = imageHeight + 60; document.onkeydown = function(e) { if (e == null) { // ie keycode = event.keyCode; } else { // mozilla keycode = e.which; } if(keycode == 27) { // close galleryHideImage(); } }; _scale(); $(window).resize(_scale); $('div#galImage').append(''); $('div#galImage').append('