PageSourceSearch

https://www.sanangelorodeo.com/Events/JS/widgets/SponsorScrollingCarousel.js?sv=8.6.3

js sanangelorodeo.com collected 2026-10-02 07:18:48 UTC 27,946 bytes, 628 lines download raw bytes

1/*Sponsor Scrolling Carousel*/
2
3
4
5
6(function ($) {
7
8    //Data service for the widget
9    function sponsorDataService() {
10
11        this.getSponsors = function (servicePath, widgetModuleItemID, successCallback, errorCallback) {
12            $.ajax({
13                type: "POST",
14                url: servicePath,
15                data: "{'widgetModuleItemID':" + widgetModuleItemID + "}",
16                contentType: "application/json; charset=utf-8",
17                dataType: "json",
18                success: successCallback,
19                error: errorCallback
20            });
21        };
22    };
23
24    //Global variable for the widget function
25    var isScrollingLeft = false;
26    var widgetModuleItemID = 0;
27    var widgetData = null;
28    var widgetContainer = null;
29
30    var majorSponsor = null;
31    var initialized = false;
32    var widgetHeight = 0;
33    var carouselHeight = 0;
34
35    var imageContainer = null;
36    var carouselContainer = null;
37    var majorSponsorContainer = null;
38    var majorSponsorTitleContainer = null;
39    var sponsorsTitleContainer = null;
40    var carouselWidth = 0;
41
42
43    var currentDirection = 1; //default 1
44    var movementIncrement = 2; //default 2
45    var timeIncrement = 30; //default 30
46
47    var currentDisplayedImageIndexes = new Array;
48    var customWidth = null;
49    var majorSponsorWidth = null;
50    var majorSponsorHeight = null;
51    var sponsorWidth = null;
52    var sponsorHeight = null;
53    var verticalCentering = false;
54    var verticalCenteringValues = new Array();
55    var runningStatic = false;
56    var sponsorsLoaded = function(){};
57    var sponsorsInitialized = function(){};
58    var bw = false;
59    var randomizeIndex = false;
60    var imageQuality = 80;
61    var staticSponsorTimer = 0;
62    var majorSponsorRotationSpeed = 7000;
63    var randomizeMajorSponsors = true;
64
65    //Constructor for the wiget
66    $.fn.SponsorScrollingCarousel = function (options) {
67
68        var opts = $.extend({}, $.fn.SponsorScrollingCarousel.defaultOptions, options);
69
70        widgetContainer = this
71        carouselContainer = this.find('#sponsorCarouselContainer');
72        majorSponsorContainer = this.find('#majorSponsorImageContainer');
73        majorSponsorTitleContainer = this.find('#majorSponsorTitleContainer');
74        sponsorsTitleContainer = this.find('#sponsorsTitleContainer');
75        imageContainer = this.find('#sponsorCarouselImageContainer')
76        carouselHeight = carouselContainer.css('height').replace('px', '')
77        carouselWidth = carouselContainer.width()
78
79        var sponsorDataAdapter = new sponsorDataService();
80
81        sponsorDataAdapter.getSponsors(opts.scriptPath, opts.currentWidgetModuleItemID, getSponsorImagesSuccess, getSponsorImagesError);
82
83        customWidth = opts.customWidth;
84        majorSponsorWidth = opts.majorSponsorWidth;
85        majorSponsorHeight = opts.majorSponsorHeight;
86        verticalCenteringValues = opts.verticalCenteringValues;
87        verticalCentering = opts.verticalCentering;
88        sponsorWidth = opts.sponsorWidth;
89        sponsorHeight = opts.sponsorHeight;
90        $(window).load(function () { carouselWidth = carouselContainer.width() });
91        sponsorsLoaded = opts.sponsorsLoaded;
92        sponsorsInitialized = opts.sponsorsInitialized;
93        movementIncrement = opts.movementIncrement;
94        bw = opts.bw;
95        randomizeIndex = opts.randomizeIndex;
96        imageQuality = opts.imageQuality;
97        majorSponsorRotationSpeed = opts.majorSponsorRotationSpeed;
98        randomizeMajorSponsors = opts.randomizeMajorSponsors;
99
100    };
101
102    //Default options for the constructor to be merged with send constructor data
103    $.fn.SponsorScrollingCarousel.defaultOptions = {
104        scriptPath: "services/eventsservice.asmx"
105        , currentWidgetModuleItemID: 0,
106        majorSponsorWidth: null,
107        majorSponsorHeight: null,
108        sponsorWidth: null,
109        sponsorHeight: null,
110        verticalCentering: false,
111        verticalCenteringValues: new Array(),
112        sponsorsLoaded: function(){},
113        sponsorsInitialized: function(){},
114        movementIncrement: 2,
115        bw: false,
116        randomizeIndex: false,
117        imageQuality: 80,
118        majorSponsorRotationSpeed: 7000,
119        randomizeMajorSponsors: true
120    };
121
122    //service call worked
123    var getSponsorImagesSuccess = function (data) {
124
125        widgetData = data.d;
126        var majorSponsors = [];
127        //if there is a major sponsor then remove it from the sponsor collection & some basic styling/text population items
128        for (i = (widgetData.Sponsors.length - 1); i >= 0; i--) {
129            if(PAGESSL){
130              var makeHTTPS = widgetData.Sponsors[i].ImageWithPath.replace('http://', 'https://');
131              widgetData.Sponsors[i].ImageWithPath = makeHTTPS;
132            }
133            var currentSponsor = widgetData.Sponsors[i]; 
134
135
136            if (widgetData.OnlySponsorIsMajorSponsor) {
137                //If the only sponsor is the major sponsor the lets not remove from the sponsor collection and just
138                //replace the regular sponsor text with the major sponsor text
139                $('#sponsorsTitleContainer .homepageh1').text(widgetData.MajorSponsorText);
140            }
141            else {
142                if (currentSponsor.IsMajorSponsor == true) {  // instance is major sponsor - here we set up the container
143                    majorSponsor = widgetData.Sponsors.splice(i, 1)[0];
144
145                    majorSponsors.push(majorSponsor);
146                    $('#sponsorWidgetContainer').addClass('sponsorWidgetContainerMajorSponsor');
147                    $('#majorSponsorTitleContainer .homepageh1').text(widgetData.MajorSponsorText);
148                    $('#sponsorsTitleContainer .homepageh1').text(widgetData.SponsorTextWhenMajorSponsorIsPresent);
149                } else {
150                    $('#sponsorsTitleContainer .homepageh1').text(widgetData.SponsorText);
151                }
152            }
153
154
155        }
156
157
158        if (majorSponsors.length == 1) {  // simplifying things  I'm just leaving this as is to avoid major testing - this is the single major sponsor scenario
159            var majorBW;
160            if(bw==true){
161                majorBW = '&bw=true';
162            } else {
163                majorBW = '';
164            }
165            var majorSponsorElement = '';
166
167            if (majorSponsor.URL != null && majorSponsor.URL != '') { // it has a url
168                majorSponsorElement = "<a href='" + majorSponsor.URL + "' target='_blank' style='border:none; outline:none;' onClick=\"_gaq.push(['_trackEvent', 'Sponsors', 'Button Click (To External Site)', '" + majorSponsor.Name.replace(/'/g, "\\'") + "'])\">";
169            }
170
171            var imageAlternateText = "";
172
173            if (majorSponsor.ImageAlternateText != null) {
174                imageAlternateText = (majorSponsor.ImageAlternateText);
175            }
176
177            if (majorSponsorWidth != null && majorSponsorHeight != null) {
178                majorSponsorElement += "<span class='majorSponsorImage' ><img src='" + majorSponsor.ImageWithPath + "&h=" + majorSponsorHeight + "&w=" + majorSponsorWidth + "&c=1&q=" + imageQuality + majorBW + "' alt='" + imageAlternateText + "' title='" + majorSponsor.Name + "' /></span>";
179            } else {
180                majorSponsorElement += "<span class='majorSponsorImage' ><img src='" + majorSponsor.ImageWithPath + "&h=" + carouselHeight + "&c=1&q=" + imageQuality + majorBW + "' alt='" + imageAlternateText + "' title='" + majorSponsor.Name + "' /></span>";
181            }
182
183            if (majorSponsor.URL != null && majorSponsor.URL != '') {
184                majorSponsorElement += "</a>";
185            }
186
187            majorSponsorContainer.html(majorSponsorElement);
188        } else if(majorSponsors.length > 1){ // this is the new multi-major sponsor section
189
190            var majorBW;
191            if(bw==true){
192                majorBW = '&bw=true';
193            } else {
194                majorBW = '';
195            }
196            majorSponsorWidth = $('#majorSponsorImageContainer').css('width').replace('px','');
197            majorSponsorHeight = $('#majorSponsorImageContainer').css('height').replace('px','');
198
199            if(randomizeMajorSponsors){
200                var currentIndex = majorSponsors.length, temporaryValue, randomIndex ;
201
202                  // While there remain elements to shuffle...
203                  while (0 !== currentIndex) {
204
205                    // Pick a remaining element...
206                    randomIndex = Math.floor(Math.random() * currentIndex);
207                    currentIndex -= 1;
208
209                    // And swap it with the current element.
210                    temporaryValue = majorSponsors[currentIndex];
211                    majorSponsors[currentIndex] = majorSponsors[randomIndex];
212                   majorSponsors[randomIndex] = temporaryValue;
213                }
214            }
215
216           var iterateMajor = 0;
217           var majorSponsorURL = '';
218           var majorSponsorCursor = '';
219            if(majorSponsors[iterateMajor].URL != null && majorSponsors[iterateMajor].URL != ''){
220                majorSponsorURL = majorSponsors[iterateMajor].URL;
221                majorSponsorCursor = '';
222            } else {
223                majorSponsorURL = 'javascript:void(0)';
224                majorSponsorCursor = ' style="cursor:default;"'
225            }
226
227
228            var imageAlternateText = "";
229
230            if (majorSponsors[iterateMajor].ImageAlternateText != null) {
231                imageAlternateText = (majorSponsors[iterateMajor].ImageAlternateText);
232            }
233
234            $('#majorSponsorImageContainer').append('<a href="' + majorSponsorURL + '"' + majorSponsorCursor + '><img src="' + majorSponsors[iterateMajor].ImageWithPath + '&h=' + majorSponsorHeight + '&w=' + majorSponsorWidth + '&q=' + imageQuality + majorBW + '" alt="' + imageAlternateText + '" /></a>');
235           iterateMajor=1;
236
237           setTimeout(function(){
238                setInterval(function(){
239                    $('#majorSponsorImageContainer img').animate({opacity: '0'},Math.round(majorSponsorRotationSpeed/20),'linear',function(){
240                        $('#majorSponsorImageContainer img').remove();
241                        $('#majorSponsorImageContainer a').remove();
242                        if(majorSponsors[iterateMajor].URL != null && majorSponsors[iterateMajor].URL != ''){
243                            majorSponsorURL = majorSponsors[iterateMajor].URL;
244                            majorSponsorCursor = '';
245                        } else {
246                            majorSponsorURL = 'javascript:void(0)';
247                            majorSponsorCursor = ' style="cursor:default;"'
248                        }
249
250
251                        var imageAlternateText = "";
252
253                        if (majorSponsors[iterateMajor].ImageAlternateText != null) {
254                            imageAlternateText = (majorSponsors[iterateMajor].ImageAlternateText);
255                        }
256                        $('#majorSponsorImageContainer').append('<a href="' + majorSponsorURL + '"' + majorSponsorCursor + '><img src="' + majorSponsors[iterateMajor].ImageWithPath + '&h=' + majorSponsorHeight + '&w=' + majorSponsorWidth + '&q=' + imageQuality + majorBW + '" alt="' + imageAlternateText + '" title="' + majorSponsors[iterateMajor].Name + '" /></a>');
257                        if(iterateMajor == majorSponsors.length-1){
258                            iterateMajor = 0;
259                        } else {
260                            iterateMajor++;
261                        }
262                    });
263                }, majorSponsorRotationSpeed);
264            }, majorSponsorRotationSpeed);
265
266        } else {
267            $('#majorSponsor').css('display', 'none');
268        }
269
270        initialize();
271
272    };
273
274    //service call has failed
275    var getSponsorImagesError = function (data) {
276        console.log('Sponsor Widget failed to load'
277        , '\n' + 'Status: ' + data.status + ' ' + data.statusText
278        , '\n' + data.responseText);
279    };
280
281    //set up the ui
282    function initialize() {
283        if (widgetData.Sponsors.length > 0) {
284            $('#sponsorLogoSection').append('<div id="hiddenSponsorCache" style="display: none;"></div>');
285            $(widgetData.Sponsors).each(function(){
286                $('#hiddenSponsorCache').append('')
287            })
288            var imageContainerWidth = parseInt(imageContainer.css('width').replace('px', ''));
289
290            //load enough image to fill the container
291
292            if(randomizeIndex){  // if the local constructor asks for a randomization of sponsors
293                var currentIndex = widgetData.Sponsors.length, temporaryValue, randomIndex ;
294
295                  // While there remain elements to shuffle...
296                  while (0 !== currentIndex) {
297
298                    // Pick a remaining element...
299                    randomIndex = Math.floor(Math.random() * currentIndex);
300                    currentIndex -= 1;
301
302                    // And swap it with the current element.
303                    temporaryValue = widgetData.Sponsors[currentIndex];
304                    widgetData.Sponsors[currentIndex] = widgetData.Sponsors[randomIndex];
305                    widgetData.Sponsors[randomIndex] = temporaryValue;
306                  }
307           }
308
309            var imageIndex = 0;
310            var totalImageWidth = 0;
311
312            while (imageIndex < widgetData.Sponsors.length && totalImageWidth <= carouselWidth) {
313                imageContainer.append(createSponsorImageHTML(imageIndex));
314                currentDisplayedImageIndexes.push(imageIndex);
315                totalImageWidth += resolveImageWidth(imageIndex);
316                imageIndex++
317            }
318
319            var updateInterval = setInterval(function () { UpdateSponsorScrollingCarousel() }, timeIncrement);
320        } else {
321            $('#sponsorLogoSection').css('display', 'none');
322            $('.homepageContent').addClass('noSponsorsEnabled');
323            $('body').addClass('globalNoSponsorsEnabled');
324        }
325
326        sponsorsInitialized();
327
328        $('#sponsorWidgetContainer').prepend('<div id="stopthesponsordiv" style="display: none;
328 width: 20px; height: 20px; background: pink; position:fixed; top: 0; left: 0; z-index: 2147483647;"></div>');
329
330        $('#stopthesponsordiv').click(function(){
331            var checkScrolling = $(this).hasClass('stopthesponsorsnow');
332            if(!checkScrolling){
333                clearInterval(updateInterval);
334                $(this).addClass('stopthesponsorsnow');
335            } else {
336                $(this).removeClass('stopthesponsorsnow');
337                updateInterval = setInterval(function () { UpdateSponsorScrollingCarousel() }, timeIncrement);
338            }
339        })
340
341        $('#sponsorWidgetContainer').hover(function(){
342            clearInterval(updateInterval);
343        }, function() {
344            updateInterval = setInterval(function () { UpdateSponsorScrollingCarousel() }, timeIncrement);
345        });
346
347        if(isLegacyResponsive && widgetData.Sponsors.length > 0){
348            var getSponsorName = widgetData.Sponsors[staticSponsorTimer].Name;
349            var getSponsorURL = widgetData.Sponsors[staticSponsorTimer].URL;
350            var getImagePath = widgetData.Sponsors[staticSponsorTimer].ImageWithPath;
351            var sponsorTarget = getSponsorURL.indexOf(SITEBASEURL);
352
353
354            var imageAlternateText = "";
355
356            if (widgetData.Sponsors[staticSponsorTimer].ImageAlternateText != null) {
357                imageAlternateText = (widgetData.Sponsors[staticSponsorTimer].ImageAlternateText);
358            }
359
360            $('#hiddenSponsorCache').html('<a onclick="_gaq.push([\'_trackEvent\', \'Sponsors\', \'Button Click (To External Site)\', \''+getSponsorName+'\'])"'+
361                    ' style="border: none; outline: none;"'+sponsorTarget+' href="'+getSponsorURL+'" class="showingMobileSponsor"><span class="sponsorCarouselImage mobileSponsorIsShowing">'+
362                    '<img src="' + getImagePath + '" alt="' + imageAlternateText + '" /></span></a>');
363            staticSponsorTimer = 1
364            setInterval(function(){
365                $('.showingMobileSponsor').remove();
366                if(staticSponsorTimer >= widgetData.Sponsors.length - 1){
367                    staticSponsorTimer = 0;
368                } else {
369                    staticSponsorTimer++;
370                }
371                getSponsorName = widgetData.Sponsors[staticSponsorTimer].Name;
372                getSponsorURL = widgetData.Sponsors[staticSponsorTimer].URL;
373                getImagePath = widgetData.Sponsors[staticSponsorTimer].ImageWithPath;
374                sponsorTarget = getSponsorURL.indexOf(SITEBASEURL);
375
376                var imageAlternateText = "";
377
378                if (widgetData.Sponsors[staticSponsorTimer].ImageAlternateText != null) {
379                    imageAlternateText = (widgetData.Sponsors[staticSponsorTimer].ImageAlternateText);
380                }
381                if(sponsorTarget == -1){
382                    sponsorTarget = ' target="_blank"';
383                } else {
384                    sponsorTarget = '';
385                }
386                $('#hiddenSponsorCache').html('<a onclick="_gaq.push([\'_trackEvent\', \'Sponsors\', \'Button Click (To External Site)\', \''+getSponsorName+'\'])"'+
387                    ' style="border: none; outline: none;"'+sponsorTarget+' href="'+getSponsorURL+'" class="showingMobileSponsor"><span class="sponsorCarouselImage mobileSponsorIsShowing">'+
388                    '<img src="' + getImagePath + '" alt="' + imageAlternateText + '" /></span></a>');
389            }, 6000);
390        }
391    }
392
393
394
395
396    function UpdateSponsorScrollingCarousel() {
397        //Update UI
398        //var windowWidth = $(window).width();
399        var majorSponsorWidth;
400        var checkMajorSponsor = $('#sponsorWidgetContainer').hasClass('sponsorWidgetContainerMajorSponsor');
401        if(checkMajorSponsor){
402            majorSponsorWidth = parseInt(majorSponsorContainer.css('width').replace('px', ''));
403        } else {
404            majorSponsorWidth = 0;
405        }
406
407        imageContainer.css('left', majorSponsorWidth + 'px');
408        //majorSponsorTitleContainer.css('width', majorSponsorWidth + 'px');
409        //sponsorsTitleContainer.css('width', (carouselWidth - majorSponsorWidth) + 'px');
410
411        var currentDisplayImages = imageContainer.find('.sponsorCarouselImage');
412
413        if (currentDisplayImages.length == widgetData.Sponsors.length && getCurrentDisplayImagesWidth() < (carouselWidth - majorSponsorWidth)) {
414            //Every sponsor is showing and fits in the window
415            //So lets just center them
416
417            var startLeft = (carouselWidth - getCurrentDisplayImagesWidth() - majorSponsorWidth) / 2
418            $('#sponsorArrowLeft, #sponsorArrowRight').css('display', 'none');
419
420            $.each(currentDisplayImages, function (index) {
421                $(this).css('left', startLeft);
422            });
423
424            runningStatic = true;
425
426            $('#sponsorWidgetContainer').addClass('notScrollingLogos');
427        }
428        else {
429
430            if (runningStatic) {
431                //if the major sponsor wasn't loaded on the first couple cycles and the images left property was adjust to center them
432                //then we want to reset their left property one we start scrolling
433                $.each(currentDisplayImages, function (index) {
434                    $(this).css('left', 0);
435                });
436                runningStatic = false;
437                $('#sponsorWidgetContainer').removeClass('notScrollingLogos');
438            }
439
440            if (currentDisplayImages.length > 0) {
441                //animation
442
443                scrollCarousel();
444
445                var firstImageLeft = carouselContainer.scrollLeft() * -1;
446                var firstImageWidth = resolveImageWidth(currentDisplayedImageIndexes[0]);
447
448                //see if the first image needs to be removed
449                if (firstImageLeft + firstImageWidth < 0) {
450                    if ($(currentDisplayImages[0]).parent().is('a')) {
451                        $(currentDisplayImages[0]).parent().remove();
452                    } else {
453                        $(currentDisplayImages[0]).remove();
454                    }
455
456                    currentDisplayedImageIndexes.shift();
457                    scrollCarousel(firstImageWidth * -1);
458                }
459
460                //see if the last image needs to be removed
461                if (getCurrentDisplayImagesWidth() - carouselContainer.scrollLeft() - resolveImageWidth(currentDisplayedImageIndexes[currentDisplayedImageIndexes.length - 1]) > carouselWidth) {
462                    if ($(currentDisplayImages[currentDisplayImages.length - 1]).parent().is('a')) {
463                        $(currentDisplayImages[currentDisplayImages.length - 1]).parent().remove();
464                    } else {
465                        $(currentDisplayImages[currentDisplayImages.length - 1]).remove();
466                    }
467
468                    currentDisplayedImageIndexes.pop();
469                }
470
471                //See if an image needs to be added to the end
472                if (firstImageLeft + getCurrentDisplayImagesWidth() < carouselWidth) {
473                    var appendSponsorIndex = resolveSponsorIndex(currentDisplayedImageIndexes[currentDisplayedImageIndexes.length - 1] + 1);
474                    imageContainer.append(createSponsorImageHTML(appendSponsorIndex, 0));
475                    currentDisplayedImageIndexes.push(appendSponsorIndex);
476                }
477
478                //See if an image needs to be added to the beginning
479                if (firstImageLeft >= 0 && isScrollingLeft) {
480                    var prependSponsorIndex = resolveSponsorIndex(currentDisplayedImageIndexes[0] - 1);
481                    //alert('one');
482                    imageContainer.prepend(createSponsorImageHTML(prependSponsorIndex, 0));
483                    currentDisplayedImageIndexes.splice(0, 0, prependSponsorIndex);
484                    //alert('two');
485                    scrollCarousel(resolveImageWidth(currentDisplayedImageIndexes[0]));
486                    //alert('three');
487                }
488
489                $('#sponsorWidgetContainer').removeClass('notScrollingLogos');
490            }
491
492        }
493        if (verticalCentering == true) {
494            $('.sponsorCarouselImage img').each(function () {
495
496                var h = $(this).height();
497                if (h < verticalCenteringValues[0]) {
498                    var n = verticalCenteringValues[1] - h;
499                    n = Math.ceil(n * 0.5);
500                    $(this).css('margin-top', n + 'px').css('margin-bottom', n + 'px').addClass('margined');
501                } else {
502                    $(this).css('margin-top', verticalCenteringValues[2] + 'px').css('margin-bottom', '0').addClass('margined');
503                }
504
505            });
506        }
507
508        sponsorsLoaded();
509        widgetContainer.show();
510
511    }
512
513
514    function getCurrentDisplayImagesWidth() {
515        var totalWidth = 0;
516        $(currentDisplayedImageIndexes).each(function () {
517            totalWidth += resolveImageWidth(this);
518        });
519
520        return totalWidth
521    }
522
523    function resolveImageWidth(sponsorIndex) {
524
525        var tempSponsor = widgetData.Sponsors[sponsorIndex];
526        var returnWidth = 0;
527
528        if (tempSponsor.ImageHeight > 0 && tempSponsor.WidthToHeighteRatio > 0) {
529
530            if (tempSponsor.ImageHeight < carouselHeight) {
531                returnWidth = tempSponsor.ImageHeight / tempSponsor.WidthToHeighteRatio;
532            }
533            else {
534                returnWidth = carouselHeight / tempSponsor.WidthToHeighteRatio;
535            }
536
537            var getCustomWidthFromCSS = $('.sponsorCarouselImage').css('max-width');
538            if (customWidth == null && getCustomWidthFromCSS != 'none'){
539                returnWidth = parseInt(getCustomWidthFromCSS);
540            } else if (customWidth != null) {
541                returnWidth = customWidth;
542            }
543
544        }
545        return (Math.round(returnWidth) + 10);
546    }
547
548    function resolveSponsorIndex(theoreticalIndex) {
549        var direction = theoreticalIndex / Math.abs(theoreticalIndex);
550        var returnIndex = 0
551        var span = Math.abs(theoreticalIndex)
552
553        for (i = 0; i < span; i++) {
554            returnIndex += direction
555            if (returnIndex < 0) {
556                returnIndex = widgetData.Sponsors.length - 1;
557            }
558            if (returnIndex > (widgetData.Sponsors.length - 1)) {
559                returnIndex = 0
560            }
561        }
562
563        return returnIndex;
564
565    }
566
567    function createSponsorImageHTML(imageIndex, cssLeft) {
568        var makeBW;
569        if(bw == true){
570            makeBW = '&bw=true';
571        } else {
572            makeBW = '';
573        }
574
575        if (cssLeft == undefined) { cssLeft = 0 }
576
577        var sponsorURL = widgetData.Sponsors[imageIndex].URL;
578        var returnElement = '';
579
580
581        var imageAlternateText = "";
582
583        if (widgetData.Sponsors[imageIndex].ImageAlternateText != null) {
584            imageAlternateText = (widgetData.Sponsors[imageIndex].ImageAlternateText);
585        }
586
587        if (sponsorURL != null && sponsorURL != '') {
588            returnElement = "<a href='" + sponsorURL + "' target='_blank' style='border:none; outline:none;' onClick=\"_gaq.push(['_trackEvent', 'Sponsors', 'Button Click (To External Site)', '" + widgetData.Sponsors[imageIndex].Name.replace(/'/g, "\\'") + "'])\">";
589        }
590
591        if (sponsorWidth != null && sponsorHeight != null) {
592            returnElement += "<span class='sponsorCarouselImage' sponsorImageIndex='" + imageIndex + "' style='left:" + cssLeft + "px;position:relative;margin:0 5px;' ><img src='" + widgetData.Sponsors[imageIndex].ImageWithPath + "&h=" + sponsorHeight + "&w=" + sponsorWidth + makeBW + "&c=1&q=" + imageQuality + "' alt='" + imageAlternateText + "' title='" + widgetData.Sponsors[imageIndex].Name + "' /></span>"
593        } else {
594            returnElement += "<span class='sponsorCarouselImage' sponsorImageIndex='" + imageIndex + "' style='left:" + cssLeft + "px;position:relative;margin:0 5px;' ><img src='" + widgetData.Sponsors[imageIndex].ImageWithPath + "&h=" + carouselHeight + makeBW + "&c=1&q=" + imageQuality + "' alt='" + imageAlternateText + "' title='" + widgetData.Sponsors[imageIndex].Name + "' /></span>"
595        }
596
597        if (sponsorURL != null && sponsorURL != '') {
598            returnElement += '</a>';
599        }
600
601        return returnElement;
602
603    }
604
605    function scrollCarousel(scrollBy) {
606        $('#sponsorArrowLeft, #sponsorArrowRight').css('display', 'block');
607        $('#sponsorArrowLeft').click(function () {
608            isScrollingLeft = true;
609            currentDirection = -1;
610            return currentDirection;
611        });
612
613        $('#sponsorArrowRight').click(function () {
614            isScrollingLeft = false;
615            currentDirection = 1;
616            return currentDirection;
617        });
618        var scrollLeft = carouselContainer.scrollLeft();
619        if (scrollBy == undefined) {
620            carouselContainer.scrollLeft(scrollLeft + (movementIncrement * currentDirection));
621        }
622        else {
623            //alert(scrollLeft + scrollBy);
624            carouselContainer.scrollLeft(scrollLeft + scrollBy);
625        }
626    }
627
628})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.