var ad = { adSplash: { adID: null, sizeID: null, keyword: null, createAd: function(inAdID, inSizeID, arg) { this.adID = inAdID; this.sizeID = inSizeID; if (arg) { this.keyword = arg.keyword ? arg.keyword : "" } document.write('<div id="aje_' + this.adID + '"></div>') }, generateScript: function() { if (this.adID != null) { var output = ""; output += '<script  type="text/javascript" language="JavaScript">var aj_server ="http://rotator.adjuggler.com/servlet/ajrotator/";var aj_tagver = "1.0";var aj_zone = "adsplash";var aj_adspot = "' + this.adID + '";var aj_page = "0";var aj_dim = "' + this.sizeID + '";var aj_ch = "";var aj_ct = "";var aj_kw = "' + this.keyword + '";var aj_pv = true;var aj_click = "";<\/script>'; output += '<script id="aje_scr_' + this.adID + '" type="text/javascript" language="JavaScript" src="http://img1.cdn.adjuggler.com/banners/async-ajtg.js"><\/script>'; $("#adSplashContainer").attr("id", "aje_tmp_" + this.adID); document.write(output) } } } }; var api = { search: function(cat, keyword, cb, args) { args = args || {}; defaults = { lang: "en-ca", page: 1, pageSize: 24, sortDir: "asc", format: "json", urlType: "friendly" }; args = $.extend(defaults, args); var that = this, sLangPath = (args.lang.toLowerCase() == "en-ca") ? "/en-CA" : "/fr-CA", url = (args.urlType.toLowerCase() == "phsyical") ? "/projects/api/search.aspx?" : sLangPath + "/api/search/products()?", qs = "&lang=" + args.lang + "&format=" + args.format + ((args.cat) ? "&categoryid=" + args.cat : "") + ((args.keyword) ? "&query=" + escape(args.keyword) : "") + ((args.facets) ? "&include=facets" : "") + ((args.facetpath) ? "&facetpath=" + escape(args.facetpath) : ""), pagination = "&page=" + args.page + "&pageSize=" + args.pageSize + "&sortdir=" + args.sortDir + ((args.sortBy) ? "&sortby=" + args.sortBy : ""); this.keyword = keyword; this.page = args.page; this.pageSize = args.pageSize; this.sortDir = args.sortDir; this.sortBy = (args.sortBy) ? args.sortBy : null; this.facetPath = (args.facetpath) ? args.facetpath : null; this.args = args; this.gotoPage = function(cb, page, size, sort, dir) { pagination = "&page=" + ((page) ? page : this.page) + "&pageSize=" + ((size) ? size : this.pageSize) + "&sortdir=" + ((dir) ? dir : this.sortDir) + ((sort) ? "&sortby=" + sort : ((this.sortBy) ? "&sortby=" + this.sortBy : "")) + ((args.format == "jsonp") ? "&jsoncallback=?" : ""); $.getJSON(url + qs + pagination, null, function(data, results) { cb(data, results) }) }; this.gotoPage(cb); return this }, product: function(sku, cb, args) { args = args || {}; defaults = { reviews: false, lang: "en-ca", include: null, format: "json" }; args = $.extend(defaults, args); var subcalls = (args.reviews) ? "reviews" : "product", url = "/" + args.lang + "/api/" + subcalls + "/" + sku + ".aspx?", qs = ((args.include) ? "include=" + args.include : "") + ((args.format == "jsonp") ? "&format=jsonp&jsoncallback=?" : "&format=" + args.format); $.getJSON(url + qs, null, function(data, results) { cb(data, results, args) }) } }; var api2 = { search: function(args) { var defaults = { cat: null, kw: null, upc: null, lang: "en", page: 1, pageSize: 24, sortDir: "asc", sortBy: null, format: "json", path: "", filter: "", include: null, requestObj: {}, cb: null, onStart: function() { }, jsonCallback: "", domain: "", singleCall: true }, scID = 0, scsID = 0; args = $.extend(true, defaults, args); args = $.extend(true, args, args.requestObj); this.update = function(options) { scID++; args = $.extend(true, args, options); args.requestObj = args; var url = args.domain + "/api/v2/" + (args.format == "jsonp" ? "json" : args.format) + "/search" + (args.upc ? "/upc/" + args.upc : "") + "?" + (args.lang.toLowerCase() == "fr" || args.lang.toLowerCase() == "fr-ca" ? "lang=fr&" : "") + (args.cat ? "categoryid=" + args.cat + "&" : "") + (args.query ? "query=" + args.query + "&" : "") + ("page=" + args.page + "&") + ("pagesize=" + args.pageSize + "&") + (args.sortBy ? "sortby=" + args.sortBy + "&" : "") + (args.sortDir ? "sortdir=" + args.sortDir + "&" : "") + (args.filter ? "filter=" + args.filter + "&" : "") + (args.path ? "path=" + escape(args.path) + "&" : "") + (args.include ? "include=" + args.include + "&" : "") + (args.format.toLowerCase() == "jsonp" ? "callback=" + (args.jsonCallback ? args.jsonCallback : "?") : ""); args.onStart(); if (args.jsonCallback) { window[args.jsonCallback] = "" } $.ajax({ dataType: args.format.toLowerCase(), data: null, jsonp: "callback", url: url, success: function(data, results) { scsID++; if ((scID == scsID) || !args.singleCall) { args.cb(data, results) } } }) }; this.update(); this.getRQ = function() { return args.requestObj }; return this } }; var util = { uagent: navigator.userAgent.toLowerCase(), browser: { isIE: function(args) { args = args || {}; if (/MSIE (\d+\.\d+);/i.test(util.uagent)) { if ((Number(args.ver) == 6 && Number(RegExp.$1) == 6) || !args.ver) { return true } } return false } }, device: { isApple: function(args) { args = args || {}; if (args.devices) { var ary = String(args.devices).split(","); for (var i in ary) { if (util.uagent.search(ary[i]) > -1) { return true } } } else { if (util.uagent.search(/ipod|ipad|iphone/) > -1) { return true } } return false }, isAndroid: function(args) { args = args || {}; if (util.uagent.search(/android/) > -1) { return true } return false }, isBlackberry: function(args) { args = args || {}; if (util.uagent.search(/blackberry/) > -1) { return true } return false }, isWindowsPhone: function(args) { args = args || {}; if (util.uagent.search(/windows phone/) > -1) { return true } return false }, isTouchEnabled: function(args) { args = args || {}; return ("ontouchstart" in document.documentElement) } }, view: { getSize: function() { var winWidth = 0, winHeight = 0; if (typeof ($(window).width()) == "number") { winWidth = $(window).width(); winHeight = $(window).height() } else { if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { winWidth = document.documentElement.clientWidth; winHeight = document.documentElement.clientHeight } } return { width: winWidth, height: winHeight} }, getScrollY: function() { var scrOfY = 0; if (typeof (window.pageYOffset) == "number") { scrOfY = window.pageYOffset } else { if (document.body && document.body.scrollTop) { scrOfY = document.body.scrollTop } else { if (document.documentElement && document.documentElement.scrollTop) { scrOfY = document.documentElement.scrollTop } } } return scrOfY }, getDocSize: function() { return { width: Math.max($(document).width(), $(window).width(), document.documentElement.clientWidth), height: Math.max($(document).height(), $(window).height(), document.documentElement.clientHeight)} } }, url: { qs: function(item) { var value = location.search.match(new RegExp("[?&]" + item + "=([^&]*)(&?)", "i")); return value ? value[1] : value }, prodImage: function(sku, args) { args = args || {}; var size = (args.size) ? String(args.size) : false; size = size ? (size.search("x") > -1 ? size : size + "x" + size) : "55x55"; return sku ? (args.host ? args.host : "") + "/multimedia/products/" + size + "/" + sku.substr(0, 3) + "/" + sku.substr(0, 5) + "/" + sku + ".jpg" : "" } }, countdown: function(target, args) { args = args || {}; var that = this; var msSec = 1000, msMin = 60 * msSec, msHour = 60 * msMin, msDay = 24 * msHour; var now = new Date(); var diff = target - now.getTime(); var onTick = (args.onTick) ? args.onTick : function(e) { }; var onFinish = (args.onFinish) ? args.onFinish : function(e) { }; this.days = this.hours = this.mins = this.secs = 0; this.start = function() { if (diff < 1) { return onFinish(this) } var temp = diff; this.days = Math.floor(temp / msDay); this.hours = Math.floor((temp -= (msDay * this.days)) / msHour); this.mins = Math.floor((temp -= (msHour * this.hours)) / msMin); this.secs = Math.floor((temp -= (msMin * this.mins)) / msSec); onTick(this); diff -= 1000; setTimeout(arguments.callee, 1000) } }, cookie: { getCookie: function(name) { var i, x, y, cookies = document.cookie.split(";"); for (i = 0; i < cookies.length; i++) { x = cookies[i].substr(0, cookies[i].indexOf("=")); y = cookies[i].substr(cookies[i].indexOf("=") + 1); x = x.replace(/^\s+|\s+$/g, ""); if (x == name) { return unescape(y) } } }, createCookie: function(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString() } else { var expires = "" } document.cookie = name + "=" + value + expires + "; path=/" }, eraseCookie: function(name) { createCookie(name, "", -1) } } }; var track = { ab_icmp: function(args) { var defaults = { cookiename: "", duration: 30, variations: [], version: "" }; args = $.extend(true, defaults, args); var currentloc = window.location.toString(); if (!util.url.qs("ICMP")) { var icmp, ver, createCookie = true; if (util.cookie.getCookie(args.cookiename)) { ver = util.cookie.getCookie(args.cookiename).split("|")[0]; icmp = util.cookie.getCookie(args.cookiename).split("|")[1]; if (ver == args.version) { createCookie = false } } ver = args.version; var random = Math.floor(Math.random() * 100), diff = 0; for (var i = 0; i < args.variations.length; i++) { var obj = args.variations[i]; if (createCookie) { if (random < diff + obj.ratio) { icmp = obj.icmp; util.cookie.createCookie(args.cookiename, ver + "|" + icmp, args.duration); url = (currentloc.search(/fr-ca/i) > -1) ? (obj.urlfr ? obj.urlfr : obj.url) : obj.url; break } else { diff += obj.ratio } } else { if (obj.icmp == icmp) { url = (currentloc.search(/fr-ca/i) > -1) ? (obj.urlfr ? obj.urlfr : obj.url) : obj.url } } } var redir = url ? url : currentloc; if (icmp) { window.location = redir + ((redir.search(/\?/) < 0) ? "?" : "&") + "ICMP=" + icmp } } return icmp } }; var ui = { lightbox: { init: function(obj, args) { args = args || {}; var that = this, dimmer = new ui.pageDimmer.init(); dimmer.click(function() { that.hide() }); this.lightboxdiv = $('<div class="ui-lightbox2"></div>').append($('<div class="content"></div>')).append($('<div class="controls"></div>').append($('<a class="close" href="#"></a>').html("close").click(function() { that.hide(); return false })).append($('<a class="prev advance" href="#"></a>').html("previous").click(function() { that.gotoIndex("prev"); return false })).append($('<a class="next advance" href="#"></a>').html("next").click(function() { that.gotoIndex("next"); return false }))).appendTo($("body")); if (obj.length < 2 || args.disableControls) { this.lightboxdiv.find(args.disableControls ? ".controls" : ".controls .advance").remove() } args.id && this.lightboxdiv.attr("id", args.id); args.cssClass && this.lightboxdiv.addClass(args.cssClass); this.current = 1; obj.each(function(index) { var $this = $(this), url = $this.attr("href"); $this.attr("href", "#").click(function() { var offsetHeight = util.view.getSize().height - that.lightboxdiv.outerHeight() + that.lightboxdiv.innerHeight(), offsetWidth = util.view.getSize().width - that.lightboxdiv.outerWidth() + that.lightboxdiv.innerWidth(), minHeight = 100, minWidth = 100; var positionDiv = function(ele, width, height, options) { options = options || {}; height = height > minHeight ? height : minHeight; width = width > minWidth ? width : minWidth; var dimention = { top: (offsetHeight - height) / 2 < 10 ? 10 + util.view.getScrollY() : (offsetHeight - height) / 2 + util.view.getScrollY(), left: (offsetWidth - width) / 2 < 10 ? 10 : (offsetWidth - width) / 2, width: width, height: height }; if (ele && !args.disableAnimation) { that.lightboxdiv.find(".content").empty().andSelf().show().animate(dimention, 400, function() { $(this).find(".content").hide().html(ele).fadeIn(); options.callback && options.callback() }) } else { that.lightboxdiv.show().css(dimention).find(".content").html(ele ? ele : ""); options.callback && options.callback() } args.positionControls && args.positionControls(dimention); dimmer.show() }; !that.lightboxdiv.is(":visible") && positionDiv(null, 100, 100); if (url.match(/([^\/\\]+)\.(jpg|jpeg|gif|png)$/i)) { $("<img></img>").one("load", function() { positionDiv($(this), $(this).attr("width"), $(this).attr("height")) }).attr("src", url).each(function() { this.complete && $(this).trigger("load") }) } else { if (url.match(/(^#.{1,})/i)) { positionDiv($(url).html(), $(url).width(), $(url).height()) } else { if (url.match(/([^\/\\]+)\.(swf)/i)) { var swfWidth = ($(this).attr("data-size")) ? $(this).attr("data-size").split("x")[0] : 100, swfHeight = ($(this).attr("data-size")) ? $(this).attr("data-size").split("x")[1] : 100; positionDiv($('<div id="flashdiv"></div>'), swfWidth, swfHeight, { callback: function() { swfobject.embedSWF(url, "flashdiv", swfWidth, swfHeight, "9.0.0", null, null, { wmode: "transparent" }) } }) } } } that.current = index + 1; return false }) }); this.hide = function() { this.lightboxdiv.hide().find(".content").html(""); dimmer.hide() }; this.gotoIndex = function(index) { index == "next" ? $(obj[this.current == 1 ? obj.length - 1 : this.current - 2]).trigger("click") : index == "prev" && $(obj[this.current == obj.length ? 0 : this.current]).trigger("click"); if (index < obj.length) { $(obj[index]).trigger("click") } }; return this } }, SlideShow: { init: function(wrapper, slides, args) { var that = this, defaults = { startingSlide: 1, wrapSlides: true, defaultTransition: ui.transition.none, controls: ui.controls.simple, controlPanel: $('<div class="pnl-controls"></div>').prependTo($(wrapper)) }; args = $.extend(defaults, args); this.current = 0; this.transition = args.defaultTransition; this.slides = ($.isArray(slides)) ? slides : (function() { var tempArray = new Array; $(slides).children().each(function() { tempArray.push(new ui.SlideShow.slide($(this))) }); return tempArray })(); this.total = this.slides.length; this.next = function() { if (this.current < this.total) { this.gotoSlide(this.current + 1) } else { if (args.wrapSlides) { this.gotoSlide(1) } } }; this.prev = function() { if (this.current > 1) { this.gotoSlide(this.current - 1) } else { if (args.wrapSlides) { this.gotoSlide(this.total) } } }; this.gotoSlide = function(index, args) { args = args || {}; if (this.current != index) { var slide = this.slides[index - 1]; var transition = (!slide.transition) ? this.transition : slide.transition; transition.exec(this.slides, (this.current < 1) ? 1 : this.current - 1, index - 1, args); this.current = index; this.controls.update() } }; this.controls = new args.controls(args.controlPanel, this); this.start = function() { this.gotoSlide(args.startingSlide) } }, slide: function(elem, args) { args = args || {}; this.interval = null; this.transition = args.transition; this.onReady = function() { }; this.ready = function(fn) { this.onReady = fn }; this.obj = elem } }, timer: {}, progessIndicator: {}, transition: { none: { exec: function(array, currentIndex, targetIndex) { var t = array[targetIndex]; var c = array[currentIndex]; $(c.obj).hide(); $(t.obj).show(0, function() { t.onReady() }) } } }, controls: { none: function() { return null }, simple: function(wrapper, obj, args) { this.update = function() { }; $(wrapper).append($('<a href="#" class="btnPrev">prevous</a>').click(function() { obj.prev() })).append($('<a href="#" class="btnNext">next</a>').click(function() { obj.next() })) } }, slideshow: function() { this.divid = ""; this.slides = []; this.params = []; this.controls = []; this.numSlides = 0; this.progressBar = null; this.globalTimer = null; this.interval = []; this.curr = { paused: false, currSlide: 0, prevSlide: 0, timer: null }; this.utils = { tmpNavItem: 0 }; this.init = function(divid, slides, controls, params, bubbles) { this.divid = divid; this.slides = slides; this.controls = controls; this.params = params; this.bubbles = bubbles; var wrapperCss = { overflow: "hidden", width: this.params.width, position: "relative" }; this.prepareSlides(); this.prepareControls(); this.controls.enableTracking ? this.activateTracking() : false; var containerCss = { width: this.numSlides * this.params.width, left: 0, position: "relative" }; $("#" + this.divid).css(wrapperCss); $("#" + this.divid + " ul.slides").css(containerCss); this.buildNavigation(); this.globalTimer = new ui.GlobalTimer(); this.globalTimer.start(); this.start(); return this }; this.prepareControls = function() { this.ensureDefaults(); this.params.previous.id ? this.addControl("previous") : false; this.params.pause.id ? this.addControl("pause") : false; this.params.next.id ? this.addControl("next") : false; this.controls.enableProgressBar ? this.addControl("progressBar") : false; this.controls.enableBubbles ? this.prepareBubbles() : false; (this.params.slideDate == null) && (this.params.slideDate = "unknown") }; this.ensureDefaults = function() { if (this.controls.enableProgressBar == undefined) { this.controls.enableProgressBar = true } if (this.controls.enableBubbles == undefined) { this.controls.enableBubbles = true } if (this.controls.enableTracking == undefined) { this.controls.enableTracking = true } if (this.controls.enableProgressBuffer == undefined) { this.controls.enableProgressBuffer = true } }; this.start = function(timeLeft) { obj = this; go = function() { obj.go() }; this.timer = setTimeout(go, timeLeft ? timeLeft : this.getTimeout()) }; this.addControl = function(controlName) { var html = ""; switch (controlName) { case "progressBar": tempHtml = '<div id="' + this.params.progressBar.id + '"></div>'; $("#" + this.divid + " .slideshowControls").append(tempHtml); this.progressBar = new ui.ProgressBar(); this.progressBar.init("#" + this.params.progressBar.id, this.params.interval); this.progressBar.reset(this.getTimeout()); break; case "previous": html = '<a id="' + this.params.previous.id + '">' + this.params.previous.html + "</a>"; break; case "next": html = '<a id="' + this.params.next.id + '">' + this.params.next.html + "</a>"; break; case "pause": html = '<a id="' + this.params.pause.id + '">' + this.params.pause.onPlayHtml + "</a>"; break; default: break } if (html != "") { $("#" + this.divid + " .slideshowControls").append(html) } }; this.prepareSlides = function() { var slideCount = 0; var slides = this.slides; var sh = this; slideCss = { width: this.params.width, height: this.params.height, display: "block", cssFloat: "left", position: "relative" }; $.each(this.slides, function(i, v) { if (v.customInterval) { sh.interval[slideCount] = v.customInterval } else { sh.interval[slideCount] = sh.params.interval } $("#" + v.id).css(slideCss); slideCount++ }); this.numSlides = slideCount }; this.buildNavigation = function() { sh = this; $(this.params.navigation).children().each(function(i) { $(this).click(function() { var slide = $(this).index(); sh.pause(); sh.flip(slide); return false }); $(this).mouseenter(function() { var slide = $(this).index(); $(this).find(".tooltip").fadeIn() }); $(this).mouseleave(function() { var slide = $(this).index(); $(this).find(".tooltip").stop(true, true); $(this).find(".tooltip").fadeOut() }) }) }; this.flip = function(flipTo) { this.curr.prevSlide = this.curr.currSlide; if (flipTo != undefined) { this.curr.currSlide = flipTo } else { this.curr.currSlide++ } if (this.curr.currSlide >= (this.numSlides)) { this.curr.currSlide = 0 } this.globalTimer.reset(); if (this.progressBar) { this.progressBar.reset(this.getTimeout()) } if (this.curr.paused) { this.globalTimer.stop(); if (this.progressBar) { this.progressBar.stop() } } $(this.params.navigation); var position = this.curr.currSlide * this.params.width; this.defaultTransition(this.divid, position) }; this.defaultTransition = function(divId, position) { sh = this; $("#" + this.divid + " ul.slides").fadeOut(sh.params.transitionSpeed / 2, function() { $("#" + divId + " ul.slides").css("left", position * -1); $("#" + sh.divid + " ul.slides").fadeIn(sh.params.transitionSpeed / 2) }) }; this.getTimeout = function() { return this.interval[this.curr.currSlide] }; this.pause = function() { clearTimeout(this.timer); this.curr.paused = true; $("#" + this.params.pause.id).html(this.params.pause.onPauseHtml); if (this.progressBar) { this.progressBar.stop() } this.globalTimer.stop() }; this.resume = function() { var timeLeft = this.getTimeout() - this.globalTimer.timer; if (timeLeft < this.params.buffer) { timeLeft = this.params.buffer; if (this.progressBar) { this.progressBar.bumpProgress(timeLeft) } } this.curr.paused = false; this.start(timeLeft); $("#" + this.params.pause.id).html(this.params.pause.onPlayHtml); if (this.progressBar) { this.progressBar.resume(timeLeft) } this.globalTimer.start() }; this.prev = function() { var slide = ((this.curr.currSlide - 1) < 0) ? this.numSlides - 1 : this.curr.currSlide - 1; this.pause(); this.flip(slide) }; this.next = function() { this.pause(); this.flip() }; this.go = function() { clearTimeout(this.timer); if (!this.curr.paused) { this.flip() } obj = this; go = function() { obj.go() }; this.timer = setTimeout(go, this.getTimeout()) }; this.prepareBubbles = function() { sh = this; $("#" + this.divid + " .bubble").each(function() { var timer = null, elemObj = $(this); elemObj.wrapInner('<div class="bubbleInsert" />'); elemObj.wrapInner('<div class="bubbleContent" />'); elemObj.prepend('<div class="indicator"></div>'); elemObj.mouseenter(function() { clearTimeout(timer); elemObj.css("z-index", "2000"); $(".bubbleContent", this).show("fast"); if (elemObj.attr("id") != null && elemObj.attr("id").length > 0) { this.trackEvent(sh.params.trackingPrefix + sh.params.slideDate + "_S" + (elemObj.parent().index() + 1) + "_bubble_" + elemObj.attr("id")) } else { this.trackEvent(sh.params.trackingPrefix + sh.params.slideDate + "_S" + (elemObj.parent().index() + 1) + "_bubble_" + elemObj.parent().attr("id")) } sh.pause() }); elemObj.mouseleave(function() { bubble = this; var hide = function() { $(".bubbleContent", bubble).hide("fast", function() { $(bubble).css("z-index", "1000") }) }; timer = setTimeout(hide, sh.params.bubbleBuffer) }) }) }; this.activateTracking = function() { sh = this; $("#" + this.divid + " .slides .trackable").each(function() { $(this).click(function() { if ($(this).attr("id") && $(this).attr("href")) { sh.trackEvent(sh.params.trackingPrefix + sh.params.slideDate + "_S" + ($(this).closest("li").index() + 1) + "_" + $(this).attr("id"), $(this).attr("href")); return false } }) }) }; this.trackEvent = function(linkId, xurl) { trackEvent.event("event.link", { lid: linkId }); if (xurl && xurl != "#") { window.location = xurl } } }, ProgressBar: function() { this.divId = ""; this.time = 0; this.rollerWidth = 0; this.init = function(divId) { this.divId = divId; $(this.divId).html('<div id="roller"></div>'); this.rollerWidth = $(this.divId + " #roller").width() }; this.reset = function(time) { var css = { width: 0 }; this.stop(); this.time = time; $(this.divId + " #roller").css("width", "auto"); $(this.divId + " #roller").animate(css, this.time, "linear") }; this.stop = function() { $(this.divId + " #roller").stop(false, false) }; this.resume = function(time) { var css = { width: 0 }; $(this.divId + " #roller").animate(css, time, "linear") }; this.bumpProgress = function(ms) { var futureWidth = this.rollerWidth / this.time * ms; $(this.divId + " #roller").width(futureWidth) } }, GlobalTimer: function() { this.timer = 0; this.looper = null; this.interval = 1000; this.start = function() { clearTimeout(this.looper); var obj = this; var go = function() { obj.updateTimer() }; this.looper = setTimeout(go, this.interval) }; this.stop = function() { clearTimeout(this.looper) }; this.reset = function() { clearTimeout(this.looper); this.timer = 0; this.start() }; this.updateTimer = function() { this.timer += this.interval; var obj = this; var go = function() { obj.updateTimer() }; this.looper = setTimeout(go, this.interval) } }, TabControl: function(obj, cb, args) { if ($(obj).data("ref")) { return false } args = args || {}; var that = this; var tabs = (args.tabs) ? args.tabs : $(obj).find(".ui-tabcontrol-tabs"); var contents = (args.contents) ? args.contents : $(obj).find(".ui-tabcontrol-contents"); var preSelectedTab = tabs.find(".selected"); this.index = (preSelectedTab.length > 0) ? preSelectedTab.index() + 1 : 1; this.index = (args.index) ? args.index : this.index; this.total = tabs.children().length; this.contents = contents; this.tabs = tabs; this.gotoTab = function(index) { if (index > 0 && index < this.total + 1) { tabs.children().removeClass("selected hover").eq(index - 1).addClass("selected"); contents.children().removeClass("selected").eq(index - 1).addClass("selected"); this.index = index; if (cb) { cb(that, that.index) } return true } else { return false } }; this.gotoTab(this.index); this.next = function() { this.gotoTab((this.index == this.total) ? 1 : this.index + 1) }; this.previous = function() { this.gotoTab((this.index == 1) ? this.total : this.index - 1) }; tabs.each(function() { $(this).children().each(function(index, value) { $(this).find("a").click(function() { that.gotoTab(index + 1); return false }); $(this).hover(function() { if (!$(this).hasClass("selected")) { $(this).addClass("hover") } }, function() { if (!$(this).hasClass("selected")) { $(this).removeClass("hover") } }) }) }); contents.find(".ui-tabcontrol-next").click(function() { that.next() }).end().find(".ui-tabcontrol-previous").click(function() { that.previous() }); $(obj).data("ref", this); return this }, pageDimmer: { init: function(args) { args = args || {}; var that = this, obj = $('<div class="ui-page-dim"></div>').click(function() { that.hide(); return false }).appendTo($("body")); if (args.id) { obj.attr("id", args.id) } if (args.cssClass) { obj.addClass(args.cssClass) } this.show = function() { obj.width($(document).width()).height($(document).height()).show() }; this.hide = function() { obj.hide() }; this.click = function(fn) { obj.click(function() { fn() }) }; return this } }, equaliseByRow: function(jqObj, args) { var largest = 0, current = 0, defaults = { container: "prod-orient-ver", rowItemClass: "content", currentIndex: 0, rowMaxItems: null, rowEndClass: "last", setQL: false, setQLClass: "featureproduct" }; args = $.extend(defaults, args); var rowObjs = jqObj.find("." + args.rowItemClass); if (args.rowMaxItems == null) { jqObj.find("." + args.container).each(function(index, elem) { if ($(elem).attr("class").search(args.rowEndClass) > 0) { args.rowMaxItems = index + 1; return false } }); ((args.rowMaxItems == null) && (args.rowMaxItems = rowObjs.length)) } if (args.currentIndex < rowObjs.length) { for (var i = args.currentIndex; ((i < rowObjs.length) && (i < (args.currentIndex + args.rowMaxItems))); i++) { current = rowObjs.eq(i).height(); if (args.setQL == true) { var parentClass = rowObjs.eq(i).parent(), calcPaddingQL = 0; if ((typeof parentClass.attr("class") === "string") && parentClass.attr("class").search(args.setQLClass) != -1) { if (typeof args.setQLPadding !== "number") { calcPaddingQL = ((parentClass.find(".top:first").height()) + (parentClass.find(".bottom:first").height())) } else { calcPaddingQL = args.setQLPadding } current = current + calcPaddingQL } } largest = (current > largest) ? current : largest } for (var i = args.currentIndex; ((i < rowObjs.length) && (i < (args.currentIndex + args.rowMaxItems))); i++) { var temp = largest; if (args.setQL == true) { var parentClass = rowObjs.eq(i).parent(), calcPaddingQL = 0; if ((typeof parentClass.attr("class") === "string") && parentClass.attr("class").search(args.setQLClass) != -1) { if (typeof args.setQLPadding !== "number") { calcPaddingQL = ((parentClass.find(".top:first").height()) + (parentClass.find(".bottom:first").height())) } else { calcPaddingQL = args.setQLPadding } temp = largest - calcPaddingQL } } rowObjs.eq(i).height(temp) } rowObjs = null; args.currentIndex = args.currentIndex + args.rowMaxItems; this.equaliseByRow(jqObj, args) } } }; var validation = {}; var widget = { social: function() { this.init = function(args) { args = $.extend({ width: 90, height: 20, lang: "en", url: "", container: "socialBookmark" }, args); var container = $("#" + args.container); args.width = args.width + (args.lang == "fr" ? 15 : 0); args.url = encodeURI(args.url); container.find(".twitter").html('<iframe allowtransparency="true" frameborder="0" scrolling="no" src="//platform.twitter.com/widgets/tweet_button.html?url=' + args.url + "&lang=" + args.lang + '" style="width:' + args.width + "px; height:" + args.height + 'px;"></iframe>'); container.find(".fblike").html('<iframe src="//www.facebook.com/plugins/like.php?locale=' + (args.lang == "fr" ? "fr_FR" : "en_US") + "&href=" + args.url + "&amp;send=false&amp;layout=button_count&amp;width=" + args.width + "&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=" + args.height + '" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:' + args.width + "px; height:" + args.height + 'px;" allowTransparency="true"></iframe>'); var renderPlusOne = function() { container.find(".gplusone").html('<div id="gplusone' + args.container + '" data-url="' + args.url + '"></div>'); gapi.plusone.render("gplusone" + args.container, { size: "Medium", href: args.url }) }; if (typeof (gapi) === "undefined") { $.ajax({ url: "https://apis.google.com/js/plusone.js", dataType: "script", parameters: { parsetags: "explicit" }, success: function() { renderPlusOne() } }) } else { renderPlusOne() } }; return this } }; if (typeof (jQuery) != "undefined") { (function($) { $.fn.Bubble = function(args) { var defaults = { hoverFade: true, opacity: 0.5, speedIn: "fast", speedOut: "fast", tracking: true, date: "", padding: 50 }; args = $.extend(defaults, args); var Bubbles = this, allIndicators = $(Bubbles).find(".ui-indicator"), IE = $.browser.msie; (IE) ? Bubbles.show() : Bubbles.fadeIn("slow"); return Bubbles.each(function() { obj = $(this); obj.addClass("ui-bubble"); obj.wrapInner('<div class="ui-bubbleInsert" />'); obj.wrapInner('<div class="ui-bubbleContent" />'); obj.prepend('<div class="ui-indicator"/>'); obj.hover(function() { _this = $(this); var posX = (_this.position()).left, posY = (_this.position()).top, curWidth = _this.parent().width(), curHeight = _this.parent().height(), bubbleContentObj = _this.find(".ui-bubbleContent"), curBubbleWidth = bubbleContentObj.width(), curBubbleHeight = bubbleContentObj.height(); if ((posX + curBubbleWidth + args.padding) > curWidth) { bubbleContentObj.css("left", (-1 * curBubbleWidth)) } if ((posY + curBubbleHeight + args.padding) > curHeight - args.padding) { bubbleContentObj.css("top", (-1 * curBubbleHeight)) } _this.css("z-index", "2000").find(".ui-bubbleContent").fadeIn(args.speedIn); if (args.tracking) { if (_this.attr("id") != null && _this.attr("id").length > 0) { trackEvent.event("event.link", { lid: _this.parent().attr("id") + "_" + args.date + "_bubble_" + _this.attr("id") }) } else { trackEvent.event("event.link", { lid: _this.parent().attr("id") + "_" + args.date + "_bubble_" + _this.parent().attr("id") }) } } if (args.hoverFade) { _this.addClass("hover"); Bubbles.each(function() { var curInd = $(this); if (!curInd.hasClass("hover")) { (IE) ? curInd.stop().hide() : curInd.stop().animate({ opacity: args.opacity }, args.speedOut) } }) } }, function() { var _this = $(this); _this.css("z-index", "170").find(".ui-bubbleContent").fadeOut(args.speedOut); if (args.hoverFade) { (IE) ? Bubbles.removeClass("hover").stop().show() : Bubbles.removeClass("hover").stop().animate({ opacity: 1 }, args.speedIn) } }) }) } })(jQuery); (function($) { $.fn.buildMenu = function(options) { var defaults = { hideFlag: "hide-menu", delayIn: 20, delayOut: 10, sensitivity: 7 }, options = $.extend(defaults, options), resetMenu = function(o) { $(".hover,.hover-link", $(o).parent().find("ul:visible").hide().andSelf()).removeClass("hover hover-link") }, openMenu = function() { resetMenu(this); $("> a", $(this).addClass("hover")).addClass("hover-link"); !$(this).hasClass(options.hideFlag) && $(this).find("> ul").show() }, closeMenu = function() { $(this).parent(".node-0").length > 0 && resetMenu(this) }, config = { sensitivity: options.sensitivity, interval: options.delayIn, over: openMenu, timeout: options.delayOut, out: closeMenu }; return this.each(function() { obj = $(this); obj.find('li:has(ul):not([class*="' + options.hideFlag + '"]) > a').addClass("tree"); obj.addClass("node-0").find("> li > ul").addClass("node-1").andSelf().find("li").hoverIntent(config); return this }) } })(jQuery); (function($) { $.fn.hoverIntent = function(f, g) { var cfg = { sensitivity: 7, interval: 100, timeout: 0 }; cfg = $.extend(cfg, g ? { over: f, out: g} : f); var cX, cY, pX, pY; var track = function(ev) { cX = ev.pageX; cY = ev.pageY }; var compare = function(ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) { $(ob).unbind("mousemove", track); ob.hoverIntent_s = 1; return cfg.over.apply(ob, [ev]) } else { pX = cX; pY = cY; ob.hoverIntent_t = setTimeout(function() { compare(ev, ob) }, cfg.interval) } }; var delay = function(ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); ob.hoverIntent_s = 0; return cfg.out.apply(ob, [ev]) }; var handleHover = function(e) { var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; while (p && p != this) { try { p = p.parentNode } catch (e) { p = this } } if (p == this) { return false } var ev = jQuery.extend({}, e); var ob = this; if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t) } if (e.type == "mouseover") { pX = ev.pageX; pY = ev.pageY; $(ob).bind("mousemove", track); if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout(function() { compare(ev, ob) }, cfg.interval) } } else { $(ob).unbind("mousemove", track); if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout(function() { delay(ev, ob) }, cfg.timeout) } } }; return this.mouseover(handleHover).mouseout(handleHover) } })(jQuery); (function($) { $.fn.buildAccordion = function(options) { var defaults = { hideRest: true, accordClass: "ui-accord", accordHead: "ui-accord-head", accordContent: "ui-accord-content", accordSection: "ui-accord-section", accordSelectedCSS: "selected" }; var options = $.extend(defaults, options); var obj = $(this); obj.addClass(options.accordClass).find("." + options.accordHead).click(function() { if (options.hideRest) { $(this).parents("." + options.accordClass).find("." + options.accordSection).removeClass(options.accordSelectedCSS).find("." + options.accordContent).hide() } if ($(this).parent().hasClass(options.accordSelectedCSS)) { $(this).next(":visible").hide().parent().removeClass(options.accordSelectedCSS) } else { $(this).next(":hidden").show().parent().addClass(options.accordSelectedCSS) } }).next().addClass(options.accordContent).hide(); return false } })(jQuery) };
