﻿var $flashobj = { imgarr: null, _data: [], preloaded: [], numAnchorsRendered: "", loading: null, noflash: null, banners: null, bannerParent: null, getDate: function () { var a = new Date(); return a.getTime() }, rotationNation: { _var: { count: 0, mod: 0, width: 0, height: 0, timer: 3500, interval: undefined, isPaused: false, pausedDifference: 0, timePaused: 0, transitionItem: 0, timeoutInterval: undefined, curIndexText: undefined, currentPage: document.URL }, start: function () { this.handleClick(); this.bindAnimation(); $flashobj.numAnchorsRendered = $("#Rotater").children("a").length }, end: function () { }, handleClick: function () { $("#controller #banners #pause").bind({ click: function () { $flashobj.rotationNation._var.isPaused ? $flashobj.rotationNation.pause("resume") : $flashobj.rotationNation.pause("pause") }, mouseenter: function () { $(this).css("background-position", "-51px -44px") }, mouseleave: function () { $flashobj.rotationNation._var.isPaused ? $(this).css("background-position", "-51px -44px") : $(this).css("background-position", "-34px -44px") } }); $("#controller #banners #previous, #controller #banners #next").bind({ click: function () { $(this).attr("id") == "previous" ? $flashobj.rotationNation.previous() : $flashobj.rotationNation.next() }, mouseenter: function () { $(this).attr("id") == "previous" ? $(this).css("background-position", "-17px -27px") : $(this).css("background-position", "-17px -44px") }, mouseleave: function () { $(this).attr("id") == "previous" ? $(this).css("background-position", "0px -27px") : $(this).css("background-position", "0px -44px") } }); $("#controller #closeFlash #close, #controller #closeFlash #closeFeedback").bind({ click: function () { try { $flashobj.flashHandler.remove() } catch (a) { killVideo() } }, mouseenter: function () { $("#controller #closeFlash #close").css("background-position", "-51px -27px") }, mouseleave: function () { $("#controller #closeFlash #close").css("background-position", "-34px -27px") } }); $($flashobj.bannerParent).delegate("a", "click", function (c) { var b = $flashobj.rotationNation._var.count, a; switch ($(this).attr("callouttype")) { case "text": a = $flashobj._data[b].link_href; _gaq.push(["_trackEvent", "Banner", $flashobj.rotationNation._var.currentPage, a]); break; case "image": a = $flashobj._data[b].link_href; _gaq.push(["_trackEvent", "Banner", $flashobj.rotationNation._var.currentPage, a]); break; case "localVideo": var d = '[{"Image":"", "Video":"' + $flashobj._data[$(this).attr("index")].vid_path + '"}]'; $("#Rotater").hide(); $("#bannerBackground").css("visibility", "visible").fadeIn("slow"); $("#primaryControls").fadeOut("slow"); $("#pauseControl").fadeOut("slow"); $("#closeFlash").hide().fadeIn("slow"); $flashobj.rotationNation.pause("pause"); playVideos(d, true, bannerVidApi); break; case "video": $flashobj.flashHandler.embed({ videoid: $(this).attr("videoid"), open_lightbox: $(this).attr("open_lightbox"), lbwidth: $(this).attr("lbwidth"), lbheight: $(this).attr("lbheight") }); $("#closeFlash").hide().fadeIn("slow"); c.preventDefault(); a = $flashobj._data[b].video_id; _gaq.push(["_trackEvent", "Banner", $flashobj.rotationNation._var.currentPage, a]); break; default: break } }) }, pause: function (a) { switch (a) { case "pause": if ($flashobj.rotationNation._var.pausedDifference) { clearTimeout($flashobj.rotationNation._var.timeoutInterval) } $flashobj.rotationNation._var.isPaused = true; $flashobj.rotationNation._var.timePaused = $flashobj.getDate(); break; case "resume": $flashobj.rotationNation._var.isPaused = false; if ($flashobj.rotationNation._var.pausedDifference) { $flashobj.rotationNation._var.timeoutInterval = setTimeout(function () { $flashobj.rotationNation.next(); $flashobj.rotationNation._var.timePaused = null; $flashobj.rotationNation._var.pausedDifference = null }, $flashobj.rotationNation._var.pausedDifference) } break; default: break } }, previous: function () { if ($flashobj.rotationNation._var.isPaused) { $flashobj.rotationNation._var.pausedDifference = $flashobj.rotationNation._var.timer } this.previous.rebindAnimation = function () { if (!$flashobj.rotationNation._var.isPaused) { $flashobj.rotationNation.bindAnimation(); $flashobj.rotationNation.previous.rebindAnimation = undefined } }; $flashobj.rotationNation.backup(); this._updateText(); this.killAnimation() }, next: function () { if ($flashobj.rotationNation._var.isPaused) { $flashobj.rotationNation._var.pausedDifference = $flashobj.rotationNation._var.timer } this.next.rebindAnimation = function () { if (!$flashobj.rotationNation._var.isPaused) { $flashobj.rotationNation.bindAnimation(); $flashobj.rotationNation.previous.rebindAnimation = undefined } }; this._updateText($flashobj.rotationNation.proceed()); this.killAnimation() }, _updateText: function (a) { $flashobj.rotationNation._var.curIndexText.text(this._var.count + 1); if (a !== null & a !== undefined) { a() } }, proceed: function () { if ($flashobj.numAnchorsRendered > 1) { if (!($flashobj.rotationNation._var.count % $flashobj.rotationNation._var.mod)) { if (($flashobj.rotationNation._var.count >= $flashobj.rotationNation._var.mod) || ($flashobj.rotationNation._var.count == $flashobj.rotationNation._var.mod)) { $flashobj.rotationNation._var.count = 0; $("#Rotater a").eq(0).css({ "z-index": $("#Rotater a").data("zIndex"), opacity: "0" }); $("#Rotater a").eq(0).stop().animate({ opacity: 1 }, 500, function () { $("#Rotater a").each(function () { if ($(this).css("z-index") == -1) { $(this).css({ "z-index": $(this).data("zIndex"), filter: "none", opacity: 1 }) } $(this).css({ filter: "none" }); if ($flashobj.rotationNation.next.rebindAnimation) { $flashobj.rotationNation.next.rebindAnimation() } }) }) } else { $flashobj.rotationNation._var.transitionItem = $flashobj.rotationNation._var.count; $("#Rotater a").eq($flashobj.rotationNation._var.transitionItem).stop().animate({ opacity: 0 }, 500, function () { $("#Rotater a").eq($flashobj.rotationNation._var.transitionItem).css({ "z-index": "-1", filter: "none", opacity: "1" }); if ($flashobj.rotationNation.next.rebindAnimation) { $flashobj.rotationNation.next.rebindAnimation() } }); $flashobj.rotationNation._var.count++ } } else { $flashobj.rotationNation._var.transitionItem = $flashobj.rotationNation._var.count; $("#Rotater a").eq($flashobj.rotationNation._var.transitionItem).stop().animate({ opacity: 0 }, 500, function () { $("#Rotater a").eq($flashobj.rotationNation._var.transitionItem).css({ "z-index": "-1", filter: "none", opacity: "1" }); if ($flashobj.rotationNation.next.rebindAnimation) { $flashobj.rotationNation.next.rebindAnimation() } }); ++$flashobj.rotationNation._var.count } } }, backup: function () { if (!(this._var.count % this._var.mod)) { if ((this._var.count > this._var.mod) || (this._var.count == this._var.mod)) { this._var.count--; $("#Rotater a").eq(this._var.count).css("z-index", $("#Rotater a").eq(this._var.count).data("zIndex")); $("#Rotater a").eq(this._var.count).stop().animate({ opacity: 1 }, 500, function () { $("#Rotater a").each(function () { $(this).css({ filter: "none" }); if ($flashobj.rotationNation.previous.rebindAnimation) { $flashobj.rotationNation.previous.rebindAnimation() } }) }) } else { this._var.count = this._var.mod; $("#Rotater a").each(function () { if ($(this).index() != 0) { if ($(this).index() != $flashobj.rotationNation._var.mod) { $(this).css({ "z-index": "-1", opacity: "0" }) } } }); $("#Rotater a").eq(0).stop().animate({ opacity: 0 }, 500, function () { $("#Rotater a").eq(0).css({ "z-index": "-1", filter: "none", opacity: "1" }); if ($flashobj.rotationNation.previous.rebindAnimation) { $flashobj.rotationNation.previous.rebindAnimation() } }) } } else { --this._var.count; $("#Rotater a").eq(this._var.count).css({ "z-index": $("#Rotater a").eq($flashobj.rotationNation._var.count).data("zIndex"), opacity: "0" }); $("#Rotater a").eq(this._var.count).stop().animate({ opacity: 1 }, 500, function () { $("#Rotater a").each(function () { $(this).css({ filter: "none", opacity: "1" }); if ($flashobj.rotationNation.previous.rebindAnimation) { $flashobj.rotationNation.previous.rebindAnimation() } }) }) } }, animateBanners: function () { if ($flashobj.rotationNation._var.isPaused) { $flashobj.rotationNation._var.pausedDifference = $flashobj.getDate() - $flashobj.rotationNation._var.timePaused; $flashobj.rotationNation.killAnimation() } else { $flashobj.rotationNation.proceed(); $flashobj.rotationNation._updateText() } }, bindAnimation: function () { if (this._var.interval == undefined) { this._var.interval = setInterval($flashobj.rotationNation.animateBanners, $flashobj.rotationNation._var.timer) } }, killAnimation: function () { clearInterval(this._var.interval); this._var.interval = undefined } }, hideNoFlash: function () { $(this.noflash).hide(); $(this.loading).css("visibility", "visible") }, init: function (a) { $flashobj.defineImageArray(a.imgArr); $flashobj.defineElements(a.domElements); $flashobj.hideNoFlash(); $flashobj.prebind($flashobj.imgarr[0]); this.init.callback = function () { $flashobj.startShow() } }, defineImageArray: function (a) { $flashobj.imgarr = a }, defineElements: function (a) { $flashobj.banners = a.bannersContainer; $flashobj.bannerParent = a.bannersParent; $flashobj.loading = a.loadingAnimation; $flashobj.noflash = a.noFlash }, prebind: function (c) { var b = new Image(); if (c.image_src) { $(b).attr({ src: c.image_src, alt: c.alt }); if (b.complete) { $flashobj.preloaded.push(b); $flashobj._data.push($flashobj.imgarr[0]); a() } else { $(b).bind("load", function () { $flashobj.preloaded.push(b); $flashobj._data.push($flashobj.imgarr[0]); a() }).bind("error", function () { a() }) } } else { a() } function a() { $flashobj.imgarr.shift(); if ($flashobj.imgarr.length > 0) { $flashobj.prebind($flashobj.imgarr[0]) } else { $flashobj.setshow() } } }, setController: function (a) { if (a.isFlash) { if (a.isFlash.show) { } else { if (a.isFlash.hide) { $("#swfobjlayer").get(0).viddlerPause(); $($flashobj.rotating).css("display", "block"); $($flashobj.banners).css("display", "block"); $($flashobj.banners).animate({ top: "0px" }, 600, function () { swfobject.removeSWF($flashobj.flashHandler._var.id) }); $("#controller #banners").animate({ top: "0px" }, 600, function () { $flashobj.rotationNation.bindAnimation() }) } } } else { $($flashobj.loading).css("display", "none"); $flashobj.rotationNation._var.curIndexText = $("#feedback").find("#currentIndex"); $flashobj.rotationNation._var.curIndexText.text("1"); $("#feedback").find("#totalCount").text($flashobj.rotationNation._var.mod); $("#controller").css({ visibility: "visible", "z-index": "9000", opacity: "0" }).animate({ top: (function () { return ($("#Rotater").children("a").eq(0).children("img").outerHeight() - Math.round((($("#Rotater").children("a").eq(0).children("img").outerHeight()) * 0.095) * 1) / 1 + "px") })() }, { duration: 500, queue: false }).animate({ opacity: a }, 800, $flashobj.init.callback) } }, setshow: function () { var f = swfobject.getFlashPlayerVersion(); var b = navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]; var e = 0; var g = $flashobj.banners; var a = $flashobj.loading; for (i = 0; i < $flashobj.preloaded.length; i++) { if ($flashobj._data[i].type == "video") { if (!(b) && !(f.major)) { continue } var d = $("<a/>", { id: "bannerRotation_" + i, videoId: $flashobj._data[i].video_id, calloutType: "video", open_lightbox: $flashobj._data[i].open_lightbox, lbheight: $flashobj._data[i].height, lbwidth: $flashobj._data[i].width }) } else { if ($flashobj._data[i].type == "localVideo") { if (!(b) && !(f.major)) { continue } var d = $("<a/>", { id: "bannerRotation_" + i, index: i, calloutType: "localVideo" }) } else { var d = $("<a/>", { id: "bannerRotation_" + i, calloutType: $flashobj._data[i].type, target: $flashobj._data[i].target }); if ($flashobj._data[i].link_href != "") { d.attr("href", $flashobj._data[i].link_href) } } } $flashobj.rotationNation._var.mod++; $($flashobj.preloaded[i]).appendTo("#Rotater"); $("#Rotater").find("img").last().wrap(d); if ($flashobj._data[i].type == "text") { var c = '<span class="overlay">'; c += $flashobj._data[i].overlay_title ? "<strong>" + $flashobj._data[i].overlay_title + "</strong>" : ""; c += $flashobj._data[i].overlay_text ? $flashobj._data[i].overlay_text : ""; c += $flashobj._data[i].overlay_link ? '<span class="link">' + $flashobj._data[i].overlay_link + "</span>" : ""; c += "</span>"; $("#Rotater").find("img").last().after(c); $flashobj.rotationNation._var.timer = 8000 } } if ($flashobj.rotationNation._var.mod > 0) { $("#Rotater").css("position", "relative"); $(a).animate({ opacity: 0 }, 1000, function () { $flashobj.rotationNation._var.mod > 1 ? $flashobj.setController("1") : $flashobj.setController("0") }); $(g).css({ visibility: "visible", "z-index": "0" }) } else { $($flashobj.noflash).css({ visibility: "visible", display: "block", opacity: "0" }).animate({ opacity: "1" }, 800); $($flashobj.rotating).css("display", "none"); $($flashobj.banners).css("display", "none") } }, startShow: function () { $flashobj.rotationNation._var.mod--; $flashobj.rotationNation._var.width = $("#Rotater").children("a").eq(0).children("img").outerWidth(); $flashobj.rotationNation._var.height = $("#Rotater").children("a").eq(0).children("img").outerHeight(); $("#Rotater").css({ width: $flashobj.rotationNation._var.width, height: $flashobj.rotationNation._var.height }); var a = 0; while ($("#Rotater").find("a")[a]) { if (a != 0) { $($("#Rotater").find("a")[a]).css({ display: "none" }) } $($("#Rotater").find("a")[a]).css({ top: function () { if (a * $flashobj.rotationNation._var.height) { return "-" + a * $flashobj.rotationNation._var.height + "px" } }, "z-index": ($flashobj.rotationNation._var.mod + 1) - a }).data("zIndex", ($flashobj.rotationNation._var.mod + 1) - a); if (a != 0) { $($("#Rotater").find("a")[a]).css({ display: "block" }) } a++ } $flashobj.rotationNation.start() }, flashHandler: { _var: { embedded: false, id: "swfobjlayer" }, embed: function (g) { leadForm.event.kill(); this.embed.callback = function (p, n, o, x, t, v, w, u, q, r, s) { $("<div id='" + n + "'></div>").appendTo($("#FlashLayer")); if (t == "True") { swfobject.embedSWF(p, n, w, v, u, "", q, r, s, function (y) { if (y.success) { $.colorbox({ inline: "true", href: "#FlashLayer", width: parseInt(w) + 90, height: parseInt(v) + 90 }) } }) } else { swfobject.embedSWF(p, n, o, x, u, "", q, r, s, function (y) { if (y.success) { $($flashobj.banners).css("display", "none"); $("#FlashLayer").css("display", "block"); $($flashobj.banners).animate({ top: "-" + $flashobj.rotationNation._var.height + "px" }, 600, function () { $flashobj.setController({ isFlash: { show: {}} }) }); $("#controller #banners").animate({ top: "-27px" }, 600) } }) } }; $flashobj.rotationNation.killAnimation(); var c = "http://www.viddler.com/simple/key"; var a = $flashobj.flashHandler._var.id; var b = $flashobj.rotationNation._var.width; var m = $flashobj.rotationNation._var.height; var h = g.open_lightbox; var l = g.lbwidth == "" ? 545 : g.lbwidth; var k = g.lbheight == "" ? 349 : g.lbheight; var j = "9.0.0"; var d = { key: g.videoid, optNoTopMenu: "1", autoplay: "t", enablecallbacks: "t", activecolor: "#8cd0ef", inactivecolor: "#FFFFFF", hovercolor: "#1c9bd4", barcolor: "#553318", whichbar: "0" }; var e = { align: "middle", allowscriptaccess: "always", allownetworking: "all", allowfullscreen: "true", scale: "scale", quality: "high", wmode: "transparent", bgcolor: "#000000" }; var f = {}; $flashobj.flashHandler.embed.callback(c, a, b, m, h, k, l, j, d, e, f) }, remove: function () { leadForm.event.setTimer(); $flashobj.setController({ isFlash: { hide: {}} }) }, callbacks: { started: function () { }, ended: function () { $flashobj.flashHandler.remove() }, paused: function () { } }} }; function bannerVidApi(a) { switch (a) { case "playlistFinished": remoteControl("stop"); break; case "stopped": resumeShow(); break; default: break } } function killVideo() { remoteControl("stop") } function resumeShow() { $("#bannerBackground").css("visibility", "hidden").hide(); $("#Rotater").fadeIn("slow"); $("#primaryControls").fadeIn("slow"); $("#pauseControl").fadeIn("slow"); $("#closeFlash").fadeOut("slow"); $flashobj.rotationNation.pause("resume") } function playStarted() { $flashobj.flashHandler.callbacks.started() } function playEnded() { $flashobj.flashHandler.callbacks.ended() } function playPaused() { $flashobj.flashHandler.callbacks.paused() };
