﻿var Sawbuck = window.Sawbuck || {}; var $j = jQuery.noConflict(); Sawbuck.Utilities = function () { function showListingVideo(a) { var b = "http://sawbuckfe.sundayskylb1.com/MediaLookup/?accountId=Sawbuck%26videoletId=ListingShowcase%26key="; var c = ":1.0:default:overlaid_video"; var d = {}; if (_videos_watched < 1 && false) d.commercialFile = Sawbuck.SERVER + "/video/ss_intro_2.flv"; d.isPopup = false; d.screenColor = "#ffffff"; d.autoStart = true; sundaySky.create(b + a + c, d); $j(".ssVideo").dialog("open"); try { $j(".ssVideo").dialog("option", "title", "Video of " + Sawbuck.Page.getListingByID(a).addr) } catch (e) { } Sawbuck.Reporting.trackEvent("Listing Video Played", "From Search Page"); _videos_watched++ } function loadListingMedia(a) { var b = "/service/WebService.asmx/ListingMediaByID"; $j.ajax({ type: "POST", url: b, data: Sawbuck.Utilities.toJson({ listingID: a }), contentType: "application/json; charset=utf-8", dataType: "json", processData: false, success: function (b) { var c = b.d; $j("#listingPics div:first").html(""); for (var d = 0; d < c.length; d++) { var e = $j("<img>").attr({ src: c[d].u, vspace: 2, "class": d == c.length - 1 ? 0 : d + 1, style: "display: block; cursor: pointer; margin-top: 4px" }); var f = $j("<div>").attr({ style: "vertical-align: middle; height: 280px; width: 428px; position: relative;" }); f.append(e); if (c[d].c && c[d].c != "null" && c[d].c != "Caption" && c[d].c != "undefined") f.append("<p class='caption' style='position: absolute; bottom: 6px; left: 0; width: 100%; background: #FFFFFF'>" + c[d].c + "</p>"); $j("#listingPics div:first").append(f); e = null; f = null } var g; try { g = Sawbuck.Page.getListingByID(a); $j("#listingPics").dialog("option", "title", "Pictures of " + g.addr) } catch (h) { g = { addr: "", url: "", stat: 0, el: false }; $j("#listingPics .tour").hide(); $j("#listingPics .listingLink").hide() } $j("#listingPics img").click(function (a) { $j("#listingPics div:first").scrollTop(this.className * 284) }); $j("#listingPics .tour").attr({ href: "/property" + g.url + "/tour", target: "_blank" }); $j("#listingPics .listingLink").attr({ href: "/property" + g.url, target: "_blank" }); try { if (Sawbuck.Page.getURL() == "/sold" || g.stat != 1 || g.el) $j("#listingPics .tour").hide(); else $j("#listingPics .tour").show() } catch (h) { } $j("#listingPics").dialog("open"); Sawbuck.Reporting.trackEvent("Listing Pictures", "From Search Page", "# of Pictures", c.length) }, error: function (a, b) { } }) } function daysAgo(a) { var b = (new Date).getTime(); var c = Math.floor((b - a) / (1e3 * 60 * 60 * 24)); return c } function writeCookie(a, b) { document.cookie = a + "=" + b + ";path=/;domain=sawbuck.com"; Sawbuck.Debugger.report("Set cookie: " + a + "=" + b + ";path=/;domain=sawbuck.com"); Sawbuck.Debugger.report(document.cookie) } function deleteCookie(a) { var b = new Date; b.setTime(b.getTime() - 1 * 24 * 60 * 60 * 1e3); document.cookie = a + "=; expires=" + b.toGMTString(); Sawbuck.Debugger.report(a + "=; expires=" + b.toGMTString()); Sawbuck.Debugger.report(document.cookie) } function readCookie(a) { var b = a + "="; var c = document.cookie.split(";"); for (var d = 0; d < c.length; d++) { var e = c[d]; while (e.charAt(0) == " ") e = e.substring(1, e.length); if (e.indexOf(b) == 0) return e.substring(b.length, e.length) } return null } function alterCSS(a, b, c) { var d; if (document.all) { d = "rules" } else if (document.getElementById) { d = "cssRules" } var e = false; try { for (var f = 0; f < document.styleSheets.length; f++) { for (var g = 0; g < document.styleSheets[f][d].length; g++) { if (document.styleSheets[f][d][g].selectorText == a) { if (document.styleSheets[f][d][g].style[b]) { document.styleSheets[f][d][g].style[b] = c; e = true; break } } } if (!e) { if (document.styleSheets[f].insertRule) { document.styleSheets[f].insertRule(a + " { " + b + ": " + c + "; }", document.styleSheets[f][d].length) } else if (document.styleSheets[f].addRule) { document.styleSheets[f].addRule(a, b + ": " + c + ";") } } } } catch (h) { } } function getImage(a, b, c, d) { if (!c || !a) { a = a || 0; if (d && d >= 1) { var e = d + "_" + parseInt(a) % 3; switch (b) { case "listing": return BASE_URL + "no_image/" + e + "_listing.png"; case "mini": return BASE_URL + "no_image/" + e + "_mini.png"; case "gallery": return BASE_URL + "no_image/" + e + "_gallery.png"; default: return BASE_URL + "no_image/orig.gif" } } switch (b) { case "listing": return BASE_URL + "no_image/listing.gif"; case "mini": return BASE_URL + "no_image/mini.gif"; case "gallery": return BASE_URL + "no_image/gallery.gif"; default: return BASE_URL + "no_image/orig.gif" } } var f = ""; switch (b) { case "listing": f = "-listing.jpg"; break; case "mini": f = "-mini.jpg"; break; case "gallery": f = "-gallery.jpg"; break; default: f = "-orig.jpg"; break } return BASE_URL + parseImagePath(a) + f } function parseImagePath(a) { a = a.toString(); var b = []; var c = a.length; var d = c - 3; while (d > 0) { var e = c - d; b.push(a.substr(d, e)); c = d; d = c - 3 } b.push(a.substr(0, c)); b.reverse(); return b.join("/") } function resettable(a, b, c) { $j(a).blur(function (a) { if ($j(this).val() == "") { $j(this).val(b); $j(this).removeClass(c) } }); $j(a).focus(function (a) { if ($j(this).val() == b) { $j(this).val(""); $j(this).addClass(c) } }) } function isSame(a, b) { return toJson(a) == toJson(b) } function deep_clone(obj) { eval("var tmp = " + toJson(obj)); return tmp } function cloneObject(a) { var b = a instanceof Array ? [] : {}; for (i in a) { if (i == "clone") continue; if (a[i] && typeof a[i] == "object") { b[i] = cloneObject(a[i]) } else b[i] = a[i] } return b } function toJson(a) { switch (typeof a) { case "object": if (a) { var b = []; if (a instanceof Array) { for (var c = 0; c < a.length; c++) { b.push(toJson(a[c])) } return "[" + b.join(",") + "]" } else { for (var d in a) { b.push('"' + d + '":' + toJson(a[d])) } return "{" + b.join(",") + "}" } } else { return "null" }; case "string": return '"' + a.replace(/(["'])/g, "\\$1") + '"'; case "number": case "boolean": return new String(a) } } function typeOf(a) { var b = typeof a; if (b === "object") { if (a) { if (a instanceof Array) { b = "array" } } else { b = "null" } } return b } var BASE_URL = ""; _noSessionTilePath = ""; Array.prototype.sum = function () { for (var a = 0, b = 0; a < this.length; b += this[a++]); return parseFloat(b) }; Array.prototype.first = function () { return this[0] }; Array.prototype.last = function () { return this[this.length - 1] }; Array.prototype.each = function (a) { for (var b = 0; b < this.length; b++) { try { a.call(this, this[b], b) } catch (c) { } } return this }; Array.prototype.collect = function (a) { var b = []; this.each(function (c, d) { b.push(a(c, d)) }); return b }; Array.prototype.findAll = function (a) { var b = []; this.each(function (c, d) { if (a(c, d)) b.push(c) }); return b }; Array.prototype.detect = function (a) { return this.findAll(a).first() }; Array.prototype.find = Array.prototype.detect; Array.prototype.invoke = function (a) { return this.collect(function (b, c) { return b[a].apply(b, arguments.slice(1)) }) }; Number.prototype.format = function (a, b, c) { var d = this + "", e = /^(-?)(\d+)/, f, g; if (a != null) d = this.toFixed(a); if (b && (f = e.exec(d))) { for (var h = f[2].split(""), i = h.length - 3; i > 0; i -= 3) h.splice(i, 0, b); d = d.replace(e, f[1] + h.join("")) } if (c) d = d.replace(/\./, c); return d }; if (typeof Number.prototype.toFixed != "function" || .9.toFixed() == "0" || .007.toFixed(2) == "0.00") Number.prototype.toFixed = function (a) { if (isNaN(a *= 1) || a < 0 || a > 20) a = 0; var b = "", c = this.valueOf(), d = ""; if (this < 0) { b = "-"; c *= -1 } if (c >= Math.pow(10, 21)) d = c.toString(); else { d = Math.round(Math.pow(10, a) * c).toString(); if (a != 0) { var e = d.length; if (e <= a) { var f = "00000000000000000000".substring(0, a + 1 - e); d = f + d; e = a + 1 } var g = d.substring(0, e - a); var h = d.substring(e - a); d = g + "." + h } } if (d == "0") b = ""; return b + d }; Number.prototype.toPrice = function (a) { a = a || 0; return "$" + this.format(a, ",") }; String.prototype.toPrice = function (a) { a = a || 0; return "$" + parseFloat(this).format(a, ",") }; String.prototype.startsWith = function (a) { if (!a || a.length > this.length) return false; return this.substr(0, a.length) == a }; String.prototype.format = function (a, b, c) { return parseFloat(this).format(a, b, c) }; String.prototype.truncate = function (a, b) { b = b || "..."; return this.substr(0, a - 1) + (this.length > a ? b : "") }; String.prototype.trim = function () { var a = this || ""; return a.replace(/^\s*/, "").replace(/\s*$/, "") }; var _videos_watched = 0; return { alterCSS: alterCSS, createDelegate: function (a, b) { return function () { return b.apply(a, arguments) } }, cloneObject: cloneObject, isSame: isSame, resettable: resettable, isArray: function (a) { return a instanceof Array }, toJson: toJson, typeOf: function (a) { return typeOf(a) }, readCookie: readCookie, writeCookie: writeCookie, deleteCookie: deleteCookie, trim: function (a) { a = a || ""; return a.replace(/^\s*/, "").replace(/\s*$/, "") }, setBaseMediaURL: function (a) { BASE_URL = a }, getImage: getImage, loadListingMedia: loadListingMedia, setNoSessionTilePath: function (a) { _noSessionTilePath = a }, getNoSessionTilePath: function () { return _noSessionTilePath }, showListingVideo: showListingVideo, daysAgo: daysAgo, modo: function (a) { $j("#" + a).dialog("open"); return false }, selectAll: function (a) { $j(a).find("input").attr("checked", "checked") }, unselectAll: function (a) { $j(a).find("input").removeAttr("checked") }, refreshAds: function () { try { $j(".ad iframe")[0].src = $j(".ad iframe")[0].src; $j(".partnerContent iframe")[0].src = $j(".partnerContent iframe")[0].src } catch (a) { } }, URLEncode: function (a) { a = a || ""; var b = ""; var c = 0; a = a.toString(); var d = /(^[a-zA-Z0-9_.]*)/; while (c < a.length) { var e = d.exec(a.substr(c)); if (e != null && e.length > 1 && e[1] != "") { b += e[1]; c += e[1].length } else { if (a[c] == " ") b += "+"; else { var f = a.charCodeAt(c); var g = f.toString(16); b += "%" + (g.length < 2 ? "0" : "") + g.toUpperCase() } c++ } } return b } } } (); Sawbuck.Debugger = function () { function d(a) { if (window.console.log(a) === false) { if (typeof a == "object") a = "<span class='object'>" + Sawbuck.Utilities.toJson(a) + "</span>"; var b = new Date; $j("#debugger .debugContent ul").append("<li title='" + b + "' >" + a + "</li>"); $j("#debugger").show(); $j("#debugger .debugContent").scrollTop($j("#debugger .debugContent ul").height()); delete b } } var a = 0; var b; var c = window.console || false; if (!c) { window.console = {}; window.console.log = function () { return false } } return { report: function (a) { return false }, clear: function () { $j("#debugger .debugContent ul").text(""); return false }, close: function () { $j("#debugger").hide(); return false }, startTimer: function () { if (!b) a = 0; b = setInterval(function () { a++ }, 1) }, pauseTimer: function () { clearInterval(b) }, stopTimer: function () { clearInterval(b); b = null; return a }, getTime: function () { return a } } } (); (function (a) { a.fn.truncate = function (b) { if (a(this).find(".truncate_more_link").length) return; if (typeof b == "string") { return this.each(function () { var c = a(this); if (c.data("truncateState") == "show" || c.data("truncateState") == "hidden") { switch (b) { case "unTruncate": c.data("truncateState", "").html(c.data("htmlJAll") || "").data("htmlJAll", "").data("htmlJShort", ""); break } } }) } var c = { maxTextLen: 200, maxBlankSearchLen: 20, maxBRLen: 3, moreText: "more", lessText: "less", moreHint: "Show hidden text", lessHint: "Hide long text" }; var d = a.extend(c, b); var e = function (b) { var c = a(' <a href="#" class="truncate_more_link" title="">' + d.moreText + "</a>"); if ((b.data("truncateState") || "") == "hidden") { b.data("truncateState", "show").html(b.data("htmlJAll") || "").append(" ").append(c.attr("title", d.lessHint).attr("alt", d.lessText)); c.text(d.lessText) } else { b.data("truncateState", "hidden").html(b.data("htmlJShort") || "").append(" ").append(c.attr("title", d.moreHint).attr("alt", d.moreText)); c.text(d.moreText) } c.bind("truncateToggle", function () { e(b) }).bind("truncateShort", function () { b.data("truncateState", "show"); e(b); a("a.truncate_more_link", b).show() }).bind("truncateAll", function () { b.data("truncateState", "hidden"); e(b); a("a.truncate_more_link", b).hide() }).one("click", function () { a("a.truncate_more_link", b).trigger("truncateToggle"); return false }) }; return this.each(function () { var b = a(this); var c = String(b.html()); if (c.length > d.maxTextLen) { var f = 0; var g = 0; var h = null; function i(a, b) { if (a.hasChildNodes()) { var c = new Array; jQuery.each(a.childNodes, function () { var a = this; if (h !== null) { c.push(this) } else { if (this.nodeType == 1) { var e = true; var j = false; switch (this.nodeName.toUpperCase()) { case "LINK": case "META": case "STYLE": case "HEADER": e = false; break; case "BR": e = false; case "P": case "H1": case "H2": case "H3": case "H4": case "H5": case "H6": case "HR": case "TR": case "TABLE": case "OL": case "UL": case "DIV": j = true; if ((b || false) !== true) { g++ } else { b = false } if (g > d.maxBRLen) { h = this; e = false } break } if (e) { i(this, j) } } else { if (this.nodeType != 8) { var k = String(this.nodeValue); var l = k.length; f += l; if (f > d.maxTextLen) { l = l - (f - d.maxTextLen); var m = k.substring(l, k.length); var n = m.length, o; k = k.substring(0, l); for (var p = 0; p < d.maxBlankSearchLen; p++) { if (p < n) { o = m.charAt(p); k += o; if (o == " ") { break } } else { break } } this.nodeValue = k + "..."; h = this } } } } }); jQuery.each(c, function () { if (typeof this.parentNode !== "undefined") { this.parentNode.removeChild(this) } }) } } i(b.get(0), false); if (h !== null) { b.hide().data("htmlJAll", c).data("htmlJShort", String(b.html())).data("truncateState", ""); e(b); b.show() } } }) } })(jQuery); (function (a) { $j.fn.resettable = function () { fields = new Array; this.each(function () { jQuery(this).data("original", jQuery(this).val()); jQuery(this).focus(function () { if (jQuery(this).val() == jQuery(this).data("original")) jQuery(this).val("") }).blur(function () { if (jQuery(this).val() == "") jQuery(this).val(jQuery(this).data("original")) }) }); return this } })(jQuery); (function (a) { a.fn.hoverIntent = function (b, c) { var d = { sensitivity: 7, interval: 100, timeout: 0 }; d = a.extend(d, c ? { over: b, out: c} : b); var e, f, g, h; var i = function (a) { e = a.pageX; f = a.pageY }; var j = function (b, c) { c.hoverIntent_t = clearTimeout(c.hoverIntent_t); if (Math.abs(g - e) + Math.abs(h - f) < d.sensitivity) { a(c).unbind("mousemove", i); c.hoverIntent_s = 1; return d.over.apply(c, [b]) } else { g = e; h = f; c.hoverIntent_t = setTimeout(function () { j(b, c) }, d.interval) } }; var k = function (a, b) { b.hoverIntent_t = clearTimeout(b.hoverIntent_t); b.hoverIntent_s = 0; return d.out.apply(b, [a]) }; var l = function (b) { var c = (b.type == "mouseover" ? b.fromElement : b.toElement) || b.relatedTarget; while (c && c != this) { try { c = c.parentNode } catch (b) { c = this } } if (c == this) { return false } var e = jQuery.extend({}, b); var f = this; if (f.hoverIntent_t) { f.hoverIntent_t = clearTimeout(f.hoverIntent_t) } if (b.type == "mouseover") { g = e.pageX; h = e.pageY; a(f).bind("mousemove", i); if (f.hoverIntent_s != 1) { f.hoverIntent_t = setTimeout(function () { j(e, f) }, d.interval) } } else { a(f).unbind("mousemove", i); if (f.hoverIntent_s == 1) { f.hoverIntent_t = setTimeout(function () { k(e, f) }, d.timeout) } } }; return this.mouseover(l).mouseout(l) } })(jQuery); for (var i = 0; i < $j("input[default]").length; i++) { var elt = $j("input[default]")[i]; if (!$j(elt).val()) { $j(elt).addClass("default"); $j(elt).val($j(elt).attr("default")) } } $j("input[default], select[default], textarea[default]").live("focus", function () { if ($j(this).hasClass("default")) { $j(this).removeClass("default"); $j(this).val("") } }); $j("input[default], select[default], textarea[default]").live("blur", function () { if ($j(this).attr("default") && !$j(this).val()) { $j(this).addClass("default"); $j(this).val($j(this).attr("default")) } }); $j(window).unload(function () { $j("input[default].default, textarea[default].default").val("") })
