var B=this.B||{}, $vars=this.$vars||{}, JSRoot='\/\/badoocdn.com/3508/-/-/'; var $s=window.$s||{}; _1=window._1||+new Date, _2=_3=_4=_5=0; $s.stats=function(type){ var t=+new Date; switch(type){ case 'ready': _2=t; break; case 'init': _3=t; break; case 'load': _4=t; break; case 'static': _5=t; break; } if(!window._1||!window._id) return; document.cookie="t="+[_id,_2&&_2-_1,_3&&_3-_2,_4&&_4-_1,$u.ua,_5&&_5-_1].join('|')+"; path=/; domain=."+/[^.]+\.[^.]+$/.exec(location.host); }; document.documentElement.className='js'; function $class(superclass, overrides) { var subclass, F, supp, subp, i, s, d; i=superclass instanceof Function; overrides=overrides || !i && superclass || {}; superclass=i && superclass || null; if(overrides.constructor!=Object.prototype.constructor) subclass=overrides.constructor, delete overrides.constructor; else if(superclass) subclass=function(){ arguments.callee.$super.apply(this,arguments); }; else subclass=function(){}; if(!superclass){ subclass.prototype=overrides; }else{ F=function(){}; supp=F.prototype=superclass.prototype; subp=subclass.prototype=new F(); subp.constructor=subclass; subclass.$super=superclass; if(supp.constructor==Object.prototype.constructor) supp.constructor=superclass; for(i in overrides){ s=overrides[i], d=subp[i]; if(s instanceof Function && d instanceof Function) s.$super=d; subp[i]=s; } } return this.constructor==arguments.callee ? new subclass() : subclass; } function $super(scope,args) { var fn=args.callee.$super; if(arguments.length>2) args=Array.prototype.slice.call(arguments,2); return fn && fn.apply(scope,args); } function $config(dst,src,def) { var i; for(i in def) dst[i]=def[i]; for(i in src) dst[i]=src[i]; return dst; } if(!Function.prototype.bind) Function.prototype.bind=function(scope) { var fn=this; if(arguments.length<2){ return function(){ return fn.apply(scope, arguments); }; }else{ var args=Array.prototype.slice.call(arguments,1); return function(){ return fn.apply(scope, args.concat(Array.prototype.slice.call(arguments,0))); }; } }; if(!window.JSON) JSON={ parse:function(s) { return eval('('+s+')'); } }; var $t=$class( { t:0, fn:null, ctx:null, args:null, time:0, constructor:function(fn,ctx,time) { this.run_=this.run.bind(this); this.fn=fn, this.ctx=ctx||null, this.time=time||0; }, set:function(time) { if(this.t) clearTimeout(this.t), this.t=0; if(time!==undefined) this.time=time; if(arguments.length>1) this.args=Array.prototype.slice.call(arguments,1); else this.args=null; this.t=setTimeout(this.run_,this.time); return this; }, clear:function() { if(this.t) clearTimeout(this.t), this.t=0; return this; }, run:function() { this.t=0; if(this.args) this.fn.apply(this.ctx,this.args); else this.fn.call(this.ctx); }, valueOf:function() { return +this.t; } }); if(!window.XMLHttpRequest && window.ActiveXObject) window.XMLHttpRequest=function(){ var r,msid=['MSXML2.XMLHTTP.6.0','MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP', 'MICROSOFT.XMLHTTP.1.0','MICROSOFT.XMLHTTP.1','MICROSOFT.XMLHTTP']; for(var i=0; i<msid.length; i++) try{ r=new ActiveXObject(msid[i]); msid=msid[i]; break; }catch(er){} if(r) window.XMLHttpRequest=new Function('return new ActiveXObject("'+msid+'")'); else $r.prototype.request=function(){ this._error('not supported'); }; return r; }; var $r=$class({ url:'', params:null, method:'get', auto:true, json:true, cors:false, ws:true, timeout:30000, ready:function(){}, error:function(){}, scope:null, _t:null, _timer:0, _stub:function(){}, constructor:function(url, options, scope) { $config(this,options); this.scope=scope||this; this.url=url; if(!this.params) this.params={}; this._wait_=this._wait.bind(this); this._timer=new $t(this._error_timeout, this, this.timeout); if(this.auto) this.request(); }, request:function(params) { var url=this.url, t, data, anchor='', method=this.method.toUpperCase(), post=(method=='POST'), a=url.indexOf('#'); if(a!=-1) anchor=url.substring(a), url=url.substring(0, a); if(params){ if(typeof params=='string' || typeof this.params=='string') this.params=params; else $config(this.params, params); } if(typeof this.params=='string') data=this.params; else data=$r.toQueryString(this.params); url+=url.indexOf('?')!=-1?'&':'?'; if(!post && data) url+=data+'&'; url+=(this.ws?'ws=1':'')+anchor; this._timer.set(); try{ if(!this._t){ if(!this.cors){ this._t=new XMLHttpRequest(); }else{ if(!$r.cors()) return this._error('CORS is not supported'); this._t=new (window.XDomainRequest ? XDomainRequest : XMLHttpRequest)(); } }else{ this._abort(); } t=this._t; t.onreadystatechange=this._wait_; t.open(method, url, true); if(post) t.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'); t.send(post?data:null); }catch(er){ this._error('xhr send exception'); } }, abort:function() { this._abort(); }, _abort:function() { var t=this._t; if(!t) return; t.onreadystatechange=this._stub; t.abort(); this._timer.clear(); }, _wait:function() { if(this._t.readyState!=4) return; this._ready(); }, _ready:function() { var t=this._t, json; if(t.status!=200) return this._error('response status is '+t.status); this._timer.clear(); if(this.json){ if(!t.responseText) return this._error('response is empty'); if('text/javascript'==t.getResponseHeader("Content-Type").split(';')[0]) try{ json=JSON.parse(t.responseText); }catch(er){ return this._error(er); } else return this._error('not a JSON'); if('auth' in json){ window.location.href=json.auth; return; } if('fatal' in json){ this._error('fatal'); dOvl.open_err({html:json.fatal}); return; } } this.ready.call(this.scope,this.json?json:t.responseText); }, _error:function(er) { this._timer.clear(); console.trace(); this.error.call(this.scope, er instanceof Error ? er : new Error(er)); }, _error_timeout:function() { this._abort(); this._error('timeout'); } }); $r.cors=function() { return this._cors!==undefined ? this._cors : (this._cors=!!(window.XDomainRequest || 'withCredentials' in new XMLHttpRequest)); }; $r.normalize_url=function(url) { var a=this.normalize_url_a||(this.normalize_url_a=document.createElement('A')); a.href=url; return a.href; }; $r.toQueryString=function(params,and,eq) { eq=eq||'='; var r=[],v; for(var i in params){ v=params[i]; switch(typeof(v)){ case 'string': v=encodeURIComponent(v); break; case 'number': case 'boolean': break; case 'undefined': continue; case 'object': if(v instanceof Array){ if(i.indexOf('[]')==-1) i=i+'[]'; i=encodeURIComponent(i); for(var j=0, n=v.length; j<n; j++){ r[r.length]=(i+eq+encodeURIComponent(v[j])); } continue; } default: v=''; } r[r.length]=(encodeURIComponent(i)+eq+v); } return r.join(and||'&'); }; $r.fromQueryString=function(str,and,eq) { eq=eq||'='; var obj={}, _=str.indexOf('#'); str=str.substring(str.indexOf('?')+1, _==-1 ? str.length : _); str=str.split(and||'&'); for(var i=0, p, n=str.length; i<n; i++){ p=str[i].split(eq); obj[decodeURIComponent(p[0])]=decodeURIComponent(p[1]); } return obj; }; $r.serialize=function(el) { if(!el) return; var els=el.elements, r={}; for(var v, name, i=0, n=els.length; i<n; i++){ el=els[i], name=el.name; if(!name || el.disabled || (!el.checked && !/select|textarea/i.test(el.nodeName) && !/text|hidden|password/i.test(el.type))) continue; if(el.nodeName!='SELECT'){ v=el.value; }else{ var one=(el.type=='select-one'); if(el.selectedIndex<0) v=''; else if(one) v=el.value; else{ v=[]; for(var j=0, ops=el.options, m=ops.length; j<m; j++){ var op=ops[j]; if(op.selected){ v[v.length]=(op.attributes.value||{}).specified?op.value:op.text; } } } } if(name.indexOf('[]')!==-1){ if(name in r) r[name][r[name].length]=v; else r[name]=[v]; }else{ r[name]=v; } } return r; }; var $=function(id) { return typeof id=='string' ? document.getElementById(id) : (id||null); }; var $el={ create:function(nodeName, attributes) { var el, style; if($u.ua_ie && $u.ua<'ie9' && attributes && (nodeName.toLowerCase()=='input' || 'name' in attributes || 'type' in attributes)){ el=document.createElement('<'+nodeName.toLowerCase()+' name="'+attributes.name+'" type="'+attributes.type+'" >'); delete attributes.name, delete attributes.type; }else{ el=document.createElement(nodeName.toUpperCase()); } if(!attributes) return el; style=attributes.style; if(style){ if(typeof style=='string') el.style.cssText=style; else $config(el.style,style); delete attributes.style; } $config(el,attributes); return el; }, _head:null, head:function() { return this._headel||(this._head=document.getElementsByTagName('HEAD')[0]||document.documentElement); }, _document_dimensions:function () { var w, h; if($u.ua=='wk' && !document.evaluate) w=self.innerWidth, h=self.innerHeight; else if(window.opera && parseFloat(window.opera.version()) < 9.5) w=document.body.clientWidth, h=document.body.clientHeight; else w=document.documentElement.clientWidth, h=document.documentElement.clientHeight; return {width:w, height:h}; }, cumulativeOffset:function(el) { var t=0, l=0; do{ t+=el.offsetTop||0, l+=el.offsetLeft||0; el=el.offsetParent; }while(el); return {left:l, top:t}; }, dimensions:function(el) { if(el==document) return $el._document_dimensions(); var s=el.style, d=s.display; if (d!='none' && d!=null) return {width: el.offsetWidth, height: el.offsetHeight}; var w, h, v=s.visibility, p=s.position; s.visibility='hidden', s.position='absolute', s.display='block'; w=el.clientWidth, h=el.clientHeight; s.display=d, s.position=p, s.visibility=v; return {width: w, height: h}; }, style:function(el,prop) { var v=document.defaultView; if(v && v.getComputedStyle){ var st=v.getComputedStyle(el,null); if(st) return st.getPropertyValue(prop); }else if(el.currentStyle){ return el.currentStyle[prop]; } }, dir:function() { return this._dir||(this._dir=this.style(document.body,'direction')||'ltr'); }, remove:function(el) { el && el.parentNode && el.parentNode.removeChild(el); }, has:function(el, cl) { var c; return el && (c=el.className) && (c==cl || (' '+c+' ').indexOf(' '+cl+' ')!=-1); }, add:function(el, cl) { if(!el) return; var c=el.className; if(!c || (c!=cl && (' '+c+' ').indexOf(' '+cl+' ')==-1)) el.className+=(c?' ':'')+cl; }, del:function(el, cl) { if(!el) return; el.className=el.className.replace(new RegExp("(^| +)"+cl+"( +|$)"), ' '); }, tgl:function(el, cl, fl) { if(!el) return; if(arguments.length==2) fl=$el.has(el,cl); fl ? $el.add(el,cl) : $el.del(el,cl); return !fl; } }; if('classList' in document.documentElement) $config($el,{ has:function(el, cl) { return el && el.classList.contains(cl); }, add:function(el, cl) { el && el.classList.add(cl); }, del:function(el, cl) { el && el.classList.remove(cl); }, tgl:function(el, cl, fl) { if(!el) return; if(arguments.length==2) fl=!el.classList.contains(cl); fl ? el.classList.add(cl) : el.classList.remove(cl); return !fl; } }); (function(){ var r_simple=/^[\w#.]\w*$/, r_comma=/ *, */, r_space=/ +/, r_sel=/([^[.#]+)?(?:#([^.]+))?(?:\.(.+))?/, k = !!document.getElementsByClassName; if(document.querySelectorAll) $el.select = function(root, selector, one) { if (arguments.length == 1) selector=root, root=document; root = root || document; if (one) return root.querySelector(selector); var ar=[], col=root.querySelectorAll(selector); for (var i=0, n=col.length; i<n; i++) ar[i]=col[i]; return ar; }; else $el.select = function(root, selector, one) { if (arguments.length == 1) selector=root, root=document; var doc=document; root = root || doc; if (r_simple.test(selector)) { var idx = 0, sets = []; switch (selector.charAt(0)) { case '#': idx = selector.slice(1); sets = doc.getElementById(idx); if (doc.all && sets && sets.id !== idx) { sets = doc.all[idx]; } if (sets) { var p = sets; if (root != doc) while((p = p.parentNode) && p != root) {} if (p) return one ? sets : [sets]; } return one ? null : []; case '.': var klass = selector.slice(1); if (k) { sets = root.getElementsByClassName(klass); if(!one){ for (var ar=[], i=0, n=sets.length; i<n; i++) ar[i]=sets[i]; return ar; } else { return sets.length ? sets[0] : null; } } else { klass = ' ' + klass + ' '; var nodes = root.getElementsByTagName('*'), i = 0, node; while (node = nodes[i++]) { if ((' ' + node.className + ' ').indexOf(klass) != -1) { sets[idx++] = node; if(one) return node; } } return idx ? sets : one ? null : []; } default: sets = root.getElementsByTagName(selector); if (!one){ for (var ar=[], i=0, n=sets.length; i<n; i++) ar[i]=sets[i]; return ar; } else { return sets.length ? sets[0] : null; } } } else { var groups_length = 0, groups = selector.split(r_comma), group, sets = [], singles, single, i, nodes, newNodes, idx, J, child, last, childs, item, h, id, klass, tag, par, stack, rootReq = root && root !== doc; while (group = groups[groups_length++]) { singles = group.split(r_space); newNodes = []; stack = []; h = 0; idx = 0; J = 0; i = 0; while (single = singles[i++]) { single = r_sel.exec(single); stack[h++] = [single[1] ? single[1].toLowerCase() : '', single[2], single[3] ? ' ' + single[3] + ' ' : '']; } item = stack[h - 1]; tag = item[0]; id = item[1]; klass = item[2]; if (id) { nodes = [doc.getElementById(id)]; if (doc.all && nodes[0].id !== id) { nodes = doc.all[idx]; } while (child = nodes[J++]) { if ((!tag || child.nodeName.toLowerCase() === tag) && (!klass || (' ' + child.className + ' ').indexOf(klass) != -1)) { if (one && h==1) return child; if (i == 1) { child._cse = 1; } newNodes[idx++] = child; } } } else { if (k && klass) { nodes = doc.getElementsByClassName(klass); while (child = nodes[J++]) { if ((!tag || child.nodeName.toLowerCase() === tag) && (!id || child.id === id)) { if (one && h==1) return child; if (i == 1) { child._cse = 1; } newNodes[idx++] = child; } } } else { nodes = root.getElementsByTagName(tag || '*'); while (child = nodes[J++]) { if ((!id || child.id === id) && (!klass || (' ' + child.className + ' ').indexOf(klass) != -1)) { if (one && h==1) return child; if (i == 1) { child._cse = 1; } newNodes[idx++] = child; } } } } i = h; if (i--) { nodes = newNodes; idx = 0; J = 0; newNodes = []; while (child = nodes[J++]) { h = i - 1; par = child; while ((item = stack[h--]) && par && (par = par.parentNode)) { tag = item[0]; id = item[1]; klass = item[2]; while (par && ((tag && par.nodeName.toLowerCase() !== tag) || (id && par.id !== id) || (klass && (' ' + par.className + ' ').indexOf(klass) == -1))) { par = par.parentNode; } } if (rootReq) { while ((par = par.parentNode) && par !== root) {} } if (child && par && !child._cse) { if (one) return child; child._cse = 1; newNodes[idx++] = child; } } } if (groups_length > 1) { sets = sets.concat(newNodes); } else { sets = newNodes; } } if (one && (!sets || !sets.length)) return null; idx = (sets = sets || []).length; while (idx--) { sets[idx]._cse = null; } return sets; } }; $el.down = function(root, selector){ if (arguments.length == 1) selector=root, root=document; return $el.select(root, selector, true) }; $el.up = function(node, selector) { if(!node) return null; if (r_simple.test(selector)) { var s1, p = node; switch (selector.charAt(0)) { case '#': s1 = selector.slice(1); while ((p=p.parentNode)) if (p.id == s1) return p; break; case '.': s1 = ' ' + selector.slice(1) + ' '; while ((p=p.parentNode)) if ((' ' + p.className + ' ').indexOf(s1) != -1) return p; break; default: while ((p=p.parentNode)) if (p.nodeName.toLowerCase() === selector) return p; } return null; } else { var i, j = 0, l, groups = selector.split(r_comma), group, singles, single, p, r, id, klass, tag; groups:while (group = groups[j++]) { p = r = node; singles = group.split(r_space); i = l = singles.length; l--; singles:while (single = singles[--i]) { single = r_sel.exec(single); tag = single[1] ? single[1].toLowerCase() : '', id = single[2], klass = single[3] ? ' ' + single[3] + ' ' : ''; while (p=p.parentNode) { if ((!id || p.id === id) && (!tag || tag === '*' || p.nodeName.toLowerCase() === tag) && (!klass || (' ' + p.className + ' ').indexOf(klass) != -1)) { if (i==l) r = p; if (i==0) return r; else continue singles; } } continue groups; } } return null; } }; })(); var $u={ ua:/*@cc_on (_=document.createElement('I'),_.innerHTML='<!--[if IE 7]>ie7<![endif]--><!--[if IE 8]>ie8<![endif]--><!--[if gte IE 9]>ie9<![endif]-->',_.innerText)||'ie6' @*/+'' ||/iphone|ipod|ipad|android|blackberry|symbian|series[6-9]0/i.test(navigator.userAgent)&&'m' ||window.opera&&'op' ||window.chrome&&'cr' ||window.netscape&&(document.getElementsByClassName?Object.create?'ff4':'ff3':'ff2') ||window.WebKitPoint&&'wk' ||/a/.__proto__=='\/\/'&&'wk' ||'', ua_ie:/*@cc_on!@*/false, tpl:function(tpl,dict,dict_def) { return tpl.replace( /\{([\w-]+)\}/g, dict_def ? function(str,key){ return dict[key]||dict_def[key]||((typeof(dict[key])=='number'||typeof(dict_def[key])=='number')?0:''); } : function(str,key){ return dict[key]||(typeof(dict[key])=='number'?0:''); } ); }, tpl2el:function(tpl,dict,dict_def) { var el=document.createElement('DIV'); el.innerHTML=(dict||dict_def) && $u.tpl(tpl.replace(/(^\s+|\s+$)/g,''),dict,dict_def) || tpl; return el.childNodes.length==1 ? el.firstChild : el; }, _imageArray:[], preloadImages:function(imgs) { if(!document.images) return; var ar=$u._imageArray; for(var i=0,j=ar.length; i<imgs.length; i++,j++){ ar[j]=new Image; ar[j].src=imgs[i]; } }, cookie:function(name, value, expires, path, domain, secure) { if(arguments.length==1){ var m=document.cookie.match(new RegExp('(^|; )'+name+'=(.*?)(;|$)')); return m && decodeURIComponent(m[2]) || null; } document.cookie = name + '=' + escape(value) + (expires ? '; expires=' + (expires instanceof Date ? expires.toGMTString() : expires):'') + (path ? '; path=' + path:'') + (domain ? '; domain=' + domain:'') + (secure ? '; secure':''); }, wins:{}, wopen:function(url, name, w, h, antiblock, resizable, scrollbars) { $u.wins[name]=window.open(url, name, 'width=' + w + ',height=' + h + ',resizable=' + (resizable||'1') + ',toolbar=0,location=0,status=0,menubar=0,directories=0,scrollbars=' + (scrollbars || 'yes')); if($u.wins[name]) $u.wins[name].focus(); return $u.wins[name]; }, add_href:function(href, add) { return href + (href.indexOf('?')!=-1 ? '&' : '?') + add; }, exec:function(s){ eval(s); } }; var Observable=$class( { _subscribers:null, constructor:function() { this._subscribers={}; }, on:function(type, fn, scope) { var i, s, ss=this._subscribers; if(typeof type!='string'){ for(i in type){ (s=ss[i]) ? s[s.length]=[type[i],fn] : ss[i]=[[type[i],fn]]; } }else{ (s=ss[type]) ? s[s.length]=[fn,scope] : ss[type]=[[fn,scope]]; } }, un:function(type, fn, scope) { if(typeof type!='string'){ for(var i in type){ this.un(i, type[i], fn); } }else{ var ss=this._subscribers[type]; if(ss) for(var i=0, n=ss.length; i<n; i++){ if(ss[i][0]==fn && ss[i][1]==scope){ ss.splice(i,1); break; } } } }, fire:function(type) { var ss=this._subscribers[type], res; if(!ss || !ss.length) return false; if(arguments.length<=3){ for(var i=0, n=ss.length; i<n; i++){ res=ss[i][0].call(ss[i][1], arguments[1], arguments[2]); } }else{ var args=Array.prototype.slice.call(arguments,1); for(var i=0, n=ss.length; i<n; i++){ res=ss[i][0].apply(ss[i][1], args); } } return res!=undefined ? res : true; } }); var $e=$class( { constructor:function() { this._manage_fn=this.manage.bind(this); var hs=this._handlers; this._type_map={'#':hs.id, '.':hs.cl, '* ':hs.up, '__any__':hs.any, '__all__':hs.all}; this.add(document, 'click', this._manage_fn); this._init_ready(); this.add(window,'load',function(){ $s.stats('load'); }); }, e:null, add:function(el, type, fn, scope) { if(!el) return; if(scope) fn=this._extend(fn,scope); el.addEventListener(type,fn,false); }, del:function(el, type, fn, scope) { if(!el) return; if(scope) fn=this._unextend(fn,scope); fn && el.removeEventListener(type,fn,false); }, _extend_fns:[], _extend:function(fn,scope) { var fns=this._extend_fns; for(var i=0, fni, n=fns.length; i<n; i++){ fni=fns[i]; if(fni[0]==fn && fni[1]==scope){ fni[3]++; return fni[2]; } } var fnEx=function $e_extend_wrapper(e){ $e.e=e; $e.click_ts=+new Date; if(!fn.call(scope,e.target||e.srcElement)) $e.stop(e); }; fns[i]=[fn,scope,fnEx,1]; fns=null; return fnEx; }, _unextend:function(fn,scope) { for(var i=0, fni, fns=this._extend_fns, n=fns.length; i<n; i++){ fni=fns[i]; if(fni[0]==fn && fni[1]==scope){ fn=fni[2]; if(!--fni[3]) fns.splice(i,1); return fn; } } }, stop:function(e) { e.preventDefault(); e.stopPropagation(); return true; }, isLeftClick:function(e) { return e.which ? (e.which==1 && !e.metaKey) : event.button==0; }, pointerXY:function(e) { var docElement=document.documentElement, body=document.body || { scrollLeft: 0, scrollTop: 0 }; return { x: e.pageX || (e.clientX + (docElement.scrollLeft || body.scrollLeft) - (docElement.clientLeft || 0)), y: e.pageY || (e.clientY + (docElement.scrollTop || body.scrollTop) - (docElement.clientTop || 0)) }; }, element:function(e) { return e && (e.target||e.srcElement); }, key:function(e) { return e && (e.charCode||e.keyCode||e.which||0); }, _is_ready:false, _ready_handlers:[], _init_ready:function() { this._fire_ready_=this._fire_ready.bind(this); if(document.addEventListener) document.addEventListener('DOMContentLoaded', this._fire_ready_, false); if($u.ua=='wk' && !document.evaluate){ (function(){ if(!/loaded|complete/.test(document.readyState)) setTimeout(arguments.callee, 10); else $e._fire_ready(); })(); } if($u.ua_ie && $u.ua<'ie9'){ document.write('<scr'+'ipt id="__ie_init" defer '+'src="\/\/:"></'+'script>'); var script=document.getElementById('__ie_init'); script.onreadystatechange=function(){ if(this.readyState=='complete') $e._fire_ready(); }; script=null; } this.add(window, 'load', this._fire_ready_); }, _fire_ready:function() { if(this._is_ready) return; this._is_ready=true; this.del(window, 'load', this._fire_ready_); if(document.addEventListener) document.removeEventListener('DOMContentLoaded', this._fire_ready_, false); var script=document.getElementById('__ie_init'); script && (script.onreadystatechange=function(){}) && script.parentNode.removeChild(script); $s.stats('ready'); for(var i=0,ar=this._ready_handlers,n=ar.length; i<n; i++){ ar[i][0].call(ar[i][1]); } $s.stats('init'); this._ready_handlers=[]; }, onload:function(fn,scope) { if(this._is_ready) fn.call(scope); else this._ready_handlers[this._ready_handlers.length]=[fn,scope]; }, _handlers:{ id:{}, cl:{}, up:{}, all:[], any:[] }, _type_re:/(?:(#|\.|\* |__all__|__any__)\s*([\w\-_]*\s*([^,]*)),?\s*)/g, _type_map:{'#':'id', '.':'cl', '* ':'up', '__any__':'any', '__all__':'all'}, on:function(type,fn,scope) { if(typeof(type)=='object'){ for(var i in type) this.on(i,type[i],fn); return false; } var self=this; type=type.replace(this._type_re,function(match, typeclass, selector, complex, offset, type) { if(complex && typeclass!='* '){ return match; } var hs=self._type_map[typeclass]; hs[selector||hs.length]=[fn,scope||null]; return ''; }); }, un:function(type,fn,scope) { if(typeof(type)=='object'){ for(var i in type) this.un(i,type[i],fn); return; } var self=this; var res=type.replace(this._type_re,function(match, typeclass, selector, complex, offset, type) { if(complex && typeclass!='* '){ return ''; } var hs=self._type_map[typeclass]; if(selector){ delete hs[selector]; }else{ for(var i=0, n=hs.length; i<n; i++){ if(hs[i][0]==fn && hs[i][1]==scope){ hs.splice(i,1); break; } } } return ''; }); }, manage:function $e_manage(e) { $e.e=e; $e.click_ts=+new Date; var i, n, ar, ari, fn, cl, hs=this._handlers, el=e.target||e.srcElement; ar=hs.all; if(ar.length) for(var i=0,n=ar.length; i<n; i++){ if($e==ar[i][0].apply(ar[i][1],arguments)){ this.stop(e); return; } } fn=hs.id[el.id]; if(fn){ if(!fn[0].call(fn[1],el)) this.stop(e); return; } cl=el.className; ar=hs.cl; if(cl){ cl=cl.split(' '); for(var i=0,n=cl.length; i<n; i++){ fn=ar[cl[i]]; if(fn){ if(!fn[0].call(fn[1],el)) this.stop(e); return; } } } ar=hs.up; for(var i in ar){ ari=ar[i]; var tfnres=$el.up(el,i); if(tfnres){ if(!ari[0].call(ari[1],tfnres)) this.stop(e); return; } } ar=hs.any; if(ar.length) for(var i=0,n=ar.length; i<n; i++){ ari=ar[i]; if(ari[0].apply(ari[1],arguments)){ this.stop(e); return; } } } }); if(!window.addEventListener){ $config($e.prototype, { _ie_handlers:[], add:function(el, type, fn, scope) { if(!el) return; if(scope) fn=this._extend(fn,scope); el.attachEvent('on'+type,fn); this._ie_handlers[this._ie_handlers.length]=[el,type,fn]; }, del:function(el, type, fn, scope) { if(!el) return; if(scope) fn=this._unextend(fn,scope); el.detachEvent('on'+type,fn); var hs=this._ie_handlers; for(var i=0,n=hs.length; i<n; i++){ var h=hs[i]; if(h[0]==el && h[1]==type && h[2]==fn){ hs.splice(i,1); return; } } }, stop:function(e) { e.returnValue=false; e.cancelBubble=true; return true; }, isLeftClick:function(e) { return e.button==1; } }); window.attachEvent('onunload', function() { var hs=$e._ie_handlers; for(var i=0,n=hs.length; i<n; i++){ var h=hs[i]; h[0].detachEvent('on'+h[1],h[2]); } $e._ie_handlers=[]; window.detachEvent('onunload', arguments.callee); }); } var $fx={}; $fx.transitions={ sineInOut:function(t,b,e,d){ return Math.round(-(e-b)/2*(Math.cos(Math.PI*t/d)-1)+b); } }; $fx.timer=$class({ duration:500, fps:50, wait:false, _timer:0, _stime:0, onStart:null, onEnd:null, scope:null, constructor:function(config) { $config(this,config); this.step_fn=this._step.bind(this); if(!this.wait) this.start(); }, start:function() { this.onStart && this.onStart.call(this.scope||this); this._stime=+new Date; this._timer=setInterval(this.step_fn, Math.round(1000/this.fps)); }, _step:function() { var ct=+new Date-this._stime, d=this.duration; if(ct>d) ct=d; this.step(ct,d); if(ct>=d) this.end(); }, end:function() { this._timer=clearInterval(this._timer); if(this.onEnd) this.onEnd.call(this.scope||this); } }); $fx.effect=$class($fx.timer,{ wait:true, items:null, constructor:function() { this.items=[]; $super(this,arguments); }, add:function(item) { this.items[this.items.length]=item; }, start:function() { for(var i=0, items=this.items, n=items.length; i<n; i++) items[i].start(); $super(this,arguments); }, step:function(ct,d) { var items=this.items; for(var i=0, n=items.length; i<n; i++) items[i].step(ct,d); }, end:function() { for(var i=0, items=this.items, n=items.length; i<n; i++) items[i].end(); $super(this,arguments); } }); $fx.style=$class({ el:null, prop:'', from:0, to:0, dimm:'px', fx:$fx.transitions.sineInOut, constructor:function(config) { $config(this,config); }, start:function(){}, end:function(){}, step:function(ct,d) { this.el.style[this.prop]=this.fx(ct,this.from,this.to,d)+this.dimm; } }); $u.storage=(function(){ if(!window.localStorage && window.globalStorage){ localStorage=globalStorage[location.host]; var _getItem=Storage.prototype.getItem; Storage.prototype.getItem=function(k){ var v=_getItem.call(this, k); return v && v.value; }; } var ls=!!window.localStorage, ie=$u.ua_ie, self={ k:{}, n:0, on:function(k, fn, scope, v) { this.k[k]=[v!==undefined?v:this.getItem(k),fn,scope]; if(++this.n==1) this.sub(); }, un:function(k, fn, scope) { if(k in this.k){ delete this.k[k]; if(--this.n==0) this.unsub(); } }, cmp:function() { var k=self.k, v; for(var i in k){ v=self.getItem(i); if(k[i][0]!=v){ setTimeout(k[i][1].bind(k[i][2],v),0); k[i][0]=v; } } } }; if(!ls){ self.type='cookie'; self.getItem=function(k){ return document.cookie.match(new RegExp('(^|; )'+k+'=(.*?)(;|$)')) && RegExp.$2; }; self.setItem=function(k,v){ document.cookie=k+'='+v+';path=/'; }; self.removeItem=function(k){ document.cookie=k+'='+v+';expires='+new Date(0).toGMTString()+';path=/'; }; }else{ self.type='native'; self.getItem=function(k){ return localStorage.getItem(k); }; self.setItem=function(k,v){ return localStorage.setItem(k,v); }; self.removeItem=function(k){ return localStorage.removeItem(k); }; } if(!ls){ self.poll=function(){ self.cmp(); self._t=setTimeout(self.poll, 500); }; self.sub=function(){ this._t=setTimeout(this.poll, 500); }; self.unsub=function(){ clearTimeout(this._t); }; }else if(ie){ self.ev=function(){ setTimeout(self.cmp, 0); }; self.sub=function() { document.attachEvent('onstorage', this.ev, false); }; self.unsub=function(){ document.detachEvent('onstorage', this.ev, false); }; }else{ self.sub=function() { window.addEventListener('storage', this.cmp, false); }; self.unsub=function(){ window.removeEventListener('storage', this.cmp, false); }; } return self; })(); if(!window.sessionStorage) sessionStorage={ getItem:function(){}, setItem:function(){}, removeItem:function(){} }; $r.loader=(function(){ var L=new $class({ ls:null, add:function(url, fn, ctx) { var ls=L.ls, l; fn=fn||new Function; if(!ls){ ls=L.ls={}; var els=$el.select(document,'link'); for(var i=0, n=els.length; i<n; i++) if(els[i].rel=='stylesheet') ls[els[i].href]={el:els[i]}; els=$el.select(document,'script'); for(var i=0, n=els.length; i<n; i++) if(els[i].src) ls[els[i].src]={el:els[i]}; } url=$r.normalize_url($u.tpl(url,{dir:$el.dir()})); l=ls[url]; if(l){ if(l.st=='i'){ l.fns[l.fns.length]=[fn,ctx]; }else{ if(l.st!='er' && !l.el.parentNode) $el.head().appendChild(l.el); fn.call(ctx,l.el); } }else{ ls[url]={st:'i', el:null, fns:[[fn,ctx]]}; (url.split('?')[0].match(/\.js$/)?L.Script:L.Link)(url); } }, del:function(url) { var l=L.ls[url]; if(!l) return; $el.remove(l.el); }, ready:function(url, el, success) { var l=L.ls[url]; if(!l) return; if(l.fns) for(var i=0, fns=l.fns; i<fns.length; i++){ fns[i][0].call(fns[i][1],el); } l.fns=[]; if(success){ l.el=el; l.st='ok'; }else{ l.st='er'; } } }); L.Script=function(url) { var el=$el.create('script',{type:'text/javascript',src:url}); el.onload=function(){ L.ready(url, el, true); el=el.onload=el.onreadystatechange=null; }; el.onreadystatechange=function(){ if(this.readyState=='complete' || this.readyState=='loaded') el.onload(); }; $el.head().appendChild(el); }; L.Link=function(url) { var el=$el.create('link',{href:url,type:'text/css',rel:'stylesheet'}), t, c=0; el.onload=function(){ L.ready(url, el, true); el=el.onload=el.onerror=null; if(t) clearTimeout(t); }, el.onerror=function(){ $el.remove(el); el=el.onload=el.onerror=null; if(t) clearTimeout(t); L.ready(url, null, false); }; $el.head().appendChild(el); if(!$u.ua_ie && $u.ua!='op') (function poll(){ var ss=document.styleSheets; for(var i=0, l, n=ss.length; i<n; i++){ l=ss[i].ownerNode ? ss[i].ownerNode : ss[i].owningElement; if(l==el){ el.onload(); return; } } if(c>300) el.onerror(); else t=setTimeout(poll,100); c++; })(); }; return L; })(); $e=new $e; B.Page=$class({ name:'', constructor:function() { $e.onload(this.name ? this.onload : this.init, this); }, onload:function() { $config(this, $vars[this.name]); this.init(); } }); B.Base=new $class(B.Page, { name:'Base', is_frame:false, init:function() { if(!this.is_frame && top!=self) top.location.href=self.location.href; } }); var dOvl=new $class(B.Page, { name:'dOvl', tpl:'', html:'', ctx:'dOvl-cont', autocenter:true, url:'', params:null, onLoad:null, onUnLoad:null, onResize:null, scope:null, defaults:{ tpl:'', html:'', ctx:'dOvl-cont', autocenter:true, url:'', params:null, onLoad:null, onUnLoad:null, onResize:null, scope:null }, _tpl:'<div class="dOvl-edge"></div><div class="dOvl-wrap">\ <div id="dOvl">\ {html}\ </div>\ <div class="formfade"></div>\ <div class="dOvl-f"><div class="dOvl-br"></div></div>\ </div>', tpl_loading:'<div class="dOvl-loading-icon"><div class="loading-icon"></div></div>', tpl_err:'<div class="dOvl-edge"></div><div class="wizard_cloud pngbg">\ <div class="ctnt">\ <span class="v_center"></span>\ <div class="wzrd_cld_cntnt" id="dOvlCloud">{html}</div>\ </div>\ <div class="formfade"></div>\ </div>', _bg:null, _bgl:null, _cont:null, _cont_tpl:'', _el:null, _t:null, _visible:false, _labels:null, js_url:JSRoot+'js/overlays/handlers.js', css_url:JSRoot+'css/wizards-{dir}.css', _loaded_js:false, handlers:{}, init:function() { $e.on({ '.dOvl-open':this.auto, '.dOvl-close':this.close, '.dOvl-close-hit':this.close_hit, '.dOvl-next':this.next, '.dOvl-prev':this.prev, '.dOvl-wait':this.wait, '.dOvl-open-ex': this.open_ex, '.dOvl-open-ex-up':this.open_ex_up }, this); dOvl.on('ovl',this.auto,this); dOvl.on('ovl-err',this.auto_err,this); var cfg=$vars['promo']; if(cfg) (cfg.simple ? cfg.errno ? this.open_err : this.open : this.open_ex).call(this,cfg); }, on:function(name,fn,scope) { if(typeof name=='string'){ this.handlers[name]=[fn,scope]; }else{ for(var i in name){ this.handlers[i]=[name[i],fn]; } } }, open_ex:function(el) { if(!el) return; var type=el.type||el.rel, url=el.url||el.rev, handler=this.handlers[type]; if(!type || (!handler && this._loaded_js)){ return this.auto('nodeType' in el ? el : {url:url}); } if(handler){ return handler[0].call(handler[1], el); } if(!this._loaded_js){ this.draw_loading(); $r.loader.add(this.js_url, this.open_ex.bind(this,el)); this._loaded_js=true; } }, open_ex_up:function(el) { return this.open_ex(el.parentNode); }, auto:function(el) { if(!el.nodeName){ this.open(el); }else{ this.open({ url:el.rev||el.href }); } }, auto_err:function(el) { if(!el.nodeName){ el.tpl=this.tpl_err; this.open(el); }else{ this.auto({ tpl:this.tpl_err, url:el.rev||el.href }); } }, open_err:function(cfg) { cfg.tpl=this.tpl_err; this.open(cfg); }, open:function(cfg) { if(this._visible){ if(this.onUnLoad && this.onUnLoad.call(this.scope)) return; this.post_unload(); } if(this.css_url) $r.loader.add(this.css_url, this.css_ready, this); if('ctx' in cfg) cfg.ctx='dOvl-cont '+cfg.ctx; $config(this, cfg, this.defaults); if(!this._visible){ this.draw_loading(); $e.add(window,'resize',this.center,this); $e.add(document,'keydown',this.keypress,this); if(this.html) this.draw(this.tpl||this._tpl, this.html); this._visible=true; }else if(this.html){ this.draw(this.tpl||this._tpl, this.html); } if(this.url) this.load(); else this.post_load(cfg); }, draw_loading:function() { var b=document.body; if(!this._bg){ this._bg=document.createElement('DIV'); this._bg.className='dOvl-bg'; b.appendChild(this._bg); } if(!this._bgl) b.appendChild(this._bgl=$u.tpl2el(this.tpl_loading)); $el.add(b.parentNode, 'dOvl-loading'); this._loading=true; }, draw:function(tpl, html) { if(tpl && this._cont_tpl!=tpl){ $el.remove(this._cont); this._cont=this._cont_tpl=null; } if(!this._cont||!this._el){ this._cont_tpl=tpl; this._cont=$u.tpl2el('<div class="'+this.ctx+'">'+tpl+'</div>',{html:html}); document.body.appendChild(this._cont); this._el=$('dOvl')||$('dOvlCloud'); }else{ this._cont.className=this.ctx; this._el.innerHTML=html; $el.del(this._cont,'el-loading'); if(this.pr) $el.del(this._cont,'el-progress'); } if(this._loading){ var b=document.documentElement; $el.del(b, 'dOvl-loading'); $el.add(b, 'dOvl-opened'); this._loading=false; } }, css_ready:function(el) { this.center(); }, close:function() { if(!this._visible) return; if(this.onUnLoad && this.onUnLoad.call(this.scope)) return true; this.post_unload(); $el.del(document.documentElement, 'dOvl-opened'); if(this._cont) $el.remove(this._cont); $e.del(window,'resize',this.center,this); $e.del(document,'keydown',this.keypress,this); this._cont=this._cont_tpl=this._el=null; if(this._t){ this._t.abort(); this._t=null; } if(this.pr){ clearTimeout(this.pr_t); this.pr.destroy(); this.pr=null; } this._visible=false; }, close_hit:function(el) { this.close(); new $r(el.href); }, load:function(method) { var params=this.params||{}; params.rand=(''+Math.random()).substr(2,5); this._t=new $r(this.url,{ method:method||'get', params:params, ready:this.load_done, error:this.load_error },this); if(this._cont) $el.add(this._cont,'el-loading'); }, load_done:function(res) { if('wait' in res){ if(this.pr){ res.tl && this.pr.adjust(res.tl); }else{ var el=$el.down(this._el,'.connect_bar'); this.pr=new $u.progress({ el:el, tl:res.wait }); if(this._cont) $el.add(this._cont,'el-progress'); } this.pr_t=setTimeout(this._t.request.bind(this._t,null), 2000); return; }else if(this.pr){ this.pr.destroy(); this.pr=null; } if('ctx' in res) this.ctx='dOvl-cont '+res['ctx']; var html=res.html, tpl=res.tpl || ((res.errno||res.pp_type) ? this.tpl_err : this.tpl||this._tpl); this.draw(tpl, html); this.post_load(res); }, load_error:function(er) { this.close(); }, post_load:function(res) { this._labels=$u.dLabel.init(this._el); var f=$el.down(this._el, 'form'); if(f && !$el.has(f,'no_autoloader')){ this._form=f; $e.add(f, 'submit', this.next, this); for(var els=f.elements, i=els.length-1; i>=0; i--){ var b=els[i]; if(b.nodeName=='SUBMIT' || (b.nodeName=='BUTTON' && b.type=='submit') && $el.has(b,'dOvl-next')) { this._bn=b; break; } } } this._ifr=$('cards_iframe'); if(this.onLoad) this.onLoad.call(this.scope, res); this.center(); if(res && ('credits' in res)){ var el=$('credits'); el && (el.innerHTML=res.credits); } if(res && ('credits_counter' in res)){ var el=$('credits_counter'); el && (el.innerHTML=res.credits_counter); } if(f && $el.has(f,'autosubmit')){ if($el.has(f,'no_autoloader')){ f.submit(); }else{ this.next(); } } }, post_unload:function() { $u.dLabel.destroy(this._labels); if(this._form) $e.del(this._form, 'submit', this.next, this); this._labels=this._form=this._bn=this._ifr=null; }, next_disabled:function() { return this._bn && (this._bn.disabled || $el.has(this._bn, 'disabled')); }, next:function(el) { var f=this._form; if(!this._visible || !f) return true; if(this.next_disabled()) return; if(this.onUnLoad && this.onUnLoad.call(this.scope)) return; this.url=(el && el.nodeName=='A' && el.rev) || f.action; this.params=$r.serialize(f); this.load(f.method||'post'); }, prev:function(el) { if(!this._visible) return true; if(this.onUnLoad && this.onUnLoad.call(this.scope)) return; this.url=el.rev||el.href||this.url; this.params=null; this.load(); }, wait:function() { $el.add(this._cont,'el-loading'); return true; }, center:function(e) { if(!this._cont) return; if(this.autocenter){ var c=$el.dimensions(this._cont), d=$el.dimensions(document), t=Math.round(Math.max(0,(d.height-c.height)/2)), s=this._cont.style; if(this._ifr) this._ifr.style.width=Math.round(d.width/2+248)+'px'; } this.onResize && this.onResize.call(this.scope||this,t); return t; }, keypress:function(el) { var code=$e.key($e.e); if(code==27){ this.close(); return false; } return true; } }); $u.progress=$class( { el:null, pel:null, pel2:null, w:120, t:-1, tl:20, min_width:22, constructor:function(config) { $config(this,config); this.update_fn=this.update.bind(this); if(this.tl) this.start(); }, destroy:function() { clearTimeout(this.timer); if(!this.el) return; this.el=this.pel=this.pel2=null; }, clean:function() { if(this.el){ this.el.removeChild(this.pel); this.el.removeChild(this.pel2); } $el.del(this.el,'progress_bar'); }, start:function() { $el.add(this.el,'progress_bar'); this.pel=$el.create('div'); this.pel2=$el.create('i'); this.el.appendChild(this.pel); this.el.appendChild(this.pel2); this.update(); }, update:function() { var t=++this.t, tl=this.tl, p=t/tl, ts=(tl-t)%60, w=this.w, pel=this.pel, pel2=this.pel2, s=$u.tpl('{m}:{s}',{ m:parseInt((tl-t)/60), s:(ts<10?('0'+ts):ts) }); if(t>tl) return this.clean(), this.destroy(); pel.style.width=parseInt(p*w)+'px'; pel2.style.width=parseInt(w-p*w)+'px'; if(t>tl/2){ pel.innerHTML=s; pel2.innerHTML=''; }else{ pel.innerHTML=''; pel2.innerHTML=s; } this.timer=setTimeout(this.update_fn, 1000); }, adjust:function(tl) { this.tl=tl; } }); $u.dLabel=$class({ el:null, input:null, constructor:function(config) { $config(this,config); if(!this.input) this.input=$(this.el && this.el.htmlFor); if(!this.el || !this.input){ return; } $e.add(this.el,'click',this.hide,this); $e.add(this.input,'focus',this.hide,this); $e.add(this.input,'blur',this.show,this); this.show(); }, destroy:function() { $e.del(this.el,'click',this.hide,this); $e.del(this.input,'focus',this.hide,this); $e.del(this.input,'blur',this.show,this); this.input=this.el=null; }, hide:function(el) { this.el.style.display='none'; if($e.e.type!='focus' && !this.input.disabled) this.input.focus(); }, show:function(el) { this.el.style.display=this.input.value?'none':'block'; } }); $config($u.dLabel, { init:function(wrap) { var dls=[], els=$el.select(wrap, '.dLabel'); for(var i=0, n=els.length; i<n; i++) dls[dls.length]=new $u.dLabel({el:els[i]}); return dls; }, destroy:function(labels) { if(!labels || !(labels instanceof Array)) return; for(var i=0, n=labels.length; i<n; i++) labels[i].destroy(); } }); $e.onload($u.dLabel.init,$u.dLabel); $u.form_loading=function(e) { var form=$e.element(e); $el.add(form,'el-loading'); }; $u.form_init=function() { var forms=document.forms; for(var i=0, n=forms.length; i<n; i++){ if(!$el.has(forms[i],'no_autoloader')) $e.add(forms[i],'submit',$u.form_loading); } }; $e.onload($u.form_init,$u); $r.ct = {}; $r.ct.id = (function(){ var d=$r.ct.id_start=+new Date, i=0; return function(){ return d+'_'+(+new Date-d)+'.'+(i++); } })(); $r.ct.Base = $class( { id:0, url:'', onmessage:null, onclose:null, scope:null, t:null, timer:null, ping_time:30000, abrt:0, active:0, st_open:0, st_error:0, st_timeout:0, constructor:function(url, cfg, scope) { this.id=$r.ct.id(); this.url=url+'&t='+this.id, $config(this, cfg), this.scope=scope; this.p_=this.p.bind(this); this.open_=this.open.bind(this); this.drop_=this.drop.bind(this); this.connect_=this.connect.bind(this); this.timer=new $t(this.timeout, this, this.ping_time); }, connect:function() { this.abrt=this.active=0; this.timer.set(); }, disconnect:function() { this.abrt=1; this.timer.clear(); }, p:function(e) { if(!this.abrt){ this.active++; this.timer.set(); }else{ this.timer.clear(); } if(e.data!='') this.onmessage.call(this.scope, this, typeof e.data=='string'?JSON.parse('['+e.data+']'):e.data); }, open:function() { this.st_open=1; }, timeout:function() { if(this.abrt) $r.comet.log(this, 'aborted_timeout'); this.disconnect(); this.st_timeout=1; this.onclose.call(this.scope, 'timeout', this); }, drop:function() { if(this.abrt) return; this.disconnect(); this.onclose.call(this.scope, 'drop', this); } }); if(window.EventSource && $u.ua!='m') $r.ct.EventSource = $class($r.ct.Base, { type:5, connect:function() { $super(this,arguments); var t=this.t=new EventSource(this.url); t.onopen=this.open_; t.onerror=this.drop_; t.onmessage=this.p_; }, drop:function() { if(this.t.readyState==2 && !this.abrt) this.st_error=1; $super(this,arguments); }, disconnect:function() { $super(this,arguments); this.t && this.t.close(); this.t=null; } }); if(window.ActiveXObject && !window.XDomainRequest) $r.ct.IFrame = $class($r.ct.Base, { type:1, connect:function() { $super(this,arguments); var t=this.t=new ActiveXObject('htmlfile'); t.open(); t.write('<html><script>document.domain="'+document.domain+'";</script><body><iframe src="'+this.url+'"></body></html>'); t.close(); t.parentWindow.p=this.p_, t.parentWindow.r=this.drop_, t.parentWindow.o=this.open_; }, disconnect:function() { $super(this,arguments); var t=this.t; if(t){ var ifr=this.t.body.firstChild; if(ifr){ ifr.src='about:blank'; this.t.body.removeChild(ifr); } t=this.t=ifr=t.parentWindow.p=t.parentWindow.r=t.parentWindow.o=null; } CollectGarbage(); }, p:function() { $super(this,arguments,{data:arguments.length?arguments:''}); } }); $r.ct.LongPolling = $class($r.ct.Base, { type:7, _offs:0, constructor:function() { $super(this,arguments); this.progress_=this.progress.bind(this); }, connect:function() { $super(this,arguments); this._offs=0; var t=this.t=new XMLHttpRequest(); t.onreadystatechange=this.progress_; t.open('GET', this.url, true); t.send(null); }, disconnect:function() { $super(this,arguments); this.t && this.t.abort(); this.t=null; }, parse:function() { var x=this._offs, y, s=this.t.responseText; while(1){ y=s.indexOf('\r\n',x); if(y==-1) break; this.p({data:s.slice(x,y)}); x=y+2; } this._offs=x; }, progress:function() { var t=this.t; if(!this.st_open && t.readyState>1) this.open(); if(t.readyState<3 || ($u.ua_ie && t.readyState<4)) return; if(t.status==200) this.parse(); else if(!this.abrt) this.st_error=1; if(t.readyState==4) this.drop(); } }); $r.ct.Polling = $class($r.ct.LongPolling, { type:8 }); if(!$u.ua_ie && ($u.ua=='ff4' || $u.ua=='ff3' || $u.ua=='cr' || $u.ua=='wk' || $u.ua=='ff2')) $r.ct.XHRInteractive = $class($r.ct.LongPolling, { type:2 }); if(window.XDomainRequest) $r.ct.XDR = $class($r.ct.LongPolling, { type:4, constructor:function() { $super(this,arguments); this.load_=this.load.bind(this); }, connect:function() { $r.ct.Base.prototype.connect.call(this); var t=this.t=new XDomainRequest(); t.onerror=this.drop_; t.onload=this.load_; t.ontimeout=this.drop_; t.onprogress=this.progress_; t.timeout=this.ping_time; t.open('GET', this.url); t.send(); }, load:function() { this.parse(); $r.ct.Base.prototype.drop.call(this); }, drop:function() { this.st_error=1; $super(this,arguments); }, progress:function() { if(!this.st_open) this.open(); this.parse(); } }); $r.ct.Best=$r.ct.EventSource || $r.ct.XDR || $r.ct.IFrame || $r.ct.XHRInteractive || $r.ct.LongPolling; $r.comet=$class(Observable, { url:'', user_id:0, session_id:'', t:null, degrade:0, mode:'normal', slave:0, params:{}, _n:0, run:0, conn_t:null, constructor:function() { $super(this,arguments); this.conn_t=new $t(this.connect, this); setTimeout(this.ping.bind(this), 1800000); }, ping:function() { if(!this.run) return; new $r('/ping.phtml?'+(+new Date),{ ready:this.ping_ready }, this); setTimeout(this.ping.bind(this), 1800000); }, ping_ready:function(res) { this.fire('session_change', res.user_id, res.session_id); }, session_change:function(uid,sid) { if(this.user_id==uid && this.session_id==sid || !uid || !sid) return; this.user_id=uid, this.session_id=sid; this.soft_reconnect(); }, channel:function(name, params, ctx) { if(params instanceof Function) this.params[name]=[params,ctx]; else this.params[name]=params; this._n++; }, get_params:function(type) { var ar=[], params=this.params; params['comet']={ 'mode':this.mode, 'ua':$u.ua, 'type':type, 'uid':this.user_id, 'sid':this.session_id }; for(var i in params){ var p=params[i]; if(p instanceof Array) p=p[0].call(p[1]); ar[ar.length]=i+'='+$r.toQueryString(p).replace(/=/g,':').replace(/&/g,','); } return ar.join('&'); }, onmessage:function(t,args) { if(!this.run) return; var type=args[0]; if(t!=this.t){ $r.comet.log(t, 'wrong_id,'+type); if(type=='master'||type=='slave'||type=='unauth') return; } if(type=='master'){ this.comet_master(t); }else if(type=='slave'){ this.comet_slave(t); }else if(type=='unauth'){ this.unauth(); } this.fire.apply(this,args); }, comet_master:function(t) { this.t.disconnect(); this.slave=0; if(this.mode=='slave') this.mode='normal'; this.reconnect('master',t); }, comet_slave:function(t) { this.t.disconnect(); if(this.mode!='master'){ this.mode='slave'; this.slave=1; } this.reconnect('slave',t); }, reconnect:function(type,t) { if(!this.run) return; if(type!='drop'){ $r.comet.log(t, 'rcn:'+type, 'debug'); } var time=10; if(!t.active && (t.st_error || t.st_timeout)){ time=1000*([5,10,30,60][this.ert++]||120); time=Math.round(time+time/3*Math.random()); }else{ this.ert=0; if(t.type==8 && type!='master'){ time=20000; }else if(type=='master' || ((this.mode=='normal' || this.mode=='master') && type=='drop')){ time=10; }else if(type=='slave'){ time=this.slave?3000:1000; }else{ time=3000; } } this.conn_t.set(time); }, connect:function() { if(!this.run) return; this.get_transport(); this.t.connect(); }, soft_reconnect:function() { if(!this.run){ this.start(); }else{ this.t && this.t.disconnect(); this.conn_t.set(10); } }, get_transport:function() { var T; if(this.slave){ T=$r.ct.Polling; }else if(this.degrade>2){ T=$r.ct.LongPolling; }else{ T=$r.ct.Best; } this.t=new T(this.url+'?'+this.get_params(T.prototype.type),{ onmessage:this.onmessage, onclose:this.close }, this); }, close:function(type,t) { if(!this.run) return; if(t!=this.t){ $r.comet.log(t, 'wrong_id,'+type); return; } if(!t.active) this.degrade++; this.reconnect(type, t); }, start:function() { $config(this, $vars['comet']); if(!this.url || !this._n) return; this.run=1; $e.add(window, 'beforeunload', this.stop.bind(this)); if($u.ua=='wk' || $u.ua=='cr' || $u.ua=='m'){ $e.add(window,'load',(function(){ this.conn_t.set(50); }).bind(this)); }else{ this.conn_t.set(10); } }, stop:function() { this.conn_t.clear(); this.t && this.t.disconnect(); this.t=null; this.run=0; }, unauth:function(uid_sess) { this.stop(); }, send:function(data) { if(!this.run) return; new $r(this.url+'?'+this.get_params(8)+'&t='+(this.t?this.t.id:0),{ method:'post', params:data }); }, delivered:function(type,params) { new $r(this.url+'?delivered='+type,{ params:params }); }, log:function(t,msg,debug) { if(debug && this.url!='/ctjs/1/') return; new $r(this.url+'?log='+msg,{ params:{ uid:this.user_id, ua:$u.ua, type:t?t.type:0, mode:this.mode, id:this.t?this.t.id:0, tid:t?t.id:0, tst:t?t.st_open+'-'+t.active+'-'+t.st_timeout+'-'+t.st_error:'' } }); } }); $r.comet=new $r.comet(); (function(){ var IM=B.IM=new Observable(); $u.flash={ detected:{}, version:[ 0, 0, 0 ], init:function(version) { if(!(version in this.detected)) this.detected[version]=this._detect(version); return this.detected[version]; }, _detect:function(version) { var a=null; var d=''; if($u.ua_ie){ try{ a=new ActiveXObject('ShockwaveFlash.ShockwaveFlash.'+version); if(version<=6) d='WIN 6,0,21,0'; a.AllowScriptAccess='always'; d=a.GetVariable('$version'); }catch(er){ if(version>6) return false; } if(!a) return false; if(d){ d=d.split(" ")[1].split(","); this.version=[ parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10) ]; } return true; }else if(navigator.plugins['Shockwave Flash']){ d=navigator.plugins['Shockwave Flash'].description; if(d){ d=d.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); this.version[0]=parseInt(d.replace(/^(.*)\..*$/, "$1"), 10); this.version[1]=parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10); this.version[2]=/r/.test(d)?parseInt(d.replace(/^.*r(.*)$/, "$1"), 10):0; } return (this.version[0] >= version); } return false; }, draw:function(src, width, height, bgcolor, vars, transparent, id, zindex) { var ret='<object id="'+id+'" name="'+id+'" style="z-index:'+(zindex||0)+'" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" '; if(!$u.ua_ie) ret+=' data="'+src+'" '; ret+='>'; if(bgcolor) ret+='<param name="bgcolor" value="'+bgcolor+'">'; if(vars){ if(typeof(vars)=='object'){ var v=[]; for(var key in vars){ v.push(key+"="+encodeURIComponent(vars[key])); } vars=v.join('&'); } ret+='<param name="FlashVars" value="'+vars+'">'; } if(transparent) ret+='<param name="wmode" value="transparent">'; if($u.ua_ie) ret+='<param name="movie" value="'+src+'">'; return ret+'<param name="allowFullScreen" value="true">\ <param name="allowScriptAccess" value="always">\ <param name="menu" value="false">\ <param name="quality" value="high">\ </object>'; } }; IM.Sound=new $class(B.Page, { name:'im-sound', sound:0, allow_swf:1, url:JSRoot+'flash/new-msg.', type:'none', t:null, _ready:0, init:function() { IM.on({ 'sound':this.play },this); $e.on({ '#turnsound':this.turn_sound },this); this.enable_sound_=this.enable_sound.bind(this); this.w=$('Baloon')||$('flash'); }, turn_sound:function(el) { this.sound=$el.tgl(el,'off'); new $r(el.rel); el.rel=el.rel.replace(/sound=[01]/,'sound='+(+!this.sound)); IM.fire('focus'); }, prepare:function() { this._ready=1; var t=document.createElement('audio'); if(t && t.canPlayType){ if(t.canPlayType('audio/mpeg;').replace('no','')){ this.url+='mp3'; }else if(t.canPlayType('audio/ogg; codecs="vorbis"').replace('no','')){ this.url+='ogg'; }else if(t.canPlayType('audio/wav; codecs="1"').replace('no','')){ this.url+='wav'; }else{ t=null; } if(t){ this.type='audio'; t.preload='auto'; t.autoplay='true'; t.src='http:'+this.url; this.w.appendChild(t); t.load(); } this.t=t; } if(!this.t && this.allow_swf && $u.flash.init(9)){ this.w.innerHTML=$u.flash.draw(this.url+'swf', '1', '1', '#fff', '', false, 'sound_swf'); this.t=$('sound_swf'); this.type='flash'; } }, _st:0, play:function(){ if(!this.sound || this._st || !this.w) return; if(!this._ready){ this.prepare(); }else if(this.t) try{ if(this.type=='flash') this.t.play_sound(); if(this.type=='audio') this.t.play(); }catch(er){} setTimeout(this.enable_sound_, 1000); this._st=1; }, enable_sound:function() { this._st=0; } }); IM.Link=new $class(B.Page, { name:'im-link', uid:0, sid:'', mid:0, msg_count:0, mb:null, link_blink:true, slave:0, opening:false, init:function() { this.mb=$('mb'); if(!this.mb || !this.uid) return; $e.on('.im-open', this.open2, this); if(this.link_blink){ this.blink_fn=this.blink.bind(this); if(this.msg_count) this.blink_start(); } $r.comet.channel('im',this.comet_params,this); $r.comet.on({ 'im:new_msg':this.new_msg, 'unauth':this.im_close, 'master':this.comet_master, 'slave':this.comet_slave, 'session_change':this.session_change },this); this.slave=sessionStorage.getItem('comet-slave') || 0; if(this.slave){ $r.comet.mode='slave'; $r.comet.slave=1; } $r.comet.start(); $u.storage.on('nm', this.new_msgR, this); }, comet_params:function() { return { mid:this.mid }; }, session_change:function(uid,sid) { if(this.uid==uid && this.sid==sid || !uid || !sid) return; this.uid=uid, this.sid=sid; }, comet_master:function() { this.slave=0; sessionStorage.removeItem('comet-slave'); }, comet_slave:function() { this.slave=1; sessionStorage.setItem('comet-slave',1); }, new_msg:function(id, txt, mid) { if(id==this.uid) return; this.mid=mid; this.msg_count++; if(this.slave) this.comet_master(); $u.storage.setItem('nm',this.msg_count); this.unread_messages(this.msg_count); $r.comet.delivered('im',{uid:this.uid,mid:mid}); IM.fire('sound'); }, new_msgR:function(v) { var n=+$u.storage.getItem('nm')||0; if(n!=this.msg_count) this.unread_messages(n); }, new_msgW:function(n) { $u.storage.setItem('nm',n); this.unread_messages(n); }, open:function(el) { if(!el || this.opening) return; if(el.target.substr(0, 3)!='my_' || el.target!='my_'+this.uid){ $r.comet.log(null, 'target:'+el.target+'&url='+encodeURIComponent(window.location.href)); return true; } var href=el.href; var tmp=href.split('/'); tmp.pop(); var u=tmp.pop(), opened=false; if(this.imw && this.imw.closed==false){ try{ this.imw.IM.fire('user_add',u); opened=true; this.imw.focus(); }catch(er){} } if(!opened){ this.imw=null; this.opening=true; this.imw=window.open(href, el.target, 'width=700,height=580,resizable=1,toolbar=0,location=0,status=0,menubar=0,directories=0,scrollbars=no'); this.opening=false; } }, open2:function(el) { var a=el && el.parentNode.getElementsByTagName('A'); if(!el || !a.length) return true; return this.open(a[0]); }, unread_messages:function(n) { if(!this.mb) return; this.msg_count=+n||0; this.mb.innerHTML=this.mb.innerHTML.replace(/\d+/,this.msg_count); if(n){ $el.del(this.mb,'sm_mb_h'); if(this.link_blink) this.blink_start(); }else{ $el.add(this.mb,'sm_mb_h'); if(this.link_blink) this.blink_stop(); } IM.fire('msg_upd', this.msg_count); }, blink_i:0, blink_timer:0, blink_start:function() { this.blink_i=0; this.mb.style.visibility=''; if(this.blink_timer) return; this.blink_timer=setInterval(this.blink_fn,500); }, blink_stop:function() { if(!this.blink_timer) return; this.mb.style.visibility=''; clearInterval(this.blink_timer); this.blink_timer=this.blink_i=0; }, blink:function() { this.blink_i=(this.blink_i+1)%3; this.mb.style.visibility=this.blink_i?'':'hidden'; }, im_close:function(uid_sess) { var _=uid_sess.split(' '); if(_[0]!=this.uid || _[1]!=this.sid){ $r.comet.log(null,'unauth&'+this.uid+'='+_[0]+'&'+this.sid+'='+_[1]); } } }); })(); B.Toggle=new $class(B.Page,{ init:function() { $e.on({ '.jst, * .jst':this.toggle, '.jss':this.set },this); }, toggle:function(el, set) { var wrap=$el.up(el,'.jsw'); if(!wrap) return; var cls=el.rel || (el.nodeName=='INPUT' && 'jse_'+el.value) || 'jse', fn=set && function(el,cl){el.className='jsw '+cl} || $el.tgl; if(cls.indexOf(' ')!=-1){ if(set) fn(wrap,cls); else for(var i=0, st=cls.split(' '), n=st.length; i<n; i++) fn(wrap,st[i]); }else{ fn(wrap,cls); } if(dOvl._visible) dOvl.center(); if(el.nodeName=='INPUT') return true; }, set:function(el) { return this.toggle(el,true); } }); B.UserCounter={}; B.UserCounter.format_number=function(v,sp) { var n=+v||0, s=''+n, i=s.length%3||3; return s.slice(0,i+(n<0))+s.slice(i).replace(/(\d{3})/g, sp + '$1'); }; B.UserCounter.start=function(name, from, to) { var els=$el.select('.uc_'+name); if(!els.length) return null; var val=B.UserCounter.clean(els[0].innerHTML); var _=function() { val+=Math.round(from+Math.random()*(to-from)); for(var i=0, n=els.length; i<n; i++) els[i].innerHTML=B.UserCounter.format_number(val,B.UserCounter.separator); }; _.destroy=function(){ els=null; }; return _; }; B.UserCounter.clean=function(txt) { B.UserCounter.clean=function(txt) { return parseInt(txt.replace(/\D/g,'')); }; var m=/\D/.exec(txt.replace(/^\D+|\D+$/g,'')); B.UserCounter.separator=m && m[0] || ' '; return B.UserCounter.clean(txt); }; B.UserCounter.Page=new $class( { fns:[], _timer:0, timeout: 3, constructor:function() { $e.add(window,'load',this.loaded,this); }, loaded:function() { this.add('user_total', 0, 4*this.timeout); this.add('photo', 0, 25*this.timeout); if(this.fns.length){ this._timer=setInterval(this.update.bind(this),this.timeout*1000); $e.add(window,'unload',this.destroy,this); } }, destroy:function() { clearInterval(this._timer); var fns=this.fns; for(var i=0, n=fns.length; i<n; i++){ fns[i].destroy(); } this.fns=[]; }, add:function(name, from, to) { var counter=B.UserCounter.start(name, from, to); if(counter) this.fns[this.fns.length]=counter; }, update:function() { var fns=this.fns; for(var i=0, n=fns.length; i<n; i++){ fns[i](); } } }); B.UploadFbc={ fb_ready:function(url) { setTimeout(function(){ dOvl.open_ex({type:'upload-import-fbc', url:url+'&ws=1'}); }, 100); }, fb_import_ready:function() { var form=$el.up($('fb_import_iframe'), 'form'); if(B.Import) B.Import._import_forms[1].submit() ; else if(B.UploadImport) B.UploadImport._import_forms[1].submit() ; } };
