$.fn.extend({ allenmenu: function() { $(this).children('ul').children('li').hover( function() { if(!$(this).children('ul').hasclass('focus')) { $(this).addclass('focus'); $(this).children('ul:first').stop(true, true).animate({ height:'show' }, 'fast'); } }, function() { $(this).removeclass('focus'); $(this).children('ul:first').stop(true, true).animate({ height:'hide', opacity:'hide' }, 'slow'); } ); $(this).children('ul').children('li').children('ul').hover( function() { $(this).addclass('focus'); }, function() { $(this).removeclass('focus'); } ); } }); $.fn.extend({ allenslide: function() { var ads = $(this).find('ul:first li'); var name = $(this).attr('id'); var n = ads.length; var w = ads.width(); var h = ads.height(); var clicked = false; var t = 4000; var lt = 5000; var speed = 'slow'; var curpage = 0; //$(this).children('ul:first').append($(this).find('ul:first li:first').clone()); $(this).width(w).height(h); $(this).css('overflow', 'hidden'); $(this).css('position', 'relative'); $(this).children('ul:first').width(w * (n + 1)); var pages = $('
'); for(var i = 1; i <= n; i++) { var el = $('' + i + ''); eval('el.click(function(){ clicked = true; slideto(' + i + '); return false; });'); pages.append(el); } $(this).append(pages); $('#' + name + '-page-1').parent().addclass('on'); autoslide(); /* fade version */ function slideto(page) { curpage = page; var ml = -1 * w * (page - 1); $('#' + name).find('li:eq('+(curpage-1)+')').stop(); if(page > n) { page = 1; curpage = 1; } $('#' + name).find('li').each(function() { if($(this).css("display") != "none") { //$(this).css('z-index', '2'); $(this).fadeout(speed); } }); //$('#' + name).find('li:eq('+(page-1)+')').css('z-index', '1'); $('#' + name).find('li:eq('+(page-1)+')').fadein(speed); $('#' + name).find('.slide-page > a').removeclass('on'); $('#' + name + '-page-' + curpage).addclass('on'); } /* slide version function slideto(page) { curpage = page; var ml = -1 * w * (page - 1); $('#' + name).children('ul:first').stop(); if(page > n) { curpage = 1; } else if(page == 2 && !clicked) { $('#' + name).children('ul:first').css('margin-left', '0px'); } $('#' + name).children('ul:first').animate({ marginleft: ml }, speed); $('#' + name).find('.slide-page > a').removeclass('on'); $('#' + name + '-page-' + curpage).addclass('on'); } */ function autoslide() { var tp = curpage; if(!clicked) { slideto(tp + 1); eval('settimeout(function() { autoslide(); }, ' + t + ');'); } else { clicked = false; eval('settimeout(function() { autoslide(); }, ' + lt + ');'); } } } });