(function($) { // set cookies for iphone site $(function() { $("a#regular-site-link").click(function() { setCookie("showIphone", "no"); }); $("a#iphone-link").click(function() { setCookie("showIphone", "yes"); }); }); //// // Apply events to this object $.fn.applyEvents = function(events, options) { return $(this).each(function() { var self = this; for (e in events) { $.each(events[e], function() { $(self).bind(e, this); }); } }); }; //// // News ticker $.fn.ticker = function(options) { return this.each(function() { options = $.extend({ delay: 7000, events: $.fn.ticker.baseEvents, container: "ul", item: "li", buttonContainer: null }, options); var items = $(options.container, this); $(this).data({ container: items, width: items.width(), size: $(options.item, items).size(), current: 0 }); // setup $(this) .applyEvents(options.events, options) .trigger("ticker:setup", options); }); }; $.fn.ticker.baseEvents = { // initial setup "ticker:setup": [ // set the size of the container function(e, options) { $(this).data("container").width( $(this).data("width") * $(this).data("size") ); return false; }, // create the prev/next buttons function(e, options) { var container = options.buttonContainer == null ? $(this) : $(options.buttonContainer, this); container.append( $('