(function(jquery) { $.fn.sxdrcnotice = function(settings) { var defaults = { background: '', title: '', titlecolor: '', titlebgcolor: '', linkcolor: '', linkhovercolor: '', fonttextsize: 16, isbold: false, border: 'none', width: '100%', autoplay: true, timer: 3000, modulid: 'sxdrcnotice', effect: 'fade' //or slide }; var settings = $.extend(defaults, settings); return this.each(function() { settings.modulid = "#" + $(this).attr("id"); var timername = settings.modulid; var activenewsid = 1; if (settings.isbold == true) fontw = 'bold'; else fontw = 'normal'; if (settings.effect == 'slide') $(settings.modulid + ' ul li').css({ 'display': 'block' }); else $(settings.modulid + ' ul li').css({ 'display': 'none' }); $(settings.modulid).css({ 'width': settings.width, 'background': settings.background, 'border': settings.border, 'font-size': settings.fonttextsize }); $(settings.modulid + ' ul li a').css({ 'color': settings.linkcolor, 'font-weight': fontw, 'height': parseint(settings.fonttextsize) + 6 }); $(settings.modulid + ' ul li').eq(parseint(activenewsid - 1)).css({ 'display': 'block' }); // links hover events ...... $(settings.modulid + ' ul li a').hover(function() { $(this).css({ 'color': settings.linkhovercolor }); }, function() { $(this).css({ 'color': settings.linkcolor }); }); // arrows click events ...... $(settings.modulid + ' .notice-box_arrows span').click(function(e) { if ($(this).attr('class') == "notice-box_arrows-left") bnautoplay('prev'); else bnautoplay('next'); }); // timer events ............... if (settings.autoplay == true) { timername = setinterval(function() { bnautoplay('next') }, settings.timer); $(settings.modulid).hover(function() { clearinterval(timername); }, function() { timername = setinterval(function() { bnautoplay('next') }, settings.timer); }); } else { clearinterval(timername); } //timer and click events function ........... function bnautoplay(pos) { if (pos == "next") { if ($(settings.modulid + ' ul li').length > activenewsid) activenewsid++; else activenewsid = 1; } else { if (activenewsid - 2 == -1) activenewsid = $(settings.modulid + ' ul li').length; else activenewsid = activenewsid - 1; } if (settings.effect == 'fade') { $(settings.modulid + ' ul li').css({ 'display': 'none' }); $(settings.modulid + ' ul li').eq(parseint(activenewsid - 1)).fadein(); } else { $(settings.modulid + ' ul').animate({ 'margintop': -($(settings.modulid + ' ul li').height() + 0) * (activenewsid - 1) }); } } }); }; })(jquery);