var banner_images = [ '/images/banners/1.png', '/images/banners/2.png', '/images/banners/3.png', '/images/banners/4.png' ]; var banner_text = [ 'Non fault taxi cab accident management services', 'Taxi cab replacement and repair', 'Accident management for licensed cabs and hire vehicles', 'Specialist taxi cab replacement vehicle and legal expenses cover', ]; var slide = Math.floor(Math.random() * banner_images.length); var page = window.location.pathname.substring(window.location.pathname.lastIndexOf('/') + 1); if (page == "") page = "Default.aspx"; $(document).ready(function() { $('#menu ul li').not('#menu ul li ul.dropdown li') .append('
') .hover( function() { fadeMenu(this, 'in'); } , function() { fadeMenu(this, 'out'); } ); $('#menu ul').find('li').each(function() { if (currentPage($(this).find('a').attr('href'))) $(this).css('font-weight', 'bold'); }); $('ul.dropdown').find('li').each(function() { if (currentPage($(this).find('a').attr('href'))) $(this).parent().parent().find('a:first').css('font-weight', 'bold'); }); $('#banner p').text(banner_text[slide]).fadeIn('fast'); $('#banner img') .attr('src', banner_images[slide]) .attr('alt', banner_text[slide]) .fadeIn('fast'); $('img').each(function() { $(this).attr('title', $(this).attr('alt')); }); }); $(function() { setInterval("slideshow()", 10000); }); function fadeMenu(what, type) { dropdown = $(what).children('ul'); if (type == 'in') { $(what).css('font-weight', 'bold'); if (dropdown.html() != null) { $(what).children('div').show(); dropdown.show(); } } else if (type == 'out') { if (!currentPage($(what).find('a').attr('href'))) $(what).css('font-weight', 'normal'); if (dropdown.html() != null) { $(what).children('div').hide(); dropdown.hide(); } } } function currentPage(checkPage) { return checkPage.substring(checkPage.lastIndexOf('/') + 1) == getMenu(); } function getMenu() { switch (page) { /*case 'why.aspx': case 'rehabilitation.aspx': return 'about.aspx';*/ default: return page; } } function slideshow() { $('#banner p').animate({top: '-=40px'}, 'slow', function() { var banner = $(this).parents('#banner'); var curr = banner.find('.current'); var next = banner.find('.next'); if (!curr.attr('class')) { curr = banner.find('img').addClass('current'); banner.prepend(''); next = banner.find('img:first').addClass('next'); } slide++; if (slide >= banner_images.length) slide = 0; $(this).hide().text(banner_text[slide]); next.attr('src', banner_images[slide]) .attr('alt', banner_text[slide]) .attr('title', banner_text[slide]); next.fadeIn('slow') .removeClass('next') .addClass('current'); curr.fadeOut('slow', function() { $(this).parents('#banner').find('p').show().animate({top: '+=40px'}, 'slow'); }) .removeClass('current') .addClass('next'); }); }