;(function(){var a=this,b=a._,c={},d=Array.prototype,e=Object.prototype,f=d.slice,g=d.unshift,h=e.toString,i=e.hasOwnProperty,j=d.forEach,k=d.map,l=d.reduce,m=d.reduceRight,n=d.filter,o=d.every,p=d.some,q=d.indexOf,r=d.lastIndexOf,s=Array.isArray,t=Object.keys,u=function(a){return new z(a)};typeof module!=="undefined"&&module.exports?(module.exports=u,u._=u):a._=u,u.VERSION="1.1.4";var v=u.each=u.forEach=function(a,b,d){var e;if(a!=null)if(j&&a.forEach===j)a.forEach(b,d);else if(u.isNumber(a.length)){for(var f=0,g=a.length;f<g;f++)if(b.call(d,a[f],f,a)===c)return}else for(var h in a)if(i.call(a,h))if(b.call(d,a[h],h,a)===c)return};u.map=function(a,b,c){var d=[];if(a==null)return d;if(k&&a.map===k)return a.map(b,c);v(a,function(a,e,f){d[d.length]=b.call(c,a,e,f)});return d},u.reduce=u.foldl=u.inject=function(a,b,c,d){var e=c!==void 0;a==null&&(a=[]);if(l&&a.reduce===l){d&&(b=u.bind(b,d));return e?a.reduce(b,c):a.reduce(b)}v(a,function(a,f,g){e||f!==0?c=b.call(d,c,a,f,g):(c=a,e=!0)});if(!e)throw new TypeError("Reduce of empty array with no initial value");return c},u.reduceRight=u.foldr=function(a,b,c,d){a==null&&(a=[]);if(m&&a.reduceRight===m){d&&(b=u.bind(b,d));return c!==void 0?a.reduceRight(b,c):a.reduceRight(b)}var e=(u.isArray(a)?a.slice():u.toArray(a)).reverse();return u.reduce(e,b,c,d)},u.find=u.detect=function(a,b,c){var d;w(a,function(a,e,f){if(b.call(c,a,e,f)){d=a;return!0}});return d},u.filter=u.select=function(a,b,c){var d=[];if(a==null)return d;if(n&&a.filter===n)return a.filter(b,c);v(a,function(a,e,f){b.call(c,a,e,f)&&(d[d.length]=a)});return d},u.reject=function(a,b,c){var d=[];if(a==null)return d;v(a,function(a,e,f){b.call(c,a,e,f)||(d[d.length]=a)});return d},u.every=u.all=function(a,b,d){b=b||u.identity;var e=!0;if(a==null)return e;if(o&&a.every===o)return a.every(b,d);v(a,function(a,f,g){if(!(e=e&&b.call(d,a,f,g)))return c});return e};var w=u.some=u.any=function(a,b,d){b=b||u.identity;var e=!1;if(a==null)return e;if(p&&a.some===p)return a.some(b,d);v(a,function(a,f,g){if(e=b.call(d,a,f,g))return c});return e};u.include=u.contains=function(a,b){var c=!1;if(a==null)return c;if(q&&a.indexOf===q)return a.indexOf(b)!=-1;w(a,function(a){if(c=a===b)return!0});return c},u.invoke=function(a,b){var c=f.call(arguments,2);return u.map(a,function(a){return(b?a[b]:a).apply(a,c)})},u.pluck=function(a,b){return u.map(a,function(a){return a[b]})},u.max=function(a,b,c){if(!b&&u.isArray(a))return Math.max.apply(Math,a);var d={computed:-Infinity};v(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;g>=d.computed&&(d={value:a,computed:g})});return d.value},u.min=function(a,b,c){if(!b&&u.isArray(a))return Math.min.apply(Math,a);var d={computed:Infinity};v(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;g<d.computed&&(d={value:a,computed:g})});return d.value},u.sortBy=function(a,b,c){return u.pluck(u.map(a,function(a,d,e){return{value:a,criteria:b.call(c,a,d,e)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")},u.sortedIndex=function(a,b,c){c=c||u.identity;var d=0,e=a.length;while(d<e){var f=d+e>>1;c(a[f])<c(b)?d=f+1:e=f}return d},u.toArray=function(a){if(!a)return[];if(a.toArray)return a.toArray();if(u.isArray(a))return a;if(u.isArguments(a))return f.call(a);return u.values(a)},u.size=function(a){return u.toArray(a).length},u.first=u.head=function(a,b,c){return b&&!c?f.call(a,0,b):a[0]},u.rest=u.tail=function(a,b,c){return f.call(a,u.isUndefined(b)||c?1:b)},u.last=function(a){return a[a.length-1]},u.compact=function(a){return u.filter(a,function(a){return!!a})},u.flatten=function(a){return u.reduce(a,function(a,b){if(u.isArray(b))return a.concat(u.flatten(b));a[a.length]=b;return a},[])},u.without=function(a){var b=f.call(arguments,1);return u.filter(a,function(a){return!u.include(b,a)})},u.uniq=u.unique=function(a,b){return u.reduce(a,function(a,c,d){if(0==d||(b===!0?u.last(a)!=c:!u.include(a,c)))a[a.length]=c;return a},[])},u.intersect=function(a){var b=f.call(arguments,1);return u.filter(u.uniq(a),function(a){return u.every(b,function(b){return u.indexOf(b,a)>=0})})},u.zip=function(){var a=f.call(arguments),b=u.max(u.pluck(a,"length")),c=Array(b);for(var d=0;d<b;d++)c[d]=u.pluck(a,""+d);return c},u.indexOf=function(a,b,c){if(a==null)return-1;if(c){var d=u.sortedIndex(a,b);return a[d]===b?d:-1}if(q&&a.indexOf===q)return a.indexOf(b);for(var d=0,e=a.length;d<e;d++)if(a[d]===b)return d;return-1},u.lastIndexOf=function(a,b){if(a==null)return-1;if(r&&a.lastIndexOf===r)return a.lastIndexOf(b);var c=a.length;while(c--)if(a[c]===b)return c;return-1},u.range=function(a,b,c){var d=f.call(arguments),e=d.length<=1,a=e?0:d[0],b=e?d[0]:d[1],c=d[2]||1,g=Math.max(Math.ceil((b-a)/c),0),h=0,i=Array(g);while(h<g)i[h++]=a,a+=c;return i},u.bind=function(a,b){var c=f.call(arguments,2);return function(){return a.apply(b||{},c.concat(f.call(arguments)))}},u.bindAll=function(a){var b=f.call(arguments,1);b.length==0&&(b=u.functions(a)),v(b,function(b){a[b]=u.bind(a[b],a)});return a},u.memoize=function(a,b){var c={};b=b||u.identity;return function(){var d=b.apply(this,arguments);return d in c?c[d]:c[d]=a.apply(this,arguments)}},u.delay=function(a,b){var c=f.call(arguments,2);return setTimeout(function(){return a.apply(a,c)},b)},u.defer=function(a){return u.delay.apply(u,[a,1].concat(f.call(arguments,1)))};var x=function(a,b,c){var d;return function(){var e=this,f=arguments,g=function(){d=null,a.apply(e,f)};c&&clearTimeout(d);if(c||!d)d=setTimeout(g,b)}};u.throttle=function(a,b){return x(a,b,!1)},u.debounce=function(a,b){return x(a,b,!0)},u.wrap=function(a,b){return function(){var c=[a].concat(f.call(arguments));return b.apply(this,c)}},u.compose=function(){var a=f.call(arguments);return function(){var b=f.call(arguments);for(var c=a.length-1;c>=0;c--)b=[a[c].apply(this,b)];return b[0]}},u.keys=t||function(a){if(u.isArray(a))return u.range(0,a.length);var b=[];for(var c in a)i.call(a,c)&&(b[b.length]=c);return b},u.values=function(a){return u.map(a,u.identity)},u.functions=u.methods=function(a){return u.filter(u.keys(a),function(b){return u.isFunction(a[b])}).sort()},u.extend=function(a){v(f.call(arguments,1),function(b){for(var c in b)a[c]=b[c]});return a},u.clone=function(a){return u.isArray(a)?a.slice():u.extend({},a)},u.tap=function(a,b){b(a);return a},u.isEqual=function(a,b){if(a===b)return!0;var c=typeof a,d=typeof b;if(c!=d)return!1;if(a==b)return!0;if(!a&&b||a&&!b)return!1;a._chain&&(a=a._wrapped),b._chain&&(b=b._wrapped);if(a.isEqual)return a.isEqual(b);if(u.isDate(a)&&u.isDate(b))return a.getTime()===b.getTime();if(u.isNaN(a)&&u.isNaN(b))return!1;if(u.isRegExp(a)&&u.isRegExp(b))return a.source===b.source&&a.global===b.global&&a.ignoreCase===b.ignoreCase&&a.multiline===b.multiline;if(c!=="object")return!1;if(a.length&&a.length!==b.length)return!1;var e=u.keys(a),f=u.keys(b);if(e.length!=f.length)return!1;for(var g in a)if(!(g in b)||!u.isEqual(a[g],b[g]))return!1;return!0},u.isEmpty=function(a){if(u.isArray(a)||u.isString(a))return a.length===0;for(var b in a)if(i.call(a,b))return!1;return!0},u.isElement=function(a){return a&&a.nodeType==1},u.isArray=s||function(a){return h.call(a)==="[object Array]"},u.isArguments=function(a){return a&&i.call(a,"callee")},u.isFunction=function(a){return!!(a&&a.constructor&&a.call&&a.apply)},u.isString=function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)},u.isNumber=function(a){return!!(a===0||a&&a.toExponential&&a.toFixed)},u.isNaN=function(a){return a!==a},u.isBoolean=function(a){return a===!0||a===!1},u.isDate=function(a){return!!(a&&a.getTimezoneOffset&&a.setUTCFullYear)},u.isRegExp=function(a){return a&&a.test&&a.exec&&(a.ignoreCase||a.ignoreCase===!1)},u.isNull=function(a){return a===null},u.isUndefined=function(a){return a===void 0},u.noConflict=function(){a._=b;return this},u.identity=function(a){return a},u.times=function(a,b,c){for(var d=0;d<a;d++)b.call(c,d)},u.mixin=function(a){v(u.functions(a),function(b){B(b,u[b]=a[b])})};var y=0;u.uniqueId=function(a){var b=y++;return a?a+b:b},u.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g},u.template=function(a,b){var c=u.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(c.interpolate,function(a,b){return"',"+b.replace(/\\'/g,"'")+",'"}).replace(c.evaluate||null,function(a,b){return"');"+b.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj",d);return b?e(b):e};var z=function(a){this._wrapped=a};u.prototype=z.prototype;var A=function(a,b){return b?u(a).chain():a},B=function(a,b){z.prototype[a]=function(){var a=f.call(arguments);g.call(a,this._wrapped);return A(b.apply(u,a),this._chain)}};u.mixin(u),v(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=d[a];z.prototype[a]=function(){b.apply(this._wrapped,arguments);return A(this._wrapped,this._chain)}}),v(["concat","join","slice"],function(a){var b=d[a];z.prototype[a]=function(){return A(b.apply(this._wrapped,arguments),this._chain)}}),z.prototype.chain=function(){this._chain=!0;return this},z.prototype.value=function(){return this._wrapped}})()
;(function($){$.toJSON=function(a){if(typeof JSON=="object"&&JSON.stringify)return JSON.stringify(a);var b=typeof a;if(a===null)return"null";if(b=="undefined")return undefined;if(b=="number"||b=="boolean")return a+"";if(b=="string")return $.quoteString(a);if(b=="object"){if(typeof a.toJSON=="function")return $.toJSON(a.toJSON());if(a.constructor===Date){var c=a.getUTCMonth()+1;c<10&&(c="0"+c);var d=a.getUTCDate();d<10&&(d="0"+d);var e=a.getUTCFullYear(),f=a.getUTCHours();f<10&&(f="0"+f);var g=a.getUTCMinutes();g<10&&(g="0"+g);var h=a.getUTCSeconds();h<10&&(h="0"+h);var i=a.getUTCMilliseconds();i<100&&(i="0"+i),i<10&&(i="0"+i);return'"'+e+"-"+c+"-"+d+"T"+f+":"+g+":"+h+"."+i+'Z"'}if(a.constructor===Array){var j=[];for(var k=0;k<a.length;k++)j.push($.toJSON(a[k])||"null");return"["+j.join(",")+"]"}var l=[];for(var m in a){var n,b=typeof m;if(b=="number")n='"'+m+'"';else if(b=="string")n=$.quoteString(m);else continue;if(typeof a[m]=="function")continue;var o=$.toJSON(a[m]);l.push(n+":"+o)}return"{"+l.join(", ")+"}"}},$.evalJSON=function(src){if(typeof JSON=="object"&&JSON.parse)return JSON.parse(src);return eval("("+src+")")},$.secureEvalJSON=function(src){if(typeof JSON=="object"&&JSON.parse)return JSON.parse(src);var filtered=src;filtered=filtered.replace(/\\["\\\/bfnrtu]/g,"@"),filtered=filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]"),filtered=filtered.replace(/(?:^|:|,)(?:\s*\[)+/g,"");if(/^[\],:{}\s]*$/.test(filtered))return eval("("+src+")");throw new SyntaxError("Error parsing JSON, source is not valid.")},$.quoteString=function(a){if(a.match(_escapeable))return'"'+a.replace(_escapeable,function(a){var b=_meta[a];if(typeof b==="string")return b;b=a.charCodeAt();return"\\u00"+Math.floor(b/16).toString(16)+(b%16).toString(16)})+'"';return'"'+a+'"'};var _escapeable=/["\\\x00-\x1f\x7f-\x9f]/g,_meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"}})(jQuery)
;var Mustache=function(){var a=function(){};a.prototype={otag:"{{",ctag:"}}",pragmas:{},buffer:[],pragmas_implemented:{"IMPLICIT-ITERATOR":!0},context:{},render:function(a,b,c,d){d||(this.context=b,this.buffer=[]);if(this.includes("",a)){a=this.render_pragmas(a);var e=this.render_section(a,b,c);if(d)return this.render_tags(e,b,c,d);this.render_tags(e,b,c,d)}else{if(d)return a;this.send(a)}},send:function(a){a!=""&&this.buffer.push(a)},render_pragmas:function(a){if(!this.includes("%",a))return a;var b=this,c=new RegExp(this.otag+"%([\\w-]+) ?([\\w]+=[\\w]+)?"+this.ctag);return a.replace(c,function(a,c,d){if(!b.pragmas_implemented[c])throw{message:"This implementation of mustache doesn't understand the '"+c+"' pragma"};b.pragmas[c]={};if(d){var e=d.split("=");b.pragmas[c][e[0]]=e[1]}return""})},render_partial:function(a,b,c){a=this.trim(a);if(!c||c[a]===undefined)throw{message:"unknown_partial '"+a+"'"};if(typeof b[a]!="object")return this.render(c[a],b,c,!0);return this.render(c[a],b[a],c,!0)},render_section:function(a,b,c){if(!this.includes("#",a)&&!this.includes("^",a))return a;var d=this,e=new RegExp(this.otag+"(\\^|\\#)\\s*(.+)\\s*"+this.ctag+"\n*([\\s\\S]+?)"+this.otag+"\\/\\s*\\2\\s*"+this.ctag+"\\s*","mg");return a.replace(e,function(a,e,f,g){var h=d.find(f,b);if(e=="^")return!h||d.is_array(h)&&h.length===0?d.render(g,b,c,!0):"";if(e=="#")return d.is_array(h)?d.map(h,function(a){return d.render(g,d.create_context(a),c,!0)}).join(""):d.is_object(h)?d.render(g,d.create_context(h),c,!0):typeof h==="function"?h.call(b,g,function(a){return d.render(a,b,c,!0)}):h?d.render(g,b,c,!0):""})},render_tags:function(a,b,c,d){var e=this,f=function(){return new RegExp(e.otag+"(=|!|>|\\{|%)?([^\\/#\\^]+?)\\1?"+e.ctag+"+","g")},g=f(),h=function(a,d,h){switch(d){case"!":return"";case"=":e.set_delimiters(h),g=f();return"";case">":return e.render_partial(h,b,c);case"{":return e.find(h,b);default:return e.escape(e.find(h,b))}},i=a.split("\n");for(var j=0;j<i.length;j++)i[j]=i[j].replace(g,h,this),d||this.send(i[j]);if(d)return i.join("\n")},set_delimiters:function(a){var b=a.split(" ");this.otag=this.escape_regex(b[0]),this.ctag=this.escape_regex(b[1])},escape_regex:function(a){if(!arguments.callee.sRE){var b=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+b.join("|\\")+")","g")}return a.replace(arguments.callee.sRE,"\\$1")},find:function(a,b){function c(a){return a===!1||a===0||a}a=this.trim(a);var d;c(b[a])?d=b[a]:c(this.context[a])&&(d=this.context[a]);if(typeof d==="function")return d.apply(b);if(d!==undefined)return d;return""},includes:function(a,b){return b.indexOf(this.otag+a)!=-1},escape:function(a){a=String(a===null?"":a);return a.replace(/&(?!\w+;)|["<>\\]/g,function(a){switch(a){case"&":return"&amp;";case"\\":return"\\\\";case'"':return'"';case"<":return"&lt;";case">":return"&gt;";default:return a}})},create_context:function(a){if(this.is_object(a))return a;var b=".";this.pragmas["IMPLICIT-ITERATOR"]&&(b=this.pragmas["IMPLICIT-ITERATOR"].iterator);var c={};c[b]=a;return c},is_object:function(a){return a&&typeof a=="object"},is_array:function(a){return Object.prototype.toString.call(a)==="[object Array]"},trim:function(a){return a.replace(/^\s*|\s*$/g,"")},map:function(a,b){if(typeof a.map=="function")return a.map(b);var c=[],d=a.length;for(var e=0;e<d;e++)c.push(b(a[e]));return c}};return{name:"mustache.js",version:"0.3.0",to_html:function(b,c,d,e){var f=new a;e&&(f.send=e),f.render(b,c,d);if(!e)return f.buffer.join("\n")}}}()
;if(jQuery.browser.mozilla||jQuery.browser.opera)document.removeEventListener("DOMContentLoaded",jQuery.ready,!1),document.addEventListener("DOMContentLoaded",function(){jQuery.ready()},!1);jQuery.event.remove(window,"load",jQuery.ready),jQuery.event.add(window,"load",function(){jQuery.ready()}),jQuery.extend({includeStates:{},include:function(a,b,c){typeof b!="function"&&!c&&(c=b,b=null),a=a.replace("\n",""),jQuery.includeStates[a]=!1;var d=document.createElement("script");d.type="text/javascript",d.onload=function(){jQuery.includeStates[a]=!0,b&&b.call(d)},d.onreadystatechange=function(){if(this.readyState=="complete"||this.readyState=="loaded")jQuery.includeStates[a]=!0,b&&b.call(d)},d.src=a,c?(c.constructor!=Array&&(c=[c]),setTimeout(function(){var a=!0;$.each(c,function(b,c){if(!c()){a=!1;return!1}}),a?document.getElementsByTagName("head")[0].appendChild(d):setTimeout(arguments.callee,10)},10)):document.getElementsByTagName("head")[0].appendChild(d);return function(){return jQuery.includeStates[a]}},readyOld:jQuery.ready,ready:function(){jQuery.isReady||(imReady=!0,$.each(jQuery.includeStates,function(a,b){if(!b)return imReady=!1}),imReady?jQuery.readyOld.apply(jQuery,arguments):setTimeout(arguments.callee,10))}})
;(function(a){function l(a){if(!a||typeof a!="string"&&typeof a!="number")throw new TypeError("Key name must be string or numeric");return!0}function k(){try{c[f]=g(b),d&&(d.setAttribute(f,c.jStorage),d.save(f)),e=c[f]?String(c[f]).length:0}catch(a){}}function j(){if(window.localStorage)try{c=window.localStorage,i="localStorage"}catch(a){}else if(window.globalStorage)try{c=window.globalStorage[window.location.hostname],i="globalStorage"}catch(g){}else{d=document.createElement("link");if(!d.addBehavior){d=null;return}d.style.behavior="url(#default#userData)",document.getElementsByTagName("head")[0].appendChild(d),d.load(f);var j="{}";try{j=d.getAttribute(f)}catch(k){}c[f]=j,i="userDataBehavior"}if(c[f])try{b=h(String(c[f]))}catch(l){c[f]="{}"}else c[f]="{}";e=c[f]?String(c[f]).length:0}if(!a||!(a.toJSON||Object.toJSON||window.JSON))throw new Error("jQuery, MooTools or Prototype needs to be loaded before jStorage!");var b={},c={jStorage:"{}"},d=null,e=0,f="jStorage",g=a.toJSON||Object.toJSON||window.JSON&&(JSON.encode||JSON.stringify),h=a.evalJSON||window.JSON&&(JSON.decode||JSON.parse)||function(a){return String(a).evalJSON()},i=!1;_XMLService={isXML:function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1},encode:function(a){if(!this.isXML(a))return!1;try{return(new XMLSerializer).serializeToString(a)}catch(b){try{return a.xml}catch(c){}}return!1},decode:function(a){var b="DOMParser"in window&&(new DOMParser).parseFromString||window.ActiveXObject&&function(a){var b=new ActiveXObject("Microsoft.XMLDOM");b.async="false",b.loadXML(a);return b},c;if(!b)return!1;c=b.call("DOMParser"in window&&new DOMParser||window,a,"text/xml");return this.isXML(c)?c:!1}},a.jStorage={version:"0.1.4.1",setBucket:function(a){f=a;return a},set:function(a,c){l(a),_XMLService.isXML(c)&&(c={_is_xml:!0,xml:_XMLService.encode(c)}),b[a]=c,k(),function(a){function k(a){if(!a||typeof a!="string"&&typeof a!="number")throw new TypeError("Key name must be string or numeric");return!0}function j(){try{c.jStorage=f(b),d&&(d.setAttribute("jStorage",c.jStorage),d.save("jStorage")),e=c.jStorage?String(c.jStorage).length:0}catch(a){}}function i(){if(window.localStorage)try{c=window.localStorage,h="localStorage"}catch(a){}else if(window.globalStorage)try{c=window.globalStorage[window.location.hostname],h="globalStorage"}catch(f){}else{d=document.createElement("link");if(!d.addBehavior){d=null;return}d.style.behavior="url(#default#userData)",document.getElementsByTagName("head")[0].appendChild(d),d.load("jStorage");var i="{}";try{i=d.getAttribute("jStorage")}catch(j){}c.jStorage=i,h="userDataBehavior"}if(c.jStorage)try{b=g(String(c.jStorage))}catch(k){c.jStorage="{}"}else c.jStorage="{}";e=c.jStorage?String(c.jStorage).length:0}if(!a||!(a.toJSON||Object.toJSON||window.JSON))throw new Error("jQuery, MooTools or Prototype needs to be loaded before jStorage!");var b={},c={jStorage:"{}"},d=null,e=0,f=a.toJSON||Object.toJSON||window.JSON&&(JSON.encode||JSON.stringify),g=a.evalJSON||window.JSON&&(JSON.decode||JSON.parse)||function(a){return String(a).evalJSON()},h=!1;_XMLService={isXML:function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1},encode:function(a){if(!this.isXML(a))return!1;try{return(new XMLSerializer).serializeToString(a)}catch(b){try{return a.xml}catch(c){}}return!1},decode:function(a){var b="DOMParser"in window&&(new DOMParser).parseFromString||window.ActiveXObject&&function(a){var b=new ActiveXObject("Microsoft.XMLDOM");b.async="false",b.loadXML(a);return b},c;if(!b)return!1;c=b.call("DOMParser"in window&&new DOMParser||window,a,"text/xml");return this.isXML(c)?c:!1}},a.jStorage={version:"0.1.4.1",set:function(a,c){k(a),_XMLService.isXML(c)&&(c={_is_xml:!0,xml:_XMLService.encode(c)}),b[a]=c,j();return c},get:function(a,c){k(a);if(a in b)return typeof b[a]=="object"&&b[a]._is_xml&&b[a]._is_xml?_XMLService.decode(b[a].xml):b[a];return typeof c=="undefined"?null:c},deleteKey:function(a){k(a);if(a in b){delete b[a],j();return!0}return!1},flush:function(){b={},j();try{window.localStorage.clear()}catch(a){}return!0},storageObj:function(){function a(){}a.prototype=b;return new a},index:function(){var a=[],c;for(c in b)b.hasOwnProperty(c)&&a.push(c);return a},storageSize:function(){return e},currentBackend:function(){return h}},i()}(window.jQuery||window.$);return c},get:function(a,c){l(a);if(a in b)return typeof b[a]=="object"&&b[a]._is_xml&&b[a]._is_xml?_XMLService.decode(b[a].xml):b[a];return typeof c=="undefined"?null:c},deleteKey:function(a){l(a);if(a in b){delete b[a],k();return!0}return!1},flush:function(){b={},k();try{window.localStorage.clear()}catch(a){}return!0},storageObj:function(){function a(){}a.prototype=b;return new a},index:function(){var a=[],c;for(c in b)b.hasOwnProperty(c)&&a.push(c);return a},storageSize:function(){return e},currentBackend:function(){return i}},j()})(window.jQuery||window.$)
;if(typeof require=="function")var sys=require("sys"),http=require("http"),url=require("url"),path=require("path"),fs=require("fs"),querystring=require("querystring"),_=require("./underscore"),Mustache=require("./common.mustache.js");typeof redman=="undefined"&&(redman={},redman=redman.prototype=function(){typeof window=="undefined"&&eval("var window = module"),typeof window.jQuery=="undefined"&&(window.jQuery=undefined);var _prototype="prototype",config={debug:!1,debugOptions:{element:"#debug",firstE:"h1",messageE:"p",consoleOnly:!0},loadPath:"/javascripts/",ajaxOptions:{dataType:"json"}},state={debug:{}},isBrowser=function(){if(window.jQuery!==undefined)return!0},debug=function(a,b){if(config.debug){isBrowser()||(config.debugOptions.consoleOnly=!0);var c,d="";typeof a=="object"&&(b=a);if(b){b.startTimer&&(state.debug||(state.debug={}),state.debug.queues||(state.debug.queues={}),state.debug.queues[b.startTimer]||(state.debug.queues[b.startTimer]=[]),state.debug.queues[b.startTimer].push([(new Date).getTime(),a]),c=state.debug.queues[b.startTimer].length-1,a+="["+c+"]");if(b.showTimer){b.uid||(b.uid=0),c=b.uid;var e;if(state.debug.queues[b.showTimer])if(e=state.debug.queues[b.showTimer][c]){var f=(new Date).getTime(),g=e[0];a=e[1],b.message&&(a=b.message);var h=f-g;h>1e3?h=h/1e3+"s":h=h+"ms",a+="["+c+"@"+h+"]"}else a+="["+b.showTimer+" not started]";d="result"}}!config.debugOptions.consoleOnly&&jQuery(config.debugOptions.element).size()==0&&jQuery("body").append("<div id='debug'><h1>DEBUG:</h1></div>"),config.debugOptions.consoleOnly||(jQuery(config.debugOptions.element).find(config.debugOptions.firstE).after("<"+config.debugOptions.messageE+' class="'+d+'">'+a+"</"+config.debugOptions.messageE+">"),jQuery(config.debugOptions.element).filter(":hidden").fadeIn(0),jQuery(config.debugOptions.element).find(config.debugOptions.messageE).filter(":first").delay(1e4).fadeOut(0,function(){jQuery(this).remove()}));try{if("console"in window||"console"in global)"log"in console&&console.log(a)}catch(i){}return c}};window.jQuery&&typeof jQuery.debug=="undefined"&&(jQuery.debug=debug);var storage=window.jQuery?jQuery.jStorage:new function(){debug("warning: in node session local storage");var a=this;a.get=function(a){return!1},a.set=function(a,b){return!1}},load=function(a,b,c){debug("trying to load"+a);var d=config.loadPath+"redman.";typeof b=="function"&&c==undefined&&(c=b,b=undefined),b!=undefined&&(d=config.loadPath+b),redman[a]==undefined||b?(c==undefined&&(c=function(){debug("loaded "+a+".js")}),jQuery.include(d+a+".js",c)):typeof c=="function"?c.call():c=function(){debug(a+".js already available, not loading")}};if(window.jQuery&&window.jQuery.ajax)var ajax=jQuery.ajax;else var ajax=function(a){var b=a.url,c=a.success||a.callback,d=a.error||a.callback,e=a.type?a.type.toUpperCase():"GET",f=querystring.stringify(a.data);if(/http:\/\//.test(b)){b=url.parse(b);var g=http.createClient(80,b.host),h={host:b.host};f!==undefined&&e=="POST"&&(h["Content-type"]="application/x-www-form-urlencoded",h["Content-Length"]=f.length.toString());var i=b.href;e=="GET"&&f!==undefined&&(i+=(i.match(/\?/g)?"&":"?")+f);var j=g.request(e,i,h);f!==undefined&&e=="POST"&&j.write(f),j.on("response",function(e){var f="";e.setEncoding("utf8"),e.on("data",function(a){f+=a}),e.on("end",function(){if(e.statusCode==200){if(/\json/.test(a.dataType))try{f=JSON.parse(f)}catch(g){console.log(__filename.replace(__dirname+"/","")+": JSON PARSE ERROR\n"),console.log(f),typeof d=="function"&&d(new Error("JSON Parse Error"))}c(f)}else console.log(b.href),console.log(__filename.replace(__dirname+"/","")+": STATUS CODE "+e.statusCode+"\n"),typeof d=="function"&&d(new Error("HTTP Error: "+e.statusCode))})}),j.end()}else fs.readFile("./public/"+b,"utf8",function(a,e){a&&d(new Error("File Error: "+b+", "+a)),c(e)})};var render={},render=render.prototype=function(){var a=storage.get("render.cache"),b=a?a:{},c={},d=function(a,c){b[a]=c,storage.set("render.cache",b)},e=function(a,c,e,g){var h=this;typeof e=="function"&&g==undefined&&(g=e,e={}),h.templatePath=a,h.view=c,h.callback=g,h.options=e||{};if(b[a]==undefined){b[a]=!1,redman.debug("loading template ("+a+") from server");var i=!1;ajax({url:a,dataType:"text",complete:function(b,c){if(!i&&b.readyState==4&&b.status==200){debug("template "+a+" ready");var e=b.responseText;d(a,e)}},success:function(b){i=!0,debug("template "+a+" ready");var c=b;d(a,c)}})}f.call(h)},f=function(){var a=this;g.call(a,function(){var c=b[a.templatePath],d=Mustache.to_html(c,a.view,a.options.partials);typeof a.callback=="function"&&a.callback(d)})},g=function(a){var c=this,d=c.renderQueue(),e=!1;d.length>0?e=d[0]==c:e=!0,b[this.templatePath]!=undefined&&b[this.templatePath]!=!1&&e?(d.shift(),a()):(c.inQueue||c.addToRenderQueue(),setTimeout(function(){g.call(c,a)},0))};e.prototype.renderQueue=function(){this.templatePath in d||(d[this.templatePath]=[]);var a=d[this.templatePath];return a},e.prototype.addToRenderQueue=function(){var a=this;this.templatePath in d||(d[this.templatePath]=[]);var b=d[this.templatePath];this.inQueue||(this.inQueue=!0,b.push(this))};return{Template:e}}(),EventBroadcaster=function(a){this.events={};for(var b=0;b<a.length;b++)this.events[a[b]]=[]},eventPrototype=EventBroadcaster[_prototype];eventPrototype.subscribe=function(a,b){function c(a){return a?a instanceof Array?a:[a]:[]}typeof b=="function"&&(b={handler:b});if(!b.handler)throw"eventPrototype.subscribe: no handler given.";b=b||{},signals=a.split(" ");for(var d in signals){var a=signals[d];this.events[a]||(this.events[a]=[]),this.events[a].push({handler:function(a){b.handler.apply(b.scope||window,c(b.curry).concat(c(a)))},once:b.once})}},eventPrototype.once=function(a,b){b=b||{},b.once=!0,this.subscribe(a,b)},eventPrototype.broadcast=function(a,b){if(!this.events[a])return debug("!!!! EventBroadcaster broadcast, signal not recognized: "+a);var c=this.events[a];debug("++ Detected "+a+". Triggering "+c.length+" events ++");for(var d=0;d<c.length;d++)c[d].handler&&c[d].handler(b),c[d].once&&delete c[d]},eventPrototype.fire=eventPrototype.publish=eventPrototype.broadcast;var extend=window.jQuery?window.jQuery.extend:_.extend;return{ajax:ajax,config:config,extend:extend,state:state,debug:debug,EventBroadcaster:EventBroadcaster,load:load,storage:storage,render:render}}()),typeof module!=="undefined"&&("exports"in module&&(module.exports=redman))
;typeof redman.navpane=="undefined"&&(redman.navpane={},redman.navpane=redman.navpane.prototype=function(){function d(){if(redman.navpane.options.animate){redman.navpane.nextState.toPage.style.left="100%",redman.navpane.nextState.toPage.setAttribute("selected","true");var a=100,b=setInterval(function(){a+=redman.navpane.options.animateX,a<=0&&(a=0,redman.navpane.nextState.fromPage.removeAttribute("selected"),clearInterval(b)),redman.navpane.nextState.fromPage.style.left=(redman.navpane.nextState.backwards?100-a:a-100)+"%",redman.navpane.nextState.toPage.style.left=(redman.navpane.nextState.backwards?-a:a)+"%"},redman.navpane.options.animateInterval)}else $(redman.navpane.nextState.fromPage).hide(),$(redman.navpane.nextState.toPage).show()}var a={width:0,container:".navSelector",pageHistory:[],page:!1},b={animateX:-20,animateInterval:24,container:"#Regions",animate:function(){var a=parseFloat(navigator.appVersion.split("MSIE")[1]);if(navigator.appVersion.indexOf("MSIE 7.")!=-1)return!1;return!0}()},c={},e=function(a,b){if(!b||redman.navpane.currentState.pageHistory.length!=0)if(redman.navpane.currentState.page!=a){redman.navpane.currentState.page||(redman.navpane.currentState.page=$(".navViewer ul:first").get(0));var c=redman.navpane.currentState.page,e="",f;if(b){var g=redman.navpane.currentState.pageHistory.pop(),h=redman.navpane.currentState.pageHistory[redman.navpane.currentState.pageHistory.length-1];f=g[1],h&&(e=h[0])}else f=a,e=c.title,redman.navpane.currentState.pageHistory.push([c.title,c]);$.debug("swipe "+JSON.stringify([f.id,f.title])),redman.navpane.currentState.page=f;var i=$(".pageTitle strong").get(0),j=f.title,k=16;j=j.replace(/[^\w\s]/gi," ");if(j.length>k){var l=f.title.length-k;j=".."+j.substr(l,k)}i.innerHTML=j||"";var m=$("#homeButton");m.text(e),"#"+f.id==m.get(0).hash?m.hide():m.show(),c&&(redman.navpane.nextState={fromPage:c,toPage:f,backwards:b},setTimeout(d,0))}},f=function(){redman.navpane.showPage(null,!0)};return{options:b,currentState:a,showPage:e,lastPage:f}}())
;typeof redman.maps=="undefined"&&(redman.maps={},redman.maps.init=function(){redman.maps=redman.maps.prototype=function(){var a=this,b,c="prototype";this._styles={priceproperty:{name:"priceproperty",width:32,height:37,zIndex:1001,offset:{x:16,y:18}},multilisting:{name:"multilisting",width:32,height:37,offset:{x:16,y:18},zIndex:1001}};var d=function(){return a._styles},e=function(a){return d()[a]},f=function f(a,b,c,d){this.style=e(a),this.gLoc=b,this.map=c,this.options=d,this.div=null,this.setMap(c)},g=function g(a,b,c,d){this.gLoc=b,this.map=c,this.pane=a,this.options=d,this.div=null,this.setMap(c)},h=function h(a,b,c){this.lat=a,this.lon=b,this.markers=[c]};h[c].addMarker=function(a){this.markers.push(a)},f[c]=new google.maps.OverlayView,f[c].makeActive=function(){this.clearActive(c);if(this.div!==null){var a=document.createElement("div");$(a).addClass("activeMarker"),this.active_layer=a;var b=redman.listings.cache().length+1;$(this.div).css("zIndex",b).addClass("active"),this.div.appendChild(this.active_layer)}else{var c=c!==undefined?c+1:0;redman.debug("no Marker, deferring makeActive"),c<5&&function(a,b){setTimeout(function(){a.makeActive(b)},100)}(this,c)}},f[c].clearActive=function(){$(".activeMarker").remove(),$(".propertyMarker, .clusterMarker").css("zIndex",""),this.active_layer=null},f[c].onAdd=function(){var a=this;this.div==null&&a.buildMarker[a.style.name](a),this.getPanes().overlayImage.appendChild(this.div),this.getPanes().overlayImage.style.zIndex=this.style.zIndex},f[c].draw=function(){var a=this.getProjection().fromLatLngToDivPixel(this.gLoc);this.div.style.left=a.x-(this.style.offset?this.style.offset.x:0)+"px",this.div.style.top=a.y-(this.style.offset?this.style.offset.y:0)+"px"},f[c].hide=function(){this.div.style.visibility="hidden"},f[c].onRemove=function(){this.div.parentNode.removeChild(this.div),this.div=null},f[c].show=function(){this.div.style.visibility="visible"},f[c].buildMarker={},f[c].buildMarker.multilisting=function(a){a.div=document.createElement("div"),a.div.style.width=a.style.width+"px",a.div.style.height=a.style.height+"px",a.div.className="clusterMarker";var b=document.createElement("div"),c=document.createElement("span");c.innerHTML=a.options.cluster.markers.length,b.appendChild(c),a.div.appendChild(b),a.div.style.cursor="pointer",google.maps.event.addDomListener(a.div,"click",function(){google.maps.event.trigger(a,"click");var b=redman.CPSearch.state.dialog.getProjection().fromLatLngToDivPixel(a.gLoc);b.y=b.y-50,a.map.setCenter(a.gLoc),a.map.panBy(0,-130)});return a.div},f[c].buildMarker.priceproperty=function(a){a.div=document.createElement("div"),a.div.style.width=a.style.width+"px",a.div.style.height=a.style.height+"px",a.div.className="propertyMarker";var b=document.createElement("div"),c=document.createElement("span"),d=parseInt(typeof a.options.listing.price=="string"?a.options.listing.price.replace(/,|\$/g,""):a.options.listing.price),e=parseInt(d/1e3);c.innerHTML=e+"K",b.appendChild(c),a.div.appendChild(b),a.div.style.cursor="pointer",google.maps.event.addDomListener(a.div,"click",function(){google.maps.event.trigger(a,"click")});return a.div},g[c]=new google.maps.OverlayView,g[c].onAdd=function(){this.div==null&&(this.div=$("#clusterSelector").clone().get(0),this.div.style.position="absolute",this.getPanes().overlayImage.appendChild(this.div),this.getPanes().overlayImage.style.zIndex=1002)},g[c].draw=function(){var a=this.getProjection().fromLatLngToDivPixel(this.gLoc);this.div.style.display="block",this.div.style.left=a.x-25+"px",this.div.style.top=a.y-152+"px",this.div.style.zIndex="100"},g[c].hide=function(){this.div.style.visibility="hidden"},g[c].show=function(){this.div.style.visibility="visible"},g[c].onRemove=function(){this.div.style.visibility="hidden",this.div.parentNode.removeChild(this.div),this.div=null};return{init:function(){return!0},Marker:f,Cluster:h,Dialog:g,getStyles:d,getStyle:e,map:b}}()},window.google&&window.google.maps&&redman.maps.init())
;if(typeof require!=="undefined")var redman=require("./redman.js");typeof redman.listings=="undefined"&&(redman.listings={},redman.listings=redman.listings.prototype=function(){var a=this,b="prototype";c=function c(a,b){this.data=a,this.options=b,this.data.location&&(this.location={lat:this.data.location.lat,lon:this.data.location.lon})},listingObject=c[b],listingObject.render=function(a,b,c,d){var e=this.data,f;new redman.render.Template("/community-property-search-classic/templates/"+a+".html?v=2010102201",e,function(e){b.context!==undefined?(f=$(e).appendTo(b),d==redman.listings.cache().length-1&&redman.debug({showTimer:a}),typeof c=="function"&&c.call(f)):"length"in b?(f=b.push(e),b.length==redman.listings.cache().length&&(redman.listings.events.broadcast("renderCache",[b,a]),typeof c=="function"&&c(b,a))):(f=e,typeof c=="function"&&c.call(f))});return f};var d={items:[]},e=_cache_confident_center=!1;clear_cache=function(){d.items=[],e=_cache_confident_center=!1},cache=function(a){return a===undefined?d.items:a<d.items.length?d.items[a]:null},renderCache=function(a,b,c){for(var d in redman.listings.cache()){var e=redman.listings.cache()[d];(function(a,b,c,d,e){setTimeout(function(){"render"in a&&a.render(b,c,e,d)},1)})(e,a,b,d,c)}},avgLatLon=function(a){var b,c;if(e===!1){var d=0,f=0,g=0;for(var h in redman.listings.cache()){var i=redman.listings.cache()[h];i.location&&i.location.lat&&i.location.lon&&(d+=i.location.lat,f+=i.location.lon,g+=1)}b=g>0?d/g:0,c=g>0?f/g:0,e={lat:b,lon:c}}if(a=="lat")return e.lat;if(a=="lon")return e.lon;return e},stdDev=function(){var a=this.avgLatLon(),b=a.lat,c=a.lon,d=0,e=0,f=redman.listings.cache();for(var g in f){var h=f[g];h.location&&h.location.lat&&h.location.lon&&(d+=Math.pow(h.location.lat-b,2),e+=Math.pow(h.location.lon-c,2))}return{lat:Math.sqrt(d),lon:Math.sqrt(e)}},confidentCenter=function(){if(!_cache_confident_center){var a=0,b=0,c=0,d=this.stdDev(),e=this.avgLatLon(),f=redman.listings.cache(),g={high:{lat:e.lat+2*d.lat,lon:e.lon+2*d.lon},low:{lat:e.lat-2*d.lat,lon:e.lon-2*d.lon}};for(var h in f){var i=f[h],j=i.location;if(j&&j.lat&&j.lon){var k=j.lat,l=j.lon;k>=g.low.lat&&k<=g.high.lat&&l>=g.low.lon&&l<=g.high.lon&&(b+=i.location.lat,c+=i.location.lon,a++)}}_cache_confident_center={lat:a>0?b/a:0,lon:a>0?c/a:0}}return _cache_confident_center},events=new redman.EventBroadcaster([]),processQuery=function(a,b){var c=b.queryRoot||redman.listings.query.options.queryRoot,d=b.board||redman.listings.query.options.board,e=[],a=c+a.replace(":board",d),f=b.event||"query.complete",g;events.broadcast("query.start",{event:f}),redman.listings.clear_cache(),redman.ajax({url:a,dataType:redman.config.ajaxOptions.dataType,error:function(a,b,c){events.broadcast("query.error",arguments),events.broadcast(f,["error",[],arguments])},success:function(a){if(a){var c=a;b.singleResult===!0&&a&&(c={},c.results=[a],c.count=c.results.length),e=c.results,e==undefined&&(e={}),e.count=a.count==undefined?a.length:a.count,e.total=a.total==undefined?0:a.total;if(c.count==0)c.outOfBoard&&c.outOfBoard==!0?g="outOfBoard":g="noListings";else{g="success";if(b.cache!==!1)for(var d=0;d<c.results.length;d=d+1){var h=new redman.listings.Listing(c.results[d]);redman.listings.cache().push(h),events.broadcast("cache.addedListing",[h,d])}}b.singleResult&&(g="single"),events.broadcast(f,[g,e]),typeof b.callback=="function"&&b.callback(e)}}})},query={options:{queryRoot:"",board:"",params:{type:{residential:"yes",condo:"yes",rural:"yes",commercial:"yes"},description:{price:"0..nolim",size:"0..nolim",bedrooms:"0..nolim",bathrooms:"0..nolim"}}},get:function(a,b){var c=Array.prototype.slice.call(arguments);typeof a=="object"&&b==undefined&&(b=a,a=b.id),b===undefined&&(b={}),b.singleResult=!0;var d="/listings/v1/:board/"+a+".json";typeof c[c.length-1]=="function"&&(b.callback=b.callback||c.pop()),processQuery(d,b)},byId:function(a){var b=Array.prototype.slice.call(arguments);a===undefined&&(a={});var c="";for(var d in a.params.ids)c+="listings[]="+a.params.ids[d]+"&";c=c.replace(/&$/,"");var e="/listings/v1/"+a.board+"/by_id?"+c;typeof a=="function"&&(a={callback:a}),typeof b[b.length-1]=="function"&&(a.callback=a.callback||b.pop()),processQuery(e,a)},byCommunity:function(a,b){var c=Array.prototype.slice.call(arguments);typeof a=="object"&&(b==undefined||typeof b=="function")&&(b=a,a=b.community),b===undefined&&(b={});var d=["communities="+a||b.communities&&b.communities.map(function(a){return encodeURI(a)}).join(",")];b.params&&(b.params.description&&(b.params.description.price&&d.push("price="+b.params.description.price),b.params.description.size&&d.push("size="+b.params.description.size),b.params.description.bedrooms&&d.push("bedrooms="+b.params.description.bedrooms),b.params.description.bathrooms&&d.push("bathrooms="+b.params.description.bathrooms)),b.params.timestamp&&d.push("timestamp="+b.params.timestamp),b.params.type.residential=="yes"&&d.push("residential=yes"),b.params.type.condo=="yes"&&d.push("condo=yes"),b.params.type.rural=="yes"&&d.push("rural=yes"),b.params.type.commercial=="yes"&&d.push("commercial=yes"),b.params.limit>0&&d.push("limit="+b.params.limit),b.params.lastNum&&d.push("lastNum="+b.params.lastNum));var e="/listings/v1/:board/by_community?"+d.join("&"),f;typeof b=="function"&&(b={callback:b}),typeof c[c.length-1]=="function"&&(b.callback=b.callback||c.pop()),b.event==undefined&&(b.event="byCommunity"),processQuery(e,b)},byProximity:function(a){var b=a.location,c=a.range,d=a.limit,e=a.params,f="/listings/v1/:board/by_range.json?latitude="+b.lat+"&longitude="+b.lon;c!==undefined&&(f+="&range="+c),d!==undefined&&(f+="&limit="+d);if(e!==undefined){if(e.type!==undefined)for(k in e.type)e.type.hasOwnProperty(k)&&e.type[k]=="yes"&&(f+=encodeURI("&"+k+"="+e.type[k]));if(e.description!==undefined)for(k in e.description)if(e.description.hasOwnProperty(k)){var g=e.description[k];f+=encodeURI("&"+k+"="+g)}}a.event==undefined&&(a.event="byProximity"),processQuery(f,a)}};return{events:events,Listing:c,renderCache:renderCache,cache:cache,clear_cache:clear_cache,avgLatLon:avgLatLon,stdDev:stdDev,confidentCenter:confidentCenter,query:query}}()),typeof module!=="undefined"&&("exports"in module&&(module.exports=redman.listings))
;if(typeof require!=="undefined")var redman=require("./redman.js");typeof redman.communities=="undefined"&&(redman.communities={},redman.communities=redman.communities.prototype=function(){var a=this,b=[],c={timestamp:"communities.cache.timestamp",json:"communities.cache"},d=!1,e=function n(a,b){for(var c in a)this[c]=a[c];this.data=a,this.options=b},f=function f(a,b){this.name=a,this.communities=[],b!==undefined&&(this.communities=b),this.communitiesData=function(){var a=[];for(var b in this.communities){var c=this.communities[b];a.push(c.data)}return a}},g=function(){var a=new Date(redman.storage.get(c.timestamp)),b=new Date;a&&b-a<=864e5?(d=redman.storage.get(c.json),b-a&&(d&&k(d))):(redman.debug("communities detected expired local_cache"),d=!1);return d},h=function(){redman.storage.set(c.json,redman.communities.cache("json")),redman.storage.set(c.timestamp,JSON.stringify(new Date))},i=function(a,c){if(a=="json"){c!=undefined&&(d=c,h());var e=d}else{c!=undefined&&(b=c);var e=b}return e},j=function(a,b){return a.name<b.name?-1:1},k=function(a,c){c==undefined&&(c={});var d=a.zones;for(var g=0;g<d.length;g=g+1)var h=d[g],i=h.communities;if(c.createObject)for(var g=0;g<d.length;g=g+1){var h=d[g],i=h.communities,j=new f(h.zoneName);for(var k=0;k<i.length;k=k+1)community=new e(i[k]),j.communities.push(community),l.broadcast("zone.addedCommunity",[community,k]);b.push(j),l.broadcast("cache.addedZone",[j,g])}l.broadcast("query.getCommunitiesByZone")},l=new redman.EventBroadcaster([]),m={options:{queryRoot:"",province:null,region:null,city:null},getCommunitiesByZone:function(a){g();if(i("json"))redman.debug("communities: loading from local storage");else{redman.debug("communities: loading from json");var b=redman.communities.query.options,c=b.queryRoot+"/communities/v1/"+b.province+"/"+b.region+"/"+b.city;a===undefined&&(a={}),typeof a=="function"&&(a={callback:a}),redman.ajax({type:"GET",url:c,async:!0,dataType:redman.config.ajaxOptions.dataType,success:function(b){redman.communities.cache("json",b),b?(k(b),typeof a.callback=="function"&&a.callback(b)):redman.debug("no data found")}})}},getZones:function(a){var b=redman.communities.query.options,c=a.queryRoot||b.queryRoot,d=c+"/listings/v1/"+(a.board||b.board)+"/get_zones.json";a===undefined&&(a={}),typeof a=="function"&&(a={callback:a}),redman.ajax({type:"GET",url:d,async:!0,dataType:redman.config.ajaxOptions.dataType,success:function(b){l.broadcast("query.getZones",b),typeof a.callback=="function"&&a.callback(b)}})},getCommunities:function(a,b){var c=redman.communities.query.options,d=b.queryRoot||c.queryRoot,e=d+"/listings/v1/"+c.board+"/get_communities.json?"+a;b===undefined&&(b={}),typeof b=="function"&&(b={callback:b}),redman.ajax({type:"GET",url:e,async:!0,dataType:redman.config.ajaxOptions.dataType,success:function(a){l.broadcast("query.getCommunities",a),typeof b.callback=="function"&&b.callback(a)}})},getSubcommunities:function(a,b){var c=redman.communities.query.options,d=b.queryRoot||c.queryRoot,e=d+"/listings/v1/"+c.board+"/get_subcommunities.json?"+a;b===undefined&&(b={}),typeof b=="function"&&(b={callback:b}),redman.ajax({type:"GET",url:e,async:!0,dataType:redman.config.ajaxOptions.dataType,success:function(a){l.broadcast("query.getSubcommunities",a),typeof b.callback=="function"&&b.callback(a)}})},findCommunitiesByName:function(a,b){var c="community="+encodeURIComponent(a),d=redman.communities.query.options,e=d.queryRoot+"/listings/v1/"+d.board+"/get_communities_by_name.json?"+c;b===undefined&&(b={}),typeof b=="function"&&(b={callback:b}),redman.ajax({type:"GET",url:e,async:!0,dataType:redman.config.ajaxOptions.dataType,success:function(a){l.broadcast("query.findCommunitiesByName",a),typeof b.callback=="function"&&b.callback(a)}})},getCommunitySubareas:function(a){var b=redman.communities.query.options,c=a.code,d=b.queryRoot+"/get_area_detail/"+c;redman.ajax({type:"GET",url:d,async:!0,dataType:redman.config.ajaxOptions.dataType,success:function(a){l.broadcast("query.getCommunitySubareas",a)}})}};return{cache:i,Community:e,events:l,query:m}}()),typeof module!=="undefined"&&("exports"in module&&(module.exports=redman.communities))
;if(typeof require!=="undefined")var redman=require("./redman.js");typeof redman.offices=="undefined"&&(redman.offices={},redman.offices=redman.offices.prototype=function(){var a=new redman.EventBroadcaster([]),b=function(a,b){var c=this;c.resource=a,c.uri="offices/v1/"+a+".json",c.options=b||{};return function(a){var b=Array.prototype.slice.call(arguments);typeof b[b.length-1]=="function"&&(a.callback=a.callback||b.pop()),c.params={args:a,uri:c.uri.replace(/:id/g,a.officeId).replace(/:agentId/g,a.agentId),method:c.options.method},redman.extend(c.params,c.options),c.execute()}};b.prototype.execute=function(){var b=this.params,c=redman.offices.query.options,d=b.args.queryRoot||c.queryRoot,e=b.method?b.method:"GET",f=b.args.event||"query.complete",g=this;redman.ajax({type:e,data:b.args.params,url:d+"/"+b.uri,dataType:redman.config.ajaxOptions.dataType,success:function(c){typeof b.args.callback=="function"?b.args.callback(null,c):null,a.broadcast(f,["success",c.results||c])},error:function(a){a.message="redman.offices.query "+e+" "+g.resource+" responded "+a.message,typeof b.args.callback=="function"?b.args.callback(a):null}})};var c={options:{queryRoot:""},getOfficeById:new b(":id"),getAgentsByOfficeId:new b(":id/agents"),getAgentById:new b(":id/agents/:agentId"),getAgentOnDuty:new b(":id/agent_on_duty"),contactAgentById:new b(":id/agents/:agentId/contact",{method:"post"}),getPersonalListingsByAgentId:new b(":id/agents/:agentId/listings"),getOfficeListings:new b(":id/listings")};return{query:c,events:a}}()),typeof module!=="undefined"&&("exports"in module&&(module.exports=redman.offices))

