﻿/* bui */
(function (a) { function o(b, c) { return parseInt(a.css(b, c)) || 0 } function n(a, b, c) { var d = a.parentNode, e = a.style; var f = (d.offsetWidth - a.offsetWidth) / 2 - o(d, "borderLeftWidth"); var g = (d.offsetHeight - a.offsetHeight) / 2 - o(d, "borderTopWidth"); if (b) e.left = f > 0 ? f + "px" : "0"; if (c) e.top = g > 0 ? g + "px" : "0" } function m(a) { if (!g) return; var b = g[a === true ? g.length - 1 : 0]; if (b) b.focus() } function l(b) { if (b.keyCode && b.keyCode == 9) { if (f && b.data.constrainTabKey) { var c = g; var d = !b.shiftKey && b.target === c[c.length - 1]; var e = b.shiftKey && b.target === c[0]; if (d || e) { setTimeout(function () { m(e) }, 10); return false } } } var h = b.data; if (a(b.target).parents("div." + h.blockMsgClass).length > 0) return true; return a(b.target).parents().children().filter("div.blockUI").length == 0 } function k(b, c, d) { var e = c == window, g = a(c); if (!b && (e && !f || !e && !g.data("blockUI.isBlocked"))) return; if (!e) g.data("blockUI.isBlocked", b); if (!d.bindEvents || b && !d.showOverlay) return; var h = "mousedown mouseup keydown keypress"; b ? a(document).bind(h, d, l) : a(document).unbind(h, l) } function j(b, c, d, e) { b.each(function (a, b) { if (this.parentNode) this.parentNode.removeChild(this) }); if (c && c.el) { c.el.style.display = c.display; c.el.style.position = c.position; if (c.parent) c.parent.appendChild(c.el); a(e).removeData("blockUI.history") } if (typeof d.onUnblock == "function") d.onUnblock(e, d) } function i(b, c) { var d = b == window; var e = a(b); var h = e.data("blockUI.history"); var i = e.data("blockUI.timeout"); if (i) { clearTimeout(i); e.removeData("blockUI.timeout") } c = a.extend({}, a.blockUI.defaults, c || {}); k(0, b, c); if (c.onUnblock === null) { c.onUnblock = e.data("blockUI.onUnblock"); e.removeData("blockUI.onUnblock") } var l; if (d) l = a("body").children().filter(".blockUI").add("body > .blockUI"); else l = a(".blockUI", b); if (d) f = g = null; if (c.fadeOut) { l.fadeOut(c.fadeOut); setTimeout(function () { j(l, h, c, b) }, c.fadeOut) } else j(l, h, c, b) } function h(c, h) { var j = c == window; var l = h && h.message !== undefined ? h.message : undefined; h = a.extend({}, a.blockUI.defaults, h || {}); h.overlayCSS = a.extend({}, a.blockUI.defaults.overlayCSS, h.overlayCSS || {}); var p = a.extend({}, a.blockUI.defaults.css, h.css || {}); var q = a.extend({}, a.blockUI.defaults.themedCSS, h.themedCSS || {}); l = l === undefined ? h.message : l; if (j && f) i(window, { fadeOut: 0 }); if (l && typeof l != "string" && (l.parentNode || l.jquery)) { var r = l.jquery ? l[0] : l; var s = {}; a(c).data("blockUI.history", s); s.el = r; s.parent = r.parentNode; s.display = r.style.display; s.position = r.style.position; if (s.parent) s.parent.removeChild(r) } a(c).data("blockUI.onUnblock", h.onUnblock); var t = h.baseZ; var u = a.browser.msie || h.forceIframe ? a('<iframe class="blockUI" style="z-index:' + t++ + ';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="' + h.iframeSrc + '"></iframe>') : a('<div class="blockUI" style="display:none"></div>'); var v = h.theme ? a('<div class="blockUI blockOverlay ui-widget-overlay" style="z-index:' + t++ + ';display:none"></div>') : a('<div class="blockUI blockOverlay" style="z-index:' + t++ + ';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>'); var w, x; if (h.theme && j) { x = '<div class="blockUI ' + h.blockMsgClass + ' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:' + (t + 10) + ';display:none;position:fixed">' + '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">' + (h.title || " ") + "</div>" + '<div class="ui-widget-content ui-dialog-content"></div>' + "</div>" } else if (h.theme) { x = '<div class="blockUI ' + h.blockMsgClass + ' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:' + (t + 10) + ';display:none;position:absolute">' + '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">' + (h.title || " ") + "</div>" + '<div class="ui-widget-content ui-dialog-content"></div>' + "</div>" } else if (j) { x = '<div class="blockUI ' + h.blockMsgClass + ' blockPage" style="z-index:' + (t + 10) + ';display:none;position:fixed"></div>' } else { x = '<div class="blockUI ' + h.blockMsgClass + ' blockElement" style="z-index:' + (t + 10) + ';display:none;position:absolute"></div>' } w = a(x); if (l) { if (h.theme) { w.css(q); w.addClass("ui-widget-content") } else w.css(p) } if (!h.theme && (!h.applyPlatformOpacityRules || !(a.browser.mozilla && /Linux/.test(navigator.platform)))) v.css(h.overlayCSS); v.css("position", j ? "fixed" : "absolute"); if (a.browser.msie || h.forceIframe) u.css("opacity", 0); var y = [u, v, w], z = j ? a("body") : a(c); a.each(y, function () { this.appendTo(z) }); if (h.theme && h.draggable && a.fn.draggable) { w.draggable({ handle: ".ui-dialog-titlebar", cancel: "li" }) } var A = d && (!a.boxModel || a("object,embed", j ? null : c).length > 0); if (e || A) { if (j && h.allowBodyStretch && a.boxModel) a("html,body").css("height", "100%"); if ((e || !a.boxModel) && !j) { var B = o(c, "borderTopWidth"), C = o(c, "borderLeftWidth"); var D = B ? "(0 - " + B + ")" : 0; var E = C ? "(0 - " + C + ")" : 0 } a.each([u, v, w], function (a, b) { var c = b[0].style; c.position = "absolute"; if (a < 2) { j ? c.setExpression("height", "Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:" + h.quirksmodeOffsetHack + ') + "px"') : c.setExpression("height", 'this.parentNode.offsetHeight + "px"'); j ? c.setExpression("width", 'jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"') : c.setExpression("width", 'this.parentNode.offsetWidth + "px"'); if (E) c.setExpression("left", E); if (D) c.setExpression("top", D) } else if (h.centerY) { if (j) c.setExpression("top", '(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"'); c.marginTop = 0 } else if (!h.centerY && j) { var d = h.css && h.css.top ? parseInt(h.css.top) : 0; var e = "((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + " + d + ') + "px"'; c.setExpression("top", e) } }) } if (l) { if (h.theme) w.find(".ui-widget-content").append(l); else w.append(l); if (l.jquery || l.nodeType) a(l).show() } if ((a.browser.msie || h.forceIframe) && h.showOverlay) u.show(); if (h.fadeIn) { var F = h.onBlock ? h.onBlock : b; var G = h.showOverlay && !l ? F : b; var H = l ? F : b; if (h.showOverlay) v._fadeIn(h.fadeIn, G); if (l) w._fadeIn(h.fadeIn, H) } else { if (h.showOverlay) v.show(); if (l) w.show(); if (h.onBlock) h.onBlock() } k(1, c, h); if (j) { f = w[0]; g = a(":input:enabled:visible", f); if (h.focusInput) setTimeout(m, 20) } else n(w[0], h.centerX, h.centerY); if (h.timeout) { var I = setTimeout(function () { j ? a.unblockUI(h) : a(c).unblock(h) }, h.timeout); a(c).data("blockUI.timeout", I) } } if (/1\.(0|1|2)\.(0|1|2)/.test(a.fn.jquery) || /^1.1/.test(a.fn.jquery)) { alert("blockUI requires jQuery v1.2.3 or later!  You are using v" + a.fn.jquery); return } a.fn._fadeIn = a.fn.fadeIn; var b = function () { }; var c = document.documentMode || 0; var d = a.browser.msie && (a.browser.version < 8 && !c || c < 8); var e = a.browser.msie && /MSIE 6.0/.test(navigator.userAgent) && !c; a.blockUI = function (a) { h(window, a) }; a.unblockUI = function (a) { i(window, a) }; a.growlUI = function (b, c, d, e) { var f = a('<div class="growlUI"></div>'); if (b) f.append("<h1>" + b + "</h1>"); if (c) f.append("<h2>" + c + "</h2>"); if (d == undefined) d = 3e3; a.blockUI({ message: f, fadeIn: 700, fadeOut: 1e3, centerY: false, timeout: d, showOverlay: false, onUnblock: e, css: a.blockUI.defaults.growlCSS }) }; a.fn.block = function (b) { return this.unblock({ fadeOut: 0 }).each(function () { if (a.css(this, "position") == "static") this.style.position = "relative"; if (a.browser.msie) this.style.zoom = 1; h(this, b) }) }; a.fn.unblock = function (a) { return this.each(function () { i(this, a) }) }; a.blockUI.version = 2.39; a.blockUI.defaults = { message: "<h1>Please wait...</h1>", title: null, draggable: true, theme: false, css: { padding: 0, margin: 0, width: "30%", top: "40%", left: "35%", textAlign: "center", color: "#000", border: "3px solid #aaa", backgroundColor: "#fff", cursor: "wait" }, themedCSS: { width: "30%", top: "40%", left: "35%" }, overlayCSS: { backgroundColor: "#000", opacity: .6, cursor: "wait" }, growlCSS: { width: "350px", top: "10px", left: "", right: "10px", border: "none", padding: "5px", opacity: .6, cursor: "default", color: "#fff", backgroundColor: "#000", "-webkit-border-radius": "10px", "-moz-border-radius": "10px", "border-radius": "10px" }, iframeSrc: /^https/i.test(window.location.href || "") ? "javascript:false" : "about:blank", forceIframe: false, baseZ: 1e3, centerX: true, centerY: true, allowBodyStretch: true, bindEvents: true, constrainTabKey: true, fadeIn: 200, fadeOut: 400, timeout: 0, showOverlay: true, focusInput: true, applyPlatformOpacityRules: true, onBlock: null, onUnblock: null, quirksmodeOffsetHack: 4, blockMsgClass: "blockMsg" }; var f = null; var g = []; })(jQuery)

