/*ALLCommonElements_key*/
/*! JSON v3.2.4 | http://bestiejs.github.com/json3 | Copyright 2012, Kit Cambridge | http://kit.mit-license.org */
;(function(){var e=void 0,i=!0,k=null,l={}.toString,m,n,p="function"===typeof define&&define.c,q=!p&&"object"==typeof exports&&exports;q||p?"object"==typeof JSON&&JSON?p?q=JSON:(q.stringify=JSON.stringify,q.parse=JSON.parse):p&&(q=this.JSON={}):q=this.JSON||(this.JSON={});var r,t,u,x,z,B,C,D,E,F,G,H,I,J=new Date(-3509827334573292),K,O,P;try{J=-109252==J.getUTCFullYear()&&0===J.getUTCMonth()&&1==J.getUTCDate()&&10==J.getUTCHours()&&37==J.getUTCMinutes()&&6==J.getUTCSeconds()&&708==J.getUTCMilliseconds()}catch(Q){}
function R(b){var c,a,d,j=b=="json";if(j||b=="json-stringify"||b=="json-parse"){if(b=="json-stringify"||j){if(c=typeof q.stringify=="function"&&J){(d=function(){return 1}).toJSON=d;try{c=q.stringify(0)==="0"&&q.stringify(new Number)==="0"&&q.stringify(new String)=='""'&&q.stringify(l)===e&&q.stringify(e)===e&&q.stringify()===e&&q.stringify(d)==="1"&&q.stringify([d])=="[1]"&&q.stringify([e])=="[null]"&&q.stringify(k)=="null"&&q.stringify([e,l,k])=="[null,null,null]"&&q.stringify({A:[d,i,false,k,"\x00\u0008\n\u000c\r\t"]})==
'{"A":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}'&&q.stringify(k,d)==="1"&&q.stringify([1,2],k,1)=="[\n 1,\n 2\n]"&&q.stringify(new Date(-864E13))=='"-271821-04-20T00:00:00.000Z"'&&q.stringify(new Date(864E13))=='"+275760-09-13T00:00:00.000Z"'&&q.stringify(new Date(-621987552E5))=='"-000001-01-01T00:00:00.000Z"'&&q.stringify(new Date(-1))=='"1969-12-31T23:59:59.999Z"'}catch(f){c=false}}if(!j)return c}if(b=="json-parse"||j){if(typeof q.parse=="function")try{if(q.parse("0")===0&&!q.parse(false)){d=
q.parse('{"A":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}');if(a=d.a.length==5&&d.a[0]==1){try{a=!q.parse('"\t"')}catch(o){}if(a)try{a=q.parse("01")!=1}catch(g){}}}}catch(h){a=false}if(!j)return a}return c&&a}}
if(!R("json")){J||(K=Math.floor,O=[0,31,59,90,120,151,181,212,243,273,304,334],P=function(b,c){return O[c]+365*(b-1970)+K((b-1969+(c=+(c>1)))/4)-K((b-1901+c)/100)+K((b-1601+c)/400)});if(!(m={}.hasOwnProperty))m=function(b){var c={},a;if((c.__proto__=k,c.__proto__={toString:1},c).toString!=l)m=function(a){var b=this.__proto__,a=a in(this.__proto__=k,this);this.__proto__=b;return a};else{a=c.constructor;m=function(b){var c=(this.constructor||a).prototype;return b in this&&!(b in c&&this[b]===c[b])}}c=
k;return m.call(this,b)};n=function(b,c){var a=0,d,j,f;(d=function(){this.valueOf=0}).prototype.valueOf=0;j=new d;for(f in j)m.call(j,f)&&a++;d=j=k;if(a)a=a==2?function(a,b){var c={},d=l.call(a)=="[object Function]",f;for(f in a)!(d&&f=="prototype")&&!m.call(c,f)&&(c[f]=1)&&m.call(a,f)&&b(f)}:function(a,b){var c=l.call(a)=="[object Function]",d,f;for(d in a)!(c&&d=="prototype")&&m.call(a,d)&&!(f=d==="constructor")&&b(d);(f||m.call(a,d="constructor"))&&b(d)};else{j=["valueOf","toString","toLocaleString",
"propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"];a=function(a,b){var c=l.call(a)=="[object Function]",d;for(d in a)!(c&&d=="prototype")&&m.call(a,d)&&b(d);for(c=j.length;d=j[--c];m.call(a,d)&&b(d));}}a(b,c)};R("json-stringify")||(r={"\\":"\\\\",'"':'\\"',"\u0008":"\\b","\u000c":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},t=function(b,c){return("000000"+(c||0)).slice(-b)},u=function(b){for(var c='"',a=0,d;d=b.charAt(a);a++)c=c+('\\"\u0008\u000c\n\r\t'.indexOf(d)>-1?r[d]:r[d]=d<" "?
"\\u00"+t(2,d.charCodeAt(0).toString(16)):d);return c+'"'},x=function(b,c,a,d,j,f,o){var g=c[b],h,s,v,w,L,M,N,y,A;if(typeof g=="object"&&g){h=l.call(g);if(h=="[object Date]"&&!m.call(g,"toJSON"))if(g>-1/0&&g<1/0){if(P){v=K(g/864E5);for(h=K(v/365.2425)+1970-1;P(h+1,0)<=v;h++);for(s=K((v-P(h,0))/30.42);P(h,s+1)<=v;s++);v=1+v-P(h,s);w=(g%864E5+864E5)%864E5;L=K(w/36E5)%24;M=K(w/6E4)%60;N=K(w/1E3)%60;w=w%1E3}else{h=g.getUTCFullYear();s=g.getUTCMonth();v=g.getUTCDate();L=g.getUTCHours();M=g.getUTCMinutes();
N=g.getUTCSeconds();w=g.getUTCMilliseconds()}g=(h<=0||h>=1E4?(h<0?"-":"+")+t(6,h<0?-h:h):t(4,h))+"-"+t(2,s+1)+"-"+t(2,v)+"T"+t(2,L)+":"+t(2,M)+":"+t(2,N)+"."+t(3,w)+"Z"}else g=k;else if(typeof g.toJSON=="function"&&(h!="[object Number]"&&h!="[object String]"&&h!="[object Array]"||m.call(g,"toJSON")))g=g.toJSON(b)}a&&(g=a.call(c,b,g));if(g===k)return"null";h=l.call(g);if(h=="[object Boolean]")return""+g;if(h=="[object Number]")return g>-1/0&&g<1/0?""+g:"null";if(h=="[object String]")return u(g);if(typeof g==
"object"){for(b=o.length;b--;)if(o[b]===g)throw TypeError();o.push(g);y=[];c=f;f=f+j;if(h=="[object Array]"){s=0;for(b=g.length;s<b;A||(A=i),s++){h=x(s,g,a,d,j,f,o);y.push(h===e?"null":h)}b=A?j?"[\n"+f+y.join(",\n"+f)+"\n"+c+"]":"["+y.join(",")+"]":"[]"}else{n(d||g,function(b){var c=x(b,g,a,d,j,f,o);c!==e&&y.push(u(b)+":"+(j?" ":"")+c);A||(A=i)});b=A?j?"{\n"+f+y.join(",\n"+f)+"\n"+c+"}":"{"+y.join(",")+"}":"{}"}o.pop();return b}},q.stringify=function(b,c,a){var d,j,f,o,g,h;if(typeof c=="function"||
typeof c=="object"&&c)if(l.call(c)=="[object Function]")j=c;else if(l.call(c)=="[object Array]"){f={};o=0;for(g=c.length;o<g;h=c[o++],(l.call(h)=="[object String]"||l.call(h)=="[object Number]")&&(f[h]=1));}if(a)if(l.call(a)=="[object Number]"){if((a=a-a%1)>0){d="";for(a>10&&(a=10);d.length<a;d=d+" ");}}else l.call(a)=="[object String]"&&(d=a.length<=10?a:a.slice(0,10));return x("",(h={},h[""]=b,h),j,f,d,"",[])});R("json-parse")||(z=String.fromCharCode,B={"\\":"\\",'"':'"',"/":"/",b:"\u0008",t:"\t",
n:"\n",f:"\u000c",r:"\r"},C=function(){H=I=k;throw SyntaxError();},D=function(){for(var b=I,c=b.length,a,d,j,f,o;H<c;){a=b.charAt(H);if("\t\r\n ".indexOf(a)>-1)H++;else{if("{}[]:,".indexOf(a)>-1){H++;return a}if(a=='"'){d="@";for(H++;H<c;){a=b.charAt(H);if(a<" ")C();else if(a=="\\"){a=b.charAt(++H);if('\\"/btnfr'.indexOf(a)>-1){d=d+B[a];H++}else if(a=="u"){j=++H;for(f=H+4;H<f;H++){a=b.charAt(H);a>="0"&&a<="9"||a>="a"&&a<="f"||a>="A"&&a<="F"||C()}d=d+z("0x"+b.slice(j,H))}else C()}else{if(a=='"')break;
d=d+a;H++}}if(b.charAt(H)=='"'){H++;return d}}else{j=H;if(a=="-"){o=i;a=b.charAt(++H)}if(a>="0"&&a<="9"){for(a=="0"&&(a=b.charAt(H+1),a>="0"&&a<="9")&&C();H<c&&(a=b.charAt(H),a>="0"&&a<="9");H++);if(b.charAt(H)=="."){for(f=++H;f<c&&(a=b.charAt(f),a>="0"&&a<="9");f++);f==H&&C();H=f}a=b.charAt(H);if(a=="e"||a=="E"){a=b.charAt(++H);(a=="+"||a=="-")&&H++;for(f=H;f<c&&(a=b.charAt(f),a>="0"&&a<="9");f++);f==H&&C();H=f}return+b.slice(j,H)}o&&C();if(b.slice(H,H+4)=="true"){H=H+4;return i}if(b.slice(H,H+5)==
"false"){H=H+5;return false}if(b.slice(H,H+4)=="null"){H=H+4;return k}}C()}}return"$"},E=function(b){var c,a;b=="$"&&C();if(typeof b=="string"){if(b.charAt(0)=="@")return b.slice(1);if(b=="["){for(c=[];;a||(a=i)){b=D();if(b=="]")break;if(a)if(b==","){b=D();b=="]"&&C()}else C();b==","&&C();c.push(E(b))}return c}if(b=="{"){for(c={};;a||(a=i)){b=D();if(b=="}")break;if(a)if(b==","){b=D();b=="}"&&C()}else C();(b==","||typeof b!="string"||b.charAt(0)!="@"||D()!=":")&&C();c[b.slice(1)]=E(D())}return c}C()}return b},
G=function(b,c,a){a=F(b,c,a);a===e?delete b[c]:b[c]=a},F=function(b,c,a){var d=b[c],j;if(typeof d=="object"&&d)if(l.call(d)=="[object Array]")for(j=d.length;j--;)G(d,j,a);else n(d,function(b){G(d,b,a)});return a.call(b,c,d)},q.parse=function(b,c){var a,d;H=0;I=b;a=E(D());D()!="$"&&C();H=I=k;return c&&l.call(c)=="[object Function]"?F((d={},d[""]=a,d),"",c):a})}p&&define(function(){return q});
}());
(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,d=e.filter,g=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.4";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:d&&n.filter===d?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:g&&n.every===g?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2),e=w.isFunction(t);return w.map(n,function(n){return(e?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t,r){return w.isEmpty(t)?r?null:[]:w[r?"find":"filter"](n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.findWhere=function(n,t){return w.where(n,t,!0)},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var k=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=k(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index<t.index?-1:1}),"value")};var F=function(n,t,r,e){var u={},i=k(t||w.identity);return A(n,function(t,a){var o=i.call(r,t,a,n);e(u,o,t)}),u};w.groupBy=function(n,t,r){return F(n,t,r,function(n,t,r){(w.has(n,t)?n[t]:n[t]=[]).push(r)})},w.countBy=function(n,t,r){return F(n,t,r,function(n,t){w.has(n,t)||(n[t]=0),n[t]++})},w.sortedIndex=function(n,t,r,e){r=null==r?w.identity:k(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i},w.bind=function(n,t){if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));var r=o.call(arguments,2);return function(){return n.apply(t,r.concat(o.call(arguments)))}},w.partial=function(n){var t=o.call(arguments,1);return function(){return n.apply(this,t.concat(o.call(arguments)))}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var I=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=I(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&I(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return I(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),"function"!=typeof/./&&(w.isFunction=function(n){return"function"==typeof n}),w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return n===void 0},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var M={escape:{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;"}};M.unescape=w.invert(M.escape);var S={escape:RegExp("["+w.keys(M.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(M.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(S[n],function(t){return M[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),D.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var T=/(.)^/,q={"'":"'","\\":"\\","\r":"r","\n":"n","	":"t","\u2028":"u2028","\u2029":"u2029"},B=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||T).source,(r.interpolate||T).source,(r.evaluate||T).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(B,function(n){return"\\"+q[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var D=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],D.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return D.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this);

/* dateFormatter.min.js */
var dateFormatter = dateFormatter || {}; dateFormatter.i18n = { monthsLong: "January,Febraury,March,April,May,June,July,August,September,October,November,December".split(","), monthsShort: "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","), daysLong: "Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday".split(","), daysShort: "Mon,Tue,Wed,Thu,Fri,Sat,Sun".split(","), patterns: { d: "M/d/yyyy", D: "dddd, MMMM dd, yyyy", f: "dddd, MMMM dd, yyyy H:mm tt", F: "dddd, MMMM dd, yyyy H:mm:ss tt", g: "M/d/yyyy H:mm tt", G: "M/d/yyyy H:mm:ss tt", m: "MMMM dd", o: "yyyy-MM-ddTHH:mm:ss.fff", s: "yyyy-MM-ddTHH:mm:ss", t: "H:mm tt", T: "H:mm:ss tt", U: "dddd, MMMM dd, yyyy HH:mm:ss tt", y: "MMMM, yyyy" }, tt: { AM: "AM", PM: "PM" }, clockType: 12 }; Date.prototype.format = function (c) { var a = this.toString(), b = dateFormatter.i18n; if (typeof b !== "undefined") { var a = (typeof b.patterns[c] !== "undefined" ? b.patterns[c] : c).replace(/yyyy/g, this.getFullYear()), a = a.replace(/yy/g, (this.getFullYear() + "").substring(2)), d = this.getMonth(), a = a.replace(/MMMM/g, b.monthsLong[d].escapeDateTimeTokens()), a = a.replace(/MMM/g, b.monthsShort[d].escapeDateTimeTokens()), a = a.replace(/MM/g, d + 1 < 10 ? "0" + (d + 1) : d + 1), a = a.replace(/(\\)?M/g, function (a, b) { return b ? a : d + 1 }), c = this.getDay(), a = a.replace(/dddd/g, b.daysLong[c].escapeDateTimeTokens()), a = a.replace(/ddd/g, b.daysShort[c].escapeDateTimeTokens()), f = this.getDate(), a = a.replace(/dd/g, f < 10 ? "0" + f : f), a = a.replace(/(\\)?d/g, function (a, b) { return b ? a : f }); b.clockType = /tt/g.test(a) ? 12 : 24; var e = this.getHours(); b.clockType == 12 && e > 12 && (e -= 12); var a = a.replace(/HH/gi, e < 10 ? "0" + e : e), a = a.replace(/(\\)?H/gi, function (a, b) { return b ? a : e }), g = this.getMinutes(), a = a.replace(/mm/g, g < 10 ? "0" + g : g), a = a.replace(/(\\)?m/g, function (a, b) { return b ? a : g }), h = this.getSeconds(), a = a.replace(/ss/g, h < 10 ? "0" + h : h), a = a.replace(/(\\)?s/g, function (a, b) { return b ? a : h }), a = a.replace(/fff/g, this.getMilliseconds()), a = a.replace(/tt/g, this.getHours() > 12 || this.getHours() == 0 ? b.tt.PM : b.tt.AM) } return a.replace(/\\/g, "") }; String.prototype.escapeDateTimeTokens = function () { return this.replace(/([dMyHhmsft])/g, "\\$1") };



(function (u, D, P) { var Q = function (d) { function Q(b, a) { ja[b] = { pageX: a.pageX, pageY: a.pageY, type: "mousemove", scrollX: u.pageXOffset || D.body.scrollLeft || D.documentElement.scrollLeft, scrollY: u.pageYOffset || D.body.scrollTop || D.documentElement.scrollTop} } function X(b) { return Fa.concat("").join(b ? "-" + b + " " : " ") } function Y(b, a) { for (var d = 0, f, g = b, h = a.split("."); g = g[h[d++]]; ) d < h.length && (f = g); return [f || b, h.pop()] } function I(b) { var a = function (a) { return a === w || !d.isPlainObject(a) }, c = function (a) { return !d.isFunction(a) && (!a && !a.attr || 1 > a.length || "object" === typeof a && !a.jquery && !a.then) }, f, j; if (!b || "object" !== typeof b) return g; a(b.metadata) && (b.metadata = { type: b.metadata }); if ("content" in b) { if (a(b.content) || b.content.jquery || b.content.done) b.content = { text: b.content }; if (c(b.content.text || g)) b.content.text = g; "ajax" in b.content && (j = (f = b.content.ajax) && f.once !== g, b.content.ajax = null, b.content.text = function (a, c) { var f = d.ajax(d.extend({}, b.content.ajax, { context: c })).then(function (a) { j && c.set("content.text", a); return a }, function (a, b, d) { c.destroyed || 0 === a.status || c.set("content.text", b + ": " + d) }); return !j ? f : "Loading..." }); if ("title" in b.content && (a(b.content.title) || (b.content.button = b.content.title.button, b.content.title = b.content.title.text), c(b.content.title || g))) b.content.title = g } "position" in b && a(b.position) && (b.position = { my: b.position, at: b.position }); "show" in b && a(b.show) && (b.show = b.show.jquery ? { target: b.show} : b.show === k ? { ready: k} : { event: b.show }); "hide" in b && a(b.hide) && (b.hide = b.hide.jquery ? { target: b.hide} : { event: b.hide }); "style" in b && a(b.style) && (b.style = { classes: b.style }); d.each(r, function () { this.sanitize && this.sanitize(b) }); return b } function sa(b, a, c, f) { function j() { var e = a.style.widget, b = n.hasClass(q); n.removeClass(q); q = e ? "ui-state-disabled" : "qtip-disabled"; n.toggleClass(q, b); n.toggleClass("ui-helper-reset " + X(), e).toggleClass(Aa, a.style.def && !e); p.content && p.content.toggleClass(X("content"), e); p.titlebar && p.titlebar.toggleClass(X("header"), e); p.button && p.button.toggleClass(F + "-icon", !e) } function h(b) { p.title && (p.titlebar.remove(), p.titlebar = p.title = p.button = w, b !== g && e.reposition(), a.content.title = g) } function y() { var b = a.content.button, c = "string" === typeof b ? b : "Close tooltip"; p.button && p.button.remove(); p.button = b.jquery ? b : d("<a />", { "class": "qtip-close " + (a.style.widget ? "" : F + "-icon"), title: c, "aria-label": c }).prepend(d("<span />", { "class": "ui-icon ui-icon-close", html: "&times;" })); p.button.appendTo(p.titlebar || n).attr("role", "button").click(function (a) { n.hasClass(q) || e.hide(a); return g }) } function m() { var e = K + "-title"; p.titlebar && h(); p.titlebar = d("<div />", { "class": F + "-titlebar " + (a.style.widget ? X("header") : "") }).append(p.title = d("<div />", { id: e, "class": F + "-title", "aria-atomic": k })).insertBefore(p.content).delegate(".qtip-close", "mousedown keydown mouseup keyup mouseout", function (a) { d(this).toggleClass("ui-state-active ui-state-focus", "down" === a.type.substr(-4)) }).delegate(".qtip-close", "mouseover mouseout", function (a) { d(this).toggleClass("ui-state-hover", "mouseover" === a.type) }); a.content.button && y() } function l(a, c) { var f = p.title; if (!e.rendered || !a) return g; d.isFunction(a) && (a = a.call(b, A.event, e)); if (d.isFunction(a.then)) return a.then(function (a) { return l(a, c) }, null, function (a) { return l(a, c) }); if (a === g || !a && "" !== a) return h(g); a.jquery && 0 < a.length ? f.empty().append(a.css({ display: "block" })) : f.html(a); c !== g && (e.rendered && 0 < n[0].offsetWidth) && e.reposition(A.event); V = k; return f.imagesLoaded().done(function () { V = g }).promise() } function v(a, c) { var f = p.content; if (!e.rendered || !a) return g; d.isFunction(a) && (a = a.call(b, A.event, e) || ""); if (d.isFunction(a.then)) return V = k, a.then(function (a) { V = g; return v(a, c) }, null, function (a) { return v(a, c) }); a.jquery && 0 < a.length ? f.empty().append(a.css({ display: "block" })) : f.html(a); V = k; return f.imagesLoaded().done(function () { V = g }).promise() } function z() { function x(b) { if (n.hasClass(q)) return g; clearTimeout(e.timers.show); clearTimeout(e.timers.hide); var d = function () { e.toggle(k, b) }; 0 < a.show.delay ? e.timers.show = setTimeout(d, a.show.delay) : d() } function f(b) { if (n.hasClass(q) || C) return g; var c = d(b.relatedTarget), x = c.closest(da)[0] === n[0], j = c[0] === m.show[0]; clearTimeout(e.timers.show); clearTimeout(e.timers.hide); if (this !== c[0] && "mouse" === h.target && x || a.hide.fixed && /mouse(out|leave|move)/.test(b.type) && (x || j)) try { b.preventDefault(), b.stopImmediatePropagation() } catch (l) { } else 0 < a.hide.delay ? e.timers.hide = setTimeout(function () { e.hide(b) }, a.hide.delay) : e.hide(b) } function j(b) { if (n.hasClass(q)) return g; "undefined" != typeof e.timers ? clearTimeout(e.timers.inactive) : e.timers = {}; e.timers.inactive = setTimeout(function () { e.hide(b) }, a.hide.inactive) } function l(a) { e.rendered && 0 < n[0].offsetWidth && e.reposition(a) } var h = a.position, m = { show: a.show.target, hide: a.hide.target, viewport: d(h.viewport), document: d(D), body: d(D.body), window: d(u) }, K = d.trim("" + a.show.event).split(" "), v = d.trim("" + a.hide.event).split(" "); n.bind("mouseenter" + s + " mouseleave" + s, function (a) { var b = "mouseenter" === a.type; b && e.focus(a); n.toggleClass(Ga, b) }); /mouse(out|leave)/i.test(a.hide.event) && "window" === a.hide.leave && m.document.bind("mouseout" + s + " blur" + s, function (a) { !/select|option/.test(a.target.nodeName) && !a.relatedTarget && e.hide(a) }); a.hide.fixed ? (m.hide = m.hide.add(n), n.bind("mouseover" + s, function () { n.hasClass(q) || clearTimeout(e.timers.hide) })) : /mouse(over|enter)/i.test(a.show.event) && m.hide.bind("mouseleave" + s, function () { clearTimeout(e.timers.show) }); -1 < ("" + a.hide.event).indexOf("unfocus") && h.container.closest("html").bind("mousedown" + s + " touchstart" + s, function (a) { var c = d(a.target), x = e.rendered && !n.hasClass(q) && 0 < n[0].offsetWidth, f = 0 < c.parents(da).filter(n[0]).length; c[0] !== b[0] && (c[0] !== n[0] && !f && !b.has(c[0]).length && x) && e.hide(a) }); "number" === typeof a.hide.inactive && (m.show.bind("qtip-" + c + "-inactive", j), d.each(E.inactiveEvents, function (a, e) { m.hide.add(p.tooltip).bind(e + s + "-inactive", j) })); d.each(v, function (a, e) { var b = d.inArray(e, K), c = d(m.hide); -1 < b && c.add(m.show).length === c.length || "unfocus" === e ? (m.show.bind(e + s, function (a) { 0 < n[0].offsetWidth ? f(a) : x(a) }), delete K[b]) : m.hide.bind(e + s, f) }); d.each(K, function (a, e) { m.show.bind(e + s, x) }); "number" === typeof a.hide.distance && m.show.add(n).bind("mousemove" + s, function (b) { var c = A.origin || {}, d = a.hide.distance, x = Math.abs; (x(b.pageX - c.pageX) >= d || x(b.pageY - c.pageY) >= d) && e.hide(b) }); "mouse" === h.target && (m.show.bind("mousemove" + s, function (a) { Q(e.id, a) }), h.adjust.mouse && (a.hide.event && (n.bind("mouseleave" + s, function (a) { (a.relatedTarget || a.target) !== m.show[0] && e.hide(a) }), p.target.bind("mouseenter" + s + " mouseleave" + s, function (a) { A.onTarget = "mouseenter" === a.type })), m.document.bind("mousemove" + s, function (a) { e.rendered && (A.onTarget && !n.hasClass(q) && 0 < n[0].offsetWidth) && e.reposition(a || ja[e.id]) }))); if (h.adjust.resize || m.viewport.length) (d.event.special.resize ? m.viewport : m.window).bind("resize" + s, l); h.adjust.scroll && m.window.add(h.container).bind("scroll" + s, l) } function t() { var b = [a.show.target[0], a.hide.target[0], e.rendered && p.tooltip[0], a.position.container[0], a.position.viewport[0], a.position.container.closest("html")[0], u, D]; e.rendered ? d([]).pushStack(d.grep(b, function (a) { return "object" === typeof a })).unbind(s) : a.show.target.unbind(s + "-create") } var e = this, K = F + "-" + c, n = d(), s = ".qtip-" + c, q = "qtip-disabled", L = 0, C = 0, V = 0, $ = 0, p, A; e.id = c; e.rendered = g; e.destroyed = g; e.elements = p = { target: b }; e.timers = { img: {} }; e.options = a; e.checks = {}; e.plugins = {}; e.cache = A = { event: {}, target: d(), disabled: g, attr: f, onTarget: g, lastClass: "" }; e.checks.builtin = { "^id$": function (a, e, b) { a = b === k ? E.nextid : b; e = F + "-" + a; a !== g && (0 < a.length && !d("#" + e).length) && (n[0].id = e, p.content[0].id = e + "-content", p.title[0].id = e + "-title") }, "^content.text$": function (a, e, b) { v(a[e] = b) }, "^content.title$": function (a, e, b) { if (!b) return h(); !p.title && b && m(); l(b); a[e] = b }, "^content.button$": function (a, b, c) { a = p.button; e.rendered && (c ? y() : a.remove()) }, "^content.title.(text|button)$": function (a, b, c) { e.set("content." + ("button" === b ? b : "title"), c) }, "^position.(my|at)$": function (a, e, b) { "string" === typeof b && (a[e] = new r.Corner(b, "at" === e)) }, "^position.container$": function (a, b, c) { e.rendered && n.appendTo(c) }, "^show.ready$": function () { e.rendered ? e.toggle(k) : e.render(1) }, "^style.classes$": function (a, e, b) { n.attr("class", F + " qtip " + b) }, "^style.width|height": function (a, e, b) { n.css(e, b) }, "^style.widget|content.title": j, "^events.(render|show|move|hide|focus|blur)$": function (a, e, b) { n[(d.isFunction(b) ? "" : "un") + "bind"]("tooltip" + e, b) }, "^(show|hide|position).(event|target|fixed|inactive|leave|distance|viewport|adjust)": function () { var e = a.position; n.attr("tracking", "mouse" === e.target && e.adjust.mouse); t(); z() } }; d.extend(e, { _triggerEvent: function (a, b, c) { a = d.Event("tooltip" + a); a.originalEvent = (c ? d.extend({}, c) : w) || A.event || w; n.trigger(a, [e].concat(b || [])); return !a.isDefaultPrevented() }, render: function (c) { if (e.rendered || e.destroyed) return e; var f = a.content.text, h = a.content.title, s = a.content.button, t = a.position, ta = []; d.attr(b[0], "aria-describedby", K); n = p.tooltip = d("<div/>", { id: K, "class": [F, Aa, a.style.classes, F + "-pos-" + a.position.my.abbrev()].join(" "), width: a.style.width || "", height: a.style.height || "", tracking: "mouse" === t.target && t.adjust.mouse, role: "alert", "aria-live": "polite", "aria-atomic": g, "aria-describedby": K + "-content", "aria-hidden": k }).toggleClass(q, A.disabled).data("qtip", e).appendTo(a.position.container).append(p.content = d("<div />", { "class": F + "-content", id: K + "-content", "aria-atomic": k })); e.rendered = -1; L = 1; h && (m(), d.isFunction(h) || ta.push(l(h, g))); s && y(); d.isFunction(f) || ta.push(v(f, g)); e.rendered = k; j(); d.each(a.events, function (a, e) { d.isFunction(e) && n.bind("toggle" === a ? "tooltipshow tooltiphide" : "tooltip" + a, e) }); d.each(r, function () { "render" === this.initialize && this(e) }); z(); d.when.apply(d, ta).then(function () { e._triggerEvent("render"); L = 0; !$ && (a.show.ready || c) && e.toggle(k, A.event, g); $ = g }); return e }, get: function (b) { if (e.destroyed) return e; b = Y(a, b.toLowerCase()); b = b[0][b[1]]; return b.precedance ? b.string() : b }, set: function (b, c) { if (e.destroyed) return e; var f = /^position\.(my|at|adjust|target|container)|style|content|show\.ready/i, j = g, h = e.checks, l; "string" === typeof b ? (l = b, b = {}, b[l] = c) : b = d.extend(k, {}, b); d.each(b, function (e, c) { var g = Y(a, e.toLowerCase()), n; n = g[0][g[1]]; g[0][g[1]] = "object" === typeof c && c.nodeType ? d(c) : c; b[e] = [g[0], g[1], c, n]; j = f.test(e) || j }); I(a); L = 1; d.each(b, function (a, b) { var c, d, f; for (c in h) for (d in h[c]) if (f = RegExp(d, "i").exec(a)) b.push(f), h[c][d].apply(e, b) }); L = 0; e.rendered && (0 < n[0].offsetWidth && j) && e.reposition("mouse" === a.position.target ? w : A.event); return e }, toggle: function (b, f, j) { function h() { b ? (r.ie && n[0].style.removeAttribute("filter"), n.css("overflow", ""), "string" === typeof p.autofocus && d(p.autofocus, n).focus(), p.target.trigger("qtip-" + c + "-inactive")) : n.css({ display: "", visibility: "", opacity: "", left: "", top: "" }); e._triggerEvent(b ? "visible" : "hidden") } V && !b && ($ = k); if (f) { if (/over|enter/.test(f.type) && /out|leave/.test(A.event.type) && a.show.target.add(f.target).length === a.show.target.length && n.has(f.relatedTarget).length) return e; A.event = d.extend({}, f) } if (!e.rendered || e.destroyed) return b ? e.render(1) : e; var m = b ? "show" : "hide", p = a[m], K = a.position, s = a.content, t = n.css("width"), y = 0 < n[0].offsetWidth, z = b || 1 === p.target.length, q = !f || 2 > p.target.length || A.target[0] === f.target; (typeof b).search("boolean|number") && (b = !y); y = !n.is(":animated") && y === b && q; q = !y ? !!e._triggerEvent(m, [90]) : w; q !== g && b && e.focus(f); if (!q || y) return e; d.attr(n[0], "aria-hidden", !b); b ? (A.origin = d.extend({}, ja[e.id]), d.isFunction(s.text) && v(s.text, g), d.isFunction(s.title) && l(s.title, g), !oa && ("mouse" === K.target && K.adjust.mouse) && (d(D).bind("mousemove." + F, function (a) { Q(e.id, a) }), oa = k), t || n.css("width", n.outerWidth(g)), e.reposition(f, j), t || n.css("width", ""), p.solo && ("string" === typeof p.solo ? d(p.solo) : d(da, p.solo)).not(n).not(p.target).qtip("hide", d.Event("tooltipsolo"))) : ("undefined" != typeof e.timers && clearTimeout(e.timers.show), delete A.origin, oa && !d(da + '[tracking="true"]:visible', p.solo).not(n).length && (d(D).unbind("mousemove." + F), oa = g), e.blur(f)); p.effect === g || z === g ? (n[m](), h.call(n)) : d.isFunction(p.effect) ? (n.stop(1, 1), p.effect.call(n, e), n.queue("fx", function (a) { h(); a() })) : n.fadeTo(90, b ? 1 : 0, h); b && p.target.trigger("qtip-" + c + "-inactive"); return e }, show: function (a) { return e.toggle(k, a) }, hide: function (a) { return e.toggle(g, a) }, focus: function (a) { if (!e.rendered || e.destroyed) return e; var b = d(da), c = parseInt(n[0].style.zIndex, 10), f = E.zindex + b.length; a = d.extend({}, a); !n.hasClass(fa) && e._triggerEvent("focus", [f], a) && (c !== f && (b.each(function () { this.style.zIndex > c && (this.style.zIndex -= 1) }), b.filter("." + fa).qtip("blur", a)), n.addClass(fa)[0].style.zIndex = f); return e }, blur: function (a) { if (e.destroyed) return e; n.removeClass(fa); e._triggerEvent("blur", [n.css("zIndex")], a); return e }, reposition: function (b, c) { if (!e.rendered || L || e.destroyed) return e; L = 1; var f = a.position.target, j = a.position, h = j.my, l = j.at, m = j.adjust, s = m.method.split(" "), K = n.outerWidth(g), k = n.outerHeight(g), v = 0, t = 0, y = n.css("position"), z = j.viewport, q = { left: 0, top: 0 }, C = j.container, V = 0 < n[0].offsetWidth, w = b && "scroll" === b.type, $ = d(u), B, F; if (d.isArray(f) && 2 === f.length) l = { x: M, y: J }, q = { left: f[0], top: f[1] }; else if ("mouse" === f && (b && b.pageX || A.event.pageX)) l = { x: M, y: J }, b = (l = ja[e.id]) && l.pageX && (m.mouse || !b || !b.pageX) ? { pageX: l.pageX, pageY: l.pageY} : (b && ("resize" === b.type || "scroll" === b.type) ? A.event : b && b.pageX && "mousemove" === b.type ? b : (!m.mouse || a.show.distance) && A.origin && A.origin.pageX ? A.origin : b) || b || A.event || l || {}, "static" !== y && (q = C.offset()), q = { left: b.pageX - q.left, top: b.pageY - q.top }, m.mouse && w && (q.left -= l.scrollX - $.scrollLeft(), q.top -= l.scrollY - $.scrollTop()); else { "event" === f && b && b.target && "scroll" !== b.type && "resize" !== b.type ? A.target = d(b.target) : "event" !== f && (A.target = d(f.jquery ? f : p.target)); f = A.target; f = d(f).eq(0); if (0 === f.length) return e; f[0] === D || f[0] === u ? (v = r.iOS ? u.innerWidth : f.width(), t = r.iOS ? u.innerHeight : f.height(), f[0] === u && (q = { top: (z || f).scrollTop(), left: (z || f).scrollLeft() })) : r.imagemap && f.is("area") ? B = r.imagemap(e, f, l, r.viewport ? s : g) : r.svg && f[0].ownerSVGElement ? B = r.svg(e, f, l, r.viewport ? s : g) : (v = f.outerWidth(g), t = f.outerHeight(g), q = f.offset()); B && (v = B.width, t = B.height, F = B.offset, q = B.position); q = r.offset(f, q, C); if (3.1 < r.iOS && 4.1 > r.iOS || 4.3 <= r.iOS && 4.33 > r.iOS || !r.iOS && "fixed" === y) q.left -= $.scrollLeft(), q.top -= $.scrollTop(); if (!B || B && B.adjustable !== g) q.left += l.x === R ? v : l.x === G ? v / 2 : 0, q.top += l.y === S ? t : l.y === G ? t / 2 : 0 } q.left += m.x + (h.x === R ? -K : h.x === G ? -K / 2 : 0); q.top += m.y + (h.y === S ? -k : h.y === G ? -k / 2 : 0); r.viewport ? (q.adjusted = r.viewport(e, q, j, v, t, K, k), F && q.adjusted.left && (q.left += F.left), F && q.adjusted.top && (q.top += F.top)) : q.adjusted = { left: 0, top: 0 }; if (!e._triggerEvent("move", [q, z.elem || z], b)) return e; delete q.adjusted; c === g || !V || isNaN(q.left) || isNaN(q.top) || "mouse" === f || !d.isFunction(j.effect) ? n.css(q) : d.isFunction(j.effect) && (j.effect.call(n, e, d.extend({}, q)), n.queue(function (a) { d(this).css({ opacity: "", height: "" }); r.ie && this.style.removeAttribute("filter"); a() })); L = 0; return e }, disable: function (a) { if (e.destroyed) return e; "boolean" !== typeof a && (a = !(n.hasClass(q) || A.disabled)); e.rendered ? (n.toggleClass(q, a), d.attr(n[0], "aria-disabled", a)) : A.disabled = !!a; return e }, enable: function () { return e.disable(g) }, destroy: function (f) { function j() { var f = d.attr(b[0], aa), l = b.data("qtip"); e.rendered && (d.each(e.plugins, function (a) { this.destroy && this.destroy(); delete e.plugins[a] }), n.stop(1, 0).find("*").remove().end().remove(), e.rendered = g); clearTimeout(e.timers.show); clearTimeout(e.timers.hide); t(); if (!l || e === l) b.removeData("qtip").removeAttr(ua), a.suppress && f && (b.attr("title", f), b.removeAttr(aa)), b.removeAttr("aria-describedby"); b.unbind(".qtip-" + c); delete va[e.id]; delete e.options; delete e.elements; delete e.cache; delete e.timers; delete e.checks; delete ja[e.id] } if (e.destroyed) return b; e.destroyed = k; var l = g; f !== k && (n.one("tooltiphide", function () { l = k; n.one("tooltiphidden", j) }), e.hide()); l || j(); return b } }) } function N(b) { return b.charAt(0).toUpperCase() + b.slice(1) } function ga(b, a, c) { var f = a.precedance === O, d = b[f ? 0 : 1]; b = b[f ? 1 : 0]; var g = -1 < a.string().indexOf(G), k = d * (g ? 0.5 : 1), m = Math.pow; a = Math.round; var l = Math.sqrt(m(k, 2) + m(b, 2)), k = [c / k * l, c / b * l]; k[2] = Math.sqrt(m(k[0], 2) - m(c, 2)); k[3] = Math.sqrt(m(k[1], 2) - m(c, 2)); c = (l + k[2] + k[3] + (g ? 0 : k[0])) / l; d = [a(c * d), a(c * b)]; return f ? d : d.reverse() } function ka(b) { function a(a, b, f) { b = pa + N(!b ? a[a.precedance] : b) + "Width"; return (f ? parseInt(ba(f, b), 10) : parseInt(ba(h.content, b), 10) || parseInt(ba(a.y === J && h.titlebar || h.content, b), 10) || parseInt(ba(y, b), 10)) || 0 } function c(e, c, d) { if (h.tip) { e = f.corner.clone(); c = d.adjusted; var l = b.options.position.adjust.method.split(" "), q = l[0], l = l[1] || l[0], v = g, t = g, z = 0, y = 0, p, r = {}, x; f.corner.fixed !== k && (q === W && e.precedance === T && c.left && e.y !== G ? e.precedance = e.precedance === T ? O : T : q !== W && c.left && (e.x = e.x === G ? 0 < c.left ? M : R : e.x === M ? R : M), l === W && e.precedance === O && c.top && e.x !== G ? e.precedance = e.precedance === O ? T : O : l !== W && c.top && (e.y = e.y === G ? 0 < c.top ? J : S : e.y === J ? S : J), e.string() !== m.corner.string() && (m.top !== c.top || m.left !== c.left) && f.update(e, g)); p = f.position(e, c); p[e.x] += a(e, e.x); p[e.y] += a(e, e.y); p.right !== P && (p.left = -p.right); p.bottom !== P && (p.top = -p.bottom); p.user = Math.max(0, j.offset); if (v = q === W && !!c.left) if (e.x === G) r[la + "-left"] = z = p[la + "-left"] - c.left; else { x = p.right !== P ? [c.left, -p.left] : [-c.left, p.left]; if ((z = Math.max(x[0], x[1])) > x[0]) d.left -= c.left, v = g; r[p.right !== P ? R : M] = z } if (t = l === W && !!c.top) if (e.y === G) r[la + "-top"] = y = p[la + "-top"] - c.top; else { x = p.bottom !== P ? [c.top, -p.top] : [-c.top, p.top]; if ((y = Math.max(x[0], x[1])) > x[0]) d.top -= c.top, t = g; r[p.bottom !== P ? S : J] = y } h.tip.css(r).toggle(!(z && y || e.x === G && y || e.y === G && z)); d.left -= p.left.charAt ? p.user : q !== W || t || !v && !t ? p.left : 0; d.top -= p.top.charAt ? p.user : l !== W || v || !v && !t ? p.top : 0; m.left = c.left; m.top = c.top; m.corner = e.clone() } } var f = this, j = b.options.style.tip, h = b.elements, y = h.tooltip, m = { top: 0, left: 0 }, l = [j.width, j.height], v, z, t = j.border || 0; f.corner = w; f.mimic = w; f.border = t; f.offset = j.offset; f.size = l; b.checks.tip = { "^position.my|style.tip.(corner|mimic|border)$": function () { !f.init() && f.destroy(); b.reposition() }, "^style.tip.(height|width)$": function () { f.size = l = [j.width, j.height]; f.create(); f.update(); b.reposition() }, "^content.title|style.(classes|widget)$": function () { h.tip && h.tip.length && f.update() } }; d.extend(f, { init: function () { var a; a = j.corner; var d = b.options.position, l = d.at, d = d.my.string ? d.my.string() : d.my; a === g || d === g && l === g ? a = g : (a === k ? f.corner = new r.Corner(d) : a.string || (f.corner = new r.Corner(a), f.corner.fixed = k), m.corner = new r.Corner(f.corner.string()), a = "centercenter" !== f.corner.string()); if (a = a && (qa || r.ie)) f.create(), f.update(), y.unbind(ma).bind("tooltipmove" + ma, c); return a }, create: function () { var a = l[0], b = l[1]; h.tip && h.tip.remove(); h.tip = d("<div />", { "class": "qtip-tip" }).css({ width: a, height: b }).prependTo(y); qa ? d("<canvas />").appendTo(h.tip)[0].getContext("2d").save() : (a = createVML("shape", 'coordorigin="0,0"', "position:absolute;"), h.tip.html(a + a), d("*", h.tip).bind("click" + ma + " mousedown" + ma, function (a) { a.stopPropagation() })) }, update: function (b, c) { var n = h.tip, s = n.children(), q = l[0], L = l[1], C = j.mimic, w = Math.round, u, p; b || (b = m.corner || f.corner); C === g ? C = b : (C = new r.Corner(C), C.precedance = b.precedance, "inherit" === C.x ? C.x = b.x : "inherit" === C.y ? C.y = b.y : C.x === C.y && (C[b.precedance] = b[b.precedance])); b.precedance === T ? (l[0] = j.height, l[1] = j.width) : (l[0] = j.width, l[1] = j.height); h.tip.css({ width: q = l[0], height: L = l[1] }); p = h; var A = b, x = function (a, b, e) { b = a.css(b); return !b || e && b === a.css(e) || Ha.test(b) ? g : b }, H = p.tip.css("cssText", ""), Z = pa + N(A[A.precedance]) + N(na), B = p.titlebar, A = B && (A.y === J || A.y === G && H.position().top + l[1] / 2 + j.offset < B.outerHeight(k)) ? B : p.content; v = x(H, ha) || x(A, ha) || x(p.content, ha) || x(y, ha) || H.css(ha); z = x(H, Z, na) || x(A, Z, na) || x(p.content, Z, na) || x(y, Z, na) || y.css(Z); d("*", H).add(H).css("cssText", ha + ":" + Ba + Ca + ";" + pa + ":0" + Ca + ";"); z !== Ba ? (t = a(b), 0 === j.border && 0 < t && (v = z), f.border = t = j.border !== k ? j.border : t) : f.border = t = 0; p = C; x = q; H = L; Z = Math.ceil(x / 2); A = Math.ceil(H / 2); x = { bottomright: [[0, 0], [x, H], [x, 0]], bottomleft: [[0, 0], [x, 0], [0, H]], topright: [[0, H], [x, 0], [x, H]], topleft: [[0, 0], [0, H], [x, H]], topcenter: [[0, H], [Z, 0], [x, H]], bottomcenter: [[0, 0], [x, 0], [Z, H]], rightcenter: [[0, 0], [x, A], [0, H]], leftcenter: [[x, 0], [x, H], [0, A]] }; x.lefttop = x.bottomright; x.righttop = x.bottomleft; x.leftbottom = x.topright; x.rightbottom = x.topleft; u = x[p.string()]; f.size = p = ga(l, b, t); n.css({ width: p[0], height: p[1], lineHeight: p[1] + "px" }); n = b.precedance === O ? [w(C.x === M ? t : C.x === R ? p[0] - q - t : (p[0] - q) / 2), w(C.y === J ? p[1] - L : 0)] : [w(C.x === M ? p[0] - q : 0), w(C.y === J ? t : C.y === S ? p[1] - L - t : (p[1] - L) / 2)]; qa ? (s.attr({ width: p[0], height: p[1] }), s = s[0].getContext("2d"), s.restore(), s.save(), s.clearRect(0, 0, 3E3, 3E3), s.fillStyle = v, s.strokeStyle = z, s.lineWidth = 2 * t, s.lineJoin = "miter", s.miterLimit = 100, s.translate(n[0], n[1]), s.beginPath(), s.moveTo(u[0][0], u[0][1]), s.lineTo(u[1][0], u[1][1]), s.lineTo(u[2][0], u[2][1]), s.closePath(), t && ("border-box" === y.css("background-clip") && (s.strokeStyle = v, s.stroke()), s.strokeStyle = z, s.stroke()), s.fill()) : (u = "m" + u[0][0] + "," + u[0][1] + " l" + u[1][0] + "," + u[1][1] + " " + u[2][0] + "," + u[2][1] + " xe", n[2] = t && /^(r|b)/i.test(b.string()) ? 8 === r.ie ? 2 : 1 : 0, s.css({ coordsize: q + t + " " + (L + t), antialias: "" + (-1 < C.string().indexOf(G)), left: n[0], top: n[1], width: q + t, height: L + t }).each(function (a) { var b = d(this); b[b.prop ? "prop" : "attr"]({ coordsize: q + t + " " + (L + t), path: u, fillcolor: v, filled: !!a, stroked: !a }).toggle(!(!t && !a)); !a && b.html(createVML("stroke", 'weight="' + 2 * t + 'px" color="' + z + '" miterlimit="1000" joinstyle="miter"')) })); setTimeout(function () { h.tip.css({ display: "inline-block", visibility: "visible" }) }, 1); c !== g && f.position(b) }, position: function (b) { var c = h.tip, m = {}, k = Math.max(0, j.offset), q = y.hasClass("ui-widget"), v, z, u; if (j.corner === g || !c) return g; b = b || f.corner; v = b.precedance; z = ga(l, b, t); u = [b.x, b.y]; v === T && u.reverse(); d.each(u, function (c, f) { var d, l, g; if (f === G) d = v === O ? M : J, m[d] = "50%", m[la + "-" + d] = -Math.round(z[v === O ? 0 : 1] / 2) + k; else { d = a(b, f, q ? y : w); l = a(b, f, q ? w : h.content); g = b; var j = pa + N(g.y) + N(g.x) + "Radius"; g = 9 > r.ie ? 0 : parseInt(ba(g.y === J && h.titlebar || h.content, j), 10) || parseInt(ba(h.tooltip, j), 10) || 0; m[f] = Math.max(-t, c ? l : k + (g > d ? g : -d)) } }); m[b[v]] -= z[v === T ? 0 : 1]; c.css({ top: "", bottom: "", left: "", right: "", margin: "" }).css(m); return m }, destroy: function () { y.unbind(ma); h.tip && h.tip.find("*").remove().end().remove(); delete f.corner; delete f.mimic; delete f.size } }); f.init() } function ia(b) { var a = this, c = b.options.show.modal, f = b.elements, j = f.tooltip, h = U + b.id, k; b.checks.modal = { "^show.modal.(on|blur)$": function () { a.destroy(); a.init(); k.toggle(j.is(":visible")) } }; d.extend(a, { init: function () { if (!c.on) return a; k = f.overlay = ea.elem; j.addClass(wa).css("z-index", r.modal.zindex + d(U).length).bind("tooltipshow" + h + " tooltiphide" + h, function (b, c, f) { c = b.originalEvent; if (b.target === j[0]) if (c && "tooltiphide" === b.type && /mouse(leave|enter)/.test(c.type) && d(c.relatedTarget).closest(k[0]).length) try { b.preventDefault() } catch (g) { } else (!c || c && !c.solo) && a.toggle(b, "tooltipshow" === b.type, f) }).bind("tooltipfocus" + h, function (a, b) { if (!(a.isDefaultPrevented() || a.target !== j[0])) { var c = d(U), f = r.modal.zindex + c.length, g = parseInt(j[0].style.zIndex, 10); k[0].style.zIndex = f - 1; c.each(function () { this.style.zIndex > g && (this.style.zIndex -= 1) }); c.filter("." + fa).qtip("blur", a.originalEvent); j.addClass(fa)[0].style.zIndex = f; ea.update(b); try { a.preventDefault() } catch (e) { } } }).bind("tooltiphide" + h, function (a) { a.target === j[0] && d(U).filter(":visible").not(j).last().qtip("focus", a) }); return a }, toggle: function (c, f, d) { if (c && c.isDefaultPrevented()) return a; ea.toggle(b, !!f, d); return a }, destroy: function () { j.removeClass(wa); j.add(D).unbind(h); ea.toggle(b, g); delete f.overlay } }); a.init() } function B(b) { var a = this, c = b.elements, f = b.options, j = c.tooltip, h = ".ie6-" + b.id, r = 1 > d("select, object").length, m = 0, l = g, v; b.checks.ie6 = { "^content|style$": function () { redraw() } }; d.extend(a, { init: function () { var b = d(u), f; r && (c.bgiframe = d('<iframe class="qtip-bgiframe" frameborder="0" tabindex="-1" src="javascript:\'\';" style="display:block; position:absolute; z-index:-1; filter:alpha(opacity=0); -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";"></iframe>'), c.bgiframe.appendTo(j), j.bind("tooltipmove" + h, a.adjustBGIFrame)); v = d("<div/>", { id: "qtip-rcontainer" }).appendTo(D.body); a.redraw(); c.overlay && !l && (f = function () { c.overlay[0].style.top = b.scrollTop() + "px" }, b.bind("scroll.qtip-ie6, resize.qtip-ie6", f), f(), c.overlay.addClass("qtipmodal-ie6fix"), l = k) }, adjustBGIFrame: function () { var a = { height: j.outerHeight(g), width: j.outerWidth(g) }, f = b.plugins.tip, e = c.tip, d; d = parseInt(j.css("border-left-width"), 10) || 0; d = { left: -d, top: -d }; f && e && (f = "x" === f.corner.precedance ? ["width", "left"] : ["height", "top"], d[f[1]] -= e[f[0]]()); c.bgiframe.css(d).css(a) }, redraw: function () { if (1 > b.rendered || m) return a; var c = f.style, d = f.position.container, e, g, l; m = 1; c.height && j.css(Da, c.height); c.width ? j.css(ra, c.width) : (j.css(ra, "").appendTo(v), e = j.width(), 1 > e % 2 && (e += 1), g = j.css("max-width") || "", l = j.css("min-width") || "", c = -1 < (g + l).indexOf("%") ? d.width() / 100 : 0, g = (-1 < g.indexOf("%") ? c : 1) * parseInt(g, 10) || e, l = (-1 < l.indexOf("%") ? c : 1) * parseInt(l, 10) || 0, e = g + l ? Math.min(Math.max(e, l), g) : e, j.css(ra, Math.round(e)).appendTo(d)); m = 0; return a }, destroy: function () { r && c.bgiframe.remove(); j.unbind(h) } }); a.init() } var k = !0, g = !1, w = null, T = "x", O = "y", ra = "width", Da = "height", J = "top", M = "left", S = "bottom", R = "right", G = "center", Ia = "flipinvert", W = "shift", E, r, F = "qtip", ua = "data-hasqtip", Fa = ["ui-widget", "ui-tooltip"], ja = {}, va = {}, da = "div.qtip." + F, Aa = F + "-default", fa = F + "-focus", Ga = F + "-hover", aa = "oldtitle", oa; E = d.fn.qtip = function (b, a, c) { var f = ("" + b).toLowerCase(), j = w, h = d.makeArray(arguments).slice(1), r = h[h.length - 1], m = this[0] ? d.data(this[0], "qtip") : w; if (!arguments.length && m || "api" === f) return m; if ("string" === typeof b) return this.each(function () { var b = d.data(this, "qtip"); if (!b) return k; r && r.timeStamp && (b.cache.event = r); if (("option" === f || "options" === f) && a) if (d.isPlainObject(a) || c !== P) b.set(a, c); else return j = b.get(a), g; else b[f] && b[f].apply(b[f], h) }), j !== w ? j : this; if ("object" === typeof b || !arguments.length) return m = I(d.extend(k, {}, b)), E.bind.call(this, m, r) }; E.bind = function (b, a) { return this.each(function (c) { function f(a) { function b() { l.render("object" === typeof a || j.show.ready); h.show.add(h.hide).unbind(m) } if (l.cache.disabled) return g; l.cache.event = d.extend({}, a); l.cache.target = a ? d(a.target) : [P]; 0 < j.show.delay ? (clearTimeout(l.timers.show), l.timers.show = setTimeout(b, j.show.delay), y.show !== y.hide && h.hide.bind(y.hide, function () { clearTimeout(l.timers.show) })) : b() } var j, h, y, m, l, v; v = d.isArray(b.id) ? b.id[c] : b.id; v = !v || v === g || 1 > v.length || va[v] ? E.nextid++ : va[v] = v; m = ".qtip-" + v + "-create"; a: { c = d(this); var z, t, e, u, n = d(D.body), s = c[0] === D ? n : c; t = c.metadata ? c.metadata(b.metadata) : w; e = "html5" === b.metadata.type && t ? t[b.metadata.name] : w; var q = c.data(b.metadata.name || "qtipopts"); try { q = "string" === typeof q ? d.parseJSON(q) : q } catch (B) { } e = d.extend(k, {}, E.defaults, b, "object" === typeof q ? I(q) : w, I(e || t)); t = e.position; e.id = v; if ("boolean" === typeof e.content.text) if (z = c.attr(e.content.attr), e.content.attr !== g && z) e.content.text = z; else { l = g; break a } t.container.length || (t.container = n); t.target === g && (t.target = s); e.show.target === g && (e.show.target = s); e.show.solo === k && (e.show.solo = t.container.closest("body")); e.hide.target === g && (e.hide.target = s); e.position.viewport === k && (e.position.viewport = t.container); t.container = t.container.eq(0); t.at = new r.Corner(t.at, k); t.my = new r.Corner(t.my); if (c.data("qtip")) if (e.overwrite) c.qtip("destroy"); else if (e.overwrite === g) { l = g; break a } c.attr(ua, !0); e.suppress && (u = c.attr("title")) && c.removeAttr("title").attr(aa, u).attr("title", ""); z = new sa(c, e, v, !!z); c.data("qtip", z); c.one("remove.qtip-" + v + " removeqtip.qtip-" + v, function () { var a; (a = d(this).data("qtip")) && a.destroy() }); l = z } if (l === g) return k; j = l.options; d.each(r, function () { "initialize" === this.initialize && this(l) }); h = { show: j.show.target, hide: j.hide.target }; y = { show: d.trim("" + j.show.event).replace(/ /g, m + " ") + m, hide: d.trim("" + j.hide.event).replace(/ /g, m + " ") + m }; /mouse(over|enter)/i.test(y.show) && !/mouse(out|leave)/i.test(y.hide) && (y.hide += " mouseleave" + m); h.show.bind("mousemove" + m, function (a) { Q(l.id, a); l.cache.onTarget = k }); h.show.bind(y.show, f); (j.show.ready || j.prerender) && f(a) }) }; for (var ca = E, xa = 3, Ea = D.createElement("div"); (Ea.innerHTML = "\x3c!--[if gt IE " + ++xa + "]><i></i><![endif]--\x3e") && Ea.getElementsByTagName("i")[0]; ); r = ca.plugins = { Corner: function (b, a) { b = ("" + b).replace(/([A-Z])/, " $1").replace(/middle/gi, G).toLowerCase(); this.x = (b.match(/left|right/i) || b.match(/center/) || ["inherit"])[0].toLowerCase(); this.y = (b.match(/top|bottom|center/i) || ["inherit"])[0].toLowerCase(); this._forceY = !!a; var c = b.charAt(0); this.precedance = "t" === c || "b" === c ? O : T; this.string = function () { return this.precedance === O || this._forceY && "center" !== this.y ? this.y + this.x : this.x + this.y }; this.abbrev = function () { var a = this.x.substr(0, 1), b = this.y.substr(0, 1); return a === b ? a : this.precedance === O || this._forceY && "c" !== b ? b + a : a + b }; this.invertx = function (a) { this.x = this.x === M ? R : this.x === R ? M : a || this.x }; this.inverty = function (a) { this.y = this.y === J ? S : this.y === S ? J : a || this.y }; this.clone = function () { return { x: this.x, y: this.y, precedance: this.precedance, string: this.string, abbrev: this.abbrev, clone: this.clone, invertx: this.invertx, inverty: this.inverty} } }, offset: function (b, a, c) { if (!c[0]) return a; b = d(b[0].ownerDocument); var f = !!r.ie && "CSS1Compat" !== D.compatMode; c = c[0]; var g, h, k; do if ("static" !== (h = d.css(c, "position"))) { if ("fixed" === h) { h = c.getBoundingClientRect(); var m = b; a.left += -1 * m.scrollLeft(); a.top += -1 * m.scrollTop() } else h = d(c).position(), h.left += parseFloat(d.css(c, "borderLeftWidth")) || 0, h.top += parseFloat(d.css(c, "borderTopWidth")) || 0; a.left -= h.left + (parseFloat(d.css(c, "marginLeft")) || 0); a.top -= h.top + (parseFloat(d.css(c, "marginTop")) || 0); if (!g && "hidden" !== (k = d.css(c, "overflow")) && "visible" !== k) g = c } while (c = c.offsetParent); if (g && g !== b[0] || f) a.left += 1 * g.scrollLeft(), a.top += 1 * g.scrollTop(); return a }, ie: 4 < xa ? xa : NaN, iOS: parseFloat(("" + (/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0, ""])[1]).replace("undefined", "3_2").replace("_", ".").replace("_", "")) || g, fn: { attr: function (b, a) { if (this.length) { var c = this[0], f = d.data(c, "qtip"); if ("title" === b && f && "object" === typeof f && f.options.suppress) { if (2 > arguments.length) return d.attr(c, aa); f && ("title" === f.options.content.attr && f.cache.attr) && f.set("content.text", a); return this.attr(aa, a) } } return d.fn.attr_replacedByqTip.apply(this, arguments) }, clone: function (b) { d([]); var a = d.fn.clone_replacedByqTip.apply(this, arguments); b || a.filter("[" + aa + "]").attr("title", function () { return d.attr(this, aa) }).removeAttr(aa); return a } } }; d.each(r.fn, function (b, a) { if (!a || d.fn[b + "_replacedByqTip"]) return k; var c = d.fn[b + "_replacedByqTip"] = d.fn[b]; d.fn[b] = function () { return a.apply(this, arguments) || c.apply(this, arguments) } }); d.ui || (d.cleanData_replacedByqTip = d.cleanData, d.cleanData = function (b) { for (var a = 0, c; (c = d(b[a])).length && c.attr(ua); a++) try { c.triggerHandler("removeqtip") } catch (f) { } d.cleanData_replacedByqTip(b) }); E.version = "2.0.1-65-"; E.nextid = 0; E.inactiveEvents = "click dblclick mousedown mouseup mousemove mouseleave mouseenter".split(" "); E.zindex = 15E3; E.defaults = { prerender: g, id: g, overwrite: k, suppress: k, content: { text: k, attr: "title", deferred: g, title: g, button: g }, position: { my: "top left", at: "bottom right", target: g, container: g, viewport: g, adjust: { x: 0, y: 0, mouse: k, scroll: k, resize: k, method: "flipinvert flipinvert" }, effect: function (b, a) { d(this).animate(a, { duration: 200, queue: g }) } }, show: { target: g, event: "mouseenter", effect: k, delay: 90, solo: g, ready: g, autofocus: g }, hide: { target: g, event: "mouseleave", effect: k, delay: 0, fixed: g, inactive: g, leave: "window", distance: g }, style: { classes: "", widget: g, width: g, height: g, def: k }, events: { render: w, move: w, show: w, hide: w, toggle: w, visible: w, hidden: w, focus: w, blur: w} }; var ba, ma = ".qtip-tip", la = "margin", pa = "border", na = "color", ha = "background-color", Ba = "transparent", Ca = " !important", qa = !!D.createElement("canvas").getContext, Ha = /rgba?\(0, 0, 0(, 0)?\)|transparent|#123456/i; if (d.curCSS) { var ya = {}, Ja = ["Webkit", "O", "Moz", "ms"]; ba = function (b, a) { var c = a.charAt(0).toUpperCase() + a.slice(1), c = (a + " " + Ja.join(c + " ") + c).split(" "), f, d, g; if (ya[a]) return b.css(ya[a]); for (g in c) if (f = c[g], (d = b.css(f)) !== P) return ya[a] = f, d } } else ba = function (b, a) { return b.css(a) }; qa || (createVML = function (b, a, c) { return "<qvml:" + b + ' xmlns="urn:schemas-microsoft.com:vml" class="qtip-vml" ' + (a || "") + ' style="behavior: url(#default#VML); ' + (c || "") + '" />' }); ca = r.tip = function (b) { var a = b.plugins.tip; return "object" === typeof a ? a : b.plugins.tip = new ka(b) }; ca.initialize = "render"; ca.sanitize = function (b) { var a = b.style; a && "tip" in a && (a = b.style.tip, "object" !== typeof a && (b.style.tip = { corner: a }), /string|boolean/i.test(typeof a.corner) || (a.corner = k), "number" !== typeof a.width && delete a.width, "number" !== typeof a.height && delete a.height, "number" !== typeof a.border && a.border !== k && delete a.border, "number" !== typeof a.offset && delete a.offset) }; d.extend(k, E.defaults, { style: { tip: { corner: k, mimic: g, width: 6, height: 6, border: k, offset: 0}} }); var ea, wa = "qtip-modal", U = "." + wa; ea = function () { function b(a) { if (d.expr[":"].focusable) return d.expr[":"].focusable; var b = !isNaN(d.attr(a, "tabindex")), c = a.nodeName && a.nodeName.toLowerCase(); if ("area" === c) { b = a.parentNode; c = b.name; if (!a.href || !c || "map" !== b.nodeName.toLowerCase()) return !1; a = d("img[usemap=#" + c + "]")[0]; return !!a && a.is(":visible") } return /input|select|textarea|button|object/.test(c) ? !a.disabled : "a" === c ? a.href || b : b } function a(a) { 1 > j.length && a.length ? a.not("body").blur() : j.first().focus() } function c(b) { if (m.is(":visible")) { b = d(b.target); var c = h.elements.tooltip, f = b.closest(da); !(1 > f.length ? g : parseInt(f[0].style.zIndex, 10) > parseInt(c[0].style.zIndex, 10)) && b.closest(da)[0] !== c[0] && a(b) } } var f = this, j = {}, h, r, m; d.extend(f, { init: function () { function a() { var b = d(this); m.css({ height: b.height(), width: b.width() }) } m = f.elem = d("<div />", { id: "qtip-overlay", html: "<div></div>", mousedown: function () { return g } }).hide(); d(u).bind("resize" + U, a); a(); d(D.body).bind("focusin" + U, c); d(D).bind("keydown" + U, function (a) { h && (h.options.show.modal.escape && 27 === a.keyCode) && h.hide(a) }); m.bind("click" + U, function (a) { h && h.options.show.modal.blur && h.hide(a) }); return f }, update: function (a) { h = a; j = a.options.show.modal.stealfocus !== g ? a.elements.tooltip.find("*").filter(function () { return b(this) }) : [] }, toggle: function (b, c, j) { if ("undefined" == typeof b.elements) return f; d(D.body); var t = b.elements.tooltip, e = b.options.show.modal, u = e.effect, n = c ? "show" : "hide", s = m.is(":visible"), t = d(U).filter(":visible:not(:animated)").not(t); f.update(b); c && e.stealfocus !== g && a(d(":focus")); m.toggleClass("blurs", e.blur); c && m.css({ left: 0, top: 0 }).appendTo(D.body); if (m.is(":animated") && s === c && r !== g || !c && t.length) return f; m.stop(k, g); if (d.isFunction(u)) u.call(m, c); else if (u === g) m[n](); else m.fadeTo(parseInt(j, 10) || 90, c ? 1 : 0, function () { c || m.hide() }); c || m.queue(function (a) { m.css({ left: "", top: "" }); d(U).length || m.detach(); a() }); r = c; h.destroyed && (h = w); return f } }); f.init() }; ea = new ea; ca = r.modal = function (b) { var a = b.plugins.modal; return "object" === typeof a ? a : b.plugins.modal = new ia(b) }; ca.sanitize = function (b) { b.show && ("object" !== typeof b.show.modal ? b.show.modal = { on: !!b.show.modal} : "undefined" === typeof b.show.modal.on && (b.show.modal.on = k)) }; ca.zindex = E.zindex - 200; ca.initialize = "render"; d.extend(k, E.defaults, { show: { modal: { on: g, effect: k, blur: k, stealfocus: k, escape: k}} }); r.viewport = function (b, a, c, f, d, h, k) { function m(b, c, e, f, d, g, j, h, l) { var m = a[d], k = z[b], n = t[b], r = e === W, v = -q.offset[d] + s.offset[d] + s["scroll" + d], u = k === d ? l : k === g ? -l : -l / 2, y = B && B.size ? B.size[j] || 0 : 0, w = B && B.corner && B.corner.precedance === b && !r ? y : 0, C = v - m + w; l = m + l - s[j] - v + w; h = u - (z.precedance === b || k === z[c] ? n === d ? h : n === g ? -h : -h / 2 : 0) - (n === G ? h / 2 : 0); if (r) w = B && B.corner && B.corner.precedance === c ? y : 0, h = (k === d ? 1 : -1) * u - w, a[d] += 0 < C ? C : 0 < l ? -l : 0, a[d] = Math.max(-q.offset[d] + s.offset[d] + (w && B.corner[b] === G ? B.offset : 0), m - h, Math.min(Math.max(-q.offset[d] + s.offset[d] + s[j], m + h), a[d])); else { f *= e === Ia ? 2 : 0; if (0 < C && (k !== d || 0 < l)) a[d] -= h + f, E["invert" + b](d); else if (0 < l && (k !== g || 0 < C)) a[d] -= (k === G ? -h : h) + f, E["invert" + b](g); a[d] < v && -a[d] > l && (a[d] = m, E = z.clone()) } return a[d] - m } var l = c.target, r = b.elements.tooltip, z = c.my, t = c.at, e = c.adjust, w = e.method.split(" "), n = w[0], w = w[1] || w[0], s = c.viewport, q = c.container; c = b.cache; var B = b.plugins.tip, C = { left: 0, top: 0 }, E, I; if (!s.jquery || l[0] === u || l[0] === D.body || "none" === e.method) return C; l = "fixed" === r.css("position"); s = { elem: s, width: s[0] === u ? s.width() : s.outerWidth(g), height: s[0] === u ? s.height() : s.outerHeight(g), scrollleft: l ? 0 : s.scrollLeft(), scrolltop: l ? 0 : s.scrollTop(), offset: s.offset() || { left: 0, top: 0} }; q = { elem: q, scrollLeft: q.scrollLeft(), scrollTop: q.scrollTop(), offset: q.offset() || { left: 0, top: 0} }; if ("shift" !== n || "shift" !== w) E = z.clone(); C = { left: "none" !== n ? m(T, O, n, e.x, M, R, ra, f, h) : 0, top: "none" !== w ? m(O, T, w, e.y, J, S, Da, d, k) : 0 }; if (E && c.lastClass !== (I = F + "-pos-" + E.abbrev())) r.removeClass(b.cache.lastClass).addClass(b.cache.lastClass = I); return C }; r.polys = { polygon: function (b, a) { for (var c = { width: 0, height: 0, position: { top: 1E10, right: 0, bottom: 0, left: 1E10 }, adjustable: g }, d = 0, j, h = [], k = 1, m = 1, l = j = 0, r, u, d = b.length; d--; ) j = [parseInt(b[--d], 10), parseInt(b[d + 1], 10)], j[0] > c.position.right && (c.position.right = j[0]), j[0] < c.position.left && (c.position.left = j[0]), j[1] > c.position.bottom && (c.position.bottom = j[1]), j[1] < c.position.top && (c.position.top = j[1]), h.push(j); r = c.width = Math.abs(c.position.right - c.position.left); u = c.height = Math.abs(c.position.bottom - c.position.top); if ("c" === a.abbrev()) c.position = { left: c.position.left + c.width / 2, top: c.position.top + c.height / 2 }; else { for (; 0 < r && 0 < u && 0 < k && 0 < m; ) { r = Math.floor(r / 2); u = Math.floor(u / 2); k = a.x === M ? r : a.x === R ? c.width - r : k + Math.floor(r / 2); m = a.y === J ? u : a.y === S ? c.height - u : m + Math.floor(u / 2); for (d = h.length; d-- && !(2 > h.length); ) j = h[d][0] - c.position.left, l = h[d][1] - c.position.top, (a.x === M && j >= k || a.x === R && j <= k || a.x === G && (j < k || j > c.width - k) || a.y === J && l >= m || a.y === S && l <= m || a.y === G && (l < m || l > c.height - m)) && h.splice(d, 1) } c.position = { left: h[0][0], top: h[0][1]} } return c }, rect: function (b, a, c, d) { return { width: Math.abs(c - b), height: Math.abs(d - a), position: { left: Math.min(b, c), top: Math.min(a, d)}} }, _angles: { tc: 1.5, tr: 1.75, tl: 1.25, bc: 0.5, br: 0.25, bl: 0.75, rc: 2, lc: 1, c: 0 }, ellipse: function (b, a, c, d, j) { var h = r.polys._angles[j.abbrev()]; j = c * Math.cos(h * Math.PI); h = d * Math.sin(h * Math.PI); return { width: 2 * c - Math.abs(j), height: 2 * d - Math.abs(h), position: { left: b + j, top: a + h }, adjustable: g} }, circle: function (b, a, c, d) { return r.polys.ellipse(b, a, c, c, d) } }; r.svg = function (b, a, c) { b = d(D); a = a[0]; for (var f = g; !a.getBBox; ) a = a.parentNode; if (!a.getBBox || !a.parentNode) return g; switch (a.nodeName) { case "rect": f = r.svg.toPixel(a, a.x.baseVal.value, a.y.baseVal.value); a = r.svg.toPixel(a, a.x.baseVal.value + a.width.baseVal.value, a.y.baseVal.value + a.height.baseVal.value); f = r.polys.rect(f[0], f[1], a[0], a[1], c); break; case "ellipse": case "circle": f = r.svg.toPixel(a, a.cx.baseVal.value, a.cy.baseVal.value); f = r.polys.ellipse(f[0], f[1], (a.rx || a.r).baseVal.value, (a.ry || a.r).baseVal.value, c); break; case "line": case "polygon": case "polyline": points = a.points || [{ x: a.x1.baseVal.value, y: a.y1.baseVal.value }, { x: a.x2.baseVal.value, y: a.y2.baseVal.value}]; f = []; i = -1; for (len = points.numberOfItems || points.length; ++i < len; ) next = points.getItem ? points.getItem(i) : points[i], f.push.apply(f, r.svg.toPixel(a, next.x, next.y)); f = r.polys.polygon(f, c); break; default: return g } f.position.left += b.scrollLeft(); f.position.top += b.scrollTop(); return f }; r.svg.toPixel = function (b, a, c) { var d = b.getScreenCTM(); b = b.farthestViewportElement || b; if (!b.createSVGPoint) return g; b = b.createSVGPoint(); b.x = a; b.y = c; a = b.matrixTransform(d); return [a.x, a.y] }; r.imagemap = function (b, a, c) { a.jquery || (a = d(a)); var f = a.attr("shape").toLowerCase().replace("poly", "polygon"); b = d('img[usemap="#' + a.parent("map").attr("name") + '"]'); a = a.attr("coords").split(","); var j, h; if (!b.length) return g; if ("polygon" === f) result = r.polys.polygon(a, c); else if (r.polys[f]) { h = -1; len = a.length; for (j = []; ++h < len; ) j.push(parseInt(a[h], 10)); result = r.polys[f].apply(this, j.concat(c)) } else return g; c = b.offset(); c.left += Math.ceil((b.outerWidth(g) - b.width()) / 2); c.top += Math.ceil((b.outerHeight(g) - b.height()) / 2); result.position.left += c.left; result.position.top += c.top; return result }; (r.ie6 = function (b) { var a = b.plugins.ie6; return 6 !== r.ie ? g : "object" === typeof a ? a : b.plugins.ie6 = new B(b) }).initialize = "render" }; "function" === typeof define && define.amd ? define(["jquery"], Q) : jQuery && !jQuery.fn.qtip && Q(jQuery) })(window, document); (function (u, D) { var P = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="; u.fn.imagesLoaded = function (Q) { function d() { var d = u(ka), k = u(ia); I && (ia.length ? I.reject(N, d, k) : I.resolve(N)); u.isFunction(Q) && Q.call(Y, N, d, k) } function za(d) { X(d.target, "error" === d.type) } function X(B, k) { B.src === P || -1 !== u.inArray(B, ga) || (ga.push(B), k ? ia.push(B) : ka.push(B), u.data(B, "imagesLoaded", { isBroken: k, src: B.src }), sa && I.notifyWith(u(B), [k, N, u(ka), u(ia)]), N.length === ga.length && (setTimeout(d), N.unbind(".imagesLoaded", za))) } var Y = this, I = u.isFunction(u.Deferred) ? u.Deferred() : 0, sa = u.isFunction(I.notify), N = Y.find("img").add(Y.filter("img")), ga = [], ka = [], ia = []; u.isPlainObject(Q) && u.each(Q, function (d, k) { if ("callback" === d) Q = k; else if (I) I[d](k) }); N.length ? N.bind("load.imagesLoaded error.imagesLoaded", za).each(function (d, k) { var g = k.src, w = u.data(k, "imagesLoaded"); if (w && w.src === g) X(k, w.isBroken); else if (k.complete && k.naturalWidth !== D) X(k, 0 === k.naturalWidth || 0 === k.naturalHeight); else if (k.readyState || k.complete) k.src = P, k.src = g }) : d(); return I ? I.promise(Y) : Y } })(jQuery);
(function (c, e) { c.store = function (a, b) { var d = this; if ("string" == typeof a) if (c.store.drivers[a]) this.driver = c.store.drivers[a]; else throw Error("Unknown driver " + a); else if ("object" == typeof a) { if (!c.isFunction(a.init) || !c.isFunction(a.get) || !c.isFunction(a.set) || !c.isFunction(a.del) || !c.isFunction(a.flush)) throw Error("The specified driver does not fulfill the API requirements"); this.driver = a } else c.each(c.store.drivers, function () { if (!c.isFunction(this.available) || !this.available()) return !0; d.driver = this; return !1 === d.driver.init() ? (d.driver = null, !0) : !1 }); b || (b = c.store.serializers); this.serializers = {}; c.each(b, function (a) { if (!c.isFunction(this.init)) return !0; d.serializers[a] = this; d.serializers[a].init(d.encoders, d.decoders) }) }; c.extend(c.store.prototype, { get: function (a) { a = this.driver.get(a); return this.driver.encodes ? a : this.unserialize(a) }, set: function (a, b) { this.driver.set(a, this.driver.encodes ? b : this.serialize(b)) }, del: function (a) { this.driver.del(a) }, flush: function () { this.driver.flush() }, driver: e, encoders: [], decoders: [], serialize: function (a) { var b = this; c.each(this.encoders, function () { var c = b.serializers[this + ""]; if (!c || !c.encode) return !0; try { a = c.encode(a) } catch (f) { } }); return a }, unserialize: function (a) { var b = this; if (!a) return a; c.each(this.decoders, function () { var c = b.serializers[this + ""]; if (!c || !c.decode) return !0; a = c.decode(a) }); return a } }); c.store.drivers = { localStorage: { ident: "$.store.drivers.localStorage", scope: "browser", available: function () { try { return window.localStorage ? (window.localStorage.setItem("jQuery Store Availability test", !0), window.localStorage.removeItem("jQuery Store Availability test"), !0) : !1 } catch (a) { return !1 } }, init: c.noop, get: function (a) { return window.localStorage.getItem(a) }, set: function (a, b) { window.localStorage.setItem(a, b) }, del: function (a) { window.localStorage.removeItem(a) }, flush: function () { window.localStorage.clear() } }, userData: { ident: "$.store.drivers.userData", element: null, nodeName: "userdatadriver", scope: "browser", initialized: !1, available: function () { try { return !(!document.documentElement || !document.documentElement.addBehavior) } catch (a) { return !1 } }, init: function () { if (!this.initialized) try { this.element = document.createElement(this.nodeName), document.documentElement.insertBefore(this.element, document.getElementsByTagName("title")[0]), this.element.addBehavior("#default#userData"), this.initialized = !0 } catch (a) { return !1 } }, get: function (a) { this.element.load(this.nodeName); return this.element.getAttribute(a) }, set: function (a, b) { this.element.setAttribute(a, b); this.element.save(this.nodeName) }, del: function (a) { this.element.removeAttribute(a); this.element.save(this.nodeName) }, flush: function () { for (var a = this.element.xmlDocument.firstChild.attributes, b = a.length - 1; 0 <= b; b--) this.element.removeAttribute(a[b].nodeName); this.element.save(this.nodeName) } }, windowName: { ident: "$.store.drivers.windowName", scope: "window", cache: {}, encodes: !0, available: function () { return !0 }, init: function () { this.load() }, save: function () { window.name = c.store.serializers.json.encode(this.cache) }, load: function () { try { this.cache = c.store.serializers.json.decode(window.name + ""), "object" != typeof this.cache && (this.cache = {}) } catch (a) { this.cache = {}, window.name = "{}" } }, get: function (a) { return this.cache[a] }, set: function (a, b) { this.cache[a] = b; this.save() }, del: function (a) { try { delete this.cache[a] } catch (b) { this.cache[a] = e } this.save() }, flush: function () { window.name = "{}" } } }; c.store.serializers = { json: { ident: "$.store.serializers.json", init: function (a, b) { a.push("json"); b.push("json") }, encode: JSON.stringify, decode: JSON.parse }, xml: { ident: "$.store.serializers.xml", init: function (a, b) { a.unshift("xml"); b.push("xml") }, isXML: function (a) { return (a = (a ? a.ownerDocument || a : 0).documentElement) ? "html" !== a.nodeName.toLowerCase() : !1 }, encode: function (a) { if (!a || a._serialized || !this.isXML(a)) return a; var b = { _serialized: this.ident, value: a }; try { return b.value = (new XMLSerializer).serializeToString(a), b } catch (c) { try { return b.value = a.xml, b } catch (f) { } } return a }, decode: function (a) { if (!a || !a._serialized || a._serialized != this.ident) return a; var b = "DOMParser" in window && (new DOMParser).parseFromString; !b && window.ActiveXObject && (b = function (a) { var b = new ActiveXObject("Microsoft.XMLDOM"); b.async = "false"; b.loadXML(a); return b }); if (!b) return e; a.value = b.call("DOMParser" in window && new DOMParser || window, a.value, "text/xml"); return this.isXML(a.value) ? a.value : e } }} })(jQuery);
(function (l, b, n) { if (Object.defineProperties) { var u = { pageX: function (a) { if (a) { var b = this.target.ownerDocument || document; doc = b.documentElement; body = b.body; return a.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0) } }, pageY: function (a) { if (a) { var b = this.target.ownerDocument || document; doc = b.documentElement; body = b.body; return a.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0) } }, relatedTarget: function (a) { if (a) return a.fromElement === this.target ? a.toElement : a.fromElement }, metaKey: function (a) { if (a) return a.ctrlKey }, which: function (a) { if (a) return null != a.charCode ? a.charCode : a.keyCode } }; b.each(b.event.keyHooks.props.concat(b.event.mouseHooks.props).concat(b.event.props), function (a, c) { "target" !== c && Object.defineProperty(b.Event.prototype, c, { get: function () { var a = this.originalEvent && this.originalEvent[c]; this["_" + c] !== n ? a = this["_" + c] : (a = u[c] && a === n ? u[c].call(this, this.originalEvent) : a, a !== n && Object.defineProperty(this, c, { value: a })); return a }, set: function (a) { this["_" + c] = a } }) }); b.event.fix = function (a) { if (a[b.expando]) return a; var c = a; a = b.Event(c); a.target = c.target; a.target || (a.target = c.srcElement || document); 3 === a.target.nodeType && (a.target = a.target.parentNode); return a } } var g = b.event, v = function (a, b, e, d) { var g, r, f, k, p, h, j, l; for (g = 0; g < b.length; g++) { r = b[g]; k = 0 > r.indexOf("."); k || (f = r.split("."), r = f.shift(), j = RegExp("(^|\\.)" + f.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)")); f = (a[r] || []).slice(0); for (p = 0; p < f.length; p++) h = f[p], (l = k || j.test(h.namespace)) && (d ? h.selector === d && e(r, h.origHandler || h.handler) : null === d ? e(r, h.origHandler || h.handler, h.selector) : h.selector || e(r, h.origHandler || h.handler)) } }; g.find = function (a, c, e) { a = (b._data(a) || {}).events; var d = []; if (!a) return d; v(a, c, function (a, b) { d.push(b) }, e); return d }; g.findBySelector = function (a, c) { var e = b._data(a).events, d = {}; if (!e) return d; v(e, c, function (a, b, c) { c = c || ""; c = d[c] || (d[c] = {}); (c[a] || (c[a] = [])).push(b) }, null); return d }; g.supportTouch = "ontouchend" in document; b.fn.respondsTo = function (a) { return this.length ? 0 < g.find(this[0], b.isArray(a) ? a : [a]).length : !1 }; b.fn.triggerHandled = function (a, c) { a = "string" == typeof a ? b.Event(a) : a; this.trigger(a, c); return a.handled }; g.setupHelper = function (a, c, e) { e || (e = c, c = null); var d = function (d) { var f = d.selector || "", k = d.namespace ? "." + d.namespace : ""; f ? (d = g.find(this, a, f), d.length || b(this).delegate(f, c + k, e)) : g.find(this, a, f).length || g.add(this, c + k, e, { selector: f, delegate: this }) }, l = function (d) { var f = d.selector || ""; f ? (d = g.find(this, a, f), d.length || b(this).undelegate(f, c, e)) : g.find(this, a, f).length || g.remove(this, c, e, { selector: f, delegate: this }) }; b.each(a, function () { g.special[this] = { add: d, remove: l, setup: function () { }, teardown: function () { } } }) }; b.Hover = function () { this._delay = b.Hover.delay; this._distance = b.Hover.distance; this._leave = b.Hover.leave }; b.extend(b.Hover, { delay: 100, distance: 10, leave: 0 }); b.extend(b.Hover.prototype, { delay: function (a) { this._delay = a; return this }, distance: function (a) { this._distance = a; return this }, leave: function (a) { this._leave = a; return this } }); var g = b.event, x = function (a) { var c = a.delegateTarget || a.currentTarget, e = a.handleObj.selector, d = b.data(c, "_hover" + e); if (d) { if (!d.forcing) { d.forcing = !0; clearTimeout(d.leaveTimer); var l = d.leaving ? Math.max(0, d.hover.leave - (new Date - d.leaving)) : d.hover.leave, r = this; setTimeout(function () { d.callHoverLeave(); x.call(r, a) }, l) } } else { var f = a.pageX, k = a.pageY, p = 0, h, j = this, q = !1, y = a, m = new b.Hover, n, s = function () { b.each(g.find(c, ["hoverleave"], e), function () { this.call(j, a, m) }); v() }, t = function (a) { clearTimeout(n); p += Math.pow(a.pageX - f, 2) + Math.pow(a.pageY - k, 2); f = a.pageX; k = a.pageY; y = a }, u = function () { clearTimeout(h); q ? 0 === m._leave ? s() : (clearTimeout(n), d.leaving = new Date, n = d.leaveTimer = setTimeout(function () { s() }, m._leave)) : v() }, v = function () { b(j).unbind("mouseleave", u); b(j).unbind("mousemove", t); b.removeData(c, "_hover" + e) }, w = function () { b.each(g.find(c, ["hoverenter"], e), function () { this.call(j, y, m) }); q = !0 }, d = { callHoverLeave: s, hover: m }; b.data(c, "_hover" + e, d); b(j).bind("mousemove", t).bind("mouseleave", u); b.each(g.find(c, ["hoverinit"], e), function () { this.call(j, a, m) }); 0 === m._delay ? w() : h = setTimeout(function () { p < m._distance && 0 == b(j).queue().length ? w() : (p = 0, h = setTimeout(arguments.callee, m._delay)) }, m._delay) } }; g.setupHelper(["hoverinit", "hoverenter", "hoverleave", "hovermove"], "mouseenter", x); b.event.reverse = function (a, c) { var e = b(), d = 0, g = b.event.dispatch || b.event.handle; b.event.special[a] = { setup: function () { this !== l && (e.push(this), b.unique(e)); return this !== l }, teardown: function () { e = e.not(this); return this !== l }, add: function (a) { a.origHandler = a.handler; a.handler = function (f, k) { var p = this === l; if (!(c && c.handler && !0 === c.handler.apply(this, arguments))) if (0 === d) { d++; var h = !1 === k ? f.target : this; g.call(h, f, k); if (!f.isPropagationStopped()) { for (var j = e.index(this), q = e.length, n, m; ++j < q && (n = e[j]) && (p || b.contains(h, n)); ) if (g.call(n, f, k), f.isPropagationStopped()) for (; ++j < q && (m = e[j]); ) if (!b.contains(n, m)) { j--; break } f.stopImmediatePropagation() } d-- } else a.origHandler.call(this, f, k) } } }; b([document, l]).bind(a, function () { }); return b.event.special[a] }; var q = b(l), s = 0, t = 0, w; b(function () { s = q.width(); t = q.height() }); b.event.reverse("resize", { handler: function (a) { if (this === l && a.originalEvent) { a = q.width(); var b = q.height(); if (a != s || b != t) s = a, t = b, clearTimeout(w), w = setTimeout(function () { q.trigger("resize") }, 1); return !0 } } }) })(this, jQuery);
(function (b) { function c(b, a) { var c = (isNaN(b) ? new Date((b || "").replace(/-/g, "/").replace(/[TZ]/g, " ")) : new Date(parseFloat(b))).addHours(a.offset), d = ((new Date).getTime() - c.getTime()) / 1E3, e = Math.floor(d / 86400); return isNaN(e) ? null : 0 > d || a.isguest ? "" != a.dateFormat && c.format(a.dateFormat) || null : 0 == e && (60 > d && a.i18n[0] || 120 > d && a.i18n[1] || 3600 > d && Math.floor(d / 60) + a.i18n[2] || 7200 > d && a.i18n[3] || 86400 > d && Math.floor(d / 3600) + a.i18n[4]) || 1 == e && a.i18n[5] || 7 > e && e + a.i18n[6] || 10 > e && a.i18n[7] || 31 > e && Math.ceil(e / 7) + a.i18n[8] || "" != a.dateFormat && c.format(a.dateFormat) } b.fn.prettyDate = function (f) { var a = b.extend(!0, {}, b.fn.prettyDate.defaults, f); if (!1 !== a.refresh && !isNaN(a.refresh)) { var g = this; setTimeout(function () { b(g.selector).prettyDate(a) }, a.refresh) } return this.each(function () { var d = b(this); a.offset = d.data("offset") || a.offset || 0; a.dateFormat = d.data("format") || a.dateFormat || ""; if (d.data("date")) { var e = c(d.data("date"), a); e && d.text(a.prefix + b.trim(e) + a.suffix) } d.data("datetitle") && (e = c(d.data("datetitle"), a)) && d.attr("title", a.prefix + b.trim(e) + a.suffix) }) }; b.fn.prettyDate.defaults = { prefix: "", suffix: "", refresh: 6E4, dateFormat: "", offset: 0, i18n: "just now;1 minute ago; minutes ago;1 hour ago; hours ago;Yesterday; days ago;1 week ago; weeks ago".split(";")} })(jQuery); Date.prototype.clone = function () { return new Date(this.valueOf()) }; Date.prototype.addHours = function (b) { var c = this.clone(); c.setTime(c.getTime() + 36E5 * b); return c }; Date.prototype.addDays = function (b) { var c = this.clone(); c.setTime(c.getTime() + 864E5 * b); return c }; Date.prototype.addMins = function (b) { var c = this.clone(); c.setTime(c.getTime() + 6E4 * b); return c };
/**
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne brian(at)cherne(dot)net
*/
(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 ev = jQuery.extend({}, e); var ob = this; if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t) } if (e.type == "mouseenter") { 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.bind('mouseenter', handleHover).bind('mouseleave', handleHover) } })(jQuery);
/**
 * Copyright (c) 2007-2013 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * @author Ariel Flesler
 * @version 1.4.5b
 */
;(function($){var h=$.scrollTo=function(a,b,c){$(window).scrollTo(a,b,c)};h.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1,limit:true};h.window=function(a){return $(window)._scrollable()};$.fn._scrollable=function(){return this.map(function(){var a=this,isWin=!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)return a;var b=(a.contentWindow||a).document||a.ownerDocument||a;return/webkit/i.test(navigator.userAgent)||b.compatMode=='BackCompat'?b.body:b.documentElement})};$.fn.scrollTo=function(e,f,g){if(typeof f=='object'){g=f;f=0}if(typeof g=='function')g={onAfter:g};if(e=='max')e=9e9;g=$.extend({},h.defaults,g);f=f||g.duration;g.queue=g.queue&&g.axis.length>1;if(g.queue)f/=2;g.offset=both(g.offset);g.over=both(g.over);return this._scrollable().each(function(){if(e==null)return;var d=this,$elem=$(d),targ=e,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break}targ=$(targ,this);if(!targ.length)return;case'object':if(targ.is||targ.style)toff=(targ=$(targ)).offset()}$.each(g.axis.split(''),function(i,a){var b=a=='x'?'Left':'Top',pos=b.toLowerCase(),key='scroll'+b,old=d[key],max=h.max(d,a);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(g.margin){attr[key]-=parseInt(targ.css('margin'+b))||0;attr[key]-=parseInt(targ.css('border'+b+'Width'))||0}attr[key]+=g.offset[pos]||0;if(g.over[pos])attr[key]+=targ[a=='x'?'width':'height']()*g.over[pos]}else{var c=targ[pos];attr[key]=c.slice&&c.slice(-1)=='%'?parseFloat(c)/100*max:c}if(g.limit&&/^\d+$/.test(attr[key]))attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&g.queue){if(old!=attr[key])animate(g.onAfterFirst);delete attr[key]}});animate(g.onAfter);function animate(a){$elem.animate(attr,f,g.easing,a&&function(){a.call(this,e,g)})}}).end()};h.max=function(a,b){var c=b=='x'?'Width':'Height',scroll='scroll'+c;if(!$(a).is('html,body'))return a[scroll]-$(a)[c.toLowerCase()]();var d='client'+c,html=a.ownerDocument.documentElement,body=a.ownerDocument.body;return Math.max(html[scroll],body[scroll])-Math.min(html[d],body[d])};function both(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);

/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
* Version: 3.0.6
*/
(function (d) { function e(a) { var b = a || window.event, c = [].slice.call(arguments, 1), f = 0, e = 0, g = 0, a = d.event.fix(b); a.type = "mousewheel"; b.wheelDelta && (f = b.wheelDelta / 120); b.detail && (f = -b.detail / 3); g = f; void 0 !== b.axis && b.axis === b.HORIZONTAL_AXIS && (g = 0, e = -1 * f); void 0 !== b.wheelDeltaY && (g = b.wheelDeltaY / 120); void 0 !== b.wheelDeltaX && (e = -1 * b.wheelDeltaX / 120); c.unshift(a, f, e, g); return (d.event.dispatch || d.event.handle).apply(this, c) } var c = ["DOMMouseScroll", "mousewheel"]; if (d.event.fixHooks) for (var h = c.length; h; ) d.event.fixHooks[c[--h]] = d.event.mouseHooks; d.event.special.mousewheel = { setup: function () { if (this.addEventListener) for (var a = c.length; a; ) this.addEventListener(c[--a], e, !1); else this.onmousewheel = e }, teardown: function () { if (this.removeEventListener) for (var a = c.length; a; ) this.removeEventListener(c[--a], e, !1); else this.onmousewheel = null } }; d.fn.extend({ mousewheel: function (a) { return a ? this.bind("mousewheel", a) : this.trigger("mousewheel") }, unmousewheel: function (a) { return this.unbind("mousewheel", a) } }) })(jQuery);
(function (a) { a.fn.lazyload = function (d) { var b = { threshold: 0, failurelimit: 0, event: "scroll", effect: "fadeIn", container: window }; d && a.extend(b, d); var e = this; "scroll" == b.event && a(b.container).bind("scroll", function () { var c = 0; e.each(function () { if (!a.abovethetop(this, b) && !a.leftofbegin(this, b)) if (!a.belowthefold(this, b) && !a.rightoffold(this, b)) a(this).trigger("appear"); else if (c++ > b.failurelimit) return false }); var d = a.grep(e, function (a) { return !a.loaded }); e = a(d) }); this.each(function () { var c = this; void 0 == a(c).attr("original") && a(c).attr("original", a(c).attr("src")); "scroll" != b.event || void 0 == a(c).attr("src") || b.placeholder == a(c).attr("src") || a.abovethetop(c, b) || a.leftofbegin(c, b) || a.belowthefold(c, b) || a.rightoffold(c, b) ? (b.placeholder ? a(c).attr("src", b.placeholder) : a(c).removeAttr("src"), c.loaded = false) : c.loaded = true; a(c).one("appear", function () { this.loaded || a("<img />").bind("load", function () { a(c).hide().attr("src", a(c).attr("original"))[b.effect](b.effectspeed); c.loaded = true }).attr("src", a(c).attr("original")) }); "scroll" != b.event && a(c).bind(b.event, function () { c.loaded || a(c).trigger("appear") }) }); a(b.container).trigger(b.event); return this }; a.belowthefold = function (d, b) { return (b.container === void 0 || b.container === window ? a(window).height() + a(window).scrollTop() : a(b.container).offset().top + a(b.container).height()) <= a(d).offset().top - b.threshold }; a.rightoffold = function (d, b) { return (b.container === void 0 || b.container === window ? a(window).width() + a(window).scrollLeft() : a(b.container).offset().left + a(b.container).width()) <= a(d).offset().left - b.threshold }; a.abovethetop = function (d, b) { return (b.container === void 0 || b.container === window ? a(window).scrollTop() : a(b.container).offset().top) >= a(d).offset().top + b.threshold + a(d).height() }; a.leftofbegin = function (d, b) { return (b.container === void 0 || b.container === window ? a(window).scrollLeft() : a(b.container).offset().left) >= a(d).offset().left + b.threshold + a(d).width() }; a.extend(a.expr[":"], { "below-the-fold": "$.belowthefold(a, {threshold : 0, container: window})", "above-the-fold": "!$.belowthefold(a, {threshold : 0, container: window})", "right-of-fold": "$.rightoffold(a, {threshold : 0, container: window})", "left-of-fold": "!$.rightoffold(a, {threshold : 0, container: window})" }) })(jQuery);
(function (F) { var O, N, E = Math.abs, p = Math.sin, g = Math.cos, x = Math.max, S = Math.min, z = {}, A = {}, B = { 0: "0,", 1: "17,", 2: "34,", 3: "51,", 4: "68,", 5: "85,", 6: "102,", 7: "119,", 8: "136,", 9: "153,", a: "170,", A: "170,", b: "187,", B: "187,", c: "204,", C: "204,", d: "221,", D: "221,", e: "238,", E: "238,", f: "255,", F: "255," }, d, G, c, h = document, w; for (O = 0; O < 256; ++O) { N = O.toString(16); if (O < 16) { N = "0" + N } A[N] = A[N.toUpperCase()] = O.toString() + "," } function K(i) { return typeof (i) != "undefined" } function l(aa) { var j, Z, V, U, Y = [], W = Math.PI * (3 - Math.sqrt(5)), X = 2 / aa; for (j = 0; j < aa; ++j) { Z = j * X - 1 + (X / 2); V = Math.sqrt(1 - Z * Z); U = j * W; Y.push([g(U) * V, Z, p(U) * V]) } return Y } function R(W, U, ab, aa, Z, Y) { var ac, ad = [], X = Math.PI * (3 - Math.sqrt(5)), V = 2 / W; for (ab = 0; ab < W; ++ab) { aa = ab * V - 1 + (V / 2); ac = ab * X; Z = g(ac); Y = p(ac); ad.push(U ? [aa, Z, Y] : [Z, aa, Y]) } return ad } function u(i) { return R(i) } function D(i) { return R(i, 1) } function n(X, i) { var W = X, V, U, j = (i * 1).toPrecision(3) + ")"; if (X[0] === "#") { if (!z[X]) { if (X.length === 4) { z[X] = "rgba(" + B[X[1]] + B[X[2]] + B[X[3]] } else { z[X] = "rgba(" + A[X.substr(1, 2)] + A[X.substr(3, 2)] + A[X.substr(5, 2)] } } W = z[X] + j } else { if (X.substr(0, 4) === "rgb(" || X.substr(0, 4) === "hsl(") { W = (X.replace("(", "a(").replace(")", "," + j)) } else { if (X.substr(0, 5) === "rgba(" || X.substr(0, 5) === "hsla(") { V = X.lastIndexOf(",") + 1, U = X.indexOf(")"); i *= parseFloat(X.substring(V, U)); W = X.substr(0, V) + i.toPrecision(3) + ")" } } } return W } function f(i, j) { if (window.G_vmlCanvasManager) { return null } var U = h.createElement("canvas"); U.width = i; U.height = j; return U } function t() { var j = f(3, 3), V, U; if (!j) { return false } V = j.getContext("2d"); V.strokeStyle = "#000"; V.shadowColor = "#fff"; V.shadowBlur = 3; V.globalAlpha = 0; V.strokeRect(2, 2, 2, 2); V.globalAlpha = 1; U = V.getImageData(2, 2, 1, 1); j = null; return (U.data[0] > 0) } function T(ab, j) { var U = 1024, X = ab.weightGradient, W, Z, V, aa, Y; if (ab.gCanvas) { Z = ab.gCanvas.getContext("2d") } else { ab.gCanvas = W = f(U, 1); if (!W) { return null } Z = W.getContext("2d"); aa = Z.createLinearGradient(0, 0, U, 0); for (V in X) { aa.addColorStop(1 - V, X[V]) } Z.fillStyle = aa; Z.fillRect(0, 0, U, 1) } Y = Z.getImageData(~ ~((U - 1) * j), 0, 1, 1).data; return "rgba(" + Y[0] + "," + Y[1] + "," + Y[2] + "," + (Y[3] / 255) + ")" } function s(X, W, U, aa, Y, Z, j) { var V = (Z || 0) + (j && j[0] < 0 ? E(j[0]) : 0), i = (Z || 0) + (j && j[1] < 0 ? E(j[1]) : 0); X.font = W; X.textBaseline = "top"; X.fillStyle = U; Y && (X.shadowColor = Y); Z && (X.shadowBlur = Z); j && (X.shadowOffsetX = j[0], X.shadowOffsetY = j[1]); X.fillText(aa, V, i) } function k(ag, Y, ac, ae, X, U, aa, ab, j, af, ad) { var V = ae + E(j[0]) + ab + ab, i = X + E(j[1]) + ab + ab, W, Z; W = f(V + af, i + ad); if (!W) { return null } Z = W.getContext("2d"); s(Z, Y, U, ag, aa, ab, j); return W } function M(Y, ab, ac, V) { var W = Y.width + E(V[0]) + ac + ac, j = Y.height + E(V[1]) + ac + ac, Z, aa, X = (ac || 0) + (V && V[0] < 0 ? E(V[0]) : 0), U = (ac || 0) + (V && V[1] < 0 ? E(V[1]) : 0); Z = f(W, j); if (!Z) { return null } aa = Z.getContext("2d"); ab && (aa.shadowColor = ab); ac && (aa.shadowBlur = ac); V && (aa.shadowOffsetX = V[0], aa.shadowOffsetY = V[1]); aa.drawImage(Y, X, U); return Z } function H(ag, Y, ae) { var af = parseInt(ag.length * ae), X = parseInt(ae * 2), V = f(af, X), ab, j, W, aa, ad, ac, U, Z; if (!V) { return null } ab = V.getContext("2d"); ab.fillStyle = "#000"; ab.fillRect(0, 0, af, X); s(ab, ae + "px " + Y, "#fff", ag); j = ab.getImageData(0, 0, af, X); W = j.width; aa = j.height; Z = { min: { x: W, y: aa }, max: { x: -1, y: -1} }; for (ac = 0; ac < aa; ++ac) { for (ad = 0; ad < W; ++ad) { U = (ac * W + ad) * 4; if (j.data[U + 1] > 0) { if (ad < Z.min.x) { Z.min.x = ad } if (ad > Z.max.x) { Z.max.x = ad } if (ac < Z.min.y) { Z.min.y = ac } if (ac > Z.max.y) { Z.max.y = ac } } } } if (W != af) { Z.min.x *= (af / W); Z.max.x *= (af / W) } if (aa != X) { Z.min.y *= (af / aa); Z.max.y *= (af / aa) } V = null; return Z } function r(i) { return "'" + i.replace(/(\'|\")/g, "").replace(/\s*,\s*/g, "', '") + "'" } function y(i, j, U) { U = U || h; if (U.addEventListener) { U.addEventListener(i, j, false) } else { U.attachEvent("on" + i, j) } } function L(V, U, j) { if (V.complete) { U.w = V.width; U.h = V.height; j.push(U) } else { jQuery(V).bind("load", function () { U.w = this.width; U.h = this.height; j.push(U) }) } } function J(V, U) { var j = h.defaultView, i = U.replace(/\-([a-z])/g, function (W) { return W[1].toUpperCase() }); return (j && j.getComputedStyle && j.getComputedStyle(V, null).getPropertyValue(U)) || (V.currentStyle && V.currentStyle[i]) } function v(U, j) { var i = 1, V; if (U.weightFrom) { i = 1 * (j.getAttribute(U.weightFrom) || U.textHeight) } else { if (V = J(j, "font-size")) { i = (V.indexOf("px") > -1 && V.replace("px", "") * 1) || (V.indexOf("pt") > -1 && V.replace("pt", "") * 1.25) || V * 3.3 } else { U.weight = false } } return i } function I(W) { var V, U, j = h.documentElement, X; for (V in q.tc) { U = q.tc[V]; if (U.tttimer) { clearTimeout(U.tttimer); U.tttimer = null } X = F(U.canvas).offset(); if (W.pageX) { U.mx = W.pageX - X.left; U.my = W.pageY - X.top } else { U.mx = W.clientX + (j.scrollLeft || h.body.scrollLeft) - X.left; U.my = W.clientY + (j.scrollTop || h.body.scrollTop) - X.top } } } function o(V) { var j = q, i = h.addEventListener ? 0 : 1, U = V.target && K(V.target.id) ? V.target.id : V.srcElement.parentNode.id; if (U && V.button == i && j.tc[U]) { I(V); j.tc[U].Clicked(V) } } function Q(U) { var i = q, j = U.target && K(U.target.id) ? U.target.id : U.srcElement.parentNode.id; if (j && i.tc[j]) { U.cancelBubble = true; U.returnValue = false; U.preventDefault && U.preventDefault(); i.tc[j].Wheel((U.wheelDelta || U.detail) > 0) } } function m() { var U = q.tc, j; for (j in U) { U[j].Draw() } } function b(U, i) { var j = p(i), V = g(i); return { x: U.x, y: (U.y * V) + (U.z * j), z: (U.y * -j) + (U.z * V)} } function a(U, i) { var j = p(i), V = g(i); return { x: (U.x * V) + (U.z * -j), y: U.y, z: (U.x * j) + (U.z * V)} } function P(V, ab, aa, Y, W, j) { var i, X, Z, U = V.z1 / (V.z1 + V.z2 + ab.z); i = ab.y * U; X = ab.x * U; Z = V.z2 + ab.z; return { x: X, y: i, z: Z} } function e(i) { this.ts = new Date().valueOf(); this.tc = i; this.x = this.y = this.w = this.h = this.sc = 1; this.z = 0; this.Draw = i.pulsateTo < 1 && i.outlineMethod != "colour" ? this.DrawPulsate : this.DrawSimple; this.SetMethod(i.outlineMethod) } d = e.prototype; d.SetMethod = function (U) { var j = { block: ["PreDraw", "DrawBlock"], colour: ["PreDraw", "DrawColour"], outline: ["PostDraw", "DrawOutline"], classic: ["LastDraw", "DrawOutline"] }, i = j[U] || j.outline; this[i[0]] = this.Draw; this.drawFunc = this[i[1]] }; d.Update = function (aa, Z, ab, X, Y, j, W, i) { var U = this.tc.outlineOffset, V = 2 * U; this.x = Y * aa + W - U; this.y = Y * Z + i - U; this.w = Y * ab + V; this.h = Y * X + V; this.sc = Y; this.z = j.z }; d.DrawOutline = function (X, i, W, j, U, V) { X.strokeStyle = V; X.strokeRect(i, W, j, U) }; d.DrawColour = function (V, Y, W, Z, U, i, aa, j, X) { return this[aa.image ? "DrawColourImage" : "DrawColourText"](V, Y, W, Z, U, i, aa, j, X) }; d.DrawColourText = function (W, Z, X, aa, U, i, ab, j, Y) { var V = ab.colour; ab.colour = i; ab.Draw(W, j, Y); ab.colour = V; return 1 }; d.DrawColourImage = function (Z, ac, aa, ad, Y, i, ag, j, ab) { var ae = Z.canvas, W = ~ ~x(ac, 0), V = ~ ~x(aa, 0), X = S(ae.width - W, ad) + 0.5 | 0, af = S(ae.height - V, Y) + 0.5 | 0, U; if (w) { w.width = X, w.height = af } else { w = f(X, af) } if (!w) { return this.SetMethod("outline") } U = w.getContext("2d"); U.drawImage(ae, W, V, X, af, 0, 0, X, af); Z.clearRect(W, V, X, af); ag.Draw(Z, j, ab); Z.setTransform(1, 0, 0, 1, 0, 0); Z.save(); Z.beginPath(); Z.rect(W, V, X, af); Z.clip(); Z.globalCompositeOperation = "source-in"; Z.fillStyle = i; Z.fillRect(W, V, X, af); Z.restore(); Z.globalCompositeOperation = "destination-over"; Z.drawImage(w, 0, 0, X, af, W, V, X, af); Z.globalCompositeOperation = "source-over"; return 1 }; d.DrawBlock = function (X, i, W, j, U, V) { X.fillStyle = V; X.fillRect(i, W, j, U) }; d.DrawSimple = function (W, i, j, V) { var U = this.tc; W.setTransform(1, 0, 0, 1, 0, 0); W.strokeStyle = U.outlineColour; W.lineWidth = U.outlineThickness; W.shadowBlur = W.shadowOffsetX = W.shadowOffsetY = 0; W.globalAlpha = 1; return this.drawFunc(W, this.x, this.y, this.w, this.h, U.outlineColour, i, j, V) }; d.DrawPulsate = function (X, i, j, V) { var W = new Date().valueOf() - this.ts, U = this.tc; X.setTransform(1, 0, 0, 1, 0, 0); X.strokeStyle = U.outlineColour; X.lineWidth = U.outlineThickness; X.shadowBlur = X.shadowOffsetX = X.shadowOffsetY = 0; X.globalAlpha = U.pulsateTo + ((1 - U.pulsateTo) * (0.5 + (g(2 * Math.PI * W / (1000 * U.pulsateTime)) / 2))); return this.drawFunc(X, this.x, this.y, this.w, this.h, U.outlineColour, i, j, V) }; d.Active = function (U, i, j) { return (i >= this.x && j >= this.y && i <= this.x + this.w && j <= this.y + this.h) }; d.PreDraw = d.PostDraw = d.LastDraw = function () { }; function C(W, j, aa, ac, ab, Y, U, V) { var Z = W.ctxt, X; this.tc = W; this.image = j.src ? j : null; this.name = j.src ? "" : j; this.title = aa.title || null; this.a = aa; this.p3d = { x: ac[0] * W.radius * 1.1, y: ac[1] * W.radius * 1.1, z: ac[2] * W.radius * 1.1 }; this.x = this.y = 0; this.w = ab; this.h = Y; this.colour = U || W.textColour; this.textFont = V || W.textFont; this.weight = this.sc = this.alpha = 1; this.weighted = !W.weight; this.outline = new e(W); if (this.image) { if (W.txtOpt && W.shadow) { X = M(this.image, W.shadow, W.shadowBlur, W.shadowOffset); if (X) { this.image = X; this.w = X.width; this.h = X.height } } } else { this.textHeight = W.textHeight; this.extents = H(this.name, this.textFont, this.textHeight); this.Measure(Z, W) } this.SetShadowColour = W.shadowAlpha ? this.SetShadowColourAlpha : this.SetShadowColourFixed; this.SetDraw(W) } G = C.prototype; G.SetDraw = function (i) { this.Draw = this.image ? (i.ie > 7 ? this.DrawImageIE : this.DrawImage) : this.DrawText }; G.Measure = function (Y, j) { this.h = this.extents ? this.extents.max.y + this.extents.min.y : this.textHeight; Y.font = this.font = this.textHeight + "px " + this.textFont; this.w = Y.measureText(this.name).width; if (j.txtOpt) { var V = j.txtScale, W = V * this.textHeight, X = W + "px " + this.textFont, U = [V * j.shadowOffset[0], V * j.shadowOffset[1]], i; Y.font = X; i = Y.measureText(this.name).width; this.image = k(this.name, X, W, i, V * this.h, this.colour, j.shadow, V * j.shadowBlur, U, V, V); if (this.image) { this.w = this.image.width / V; this.h = this.image.height / V } this.SetDraw(j); j.txtOpt = this.image } }; G.SetWeight = function (i) { this.weight = i; this.Weight(this.tc.ctxt, this.tc); this.Measure(this.tc.ctxt, this.tc) }; G.Weight = function (V, U) { var j = this.weight, i = U.weightMode; this.weighted = true; if (i == "colour" || i == "both") { this.colour = T(U, (j - U.min_weight) / (U.max_weight - U.min_weight)) } if (i == "size" || i == "both") { this.textHeight = j * U.weightSize } this.extents = H(this.name, this.textFont, this.textHeight) }; G.SetShadowColourFixed = function (U, j, i) { U.shadowColor = j }; G.SetShadowColourAlpha = function (U, j, i) { U.shadowColor = n(j, i) }; G.DrawText = function (U, Y, j) { var Z = this.tc, W = this.x, V = this.y, X, i, aa = this.sc; U.globalAlpha = this.alpha; U.setTransform(aa, 0, 0, aa, 0, 0); U.fillStyle = this.colour; Z.shadow && this.SetShadowColour(U, Z.shadow, this.alpha); U.font = this.font; X = this.w; i = this.h; W += (Y / aa) - (X / 2); V += (j / aa) - (i / 2); U.fillText(this.name, W, V) }; G.DrawImage = function (W, ac, V) { var ad = this.tc, Z = this.x, X = this.y, ae = this.sc, j = this.image, aa = this.w, U = this.h, Y = this.alpha, ab = this.shadow; W.globalAlpha = Y; W.setTransform(ae, 0, 0, ae, 0, 0); W.fillStyle = this.colour; ab && this.SetShadowColour(W, ab, Y); Z += (ac / ae) - (aa / 2); X += (V / ae) - (U / 2); W.drawImage(j, Z, X, aa, U) }; G.DrawImageIE = function (W, aa, V) { var j = this.image, ab = this.sc, Z = j.width = this.w * ab, U = j.height = this.h * ab, Y = (this.x * ab) + aa - (Z / 2), X = (this.y * ab) + V - (U / 2); W.setTransform(1, 0, 0, 1, 0, 0); W.globalAlpha = this.alpha; W.drawImage(j, Y, X) }; G.Calc = function (W, V) { var i = a(this.p3d, W), j = this.tc, X = j.minBrightness, U = j.radius; this.p3d = b(i, V); i = P(j, this.p3d, this.w, this.h, Math.PI / 4, 20); this.x = i.x; this.y = i.y; this.sc = (j.z1 + j.z2 - i.z) / j.z2; this.alpha = x(X, S(1, X + 1 - ((i.z - j.z2 + U) / (2 * U)))) }; G.CheckActive = function (V, Z, U) { var aa = this.tc, i = this.outline, Y = this.w, j = this.h, X = this.x - Y / 2, W = this.y - j / 2; i.Update(X, W, Y, j, this.sc, this.p3d, Z, U); return i.Active(V, aa.mx, aa.my) ? i : null }; G.Clicked = function (W) { var j = this.a, U = j.target, V = j.href, i; if (U != "" && U != "_self") { if (self.frames[U]) { self.frames[U] = V } else { if (top.frames[U]) { top.frames[U] = V } else { window.open(V, U) } } return } if (j.fireEvent) { if (!j.fireEvent("onclick")) { return } } else { i = h.createEvent("MouseEvents"); i.initMouseEvent("click", 1, 1, window, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); if (!j.dispatchEvent(i)) { return } } h.location = V }; function q() { var j, U = { mx: -1, my: -1, z1: 20000, z2: 20000, z0: 0.0002, freezeActive: false, activeCursor: "pointer", pulsateTo: 1, pulsateTime: 3, reverse: false, depth: 0.5, maxSpeed: 0.05, minSpeed: 0, decel: 0.95, interval: 20, initial: null, hideTags: true, minBrightness: 0.1, outlineColour: "#ffff99", outlineThickness: 2, outlineOffset: 5, outlineMethod: "outline", textColour: "#ff99ff", textHeight: 15, textFont: "Helvetica, Arial, sans-serif", shadow: "#000", shadowBlur: 0, shadowOffset: [0, 0], zoom: 1, weight: false, weightMode: "size", weightFrom: null, weightSize: 1, weightGradient: { 0: "#f00", 0.33: "#ff0", 0.66: "#0f0", 1: "#00f" }, txtOpt: true, txtScale: 2, frontSelect: false, wheelZoom: true, zoomMin: 0.3, zoomMax: 3, zoomStep: 0.05, shape: "sphere", lock: null, tooltip: null, tooltipDelay: 300, tooltipClass: "tctooltip" }; for (j in U) { this[j] = U[j] } this.max_weight = 0; this.min_weight = 200 } c = q.prototype; c.Draw = function () { var ad = this.canvas, ab = ad.width, U = ad.height, j = 0, aa = this.yaw, V = this.pitch, W = ab / 2, ag = U / 2, ae = this.ctxt, Y, af, ac, Z = -1, ai = this.taglist, X = ai.length, ah = this.frontSelect; if (aa == 0 && V == 0 && this.drawn) { return this.Animate(ab, U) } ae.setTransform(1, 0, 0, 1, 0, 0); this.active = null; for (ac = 0; ac < X; ++ac) { ai[ac].Calc(aa, V) } ai = ai.sort(function (aj, i) { return aj.sc - i.sc }); for (ac = 0; ac < X; ++ac) { af = ai[ac].CheckActive(ae, W, ag); if (af && af.sc > j && (!ah || af.z <= 0)) { Y = af; Y.index = Z = ac; j = af.sc } } this.active = Y; if (!this.txtOpt && this.shadow) { ae.shadowBlur = this.shadowBlur; ae.shadowOffsetX = this.shadowOffset[0]; ae.shadowOffsetY = this.shadowOffset[1] } ae.clearRect(0, 0, ab, U); for (ac = 0; ac < X; ++ac) { if (!(Z == ac && Y.PreDraw(ae, ai[ac], W, ag))) { ai[ac].Draw(ae, W, ag) } Z == ac && Y.PostDraw(ae) } if (this.freezeActive && Y) { this.yaw = this.pitch = this.drawn = 0 } else { this.Animate(ab, U); this.drawn = 1 } Y && Y.LastDraw(ae); ad.style.cursor = Y ? this.activeCursor : ""; this.Tooltip(Y, ai[Z]) }; c.TooltipNone = function () { }; c.TooltipNative = function (j, i) { this.canvas.title = j && i.title ? i.title : "" }; c.TooltipDiv = function (V, j) { var i = this, U = i.ttdiv.style, W = i.canvas.id; if (V && j.title) { i.ttdiv.innerHTML = j.title; if (U.display == "none" && !i.tttimer) { i.tttimer = setTimeout(function () { var X = F(i.canvas).offset(); U.display = "block"; U.left = X.left + i.mx + "px"; U.top = X.top + i.my + 24 + "px"; i.tttimer = null }, i.tooltipDelay) } } else { U.display = "none" } }; c.Animate = function (Z, W) { var U = this, Y = U.mx, X = U.my, j = U.lock, ab, aa, V, i; if (Y >= 0 && X >= 0 && Y < Z && X < W) { ab = U.maxSpeed, i = U.reverse ? -1 : 1; if (j != "x") { this.yaw = i * ((ab * 2 * Y / Z) - ab) } if (j != "y") { this.pitch = i * -((ab * 2 * X / W) - ab) } this.initial = null } else { if (!U.initial) { ab = U.minSpeed, aa = E(U.yaw), V = E(U.pitch); if (j != "x" && aa > ab) { this.yaw = aa > U.z0 ? U.yaw * U.decel : 0 } if (j != "y" && V > ab) { this.pitch = V > U.z0 ? U.pitch * U.decel : 0 } } } }; c.Zoom = function (i) { this.z2 = this.z1 * (1 / i); this.drawn = 0 }; c.Clicked = function (V) { var U = this.taglist, i = this.active; try { if (i && U[i.index]) { U[i.index].Clicked(V) } } catch (j) { } }; c.Wheel = function (j) { var U = this.zoom + this.zoomStep * (j ? 1 : -1); this.zoom = S(this.zoomMax, x(this.zoomMin, U)); this.Zoom(this.zoom) }; q.tc = {}; jQuery.fn.tagcanvas = function (U, j) { var i, V = j ? jQuery("#" + j) : this; if (h.all && !j) { return false } i = V.find("a"); if (K(window.G_vmlCanvasManager)) { this.each(function () { F(this)[0] = window.G_vmlCanvasManager.initElement(F(this)[0]) }); U.ie = parseFloat(navigator.appVersion.split("MSIE")[1]) } if (!i.length || !this[0].getContext || !this[0].getContext("2d").fillText) { return false } this.each(function () { var Y, W, aa, ad, ae, Z, ac, ab = [], X = { sphere: l, vcylinder: u, hcylinder: D }; j || (i = F(this).find("a")); Z = new q; for (Y in U) { Z[Y] = U[Y] } Z.z1 = (19800 / (Math.exp(Z.depth) * (1 - 1 / Math.E))) + 20000 - 19800 / (1 - (1 / Math.E)); Z.z2 = Z.z1 * (1 / Z.zoom); Z.radius = (this.height > this.width ? this.width : this.height) * 0.33 * (Z.z2 + Z.z1) / (Z.z1); Z.yaw = Z.initial ? Z.initial[0] * Z.maxSpeed : 0; Z.pitch = Z.initial ? Z.initial[1] * Z.maxSpeed : 0; Z.canvas = F(this)[0]; Z.ctxt = Z.canvas.getContext("2d"); Z.textFont = Z.textFont && r(Z.textFont); Z.pulsateTo *= 1; Z.textHeight *= 1; Z.minBrightness *= 1; Z.ctxt.textBaseline = "top"; if (Z.shadowBlur || Z.shadowOffset[0] || Z.shadowOffset[1]) { Z.ctxt.shadowColor = Z.shadow; Z.shadow = Z.ctxt.shadowColor; Z.shadowAlpha = t() } else { delete Z.shadow } Z.taglist = []; Z.shape = X[Z.shape] || X.sphere; W = Z.shape(i.length); for (Y = 0; Y < i.length; ++Y) { aa = i[Y].getElementsByTagName("img"); if (aa.length) { ad = new Image; ad.src = aa[0].src; ae = new C(Z, ad, i[Y], W[Y], 1, 1); L(ad, ae, Z.taglist) } else { Z.taglist.push(new C(Z, i[Y].innerText || i[Y].textContent, i[Y], W[Y], 2, Z.textHeight + 2, Z.textColour || J(i[Y], "color"), Z.textFont || r(J(i[Y], "font-family")))) } if (Z.weight) { ac = v(Z, i[Y]); if (ac > Z.max_weight) { Z.max_weight = ac } if (ac < Z.min_weight) { Z.min_weight = ac } ab.push(ac) } } if (Z.weight = (Z.max_weight > Z.min_weight)) { for (Y = 0; Y < Z.taglist.length; ++Y) { Z.taglist[Y].SetWeight(ab[Y]) } } q.tc[F(this)[0].id] = Z; Z.Tooltip = (Z.tooltip == "native" ? Z.TooltipNative : (Z.tooltip ? Z.TooltipDiv : Z.TooltipNone)); if (Z.tooltip) { if (Z.tooltip == "native") { Z.Tooltip = Z.TooltipNative } else { Z.Tooltip = Z.TooltipDiv; if (!Z.ttdiv) { Z.ttdiv = h.createElement("div"); Z.ttdiv.className = Z.tooltipClass; Z.ttdiv.style.position = "absolute"; Z.ttdiv.style.zIndex = Z.canvas.style.zIndex + 1; y("mouseover", function (af) { af.target.style.display = "none" }, Z.ttdiv); h.body.appendChild(Z.ttdiv) } } } else { Z.Tooltip = Z.TooltipNone } y("mousemove", I, this); y("mouseout", I, this); y("mouseup", o, this); if (Z.wheelZoom) { y("mousewheel", Q, this); y("DOMMouseScroll", Q, this) } j && Z.hideTags && V.hide(); U.interval = U.interval || Z.interval }); return !!(q.started || (q.started = setInterval(m, U.interval))) } })(jQuery);
(function(){
    
    var special = jQuery.event.special,
        uid1 = 'D' + (+new Date()),
        uid2 = 'D' + (+new Date() + 1);
        
    special.scrollstart = {
        setup: function() {
            
            var timer,
                handler =  function(evt) {
                    
                    var _self = this,
                        _args = arguments;
                    
                    if (timer) {
                        clearTimeout(timer);
                    } else {
                        evt.type = 'scrollstart';
                        jQuery.event.dispatch.apply(_self, _args);
                    }
                    
                    timer = setTimeout( function(){
                        timer = null;
                    }, special.scrollstop.latency);
                    
                };
            
            jQuery(this).bind('scroll', handler).data(uid1, handler);
            
        },
        teardown: function(){
            jQuery(this).unbind( 'scroll', jQuery(this).data(uid1) );
        }
    };
    
    special.scrollstop = {
        latency: 100,
        setup: function() {
            
            var timer,
                    handler = function(evt) {
                    
                    var _self = this,
                        _args = arguments;
                    
                    if (timer) {
                        clearTimeout(timer);
                    }
                    
                    timer = setTimeout( function(){
                        
                        timer = null;
                        evt.type = 'scrollstop';
                        jQuery.event.dispatch.apply(_self, _args);
                        
                    }, special.scrollstop.latency);
                    
                };
            
            jQuery(this).bind('scroll', handler).data(uid2, handler);
            
        },
        teardown: function() {
            jQuery(this).unbind( 'scroll', jQuery(this).data(uid2) );
        }
    };
    
})();
// format all dates
var _userTimeOffset = 0;

function performDateFormat(refreshInterval) { // refreshInterval set to false to prevent refreshing
    $('span.performdateformat').prettyDate(
        { refresh: refreshInterval,
            i18n: timeRelativeFormat, //from BasePageHelper.RegisterDateFormati18n
            offset: _userTimeOffset,
            isguest: false //(cMemberInfo.memID == -1)
        });
}

function autoAdjustTimeZone(serverTime) { //called by BasePageHelper.RegisterDateFormati18n
    var serverDateTime = new Date(serverTime);
    var clientDateTime = new Date();
    var iniOffset = -((serverDateTime.getTime() - clientDateTime.getTime()) / 36E5);
    _userTimeOffset = Math.abs(iniOffset) > 0.5 ? Math.round(iniOffset / 0.5) * 0.5 : Math.round(iniOffset);
}
/* common.js */

// initialize Basic jQuery
var $win = $(window), $doc = $(document), $body = $('body');

if (typeof $.store != 'undefined') $.storage = new $.store();

$doc.ready(function () { // functions in datecommon.js
    //autoAdjustTimeZone(new Date().addHours(3.7));    
    if (typeof cMemberInfo != 'undefined')
        performDateFormat(cMemberInfo.isMobileDevice ? false : 60000);
});

// debugging function
function consoleLog(obj) {
    if (window.console && window.console.log)
        console.log(obj);
}

function jqListAllEvents($ele, useAlert, onlyEvent) {
    $.each($ele.data("events"), function (i, event) {
        
        if (onlyEvent && !i.startsWith(onlyEvent)) return true; // skip

        if (useAlert) alert(i); else consoleLog(i);

        $.each(event, function (j, h) {
            if (useAlert) alert(h.handler); else consoleLog(h.handler);
        });
    });
}

$.fn.insertAt = function(elements, index) {
    var children = this.children().clone(true);
    var array = $.makeArray(children);
    array.splice(index, 0, elements);
    this.empty().append(array);
    return this;
};

function removeTouchFromBody() {
    // significant iPad dragging slowdown
    $body
        .off('touchmove')
        .off('touchstart')
        ;
    //jqListAllEvents($body, true, 'mouse');    
}

$doc.ready(removeTouchFromBody);

var _mobileAwareEventName =
    ((typeof cMemberInfo != 'undefined' && cMemberInfo.isMobileDevice) ? 'touchend' : 'mousedown'); //never register this on $body

// Checkbox function

function checkUncheckAll(self, attri, value){
    $(String.format("input:checkbox[{0}={1}]", attri, value)).each(function () { this.checked = self.checked; });
}

function anyChecked(attri, value) {
    return ($(String.format("input:checkbox[{0}={1}]:checked", attri, value)).length > 0);
}

// Random Chars Generator

function randomString(len, charSet) {
    charSet = charSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    var randomString = '';
    for (var i = 0; i < len; i++) {
        var randomPoz = Math.floor(Math.random() * charSet.length);
        randomString += charSet.substring(randomPoz, randomPoz + 1);
    }
    return randomString;
}

// Array Extension
Array.prototype.contains = function (value) {
    return _.contains(this, value);
};

Array.prototype.any = function (arr2) {
    for (var i = 0; i < this.length; i++) {
        var val = this[i];
        for (var j = 0; j < arr2.length; j++) {
            if (val == arr2[j]) {
                return true;
            }
        }
    }
    return false;
};

if (!('indexOf' in Array.prototype)) {
    Array.prototype.indexOf = function (find, i /*opt*/) {
        return _.indexOf(this, find, i);
    };
}

// String Extension
String.prototype.escapeHtml = function() {
    var map = {
        "&": "&amp;",
        "'": "&#39;",
        '"': "&quot;",
        "<": "&lt;",
        ">": "&gt;"
    };

    return this.replace(/[&"'\<\>]/g, function (c) {
        return map[c];
    });
};

String.prototype.crLfToBr = function() {
    return this.
        replace(/\r\n/g, '<br>').
        replace(/\r/g, '<br>').
        replace(/\n/g, '<br>');
};

/*
General Image functions
*/

function getFileExt(filename) {
    var dot = filename.lastIndexOf(".");
    if (dot == -1) return "";
    var extension = filename.substr(dot + 1, filename.length);

    return extension;
}

function isImageFile(filename) {
    return /(gif|jpg|jpeg|bmp|png)/gi.test(getFileExt(filename));
}

function getThumbScale(maxWidth){
    var thumbScales = [1600, 1280, 1024, 800, 640, 400];
    
    for (var i = 0; i < thumbScales.length; i++){
        if (maxWidth < thumbScales[i]){
            continue;
        }
        else {
            return thumbScales [i];
        }
    }
    
    return thumbScales [thumbScales.length-1];
    
}

function resizeImage(imgId, w, h) {
    var currentheight, currentwidth, tempMultiplier;
    var myBitmap = (typeof imgId == "string") ? document.getElementById(imgId) : imgId;
    //alert(typeof imgId);
    if (!myBitmap || w == 0 || h == 0) return; //otherwise IE will trigger error;

    currentheight = $(myBitmap).height();
    currentwidth = $(myBitmap).width();

    //alert("currentWidth: " + currentwidth + "; currentheight: " + currentheight);
    //alert('resizeImage2');
    if (h <= currentheight || w <= currentwidth) {
        if ((currentheight / h) > (currentwidth / w)) {
            tempMultiplier = h / currentheight;
        } else {
            tempMultiplier = w / currentwidth;
        }

        $(myBitmap).height(currentheight * tempMultiplier);
        $(myBitmap).width(currentwidth * tempMultiplier);
        //alert('resizeImage3');
    } else {
        //alert('resizeImage4');
        return;
    }

}

/*
General Radtooltip Function
*/

function popTip(txt, width, modal, manualClose, closeDelayInms, textFormat, title){
    var option = {};
    if (title) option = $.extend(true, {}, { content: { title: { text: title}} });
    qtip.pop(txt, width, modal, manualClose, closeDelayInms, textFormat, option);
}

function SignalNewPM(str){
    popTip(str, 450, false, true, 30*1000);
}

function popwin(url, winname, width, height) {

    var reOpera = /opera/i;
    var winnameRequired = ((navigator.appName == "Netscape" && parseInt(navigator.appVersion) == 4) || reOpera.test(navigator.userAgent));
    var leftPo = (screen.availWidth - width) / 2;
    var topPo = (screen.availHeight - height) / 2;

    if (!winnameRequired) winname = '';

    var win = window.open((urlNotRelative(url) ? cPathInfo.ForumDir : '') + url, winname,
        String.format("scrollbars=yes,toolbar=no,status=no,location=no,menubar=no,resizable=yes,height={0},width={1},left={2},top={3}", 
            (height - 20), (width - 10), leftPo, topPo));
    
    return win;
}

/*
General RadWindow Function
*/

function popRadWin(url, w, h, hideHandler, options) {
    var dim = getPopDimension(w, h);

    var finalHideHandler = $.isFunction(hideHandler) ? hideHandler : ($.isFunction(window.qtipPopupCloseHandler) ? window.qtipPopupCloseHandler : null);
    var oqtip = qtip.popWindow(url, document.title.replace(/</g, '&lt;').replace(/>/g, '&gt;'), dim.w, dim.h, finalHideHandler, options);
    return $(oqtip);
}

function getPopDimension(w, h) {
    var dim = {};
    
    if (!w || !h) {
        var maxWidth = 1150; var maxHeight = 700; var sizeShrinkFactor = 0.8;

        var vportSize = getViewportSize();
        var desiredWidth = (vportSize[0] * sizeShrinkFactor); var desiredHeight = (vportSize[1] * sizeShrinkFactor);

        var finalWidth = desiredWidth > maxWidth ? maxWidth : desiredWidth;
        var finalHeight = desiredHeight > maxHeight ? maxHeight : desiredHeight;

        if (!w) dim.w = finalWidth;
        if (!h) dim.h = finalHeight;
        
    } else {
        dim.w = w;
        dim.h = h;
    }
    if (dim.w < 560) dim.w = 560;
    return dim;
}

function urlNotRelative(url) {
    var firstChar = url.substring(0, 1);

    return (firstChar != '.' &&
        firstChar != '/' &&
            url.substring(0, 7).toLowerCase() != 'http://' && 
                url.substring(0, 8).toLowerCase() != 'https://');
    
}

/* search box and autoComplete functions */

function registerAutoCompleteForNameSearch() {
    $body.on('focus', 'input[type=text]', function () {
        //consoleLog('focus on auto complete');
        var $box = $(this);

        if ($box.attr('loginbox') == 'true') {
            registerAutoCompleteForTxtbox($box, function (phrase, onComplete) {
                JQCallWebService("ws/MemberList.aspx/SimpleSearchMember",
                { searchString: phrase },
                function (rtn) { var returnedData = rtn.d; onComplete(returnedData); });
            });
        }
    });
}

function registerAutoCompleteForTxtbox(txtbox, queryFunction) {

    $(txtbox).autocomplete({
        source: function (request, response) {
            queryFunction(request.term, response);
            //  1.  response is a .autocomplete function that takes [string] as param
            //  2.  queryFunction receives request.term as query phrase, and execute
            //      response([answers]) at the end
        },
        minLength: 2,
        open: function () {
            $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
        },
        close: function () {
            $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
        }
    }).unbind('unfocus.autocomplete').bind('unfocus.autocomplete', function () {
        $(this).autocomplete('close');

    }).unbind('keypress.autocomplete').bind('keypress.autocomplete', function (e) {
        if (isEnterKeyPressed(e)) $(this).autocomplete('close');
    });
}

/*
    Keyboard enter to Update
*/

function isEnterKeyPressed(e) {
    return ((e.keyCode ? e.keyCode : e.which) == 13);
}

function registerEnterClickButton(areaSelector, btnSelector) {
    var selectors = '{0} input[type="text"], {0} input[type=radio], {0} input[type=checkbox], {0} select';

    $body.delegate(String.format(selectors, areaSelector), 'keydown', function (e) {
        if (isEnterKeyPressed(e)) {
            $(btnSelector).click();
            return false;
        }
    });
}

function enterToClickButton(event, btnClientID){

    if (isEnterClicked(event)) {
        //alert("enterToClickButton");
        document.getElementById(btnClientID).click();
        stopDefaultAction(event);
    }
}

function enterToSubmitLinkButton(event, btnUniqueID){

    if (isEnterClicked(event)) {
        //alert("enterToSubmitLinkButton");
        __doPostBack(btnUniqueID, '');
        stopDefaultAction(event); 
    } 
}

function enterToAjaxRequestLinkButton(event, btnUniqueID, AjaxPanel){

    if (isEnterClicked(event)) {
        AjaxPanel.ajaxRequestWithTarget(btnUniqueID, '');
        stopDefaultAction(event);
    } 
}

function enterToExecuteScript(event, script){

    if (isEnterClicked(event)) {
        //alert("enterToExecuteScript");
        eval(script);
        stopDefaultAction(event);
    }
}

function isEnterClicked(event) {
    if (typeof event == "undefined") event = window.event;

    if (event.which || event.keyCode) {
        if ((event.which == 13) || (event.keyCode == 13)) return true;
    }

    return false;
}

/* Cookies Functions */
function createCookie(name,value,days) {
    var expires = "";

	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
    document.cookie = cookiePrefix + name + "=" + value + expires + "; path=/";
	//alert(name+"="+value+expires+"; path=/");
}

function readCookie(name)
{
    var nameEQ = cookiePrefix + name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
    createCookie(name, "", -1);
}

/* Smart Columns 
----------------------*/

function enableSmartColumns(containerSel, childSel, minChildrenWidth, afterResizeHandler) {

    //Reset column size to a 100% once view port has been adjusted
    var $container = $(containerSel);
    $container.css({ 'width': "100%" });

    var colWrap = $container.width(); //Get the width of row
    var colNum = Math.floor(colWrap / minChildrenWidth); //Find how many columns of 200px can fit per row / then round it down to a whole number
    var colFixed = Math.floor(colWrap / colNum); //Get the width of the row and divide it by the number of columns it can fit / then round it down to a whole number. This value will be the exact width of the re-adjusted column

    $container.css({ 'width': colWrap }); //Set exact width of row in pixels instead of using % - Prevents cross-browser bugs that appear in certain view port resolutions.
    $container.find(childSel).css({ 'width': colFixed }); //Set exact width of the re-adjusted column

    if ($.isFunction(afterResizeHandler)) {
        afterResizeHandler.call($container, colFixed);
    }
}

/*
 Jump Menu
*/

function jumpMenu(j){
    var jval = j.options[j.selectedIndex].value;
    if (jval != "") self.location.href = jval;
}

function changeTheme(s) {
    var theVal = s.options[s.selectedIndex].value;
    
    if(theVal == 'Mobile') {
        self.location.replace(cPathInfo.ForumDir + 'm/');
        return false;
    }

    createCookie("settheme", theVal, 30); //save cookie on browser so we can have per device theme
    self.location.replace(cPathInfo.Url.replace(/settheme=[^\&]+/i, ''));
}


function getQueryString(name) {
    var match = RegExp('[?&]' + name + '=([^&]*)')
                    .exec(location.search);
    return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}

function insertQueryString(key, value) {
    key = escape(key); value = escape(value);

    var kvp = document.location.search.substr(1).split('&');
    if (kvp == '') {
        document.location.search = '?' + key + '=' + value;
    }
    else {

        var i = kvp.length; var x; while (i--) {
            x = kvp[i].split('=');

            if (x[0] == key) {
                x[1] = value;
                kvp[i] = x.join('=');
                break;
            }
        }

        if (i < 0) { kvp[kvp.length] = [key, value].join('='); }

        //this will reload the page, it's likely better to store this until finished
        document.location.search = kvp.join('&');
    }
}

 // Getting viewport size 
function getViewportSize(win)
{
  if (typeof win == 'undefined') win = self.window;
  
  var size;

  if (typeof win.innerWidth != 'undefined')
  {
    size = [
        win.innerWidth,
        win.innerHeight
    ];
    //alert("innerWidth");
  }
  else if (typeof win.document.documentElement != 'undefined'
      && typeof win.document.documentElement.clientWidth != 'undefined'
      && win.document.documentElement.clientWidth != 0)
  {
    size = [
        win.document.documentElement.clientWidth,
        win.document.documentElement.clientHeight
    ];
    //alert("clientWidth");
  }
  else
  {
    size = [
        win.document.getElementsByTagName('body')[0].clientWidth,
        win.document.getElementsByTagName('body')[0].clientHeight
    ];
    //alert("body.clientWidth");
  }

  return size;
}

function stopDefaultAction(event)
{
  event.returnValue = false;

  if (typeof event.preventDefault != "undefined")
  {
    event.preventDefault();
  }

  return true;
}

function getEventTarget(event) {

    if (typeof event == "undefined") {
        event = window.event;
    }

    var targetElement;

    if (typeof event.target != "undefined") {
        targetElement = event.target;
    }
    else {
        targetElement = event.srcElement;
    }

    while (targetElement.nodeType == 3 && targetElement.parentNode != null) {
        targetElement = targetElement.parentNode;
    }

    return targetElement;
}

$doc.ready(function () {
    $("input[name^='__']").attr('autocomplete', 'off'); //enable firefox BF cache
    //performScrollToContent();

    if (typeof $telerik != "undefined" && typeof $telerik.$ === "undefined") { // fix Telerik error without global disable switch
        $telerik.$ = window.jQuery;
    }
});

function performScrollToContent() {

    if (typeof scrollToContent != 'undefined' && $.isFunction(scrollToContent)) {

        var scrollToSpec = scrollToContent.apply();
        
        if (!scrollToSpec) return;

        var scrollToSel = '.message_title, .forum_title, .category_title';

        if (typeof scrollToSpec == 'string') {
            scrollToSel = scrollToSpec;
        }

        var $scrollToTarget = $(scrollToSel);

        if ($scrollToTarget.length != 0) {
            $.scrollTo($scrollToTarget.eq(-1), { duration: 0 });
        }
    }
}

function addTabSupportToTextarea(selectors) {
    $doc.on('keydown', selectors, function (e) {
        var keyCode = e.keyCode || e.which;

        if (keyCode == 9) {
            e.preventDefault();
            var start = $(this).get(0).selectionStart;
            var end = $(this).get(0).selectionEnd;

            // set textarea value to: text before caret + tab + text after caret
            $(this).val($(this).val().substring(0, start)
            + "\t"
            + $(this).val().substring(end));

            // put caret at right position again
            $(this).get(0).selectionStart =
            $(this).get(0).selectionEnd = start + 1;
        }
    });         
}

var createElement = (function () {
    // Detect IE using conditional compilation

    var ie9Above = (navigator.userAgent.indexOf("Trident/5") > -1 || navigator.userAgent.indexOf("Trident/6") > -1);

    if (/*@cc_on@*//*@if (@_win32)!/*@end@*/false && !ie9Above) {
        // Translations for attribute names which IE would otherwise choke on
        var attrTranslations =
        {
            "class": "className",
            "for": "htmlFor"
        };

        var setAttribute = function (element, attr, value) {
            if (attrTranslations.hasOwnProperty(attr)) {
                element[attrTranslations[attr]] = value;
            }
            else if (attr == "style") {
                element.style.cssText = value;
            }
            else {
                element.setAttribute(attr, value);
            }
        };

        return function (tagName, attributes) {
            attributes = attributes || {};
            var element;

            // See http://channel9.msdn.com/Wiki/InternetExplorerProgrammingBugs
            if (attributes.hasOwnProperty("name") ||
                attributes.hasOwnProperty("checked") ||
                attributes.hasOwnProperty("multiple")) {
                var tagParts = ["<" + tagName];
                if (attributes.hasOwnProperty("name")) {
                    tagParts[tagParts.length] =
                        ' name="' + attributes.name + '"';
                    delete attributes.name;
                }
                if (attributes.hasOwnProperty("checked") &&
                    "" + attributes.checked == "true") {
                    tagParts[tagParts.length] = " checked";
                    delete attributes.checked;
                }
                if (attributes.hasOwnProperty("multiple") &&
                    "" + attributes.multiple == "true") {
                    tagParts[tagParts.length] = " multiple";
                    delete attributes.multiple;
                }
                tagParts[tagParts.length] = ">";

                element =
                    document.createElement(tagParts.join(""));
            }
            else {
                element = document.createElement(tagName);
            }

            for (var attr in attributes) {
                if (attributes.hasOwnProperty(attr)) {
                    setAttribute(element, attr, attributes[attr]);
                }
            }

            return element;
        };
    }
    // All other browsers
    else {
        return function (tagName, attributes) {
            attributes = attributes || {};
            var element = document.createElement(tagName);
            for (var attr in attributes) {
                if (attributes.hasOwnProperty(attr)) {
                    element.setAttribute(attr, attributes[attr]);
                }
            }
            return element;
        };
    }
})();

function urlNotRelative(url) {
    var firstChar = url.substring(0, 1);

    return (firstChar != '.' &&
        firstChar != '/' &&
            url.substring(0, 7).toLowerCase() != 'http://' &&
                url.substring(0, 8).toLowerCase() != 'https://');

}

function JQCallWebService(location, data, success, failure, ctex) {

    var webMethod = location;

    if (urlNotRelative(location)) { webMethod = cPathInfo.ForumDir + location; }
    //alert(webMethod);
    return $.ajax({
        cache: false,
        type: "POST",
        url: webMethod, //"ServiceName.asmx/WebMethodName"; "PageName.aspx/MethodName"
        data: JSON.stringify(($.isFunction(data) ? data() : data)),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        context: ctex,
        success: success,
        error: $.isFunction(failure) ? failure : JQOnCallError
    });
}

function JQOnCallError(XMLHttpRequest, ajaxOptions, thrownError) {

    var trapError = true;
    
    if (!trapError || XMLHttpRequest.readyState == 0 || XMLHttpRequest.status == 0)
        return;  // it's not really an error or we don't trap error

    try {

        JQCallWebService('ws/SystemConfig.aspx/LogPageMethodError', JSON.parse(XMLHttpRequest.responseText), function () {
            qtip.alert('An unexpected error occurred and logged. Please try again later.');
        }, function () {
            return '';
        });
        
    } catch (e) {

    }

}
var forumThemeInfo = {};
forumThemeInfo.forumIcons = [];
forumThemeInfo.forumIcons.forumUnRead = 'board_new.gif';
forumThemeInfo.forumIcons.forumRead = 'board.gif';
forumThemeInfo.forumIcons.forumLink = 'board_link.gif';
forumThemeInfo.forumIcons.subforumRead = 'blank.gif';
forumThemeInfo.forumIcons.subforumUnRead = 'subforum_new.gif';
forumThemeInfo.forumIcons.subforumLink = 'subforum_link.gif';
forumThemeInfo.forumIcons.threadUnRead = 'thread_new.gif';
forumThemeInfo.forumIcons.threadRead = 'thread.gif';
forumThemeInfo.forumIcons.threadNewestArrow = 'newestmsg.gif';
forumThemeInfo.forumIcons.threadLatestArrow = 'latestmsg.gif';
forumThemeInfo.forumIcons.subforumClose = 'minus-small.png';
forumThemeInfo.forumIcons.subforumOpen = 'plus-small.png';

forumThemeInfo.forumIcons.popqTipTitleIcon = 'tip_titleIcon.png';

forumThemeInfo.jQueryEasing = 'easeInOutCubic';
forumThemeInfo.topNavScrollEasing = 'easeInOutExpo';

$.scrollTo.defaults.margin = true;
$.scrollTo.defaults.easing = 'easeOutExpo';
$.scrollTo.defaults.duration = 500;
$.fn.qtip.defaults.hide.delay = 140;
$.fn.qtip.defaults.hide.fixed = true;
//$.fn.qtip.defaults.position.fixed = false;
$.fn.qtip.zindex = 210000;
$.fn.qtip.plugins.modal.zindex = 209000;

var qtip = {
    id: 'qTip',

    contentSelector: 'div.qtip-content',

    tipSelector: 'div.qtip',

    hide: function () {
        var qtipApi = $('#qtip-' + this.id).qtip('api');
        if (qtipApi) qtipApi.hide();
    },

    // simple notice tip after performing certain action
    notice: function ($target, content, additionalOptions) {
        var qTipOptions = {
            content: { text: content },
            position: { my: 'top right', at: 'bottom right' },
            style: { classes: 'qtip-rounded qtip-youtube qtip-shadow' },
            show: { ready: true, delay: 150, effect: function () { $(this).fadeIn(); } },
            hide: { fixed: true, inactive: 3000, delay: 1000 },
            events: { hide: function (e, api) { api.destroy(); } }
        };

        $target.qtip($.extend(true, {}, qTipOptions, additionalOptions));
    },

    // iFrame loading URL Support
    popWindow: function (url, title, width, height, hideEventHandler, additionalOptions) {

        if (urlNotRelative(url)) {
            url = cPathInfo.ForumDir + url;
        }

        var popHTML =
            '<div id="featuredOverlay" style="position:absolute; top:0; left:0; width:100%; height:100%;" class="none">' +
                '<img src="' + cPathInfo.ForumDir + 'image/blank.gif" width="100%" height="100%" alt="image" /></div>' +
                    '<iframe id="featuredIframe" marginheight="0" marginwidth="0" frameborder="0" width="100%" height="' + height.toString() + 'px" src="' + url + '"></iframe>';

        return this.dialogue(popHTML,
            '<i class="icon-tasks"></i> ' + title, 
                $.extend(true, {}, {
                    id: 'popWindow',
                    style: {
                        widget: false,
                        tip: false,
                        width: width.toString() + 'px',
                        classes: 'qtip-apgpop qtip-wideshadow qtip-rounded qtip-draggable '
                    },
                    position: { adjust: { resize: false, scroll : false} }, //for ui.resizable
                    show: { modal: { on: !qtip.isMobileBrowser(), blur: false} },
                    events: {
                        show: function () {
                            if (qtip.isMobileBrowser()) return true;
                            var $thisTooltip = $(this);
                            var $overlay = $thisTooltip.find('#featuredOverlay');

                            $thisTooltip.draggable({
                                appendTo: document,
                                handle: '.qtip-titlebar',
                                iframeFix: true,
                                start: function () {
                                    $overlay.removeClass('none');
                                },
                                stop: function () {
                                    $overlay.addClass('none');
                                }
                            });

                            // resize tooltip-content to prevent FF issue: editor losing focus
                            $thisTooltip.children(qtip.contentSelector).resizable({
                                autoHide: true,
                                handles: 'se',
                                alsoResize: '.qtip-apgpop, #featuredIframe',
                                start: function () {
                                    $overlay.removeClass('none');
                                },
                                stop: function () {
                                    $overlay.addClass('none');
                                }
                            });

                            return true;
                        },
                        hide: function (event, api) {
                            if ($.isFunction(hideEventHandler)) {
                                hideEventHandler.call(this, event, api);
                            }
                            api.destroy();
                        }
                    }
                }, additionalOptions));
    },

    isMobileBrowser: function () {
        return cMemberInfo.isMobileDevice;
        /*        return (
        //Detect iPhone
        (navigator.platform.indexOf("iPhone") != -1) ||
        //Detect iPod
        (navigator.platform.indexOf("iPod") != -1) ||
        //Detect iPad
        (navigator.platform.indexOf("iPad") != -1)
        );*/
    },

    // bigger dialogue box mainly used for WYSIWYG function windows
    dialogue: function (content, title, additionalOptions) {
        /* 
        * Since the dialogue isn't really a tooltip as such, we'll use a dummy
        * out-of-DOM element as our target instead of an actual element like document.body
        */
        var qTipOptions = {
            content: {
                text: content,
                title: {
                    text: (title || '&nbsp;'),
                    button: true
                }
            },
            position: {
                my: 'center',
                at: 'center',
                target: $win,
                //viewport: $win, this will restore position when you scroll
                adjust: { resize: true }
            },
            show: {
                ready: true, // Show it straight away
                modal: {
                    on: true, // Make it modal (darken the rest of the page)...
                    blur: false // ... but don't close the tooltip when clicked
                }
            },
            hide: false, // We'll hide it maunally so disable hide events
            style: {
                classes: 'qtip-rounded qtip-wideshadow qtip-apgpop zMax ',
                widget: false
            },
            events: {
                // Hide the tooltip when any buttons in the dialogue are clicked
                render: function (event, api) {
                    $('button', api.elements.content).bind('click.dialogue', api.hide);
                    var $tip = $(this);
                    if (qtip.isMobileBrowser())
                        $tip.css('top', '+=' + $win.scrollTop().toString());
                    else
                        $tip.css('position', 'fixed'); //api.set('position.adjust.y', $win.scrollTop());
                },
                // Destroy the tooltip once it's hidden as we no longer need it!
                hide: function (event, api) { api.destroy(); }
            }
        };

        return $('<div />').qtip($.extend(true, {}, qTipOptions, additionalOptions));
    },

    // a confirm dialogue with 3 buttons support
    confirm: function (msg, okBtnTxt, ok2BtnTxt, cancelBtnTxt, okHandler, ok2Handler, cancelHandler) {
        this.dialogue(
            '<div style="padding: 20px 10px 15px; min-width:220px;">' +
            '<div class="center">' +
            '<h4 style="margin-bottom: 15px"><i class="icon-exclamation-sign icon-large"></i>&nbsp; ' + msg + '</h4>' +
            (okBtnTxt !== '' ? '<button class="gradient1 rMargin10 ok">' + okBtnTxt + '</button>' : '') +
            (ok2BtnTxt !== '' ? '<button class="gradient1 rMargin10 ok2">' + ok2BtnTxt + '</button>' : '') +
            (cancelBtnTxt !== '' ? '<button class="gradient2 cancel">' + cancelBtnTxt + '</button>' : '') +
            '</div></div>', '&nbsp;', {
                events: {
                    // Hide the tooltip when any buttons in the dialogue are clicked
                    render: function (event, api) {

                        $('button', api.elements.content).bind('click.confirm', function () {
                            if ($(this).hasClass('ok')) {
                                if ($.isFunction(okHandler)) okHandler.call(this);
                                api.hide();
                            } else if ($(this).hasClass('ok2')) {
                                if ($.isFunction(ok2Handler)) ok2Handler.call(this);
                                api.hide();
                            } else {
                                if ($.isFunction(cancelHandler)) cancelHandler.call(this);
                                api.hide();
                            }
                        });

                        var $tip = $(this);
                        if (qtip.isMobileBrowser())
                            $tip.css('top', '+=' + $win.scrollTop().toString());
                        else
                            $tip.css('position', 'fixed'); //api.set('position.adjust.y', $win.scrollTop());
                    },
                    visible: function () {
                        $(this).find('button.ok').focus();
                    }
                }
            });
    },

    // a prompt dialogue with 2 button and a textbox

    multilinePrompt: function ($target, width, title, txtboxVal, updateBtnTxt, cancelBtnTxt, updateHandler, cancelHandler, additionalOptions) {
        return qtip.prompt($target, width, title, txtboxVal, updateBtnTxt, cancelBtnTxt, updateHandler, cancelHandler, additionalOptions, true);
    },
    prompt: function ($target, width, title, txtboxVal, updateBtnTxt, cancelBtnTxt, updateHandler, cancelHandler, additionalOptions, multiline) {

        var options = $.extend(true, {}, {
            content: { title: { text: title} },
            position: { target: $target, my: 'bottom right', at: 'top center' },
            style: { classes: ' qtip-apgmenu qtip-wideshadow '},
            events: {
                visible: function (e, api) {

                    var $tip = $(this);
                    var $txtbox = $('#qtipPromptTxtbox');
                    var $update = $('#qtipPromptUpdate');
                    var $cancel = $('#qtipPromptCancel');

                    $txtbox.select().keypress(function (clickEvent) {
                        if (multiline) return true;
                        var code = (clickEvent.keyCode ? clickEvent.keyCode : clickEvent.which);
                        if (code == 13) {
                            $update.click();
                        }

                        return true;
                    });

                    $update.click(function () {
                        if ($.isFunction(updateHandler)) {
                            updateHandler.call($tip, $txtbox.val());
                        }
                    });

                    $cancel.click(function () {
                        if ($.isFunction(cancelHandler)) {
                            cancelHandler.call($tip, $txtbox.val());
                        } else {
                            api.hide();
                        }
                    });

                },
                hide: function (e, api) { api.destroy(); }
            }
        }, additionalOptions);

        var boxTmpl = (multiline ? '<textarea id="qtipPromptTxtbox" style="width:90%">{0}</textarea>' :
            '<input type="text" id="qtipPromptTxtbox" style="width:90%" value="{0}" />');

        var htmlbox = String.format(boxTmpl, txtboxVal.replace(/\"/gi, '&quot;'));

        return this.pop(htmlbox + "<div class='divider'></div>&nbsp;<button id='qtipPromptUpdate' class='gradient1 rMargin10'>" + updateBtnTxt + "</button>" +
                (cancelBtnTxt != '' ? "<button id='qtipPromptCancel' class='gradient2 rMargin10'>" + cancelBtnTxt + '</button>' : ''),
                width, false, true, 50000, '<div class="bPadding5">{0}</div>', options);
    },

    // simple dialogue like alert box etc
    pop: function (txt, width, modal, manualClose, closeDelayInms, textFormat, additionalOptions) {
        var theID = this.id;
        var qTipOptions = {
            id: theID, // Since we're only creating one modal, give it an ID so we can style it
            content: {
                text: String.format((textFormat ? textFormat : '<div class="padding10 margin10"><h4> {0} </h4></div>'), txt),
                title: {
                    text: '&nbsp;',
                    button: true
                }
            },
            position: {
                my: 'center',
                at: 'center',
                target: $win,
                viewport: $win,
                adjust: { resize: true }
            },
            show: {
                ready: true, // Show it on click...
                solo: true, // ...and hide all other tooltips...
                modal: { on: modal, blur: !manualClose} // ...and make it modal
            },
            hide: (manualClose ? false : {
                event: 'unfocus',
                inactive: closeDelayInms,
                fixed: true,
                distance: 15
            }),
            style: {
                classes: 'qtip-rounded qtip-wideshadow qtip-apgpop ',
                width: width || 'auto',
                widget: false
            },
            events: {
                // Hide the tooltip when any buttons in the dialogue are clicked
                render: function () {
                    var $tip = $(this);
                    if (qtip.isMobileBrowser())
                        $tip.css('top', '+=' + $win.scrollTop().toString());
                    else
                        $tip.css('position', 'fixed'); //api.set('position.adjust.y', $win.scrollTop());
                } //,
                // Destroy the tooltip once it's hidden as we no longer need it!
                //hide: function (event, api) { api.destroy(); }
            }
        };

        var $empty = $('<div />');
        $empty.qtip($.extend(true, {}, qTipOptions, additionalOptions));

        return $empty;
    },

    // simplest usage with predefined width and modal
    alert: function (txt) {
        return this.pop(txt, 450, true, true, 10 * 1000);
    }

};

var xml_htmlReturned = '';
var Page_IsCallBack = false;

function grabContent(panel, args) { // OnClientResponseEnding
    xml_htmlReturned = args.get_content();
    Page_IsCallBack = true;
}

function executeScript(panel) { // OnClientResponseEnded
    performDateFormat(false);
    parseScript(xml_htmlReturned);
    $('#' + panel.get_id()).stop().animate({ 'opacity': 1 });
}

function parseJQLoadScript(source) {
    var scripts = new Array();
    while (source.indexOf("<!--ajaxs") > -1 || source.indexOf("<!--ajaxe") > -1) {
        var s = source.indexOf("<!--ajaxs");
        var s_e = source.indexOf(">", s);
        var e = source.indexOf("<!--ajaxe", s);
        var e_e = source.indexOf(">", e);

        // Add to scripts array
        scripts.push(source.substring(s_e + 1, e));
        // Strip from source
        source = source.substring(0, s) + source.substring(e_e + 1);
    }
    for (var i = 0; i < scripts.length; i++) {
        parseScript(scripts[i]);
    }
}

function parseScript(_source) {
    var source = _source;
    var scripts = new Array();

    // Strip out tags
    while (source.indexOf("<script") > -1 || source.indexOf("</script") > -1) {
        var s = source.indexOf("<script");
        var s_e = source.indexOf(">", s);
        var e = source.indexOf("</script", s);
        var e_e = source.indexOf(">", e);

        // Add to scripts array
        scripts.push(source.substring(s_e + 1, e));
        // Strip from source
        source = source.substring(0, s) + source.substring(e_e + 1);
    }

    // Loop through every script collected and eval it
    for (var i = 0; i < scripts.length; i++) {

        try {
            eval(scripts[i]);
            //consoleLog('success script: ' + scripts[i]);
        }
        catch (ex) {
            // do what you want here when a script fails
            consoleLog('failed: ' + scripts[i] + '. Reason:' + ex.toString());
        }
    }

    // Return the cleaned source
    return source;
}

// file: trackread.js

/* Cookies Functions Duplicates */
function readCookie(name) {
    var nameEQ = cookiePrefix + name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

//appReadTracking = 0;

var hashTTrack, hashFTrack;
if (typeof appReadTracking == 'undefined' || appReadTracking == 0 || cMemberInfo.memID == -1) {

    var threadTracking = (readCookie('tTrack') != null) ? readCookie('tTrack') : "";

    var forumTracking = (readCookie('fTrack') != null) ? readCookie('fTrack') : "";

    hashTTrack = getReadTrackingCookieIntoHash(threadTracking);
    hashFTrack = getReadTrackingCookieIntoHash(forumTracking);

    //consoleLog(hashFTrack);
}

function getReadTrackingCookieIntoHash(cookieVal) {
    var arrTrack = cookieVal.split("&");
    var hash = new Array();

    for (var i = 0; i < arrTrack.length; i++) {

        var fSubArr = arrTrack[i].split("=");

        if (fSubArr.length == 2) hash[fSubArr[0]] = fSubArr[1];
    }

    return hash;
}

function trackForumRead() {

    if (appReadTracking == 0 || cMemberInfo.memID == -1) {
        trackReadSessionOnly('f');
        return;
    }
    
    var theForumId = (typeof currentForumID != 'undefined' ? (currentForumID ? currentForumID : 0) : 0);
    var icons = forumThemeInfo.forumIcons;
    var forumTrackIconSel = 'img.trackreadfimg';

    $(forumTrackIconSel).each(function () {
        var $thisImg = $(this);
        $thisImg.attr('src', pageThemeImageURL + (!$thisImg.hasClass('arrow') ? icons.forumRead : icons.subforumRead));
    });

    JQCallWebService('ws/TrackRead.aspx/CheckForumRead', { forumid: theForumId }, function (r) {
        var forumsToMarkNew = r.d; // contains non-visible sub forums that needs marked new, which influences the state of parent forum img

        $(forumTrackIconSel).each(function () {
            var $thisImg = $(this);
            var fid = $thisImg.data('trackfid');
            
            if (!fid) { // not trackable  - probably link forum
                displayNonTrackableForumImage($thisImg);
                return true;
            }
            
            var subfData = $thisImg.data('subforums');
            var subforums = (typeof subfData != 'undefined' ? (subfData ? subfData.toString().split(',') : []) : []);
            
            if (forumsToMarkNew.contains(fid) || forumsToMarkNew.any(subforums)) {
                $thisImg.attr('src', pageThemeImageURL + (!$thisImg.hasClass('arrow') ? icons.forumUnRead : icons.subforumUnRead));
            } 
            
            return true;
        });

    }, JQOnCallError);
}

function trackThreadRead(region, markNewFunc, setTrackImgFunc) {
    if (appReadTracking == 0 || cMemberInfo.memID == -1) {
        trackReadSessionOnly('t');
        return;
    }

    var $region = region ? $(region) : $body;

    var $timgSelector = $region.find('img.trackreadtimg');
    
    var threadIds = [];

    $timgSelector
    //.attr('src', pageThemeImageURL + forumThemeInfo.forumIcons.threadRead)
        .each(function () {
            var $thisImg = $(this);
            if (WorthMarkingRead(new Date($thisImg.data('trackdate')))) {
                threadIds[threadIds.length] = $thisImg.data('tracktid');
            } else {
                if ($.isFunction(setTrackImgFunc)) {
                    setTrackImgFunc.apply($thisImg);
                } else {
                    setThreadReadTrackImgSrc($thisImg);
                }
            }
        });

    if (threadIds.length == 0) return;

    JQCallWebService('ws/TrackRead.aspx/CheckThreadRead', { threadIDs: threadIds }, function (r) {
        var threadsToMarkNew = r.d; // this includes all threads needs to be marked new, and everything else marked old;

        $timgSelector.each(function () {
            // skip whose id is not in

            var $thisImg = $(this);
            var tid = $thisImg.data('tracktid');

            if (threadIds.contains(tid)) {

                if (threadsToMarkNew.contains(tid)) {
                    $thisImg.addClass('newpost');

                    if ($.isFunction(markNewFunc)) {
                        markNewFunc.call($thisImg, tid);
                    } else {
                        markNewThreadTitleAndArrow(tid);
                    }

                }

                if ($.isFunction(setTrackImgFunc)) {
                    setTrackImgFunc.apply($thisImg);
                } else {
                    setThreadReadTrackImgSrc($thisImg);
                }
            }

        });
    });
}

function trackMessageRead($allClientDates, getNewLabelParent, callbackAfterMarking) { 
    // getNewLabelParent is a function that returns the parent for "new" label; Usually the parent of the avatar;
    // callbackAfterMarking is a function to execute after at least one message is unread
    
    //consoleLog('checkReadOnload');
    //consoleLog($allClientDates.length);
    var latestDate = new Date(1); // 1 ms after 1970
    var aVisibleMsgFound = false; // not recycled

    $allClientDates.each(function () {
        aVisibleMsgFound = true;
        var thisMsgDate = new Date($(this).data('date'));
        if (thisMsgDate.getTime() - latestDate.getTime() > 0)
            latestDate = thisMsgDate;
    });

    //consoleLog(aVisibleMsgFound);
    if (!aVisibleMsgFound) return;

    //compare the latest message date with last read trackable date
    if (WorthMarkingRead(latestDate)) {
        
        //consoleLog('WorthMarkingRead');

        var atLeastOneMarked = false;

        if (appReadTracking == 0 || cMemberInfo.memID == -1) {
            var cookiedate = getCookieTrackDate('t', currentThreadID);

            atLeastOneMarked = markNewMessageTitleAndArrow(cookiedate, $allClientDates, getNewLabelParent);
            if (atLeastOneMarked && $.isFunction(callbackAfterMarking)) callbackAfterMarking();
            if (atLeastOneMarked) recordNewMessageLastVisit(latestDate);
            
        } else {

            JQCallWebService('ws/TrackRead.aspx/GetThreadLastRead', { threadID: currentThreadID }, function (r) { // check read
                var referenceDate = new Date(r.d);

                atLeastOneMarked = markNewMessageTitleAndArrow(referenceDate, $allClientDates, getNewLabelParent);
                if (atLeastOneMarked && $.isFunction(callbackAfterMarking)) callbackAfterMarking();
                if (atLeastOneMarked) recordNewMessageLastVisit(latestDate);
            });
        }
        
    }
}

function recordNewMessageLastVisit(latestDate) {

    var mark = new Date(latestDate.getTime() + 1000).format('s');
    JQCallWebService("ws/TrackRead.aspx/MarkThreadRead", { threadID: currentThreadID, mark: mark });
}

function markNewMessageTitleAndArrow(referenceDate, $allClientDates, getNewLabelParent) {

    var atLeastOneMarked = false;
    
    $allClientDates.each(function () {
        var $this = $(this);
        var thisdate = new Date($this.data('date') || cMemberInfo.lastVisit);

        if (thisdate.getTime() - referenceDate.getTime() > 0) {

            if ($.isFunction(getNewLabelParent)) {
                getNewLabelParent.apply($(this))
                                .prepend('<span class="msgState newest">' + ln.ttIsNewTopic + '</span>');
            }
            
            atLeastOneMarked = true;
        }
    });

    return atLeastOneMarked;
}

function WorthMarkingRead(latestDateOnPage) { 
    if (appReadTracking == 0 || cMemberInfo.memID == -1) {
        return (latestDateOnPage.getTime() - new Date(cMemberInfo.lastVisit).getTime() > 0);
    } else {
        return (latestDateOnPage.getTime() - pageLastGenerated.addDays(-cFeatureInfo.readTrackLength).getTime() > 0);
    }
}

function markNewThreadTitleAndArrow(tid) {
    $('a[id=msgSubjectLink_' + tid + ']').addClass("newpost");
    $('img[id=msgSubjectImg_' + tid + ']').attr('src', pageThemeImageURL + forumThemeInfo.forumIcons.threadNewestArrow).attr('title', ln.ttNewsetMsg);
    $('a[id=msgSubjectImgLink_' + tid + ']').attr('href',
        function () {
            var $lnk = $(this); // isblog is set in BlogPostTemplate.ascx
            return cPathInfo.ForumDir + 'FindPost/' + tid + '?go=newest' + ($lnk.data('isblog') ? '&toblog=true' : '');
        });
    $('img[id=postMsg_' + tid + ']').before('<span class="msgState newest">' + ln.ttIsNewTopic +'</span>');
}

function setThreadReadTrackImgSrc($img) {
    var icons = forumThemeInfo.forumIcons;
    
    if ($img.hasClass('newpost')) {
        $img.attr('src', pageThemeImageURL + icons.threadUnRead).attr('title', ln.newMessageDesc);
    }
    else {
        $img.attr('src', pageThemeImageURL + icons.threadRead).attr('title', ln.oldMessageDesc);
    }
}

function getCookieTrackDate(fOrT, forID) {
    
    var cookieDate = (fOrT == 'f' && hashFTrack[forID]) || (fOrT == 't' && hashTTrack[forID]);

    if (fOrT == 't' && typeof currentForumID != 'undefined') {
        var fTrackForCurrentForum = hashFTrack[currentForumID.toString()];
        if (cookieDate) {
            if (fTrackForCurrentForum) {
                if ((new Date(fTrackForCurrentForum).getTime() - new Date(cookieDate).getTime()) > 0) {
                    cookieDate = fTrackForCurrentForum;
                }
            }
        } else {
            cookieDate = fTrackForCurrentForum;
        }
        //consoleLog(cookieDate);
    }

    return new Date(cookieDate || cMemberInfo.lastVisit);
}

function trackReadSessionOnly(fOrT) {

    $('img.trackread' + fOrT + 'img').each(function () {
        var $thisImg = $(this);
        var theDate = new Date($thisImg.data('trackdate'));
        var forID = $thisImg.data('track' + fOrT + 'id');

        if (!forID) { // not trackable  - probably link forum
            displayNonTrackableForumImage($thisImg);
            return true;
        }

        var referenceDate = getCookieTrackDate(fOrT, forID);

        var boardMarkRead = hashFTrack['0'];
        if (boardMarkRead) {
            var boardMarkReadDate = new Date(boardMarkRead);
            if ((boardMarkReadDate.getTime() - referenceDate.getTime()) > 0) {
                referenceDate = boardMarkReadDate;
            }
        }

        //consoleLog(referenceDate);
        if (theDate.getTime() - referenceDate.getTime() > 0) { //new
            if (fOrT == 'f') { //forum
                $thisImg.attr('src', pageThemeImageURL + (!$thisImg.hasClass('arrow') ? forumThemeInfo.forumIcons.forumUnRead : forumThemeInfo.forumIcons.subforumUnRead));

            } else { //thread; need to check hits and replies too
                $thisImg.addClass('newpost');
                markNewThreadTitleAndArrow(forID);
            }

        } else {
            if (fOrT == 'f') { //forum
                if (!$thisImg.hasClass('arrow')) $thisImg.attr('src', pageThemeImageURL + forumThemeInfo.forumIcons.forumRead);
            } else { //thread; 
                //don't do anything
            }
        }

        if (fOrT == 't')
            setThreadReadTrackImgSrc($thisImg);

        return true;
    });

}

function displayNonTrackableForumImage($thisImg) {
    var forumtype = $thisImg.data('forumtype');
    if (forumtype == 2) {
        $thisImg.attr('src', pageThemeImageURL + (!$thisImg.hasClass('arrow') ? forumThemeInfo.forumIcons.forumLink : forumThemeInfo.forumIcons.subforumLink));
    }
}


function registerModeratorChecking(forumId) {
    //checkForApprovalRequiredPosts(forumId);
    checkForTickets();
}

function checkForTickets() {
    var checkedTimeKey = '_ticketChecked';
    var checkedCacheKey = '_ticketCached';

    var lastChecked = $.storage.get(checkedTimeKey);

    if (lastChecked == 'null' || lastChecked == null || new Date(lastChecked).addMins(2) < (new Date())) {

        JQCallWebService('ws/Ticket.aspx/CheckIsThereTicket', {},
            function (r) {
                $.storage.set(checkedTimeKey, new Date());
                $.storage.set(checkedCacheKey, r.d);
                if (r.d) {
                    createTicketNotice(checkedTimeKey, checkedCacheKey);
                }
                else {
                    removeTicketNotice();
                }
            });
    }

    var checkedCached = $.storage.get(checkedCacheKey);

    if (checkedCached) {
        createTicketNotice(checkedTimeKey, checkedCacheKey);
    }

/*    consoleLog('checkForTickets');
    consoleLog(lastChecked);
    consoleLog(checkedCached);*/
}

var _ticketDivClass = 'topTicketNotification';

function removeTicketNotice() {
    $('.' + _ticketDivClass).remove();
}

function createTicketNotice(checkedTimeKey, checkedCacheKey) {

    if ($('.' + _ticketDivClass)[0]) return;

    var $noticeDiv = $('<div />').addClass(_ticketDivClass);

    $noticeDiv.on('click', 'a', function () {
        var $lnk = $(this);

        $.storage.set(checkedCacheKey, false);

        if ($lnk.hasClass('remove') || $lnk.hasClass('nocheck')) {
            $('.' + _ticketDivClass).remove();

            if ($lnk.hasClass('nocheck')) {
                $.storage.set(checkedTimeKey, new Date().addDays(1));
            }
        }

        if ($lnk.hasClass('ok'))
            self.location.href = cPathInfo.ForumDir + 'ticket.aspx?filter=3';

        return false;
    });

    $noticeDiv.html(String.format(
            '<a href="#" class="right remove"><i class="icon-remove"></i></a>' +
            '<h3 class="margin5"><i class="icon-tags"></i> {2}</h3>' +
            '<div class="right">' +
            '<a href="#" class="gradient1 smalllinkbutton ok"> <i class="icon-ok-sign icon-large"></i> {0}</a>' +
            '<a href="#" class="gradient2 smalllinkbutton nocheck"> <i class="icon-remove-sign icon-large"></i> {1}</a>' +
            '</div>',
        ln.buttonSubmitValue, ln.ttAwaitingApprovalCheckInADay, ln.ttHasTicketWaiting));

    $noticeDiv.insertAfter('#TN');
}


function checkForApprovalRequiredPosts(forumId) {
   var checkedTimeKey = forumId.toString() + '_approvalChecked';
   var checkedCacheKey = forumId.toString() + '_approvalCached';

   var lastChecked = $.storage.get(checkedTimeKey);

   if (lastChecked == 'null' || lastChecked == null || new Date(lastChecked).addMins(2) < (new Date())) {

       JQCallWebService('ws/Management.aspx/CheckIsThereApprovalRequired', { forumID: forumId },
           function (r) {
               $.storage.set(checkedTimeKey, new Date());
               $.storage.set(checkedCacheKey, r.d);
               if (r.d) {
                   createApprovalRequiredNotice(forumId, checkedTimeKey, checkedCacheKey);
               } else {
                   removeApprovalRequiredNotice();
               }
           });
   }

   var checkedCached = $.storage.get(checkedCacheKey);

   if (checkedCached) {
       createApprovalRequiredNotice(forumId, checkedTimeKey, checkedCacheKey);
   }

/*    consoleLog('checkForApprovalRequiredPosts');
   consoleLog(lastChecked);
   consoleLog(checkedCached);*/
}

var _approvalDivClass = 'topPostApprovalNotification';

function removeApprovalRequiredNotice() {
    $('.' + _approvalDivClass).remove();
}

function createApprovalRequiredNotice(forumId, checkedTimeKey, checkedCacheKey) {

    if ($('.' + _approvalDivClass)[0]) return;

    var $noticeDiv = $('<div />').addClass(_approvalDivClass);

    $noticeDiv.on('click', 'a', function () {
        var $lnk = $(this);

        $.storage.set(checkedCacheKey, false);

        if ($lnk.hasClass('remove') || $lnk.hasClass('nocheck')) {
            $('.' + _approvalDivClass).remove();

            if ($lnk.hasClass('nocheck')) {
                $.storage.set(checkedTimeKey, new Date().addDays(1));
            }
        }

        if ($lnk.hasClass('ok'))
            self.location.href = cPathInfo.ForumDir + 'Approve' + (forumId == 0 ? '' : '?forumid=' + forumId.toString());

        return false;
    });

    $noticeDiv.html(String.format(
            '<a href="#" class="right remove"><i class="icon-remove"></i></a>' +
            '<h3 class="margin5"><i class="icon-exclamation-sign"></i> {2}</h3>' +
            '<div class="right">' +
            '<a href="#" class="gradient1 smalllinkbutton ok"> <i class="icon-ok-sign icon-large"></i> {0}</a>' +
            '<a href="#" class="gradient2 smalllinkbutton nocheck"> <i class="icon-remove-sign icon-large"></i> {1}</a>' +
            '</div>',
        ln.buttonSubmitValue, ln.ttAwaitingApprovalCheckInADay, ln.ttHasAwaitingApproval));

    $noticeDiv.insertAfter('#TN');
}


function ProduceSearchPhraseFromString(str, top, useAnd) {
    var cleanedTitle = str.trim().replace(/[^\w\s\.\-]/gi, '');
    var arrToRemove = cleanedTitle.split(' ');

    arrToRemove.sort(function (a, b) { return (b.length - a.length); });

    if (!top) top = 4;

    var arrLongestWords = new Array();

    for (var j = 0; j < arrToRemove.length; j++) {
        if (arrLongestWords.indexOf(arrToRemove[j]) == -1) {
            arrLongestWords.push(arrToRemove[j]);

            if (arrLongestWords.length == (arrToRemove.length < top ? arrToRemove.length : top))
                break;
        }
    }

    var arrFresh = cleanedTitle.split(' ');
    var arrFinal = new Array();

    for (var i = 0; i < arrFresh.length; i++) {
        var currentWord = arrFresh[i];
        if (arrLongestWords.indexOf(currentWord) != -1 && arrFinal.indexOf(currentWord) == -1) {
            if (currentWord.match(/[^\w]/gi)) currentWord = '"' + currentWord + '"';
            arrFinal.push(currentWord);
        }

    }

    return arrFinal.join((useAnd ? ' ' : ' OR ')).trim();
}

function getSearchTermSuggestionFromWiki(phrase, onComplete) {
    $.ajax(
        { url: "http://en.wikipedia.org/w/api.php",
            dataType: "jsonp",
            data: { action: "opensearch",
                search: phrase,
                format: "json"
            },
            success: function (data, textStatus, xhr) {
                onComplete(data[1]);
//                $("#results").empty();
//                $.each(data[1], function (_, result) {
//                    $("#results").append("<li>" + result + "</li>");
//                });
            },
            error: function (xhr, textStatus, errorThrown) {
                onComplete(errorThrown);
            }
        }); 
    
}
var _searchSuggest = '';

function getSearchTermSuggestion(phrase, onComplete) {
    if (_searchSuggest!= phrase.trim()){
        JQCallWebService("ws/Search.aspx/SearchSuggestion",
                { searchPhrase: phrase },
                function (rtn) {
                    var returnedData = rtn.d;
                    _searchSuggest = phrase;
                    onComplete(returnedData);
                });
        }
}

function initiateRelatedTopicSearch(phrase, forumSpec, onComplete, topN) {
    JQCallWebService("ws/Search.aspx/SearchRelatedTopics",
        {
            sRequest: {
                Phrase: phrase.trim(),
                ForumIDs: forumSpec,
                TopNResults: topN,
                Precision: ['Normal']
            }
        },
        onComplete,
        JQOnCallError);
}

function initiateSearchSimilarThreads(phrase, forumSpec, onComplete, topN, searchPrecision) {

    if (typeof searchPrecision == 'undefined') searchPrecision = ['Exact'];
    
    JQCallWebService("ws/Search.aspx/SearchSimilarThreads",
        {
            sRequest: {
                Phrase: phrase.trim(),
                ForumIDs: forumSpec,
                TopNResults: (!topN ? 30 : topN),
                Precision: searchPrecision
            }            
        },
        onComplete,
        JQOnCallError);

}

function initiateSearchRegular(phrase, forumIDs, threadID, topN, phraseIn, resultAs,
                                searchPrecision, onComplete) {
        
    // resultAs: TopicsOnly RepliesOnly Both Combined
    // searchPrecision: Fuzzy Normal Exact ExactOnly
        
    if (typeof topN == 'undefined') topN = 300;
    if (typeof resultAs == 'undefined') resultAs = 'Combined';
    if (typeof searchPrecision == 'undefined') searchPrecision = 'Exact';

    JQCallWebService("ws/Search.aspx/BeginSearch",
        {
            sRequest: {
                Phrase: phrase,
                ForumIDs: forumIDs,
                ThreadID: threadID,
                TopNResults: topN,
                ListResultAs: resultAs,
                Precision: searchPrecision,
                PhraseFoundIn: phraseIn
            }
        },
        onComplete,
        JQOnCallError);

}

function searchCheckIfComplete(aid, initialSearchTime, onComplete) {

    var data = { theAID: aid, beginTime: initialSearchTime };

    JQCallWebService("ws/Search.aspx/CheckIfStepOneCompleted", data, onComplete, JQOnCallError);
}


function beginRetrieveingSimpleSearchResults(searchID, onBeforeRetrieving, onFinishRetrieving) {
    onBeforeRetrieving();

    var data = { searchID: searchID, top : -1 };

    JQCallWebService("ws/Search.aspx/RetrieveSimpleSearchResults", data, onFinishRetrieving, JQOnCallError);

}

