(function ($) { $.fn.CrownSlideShow = function (b) { var c = $.extend({}, $.fn.CrownSlideShow.defaults, b); return this.each(function (i) { obj = $(this); var a = {}; a.which = i; createFeature(c, a); customizeFeature(c, a); eventFeature(c, a) }) }; $.fn.CrownSlideShow.defaults = { outputElementId: 'image-block', imgBgIdPrefix: 'image', tabIdPrefix: 'tab', containerWidth: '980px', containerHeight: '349px', imgWidth: '704px', tabsLocation: 'left', tabBgImg: '/graphics/arrow-left.png', tabBgImgIE6: '/graphics/arrow-left.gif', tabControl: 'click', activeTabIsLink: true, activeWindowIsLink: true, animateInOnLoad: true, imgBgsAnimateInDuration: 750, imgBgsAnimateOutDuration: 750, tabsAnimateInDuration: 0, tabsAnimateWidth: '+=27', autoPlay: true, autoPlayInterval: 5000, pauseOnHover: true, endCreateFunction: null }; function outerHTML(a) { return $('<div>').append(a.eq(0).clone()).html() }; function createFeature(a, b) { var c; var d = "<div id='" + a.imgBgIdPrefix + "-container'>"; var e = "<div id='" + a.tabIdPrefix + "-container'>"; if ($.browser.msie && $.browser.version == 6) { if (a.tabBgImgIE6 != null || a.tabBgImgIE6 != '') { a.tabBgImg = a.tabBgImgIE6 } } obj.children().each(function (i) { sfcurrent = $(this); cloned = sfcurrent.clone().attr({ id: a.tabIdPrefix + i }).find('img').remove().end().wrapInner('<div>').prepend('<span></span>'); d += '<div id="' + a.tabIdPrefix + i + '" style="background-image:url(' + sfcurrent.find('img').attr('src') + '); width:' + a.imgWidth + '; height:' + a.containerHeight + ';"></div>'; e += '<a href="#' + a.tabIdPrefix + i + '" id="' + a.tabIdPrefix + i + '"><span><span></span><img src="' + a.tabBgImg + '"/></span><h3>' + sfcurrent.find('h3').text() + '</h3><p>' + sfcurrent.find('p').text() + '</p></a>' }); d += "</div>"; e += "</div>"; c = (d + e); obj.empty().attr({ 'id': a.outputElementId, 'class': a.tabsLocation }).css({ 'width': a.containerWidth, 'height': a.containerHeight }).append(c); obj.addClass('SF-' + b.which); if ($.isFunction(a.endCreateFunction)) { a.endCreateFunction.apply(this, [a]) } } function customizeFeature(a, b) { var c = $('#' + a.imgBgIdPrefix + '-container', obj); var d = $('#' + a.tabIdPrefix + '-container', obj); c.css({ 'width': a.imgWidth, 'height': a.containerHeight }); d.children().css({ 'width': (parseInt(a.containerWidth) - parseInt(a.imgWidth)), 'height': ((parseInt(a.containerHeight) / d.children().length) - (1 + (1 / d.children().length))) }).children('span').css({ 'width': (parseInt(a.containerWidth) - parseInt(a.imgWidth)), 'height': ((parseInt(a.containerHeight) / d.children().length) - (1 + (1 / d.children().length))) }).children('img').css({ 'left': ((a.tabsLocation == 'left') ? parseInt(a.containerWidth) - parseInt(a.imgWidth) : '0') }).prev().css({ 'width': (parseInt(a.containerWidth) - parseInt(a.imgWidth)) }) } function eventFeature(c, d) { var f = obj; var g = $('#' + c.imgBgIdPrefix + '-container', obj).children(); var h = $('#' + c.tabIdPrefix + '-container', obj).children(); h.click(function (e) { if (!h.hasClass('selected')) { if (c.animateInOnLoad) { g.css({ 'opacity': '0', 'display': 'none' }).filter(this.hash).css({ 'display': 'block' }).animate({ 'opacity': '1' }, c.imgBgsAnimateInDuration, null); h.filter(this.hash).children('span').animate({ 'width': c.tabsAnimateWidth }, c.tabsAnimateInDuration, null) } else { g.css({ 'opacity': '0', 'display': 'none' }).filter(this.hash).css({ 'opacity': '1', 'display': 'block' }); h.filter(this.hash).children('span').animate({ 'width': c.tabsAnimateWidth }, 0, null) } } else { if (!$(this).hasClass('selected')) { var a = this.hash; g.filter('.selected').animate({ 'opacity': '0' }, c.imgBgsAnimateOutDuration, function () { $(this).css({ 'display': 'none' }) }).end().filter(this.hash).css({ 'display': 'block' }).animate({ 'opacity': '1' }, c.imgBgsAnimateInDuration); h.filter('.selected').children('span').css({ 'width': (parseInt(c.containerWidth) - parseInt(c.imgWidth)), 'display': 'none' }).end().end().filter(this.hash).children('span').animate({ 'width': c.tabsAnimateWidth }, c.tabsAnimateInDuration) } else { if (c.activeTabIsLink) { window.location = h.filter(this.hash).find('a').attr('href'); return false } } } f.find('.selected').removeClass('selected'); f.find(this.hash).each(function () { $(this).addClass('selected') }); return false }).filter(':first').click(); if (c.activeWindowIsLink) { $('#' + c.tabIdPrefix + '-container').css({ 'cursor': 'pointer' }).click(function (e) { if (e.target.tagName == 'A') { return true } else { var a = h.filter('.selected').attr('href'); var b = a.lastIndexOf('#'); a = a.substring(b, a.length); window.location = h.filter(a).find('a').attr('href'); return false } }) } if (c.autoPlay) { CrownSlideShowAutoPlayInterval['which' + d.which] = setInterval("CrownSlideShowAutoPlayer(" + d.which + ")", c.autoPlayInterval); if (c.pauseOnHover) { obj.hover(function () { clearInterval(CrownSlideShowAutoPlayInterval['which' + d.which]) }, function () { CrownSlideShowAutoPlayInterval['which' + d.which] = setInterval("CrownSlideShowAutoPlayer(" + d.which + ")", c.autoPlayInterval) }) } } if (c.tabControl == 'hover') { h.mouseover(function () { if (!$(this).hasClass('selected')) { var a = this.hash; g.filter('.selected').animate({ 'opacity': '0' }, c.imgBgsAnimateOutDuration, function () { $(this).css({ 'display': 'none' }) }).end().filter(this.hash).css({ 'display': 'block' }).animate({ 'opacity': '1' }, c.imgBgsAnimateInDuration); h.filter('.selected').children('span').css({ 'width': (parseInt(c.containerWidth) - parseInt(c.imgWidth)), 'display': 'none' }).end().end().filter(this.hash).children('span').animate({ 'width': c.tabsAnimateWidth }, 0) } f.find('.selected').removeClass('selected'); f.find(this.hash).each(function () { $(this).addClass('selected') }) }) } } })(jQuery); var CrownSlideShowAutoPlayInterval = []; function CrownSlideShowAutoPlayer(a) { var b = $('.SF-' + a).find('#' + $.fn.CrownSlideShow.defaults.tabIdPrefix + '-container').children(); if ((b.length - 1) == b.index(b.filter('.selected'))) { b.filter(':first').click() } else { b.filter('.selected').next().click() } }