/* cookie */
jQuery.cookie = function (a, b, c) { if (arguments.length > 1 && String(b) !== "[object Object]") { c = jQuery.extend({}, c); if (b === null || b === undefined) { c.expires = -1 } if (typeof c.expires === "number") { var d = c.expires, e = c.expires = new Date; e.setDate(e.getDate() + d) } b = String(b); return document.cookie = [encodeURIComponent(a), "=", c.raw ? b : encodeURIComponent(b), c.expires ? "; expires=" + c.expires.toUTCString() : "", c.path ? "; path=" + c.path : "", c.domain ? "; domain=" + c.domain : "", c.secure ? "; secure" : ""].join("") } c = b || {}; var f, g = c.raw ? function (a) { return a } : decodeURIComponent; return (f = (new RegExp("(?:^|; )" + encodeURIComponent(a) + "=([^;]*)")).exec(document.cookie)) ? g(f[1]) : null }

/* url */
jQuery.url = function () { var segments = {}; var parsed = {}; var options = { url: window.location, strictMode: false, key: ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"], q: { name: "queryKey", parser: /(?:^|&)([^&=]*)=?([^&]*)/g }, parser: { strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/} }; var parseUri = function () { str = decodeURI(options.url); var m = options.parser[options.strictMode ? "strict" : "loose"].exec(str); var uri = {}; var i = 14; while (i--) { uri[options.key[i]] = m[i] || "" } uri[options.q.name] = {}; uri[options.key[12]].replace(options.q.parser, function ($0, $1, $2) { if ($1) { uri[options.q.name][$1] = $2 } }); return uri }; var key = function (key) { if (!parsed.length) { setUp() } if (key == "base") { if (parsed.port !== null && parsed.port !== "") { return parsed.protocol + "://" + parsed.host + ":" + parsed.port + "/" } else { return parsed.protocol + "://" + parsed.host + "/" } } return (parsed[key] === "") ? null : parsed[key] }; var param = function (item) { if (!parsed.length) { setUp() } return (parsed.queryKey[item] === null) ? null : parsed.queryKey[item] }; var setUp = function () { parsed = parseUri(); getSegments() }; var getSegments = function () { var p = parsed.path; segments = []; segments = parsed.path.length == 1 ? {} : (p.charAt(p.length - 1) == "/" ? p.substring(1, p.length - 1) : path = p.substring(1)).split("/") }; return { setMode: function (mode) { strictMode = mode == "strict" ? true : false; return this }, setUrl: function (newUri) { options.url = newUri === undefined ? window.location : newUri; setUp(); return this }, segment: function (pos) { if (!parsed.length) { setUp() } if (pos === undefined) { return segments.length } return (segments[pos] === "" || segments[pos] === undefined) ? null : segments[pos] }, attr: key, param: param} } ();

/* exit */
function trimAll(a) { return a.replace(/\s/g, "") } function attachEventListener(a, b, c, d) { if (window.addEventListener) { a.addEventListener(b, c, d) } else { a.attachEvent("on" + b, c) } } function interceptKeyPress(a) { if (!a) { if (window.event) a = window.event; else return } var b = a.keyCode ? a.keyCode : a.which ? a.which : void 0; if (a.charCode == null || a.charCode == 0) { if (b == 116) { userMovingWithinSite() } } } function interceptKeyDown(a) { if (!a) { if (window.event) a = window.event; else return } keyCode = a.keyCode; if (keyCode == 116) { userMovingWithinSite() } if (keyCode == 17) { ctrlKeyIsDown = true } if (ctrlKeyIsDown && keyCode == 82) { userMovingWithinSite() } } function interceptKeyUp(a) { if (!a) { if (window.event) a = window.event; else return } keyCode = a.keyCode; if (keyCode == 17) { ctrlKeyIsDown = false } } function userMovingWithinSite() { movingWithinSite = true } var movingWithinSite = false; var codeToExecute = function () { }; var ctrlKeyIsDown = false; (function (a) { a.fn.onUserExit = function (b) { var c = { execute: "", internalURLs: "" }; var b = a.extend(c, b); if (b.execute == "") { alert("The onUserExit jQuery Plugin has been misconfigured.  Please add the function you wish to execute.") } if (b.internalURLs == "") { alert("The onUserExit jQuery Plugin has been misconfigured.  Please add internal URLs so it know when the user is navigating internally.") } codeToExecute = b.execute; a("a").each(function () { var c = a(this); var d = false; var e = trimAll(b.internalURLs).split("|"); for (i = 0; i < e.length; i++) { if (c.attr("href") == null || c.attr("href") == "undefined") continue; if (c.attr("href").indexOf(e[i]) !== -1) { d = true } if (c.attr("href").indexOf("http://") == -1) { d = true } } if (d == true) { c.bind("click", function () { userMovingWithinSite() }) } }); a("form").each(function () { var b = a(this); currentonSubmit = b.attr("onSubmit"); if (currentonSubmit === undefined) { currentonSubmit = "" } b.attr("onSubmit", currentonSubmit + " userMovingWithinSite();") }); attachEventListener(document, "keydown", interceptKeyDown, true); attachEventListener(document, "keyup", interceptKeyUp, true); attachEventListener(document, "keypress", interceptKeyPress, true) }; a(window).bind("beforeunload unload", function () { if (movingWithinSite == false) codeToExecute() }) })(jQuery)

/* survey */
function surveyRun() { if (settings.enable == false) return false; if (performTimerValidation() == false) return false; debug("after timer"); if (performCountryValidation() == false) return false; debug("after country"); if (performIPValidation() == false) return false; debug("after ip"); var a = settings.cookie.enable; var b = a == true ? $.cookie(settings.cookie.name) : null; if (b == null) { $.get(settings.popupUrl, function (a) { $.blockUI({ message: a }); loadLanguage(); attachTemplateResponseEvents(); attachTemplateTheme() }) } } function surveyInit(a, b) { $.holdReady(true); execute = b == null ? true : b; path = a; loadSettings(); performTimerDetection(); performCountryDetection(); performIPDetection(); $.holdReady(false) } function performExitDomainDetection() { if (settings.onExitDomain == true) { $().onUserExit({ execute: function () { var a = settings.cookie.enable; var b = a == true ? $.cookie(settings.cookie.name) : null; if (a == true) { if (b != null && b == "true") { popup(settings.surveyUrl, settings.width, settings.height); $.cookie(settings.cookie.name, "complete", { expires: 1, path: "/" }) } } else popup(settings.surveyUrl, settings.width, settings.height) }, internalURLs: settings.internalDomains }) } } function performIPDetection() { if (settings.ipDetection.enable == true && (settings.ipDetection.allowedIPs != "-1" || settings.ipDetection.deniedIPs != "-1")) { $.holdReady(true); $.getJSON("http://jsonip.appspot.com?callback=?", function (a) { var b = a.ip; saveIP(b) }).complete(function () { $.holdReady(false) }) } } function saveIP(a) { clientIP = a } function performCountryDetection() { if (settings.countryDetection.enable == true && settings.countryDetection.locations != "-1") { $.holdReady(true); $.getJSON("http://api.wipmania.com/jsonp?callback=?", function (a) { var b = a.address.country_code; saveCountry(b) }).complete(function () { $.holdReady(false) }) } } function saveCountry(a) { clientCountry = a } function performTimerDetection() { if (settings.timer.enable == true) { $.holdReady(true); var a = "http://json-time.appspot.com/time.json?tz=" + settings.timer.timezone + "&callback=?"; $.getJSON(a, function (a) { var b = a; if (b.error == true) saveTime(null); else saveTime(b.datetime) }).complete(function () { $.holdReady(false) }) } } function saveTime(a) { clientDateTime = a } function readyLock() { if (settings.countryDetection.enable == true && settings.countryDetection.locations != "-1" || settings.ipDetection.enable == true || settings.timer.enable == true) $.holdReady(true) } function loadSettings() { $.ajax({ type: "GET", url: path, dataType: "JSON", async: false, success: function (a) { settings = a }, error: function (a, b, c) { alert(b) }, complete: function () { } }) } function attachTemplateTheme() { var a = settings.theme.color; if (a == "-1") return false; $("#surveyBG .color").css("color", a).removeClass("color"); $("#surveyBG .bgColor").css("background-color", a).removeClass("bgColor") } function attachTemplateResponseEvents() { $("#surveyYes").click(function () { var a = settings.cookie.enable; if (a == true) $.cookie(settings.cookie.name, "true", { expires: 1, path: "/" }); if (settings.onExitDomain == false) { if (a == true) { $.cookie(settings.cookie.name, "complete", { expires: 1, path: "/" }) } popup(settings.surveyUrl, settings.width, settings.height) } $.unblockUI() }); $("#surveyNo, #surveyClose").click(function () { var a = settings.cookie.enable; if (a == true) $.cookie(settings.cookie.name, "false", { expires: 1, path: "/" }); $.unblockUI(); return false }) } function loadLanguage() { var a = settings.languageUrl; $.ajax({ type: "GET", url: a, dataType: "JSON", async: false, success: function (a) { $("#surveyContent #surveyHeading").text(a.heading); $("#surveyContent #surveyBody").text(a.body); $("#surveyContent #surveyAsk").text(a.question); $("#surveyContent #surveyYes").val(a.yes); $("#surveyContent #surveyNo").val(a.no) }, error: function (a, b, c) { alert("invalid language") } }) } function performIPValidation() { debug("clientIP is " + clientIP); if (clientIP == null) return true; var a = settings.ipDetection.allowedIPs; var b = settings.ipDetection.deniedIPs; var c = true; if (a != "-1" || b != "-1") { if (a != "-1") a = trimAll(a); if (b != "-1") b = trimAll(b); if (a != "-1") { if (!ipFoundInList(clientIP, a)) c = false } if (b != "-1") { if (ipFoundInList(clientIP, b)) c = false } } return c } function ipFoundInList(a, b) { var c = false; var d = b.split("|"); for (var e = 0; e < d.length; e++) { if (matchesIPOrMask(a, d[e])) c = true } return c } function matchesIPOrMask(a, b) { var c = true; var d, e; if (a.length > 0 && b.length > 0) { d = a.split("."); e = b.split("."); if (d.length == e.length) { for (var f = 0; f < d.length; f++) { if (d[f] != e[f] && e[f] != "*") { c = false; break } } } else c = false } return c } function performCountryValidation() { debug("clientCountry is " + clientCountry); if (clientCountry == null) return true; var a = trimAll(settings.countryDetection.locations).split("|"); var b = $.inArray(clientCountry, a) > -1; return b } function performTimerValidation() { debug("clientDateTime is " + clientDateTime); if (clientDateTime == null) return true; var a = false; var b = new Date(clientDateTime), c = new Date(clientDateTime), d = new Date(clientDateTime); var e, f; var g, h, i, j; var k = settings.timer.intervals; var l = trimAll(k).split("|"); var m, n, o; try { for (var p = 0; p < l.length; p++) { m = l[p].split("-"); n = m[0]; o = m[1]; e = n.split(":"); g = parseInt(e[0]); h = parseInt(e[1]); f = o.split(":"); i = parseInt(o.split(":")[0]); j = parseInt(o.split(":")[1]); c.setHours(g, h); d.setHours(i, j); if (b.getTime() >= c.getTime() && b.getTime() <= d.getTime()) { a = true; break } } return a } catch (q) { debug("exception caught in performTimerValidation()..." + q); return a } } function popup(a, b, c) { var b = b; var c = c; var d = (screen.width - b) / 2; var e = (screen.height - c) / 2; var f = "width=" + b + ", height=" + c; f += ", top=" + e + ", left=" + d; f += ", directories=0"; f += ", location=0"; f += ", menubar=0"; f += ", resizable=1"; f += ", scrollbars=1"; f += ", status=1"; f += ", toolbar=0"; var g = window.open(a, "survey", f); if (window.focus()) window.blur(); if (g != null) g.focus(); return false } function debug(a) { if (mode) try { window.console.debug(a) } catch (b) { window.console.log(a) } } function trimAll(a) { return a.replace(/\s/g, "") } var mode = false; var path = "settings.json"; var settings = null; var clientDateTime = null; var clientCountry = null; var clientIP = null; var execute = false; $.blockUI.defaults.css = { padding: 0, margin: 0, width: "", top: "25%", left: "35%", textAlign: "center", color: "", border: "none", backgroundColor: "transparent", cursor: "default" }; $.blockUI.defaults.overlayCSS = { backgroundColor: "#FFF", opacity: .5, cursor: "default" }; $(function () { if (execute == true) surveyRun(); if (settings != null) performExitDomainDetection() })
