/*! * jQuery JavaScript Library v1.6.2 * http://jquery.com/ * * Copyright 2011, John Resig * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * Includes Sizzle.js * http://sizzlejs.com/ * Copyright 2011, The Dojo Foundation * Released under the MIT, BSD, and GPL Licenses. * * Date: Thu Jun 30 14:16:56 2011 -0400 */ (function(a,b){function cv(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cs(a){if(!cg[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ch||(ch=c.createElement("iframe"),ch.frameBorder=ch.width=ch.height=0),b.appendChild(ch);if(!ci||!ch.createElement)ci=(ch.contentWindow||ch.contentDocument).document,ci.write((c.compatMode==="CSS1Compat"?"":"")+""),ci.close();d=ci.createElement(a),ci.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ch)}cg[a]=e}return cg[a]}function cr(a,b){var c={};f.each(cm.concat.apply([],cm.slice(0,b)),function(){c[this]=a});return c}function cq(){cn=b}function cp(){setTimeout(cq,0);return cn=f.now()}function cf(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ce(){try{return new a.XMLHttpRequest}catch(b){}}function b$(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){c!=="border"&&f.each(e,function(){c||(d-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?d+=parseFloat(f.css(a,c+this))||0:d-=parseFloat(f.css(a,"border"+this+"Width"))||0});return d+"px"}d=bx(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0,c&&f.each(e,function(){d+=parseFloat(f.css(a,"padding"+this))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+this+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+this))||0)});return d+"px"}function bm(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(be,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bl(a){f.nodeName(a,"input")?bk(a):"getElementsByTagName"in a&&f.grep(a.getElementsByTagName("input"),bk)}function bk(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bj(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function bi(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bh(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c=f.expando,d=f.data(a),e=f.data(b,d);if(d=d[c]){var g=d.events;e=e[c]=f.extend({},d);if(g){delete e.handle,e.events={};for(var h in g)for(var i=0,j=g[h].length;i=0===c})}function V(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function N(a,b){return(a&&a!=="*"?a+".":"")+b.replace(z,"`").replace(A,"&")}function M(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;ic)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function K(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefault()}function E(){return!0}function D(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(j,"$1-$2").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(g){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function J(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(J,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=/-([a-z])/ig,x=function(a,b){return b.toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6.2",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!A){A=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1;var c;for(c in a);return c===b||D.call(a,c)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(b,c,d){a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b)),d=c.documentElement,(!d||!d.nodeName||d.nodeName==="parsererror")&&e.error("Invalid XML: "+b);return c},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;c
a",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=a.getElementsByTagName("input")[0],k={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55$/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,k.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,k.optDisabled=!h.disabled;try{delete a.test}catch(v){k.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function(){k.noCloneEvent=!1}),a.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),k.radioValue=i.value==="t",i.setAttribute("checked","checked"),a.appendChild(i),l=c.createDocumentFragment(),l.appendChild(a.firstChild),k.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",m=c.getElementsByTagName("body")[0],o=c.createElement(m?"div":"body"),p={visibility:"hidden",width:0,height:0,border:0,margin:0},m&&f.extend(p,{position:"absolute",left:-1e3,top:-1e3});for(t in p)o.style[t]=p[t];o.appendChild(a),n=m||b,n.insertBefore(o,n.firstChild),k.appendChecked=i.checked,k.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,k.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="
",k.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="
t
",q=a.getElementsByTagName("td"),u=q[0].offsetHeight===0,q[0].style.display="",q[1].style.display="none",k.reliableHiddenOffsets=u&&q[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",a.appendChild(j),k.reliableMarginRight=(parseInt((c.defaultView.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0),o.innerHTML="",n.removeChild(o);if(a.attachEvent)for(t in{submit:1,change:1,focusin:1})s="on"+t,u=s in a,u||(a.setAttribute(s,"return;"),u=typeof a[s]=="function"),k[t+"Bubbles"]=u;o=l=g=h=m=j=a=i=null;return k}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([a-z])([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g=f.expando,h=typeof c=="string",i,j=a.nodeType,k=j?f.cache:a,l=j?a[f.expando]:a[f.expando]&&f.expando;if((!l||e&&l&&!k[l][g])&&h&&d===b)return;l||(j?a[f.expando]=l=++f.uuid:l=f.expando),k[l]||(k[l]={},j||(k[l].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?k[l][g]=f.extend(k[l][g],c):k[l]=f.extend(k[l],c);i=k[l],e&&(i[g]||(i[g]={}),i=i[g]),d!==b&&(i[f.camelCase(c)]=d);if(c==="events"&&!i[c])return i[g]&&i[g].events;return h?i[f.camelCase(c)]||i[c]:i}},removeData:function(b,c,d){if(!!f.acceptData(b)){var e=f.expando,g=b.nodeType,h=g?f.cache:b,i=g?b[f.expando]:f.expando;if(!h[i])return;if(c){var j=d?h[i][e]:h[i];if(j){delete j[c];if(!l(j))return}}if(d){delete h[i][e];if(!l(h[i]))return}var k=h[i][e];f.support.deleteExpando||h!=a?delete h[i]:h[i]=null,k?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=k):g&&(f.support.deleteExpando?delete b[f.expando]:b.removeAttribute?b.removeAttribute(f.expando):b[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;d=e.value;return typeof d=="string"?d.replace(p,""):d==null?"":d}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c=a.selectedIndex,d=[],e=a.options,g=a.type==="select-one";if(c<0)return null;for(var h=g?c:0,i=g?c+1:e.length;h=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);if(!("getAttribute"in a))return f.prop(a,c,d);var h,i,j=g!==1||!f.isXMLDoc(a);j&&(c=f.attrFix[c]||c,i=f.attrHooks[c],i||(t.test(c)?i=w:v&&c!=="className"&&(f.nodeName(a,"form")||u.test(c))&&(i=v)));if(d!==b){if(d===null){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j&&(h=i.get(a,c))!==null)return h;h=a.getAttribute(c);return h===null?b:h},removeAttr:function(a,b){var c;a.nodeType===1&&(b=f.attrFix[b]||b,f.support.getSetAttribute?a.removeAttribute(b):(f.attr(a,b,""),a.removeAttributeNode(a.getAttributeNode(b))),t.test(b)&&(c=f.propFix[b]||b)in a&&(a[c]=!1))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},tabIndex:{get:function(a){var c=a.getAttributeNode("tabIndex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}},value:{get:function(a,b){if(v&&f.nodeName(a,"button"))return v.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(v&&f.nodeName(a,"button"))return v.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e=a.nodeType;if(!a||e===3||e===8||e===2)return b;var g,h,i=e!==1||!f.isXMLDoc(a);i&&(c=f.propFix[c]||c,h=f.propHooks[c]);return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==b?g:a[c]},propHooks:{}}),w={get:function(a,c){return f.prop(a,c)?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},f.support.getSetAttribute||(f.attrFix=f.propFix,v=f.attrHooks.name=f.attrHooks.title=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&d.nodeValue!==""?d.nodeValue:b},set:function(a,b,c){var d=a.getAttributeNode(c);if(d){d.nodeValue=b;return b}}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var x=/\.(.*)$/,y=/^(?:textarea|input|select)$/i,z=/\./g,A=/ /g,B=/[^\w\s.|`]/g,C=function(a){return a.replace(B,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){if(d===!1)d=D;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=D);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),C).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;j=0&&(h=h.slice(0,-1),j=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i. shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d!=null?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h-1?f.map(a.options,function(a){return a.selected}).join("-"):"":f.nodeName(a,"select")&&(c=a.selectedIndex);return c},J=function(c){var d=c.target,e,g;if(!!y.test(d.nodeName)&&!d.readOnly){e=f._data(d,"_change_data"),g=I(d),(c.type!=="focusout"||d.type!=="radio")&&f._data(d,"_change_data",g);if(e===b||g===e)return;if(e!=null||g)c.type="change",c.liveFired=b,f.event.trigger(c,arguments[1],d)}};f.event.special.change={filters:{focusout:J,beforedeactivate:J,click:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(c==="radio"||c==="checkbox"||f.nodeName(b,"select"))&&J.call(this,a)},keydown:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(a.keyCode===13&&!f.nodeName(b,"textarea")||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&J.call(this,a)},beforeactivate:function(a){var b=a.target;f._data(b,"_change_data",I(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in H)f.event.add(this,c+".specialChange",H[c]);return y.test(this.nodeName)},teardown:function(a){f.event.remove(this,".specialChange");return y.test(this.nodeName)}},H=f.event.special.change.filters,H.focus=H.beforeactivate}f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){function e(a){var c=f.event.fix(a);c.type=b,c.originalEvent={},f.event.trigger(c,null,c.target),c.isDefaultPrevented()&&a.preventDefault()}var d=0;f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.each(["bind","one"],function(a,c){f.fn[c]=function(a,d,e){var g;if(typeof a=="object"){for(var h in a)this[c](h,d,a[h],e);return this}if(arguments.length===2||d===!1)e=d,d=b;c==="one"?(g=function(a){f(this).unbind(a,g);return e.apply(this,arguments)},g.guid=e.guid||f.guid++):g=e;if(a==="unload"&&c!=="one")this.one(a,d,e);else for(var i=0,j=this.length;i0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d=0,e=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,f,g){f=f||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return f;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(e.call(n)==="[object Array]")if(!u)f.push.apply(f,n);else if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&f.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&f.push(j[t]);else p(n,f);o&&(k(o,h,f,g),k.uniqueSort(f));return f};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=d++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(e.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var f=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g0)for(h=g;h0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(d=0,e=a.length;d-1:f(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=T.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a||typeof a=="string")return f.inArray(this[0],a?f(a):this.parent().children());return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(V(c[0])||V(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=S.call(arguments);O.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!U[a]?f.unique(e):e,(this.length>1||Q.test(d))&&P.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var X=/ jQuery\d+="(?:\d+|null)"/g,Y=/^\s+/,Z=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,$=/<([\w:]+)/,_=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]};bf.optgroup=bf.option,bf.tbody=bf.tfoot=bf.colgroup=bf.caption=bf.thead,bf.th=bf.td,f.support.htmlSerialize||(bf._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(X,""):null;if(typeof a=="string"&&!bb.test(a)&&(f.support.leadingWhitespace||!Y.test(a))&&!bf[($.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Z,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j )}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bi(a,d),e=bj(a),g=bj(d);for(h=0;e[h];++h)bi(e[h],g[h])}if(b){bh(a,d);if(c){e=bj(a),g=bj(d);for(h=0;e[h];++h)bh(e[h],g[h])}}e=g=null;return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!ba.test(k))k=b.createTextNode(k);else{k=k.replace(Z,"<$1>");var l=($.exec(k)||["",""])[1].toLowerCase(),m=bf[l]||bf._default,n=m[0],o=b.createElement("div");o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=_.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&Y.test(k)&&o.insertBefore(b.createTextNode(Y.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bo.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle;c.zoom=1;var e=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.filter=bn.test(g)?g.replace(bn,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bx(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(by=function(a,c){var d,e,g;c=c.replace(bp,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bz=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bq.test(d)&&br.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bx=by||bz,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bB=/%20/g,bC=/\[\]$/,bD=/\r?\n/g,bE=/#.*$/,bF=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bG=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bH=/^(?:about|app|app\-storage|.+\-extension|file|widget):$/,bI=/^(?:GET|HEAD)$/,bJ=/^\/\//,bK=/\?/,bL=/)<[^<]*)*<\/script>/gi,bM=/^(?:select|textarea)/i,bN=/\s+/,bO=/([?&])_=[^&]*/,bP=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bQ=f.fn.load,bR={},bS={},bT,bU;try{bT=e.href}catch(bV){bT=c.createElement("a"),bT.href="",bT=bT.href}bU=bP.exec(bT.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bQ)return bQ.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bL,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bM.test(this.nodeName)||bG.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bD,"\r\n")}}):{name:b.name,value:c.replace(bD,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?f.extend(!0,a,f.ajaxSettings,b):(b=a,a=f.extend(!0,f.ajaxSettings,b));for(var c in{context:1,url:1})c in b?a[c]=b[c]:c in f.ajaxSettings&&(a[c]=f.ajaxSettings[c]);return a},ajaxSettings:{url:bT,isLocal:bH.test(bU[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML}},ajaxPrefilter:bW(bR),ajaxTransport:bW(bS),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a?4:0;var o,r,u,w=l?bZ(d,v,l):b,x,y;if(a>=200&&a<300||a===304){if(d.ifModified){if(x=v.getResponseHeader("Last-Modified"))f.lastModified[k]=x;if(y=v.getResponseHeader("Etag"))f.etag[k]=y}if(a===304)c="notmodified",o=!0;else try{r=b$(d,w),c="success",o=!0}catch(z){c="parsererror",u=z}}else{u=c;if(!c||a)c="error",a<0&&(a=0)}v.status=a,v.statusText=c,o?h.resolveWith(e,[r,c,v]):h.rejectWith(e,[v,c,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.resolveWith(e,[v,c]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f._Deferred(),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bF.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.done,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bE,"").replace(bJ,bU[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bN),d.crossDomain==null&&(r=bP.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bU[1]&&r[2]==bU[2]&&(r[3]||(r[1]==="http:"?80:443))==(bU[3]||(bU[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bX(bR,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bI.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bK.test(d.url)?"&":"?")+d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bO,"$1_="+x);d.url=y+(y===d.url?(bK.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", */*; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bX(bS,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){status<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)bY(g,a[g],c,e);return d.join("&").replace(bB,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var b_=f.now(),ca=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+b_++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ca.test(b.url)||e&&ca.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ca,l),b.url===j&&(e&&(k=k.replace(ca,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cb=a.ActiveXObject?function(){for(var a in cd)cd[a](0,1)}:!1,cc=0,cd;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ce()||cf()}:ce,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cb&&delete cd[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cc,cb&&(cd||(cd={},f(a).unload(cb)),cd[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cg={},ch,ci,cj=/^(?:toggle|show|hide)$/,ck=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cl,cm=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cn,co=a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cr("show",3),a,b,c);for(var g=0,h=this.length;g=e.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),e.animatedProperties[this.prop]=!0;for(g in e.animatedProperties)e.animatedProperties[g]!==!0&&(c=!1);if(c){e.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=e.overflow[a]}),e.hide&&f(d).hide();if(e.hide||e.show)for(var i in e.animatedProperties)f.style(d,i,e.orig[i]);e.complete.call(d)}return!1}e.duration==Infinity?this.now=b:(h=b-this.startTime,this.state=h/e.duration,this.pos=f.easing[e.animatedProperties[this.prop]](this.state,h,0,1,e.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){for(var a=f.timers,b=0;b
";f.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),d=b.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,this.doesNotAddBorder=e.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,e.style.position="fixed",e.style.top="20px",this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),f.offset.initialize=f.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.offset.initialize(),f.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cu.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cu.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cv(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cv(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a&&a.style?parseFloat(f.css(a,d,"padding")):null},f.fn["outer"+c]=function(a){var b=this[0];return b&&b.style?parseFloat(f.css(b,d,a?"margin":"border")):null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c];return e.document.compatMode==="CSS1Compat"&&g||e.document.body["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var h=f.css(e,d),i=parseFloat(h);return f.isNaN(i)?h:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f})(window); jQuery.noConflict(); jQuery.ajaxSetup({ cache: false }); jQuery.fn.ljAddContextualPopup = function(){ if(!window.ContextualPopup) return this; return this.each(function(){ ContextualPopup.searchAndAdd(this); }); }; jQuery.fn.hourglass = function(xhr){ var hourglasses = []; this.each(function(){ // is complete or was aborted if(xhr && (xhr.readyState == 0 || xhr.readyState == 4)) return; if(this.nodeType){ // node } else { // position from event var e = jQuery.event.fix(this), hourglass = new Hourglass(), offset = {}; // from keyboard if(!e.clientX || !e.clientY){ offset = jQuery(e.target).offset(); } hourglass.init(); hourglass.hourglass_at(offset.left || e.pageX, offset.top || e.pageY); } hourglasses.push(hourglass); if(xhr){ jQuery(hourglass.ele).bind('ajaxComplete', function(event, request){ if(request == xhr){ hourglass.hide(); jQuery(hourglass.ele).unbind('ajaxComplete', arguments.callee); } }); } }); return hourglasses; }; // not work for password jQuery.fn.placeholder = (function() { var check_focus = function() { if (this.value === this.getAttribute("placeholder")) { jQuery(this) .val("") .removeClass("placeholder"); } }, check_blur = function() { if (!this.value) { jQuery(this) .val(this.getAttribute("placeholder")) .addClass("placeholder"); } }, support; return function() { if (support === undefined) { support = "placeholder" in document.createElement("input"); } if (support === true) { return this; } else { return this.each(function() { if (this.getAttribute("placeholder")) { var $this = jQuery(this); if (!$this.data('jQuery-has-placeholder')) { $this.focus(check_focus).blur(check_blur); jQuery(this.form) .submit(function() { $this.hasClass("placeholder") && $this.removeClass("placeholder").val(""); }); } this.value === this.getAttribute("placeholder") || !this.value ? $this.val(this.getAttribute("placeholder")).addClass("placeholder") : $this.removeClass("placeholder"); $this.data('jQuery-has-placeholder', true) } }); } } })(); //this one is fields type agnostic but creates additional label elements, which need to be styled jQuery.fn.labeledPlaceholder = function(){ function focus_action(input, label){ label.hide(); } function blur_action(input, label){ if(input.val().length === 0 && input.is(':visible')){ label.show(); } } return this.each(function(){ if('placeholder' in document.createElement('input') && this.tagName.toLowerCase() === "input"){ return; } if('placeholder' in document.createElement('textarea') && this.tagName.toLowerCase() === "textarea"){ return; } var $this = jQuery(this), placeholder = $this.attr('placeholder'); $this.wrap(''); if(!placeholder || placeholder.length === 0){ return; } var label = jQuery("").addClass('placeholder-label').mousedown(function(ev){ setTimeout(function(){ focus_action($this, label); $this.focus(); }, 0); }).html(placeholder).insertBefore($this); $this.focus(function(){ focus_action($this, label) }).blur(function(){ blur_action($this, label) }); blur_action($this, label); }); }; jQuery.fn.input = function(fn){ return fn ? this.each(function(){ var last_value = this.value; jQuery(this).bind("input keyup paste", function(e){ // e.originalEvent use from trigger if(!e.originalEvent || this.value !== last_value){ last_value = this.value; fn.apply(this, arguments); } }) }) : this.trigger("input"); }; // ctrl+enter send form jQuery.fn.disableEnterSubmit = function() { this.bind("keypress", function(e) { // keyCode == 10 in IE with ctrlKey if ((e.which === 13 || e.which === 10) && e.target && e.target.form) { if (e.ctrlKey && !jQuery(":submit", e.target.form).attr("disabled") && (e.target.tagName === "TEXTAREA" || e.target.tagName === "INPUT") ) { e.target.form.submit(); } if (e.target.tagName === "INPUT") { e.preventDefault(); } } }); return this; }; /* function based on markup: tab links: ul>li>a current tab: ul>li.current tab container: ul>li tab container current: ul>li.current */ jQuery.fn.tabsChanger = function(container){ var links = this.children("li").children("a"); if(container){ container = jQuery(container); } else { // next sibling of links container = links.parent().parent().next(); } links.click(function(e){ var item = jQuery(this).parent(), index = item.index(), containers = container.children("li"); if(containers[index]){ links.parent().removeClass("current"); item.addClass("current"); containers.removeClass("current").eq(index).addClass("current"); e.preventDefault(); } }); return this; }; /** jQuery overlay plugin * After creation overlay visibility can be toggled with * $( '#selector' ).overlay( 'show' ) and $( '#selector' ).overlay( 'hide' ) */ jQuery.fn.overlay = function(opts){ var options = { hideOnInit: true, hideOnClick: true }; function Overlay(layer, options){ this.layer = jQuery(layer); this.options = options; this.updateState(this.options.hideOnInit); this.bindEvents(); } Overlay.prototype.bindEvents = function(){ var overlay = this; if(this.options.hideOnClick){ overlay.layer.mousedown(function(ev){ ev.stopPropagation(); }); jQuery(document).mousedown(function(ev){ overlay.updateState(true); ev.stopPropagation(); }); } }; Overlay.prototype.updateState = function(hide){ this.layerVisible = !hide; if(this.layerVisible){ this.layer.show(); } else { this.layer.hide(); } }; Overlay.prototype.proccessCommand = function (cmd){ switch(cmd){ case 'show' : this.updateState(false); break; case 'hide' : this.updateState(true); break; } }; var cmd; if(typeof opts === "string"){ cmd = opts; } return this.each(function(){ if(!this.overlay){ var o = jQuery.extend({}, options, opts || {}); this.overlay = new Overlay(this, o); } if(cmd.length > 0){ this.overlay.proccessCommand(opts) } }); }; /** * Function assures that callback will run not faster then minDelay. * * @param {Function} callback A callback to run. * @param {Number} minDelay Minimum delay in ms. * * @return {Function} Callback wrapper to use as a collback in your code. */ jQuery.delayedCallback = function(callback, minDelay) { var callCount = 2, results, checkFinish = function() { callCount--; if (callCount === 0) { callback.apply(null, results); } } setTimeout(checkFinish, minDelay); return function() { results = [].slice.apply(arguments); checkFinish(); }; }; document.documentElement.id = 'js'; /* Cookie plugin. Copyright (c) 2006 Klaus Hartl (stilbuero.de) */ function Cookie(name, value, options) { if (value !== undefined) { // name and value given, set/delete cookie options = options || {}; if (value === null) { value = ''; options.expires = -1; } var expires = ''; if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { var date; if (typeof options.expires == 'number') { date = new Date; date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); } else { date = options.expires; } expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE } // CAUTION: Needed to parenthesize options.path and options.domain // in the following expressions, otherwise they evaluate to undefined // in the packed version for some reason... var path = options.path ? '; path=' + (options.path) : '', domain = options.domain ? '; domain=' + (options.domain) : '', secure = options.secure ? '; secure' : ''; document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); } else { // only name given, get cookie var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i].trim(); // Does this cookie string begin with the name we want? if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } } //core.js /** * Utility method. * @param x any Any JavaScript value, including undefined. * @return boolean true if the value is not null and is not undefined. */ finite = function(x){ return isFinite(x) ? x : 0; }; finiteInt = function(x, base){ return finite(parseInt(x, base)); }; finiteFloat = function(x){ return finite(parseFloat(x)); }; /* unique id generator */ Unique = { length: 0, id: function(){ return ++this.length; } }; /* event methods */ var Event = Event||{}; Event.stop = function(e){ // this set in Event.prep e = e || window.event || this; Event.stopPropagation(e); Event.preventDefault(e); return false; }; Event.stopPropagation = function(e){ if(e && e.stopPropagation) e.stopPropagation(); else window.event.cancelBubble = true; }; Event.preventDefault = function(e){ e = e || window.event; if(e.preventDefault) e.preventDefault(); e.returnValue = false; }; Event.prep = function(e){ e = e || window.event; if(e.stop === undefined) e.stop = this.stop; if(e.target === undefined) e.target = e.srcElement; if(e.relatedTarget === undefined) e.relatedTarget = e.toElement; return e; }; /* object extensions */ if (!Object.extend) Object.extend = function (d, s){ if(d) for(var p in s) if(!d[p]) d[p] = s[p]; return d }; if (!Object.override) Object.override = function (d, s){ if(d) for(var p in s) d[p] = s[p]; return d }; /* function extensions */ /** * Returns an array of all own enumerable properties found upon a given object, * in the same order as that provided by a for-in loop. * * @param {Object} The object whose enumerable own properties are to be returned. * * @return {Array} Array with properties names. */ Object.extend(Object, { keys: function(o) { if (o !== Object(o)) { throw new TypeError('Object.keys called on non-object'); } var ret=[],p; for(p in o) if(Object.prototype.hasOwnProperty.call(o,p)) ret.push(p); return ret; } }); Object.extend(Function.prototype, { bind: function(that) { // .length is 1 var target = this, slice = [].slice; if (typeof target.apply != "function" || typeof target.call != "function") return new TypeError(); var args = slice.call(arguments, 1); // for normal call var bound = function () { if (this instanceof bound) { var self = Object.create(target.prototype); var result = target.apply( self, args.concat(slice.call(arguments)) ); if (result !== null && Object(result) === result) return result; return self; } else { return target.apply( that, args.concat(slice.call(arguments)) ); } } return bound; }, bindEventListener: function(object) { var method = this; // Use double closure to work around IE 6 memory leak. return function(e) { e = Event.prep(e); return method.call(object, e); }; } }); Object.extend(Function, { defer: function(func, args/*, more than one*/) { var args = [].slice.call(arguments, 1); setTimeout(function() { func.apply(null, args); }, 0); } }); /* class helpers */ indirectObjects = []; Class = function(superClass){ // Set the constructor: var constructor = function(){ if(arguments.length) this.init.apply(this, arguments); }; // -- Accomplish static-inheritance: Object.override(constructor, Class); // inherit static methods from Class superClass = superClass || function(){ }; superClassFunc = function(){ } Object.extend(superClassFunc.prototype, superClass.prototype) Object.extend(superClassFunc.prototype, { init: function(){ }, destroy: function(){ } }) Object.override(constructor, superClass); // inherit static methods from the superClass constructor.superClass = superClassFunc.prototype; // Set the constructor's prototype (accomplish object-inheritance): constructor.prototype = new superClass(); constructor.prototype.constructor = constructor; // rev. 0.7 // -- extend prototype with Class instance methods Object.extend(constructor.prototype, Class.prototype); // -- override prototype with interface methods for(var i = 1; i < arguments.length; i++) Object.override(constructor.prototype, arguments[i]); return constructor; }; Class.prototype = { destroy: function(){ try{ if(this.indirectIndex) indirectObjects[ this.indirectIndex ] = undefined; delete this.indirectIndex; } catch(e){ } for(var property in this){ try{ delete this[ property ]; } catch(e){ } } } }; /* string extensions */ Object.extend(String, { escapeJSChar: function( c ) { // try simple escaping switch( c ) { case "\\": return "\\\\"; case "\"": return "\\\""; case "'": return "\\'"; case "\b": return "\\b"; case "\f": return "\\f"; case "\n": return "\\n"; case "\r": return "\\r"; case "\t": return "\\t"; } // return raw bytes now ... should be UTF-8 if( c >= " " ) return c; // try \uXXXX escaping, but shouldn't make it for case 1, 2 c = c.charCodeAt( 0 ).toString( 16 ); switch( c.length ) { case 1: return "\\u000" + c; case 2: return "\\u00" + c; case 3: return "\\u0" + c; case 4: return "\\u" + c; } // should never make it here return ""; }, encodeEntity: function( c ) { switch( c ) { case "<": return "<"; case ">": return ">"; case "&": return "&"; case '"': return """; case "'": return "'"; } return c; }, decodeEntity: function( c ) { switch( c ) { case "amp": return "&"; case "quot": return '"'; case "apos": return "'"; case "gt": return ">"; case "lt": return "<"; } var m = c.match( /^#(\d+)$/ ); if( m && defined( m[ 1 ] ) ) return String.fromCharCode( m[ 1 ] ); m = c.match( /^#x([0-9a-f]+)$/i ); if( m && defined( m[ 1 ] ) ) return String.fromCharCode( parseInt( hex, m[ 1 ] ) ); return c; } }); Object.extend(String.prototype, { escapeJS: function() { return this.replace( /([^ -!#-\[\]-~])/g, function( m, c ) { return String.escapeJSChar( c ); } ) }, /** * Encode a string to allow a secure insertion in html code. */ encodeHTML: function() { return this.replace( /([<>&"])/g, function( m, c ) { return String.encodeEntity( c ) } ); /* fix syntax highlight: " */ }, decodeHTML: function() { return this.replace( /&(.*?);/g, function( m, c ) { return String.decodeEntity( c ) } ); }, /** * Add chars in front of string until it gets the length required. * * @param {Number} length Required string length. * @param {String} padChar A char to add in front of string. * * @return {String} A padded string. */ pad: function(length, padChar) { return ((new Array(length + 1)) .join(padChar) + this ).slice(-length); }, trim: function() { return this.replace(/^\s+|\s+$/g, ''); }, supplant: function(o) { return this.replace(/{([^{}]*)}/g, function (a, b) { var r = o[b]; return typeof r === 'string' || typeof r === 'number' ? r : a; }); } }); Object.extend(Date, { /** * Return timestamp number for current moment. * * @return {Number} A Timestamp. */ now: function() { return +new Date; } }); Object.extend(Array, { /** * Returns true if an object is an array, false if it is not. * * @param {Object} Argument to test. * * @return {Boolean} Test result. */ isArray: function(arg) { return Object.prototype.toString.call(arg) == '[object Array]'; } }); /* extend array object */ Object.extend(Array.prototype, { /** * Check if index fits in current array size and fix it otherwise. * * @param {Number} fromIndex Index to check. * @param {Number} defaultIndex This value will be taken if fromIndex is not defined. * * @return {Number} Fixed index value. */ fitIndex: function(fromIndex, defaultIndex) { if (fromIndex !== undefined || fromIndex == null) { fromIndex = defaultIndex; } else if (fromIndex < 0) { fromIndex = this.length + fromIndex; if (fromIndex < 0) { fromIndex = 0; } } else if (fromIndex >= this.length) { fromIndex = this.length - 1; } return fromIndex; }, /** * The function takes its arguments and add the ones that are not already inside to the end. * * @return {Number} New length of the array. */ add: function(/* a1, a2, ... */) { for (var j, a = arguments, i = 0; i < a.length; i++ ) { j = this.indexOf(a[i]); if (j < 0) { this.push(arguments[i]); } } return this.length; }, /* * The function takes its arguments and removes them from the array, if they are inside * * @return {Number} New length of the array. */ remove: function(/* a1, a2, ... */) { for (var j, a = arguments, i = 0; i < a.length; i++ ) { j = this.indexOf(a[i]); if (j >= 0) { this.splice(j, 1); } } return this.length; }, /* javascript 1.5 array methods */ /* http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array#Methods */ /** * Creates a new array with all elements that pass the test implemented by the provided function. * * @param {Function} fun Function to test each element of the array. * @param {Function} thisp Object to use as this when executing callback. * * @param {Array} Filtered array. */ filter: function(fun/*, thisp*/) { var thisp = arguments[1] || null; if (typeof fun !== "function") { throw new TypeError("First argument is not callable"); } for (var i = 0, len = this.length >>> 0, res = []; i < len; i++) { if (i in this) { var val = this[i]; // in case fun mutates this if (fun.call(thisp, val, i, this)) res.push(val); } } return res; }, /** * Executes a provided function once per array element. * * @param {Function} fun Function to test each element of the array. * @param {Function} thisp Object to use as this when executing callback. * * @return {Void} */ forEach: function(fun/*, thisp*/) { if (typeof fun !== "function") { throw new TypeError("First argument is not callable"); } var thisp = arguments[1] || null; for (var i = 0, len = this.length >>> 0; i < len; i++) { if (i in this) { fun.call(thisp, this[i], i, this); } } }, /** * Returns the first index at which a given element can be found in the array, * or -1 if it is not present. * * @param {Object} elt Element to locate in the array. * @param {Number} from The index at which to begin the search. Defaults to 0, i.e. * the whole array will be searched. If the index is greater than or equal * to the length of the array, -1 is returned, i.e. the array will not be * searched. If negative, it is taken as the offset from the end of the array. * Note that even when the index is negative, the array is still searched * from front to back. If the calculated index is less than 0, the whole * array will be searched. * * @return {Number} Array index. */ indexOf: function(elt/*, from*/) { if (this === null || this === void 0) { throw new TypeError(); } var len = this.length >>> 0; var from = Number(arguments[1]) || 0; from = from < 0 ? Math.ceil(from) : Math.floor(from); if (from < 0) { from += len; } for (; from < len; from++) { if (((from in this) || (len > from + 1 && this[from] === void 0)) && this[from] === elt) { return from; } } return -1; }, /** * Returns the last index at which a given element can be found in the array, * or -1 if it is not present. The array is searched backwards, starting at fromIndex. * * @param {Object} elt Element to locate in the array. * @param {Number=0} from The index at which to start searching backwards. Defaults to * the array's length, i.e. the whole array will be searched. If the index is * greater than or equal to the length of the array, the whole array will be * searched. If negative, it is taken as the offset from the end of the array. * Note that even when the index is negative, the array is still searched from * back to front. If the calculated index is less than 0, -1 is returned, i.e. * the array will not be searched. * * @return {Number} Array index. */ lastIndexOf: function(elt/*, from*/) { var len = this.length >>> 0; if (len === 1) { return -1; } var from = Number(arguments[1]); if (arguments.length === 1) { from = len; } else { if (isNaN(from)) { if (arguments[1] === void 0) { from = 0; } else { from = -1; } } else { from = (from < 0) ? Math.ceil(from) : Math.floor(from); if (from < 0) { from += len; } else if (from >= len) { from = len - 1; } } } for (; from > -1; from--) { if (((from in this) || (len > from + 1 && this[from] === void 0)) && this[from] === elt) { return from; } } return -1; }, /** * Tests whether all elements in the array pass the test implemented by the provided function. * * Implementation from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every * * @param {Function} fun Function to test for each element. * @param {Object=} thisp Object to use as this when executing fun. * * @return {Boolean} Test result. */ every: function(fun/*, thisp */) { if (this === void 0 || this === null) { throw new TypeError(); } var t = Object(this); var len = t.length >>> 0; if (typeof fun !== "function") { throw new TypeError(); } var thisp = arguments[1]; for (var i = 0; i < len; i++) { if (i in t && !fun.call(thisp, t[i], i, t)) { return false; } } return true; }, /** * Tests whether some element in the array passes the test implemented * by the provided function. * * Implementation from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some * * @param {Function} fun Function to test for each element. * @param {Object=} thisp Object to use as this when executing fun. * * @return {Boolean} Test result. */ some: function(fun/*, thisp */) { if (this === void 0 || this === null) { throw new TypeError(); } var t = Object(this); var len = t.length >>> 0; if (typeof fun !== "function") { throw new TypeError(); } var thisp = arguments[1]; for (var i = 0; i < len; i++) { if (i in t && fun.call(thisp, t[i], i, t)) { return true; } } return false; }, /** * Creates a new array with the results of calling a provided function on every element in this array. * * Implementation from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/map * * @param {Function} callback Function that produces an element of the new Array from an element of the current one. * @param {Object=} thisp Object to use as this when executing fun. * * @return {Boolean} New array. */ map: function(callback/*, thisp*/ ) { var A, k; var thisp = arguments[1] || null; if (this == null) { throw new TypeError(" this is null or not defined"); } var O = Object(this); var len = O.length >>> 0; if ({}.toString.call(callback) != "[object Function]") { throw new TypeError(callback + " is not a function"); } A = new Array(len); k = 0; while(k < len) { var kValue, mappedValue; if (k in O) { kValue = O[ k ]; mappedValue = callback.call(thisp, kValue, k, O); A[ k ] = mappedValue; } k++; } return A; }, /** * Apply a function against an accumulator and each value of the array (from left-to-right) * as to reduce it to a single value. * * Implementation from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/Reduce * * @param {Function} accumulator Function to execute on each value in the array. * @param {Object=} initial Object to use as the first argument to the first call of the callback. * * @return {Object} Result of function application. */ reduce: function(accumulator/*, initial */) { var i, l = Number(this.length), curr; if (typeof accumulator !== "function") { // ES5 : "If IsCallable(callbackfn) is false, throw a TypeError exception." throw new TypeError("First argument is not callable"); } if (l === 0) { if (arguments.length > 1) { return arguments[1]; } else { throw new TypeError("No initial value for empty array"); } } if (l === null && (arguments.length <= 1)) {// == on purpose to test 0 and false. throw new TypeError("Array length is 0 and no second argument"); } if (arguments.length <= 1) { curr = this[0]; // Increase i to start searching the secondly defined element in the array i = 1; // start accumulating at the second element } else { curr = arguments[1]; } for (i = i || 0 ; i < l ; ++i) { if(i in this) { curr = accumulator.call(undefined, curr, this[i], i, this); } } return curr; }, /** * Apply a function simultaneously against two values of the array (from right-to-left) * as to reduce it to a single value. * * @param {Function} callbackfn Function to execute on each value in the array. * @param {Object=} initial Object to use as the first argument to the first call of the callback. * * @return {Object} Result of function application. */ reduceRight: function(callbackfn/*, initial */) { if (this === void 0 || this === null) { throw new TypeError(); } var t = Object(this); var len = t.length >>> 0; if (typeof callbackfn !== "function") { throw new TypeError(); } // no value to return if no initial value, empty array if (len === 0 && arguments.length === 1) throw new TypeError(); var k = len - 1; var accumulator; if (arguments.length >= 2) { accumulator = arguments[1]; } else { do { if (k in this) { accumulator = this[k--]; break; } // if array contains no values, no initial value to return if (--k < 0) { throw new TypeError(); } } while (true); } while (k >= 0) { if (k in t) { accumulator = callbackfn.call(undefined, accumulator, t[k], k, t); } k--; } return accumulator; } }); /* ajax */ var XMLHttpRequest = XMLHttpRequest || window.ActiveXObject && function(){ return new ActiveXObject('Msxml2.XMLHTTP'); }; //dom.js /* DOM class */ DOM = { getElement: function(e){ return (typeof e == "string" || typeof e == "number") ? document.getElementById(e) : e; }, addEventListener: function(e, eventName, func, useCapture){ if(e.addEventListener) e.addEventListener(eventName, func, useCapture); else if(e.attachEvent) e.attachEvent('on' + eventName, func); else e['on' + eventName] = func; }, removeEventListener: function(e, eventName, func, useCapture){ if(e.removeEventListener) e.removeEventListener(eventName, func, useCapture); else if(e.detachEvent) e.detachEvent('on' + eventName, func); else e['on' + eventName] = undefined; }, /* style */ getComputedStyle: function(node){ if(node.currentStyle){ return node.currentStyle; } var defaultView = node.ownerDocument.defaultView; if(defaultView && defaultView.getComputedStyle){ return defaultView.getComputedStyle(node, null); } }, // given a window (or defaulting to current window), returns // object with .x and .y of client's usable area getClientDimensions: function(w){ if(!w) w = window; var d = {}; // most browsers if(w.innerHeight){ d.x = w.innerWidth; d.y = w.innerHeight; return d; } // IE6, strict var de = w.document.documentElement; if(de && de.clientHeight){ d.x = de.clientWidth; d.y = de.clientHeight; return d; } // IE, misc if(document.body){ d.x = document.body.clientWidth; d.y = document.body.clientHeight; return d; } return undefined; }, getDimensions: function(e){ if(!e) return undefined; var style = DOM.getComputedStyle(e); return { offsetLeft: e.offsetLeft, offsetTop: e.offsetTop, offsetWidth: e.offsetWidth, offsetHeight: e.offsetHeight, clientWidth: e.clientWidth, clientHeight: e.clientHeight, offsetRight: e.offsetLeft + e.offsetWidth, offsetBottom: e.offsetTop + e.offsetHeight, clientLeft: finiteInt(style.borderLeftWidth) + finiteInt(style.paddingLeft), clientTop: finiteInt(style.borderTopWidth) + finiteInt(style.paddingTop), clientRight: e.clientLeft + e.clientWidth, clientBottom: e.clientTop + e.clientHeight }; }, getAbsoluteDimensions: function(e){ var d = DOM.getDimensions(e); if(!d) return d; d.absoluteLeft = d.offsetLeft; d.absoluteTop = d.offsetTop; d.absoluteRight = d.offsetRight; d.absoluteBottom = d.offsetBottom; var bork = 0; while(e){ try{ // IE 6 sometimes gives an unwarranted error ("htmlfile: Unspecified error"). e = e.offsetParent; } catch (err){ if(++bork > 25) return null; } if(!e) return d; d.absoluteLeft += e.offsetLeft; d.absoluteTop += e.offsetTop; d.absoluteRight += e.offsetLeft; d.absoluteBottom += e.offsetTop; } return d; }, setLeft: function(e, v){ e.style.left = finiteInt(v) + "px"; }, setTop: function(e, v){ e.style.top = finiteInt(v) + "px"; }, setWidth: function(e, v){ e.style.width = Math.max(0, finiteInt(v)) + "px"; }, setHeight: function(e, v){ e.style.height = Math.max(0, finiteInt(v)) + "px"; }, getWindowScroll: function(w){ var s = { left: 0, top: 0 } if(!w) w = window; var d = w.document; var de = d.documentElement; // most browsers if(w.pageXOffset !== undefined){ s.left = w.pageXOffset; s.top = w.pageYOffset; } // ie else if(de && de.scrollLeft !== undefined){ s.left = de.scrollLeft; s.top = de.scrollTop; } // safari else if(w.scrollX !== undefined){ s.left = w.scrollX; s.top = w.scrollY; } // opera else if(d.body && d.body.scrollLeft !== undefined){ s.left = d.body.scrollLeft; s.top = d.body.scrollTop; } return s; }, getAbsoluteCursorPosition: function(event){ event = event || window.event; var s = DOM.getWindowScroll(window); return { x: s.left + event.clientX, y: s.top + event.clientY }; }, /* dom methods */ filterElementsByClassName: function(es, className){ var filtered = []; for(var i = 0; i < es.length; i++){ var e = es[ i ]; if(DOM.hasClassName(e, className)) filtered[ filtered.length ] = e; } return filtered; }, filterElementsByAttribute: function(es, attr){ if(!es) return []; if(!attr) return es; var filtered = []; for(var i = 0; i < es.length; i++){ var element = es[ i ]; if(!element) continue; if(element.getAttribute && ( element.getAttribute(attr) )) filtered[ filtered.length ] = element; } return filtered; }, filterElementsByTagName: function(es, tagName){ if(tagName == "*") return es; var filtered = []; tagName = tagName.toLowerCase(); for(var i = 0; i < es.length; i++){ var e = es[ i ]; if(e.tagName && e.tagName.toLowerCase() == tagName) filtered[ filtered.length ] = e; } return filtered; }, // private getElementsByTagAndAttribute: function(root, tagName, attr){ if(!root) root = document; var es = root.getElementsByTagName(tagName); return DOM.filterElementsByAttribute(es, attr); }, getElementsByAttributeAndValue: function(root, attr, value){ var es = DOM.getElementsByTagAndAttribute(root, "*", attr); var filtered = []; for(var i = 0; i < es.length; i++) if(es[ i ].getAttribute(attr) == value) filtered.push(es[ i ]); return filtered; }, getElementsByTagAndClassName: function(root, tagName, className){ if(!root) root = document; var elements = root.getElementsByTagName(tagName); return DOM.filterElementsByClassName(elements, className); }, getElementsByClassName: function(root, className){ return DOM.getElementsByTagAndClassName(root, "*", className); }, getAncestors: function(n, includeSelf){ if(!n) return []; var as = includeSelf ? [ n ] : []; n = n.parentNode; while(n){ as.push(n); n = n.parentNode; } return as; }, getAncestorsByClassName: function(n, className, includeSelf){ var es = DOM.getAncestors(n, includeSelf); return DOM.filterElementsByClassName(es, className); }, getFirstAncestorByClassName: function(n, className, includeSelf){ return DOM.getAncestorsByClassName(n, className, includeSelf)[ 0 ]; }, hasClassName: function(e, className){ if(!e || !e.className) return false; var cs = e.className.split(/\s+/g); for(var i = 0; i < cs.length; i++){ if(cs[ i ] == className) return true; } return false; }, addClassName: function(e, className){ if(!e || !className) return false; var cs = e.className.split(/\s+/g); for(var i = 0; i < cs.length; i++){ if(cs[ i ] == className) return true; } cs.push(className); e.className = cs.join(" "); return false; }, removeClassName: function(e, className){ var r = false; if(!e || !e.className || !className) return r; var cs = (e.className && e.className.length) ? e.className.split(/\s+/g) : []; var ncs = []; for(var i = 0; i < cs.length; i++){ if(cs[ i ] == className){ r = true; continue; } ncs.push(cs[ i ]); } if(r) e.className = ncs.join(" "); return r; }, getSelectedRange: function(node){ var start = 0, end = 0; if('selectionStart' in node){ start = node.selectionStart; end = node.selectionEnd; } else if(node.createTextRange){ var range = document.selection.createRange(); if(range.parentElement() == node){ var dup = range.duplicate(); if(node.type == 'text'){ node.focus(); start = -dup.moveStart('character', -node.value.length); end = start + range.text.length; } else {// textarea var rex = /\r/g; dup.moveToElementText(node); dup.setEndPoint('EndToStart', range); start = dup.text.replace(rex, '').length; dup.setEndPoint('EndToEnd', range); end = dup.text.replace(rex, '').length; dup = document.selection.createRange(); dup.moveToElementText(node); dup.moveStart('character', start); while(dup.move('character', -dup.compareEndPoints('StartToStart', range))){ start++; } dup.moveStart('character', end - start); while(dup.move('character', -dup.compareEndPoints('StartToEnd', range))){ end++; } } } } return { start: start, end: end } }, setSelectedRange: function(node, start, end){ // see https://bugzilla.mozilla.org/show_bug.cgi?id=265159 node.focus(); if(node.setSelectionRange){ node.setSelectionRange(start, end); } // IE, "else" for opera 10 else if(document.selection && document.selection.createRange){ var range = node.createTextRange(); range.collapse(true); range.moveEnd('character', end); range.moveStart('character', start); range.select(); } } }; $ = DOM.getElement; //httpreq.js // opts: // url, onError, onData, method (GET or POST), data // url: where to get/post to // onError: callback on error // onData: callback on data received // method: HTTP method, GET by default // data: what to send to the server (urlencoded) HTTPReq = { getJSON: function(opts){ var req = new XMLHttpRequest(); var state_callback = function(){ if(req.readyState != 4) return; if(req.status != 200){ if(opts.onError) opts.onError(req.status ? "status: " + req.status : "no data"); return; } var resObj; var e; try{ eval("resObj = " + req.responseText + ";"); } catch (e){ } if(e || ! resObj){ if(opts.onError) opts.onError("Error parsing response: \"" + req.responseText + "\""); return; } if(opts.onData) opts.onData(resObj); }; req.onreadystatechange = state_callback; var method = opts.method || "GET"; var data = opts.data || null; var url = opts.url; if(opts.method == "GET" && opts.data){ url += url.match(/\?/) ? "&" : "?"; url += opts.data } url += url.match(/\?/) ? "&" : "?"; url += "_rand=" + Math.random(); req.open(method, url, true); // we should send null unless we're in a POST var to_send = null; if(method.toUpperCase() == "POST"){ req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); to_send = data; } req.send(to_send); }, formEncoded: function(vars){ var enc = []; var e; for(var key in vars){ enc.push(encodeURIComponent(key) + "=" + encodeURIComponent(vars[key])); } return enc.join("&"); } }; // This file contains general-purpose LJ code LiveJournal = { hooks: {} // The hook mappings } LiveJournal.register_hook = function (hook, func) { if (! LiveJournal.hooks[hook]) LiveJournal.hooks[hook] = []; LiveJournal.hooks[hook].push(func); }; // args: hook, params to pass to hook LiveJournal.run_hook = function () { var a = arguments; var hookfuncs = LiveJournal.hooks[a[0]]; if (!hookfuncs || !hookfuncs.length) return; var hookargs = [].slice.call( arguments, 1 ); var rv = null; hookfuncs.forEach(function (hookfunc) { rv = hookfunc.apply(null, hookargs); }); return rv; }; LiveJournal.initPage = function () { //register system hooks LiveJournal.register_hook( 'update_wallet_balance', LiveJournal.updateWalletBalance ); LiveJournal.register_hook( 'xdr/message', LiveJournal.processXdr ); // set up various handlers for every page LiveJournal.initInboxUpdate(); LiveJournal.initNotificationStream(); //ljunq cookie is checked in PageStats/Omniture.pm now // run other hooks LiveJournal.run_hook("page_load"); }; jQuery(LiveJournal.initPage); /** * Init long-polling connection to the server. * Now function can be used for testing purposes and * should be modified for any real use. E.g. it could be * used as an adapter to the Socket.IO */ LiveJournal.initNotificationStream = function(force) { force = force || false; var abortNotifications = false, seed = Site.notifySeed || 0; if (Site.notifyDisabled || (!Cookie('ljnotify') && !force && (Math.random() > seed))) { return; } if (!Cookie( 'ljnotify')) { Cookie( 'ljnotify', '1', { domain: Site.siteroot.replace(/^https?:\/\/www\./, ''), expires: 5000, path: '/' }); } LiveJournal.register_hook('notification.stop', function() { abortNotifications = true; }); function requestRound() { if (abortNotifications) { return; } jQuery .get(LiveJournal.getAjaxUrl('notifications'), 'json') .success(function(data) { //if it's not a notification than it is a timeout answer if(data.type === 'notification') { LiveJournal.run_hook(data.name, data.params || []); } requestRound(); }).error(function() { requestRound() }); } requestRound(); }; /** * Translate message from xdreceiver. The function will eventually be run * from xdreceiver.html helper frame to send messages between different domains. * * @param {Object} message Object with the message. Object should always contain type field with event name */ LiveJournal.processXdr = function(message) { if (message.type) { var type = decodeURIComponent(message.type); } else { return; } var messageCopy = {}; for (var name in message) if (message.hasOwnProperty(name) && name !== 'type') { messageCopy[name] = decodeURIComponent(message[name]); } LiveJournal.run_hook(type, messageCopy); }; // Set up a timer to keep the inbox count updated LiveJournal.initInboxUpdate = function () { // Don't run if not logged in or this is disabled if (! Site || ! Site.has_remote || ! Site.inbox_update_poll) return; // Don't run if no inbox count var unread = $("LJ_Inbox_Unread_Count"); if (! unread) return; // Update every five minutes window.setInterval(LiveJournal.updateInbox, 1000 * 60 * 5); }; // Do AJAX request to find the number of unread items in the inbox LiveJournal.updateInbox = function () { jQuery.post( LiveJournal.getAjaxUrl( 'esn_inbox' ), { "action": "get_unread_items" }, function( resp ) { if (! resp || resp.error) return; var unread = $("LJ_Inbox_Unread_Count"); if( unread ) { unread.innerHTML = resp.unread_count ? " (" + resp.unread_count + ")" : ""; } else { var unread = $("LJ_Inbox_Unread_Count_Controlstrip"); if( unread ) { unread.innerHTML = resp.unread_count ? resp.unread_count : "0"; } } }, 'json' ); }; //refresh number of tokens in the header LiveJournal.updateWalletBalance = function () { jQuery.get( LiveJournal.getAjaxUrl( 'get_balance' ), function( resp ) { if (! resp || resp.status != 'OK') return; var newBalance = resp.balance ? parseInt( resp.balance, 10 ) : 0; var balance = $("LJ_Wallet_Balance"); if( balance ) { if( resp.balance ) { balance.innerHTML = balance.innerHTML.replace( /\d+/, newBalance ); } else { balance.innerHTML = ""; } } else { var balance = $("LJ_Wallet_Balance_Controlstrip"); if( balance ) { balance.innerHTML = newBalance; } } }, 'json' ); }; // Placeholder onclick event LiveJournal.placeholderClick = function(link, html) { // use replaceChild for no blink scroll effect link.parentNode.parentNode.replaceChild(jQuery(unescape(html))[0], link.parentNode); return false } // handy utilities to create elements with just text in them function _textSpan () { return _textElements("span", arguments); } function _textDiv () { return _textElements("div", arguments); } function _textElements (eleType, txts) { var ele = []; for (var i = 0; i < txts.length; i++) { var node = document.createElement(eleType); node.innerHTML = txts[i]; ele.push(node); } return ele.length == 1 ? ele[0] : ele; }; LiveJournal.pollAnswerClick = function(e, data) { if (!data.pollid || !data.pollqid) return false; var xhr = jQuery.post(LiveJournal.getAjaxUrl('poll'), { pollid : data.pollid, pollqid : data.pollqid, page : data.page, pagesize : data.pagesize, action : 'get_answers' }, function(data, status) { status == 'success' ? LiveJournal.pollAnswersReceived(data): LiveJournal.ajaxError(data); }, 'json'); jQuery(e).hourglass(xhr); return false; } LiveJournal.pollAnswersReceived = function(answers) { if (!answers || !answers.pollid || !answers.pollqid) return; if (answers.error) return LiveJournal.ajaxError(answers.error); var id = '#LJ_Poll_' + answers.pollid + '_' + answers.pollqid, to_remove = '.LJ_PollAnswerLink, .lj_pollanswer, .lj_pollanswer_paging', html = '
' + (answers.answer_html || '(No answers)') + '
'; answers.paging_html && (html += '
' + answers.paging_html + '
'); jQuery(id).find(to_remove).remove() .end().prepend(html).find('.lj_pollanswer').ljAddContextualPopup(); } // gets a url for doing ajax requests LiveJournal.getAjaxUrl = function(action, params) { // if we are on a journal subdomain then our url will be // /journalname/__rpc_action instead of /__rpc_action var uselang = LiveJournal.parseGetArgs(location.search).uselang; if (uselang) { action += "?uselang=" + uselang; } if (params) { action += (uselang ? "&" : "?") + jQuery.param(params); } return Site.currentJournal ? "/" + Site.currentJournal + "/__rpc_" + action : "/__rpc_" + action; }; // generic handler for ajax errors LiveJournal.ajaxError = function (err) { if (LJ_IPPU) { LJ_IPPU.showNote("Error: " + err); } else { alert("Error: " + err); } }; // given a URL, parse out the GET args and return them in a hash LiveJournal.parseGetArgs = function (url) { url = url || window.location.href; url = url.replace(/#.*$/,''); var getArgsHash = {}; var urlParts = url.split("?"); if (!urlParts[1]) return getArgsHash; var getArgs = urlParts[1].split("&"); for (var arg=0; arg' ) .css( { width: "110px", height: "20px" } ) .attr( 'src', LiveJournal.constructUrl( 'http://platform.twitter.com/widgets/tweet_button.html', params ) ) .insertBefore( link ) ); } ); } /** * Insert script in the document. * * @param {String} url Url of the script * @param {Object=} params Data to apply to the scipt node object, e.g. async, text. * @param {Node=} parent If exists, script tag will be inserted in this node or before the * first script tag otherwise. */ LiveJournal.injectScript = function( url, params, parent ) { function loadScript() { var defaults = { async: true }; params = params || {}; params = jQuery.extend({}, defaults, params); var e = document.createElement('script'); e.src = url; for (var i in params) { if (params.hasOwnProperty(i)) { e[i] = params[i]; } } if (parent) { parent.appendChild(e); } else { s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(e, s); } } //opera doesn't support async attribute, so we load the scrips on onload event to display page faster if (jQuery.browser.opera) { jQuery(loadScript); } else { loadScript(); } } LiveJournal.getLocalizedStr = function( key, dict ) { dict = dict || {}; var str = ""; if( key in Site.ml_text ) { str = Site.ml_text[ key ]; for( var tmpl in dict ) { str = str.replace( '%' + tmpl + '%', dict[ tmpl ] ); } } else { str = "[" + key + "]"; } return str; } LiveJournal.JSON = function() { /** * Formats integers to 2 digits. * @param {number} n * @private */ function f(n) { return n < 10 ? '0' + n : n; } Date.prototype.toJSON = function() { return [this.getUTCFullYear(), '-', f(this.getUTCMonth() + 1), '-', f(this.getUTCDate()), 'T', f(this.getUTCHours()), ':', f(this.getUTCMinutes()), ':', f(this.getUTCSeconds()), 'Z'].join(''); }; // table of character substitutions /** * @const * @enum {string} */ var m = { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\' }; /** * Converts a json object into a string. * @param {*} value * @return {string} * @member gadgets.json */ function stringify(value) { var a, // The array holding the partial texts. i, // The loop counter. k, // The member key. l, // Length. r = /["\\\x00-\x1f\x7f-\x9f]/g, v; // The member value. switch (typeof value) { case 'string': // If the string contains no control characters, no quote characters, and no // backslash characters, then we can safely slap some quotes around it. // Otherwise we must also replace the offending characters with safe ones. return r.test(value) ? '"' + value.replace(r, function(a) { var c = m[a]; if (c) { return c; } c = a.charCodeAt(); return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16); }) + '"' : '"' + value + '"'; case 'number': // JSON numbers must be finite. Encode non-finite numbers as null. return isFinite(value) ? String(value) : 'null'; case 'boolean': case 'null': return String(value); case 'object': // Due to a specification blunder in ECMAScript, // typeof null is 'object', so watch out for that case. if (!value) { return 'null'; } // toJSON check removed; re-implement when it doesn't break other libs. a = []; if (typeof value.length === 'number' && !value.propertyIsEnumerable('length')) { // The object is an array. Stringify every element. Use null as a // placeholder for non-JSON values. l = value.length; for (i = 0; i < l; i += 1) { a.push(stringify(value[i]) || 'null'); } // Join all of the elements together and wrap them in brackets. return '[' + a.join(',') + ']'; } // Otherwise, iterate through all of the keys in the object. for (k in value) { if (k.match('___$')) continue; if (value.hasOwnProperty(k)) { if (typeof k === 'string') { v = stringify(value[k]); if (v) { a.push(stringify(k) + ':' + v); } } } } // Join all of the member texts together and wrap them in braces. return '{' + a.join(',') + '}'; } return ''; } return { 'stringify': stringify, 'parse': function(text) { // Parsing happens in three stages. In the first stage, we run the text against // regular expressions that look for non-JSON patterns. We are especially // concerned with '()' and 'new' because they can cause invocation, and '=' // because it can cause mutation. But just to be safe, we want to reject all // unexpected forms. // We split the first stage into 4 regexp operations in order to work around // crippling inefficiencies in IE's and Safari's regexp engines. First we // replace all backslash pairs with '@' (a non-JSON character). Second, we // replace all simple value tokens with ']' characters. Third, we delete all // open brackets that follow a colon or comma or that begin the text. Finally, // we look to see that the remaining characters are only whitespace or ']' or // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. if (/^[\],:{}\s]*$/.test(text.replace(/\\["\\\/b-u]/g, '@'). replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'). replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { return eval('(' + text + ')'); } // If the text is not JSON parseable, then return false. return false; } }; }(); var ESN = new Object(); // When page loads, set up "check all" checkboxes ESN.initCheckAllBtns = function () { var ntids = $("ntypeids"); var catids = $("catids"); if (!ntids || !catids) return; ntidList = ntids.value; catidList = catids.value; if (!ntidList || !catidList) return; ntids = ntidList.split(","); catids = catidList.split(","); catids.forEach( function (catid) { ntids.forEach( function (ntypeid) { var className = "SubscribeCheckbox-" + catid + "-" + ntypeid; var cab = new CheckallButton(); cab.init({ "class": className, "button": $("CheckAll-" + catid + "-" + ntypeid), "parent": $("CategoryRow-" + catid) }); }); }); } // attach event handlers to all track buttons ESN.initTrackBtns = function (node) { // don't do anything if no remote if (!Site.has_remote) return; node = node || document; var trackBtns = DOM.getElementsByTagAndClassName(node, 'img', 'TrackButton'); trackBtns.forEach(function (trackBtn) { if (!trackBtn || !trackBtn.getAttribute) return; if (!trackBtn.getAttribute("lj_subid") && !trackBtn.getAttribute("lj_journalid")) return; if (trackBtn.getAttribute("lj_dtalkid") && !Site.remote_can_track_threads) return; DOM.addEventListener(trackBtn, 'click', ESN.trackBtnClickHandler.bindEventListener(trackBtn)); }); }; ESN.trackBtnClickHandler = function (evt) { var trackBtn = evt.target; if (! trackBtn || trackBtn.tagName.toLowerCase() != "img") return true; Event.stop(evt); var btnInfo = {}; ['arg1', 'arg2', 'etypeid', 'newentry_etypeid', 'newentry_token', 'newentry_subid', 'journalid', 'subid', 'auth_token'].forEach(function (arg) { btnInfo[arg] = trackBtn.getAttribute("lj_" + arg); }); // pop up little dialog to either track by inbox/email or go to more options var dlg = document.createElement("div"); var title = _textDiv("Email me when"); DOM.addClassName(title, "track_title"); dlg.appendChild(title); var TrackCheckbox = function (title, checked) { var checkContainer = document.createElement("div"); var newCheckbox = document.createElement("input"); newCheckbox.type = "checkbox"; newCheckbox.id = "newentrytrack" + Unique.id(); var newCheckboxLabel = document.createElement("label"); newCheckboxLabel.setAttribute("for", newCheckbox.id); newCheckboxLabel.innerHTML = title; checkContainer.appendChild(newCheckbox); checkContainer.appendChild(newCheckboxLabel); dlg.appendChild(checkContainer); newCheckbox.checked = checked ? true : false; return newCheckbox; }; // global trackPopup so we can only have one if (ESN.trackPopup) { ESN.trackPopup.hide(); ESN.trackPopup = null; } var saveChangesBtn = document.createElement("input"); saveChangesBtn.type = "button"; saveChangesBtn.value = "Save Changes"; DOM.addClassName(saveChangesBtn, "track_savechanges"); var trackingNewEntries = Number(btnInfo['newentry_subid']) ? 1 : 0; var trackingNewComments = Number(btnInfo['subid']) ? 1 : 0; var newEntryTrackBtn; var commentsTrackBtn; if (trackBtn.getAttribute("lj_dtalkid")) { // this is a thread tracking button // always checked: either because they're subscribed, or because // they're going to subscribe. commentsTrackBtn = TrackCheckbox("someone replies in this comment thread", 1); } else { // entry tracking button newEntryTrackBtn = TrackCheckbox(Site.currentJournal + ' posts a new entry', trackingNewEntries); commentsTrackBtn = TrackCheckbox("someone comments on this post", trackingNewComments); } DOM.addEventListener(saveChangesBtn, "click", function () { ESN.toggleSubscriptions(btnInfo, evt, trackBtn, { newEntry: newEntryTrackBtn ? newEntryTrackBtn.checked : false, newComments: commentsTrackBtn.checked }); if (ESN.trackPopup) ESN.trackPopup.hide(); }); var btnsContainer = document.createElement("div"); DOM.addClassName(btnsContainer, "track_btncontainer"); dlg.appendChild(btnsContainer); btnsContainer.appendChild(saveChangesBtn); var custTrackLink = document.createElement("a"); custTrackLink.href = trackBtn.parentNode.href; btnsContainer.appendChild(custTrackLink); custTrackLink.innerHTML = "More Options"; DOM.addClassName(custTrackLink, "track_moreopts"); ESN.trackPopup = new LJ_IPPU.showNoteElement(dlg, trackBtn, 0); DOM.addEventListener(custTrackLink, "click", function (evt) { Event.stop(evt); document.location.href = trackBtn.parentNode.href; if (ESN.trackPopup) ESN.trackPopup.hide(); return false; }); return false; } // toggles subscriptions ESN.toggleSubscriptions = function (subInfo, evt, btn, subs) { subInfo["subid"] = Number(subInfo["subid"]); if ((subInfo["subid"] && ! subs["newComments"]) || (! subInfo["subid"] && subs["newComments"])) { ESN.toggleSubscription(subInfo, evt, btn, "newComments"); } subInfo["newentry_subid"] = Number(subInfo["newentry_subid"]); if ((subInfo["newentry_subid"] && ! subs["newEntry"]) || (! subInfo["newentry_subid"] && subs["newEntry"])) { var newentrySubInfo = new Object(subInfo); newentrySubInfo["subid"] = Number(btn.getAttribute("lj_newentry_subid")); ESN.toggleSubscription(newentrySubInfo, evt, btn, "newEntry"); } }; // (Un)subscribes to an event ESN.toggleSubscription = function (subInfo, evt, btn, sub) { var action = ""; var params = { auth_token: sub == "newEntry" ? subInfo.newentry_token : subInfo.auth_token }; if (Number(subInfo.subid)) { // subscription exists action = "delsub"; params.subid = subInfo.subid; } else { // create a new subscription action = "addsub"; var param_keys; if (sub == "newEntry") { params.etypeid = subInfo.newentry_etypeid; param_keys = ["journalid"]; } else { param_keys = ["journalid", "arg1", "arg2", "etypeid"]; } param_keys.forEach(function (param) { if (Number(subInfo[param])) params[param] = parseInt(subInfo[param]); }); } params.action = action; var reqInfo = { "method": "POST", "url": LiveJournal.getAjaxUrl('esn_subs'), "data": HTTPReq.formEncoded(params) }; var gotInfoCallback = function (info) { if (! info) return LJ_IPPU.showNote("Error changing subscription", btn); if (info.error) return LJ_IPPU.showNote(info.error, btn); if (info.success) { if (info.msg) LJ_IPPU.showNote(info.msg, btn); if (info.subscribed) { if (info.subid) btn.setAttribute('lj_subid', info.subid); if (info.newentry_subid) btn.setAttribute('lj_newentry_subid', info.newentry_subid); btn.setAttribute('title', 'Untrack This'); // update subthread tracking icons var dtalkid = btn.getAttribute("lj_dtalkid"); if (dtalkid) ESN.updateThreadIcons(dtalkid, "on"); else // not thread tracking button btn.src = Site.imgprefix + "/btn_tracking.gif"; } else { if (info["event_class"] == "LJ::Event::JournalNewComment") btn.setAttribute('lj_subid', 0); else if (info["event_class"] == "LJ::Event::JournalNewEntry") btn.setAttribute('lj_newentry_subid', 0); btn.setAttribute('title', 'Track This'); // update subthread tracking icons var dtalkid = btn.getAttribute("lj_dtalkid"); if (dtalkid) { // set state to "off" if no parents tracking this, // otherwise set state to "parent" var state = "off"; var parentBtn; var parent_dtalkid = dtalkid; while (parentBtn = ESN.getThreadParentBtn(parent_dtalkid)) { parent_dtalkid = parentBtn.getAttribute("lj_dtalkid"); if (! parent_dtalkid) { break; } if (! Number(parentBtn.getAttribute("lj_subid"))) continue; state = "parent"; break; } ESN.updateThreadIcons(dtalkid, state); } else { // not thread tracking button btn.src = Site.imgprefix + "/btn_track.gif"; } } if (info.auth_token) btn.setAttribute('lj_auth_token', info.auth_token); if (info.newentry_token) btn.setAttribute('lj_newentry_token', info.newentry_token); } }; reqInfo.onData = gotInfoCallback; reqInfo.onError = function (err) { LJ_IPPU.showNote("Error: " + err) }; HTTPReq.getJSON(reqInfo); }; // given a dtalkid, find the track button for its parent comment (if any) ESN.getThreadParentBtn = function (dtalkid) { var cmtInfo = LJ_cmtinfo[dtalkid + ""]; if (! cmtInfo) { return null; } var parent_dtalkid = cmtInfo.parent; if (! parent_dtalkid) return null; return $("lj_track_btn_" + parent_dtalkid); }; // update all the tracking icons under a parent comment ESN.updateThreadIcons = function (dtalkid, tracking) { var btn = $("lj_track_btn_" + dtalkid); if (! btn) { return; } var cmtInfo = LJ_cmtinfo[dtalkid + ""]; if (! cmtInfo) { return; } if (Number(btn.getAttribute("lj_subid")) && tracking != "on") { // subscription already exists on this button, don't mess with it return; } if (cmtInfo.rc && cmtInfo.rc.length) { // update children cmtInfo.rc.forEach(function (child_dtalkid) { window.setTimeout(function () { var state; switch (tracking) { case "on": state = "parent"; break; case "off": state = "off"; break; case "parent": state = "parent"; break; default: alert("Unknown tracking state " + tracking); break; } ESN.updateThreadIcons(child_dtalkid, state); }, 300); }); } // update icon var uri; switch (tracking) { case "on": uri = "/btn_tracking.gif"; break; case "off": uri = "/btn_track.gif"; break; case "parent": uri = "/btn_tracking_thread.gif"; break; default: alert("Unknown tracking state " + tracking); break; } btn.src = Site.imgprefix + uri; }; jQuery(function($) { ESN.initCheckAllBtns(); ESN.initTrackBtns(); $('#settings_form').delegate('a.delete-group', 'click', function(e) { var group = this.href.match('&delete_group=(.*?)&')[1]; $.post(location.href, { delete_group: group }); $(this).parents('tr').eq(0).remove(); e.preventDefault(); }); }); /* IPPU methods: init([innerHTML]) -- takes innerHTML as optional argument show() -- shows the popup hide() -- hides popup cancel() -- hides and calls cancel callback Content setters: setContent(innerHTML) -- set innerHTML setContentElement(element) -- adds element as a child of the popup Accessors: getElement() -- returns popup DIV element visible() -- returns whether the popup is visible or not Titlebar: setTitlebar(show) -- true: show titlebar / false: no titlebar setTitle(title) -- sets the titlebar text getTitlebarElement() -- returns the titlebar element setTitlebarClass(className) -- set the class of the titlebar Styling: setOverflow(overflow) -- sets ele.style.overflow to overflow addClass(className) -- adds class to popup removeClass(className) -- removes class to popup Browser Hacks: setAutoHideSelects(autohide) -- when the popup is shown should it find all the selects on the page and hide them (and show them again) (for IE) Positioning/Sizing: setLocation(left, top) -- set popup location: will be pixels if units not specified setLeft(left) -- set left location setTop(top) -- set top location setDimensions(width, height) -- set popup dimensions: will be pixels if units not specified setAutoCenter(x, y) -- what dimensions to auto-center center() -- centers popup on screen centerX() -- centers popup horizontally centerY() -- centers popup vertically setFixedPosition(fixed) -- should the popup stay fixed on the page when it scrolls? centerOnWidget(widget) -- center popup on this widget setAutoCenterCallback(callback) -- calls callback with this IPPU instance as a parameter for auto-centering. Some common built-in class methods you can use as callbacks are: IPPU.center IPPU.centerX IPPU.centerY moveForward(amount) -- increases the zIndex by one or amount if specified moveBackward(amount) -- decreases the zIndex by one or amount if specified Modality: setClickToClose(clickToClose) -- if clickToClose is true, clicking outside of the popup will close it setModal(modality) -- If modality is true, then popup will capture all mouse events and optionally gray out the rest of the page. (overrides clickToClose) setOverlayVisible(visible) -- If visible is true, when this popup is on the page it will gray out the rest of the page if this is modal Callbacks: setCancelledCallback(callback) -- call this when the dialog is closed through clicking outside, titlebar close button, etc... setHiddenCallback(callback) -- called when the dialog is closed in any fashion Fading: setFadeIn(fadeIn) -- set whether or not to automatically fade the ippu in setFadeOut(fadeOut) -- set whether or not to automatically fade the ippu out setFadeSpeed(secs) -- sets fade speed Class Methods: Handy callbacks: IPPU.center IPPU.centerX IPPU.centerY Browser testing: IPPU.isIE() -- is the browser internet exploder? IPPU.ieSafari() -- is this safari? //////////////////// ippu.setModalDenialCallback(IPPU.cssBorderFlash); private: Properties: ele -- DOM node of div shown -- boolean; if element is in DOM autoCenterX -- boolean; auto-center horiz autoCenterY -- boolean; auto-center vertical fixedPosition -- boolean; stay in fixed position when browser scrolls? titlebar -- titlebar element title -- string; text to go in titlebar showTitlebar -- boolean; whether or not to show titlebar content -- DIV containing user's specified content clickToClose -- boolean; clicking outside popup will close it clickHandlerSetup -- boolean; have we set up the click handlers? docOverlay -- DIV that overlays the document for capturing clicks modal -- boolean; capture all events and prevent user from doing anything until dialog is dismissed visibleOverlay -- boolean; make overlay slightly opaque clickHandlerFunc -- function; function to handle document clicks resizeHandlerFunc -- function; function to handle document resizing autoCenterCallback -- function; what callback to call for auto-centering cancelledCallback -- function; called when dialog is cancelled setAutoHideSelects -- boolean; autohide all SELECT elements on the page when popup is visible hiddenSelects -- array; SELECT elements that have been hidden hiddenCallback -- funciton; called when dialog is hidden fadeIn, fadeOut, fadeSpeed -- fading settings fadeMode -- current fading mode (in, out) if there is fading going on Methods: updateTitlebar() -- create titlebar if it doesn't exist, hide it if titlebar == false, update titlebar text updateContent() -- makes sure all currently specified properties are applied setupClickCapture() -- if modal, create document-sized div overlay to capture click events otherwise install document onclick handler removeClickHandlers() -- remove overlay, event handlers clickHandler() -- event handler for clicks updateOverlay() -- if we have an overlay, make sure it's where it should be and (in)visible if it should be autoCenter() -- centers popup on screen according to autoCenterX and autoCenterY hideSelects() -- hide all select element on page showSelects() -- show all selects _hide () -- actually hides everything, called by hide(), which does fading if necessary */ // this belongs somewhere else: function changeOpac(id, opacity) { var e = $(id); if (e && e.style) { var object = e.style; if (object) { //reduce flicker if (IPPU.isSafari() && opacity >= 100) opacity = 99.99; // IE if (object.filters) object.filters.alpha.opacity = opacity * 100; object.opacity = opacity; } } } IPPU = new Class( Object, { setFixedPosition: function (fixed) { // no fixed position for IE if (IPPU.isIE()) return; this.fixedPosition = fixed; this.updateContent(); }, clickHandler : function (evt) { if (!this.clickToClose) return; if (!this.visible()) return; evt = Event.prep(evt); var target = evt.target; // don't do anything if inside the popup if (DOM.getAncestorsByClassName(target, "ippu", true).length > 0) return; this.cancel(); }, setCancelledCallback : function (callback) { this.cancelledCallback = callback; }, cancel : function () { if (this.cancelledCallback) this.cancelledCallback(); this.hide(); }, setHiddenCallback: function (callback) { this.hiddenCallback = callback; }, setupClickCapture : function () { if (!this.visible() || this.clickHandlerSetup){return;} if (!this.clickToClose && !this.modal) {return;} this.clickHandlerFunc = this.clickHandler.bindEventListener(this); if (this.modal) { // create document-sized div to capture events if (this.overlay) return; // wtf? shouldn't exist yet this.overlay = document.createElement("div"); this.overlay.style.left = "0px"; this.overlay.style.top = "0px"; this.overlay.style.margin = "0px"; this.overlay.style.padding = "0px"; this.overlay.style.backgroundColor = "#000000"; this.overlay.style.zIndex="900"; if (IPPU.isIE()){ this.overlay.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=50)"; this.overlay.style.position="absolute"; this.overlay.style.width=document.body.scrollWidth; this.overlay.style.height=document.body.scrollHeight; } else{ this.overlay.style.position = "fixed"; } this.ele.parentNode.insertBefore(this.overlay, this.ele); this.updateOverlay(); DOM.addEventListener(this.overlay, "click", this.clickHandlerFunc); } else { // simple document onclick handler DOM.addEventListener(document, "click", this.clickHandlerFunc); } this.clickHandlerSetup = true; }, updateOverlay : function () { if (this.overlay) { var cd = DOM.getClientDimensions(); this.overlay.style.width = (cd.x - 1) + "px"; if(!IPPU.isIE()){ this.overlay.style.height = (cd.y - 1) + "px"; } if (this.visibleOverlay) { this.overlay.backgroundColor = "#000000"; changeOpac(this.overlay, 0.50); } else { this.overlay.backgroundColor = "#FFFFFF"; changeOpac(this.overlay, 0.0); } } }, resizeHandler : function (evt) { this.updateContent(); }, removeClickHandlers : function () { if (!this.clickHandlerSetup) return; var myself = this; var handlerFunc = function (evt) { myself.clickHandler(evt); }; DOM.removeEventListener(document, "click", this.clickHandlerFunc, false); if (this.overlay) { DOM.removeEventListener(this.overlay, "click", this.clickHandlerFunc, true); this.overlay.parentNode.removeChild(this.overlay); this.overlay = undefined; } this.clickHandlerFunc = undefined; this.clickHandlerSetup = false; }, setClickToClose : function (clickToClose) { this.clickToClose = clickToClose; if (!this.clickHandlerSetup && clickToClose && this.visible()) { // popup is already visible, need to set up click handler var setupClickCaptureCallback = this.setupClickCapture.bind(this); window.setTimeout(setupClickCaptureCallback, 100); } else if (!clickToClose && this.clickHandlerSetup) { this.removeClickHandlers(); } this.updateContent(); }, setModal : function (modal) { var changed = (this.modal == modal); // if it's modal, we don't want click-to-close if (modal) this.setClickToClose(false); this.modal = modal; if (changed) { this.removeClickHandlers(); this.updateContent(); } }, setOverlayVisible : function (vis) { this.visibleOverlay = vis; this.updateContent(); }, updateContent : function () { this.autoCenter(); this.updateTitlebar(); this.updateOverlay(); if (this.titlebar) this.setTitlebarClass(this.titlebar.className); var setupClickCaptureCallback = this.setupClickCapture.bind(this); window.setTimeout(setupClickCaptureCallback, 100); if (this.fixedPosition && this.ele.style.position != "fixed") this.ele.style.position = "fixed"; else if (!this.fixedPosition && this.ele.style.position == "fixed") this.ele.style.position = "absolute"; }, getTitlebarElement : function () { return this.titlebar; }, setTitlebarClass : function (className) { if (this.titlebar) this.titlebar.className = className; }, setOverflow : function (overflow) { if (this.ele) this.ele.style.overflow = overflow; }, visible : function () { return this.shown; }, setTitlebar : function (show) { this.showTitlebar = show; if (show) { if (!this.titlebar) { // titlebar hasn't been created. Create it. var tbar = document.createElement("div"); if (!tbar) return; tbar.style.width = "100%"; if (this.title) tbar.innerHTML = this.title; this.ele.insertBefore(tbar, this.content); this.titlebar = tbar; } } else if (this.titlebar) { this.ele.removeChild(this.titlebar); this.titlebar = false; } }, setTitle : function (title) { this.title = title; this.updateTitlebar(); }, updateTitlebar : function() { if (this.showTitlebar && this.titlebar && this.title != this.titlebar.innerHTML) { this.titlebar.innerHTML = this.title; } }, addClass : function (className) { DOM.addClassName(this.ele, className); }, removeClass : function (className) { DOM.removeClassName(this.ele, className); }, setAutoCenterCallback : function (callback) { this.autoCenterCallback = callback; }, autoCenter : function () { if (!this.visible || !this.visible()) return; if (this.autoCenterCallback) { this.autoCenterCallback(this); return; } if (this.autoCenterX) this.centerX(); if (this.autoCenterY) this.centerY(); }, center : function () { this.centerX(); this.centerY(); }, centerOnWidget : function (widget, offsetTop, offsetLeft) { offsetTop = offsetTop || 0; offsetLeft = offsetLeft || 0; this.setAutoCenter(false, false); this.setAutoCenterCallback(null); var wd = DOM.getAbsoluteDimensions(widget); var ed = DOM.getAbsoluteDimensions(this.ele); var newleft = (wd.absoluteRight - wd.offsetWidth / 2 - ed.offsetWidth / 2) + offsetLeft; var newtop = (wd.absoluteBottom - wd.offsetHeight / 2 - ed.offsetHeight / 2) + offsetTop; newleft = newleft < 0 ? 0 : newleft; newtop = newtop < 0 ? 0 : newtop; DOM.setLeft(this.ele, newleft); DOM.setTop(this.ele, newtop); }, centerX : function () { if (!this.visible || !this.visible()) return; var cd = DOM.getClientDimensions(); var newleft = cd.x / 2 - this.ele.offsetWidth / 2; // If not fixed position, center relative to the left of the page if (!this.fixedPosition) { var wd = DOM.getWindowScroll(); newleft += wd.left; } DOM.setLeft(this.ele, newleft); }, centerY : function () { if (!this.visible || !this.visible()) return; var cd = DOM.getClientDimensions(); var newtop = cd.y / 2 - this.ele.offsetHeight / 2; // If not fixed position, center relative to the top of the page if (!this.fixedPosition) { var wd = DOM.getWindowScroll(); newtop += wd.top; } DOM.setTop(this.ele, newtop); }, setAutoCenter : function (autoCenterX, autoCenterY) { this.autoCenterX = autoCenterX || false; this.autoCenterY = autoCenterY || false; if (!autoCenterX && !autoCenterY) { this.setAutoCenterCallback(null); return; } this.autoCenter(); }, setDimensions : function (width, height) { width = width + ""; height = height + ""; if (width.match(/^\d+$/)) width += "px"; if (height.match(/^\d+$/)) height += "px"; this.ele.style.width = width; this.ele.style.height = height; }, moveForward : function (howMuch) { if (!howMuch) howMuch = 1; if (! this.ele) return; this.ele.style.zIndex += howMuch; }, moveBackward : function (howMuch) { if (!howMuch) howMuch = 1; if (! this.ele) return; this.ele.style.zIndex -= howMuch; }, setLocation : function (left, top) { this.setLeft(left); this.setTop(top); }, setTop : function (top) { if (typeof top != 'string') top += 'px'; this.ele.style.top = top; }, setLeft : function (left) { if (typeof left != 'string') left += 'px'; this.ele.style.left = left; }, getElement : function () { return this.ele; }, setContent : function (html) { this.content.innerHTML = html; }, setContentElement : function (element) { // remove child nodes while (this.content.firstChild) { this.content.removeChild(this.content.firstChild); }; this.content.appendChild(element); }, setFadeIn : function (fadeIn) { this.fadeIn = fadeIn; }, setFadeOut : function (fadeOut) { this.fadeOut = fadeOut; }, setFadeSpeed : function (fadeSpeed) { this.fadeSpeed = fadeSpeed; }, show : function () { this.shown = true; if (this.fadeIn) { var opp = 0.01; changeOpac(this.ele, opp); } document.body.appendChild(this.ele); this.ele.style.position = "absolute"; if (this.autoCenterX || this.autoCenterY) this.center(); this.updateContent(); if (!this.resizeHandlerFunc) { this.resizeHandlerFunc = this.resizeHandler.bindEventListener(this); DOM.addEventListener(window, "resize", this.resizeHandlerFunc, false); } if (this.fadeIn) this.fade("in"); this.hideSelects(); }, fade : function (mode, callback) { var opp; var delta; var steps = 10.0; if (mode == "in") { delta = 1 / steps; opp = 0.1; } else { if (this.ele.style.opacity) opp = finiteFloat(this.ele.style.opacity); else opp = 0.99; delta = -1 / steps; } var fadeSpeed = this.fadeSpeed; if (!fadeSpeed) fadeSpeed = 1; var fadeInterval = steps / fadeSpeed * 5; this.fadeMode = mode; var self = this; var fade = function () { opp += delta; // did someone start a fade in the other direction? if so, // cancel this fade if (self.fadeMode && self.fadeMode != mode) { if (callback) callback.call(self, []); return; } if (opp <= 0.1) { if (callback) callback.call(self, []); self.fadeMode = null; return; } else if (opp >= 1.0) { if (callback) callback.call(self, []); self.fadeMode = null; return; } else { changeOpac(self.ele, opp); window.setTimeout(fade, fadeInterval); } }; fade(); }, hide : function () { if (! this.visible()) return; if (this.fadeOut && this.ele) { this.fade("out", this._hide.bind(this)); } else { this._hide(); } }, _hide : function () { if (this.hiddenCallback) this.hiddenCallback(); this.shown = false; this.removeClickHandlers(); if (this.ele) document.body.removeChild(this.ele); if (this.resizeHandlerFunc) DOM.removeEventListener(window, "resize", this.resizeHandlerFunc); this.showSelects(); }, // you probably want this for IE being dumb // (IE thinks select elements are cool and puts them in front of every element on the page) setAutoHideSelects : function (autohide) { this.autoHideSelects = autohide; this.updateContent(); }, hideSelects : function () { if (!this.autoHideSelects || !IPPU.isIE()) return; var sels = document.getElementsByTagName("select"); var ele; for (var i = 0; i < sels.length; i++) { ele = sels[i]; if (!ele) continue; // if this element is inside the ippu, skip it if (DOM.getAncestorsByClassName(ele, "ippu", true).length > 0) continue; if (ele.style.visibility != 'hidden') { ele.style.visibility = 'hidden'; this.hiddenSelects.push(ele); } } }, showSelects : function () { if (! this.autoHideSelects) return; var ele; while (ele = this.hiddenSelects.pop()) ele.style.visibility = ''; }, init: function (html) { var ele = document.createElement("div"); this.ele = ele; this.shown = false; this.autoCenterX = false; this.autoCenterY = false; this.titlebar = null; this.title = ""; this.showTitlebar = false; this.clickToClose = false; this.modal = false; this.clickHandlerSetup = false; this.docOverlay = false; this.visibleOverlay = false; this.clickHandlerFunc = false; this.resizeHandlerFunc = false; this.fixedPosition = false; this.autoCenterCallback = null; this.cancelledCallback = null; this.autoHideSelects = false; this.hiddenCallback = null; this.fadeOut = false; this.fadeIn = false; this.hiddenSelects = []; this.fadeMode = null; ele.style.position = "absolute"; ele.style.top = 0; ele.style.zIndex = "1000"; // plz don't remove thx DOM.addClassName(ele, "ippu"); // create DIV to hold user's content this.content = document.createElement("div"); this.content.innerHTML = html; this.ele.appendChild(this.content); } }); // class methods IPPU.center = function (obj) { obj.centerX(); obj.centerY(); }; IPPU.centerX = function (obj) { obj.centerX(); }; IPPU.centerY = function (obj) { obj.centerY(); }; IPPU.isIE = function () { var UA = navigator.userAgent.toLowerCase(); if (UA.indexOf('msie') != -1) return true; return false; }; IPPU.isSafari = function () { var UA = navigator.userAgent.toLowerCase(); if (UA.indexOf('safari') != -1) return true; return false; }; LJ_IPPU = new Class ( IPPU, { init: function(title) { if (!title) title = ""; LJ_IPPU.superClass.init.apply(this, []); this.uniqId = this.generateUniqId(); this.cancelThisFunc = this.cancel.bind(this); this.setTitle(title); this.setTitlebar(true); this.setTitlebarClass("lj_ippu_titlebar"); this.addClass("lj_ippu"); this.setAutoCenterCallback(IPPU.center); this.setDimensions(514, "auto"); //this.setOverflow("hidden"); this.setFixedPosition(true); this.setClickToClose(true); this.setAutoHideSelects(true); }, setTitle: function (title) { var titlebarContent = "\
" + "
" + title; LJ_IPPU.superClass.setTitle.apply(this, [titlebarContent]); }, generateUniqId: function() { var theDate = new Date(); return "lj_ippu_" + theDate.getHours() + theDate.getMinutes() + theDate.getMilliseconds(); }, show: function() { LJ_IPPU.superClass.show.apply(this); var setupCallback = this.setup_lj_ippu.bind(this); this.timerSetup = window.setTimeout(setupCallback, 300); }, setup_lj_ippu: function (evt) { var cancelCallback = this.cancelThisFunc; $(this.uniqId + "_cancel").onclick = function(){ cancelCallback(); }; }, hide: function() { clearInterval(this.timerSetup); LJ_IPPU.superClass.hide.apply(this); } } ); // Class method to show a popup to show a note to the user // note = message to show // underele = element to display the note underneath LJ_IPPU.showNote = function (note, underele, timeout, style) { var noteElement = document.createElement("div"); noteElement.innerHTML = note; return LJ_IPPU.showNoteElement(noteElement, underele, timeout, style); }; LJ_IPPU.showErrorNote = function (note, underele, timeout) { return LJ_IPPU.showNote(note, underele, timeout, "ErrorNote"); }; LJ_IPPU.showNoteElement = function (noteEle, underele, timeout, style) { var notePopup = new IPPU(); notePopup.init(); var inner = document.createElement("div"); DOM.addClassName(inner, "Inner"); inner.appendChild(noteEle); notePopup.setContentElement(inner); notePopup.setTitlebar(false); notePopup.setFadeIn(true); notePopup.setFadeOut(true); notePopup.setFadeSpeed(4); notePopup.setDimensions("auto", "auto"); if (!style) style = "Note"; notePopup.addClass(style); var dim; if (underele) { // pop up the box right under the element dim = DOM.getAbsoluteDimensions(underele); if (!dim) return; } var bounds = DOM.getClientDimensions(); if (!bounds) return; if (!dim) { // no element specified to pop up on, show in the middle // notePopup.setModal(true); // notePopup.setOverlayVisible(true); notePopup.setAutoCenter(true, true); notePopup.show(); } else { // default is to auto-center, don't want that notePopup.setAutoCenter(false, false); notePopup.setLocation(dim.absoluteLeft, dim.absoluteBottom + 4); notePopup.show(); var popupBounds = DOM.getAbsoluteDimensions(notePopup.getElement()); if (popupBounds.absoluteRight > bounds.x) { notePopup.setLocation(bounds.x - popupBounds.offsetWidth - 30, dim.absoluteBottom + 4); } } notePopup.setClickToClose(true); notePopup.moveForward(); if (timeout === undefined) { timeout = 5000; } if (timeout) { window.setTimeout(function () { if (notePopup) notePopup.hide(); }, timeout); } return notePopup; }; LJ_IPPU.textPrompt = function (title, prompt, callback, options) { options = options || {}; title += ''; var notePopup = new LJ_IPPU(title); var inner = document.createElement("div"); DOM.addClassName(inner, "ljippu_textprompt"); // label if (prompt) inner.appendChild(_textDiv(prompt)); // text field var field = document.createElement("textarea"); DOM.addClassName(field, "htmlfield"); field.cols = 40; field.rows = 5; inner.appendChild(field); // submit btn var btncont = document.createElement("div"); DOM.addClassName(btncont, "submitbtncontainer"); var btn = document.createElement("input"); DOM.addClassName(btn, "submitbtn"); btn.type = "button"; btn.value = "Insert"; btncont.appendChild(btn); inner.appendChild(btncont); notePopup.setContentElement(inner); notePopup.setAutoCenter(true, true); notePopup.setDimensions(options.width || "60%", "auto"); notePopup.show(); field.focus(); DOM.addEventListener(btn, "click", function (e) { notePopup.hide(); if (callback) callback.apply(null, [field.value]); }); } LJWidget = new Class(Object, { // replace the widget contents with an ajax call to render with params updateContent: function (params) { if (! params) params = {}; this._show_frame = params["showFrame"]; if ( params["method"] ) method = params["method"]; params["_widget_update"] = 1; if (this.doAjaxRequest(params)) { // hilight the widget to show that its updating this.hilightFrame(); } }, // returns the widget element getWidget: function () { return $(this.widgetId); }, // do a simple post to the widget doPost: function (params) { if (! params) params = {}; this._show_frame = params["showFrame"]; var postParams = {}; var classPrefix = this.widgetClass; classPrefix = "Widget[" + classPrefix.replace(/::/g, "_") + "]_"; for (var k in params) { var class_k = k; if (! k.match(/^Widget\[/) && k != 'lj_form_auth' && ! k.match(/^_widget/)) { class_k = classPrefix + k; } postParams[class_k] = params[k]; } postParams["_widget_post"] = 1; this.doAjaxRequest(postParams); }, doPostAndUpdateContent: function (params) { if (! params) params = {}; params["_widget_update"] = 1; this.doPost(params); }, // do an ajax post of the form passed in postForm: function (formElement) { if (! formElement) return false; var params = {}; for (var i=0; i < formElement.elements.length; i++) { var element = formElement.elements[i]; var name = element.name; var value = element.value; params[name] = value; } this.doPost(params); }, ///////////////// PRIVATE METHODS //////////////////// init: function (id, widgetClass, authToken) { LJWidget.superClass.init.apply(this, arguments); this.widgetId = id; this.widgetClass = widgetClass; this.authToken = authToken; }, hilightFrame: function () { if (this._show_frame != 1) return; if (this._frame) return; var widgetEle = this.getWidget(); if (! widgetEle) return; var widgetParent = widgetEle.parentNode; if (! widgetParent) return; var enclosure = document.createElement("fieldset"); enclosure.style.borderColor = "red"; var title = document.createElement("legend"); title.innerHTML = "Updating..."; enclosure.appendChild(title); widgetParent.appendChild(enclosure); enclosure.appendChild(widgetEle); this._frame = enclosure; }, removeHilightFrame: function () { if (this._show_frame != 1) return; var widgetEle = this.getWidget(); if (! widgetEle) return; if (! this._frame) return; var par = this._frame.parentNode; if (! par) return; par.appendChild(widgetEle); par.removeChild(this._frame); this._frame = null; }, method: "POST", endpoint: "widget", requestParams: {}, doAjaxRequest: function (params) { if (! params) params = {}; if (this._ajax_updating) return false; this._ajax_updating = true; params["_widget_id"] = this.widgetId; params["_widget_class"] = this.widgetClass; params["auth_token"] = this.authToken; if ($('_widget_authas')) { params["authas"] = $('_widget_authas').value; } var reqOpts = { method: this.method, data: HTTPReq.formEncoded(params), url: LiveJournal.getAjaxUrl(this.endpoint), onData: this.ajaxDone.bind(this), onError: this.ajaxError.bind(this) }; for (var k in params) { reqOpts[k] = params[k]; } HTTPReq.getJSON(reqOpts); return true; }, ajaxDone: function (data) { this._ajax_updating = false; this.removeHilightFrame(); if (data["_widget_body"]) { if (data["_widget_body"].match(/ajax:.[^"]+/)) { this.authToken = data["_widget_body"].match(/ajax:.[^"]+/)[0]; } } if (data.auth_token) { this.authToken = data.auth_token; } if (data.errors && data.errors != '') { return this.ajaxError(data.errors); } if (data.error) { return this.ajaxError(data.error); } // call callback if one exists if (this.onData) { this.onData(data); } if (data["_widget_body"]) { // did an update request, got the new body back var widgetEle = this.getWidget(); if (! widgetEle) { // widget is gone, ignore return; } widgetEle.innerHTML = data["_widget_body"]; if (this.onRefresh) { this.onRefresh(); } } }, ajaxError: function (err) { this._ajax_updating = false; if (this.onError) { // use class error handler this.onError(err); } else { // use generic error handler LiveJournal.ajaxError(err); } } }); LJWidget.widgets = []; LJWidgetIPPU = new Class(LJWidget, { init: function (opts, reqParams) { var title = opts.title; var widgetClass = opts.widgetClass; var authToken = opts.authToken; var nearEle = opts.nearElement; var not_view_close = opts.not_view_close; if (! reqParams) reqParams = {}; this.reqParams = reqParams; // construct a container ippu for this widget var ippu = new LJ_IPPU(title, nearEle); this.ippu = ippu; var c = document.createElement("div"); c.id = "LJWidgetIPPU_" + Unique.id(); ippu.setContentElement(c); if (opts.width && opts.height) ippu.setDimensions(opts.width, opts.height); if (opts.overlay) { if (IPPU.isIE()) { this.ippu.setModal(true); this.ippu.setOverlayVisible(true); this.ippu.setClickToClose(false); } else { this.ippu.setModal(true); this.ippu.setOverlayVisible(true); } } if (opts.center) ippu.center(); ippu.show(); if (not_view_close) ippu.titlebar.getElementsByTagName('img')[0].style.display = 'none'; var loadingText = document.createElement("div"); loadingText.style.fontSize = '1.5em'; loadingText.style.fontWeight = 'bold'; loadingText.style.margin = '5px'; loadingText.style.textAlign = 'center'; loadingText.innerHTML = "Loading..."; this.loadingText = loadingText; c.appendChild(loadingText); // id, widgetClass, authToken var widgetArgs = [c.id, widgetClass, authToken] LJWidgetIPPU.superClass.init.apply(this, widgetArgs); var self = this; ippu.setCancelledCallback( function() { if( self.cancel ) { self.cancel(); } } ); if (!widgetClass) return null; this.widgetClass = widgetClass; this.authToken = authToken; this.title = title; this.nearEle = nearEle; window.setInterval(this.animateLoading.bind(this), 20); this.loaded = false; // start request for this widget now this.loadContent(); return this; }, animateCount: 0, animateLoading: function (i) { var ele = this.loadingText; if (this.loaded || ! ele) { window.clearInterval(i); return; } this.animateCount += 0.05; var intensity = ((Math.sin(this.animateCount) + 1) / 2) * 255; var hexColor = Math.round(intensity).toString(16); if (hexColor.length == 1) hexColor = "0" + hexColor; hexColor += hexColor + hexColor; ele.style.color = "#" + hexColor; this.ippu.center(); }, // override doAjaxRequest to add _widget_ippu = 1 doAjaxRequest: function (params) { if (! params) params = {}; params['_widget_ippu'] = 1; if(document.getElementById("LJ__Setting__InvisibilityGuests_invisibleguests_self")){ params['Widget[IPPU_SettingProd]_LJ__Setting__InvisibilityGuests_invisibleguests']= (document.getElementById("LJ__Setting__InvisibilityGuests_invisibleguests_self").checked==true)?(1):((document.getElementById("LJ__Setting__InvisibilityGuests_invisibleguests_anon").checked==true)?(2):(0)) } LJWidgetIPPU.superClass.doAjaxRequest.apply(this, [params]); }, close: function () { this.ippu.hide(); }, loadContent: function () { var reqOpts = this.reqParams; this.updateContent(reqOpts); }, method: "POST", // request finished onData: function (data) { this.loaded = true; }, render: function (params) { } }); ILikeThis = { dialog: jQuery(), dialogRemove: function() { this.dialog.remove(); jQuery(document).unbind('click', this.document_click); }, // inline click rate: function(e, node, itemid, username) { var click = node.onclick; node.onclick = function(){ return false } // has undorate node var action = jQuery('.i_like_this_'+itemid+' .i_like_this_already').remove().length ? 'undorate' : 'rate'; jQuery(node).parent().removeClass('i_dont_like_this'); jQuery.ajax({ url: LiveJournal.getAjaxUrl('eventrate'), data: { action: action, journal: username, itemid: itemid }, type: 'POST', dataType: 'json', complete: function() { node.onclick = click; }, success: function(data) { if (data.status === 'OK') { var append_node = jQuery('.we_like_this_'+itemid+' span>span>span'); if (!append_node.length) { // s1 append_node = jQuery('.we_like_this_'+itemid); } append_node.text(data.total); if (action == 'rate') { var context = jQuery('.i_like_this_'+itemid).addClass('i_dont_like_this'), append_node = context.find('span>span>span'); if (!append_node.length) { // s1 append_node = jQuery(context); } append_node.append('/'); } } } }); return false; }, // inline click showList: function(e, node, itemid, username) { this.ajax && this.ajax.abort(); this.ajax = jQuery.ajax({ url: LiveJournal.getAjaxUrl('eventrate'), data: { action: 'list', journal: username, itemid: itemid, limit: 10 }, type: 'POST', dataType: 'json', success: function(data) { $node = jQuery(node); if (data.status === 'OK') { ILikeThis.dialog.remove(); ILikeThis.dialog = jQuery('
', { 'class': 'b-popup b-popup-messagebox b-popup-ilikethis', css: {top: 0, visibility: 'hidden'}, html: '
' +'

'+data.ml_users_who_like_it+' ('+data.total+')

' +'
' +'
' +'

' +data.result +'

' +'
' +(data.total > 10 ? '') }).ljAddContextualPopup(); ILikeThis.dialog.appendTo(document.body); //calc with viewport var ele_offset = $node.offset(), left = ele_offset.left, top = ele_offset.top + $node.height() + 0, // TODO: 4 is fix markup height $window = jQuery(window); left = Math.min(left, $window.width() + $window.scrollLeft() - ILikeThis.dialog.outerWidth(true)); top = Math.min(top, $window.height() + $window.scrollTop() - ILikeThis.dialog.outerHeight(true)); jQuery(document).click(ILikeThis.document_click); ILikeThis.dialog.css({ left: left, top: top, visibility: 'visible' }); var append_node = jQuery('.we_like_this_'+itemid+' span>span>span'); if (!append_node.length) { // s1 append_node = jQuery('.we_like_this_'+itemid); } append_node.text(data.total); } } }); return false; }, document_click: function(e) { if (!jQuery(e.target).parents('.b-popup-ilikethis').length) { ILikeThis.dialogRemove(); } } } DonateButton = { buyMore: function(node, ml_message, event) { var bubble = jQuery(node).data("buyMoreCachedBubble"); if (!bubble) { bubble = jQuery("" + ml_message + "").bubble({ target: node }); jQuery(node).data("buyMoreCachedBubble", bubble); } bubble.bubble("show"); event.stopPropagation ? event.stopPropagation() : (event.cancelBubble=true); return false; }, donate: function( link, url_data, event ) { var url = link.href, origin, h; var width = 639; var height = 230; jQuery.rpc.bind( function( ev ) { if( ev.origin && ev.origin != Site.siteroot ) { return; } if( ev.data === "updateWallet" ) { LiveJournal.run_hook( 'update_wallet_balance' ); jQuery.getJSON( LiveJournal.getAjaxUrl( 'give_tokens' ) + "?" + url_data + "&mode=js", function( result ) { if( result.html ) { $node = jQuery( link ).closest( '.lj-button' ); $node.replaceWith( result.html ); } } ); } } ); var popupUrl = url + ( url.indexOf( "?" ) === -1 ? "?" : "&" ) + 'usescheme=nonavigation'; h = window.open( 'about:blank', 'donate' , 'toolbar=0,status=0,width=' + width + ',height=' + height + ',scrollbars=yes,resizable=yes'); h.name = location.href.replace( /#.*$/, '' ); setTimeout( function() { jQuery.rpc.initRecipient( h, popupUrl, location.href.replace( /#.*$/, '' ) ); }, 0 ); event.stopPropagation ? event.stopPropagation() : (event.cancelBubble=true); return false; } }; // Share at some S2 styles jQuery(document).click(function(e) { var a = e.target, href = a.href, args; if (href && !a.shareClickIgnore) { if (href.indexOf('http://www.facebook.com/sharer.php') === 0) { LJShare.entry({url: decodeURIComponent(LiveJournal.parseGetArgs(href).u)}) .attach(a, "facebook"); a.shareClickIgnore = true; jQuery(a).click(); e.preventDefault(); } else if (href.indexOf("http://twitter.com/share") === 0) { args = LiveJournal.parseGetArgs(href); LJShare.entry({ url: decodeURIComponent(args.url), title: decodeURIComponent(args.text) }).attach(a, "twitter"); a.shareClickIgnore = true; jQuery(a).click(); e.preventDefault(); } else if (href.indexOf("http://api.addthis.com/oexchange/0.8/forward/email") === 0) { args = LiveJournal.parseGetArgs(href); LJShare.entry({ url: decodeURIComponent(args.url), title: decodeURIComponent(args.title) }).attach(a, "email"); a.shareClickIgnore = true; jQuery(a).click(); e.preventDefault(); } } }); (function() { var options = { blockSelector: '.yota-contest' }; function retrieveContestInfo( element ) { var journal = element.attr( 'data-user' ); jQuery.getJSON( LiveJournal.getAjaxUrl( 'yota_widget_post' ), { json: 1, journal: journal }, function( answer ) { if( 'collected' in answer ) { var collected = answer.collected; for( var i = 0; i < collected.length; i += 2 ) { element.find( "." + collected[ i ] ).html( collected[ i + 1 ] ); } } if( 'rating' in answer ) { i = 5; var key; while( --i > 0) { key = "" + i; if( key in answer.rating ) { element.find( '.c' + i ).html( answer.rating[ key ] ); } } } } ); } function findElement() { var element = jQuery( options.blockSelector ); if( element.length ) { element.each( function() { retrieveContestInfo( jQuery( this ) ); } ); } } jQuery( function() { findElement(); } ); } )(); // LiveJournal javascript standard interface routines // create a little animated hourglass at (x,y) with a unique-ish ID // returns the element created Hourglass = new Class( Object, { init: function(widget, classname) { this.ele = document.createElement("img"); if (!this.ele) return; var imgprefix = Site ? Site.imgprefix : ''; this.ele.src = imgprefix ? imgprefix + "/hourglass.gif" : "/img/hourglass.gif"; this.ele.style.position = "absolute"; DOM.addClassName(this.ele, classname); if (widget) this.hourglass_at_widget(widget); }, hourglass_at: function (x, y) { this.ele.width = 17; this.ele.height = 17; this.ele.style.top = (y - 8) + "px"; this.ele.style.left = (x - 8) + "px"; // unique ID this.ele.id = "lj_hourglass" + x + "." + y; document.body.appendChild(this.ele); }, add_class_name: function (classname) { if (this.ele) DOM.addClassName(this.ele, classname); }, hourglass_at_widget: function (widget) { var dim = DOM.getAbsoluteDimensions(widget); var x = dim.absoluteLeft; var y = dim.absoluteTop; var w = dim.absoluteRight - x; var h = dim.absoluteBottom - y; if (w && h) { x += w/2; y += h/2; } this.hourglass_at(x, y); }, hide: function () { if (this.ele) { try { document.body.removeChild(this.ele); } catch (e) {} } } } ); // ljtalk for ctxpopup LiveJournal.register_hook("ctxpopup_extrainfo", function (userdata) { var content = ''; if (userdata.is_person) { if (userdata.is_online !== null) { content = '' + userdata.ml_ljtalk + ''; if (userdata.is_online) { content += " " + userdata.ml_online; } else if (userdata.is_online == '0') { content += " " + userdata.ml_offline; } } } return content; }); // for updating ljcom widgets from livejournal ones LiveJournal.register_hook("update_other_widgets", function (from_widget) { if (from_widget == "LayoutChooser" && Customize.AdLayout) { Customize.AdLayout.updateContent(); } }); QuickReply = { lastDiv: 'qrdiv', reply: function(dtid, pid, newsubject) { var targetname = 'ljqrt' + dtid, qr_ptid = $('parenttalkid'), qr_rto = $('replyto'), qr_dtid = $('dtid'), qr_div = $('qrdiv'), cur_div = $(targetname), qr_form_div = $('qrformdiv'), qr_form = $('qrform'), subject = $('subject'); // Is this a dumb browser? if (!qr_ptid || !qr_rto || !qr_dtid || !qr_div || !cur_div || !qr_form || !qr_form_div || !subject) { return true; } qr_ptid.value = pid; qr_dtid.value = dtid; qr_rto.value = pid; if (QuickReply.lastDiv == 'qrdiv') { qr_div.style.display = 'inline'; // Only one swap cur_div.parentNode.insertBefore(qr_div, cur_div); } else if (QuickReply.lastDiv != dtid) { cur_div.parentNode.insertBefore(qr_div, cur_div); } QuickReply.lastDiv = targetname; if (!subject.value || subject.value == subject.defaultValue || subject.value.substr(0, 4) == 'Re: ') { subject.value = newsubject; subject.defaultValue = newsubject; } qr_form_div.className = cur_div.className || ''; // have to set a timeout because most browsers won't let you focus // on an element that's still in the process of being created. // so lame. window.setTimeout(function(){ qr_form.body.focus() }, 100); return false; }, more: function() { var qr_form = $('qrform'), basepath = $('basepath'), dtid = $('dtid'), pidform = $('parenttalkid'); // do not do the default form action (post comment) if something is broke if (!qr_form || !basepath || !dtid || !pidform) { return false; } if(dtid.value > 0 && pidform.value > 0) { //a reply to a comment qr_form.action = basepath.value + "replyto=" + dtid.value + "#add_comment"; } else { qr_form.action = basepath.value + "mode=reply#add_comment"; } // we changed the form action so submit ourselves // and don't use the default form action qr_form.submit(); return false; }, submit: function() { var submitmore = $('submitmoreopts'), submit = $('submitpost'); if (!submitmore || !submit) { return false; } submit.disabled = true; submitmore.disabled = true; // New top-level comments var dtid = $('dtid'); if (!Number(dtid.value)) { dtid.value =+ 0; } var qr_form = $('qrform'); qr_form.action = Site.siteroot + '/talkpost_do.bml'; qr_form.submit(); // don't do default form action return false; }, check: function() { var qr_form = $('qrform'); if (!qr_form) return true; var len = qr_form.body.value.length; if (len > 4300) { alert('Sorry, but your comment of ' + len + ' characters exceeds the maximum character length of 4300. Please try shortening it and then post again.'); return false; } return true; }, // Maintain entry through browser navigations. save: function() { var qr_form = $('qrform'); if (!qr_form) { return false; } var do_spellcheck = $('do_spellcheck'), qr_upic = $('prop_picture_keyword'); $('saved_body').value = qr_form.body.value; $('saved_subject').value = $('subject').value; $('saved_dtid').value = $('dtid').value; $('saved_ptid').value = $('parenttalkid').value; if (do_spellcheck) { $('saved_spell').value = do_spellcheck.checked; } if (qr_upic) { // if it was in the form $('saved_upic').value = qr_upic.selectedIndex; } return false; }, // Restore saved_entry text across platforms. restore: function() { setTimeout(function(){ var saved_body = $('saved_body'), dtid = $('saved_dtid'), subject = $('saved_subject'), subject_str = '', qr_form = $('qrform'); if (!saved_body || saved_body.value == '' || !qr_form || !dtid) { return; } if (subject) { subject_str = subject.value; } QuickReply.reply(dtid.value, parseInt($('saved_ptid').value, 10), subject_str); qr_form.body.value = saved_body.value; // if it was in the form var upic = $('prop_picture_keyword'); if (upic) { upic.selectedIndex = $('saved_upic').value; } var spellcheck = $('do_spellcheck'); if (spellcheck) { spellcheck.checked = $('saved_spell').value == 'true'; } }, 100); }, userpicSelect: function() { var ups = new UserpicSelect(); ups.init(); ups.setPicSelectedCallback(function(picid, keywords) { var kws_dropdown = $('prop_picture_keyword'); if (kws_dropdown) { var items = kws_dropdown.options; // select the keyword in the dropdown keywords.forEach(function(kw) { for (var i = 0; i < items.length; i++) { var item = items[i]; if (item.value == kw) { kws_dropdown.selectedIndex = i; return; } } }); } }); ups.show(); } } jQuery(QuickReply.restore); DOM.addEventListener(window, 'unload', QuickReply.save); /* * md5.jvs 1.0b 27/06/96 * * Javascript implementation of the RSA Data Security, Inc. MD5 * Message-Digest Algorithm. * * Copyright (c) 1996 Henri Torgemane. All Rights Reserved. * * Permission to use, copy, modify, and distribute this software * and its documentation for any purposes and without * fee is hereby granted provided that this copyright notice * appears in all copies. * * Of course, this soft is provided "as is" without express or implied * warranty of any kind. */ function array(n) { for(i=0;i> 4 with it.. * Of course, these functions are slower than the original would be, but * at least, they work! */ function integer(n) { return n%(0xffffffff+1); } function shr(a,b) { a=integer(a); b=integer(b); if (a-0x80000000>=0) { a=a%0x80000000; a>>=b; a+=0x40000000>>(b-1); } else a>>=b; return a; } function shl1(a) { a=a%0x80000000; if (a&0x40000000==0x40000000) { a-=0x40000000; a*=2; a+=0x80000000; } else a*=2; return a; } function shl(a,b) { a=integer(a); b=integer(b); for (var i=0;i=0) if (t2>=0) return ((t1&t2)+0x80000000); else return (t1&b); else if (t2>=0) return (a&t2); else return (a&b); } function or(a,b) { a=integer(a); b=integer(b); var t1=(a-0x80000000); var t2=(b-0x80000000); if (t1>=0) if (t2>=0) return ((t1|t2)+0x80000000); else return ((t1|b)+0x80000000); else if (t2>=0) return ((a|t2)+0x80000000); else return (a|b); } function xor(a,b) { a=integer(a); b=integer(b); var t1=(a-0x80000000); var t2=(b-0x80000000); if (t1>=0) if (t2>=0) return (t1^t2); else return ((t1^b)+0x80000000); else if (t2>=0) return ((a^t2)+0x80000000); else return (a^b); } function not(a) { a=integer(a); return (0xffffffff-a); } /* Here begin the real algorithm */ var state = new array(4); var count = new array(2); count[0] = 0; count[1] = 0; var buffer = new array(64); var transformBuffer = new array(16); var digestBits = new array(16); var S11 = 7; var S12 = 12; var S13 = 17; var S14 = 22; var S21 = 5; var S22 = 9; var S23 = 14; var S24 = 20; var S31 = 4; var S32 = 11; var S33 = 16; var S34 = 23; var S41 = 6; var S42 = 10; var S43 = 15; var S44 = 21; function F(x,y,z) { return or(and(x,y),and(not(x),z)); } function G(x,y,z) { return or(and(x,z),and(y,not(z))); } function H(x,y,z) { return xor(xor(x,y),z); } function I(x,y,z) { return xor(y ,or(x , not(z))); } function rotateLeft(a,n) { return or(shl(a, n),(shr(a,(32 - n)))); } function FF(a,b,c,d,x,s,ac) { a = a+F(b, c, d) + x + ac; a = rotateLeft(a, s); a = a+b; return a; } function GG(a,b,c,d,x,s,ac) { a = a+G(b, c, d) +x + ac; a = rotateLeft(a, s); a = a+b; return a; } function HH(a,b,c,d,x,s,ac) { a = a+H(b, c, d) + x + ac; a = rotateLeft(a, s); a = a+b; return a; } function II(a,b,c,d,x,s,ac) { a = a+I(b, c, d) + x + ac; a = rotateLeft(a, s); a = a+b; return a; } function transform(buf,offset) { var a=0, b=0, c=0, d=0; var x = transformBuffer; a = state[0]; b = state[1]; c = state[2]; d = state[3]; for (i = 0; i < 16; i++) { x[i] = and(buf[i*4+offset],0xff); for (j = 1; j < 4; j++) { x[i]+=shl(and(buf[i*4+j+offset] ,0xff), j * 8); } } /* Round 1 */ a = FF ( a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ d = FF ( d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ c = FF ( c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ b = FF ( b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ a = FF ( a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ d = FF ( d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ c = FF ( c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ b = FF ( b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ a = FF ( a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ d = FF ( d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ c = FF ( c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ b = FF ( b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ a = FF ( a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ d = FF ( d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ c = FF ( c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ b = FF ( b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ /* Round 2 */ a = GG ( a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ d = GG ( d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ c = GG ( c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ b = GG ( b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ a = GG ( a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ d = GG ( d, a, b, c, x[10], S22, 0x2441453); /* 22 */ c = GG ( c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ b = GG ( b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ a = GG ( a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ d = GG ( d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ c = GG ( c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ b = GG ( b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ a = GG ( a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ d = GG ( d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ c = GG ( c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ b = GG ( b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ /* Round 3 */ a = HH ( a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ d = HH ( d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ c = HH ( c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ b = HH ( b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ a = HH ( a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ d = HH ( d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ c = HH ( c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ b = HH ( b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ a = HH ( a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ d = HH ( d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ c = HH ( c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ b = HH ( b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ a = HH ( a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ d = HH ( d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ c = HH ( c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ b = HH ( b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ /* Round 4 */ a = II ( a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ d = II ( d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ c = II ( c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ b = II ( b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ a = II ( a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ d = II ( d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ c = II ( c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ b = II ( b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ a = II ( a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ d = II ( d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ c = II ( c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ b = II ( b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ a = II ( a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ d = II ( d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ c = II ( c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ b = II ( b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ state[0] +=a; state[1] +=b; state[2] +=c; state[3] +=d; } function init() { count[0]=count[1] = 0; state[0] = 0x67452301; state[1] = 0xefcdab89; state[2] = 0x98badcfe; state[3] = 0x10325476; for (i = 0; i < digestBits.length; i++) digestBits[i] = 0; } function update(b) { var index,i; index = and(shr(count[0],3) , 0x3f); if (count[0]<0xffffffff-7) count[0] += 8; else { count[1]++; count[0]-=0xffffffff+1; count[0]+=8; } buffer[index] = and(b,0xff); if (index >= 63) { transform(buffer, 0); } } function finish() { var bits = new array(8); var padding; var i=0, index=0, padLen=0; for (i = 0; i < 4; i++) { bits[i] = and(shr(count[0],(i * 8)), 0xff); } for (i = 0; i < 4; i++) { bits[i+4]=and(shr(count[1],(i * 8)), 0xff); } index = and(shr(count[0], 3) ,0x3f); padLen = (index < 56) ? (56 - index) : (120 - index); padding = new array(64); padding[0] = 0x80; for (i=0;i?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"+ "[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; function MD5(entree) { var l,s,k,ka,kb,kc,kd; init(); for (k=0;k