var dTooltip=$class({ el:null, type:'', target:'', cel:null, x:0, y:0, html:'', images:[], scope:null, _re:null, _wrap:null, _cont:null, _tpl:'<div class="js_tooltip pngbox">\ <div class="tpt">\ <div class="bpt">\ <div class="cont">\ {html}\ </div>\ <div class="bpc"></div>\ </div>\ </div>\ <div class="tcn"></div>\ <div class="bcn"></div>\ </div>', constructor:function(config) { $config(this,config); this.init(); }, init:function() { if(!this.el) throw new Error('No element for dTooltip'); this._re=new RegExp('(^|\\s)'+this.target+'(\\s|$)'); this._wrap=$u.el('div',{ id:'dTooltipWrap', className:'hidden', innerHTML:this._tpl }); this._cont = $q.down(this._wrap, '.cont'); document.body.appendChild(this._wrap); this.attachEventHandlers(); if(this.images.length) $e.add(window,'load',$u.preloadImages.bind(null,this.images)); }, attachEventHandlers :function() { $e.add(this.el,'mouseover',this.test,this); $e.add(this.el,'mouseout',this.test,this); $e.add(this._wrap,'mouseout',this.test,this); }, detachEventHandlers :function() { $e.del(this.el,'mouseover',this.test,this); $e.del(this.el,'mouseout',this.test,this); $e.del(this._wrap,'mouseout',this.test,this); }, destroy:function() { this.detachEventHandlers (); $el.remove(this._wrap); this._wrap=null; this._cont=null; this.el=null; }, test:function(el) { var e=$e.e; if(e.type=='mouseout') el=e.relatedTarget||e.toElement; var p=el, cel=this.cel, w=this._wrap, b=document.body, re=this._re; if(el==cel) return; while(p && p!=cel && p!=w && !re.test(p.className) && p!=b) p=p.parentNode; if(!p || p==b) this.hide(); else if(p!=w && p!=cel) this.show(p); }, show:function(el) { this.cel=el; var config=this.format.call(this.scope || this,$(el)); if(el) el.title=''; this._cont.innerHTML=config.html; this._wrap.style.left=config.left+'px'; this._wrap.style.top=config.top+'px'; this._wrap.className=this.type; }, hide:function() { this._wrap.className='hidden'; this.cel=null; }, format:function(el) { var e=$e.e; var html=el.title; var xy=$e.pointerXY(e); return { left:xy.x, top:xy.y, html:html }; } }); var SLUpdater = function (config) { $config(this, config); this.init(); }; SLUpdater.prototype = { spotlight: null, spotlightVars: null, sls: {}, slp_id: -1, submit_bn:null, params:{}, timeout: 8000, update_ts:0, profileUrl: '', secondUrl: '/sl/list-ws-json/', firstUrl: '/sl/ws/', init: function() { if(!this.spotlightVars) return; this.sls = this.spotlightVars && this.spotlightVars.sls || {}; this.params = this.spotlightVars.params; if (this.spotlightVars.items) this.items = eval('('+this.spotlightVars.items+')'); else this.items = []; this.update_ts = this.params.ts; this.requestParams = { language_id: this.params.lid, spotlight_id: this.params.sid }; this.firstRequest_fn = this.request1.bind(this); this.timerInt = setTimeout(this.firstRequest_fn, this.timeout); }, destroy: function() { clearTimeout(this.timerInt); if (this._t1) { this._t1.abort(); this._t1 = null; } if (this._t2) { this._t2.abort(); this._t2 = null; } this.spotlight = null; }, getProfileUrl: function(r) { var url = window.location.protocol+'\/\/' + (this.params.b?('{login}.' + this.params.s) : (this.params.s + '/{login}')); return url; }, request1: function() { this.getRequest1Transport().request(); }, getRequest1Transport: function(transport) { if (this._t1) return this._t1; this._t1 = new $r(this.firstUrl,{ method: 'get', auto:false, params:this.requestParams, error:this.request1Error, readyEx: this.firstRequestHandler }, this); return this._t1; }, firstRequestHandler : function(transport) { var ts = transport.transport.responseText; if(ts != this.update_ts) { this.update_ts = ts; this.request2(ts); } else { this.runTimeout(); } }, request1Error: function() { this.runTimeout(); }, runTimeout: function() { this.timerInt = setTimeout(this.firstRequest_fn, this.timeout); }, request2: function(ts) { this.getRequest2Transport().request(); }, getRequest2Transport: function(ts) { if (this._t2) return this._t2; this._t2 = new $r (this.secondUrl,{ method: 'get', auto:false, params:this.requestParams, ready: this.secondRequestHandler }, this); return this._t2; }, secondRequestHandler: function(res) { this.items = res; if (this.spotlight) { this.spotlight.updateLayout(this.items); this.timerInt = setTimeout(this.firstRequest_fn, this.timeout); } } }; var SLTooltip = $class(dTooltip,{ tooltipHtmlContent: '', userUrl: '', leftOfs: 0, spotlight: null, visible: false, init:function() { if(!this.el) throw new Error('No element for dTooltip'); this._re=new RegExp('(^|\\s)'+this.target+'(\\s|$)'); this._wrap=$u.el('div',{ id:'dTooltipWrap', className:'hidden', innerHTML:this._tpl }); this._cont = $q.down(this._wrap, '.cont'); $e.add(window,'load',$u.preloadImages.bind(null,[JSRoot + 'i/box-spot.png'])); }, delayedDOMChange: function() { document.body.appendChild(this._wrap); this.attachEventHandlers(); }, format: function(userUrl, html, x) { var tooltipHtmlContent = html.replace('<mask>', userUrl), tl = $el.cumulativeOffset(this.el); return { html: tooltipHtmlContent, left: tl.left + 0 + x +40, top: tl.top + 82+ (this.is_wizard?(document.documentElement.scrollTop || document.body.scrollTop) - (document.documentElement.clientTop || 0):0) }; }, mouseOverHandler: function() { this.mouseOvered = true; }, mouseOutHandler: function() { var e = $e.e, el=e.relatedTarget||e.toElement; if (!el) { this.hide(); return; } var n = el; while (n && n != document.body) { if (n == this.el) { this.mouseOvered = false; return; } if (n == this._wrap) { this.mouseOvered = true; return; } try { n = n.parentNode; } catch (e) { n = null; } } this.hide(); }, show: function(x, tooltip_html, user_url) { var leftOfs = parseInt(x) - 25, config=this.format(user_url, tooltip_html, leftOfs); this._cont.innerHTML=config.html; var sl_add_btn_class = ''; try { if (Spotlight.slLine.focI == 0) sl_add_btn_class = ' sl_add_btn_tooltip'; } catch (e) { } this._wrap.className=this.type + sl_add_btn_class; this.fit(config); this._wrap.style.left=config.left+'px', this._wrap.style.top=config.top+'px', this.mouseOvered = false, this.visible = true; }, fit:function(config) { var tl=$el.cumulativeOffset(this.el), t=tl.left+this.el.offsetWidth-(config.left+this._wrap.offsetWidth); if(t<20) config.left=config.left+t-60; }, hide:function() { this.mouseOvered = false, this._wrap.style.top='-1000px', this.cel=null; if (this.visible) { this.visible = false; this.spotlight.checkFromTooltip(); } }, attachEventHandlers : function() { $e.add(this._wrap,'mouseout',this.mouseOutHandler,this); $e.add(this._wrap,'mouseover',this.mouseOverHandler,this); }, detachEventHandlers :function() { $e.del(this._wrap,'mouseout',this.mouseOutHandler,this); $e.del(this._wrap,'mouseover',this.mouseOverHandler,this); } }); var SLLine=function(config) { $config(this, config); this.init(); }; SLLine.prototype={ spotlight: null, rightBorderDiv:null, cnvs: null, cnvs_wrap: null, items: [], profileURL: "", imgs: [], addBtnImg: null, imgNum: 9, minImgNum: 9, intrv: 3, min: 83, max: 110, originMinSize: 83, originMaxSize: 110, timeOut: 15, timerInt: -1, sp: null, focI: -1, leftOfs: 10, spLeft: 230, spTop: 0, spWidth: 800, spHeight: 120, canvasImgTop: 15, vmlImgTop: 4, imgTop: 30, firstImgLeft: 17, addBtnLeft: 17, applyTimeoutInt:0, applyTimeout: 15, zoomDuration: 250, zoomOutDuration: 250, opacityDuration: 300, updateDuration: 1000, normalSize: 890, zoom: 1, startAlpha: 100, tooltipImgIndex: -1, need2ShowTooltip: -1, need2RemovePreviousItems: false, updateIsAvailable:true, tempUpdateLayoutParams: null, canvasImgBackground: "rgb(228,217,255)", ofsAnimationMode: false, ie6Mode: false, subscribedAnimQueue: [], init: function () { this.resize_binded=this.resize.bind(this), this.timer_binded=this.timer.bind(this), this.showTooltip2_binded=this.showTooltip2.bind(this), this.opacityWaveStep_binded=this.opacityWaveStep.bind(this), this.fullUpdateStart_binded=this.fullUpdateStart.bind(this); $e.on({ '.sl_add_btn, * .sl_add_btn_tooltip, .sl_add_btn_tooltip': this.openWizard }, this); this.rightBorderDiv = $('sl_plug'); this.imgNum = this.items.length < this.minImgNum ? this.items.length : this.minImgNum; this.updateImgLeft(); this.setupZoom(); if(/*@cc_on!@*/false) { this.zoomDuration = 350; this.zoomOutDuration = 400; this.applyTimeout=10, this.timeOut=10, this.imgTop=this.vmlImgTop, this.applyChanges=this.applyChangesVML; $e.add(window, 'resize', this.resizeIE, this); this.initVML(); } else { this.zoomDuration = 250; this.zoomOutDuration = 250; this.applyTimeout=20, this.timeOut=20; this.imgTop=this.canvasImgTop, this.applyChanges=this.applyChangesCanvas; $e.add(window, 'resize', this.resize, this); this.initCanvas(); } this.applyChanges_bind=this.applyChanges.bind(this); }, destroy: function () { this.stopTimer (); this.stopApplyChangesTimer (); clearInterval(this.showTooltipInt); clearInterval(this.resizeIEInt); clearInterval(this.zoomOutInt); clearInterval(this.showTooltipInt); clearInterval(this.fullUpdateStartInt); clearInterval(this.opacityWaveInt); if(/*@cc_on!@*/false) { $e.del(window, 'resize', this.resizeIE, this); $e.del(this.sp, 'mouseover', this.mouseOver, this); $e.del(this.sp, 'mouseout', this.mouseOut, this); } else { $e.del(window, 'resize', this.resize, this); $e.del(this.cnvs_wrap, 'mousemove', this.mouseMove, this); $e.del(this.cnvs_wrap, 'mouseout', this.cnvsMouseOut, this); $e.del(this.cnvs_wrap, 'click', this.canvasClickHandler, this); } var imgs=this.imgs; if (this.addBtnImg) { this.addBtnImg.destroy(); } if (imgs) { for (var i=0, imgNum=this.imgNum; i < imgNum; i++) { var d=imgs[i]; d.destroy(); } } this.addBtnImg=this.subscribedAnimQueue=this.imgs=this.rightBorderDiv=this.VMLPattern=this.cnvs=this.cnvs_wrap=this.sp=this.ctx=null; return true; }, initCanvas: function () { var cnvs_wrap=$("cnvs_wrap"), cnvs=$("cnvs"); this.cnvs_wrap =cnvs_wrap, this.cnvs=cnvs; var tl=$el.cumulativeOffset(cnvs_wrap); this.spLeft=tl.left, this.spTop=tl.top, this.spWidth=parseInt(cnvs_wrap.offsetWidth), this.spHeight=parseInt(cnvs_wrap.offsetHeight), cnvs.width=this.spWidth, cnvs.height=this.spHeight, this.sp=cnvs; var ctx=cnvs.getContext('2d'); this.ctx=ctx; ctx.fillStyle=this.canvasImgBackground, ctx.lineWidth=1, ctx.globalAlpha=this.startAlpha / 100, this.prevCtxAlpha=this.startAlpha / 100; var img=$("img_add_btn"); img.parentNode.style.display='none'; var d=this.newImg(this.addBtnLeft); d.sp=this; d.image=img; this.addBtnImg=d; d.draw(); var ofs=this.firstImgLeft; for (var i=0; i < this.imgNum; i++) { var img=$("img" + i); img.parentNode.style.display='none'; var d=this.newImg(ofs); d.sp=this, d.image=img, d.draw(), this.imgs[this.imgs.length]=d; ofs += this.min + this.intrv; } $e.add(cnvs_wrap, 'mousemove', this.mouseMove, this); $e.add(cnvs_wrap, 'mouseout', this.cnvsMouseOut, this); $e.add(cnvs_wrap, 'click', this.canvasClickHandler, this); }, initVML: function () { var sp=$("sp"), tl=$el.cumulativeOffset(sp); this.sp=sp, this.spLeft=tl.left, this.spTop=tl.top, this.spWidth=parseInt(sp.offsetWidth), this.spHeight=parseInt(sp.offsetHeight), this.ie6Mode=_ua=='ie6'; var img=$("img_add_btn"), vml_img=$("vml_img_add_btn"), anchor=img.parentNode; anchor.title='', img.index=0, vml_img.index=0, anchor.index=0; var d=this.newImg(this.addBtnLeft, anchor, img, vml_img); d.sp=this, this.addBtnImg=d, d.anchor=anchor; d.a.elV = 0; d.a.v = 100; d.drawVMLDirect(); var ofs=this.firstImgLeft; for (var i=0; i < this.imgNum; i++) { var img=$("img" + i), vml_img=$("vml_img" + i), anchor=img.parentNode; img.index=i+1, vml_img.index=i+1, anchor.index=i+1, anchor.title=''; var d=this.newImg(ofs, anchor, img, vml_img); d.sp=this, this.imgs[this.imgs.length]=d, d.anchor=anchor; d.drawVMLDirect(); ofs += this.min + this.intrv; } this.initVMLPattern(); $e.add(sp, 'mouseover', this.mouseOver, this); $e.add(sp, 'mouseout', this.mouseOut, this); }, resizeIEInt: 0, resizeIE: function() { if (this.resizeIEInt) clearInterval(this.resizeIEInt); this.resizeIEInt=setTimeout(this.resize_binded, 20); }, resize: function() { this.setupZoom(); }, updateImgLeft: function(skipImageUpdate) { this.firstImgLeft = this.addBtnLeft + this.min + this.intrv; }, updateRightBorder: function() { var rightBorder = this.firstImgLeft + (this.intrv + this.min) * this.minImgNum; var rightBorderW = this.spWidth - rightBorder + 10; this.rightBorderDiv.style.width = rightBorderW + 'px', this.rightBorderDiv.style.left = rightBorder + 'px'; }, setupZoom: function(skipImageUpdate) { var normalSize=this.normalSize; var slline=$('slline'); var tl=$el.cumulativeOffset(slline); this.spLeft=tl.left; this.spWidth=parseInt(slline.offsetWidth); var currentSize=this.spWidth > normalSize ? normalSize : this.spWidth; this.zoom=Math.round((currentSize * 100 / normalSize)) / 100; var newMinSize=Math.round( this.originMinSize * this.zoom), newMaxSize=Math.round( this.originMaxSize * this.zoom); if (newMinSize != this.min || newMaxSize != this.max) { this.min=newMinSize, this.max=newMaxSize; this.updateImgLeft(); if (skipImageUpdate) return; if (this.imgs && this.imgs.length > 0) { var imgNum=this.imgNum, imgs=this.imgs, ofs=this.firstImgLeft; for (var i=0; i < imgNum; i++) { var d=imgs[i]; d.left.v=ofs; ofs += this.min + this.intrv; } this.setupDestSize(-1000, this.min, 250); } } }, newImg: function(ofs, anchor, img, vml_img) { var d=new sIm ({ w: { elV: this.min,v: this.min,d: this.min,s: this.min,top: this.imgTop,elTop: this.imgTop,dur: this.zoomDuration }, a: {elV: this.startAlpha,d: this.startAlpha,s: this.startAlpha,v: this.startAlpha,dur: this.opacityDuration}, left: {elV: ofs,d: ofs,s: ofs,v: ofs,dur: this.zoomDuration }, anchor: anchor, image: img, vml_image: vml_img }); return d; }, valueByTime: function(t,b,c,d) { var v=Math.round( (c - b) *((t=t/d-1)*t*t+1)+b); if (b > c) { if (v < c ) v=c; } else { if (v > c) v=c; } return v; }, sizeByTime: function(t,b,c,d) { var v=Math.round( (c - b) *((t=t/d-1)*t*t+1)+b); if (b > c) { if (v < c ) v=c; } else { if (v > c) v=c; } if (v < this.min) { v=this.min; } if (v > this.max) { v=this.max; } return v; }, startTimer: function () { clearInterval(this.timerInt); this.timerInt=setInterval(this.timer_binded, this.timeOut); this.startApplyChangesTimer(); }, stopTimer: function () { clearInterval(this.timerInt); this.applyChanges(); this.stopApplyChangesTimer(); }, setupDestLeft: function (dur) { var dur=dur || this.zoomDuration, sum=0, minSum=this.min * this.imgNum, imgs=[this.addBtnImg].concat(this.imgs), imgNum=this.imgNum + 1; for (var i=0; i < imgNum; i++) { var d=imgs[i]; sum += d.w.d; } var firstImgLeft = this.addBtnLeft, curTime=new Date().getTime(), focI=this.focI; if (sum > minSum && focI >= 0 && focI < imgs.length) { var d=imgs[focI], focusedPos= firstImgLeft + focI * (this.min + this.intrv) - Math.round( (d.w.d - this.min)/ 2); d.left.d=focusedPos, d.left.startTime=curTime, d.left.s=d.left.v, d.left.dur=dur; var ofs= focusedPos + d.w.d + this.intrv; for (var i=focI + 1; i < imgNum; i++) { var d=imgs[i]; d.left.d =ofs, d.left.s=d.left.v, d.left.dur=dur, d.left.startTime=curTime; ofs += d.w.d + this.intrv; } var ofs=focusedPos; for (var i=focI - 1; i >= 0 ; i--) { var d=imgs[i]; ofs -= d.w.d + this.intrv; d.left.d =ofs, d.left.startTime=curTime, d.left.dur=dur, d.left.s=d.left.v; } } else { var ofs=0; for (var i=0; i < imgNum; i++) { var d=imgs[i]; d.left.d =ofs + firstImgLeft, d.left.startTime=curTime, d.left.dur=dur, d.left.s=d.left.v; ofs += d.w.d + this.intrv; } } }, opacityWaveDelay: 30, opacityWaveInt: -1, imgWaveIndex: 0, animStep: function () { var need2ProcessMore=false, curTime=new Date().getTime(), imgNum=this.imgNum+1, imgs=[this.addBtnImg].concat(this.imgs), numChanges=0; var wSum=0; for (var i=0; i < imgNum; i++) { var d=imgs[i], changed=false; if (d.a.startTime) { if (d.a.v != d.a.d) { var newAlpha=this.valueByTime(curTime -d.a.startTime,d.a.s, d.a.d, d.a.dur); if (d.a.v != newAlpha) { d.changed=true, d.a.v=newAlpha, changed=true; } if (newAlpha != d.a.d) need2ProcessMore=true; else d.a.startTime=0; } else d.a.startTime=0; } var need2Left = false; if (d.w.startTime) { if (d.w.v != d.w.d) { need2Left = true; var newSize=this.sizeByTime(curTime -d.w.startTime,d.w.s,d.w.d,d.w.dur); var newLeft=this.valueByTime(curTime -d.w.startTime,d.left.s,d.left.d,d.left.dur); if ((Math.abs(d.w.d - d.w.s) != this.max - this.min) || ((Math.abs(newSize - d.w.v) >=2) ) || ((Math.abs(d.left.d - d.left.s)) >= this.min) || (newSize == d.w.d)) { d.w.v=newSize, d.w.top=this.imgTop - Math.round((d.w.v - this.min) / 2), d.changed=true, changed=true; if (d.left.v != d.left.d ) { if (d.left.v != newLeft) { d.changed=true, d.left.v=newLeft, changed=true; } } } } if (d.left.startTime && !need2Left) { if (d.left.v != d.left.d ) { var newLeft=this.valueByTime(curTime -d.w.startTime,d.left.s,d.left.d,d.left.dur); if (d.left.v != newLeft) { d.changed=true, d.left.v=newLeft, changed=true; } if (newLeft != d.left.d) need2ProcessMore=true; else d.left.startTime=0; } } if (d.w.v == d.w.d && d.w.d == this.max && this.tooltipImgIndex != i) { this.need2ShowTooltip=i; } if (d.w.v != d.w.d || d.left.v != d.left.d) need2ProcessMore=true; else d.w.startTime=0; } wSum += d.w.v; if (changed) numChanges++; } this.numChanges=numChanges, this.need2ProcessMore=need2ProcessMore; if (numChanges > 0 && !need2ProcessMore && wSum == imgs.length * this.min) { if (!this.updateIsAvailable && !this.spotlight.slTooltip.visible) { this.processDelayedUpdate(); } } if (!need2ProcessMore && this.ofsAnimationMode) this.stopOfsAnimationEvent(); return need2ProcessMore; }, showTooltip: function() { if (this.need2ShowTooltip == -1) return; this.showTooltipInt=setTimeout(this.showTooltip2_binded, 150); }, showTooltip2: function() { if (!this.imgs || this.need2ShowTooltip == -1 || this.need2ProcessMore || this.need2ShowTooltip != this.focI) return; var simIndex=this.need2ShowTooltip; this.need2ShowTooltip=-1; this.tooltipImgIndex=simIndex; if (simIndex == 0) { var sim=this.addBtnImg; var tooltipStr=this.spotlight.addBtnToolip; var userUrl=''; } else { var sim=this.imgs [simIndex - 1]; var item=this.items[simIndex - 1]; var tooltipStr=item.tooltip; var userUrl=this.profileURL.replace('{login}', item.login); } var leftOfs=sim.left.elV; this.spotlight.tooltip(tooltipStr, leftOfs, userUrl); }, hideTooltip: function() { this.tooltipImgIndex=-1; this.spotlight.tooltip_hide(); }, applyChangesCanvas: function () { this.processSubscribedAnimQueue(); if (this.cnvs.width != this.spWidth) { this.cnvs.width=this.spWidth, this.ctx.fillStyle=this.canvasImgBackground; this.fullCanvasRedraw(); return; } if (this.numChanges == 0) return; if (this.numChanges <= 4) this.fullCanvasRedraw(); else this.fullCanvasRedraw(); this.numChanges=0; if (this.need2ShowTooltip >=0) this.showTooltip(); }, canvasRedrawByImages: function () { var imgs=this.imgs, ctx=this.ctx, changes=this.changes; for (var i=0, n= this.imgNum; i < n; i++) { var d=imgs[i]; if (d.changed) { ctx.clearRect(d.left.elV - 2, d.w.elTop - 2, d.w.elV + 4, d.w.elV + 4); d.w.elV=d.w.v, d.left.elV=d.left.v, d.w.elTop=d.w.top, d.a.elV=d.a.v; if (d.a.elV / 100 != this.prevCtxAlpha) { this.prevCtxAlpha=d.a.elV / 100; ctx.globalAlpha=this.prevCtxAlpha; } d.draw(); } } var d = this.addBtnImg; if (d.changed) { ctx.clearRect(d.left.elV - 2, d.w.elTop - 2, d.w.elV + 4, d.w.elV + 4); d.w.elV=d.w.v, d.left.elV=d.left.v, d.w.elTop=d.w.top, d.a.elV=d.a.v; if (d.a.elV / 100 != this.prevCtxAlpha) { this.prevCtxAlpha=d.a.elV / 100; ctx.globalAlpha=this.prevCtxAlpha; } } d.draw(); }, fullCanvasRedraw: function () { var imgs=this.imgs; var ctx=this.ctx; ctx.clearRect(0, 0, this.spWidth, this.spHeight); for (var i=0, n= this.imgNum; i < n; i++) { var d=imgs[i]; d.w.elV=d.w.v, d.left.elV=d.left.v, d.w.elTop=d.w.top, d.a.elV=d.a.v; d.elFocused= d.focused; if (d.a.elV / 100 != this.prevCtxAlpha) { this.prevCtxAlpha=d.a.elV / 100; ctx.globalAlpha=this.prevCtxAlpha; } d.draw(); } var d = this.addBtnImg; d.w.elV=d.w.v, d.left.elV=d.left.v, d.w.elTop=d.w.top, d.a.elV=d.a.v; d.elFocused= d.focused; if (d.a.elV / 100 != this.prevCtxAlpha) { this.prevCtxAlpha=d.a.elV / 100; ctx.globalAlpha=this.prevCtxAlpha; } this.addBtnImg.draw(); }, applyChangesVML: function () { this.processSubscribedAnimQueue(); var imgs=this.imgs; if (!imgs) return; var d = this.addBtnImg; if (d.changed) d.draw(); for (var i=0, n= this.imgNum; i < n; i++) { var d= imgs[i]; if (d.changed) d.draw(); } this.numChanges=0; if (this.need2ShowTooltip >=0) this.showTooltip(); }, timer: function () { var need2ProcessMore=this.animStep(); if (!need2ProcessMore) this.stopTimer(); }, startApplyChangesTimer: function () { clearInterval(this.applyTimeoutInt); this.applyTimeoutInt= setInterval(this.applyChanges_bind, this.applyTimeout); }, subscribeAnim: function (animDesr) { if (!this.applyTimeoutInt) return false; this.subscribedAnimQueue[this.subscribedAnimQueue.length]=animDesr; return false; }, processSubscribedAnimQueue: function () { var a=this.subscribedAnimQueue; var n=a.length; if (!n) return; for (var i=0;i<n;i++) { var d=a[i]; var d2=null; if (d) { for (var k=n-1;k>=i;k--) { if (d2) { var d3=a[k]; if (d3.func==d.func && d3.scope==d.scope) a[k]=null; } else { d2=a[k]; if (d2.func!=d.func || d2.scope!=d.scope) d2=null; } } } d = d2 || d; d.func.call(d.scope, d.argmts[0]); } this.subscribedAnimQueue=[]; }, stopApplyChangesTimer: function () { clearInterval(this.applyTimeoutInt); this.applyTimeoutInt=0; }, getImageIndex: function (clientX, clientY) { var clientX=clientX - this.spLeft; var clientY=clientY - this.spTop; var descr=this.addBtnImg; if (clientX >= descr.left.elV && clientX < descr.left.elV + descr.w.elV) return 0; for (var i=0, imgs=this.imgs, n=imgs.length; i < n; i++) { var descr= imgs[i]; if (clientX >= descr.left.elV && clientX < descr.left.elV + descr.w.elV) { return i+1; } } return -1; }, openWizard: function () { Spotlight.ovlOpen(); }, spMouseOver: false, imageMouseOverIndex: -1, canvasClickHandler: function () { this.mouseMove(); if (this.focI == 0) { this.openWizard (); } else if (this.focI > 0 && this.focI - 1 < this.items.length) { var item=this.items[this.focI-1]; window.location.href=this.profileURL.replace('{login}', item.login); } }, mouseMove: function () { var event=$e.e, clientX=event.clientX, clientY=event.clientY; if (clientX >= this.spLeft && clientX < this.spLeft + this.spWidth) { this.spMouseOver=true; var imageIndex =this.getImageIndex(clientX, clientY); if (imageIndex == -1 && this.imageMouseOverIndex != -1) { this.imageMouseOverIndex=-1; this.mouseOut({ toElement: this.sp}); this.cnvs_wrap.href="#"; } else if (imageIndex != -1 && imageIndex != this.imageMouseOverIndex) { this.imageMouseOverIndex=imageIndex; this.imageMouseOver({index : imageIndex}); } } else { if (this.spMouseOver) { this.imageMouseOverIndex=-1; this.spMouseOver=false; this.mouseOut({toElement: null}); this.cnvs_wrap.href="#"; } } }, mouseOver: function (event) { var event=$e.e, el=event.target || event.srcElement; if (el == this.sp) return; this.imageMouseOver(el); return true; }, _style_cursor: 'pointer', setupCursorStyle: function (v) { if (this._style_cursor != v) { this._style_cursor=v; this.cnvs_wrap.style.cursor=v; } }, imageMouseOver: function (el) { if (!el || el.index < 0 || el.index >= this.minImgNum+1) return; if (this.cnvs) { this.setupCursorStyle('pointer'); if (el.index >0) { var item=this.items[el.index-1]; this.cnvs_wrap.href=this.profileURL.replace('{login}', item.login); } else this.cnvs_wrap.href='#'; } this.focI=el.index; this.setupDestSize(this.focI, this.max); }, hasAsParent: function (el, parent) { var el=el; while (el && el != document.body) { if (el == parent) return true; try { el=el.parentNode; } catch (e) { return false; } } return false; }, cnvsMouseOut: function (event) { var event=$e.e; var toElement=event.relatedTarget || event.toElement; this.spMouseOver=false, this.imageMouseOverIndex=-1, this.focI=-1; var toTooltip = this.tooltipCheck(event); this.tooltipImgIndex=-1; if (!toTooltip) this.setupDestSize(-1000, this.min, this.zoomOutDuration); }, mouseOut: function (event) { if(/*@cc_on!@*/false) var event=$e.e; else { var event=event || $e.e; } var toElement=event.relatedTarget || event.toElement; if (this.cnvs && (!toElement || !toElement.index)) { this.setupCursorStyle('default'); } if (/*@cc_on!@*/true) { if (toElement == this.cnvs) { return; } } if (this.hasAsParent(toElement, this.sp) || (toElement && toElement.index)) return true; if (/*@cc_on!@*/false) { if (!toElement || (!toElement.index && toElement.index != 0)) { this.spMouseOver=false, this.imageMouseOverIndex=-1, this.focI=-1; var toTooltip = this.tooltipCheck(event); this.tooltipImgIndex=-1; if (!toTooltip) this.setupDestSize(-1000, this.min, this.zoomOutDuration); } } return true; }, tooltipCheck: function (e) { var el=e.relatedTarget || e.toElement; if (!el) { this.hideTooltip(); return false; } var tooltipF = this.hasAsParent(el, this.spotlight.slTooltip._wrap); if (!tooltipF) this.hideTooltip(); return tooltipF; }, zoomOutInt: 0, zoomOut: function (imgIndex, size, dur) { var imgIndex=imgIndex, size=size, dur= dur, scope=this; clearInterval(this.zoomOutInt); this.zoomOutInt=setTimeout(function () { scope.setupDestSize(imgIndex, size, dur); }, 500); }, setupDestSize: function (imgIndex, size, dur) { this.stopTimer(); if (this.zoomOutInt) { clearInterval(this.zoomOutInt); this.zoomOutInt=0; } var dur=dur || this.zoomDuration; var imgs=[this.addBtnImg].concat(this.imgs); if (!imgs) return; if (imgIndex >=0) { this.updateIsAvailable=false; } var curTime=new Date().getTime(), focI=this.focI; for (var i=0, imgNum=this.imgNum+1; i < imgNum; i++) { var d =imgs[i]; d.focused=focI == i, d.w.startTime=curTime, d.w.s=d.w.v, d.w.dur=dur; if (i != imgIndex) { d.w.d=this.min; if (d.w.d < this.min) d.w.d= this.min; } else d.w.d=size; } this.setupDestLeft(dur); this.startTimer(); }, identical: function (a) { for (var i=0, n=a.length; i < n; i++) { var item=a[i]; if (this.getItemIndexByValues(this.items, item) != i) { return false; } } return true; }, updateLayout: function (sljson) { if (!this.updateIsAvailable) { this.tempUpdateLayoutParams=sljson; return; } var newItems=[]; if (sljson instanceof Array) for(var i=0; i < sljson.length; i++){ var item=sljson[i]; newItems[newItems.length]=item; } else for(var itemKey in sljson) { var item=sljson[itemKey]; newItems[newItems.length]=item; } if (this.identical(newItems)) { return; } this.hideTooltip(); clearInterval(this.opacityWaveInt); this.imageMouseOverIndex=-1; if(/*@cc_on!@*/true) this.setupZoom(true); if (!this.items || this.items.length == 0 || newItems.length < this.minImgNum) { this.redrawFullReplace(newItems, 0); } else { this.removePreviousItems (); var ofsIndex=this.getOffsetIndex (newItems); if (ofsIndex >= newItems.length - 1 || ofsIndex == 0) this.redrawFullReplace(newItems, ofsIndex); else this.redrawViaOfsAnimation (newItems, ofsIndex); } }, initVMLPattern: function () { if (this.VMLPattern) return this.VMLPattern; var anchor = this.addBtnImg.anchor; var pattern=anchor.cloneNode(true); var img=pattern.firstChild, vml_img=pattern.lastChild; img.className = "sp_img", vml_img.className = "sp_vml_img", img.src=JSRoot + 'i/blank.gif', vml_img.src=JSRoot + 'i/blank.gif'; this.VMLPattern = pattern; }, getVMLElem: function () { if (!this.VMLPattern) this.initVMLPattern(); var pattern=this.VMLPattern.cloneNode(true); return pattern; }, getImage4Update: function (ofs, imgSrc, profileURL) { if(/*@cc_on!@*/false) { var newEl=this.getVMLElem(); var curFirstElem= this.imgs[0].anchor; this.sp.insertBefore(newEl, curFirstElem); var img=newEl.firstChild, vml_img=newEl.lastChild; newEl.href=profileURL, newEl.style.zIndex = 1000, img.src= imgSrc, newEl.style.left = -1000; if (this.ie6Mode) vml_img.src= imgSrc; var d=this.newImg(ofs, newEl, img, vml_img); d.w.elV=-1, d.sp=this; } else { var d=this.newImg(ofs); var newEl=new Image(); var img=newEl; d.sp=this, d.image=newEl; img.src= imgSrc; } return d; }, startOfsAnimationEvent: function () { this.rightBorderDiv.style.display = 'block'; this.ofsAnimationMode = true; }, stopOfsAnimationEvent: function () { this.rightBorderDiv.style.display = 'none'; this.ofsAnimationMode = false; if (this.need2RemovePreviousItems) { this.removePreviousItems(); if(/*@cc_on!@*/true) this.fullCanvasRedraw(); } }, redrawViaOfsAnimation: function (newItems, ofsIndex) { this.updateRightBorder(); this.startOfsAnimationEvent(); var finalItemsArr=[].concat(this.items); for (var i=ofsIndex - 1; i >= 0; i--) { var item=newItems[i]; finalItemsArr.unshift(item); } this.items=finalItemsArr, this.need2RemovePreviousItems=true, this.imgNum=this.items.length; var ofs=this.firstImgLeft; var startTime=new Date().getTime(); for (var i=ofsIndex - 1; i >= 0 ; i--) { var item=this.items[i]; ofs -= this.min + this.intrv; var profileURL=this.profileURL.replace('{login}', item.login); var d=this.getImage4Update(ofs, item.url, profileURL); if(/*@cc_on!@*/false) { d.image.filters[0].opacity=100; } d.a.elV=0,d.a.d=100,d.a.v=100,d.a.s=100,d.a.startTime=startTime,d.a.dur = 3000; this.imgs.unshift(d); } for (var i=0, n=this.imgs.length; i < n; i++) { var d=this.imgs[i]; d.image.index=i+1; if(/*@cc_on!@*/false) { if (d.vml_image) d.vml_image.index=i+1; d.anchor.index=i+1; } } var startTime=new Date().getTime(); this.zoomOut(-10000, this.min, this.updateDuration); }, redrawFullReplace: function (newItems, ofsIndex) { this.removePreviousItems (); this.items4FullUpdate=newItems, this.d4FullUpdate=[]; var ofs=this.firstImgLeft; var newItemsArrCount = newItems.length > this.minImgNum ? this.minImgNum : newItems.length; for (var i=0; i < newItemsArrCount; i++) { var item=newItems[i]; var profileURL=this.profileURL.replace('{login}', item.login); var d=this.getImage4Update(ofs, item.url, profileURL); d.image.index=i+1; if(/*@cc_on!@*/false) { d.image.filters[0].opacity=0; if (d.vml_image) d.vml_image.index=i+1; d.anchor.index=i+1; } ofs += this.min + this.intrv; d.a.elV=0,d.a.d=100,d.a.v=0,d.a.s=0; this.d4FullUpdate[this.d4FullUpdate.length]=d; } clearInterval(this.opacityWaveInt); this.imgNum = this.imgs.length; this.imgWaveIndex=this.imgNum - 1; this.hideBeforeUpdate=true; this.opacityWaveStep(); this.opacityWaveInt=setInterval(this.opacityWaveStep_binded, this.opacityWaveDelay); }, fullUpdateStart: function () { this.clear(); this.items=this.items4FullUpdate, this.items4FullUpdate=null, this.imgs=this.d4FullUpdate, this.d4FullUpdate=null, this.imgNum=this.items.length > this.minImgNum ? this.minImgNum : this.items.length; for (var i=0; i < this.imgNum; i++) { var item=this.items[i]; var d=this.imgs[i]; if(/*@cc_on!@*/false) { d.drawVMLDirect(); } } this.hideBeforeUpdate=false; clearInterval(this.opacityWaveInt); this.imgWaveIndex=this.imgNum - 1; this.opacityWaveStep(); this.opacityWaveInt=setInterval(this.opacityWaveStep_binded, this.opacityWaveDelay); }, fullUpdateStartInt: 0, opacityWaveStep: function () { var d=this.imgs[this.imgWaveIndex]; if (this.hideBeforeUpdate) { d.a.d=0, d.a.s=100; } else { d.a.d=100, d.a.s=0; } d.a.startTime=new Date().getTime(); if (this.imgWaveIndex > 0) { this.imgWaveIndex--; this.startTimer(); } else { clearInterval(this.opacityWaveInt); if (this.hideBeforeUpdate) { this.fullUpdateStartInt=setTimeout(this.fullUpdateStart_binded, 500); } } }, checkFromTooltip: function() { if (this.tempUpdateLayoutParams) this.processDelayedUpdate(); else this.setupDestSize(-1000, this.min, this.zoomOutDuration); }, processDelayedUpdate: function() { if (this.need2ProcessMore || this.focI >= 0) return; this.updateIsAvailable=true; if (!this.tempUpdateLayoutParams) return; var newItems=this.tempUpdateLayoutParams; this.tempUpdateLayoutParams=null; this.updateLayout(newItems); }, removePreviousItems: function () { var imgs=this.imgs; if (!imgs) return; for (var i=this.minImgNum, n=imgs.length; i < n; i++) { var d=imgs[i]; d.removeFromDOM(); d.destroy(); } this.items.splice (this.minImgNum, this.items.length - this.minImgNum); imgs.splice (this.minImgNum, imgs.length - this.minImgNum); this.imgNum=this.minImgNum; this.need2RemovePreviousItems=false; }, clear: function () { var imgs=this.imgs; for (var i=0, n=imgs.length; i < n; i++) { var d=imgs[i]; d.removeFromDOM(); d.destroy(); } this.imgs=[], this.imgNum=0; }, getItemIndexByValues: function (a, item) { for (var i=0, n=a.length; i < n; i++) { var v=a[i]; if (v.id == item.id) return i; } return -1; }, getOffsetIndex: function (newItemsArr) { var a=[]; var firstInd=-1; var newItemsArrCount = newItemsArr.length > this.minImgNum ? this.minImgNum : newItemsArr.length; for (var i=0, n=newItemsArr.length; i < n; i++) { var item=newItemsArr[i]; item.indexInCurrentItems=this.getItemIndexByValues(this.items, item); if (firstInd == -1 && item.indexInCurrentItems != -1) firstInd=i; } if (firstInd == -1) return this.items.length; for (var i=firstInd + 1, n=newItemsArr.length; i < n; i++) { var item=newItemsArr[i]; var prevItem=newItemsArr[i - 1]; if (prevItem.indexInCurrentItems != item.indexInCurrentItems - 1) return this.items.length; } return firstInd; } }; var sIm=function (config) { $config(this, config); this.init(); }; sIm.prototype={ changed: false, focused: false, elFocused: false, anchor: null, w: { elV: 0,v: 0, d: 0, s: 0, top: 0, elTop: 0, dur: 0, startTime: 0}, a: { elV: 0,d: 0, s: 0, v: 0, dur: 0, startTime: 0}, left: { elV:0,d: 0,s:0,v:0,dur:0,startTime: 0}, image: null, vml_image: null, imageComplete: false, sp: null, ie6Mode:false, init: function () { if(/*@cc_on!@*/false) { this.ie6Mode=_ua=='ie6'; this.draw=this.drawViaVML; if (this.ie6Mode) this.initVMLLoader(); } else { this.draw=this.drawViaCanvas; } }, destroy: function () { if(/*@cc_on!@*/false) { if (this.vml_image) { this.vml_image.onfilterchange = null; this.vml_image = null; } } this.image.onload=null; this.image=null; this.sp=null; this.vml_image=null; this.anchor=null; }, initVMLLoader: function () { var scope = this; this.vml_image.onfilterchange_count = 0; this.vml_image.onfilterchange = function (e) { this.onfilterchange_count++; if (this.onfilterchange_count <2) return; this.onfilterchange = null; setTimeout(function () { try { scope.switch2VML(); } catch (e) { ; } },750); } }, switch2VML: function () { this.vml_image.onfilterchange = null; if (this.imageComplete) return true; this.imageComplete = true; this.drawVMLDirect(); return true; }, initUploadHandler: function (src) { var scope=this; this.image.onload=function() { scope.imageComplete = true; if(/*@cc_on!@*/false) scope.drawVMLDirect(); else scope.drawViaCanvas(); this.onload=null; } }, drawViaCanvas: function () { if (this != this.sp.addBtnImg && this.left.v < this.sp.addBtnLeft) { return; } if (this.image.complete) { try { this.sp.ctx.drawImage(this.image, this.left.elV, this.w.elTop, this.w.elV, this.w.elV); this.imageComplete = true; } catch (e) { this.imageComplete = false; this.drawEmptyRect(); if (!this.image.onload) this.initUploadHandler(); } } else { if (!this.image.onload) this.initUploadHandler(); this.drawEmptyRect(); } this.changed=false; }, drawEmptyRect: function () { this.sp.ctx.fillRect(this.left.elV, this.w.elTop, this.w.elV, this.w.elV); this.changed=false; }, drawViaVML: function () { if (this != this.sp.addBtnImg && this.left.v < this.sp.addBtnLeft) { return; } var img=this.image, vml_image=this.vml_image, anchor=this.anchor; if (this.focused != this.elFocused) { this.elFocused=this.focused; } if (this.w.elV != this.w.v) { var w=this.w.v; img.style.width=w, img.style.height=w, anchor.style.width=w, anchor.style.height=w, anchor.style.top=this.w.top, this.w.elV=this.w.v, this.w.elTop=this.w.top; if (this.ie6Mode && this.imageComplete) { vml_image.style.width=w, vml_image.style.height=w; } } if (this.left.elV != this.left.v) { anchor.style.left=this.left.v, this.left.elV=this.left.v; } if (this.a.elV!= this.a.v) { img.filters[0].opacity=this.a.v; if (this.ie6Mode && this.imageComplete) { vml_image.filters[0].opacity=this.a.v; } this.a.elV=this.a.v; } this.changed=false; }, drawVMLDirect: function () { if (this != this.sp.addBtnImg && this.left.v < this.sp.addBtnLeft) { return; } var img=this.image, vml_image=this.vml_image, anchor=this.anchor; this.elFocused=this.focused; var w=this.w.v; img.style.width=w, img.style.height=w; if (this.ie6Mode && this.imageComplete) { vml_image.style.width=w, vml_image.style.height=w; } anchor.style.width=w, anchor.style.height=w, anchor.style.top=this.w.top, this.w.elV=this.w.v, this.w.elTop=this.w.top, anchor.style.left=this.left.v, this.left.elV=this.left.v; img.filters[0].opacity=this.a.v; if (this.ie6Mode && this.imageComplete) { vml_image.filters[0].opacity=this.a.v; } this.a.elV=this.a.v, this.changed=false; }, removeFromDOM: function () { if(/*@cc_on!@*/false) { this.anchor.parentNode.removeChild(this.anchor); } } }; var SpotlightClass =function(config) { $config(this, config); this.init(); }; SpotlightClass.prototype={ name: 'Spotlight', slLine: null, updater: null, slTooltip: null, init: function() { if(!$('slline') || !vars.Spotlight) return; this.updater = new SLUpdater({ spotlightVars: vars.Spotlight, spotlight: this }); this.slLine = new SLLine({ spotlight: this, items: this.updater.items, profileURL: this.updater.getProfileUrl() }); this.slTooltip = new SLTooltip({ el: this.slLine.sp, spotlight: this, type: 'spotbox', target: 'spotlight-line_ur_2' }); $u.app.on('spotlight', this.ovlOpen, this); $e.add(window,'beforeunload',this.destroy, this); }, ovlOpen: function() { var url = vars.SpotlightWizard && vars.SpotlightWizard.url; dOvl.open_ex({rev:url,rel:'sl_step'}); }, destroy: function() { if (this.slLine) { this.slLine.destroy (); this.slLine = null; } if (this.slTooltip) { this.slTooltip.destroy(); this.slTooltip = null; } if (this.updater) { this.updater.destroy (); this.updater = null; } return true; }, tooltip: function (tooltip_html, x, user_url, from_wizard, id) { this.slTooltip.show(x, tooltip_html, user_url); }, updateLayout: function (json) { this.slLine.updateLayout(json); }, tooltip_hide: function () { if (!this.slTooltip.mouseOvered) { this.slTooltip.hide(); } }, checkFromTooltip: function () { this.slLine.checkFromTooltip(); } }; var SpotlightDOMReadySupply=new $class(dPage, { name: 'SpotlightDOMReadySupply', init: function () { if (window.Spotlight && Spotlight.slTooltip) { Spotlight.slTooltip.delayedDOMChange(); } } }); var RedButton= { name:'RedButton', url:'/ws/boring-ws.phtml', inset:null, activated:false, autoshow:false, fxAnim: null, forceHide: false, state: 0, animDuration: 750, pr:false, init:function() { if (!this.pr) return; this.inset=$('js_chatting_button'), this.block=$('js_chatting_block'), this.form=$('red_button_form'); if(!this.inset || !this.block) return; this.block.style.left='-240px'; if(this.autoshow) this.show(this.inset); $e.on('.rb-force-hide',this.force_hide, this); if(!this.activated){ $e.add(this.inset, 'mouseover', this.show, this); }else{ $e.add(this.inset, 'mouseover', this.over, this); $e.add(this.inset, 'click', this.show, this); } $e.add(this.inset, 'mouseout', this.hide, this); $e.add(this.block, 'mouseover', this.over, this); $e.add(this.block, 'mouseout', this.hide, this); $e.add(this.form, 'submit', this.activate, this); }, force_hide:function(el) { this.move(false); this.forceHide = true; new $r(this.url,{ method:'post', params:{ hide:1 } }); }, activate:function(el) { new $r(this.url,{ method:'post', params:{ws:1} }); $el.removeClassName(this.block,'wish_to_chat'); $el.addClassName(this.block,'search_interlocutor'); }, move:function(show) { if (this.forceHide) return; if ((this.state==1 && show) || (this.state==2 && !show)) return; if (this.fxAnim) this.fxAnim.end(); this.state=show?1:2; var from = parseInt(this.block.style.left); var to = show ? 0 : -240; var duration = Math.round(this.animDuration * Math.abs(from - to) / 240); if (!duration) return; this.fxAnim = new $fx.effect({ wait:false, duration: duration, scope:this, items:[ new $fx.style({ rb: this,el:this.block,prop:'left',from: from,to: to, end: function () { this.rb.forceHide = false; this.rb.fxAnim=null; this.rb.state=0; } }) ] }); }, show:function() { this.move(true); }, over:function() { this.show(true); }, hide:function(el) { var e=$e.e; var reltg=$(e.relatedTarget || e.toElement); if(!reltg || (reltg && !$q.up(reltg,'#js_chatting_block'))) { this.move(false); } } }; RedButton=new $class(dPage,RedButton); if(Flash.init(9)){ try{ document.documentElement.className+=' flash_upload '; }catch(e){} } var MorePeople=new $class(dPage,{ more_people:null, init:function() { var more_people=$('people_cont'); if(!more_people) return; this.tooltip=new dTooltip({ el:more_people, type:'ppl_ttp', target:'tooltip_target', format:function(el) { var html=$u.tpl('<a href="{url}" class="name {online}">{name}</a>\ <small>{info}</small><span>{msg}</span>',{ name:el.rel, url:el.href, info:el.rev.split('|')[0], msg:el.rev.split('|')[1] }); var tl=$el.cumulativeOffset(el); return { html:html, left:tl.left+5, top:tl.top+el.offsetHeight-15 }; } }); } }); var dSuggest=$class({ _1:true, target:null, timeout: 250, url:'', url_params:null, msgs:{ note:'Start typing and select your city from the list', loading:'Loading...', nothing_found:'Nothing found' }, validate:false, initial_data:null, del:false, autocomplete_onblur:true, _focused:false, _timer:null, _form:null, _list:null, _value:'', _sel_length:0, _sel_item:0, _items:null, _show_loading:true, _load_progress:false, _store: {}, constructor:function(config) { this.url_params={}; $config(this,config); this.init(); }, init:function() { var target=this.target=$(this.target); if(!this.target) return; target.setAttribute("autocomplete", "off"); this._value=target.value; this._list=$u.el('ul',{className:'hidden'}); target.parentNode.appendChild(this._list); if(this.del){ this._del=$u.el('div'); target.parentNode.appendChild(this._del); } this._form=this._form||$q.up(target,'form'); if(!this._hid){ var hid=this._form.elements[target.name+'_id']; if(!hid){ hid=$u.el('input',{ name:(target.name+'_id'), type:'hidden' }); target.parentNode.insertBefore(hid,target); } this._hid=hid; } this._suggest_fn=this.suggest.bind(this); $e.add(target,'keyup',this.suggest_delayed,this); $e.add(target,'keydown',this.highlight_kbd,this); $e.add(this._list,'mouseover',this.highlight_mouse,this); $e.add(target,'blur',this.blur,this); $e.add(target,'focus',this.focus,this); if(this.del) $e.add(this._del,'click',this.clear,this); if(!this.autocomplete_onblur) $e.add(this._list,'click',this.onClick,this); $e.add(this._form,'submit',this.onSubmit,this); if(!this.initial_data) this._1=false; if(this.initial_data) this.parse_results(this.initial_data); }, destroy:function() { var target=this.target; clearTimeout(this._timer); $e.del(target,'keyup',this.suggest_delayed,this); $e.del(target,'keydown',this.highlight_kbd,this); $e.del(this._list,'mouseover',this.highlight_mouse,this); $e.del(target,'blur',this.blur,this); $e.del(target,'focus',this.focus,this); if(this.del) $e.del(this._del,'click',this.clear,this); if(!this.autocomplete_onblur) $e.del(this._list,'click',this.onClick,this); $e.del(this._form,'submit',this.onSubmit,this); this._form=this._hid=this.target=null; }, focus:function() { if(this._focused) return true; this.target.select(); this._focused=true; this.layout(); return true; }, blur:function() { this._focused=false; if(this.autocomplete_onblur) this.select(); this.onError(!this._hid.value); this.layout(); return true; }, clear:function() { this._value=this.target.value=""; this._hid.value=''; if(this._transport){ this._transport.abort(); this._transport=null; } this.target.focus(); }, highlight:function(i,renew) { if(!this._items) return; if(!renew) $el.removeClassName(this._list.childNodes[this._sel_item],'selected'); if(i<0) i=this._sel_length+i; this._sel_item=i%this._sel_length; var list=this._list; var item=list.childNodes[this._sel_item]; $el.addClassName(item,'selected'); if(this._list.className) return; if(item.offsetTop<list.scrollTop){ list.scrollTop=item.offsetTop; }else if(item.offsetTop+item.offsetHeight>list.scrollTop+list.offsetHeight){ list.scrollTop=item.offsetTop-list.offsetHeight+item.offsetHeight; } }, highlight_mouse:function(el) { if(!this._items || !el) return; if(el.nodeName!='LI'){ el=el.parentNode; if(el.nodeName!='LI'){ return; } } $el.removeClassName(this._list.childNodes[this._sel_item],'selected'); this._sel_item=0; var i=el; while(i.previousSibling){ i=i.previousSibling; if(i.nodeName=='LI') this._sel_item++; } $el.addClassName(this._list.childNodes[this._sel_item],'selected'); }, highlight_kbd:function() { var e=$e.e; var code=e.charCode||e.keyCode||e.which||0; switch(code){ case 40: this.highlight(this._sel_item+1); return; case 38: this.highlight(this._sel_item-1); return; case 13: this.select(); return; } return true; }, onClick:function(el) { var onSelectDisabled = el && $el.hasClassName (el, 'change'); this.select(onSelectDisabled); return true; }, select:function(onSelectDisabled) { if(this._items){ var _=/^dsi_([\d_]+)$/.exec(this._list.childNodes[this._sel_item].id); if(!_) return true; var id=_[1]; if(this._1 && id==0) return true; var v=this._items[id].split(', '); if((this._items[id].unique) && v.length==3) v.splice(1,1); v=v.join(', '); this._value=this.target.value=v; if(this.url) this._items=null; this._hid.value=id; } if(this._hid.value) { this.onError(false); if (!onSelectDisabled) this.onSelect(); } this.layout(); return true; }, suggest_delayed:function() { if(this._value==this.target.value) return; this._hid.value=''; clearTimeout(this._timer); this._timer=null; if(this.target.value.length<2){ if(this.url) this._items=null; this._value=''; }else{ if(this.url) this._timer=setTimeout(this._suggest_fn,this.timeout); } this.layout(); }, suggest:function() { this._timer=null; if(this._value==this.target.value){ this.layout(); return; } this._value=this.target.value; if(this._transport){ this._transport.abort(); this._transport=null; } if(this.target.value){ this._load_progress=true; var q=this.target.value.replace(/(^[\s,]+|[\s,]+$)/g,''); if(q in this._store){ setTimeout(this.parse_results.bind(this,this._store[q]),0); }else{ this.url_params.q=q; this._transport=new $r(this.url,{ method:'get', params:this.url_params, ready:this.suggest_ready, error:this.response_error },this); } } this.layout(); }, suggest_ready:function(res) { this.parse_results(res); this._transport=null; }, response_error:function() { this._load_progress=false; this.layout(); }, parse_results:function(res,no_layout) { if(!res) return; this._store[res.q]=res; this._load_progress=false; var locations=res.locations; if('length' in locations){ this._items=null; this._sel_item=null; this._sel_length=0; }else{ var q=res.q; var html=[]; var j=false; if(this._2){ html=['<li class="info_li" id="dsi_0">'+this.msgs.note+'</li>']; j=!j; } var filter_data=res.filter && this.filters[res.filter]; if(filter_data) locations=filter_data(locations); this._items=locations; var re=new RegExp('('+q+')','i'); for(var i in locations){ html[html.length]='<li id="dsi_'+i+'"'+(j?'class="bg"':'')+'>'+(q?locations[i].replace(re,'<span>$1</span>'):locations[i])+'</li>'; j=!j; } this._sel_length=html.length; this._list.innerHTML=html.join(''); this.highlight(0,1); if(!this._focused && html.length==1){ this.select(); } } if(!no_layout) this.layout(); }, filters:{ rm_region:function(data) { var res={}; var idx={}; for(var i in data){ var v=data[i].split(', '); v[3]=v[2] ? (v[0]+v[2]) : data[i]; res[i]=v; idx[v[3]]=(idx[v[3]]||0)+1; } for(var i in res){ var v=res[i]; if(idx[v[3]]==1){ res[i]=v[2] ? (v[0]+', '+v[2]) : v[3]; res[i].unique=true; }else{ res[i]=v[2] ? (v[0]+', '+v[1]+', '+v[2]) : v[3]; } } return res; } }, external_set:function(id,text) { var v=text.split(', '); if(v.length==3){ v.splice(1,1); text=v.join(', '); } this._value=this.target.value=text; this._hid.value=id; if(this.url) this._items=null; this.onError(!this._hid.value); this.layout(); }, onSelect:function() { }, onError:function(error) { if(error) $el.addClassName(this.target,'error_location'); else $el.removeClassName(this.target,'error_location'); }, onSubmit:function() { if(window.opera && this._focused){ return; } if(!this.validate || this.onValidate()) return true; if(this.target.offsetHeight) this.target.focus(); }, onValidate:function() { if(this._hid.value){ this.onError(false); return true; }else{ this.onError(true); return false; } }, layout:function() { clearTimeout(this._del_timer); if(!this._focused){ this._del_timer=setTimeout((function(){ this._list.className='hidden'; if(this.del) this._del.className='hidden'; }).bind(this),200); if(this._load_progress){ $el.addClassName(this.target.parentNode,'dSuggest-loading'); }else{ $el.removeClassName(this.target.parentNode,'dSuggest-loading'); } if(this._hid.value) $el.addClassName(this.target,'selected'); return; } $el.removeClassName(this.target,'selected'); if(this._hid.value) this._list.className='hidden'; else this._list.className=''; var msg=''; if(this.target.value.length<2 || this._value.length<2){ if(this._1){ this._2=1; this.parse_results(this.initial_data,true); if (this.encLocMode) this._list.className=''; this._2=0; }else{ msg=('<li class="info_li">'+this.msgs.note+'</li>'); if (this.encLocMode) this._list.className=''; } if(this.del) this._del.className='hidden'; this._show_loading=true; }else if(this._load_progress && this._show_loading){ msg=('<li class="info_li">'+this.msgs.loading+'</li>'); this._show_loading=false; }else if(!this._hid.value && !this._items){ msg=('<li class="info_li">'+this.msgs.nothing_found+'</li>'); this._show_loading=true; } if(msg) this._list.innerHTML=msg; if(this._load_progress){ if(this.del) this._del.className='hidden'; $el.addClassName(this.target.parentNode,'dSuggest-loading'); }else{ if(this.target.value) if(this.del) this._del.className=''; $el.removeClassName(this.target.parentNode,'dSuggest-loading'); } } }); var SuggestLocation = { name: 'SuggestLocation', menuVisible: false, savedCityId: null, init: function() { var encounters_location_field = $('encounters_location_field'); if (!encounters_location_field) return; $e.on({ '* .dropdown_item_css': this.showMenu, '* .dropdown_item_ie': this.showMenu, '.show_location_suggest': this.showSuggest, '.menu_location_item': this.menuItemClick, '.cancel_dSuggest': this.hideSuggest, '#more_location':this.openLocation, '#more_location2':this.openLocation, '.location_suggest_select':this.selectBtnPress }, this); var n=0; if (this.suggest_data && this.suggest_data.locations) { var loctns = this.suggest_data.locations; if (loctns instanceof Array) n=loctns.length; else for (var l in loctns) n++; if (n == 1) { this.suggest_data.locations = []; n = 0; } } this.locationSuggest = new dSuggest({ target: encounters_location_field, url: this.suggest_url, msgs: this.str, validate:true, _invalid_flag:false, initial_data: this.suggest_data, autocomplete_onblur: false, onSubmit:function(error) { return true; }, onSelect:function() { $u.startWaiting('submit_wait_el'); $('encounters_location').submit(); } }); if (n==0) this.locationSuggest._1=false; this.locationSuggest.encLocMode=true; $e.add($('encounters_location_menu'), 'mouseout', this.menuOut, this); $e.add(encounters_location_field, 'keyup', this.pressEscCheck, this); try{ document.documentElement.className+=' js-ready'; }catch(e){} }, menuItemClick: function (el) { if (el.rev && el.rel) { var location_text_ie = $('location_text_ie'); if (location_text_ie) location_text_ie.innerHTML = el.rev; else $("location_text").innerHTML = el.rev; $('city_id_field').value = el.rel; } this.hideMenu(); $u.startWaiting('submit_wait_el'); $('encounters_location').submit(); }, pressEscCheck: function () { var e=$e.e; var code=e.charCode||e.keyCode||e.which||0; if (code == 27) this.hideSuggest(); return false; }, openLocation: function () { dOvl.open_ex({ type:'loc-ovl', cfg:{ wizard_url: this.wizard_url, callback: this.setupLocation, scope: this } }); }, setupLocation: function (vvalue, vtext) { this.locationSuggest.external_set(vvalue, vtext); $u.startWaiting('submit_wait_el'); $('encounters_location').submit(); }, showMenu: function () { $el.removeClassName($('es_location'), 'suggest_choice_location'); $el.addClassName($('title_distance'), 'e_show_dropdown'); if(/*@cc_on!@*/false) $el.addClassName($('es_content'), 'hide_selects'); this.menuVisible = true; }, menuOut: function (el) { if (!this.menuVisible) return; var e = $e.e; var el = e.relatedTarget||e.toElement; if ($q.up(el,'#encounters_location_menu')) return; this.hideMenu(); }, hideMenu: function () { $el.removeClassName($('title_distance'), 'e_show_dropdown'); if(/*@cc_on!@*/false) $el.removeClassName($('es_content'), 'hide_selects'); this.menuVisible = false; }, showSuggest: function () { this.savedCityId = $('city_id_field').value; $el.removeClassName($('title_distance'), 'e_show_dropdown'); $el.addClassName($('es_location'), 'suggest_choice_location'); $('encounters_location_field').focus(); }, hideSuggest: function () { $el.removeClassName($('es_location'), 'suggest_choice_location'); this.savedCityId = $('city_id_field').value; }, selectBtnPress: function () { this.locationSuggest.select(); } }; SuggestLocation = new $class(dPage, SuggestLocation); var EncountersByWish = { name: 'EncountersByWish', dropdownVisible: false, dLabel: null, ideaText: '', maxLength: 32, init: function() { $e.on({ '.tiw_edit_anchor': this.edit, '#i_want_more_ideas': this.moreIdeas, '* .dropdownBtn': this.dropdownBtn, '.tiw_list_item': this.itemClick, '.tiw_dropdown_item': this.dropdownItemClick }, this); var to_full = $('to_full'); if (to_full) { $e.add(to_full, 'blur', this.blur, this); $e.add(to_full, 'focus', this.focus, this); var form = $q.up(to_full, 'form'); $e.add(form,'submit',this.submit,this); this.maxLength = parseInt(to_full.maxLength || this.maxLength); $u.textarea_count ('to_full', this.maxLength); } }, submit: function (el) { var to_id_field = $("to_id_field"); if (to_id_field.value) { if (this.ideaText != $('to_full').value) to_id_field.value = ''; } return true; }, refreshCounter: function () { $u.textarea_stop_count ('to_full'); $u.textarea_count ('to_full', this.maxLength); }, dropdownItemClick: function (el) { if (el && el.rel) { $('to_full').value = el.rel; this.refreshCounter(); $('to_full').focus(); $("to_id_field").value = ""; } this.dropdownHide(); }, itemClick: function (el) { var to_full = $('to_full'); if (!el || !el.title || !to_full) return true; to_full.value = el.title; this.ideaText = el.title; this.refreshCounter(); $("to_id_field").value = el.rel; to_full.focus(); }, dropdownBtn: function () { if (this.dropdownVisible) this.dropdownHide(); else this.dropdownShow(); }, dropdownHide: function (e) { if (e) { var el = e.srcElement || e.target; var btn = $q.up(el, '.dropdownBtn'); if (btn) return; } this.dropdownVisible = false; $el.removeClassName($('full_box'), 'show_dropdown_tiw'); $e.un('__all__',this.dropdownHide,this); }, dropdownShow: function () { this.dropdownVisible = true; $el.addClassName($('full_box'), 'show_dropdown_tiw'); $e.on('__all__',this.dropdownHide,this); }, blur: function () { $el.removeClassName($('full_box'), 'focus'); }, focus: function () { $el.addClassName($('full_box'), 'focus'); }, edit: function () { $('basic_box').className+=' tiw-edited'; $('to_full').focus(); $('to_full').select(); }, moreIdeas: function (el) { if (!el || !el.rel || this.waiting) return; this.waiting = true; $u.startWaiting('i_want_more_ideas'); new $r(el.rel,{ method:'post', params:{ws:1}, ready:this.loaded, error: this.error },this); }, error: function () { $u.stopWaiting('i_want_more_ideas'); this.waiting = false; }, loaded: function (res) { $u.stopWaiting('i_want_more_ideas'); this.waiting = false; if (res.html) { $('i_want_ideas').innerHTML = res.html; } if (res.url) $('i_want_more_ideas').rel = res.url; } }; EncountersByWish = new $class(dPage, EncountersByWish); var EncountersByCriteria = { name : 'EncountersByCriteria', tabNames : null, tabs : {}, metrics : { 'cm' : 'inch', 'inch' : 'cm', 'kg' : 'lbs', 'lbs' : 'kg', 'height' : 'weight', 'weight' : 'height' }, init : function() { $e.on({ '.reset_tab' : this.resetTabClick, '* .reset' : this.reset, '.switch_height' : this.switchMetrics, '.switch_weight' : this.switchMetrics, '* .ext_tab_text' : this.activateTab, '#es_other' : this.laguages_other_checkbox }, this); $e.add($('s_languages_other'), 'change', this.laguages_other_select, this); if(/*@cc_on!@*/false) $e.add($('extended_container'), 'click', this.changeHandler, this); else $e.add($('extended_container'), 'change', this.changeHandler, this); }, initTab : function(tabName) { if (this.tabs[tabName]) return; var controlsHash = this.getInputControls(tabName); this.tabs[tabName] = controlsHash; }, changeHandler: function(el) { var tabName = el.tabName || this.getTabName($('extended_container').className); this.updateModified(tabName); return true; }, initTabNames : function() { var tabArr = $q.select($('extended_container'), '.ext_tab'); var tabNames = []; for (var i = 0, n = tabArr.length; i < n; i++) { var el = tabArr[i]; var tabName = this.getTabName(el.id); if (tabName) tabNames[tabNames.length] = tabName; } this.tabNames = tabNames; }, show : function() { $('es').className = 'extended_filter'; }, getTabName : function(tab_id) { var prefix = tab_id.substr(0, 2); if (prefix != 't_' && prefix != 's_') return null; var tabName = tab_id.substr(2, tab_id.length - 2); return tabName; }, activateTab : function(el) { var current = this.getTabName($('extended_container').className); if (current) this.updateModified(current); var li = $q.up(el, '.ext_tab'); if (!li) return null; var tab_id = li.id; var newTabName = this.getTabName(tab_id); if (!newTabName) return; $('extended_container').className = 's_' + newTabName; }, updateModified : function(tabName) { var li = $('t_' + tabName); if (!li) return; var wasChanged = this.wasChanged(tabName); if (wasChanged && !$el.hasClassName(li, 'ch')) $el.addClassName(li, 'ch'); else if (!wasChanged && $el.hasClassName(li, 'ch')) $el.removeClassName(li, 'ch'); }, getInputControls : function(tabName) { var tab = $('t_' + tabName); if (!tab) return false; var controls = $q.select(tab, 'INPUT, SELECT'); var controlsHash = {}; for (var i = 0, n = controls.length; i < n; i++) { var control = controls[i]; if (control.name) { var arr = controlsHash[control.name]; if (!arr) { arr = []; controlsHash[control.name] = arr; } arr[arr.length] = control; } } return controlsHash; }, wasChanged : function(tabName) { this.initTab(tabName); var defaultValues = this.defaultValues || {}; var controlsHash = this.tabs[tabName]; for (var name in controlsHash) { var inputs = controlsHash[name]; var defaultValue = defaultValues[name.replace('[]', '')]; var input = inputs[0]; if (input.tagName == 'SELECT') { if (defaultValue) { if (input.value != defaultValue) return true; } else if (input.options && input.options.length > 0) { var firstOptionValue = input.options[0].value; if (input.value != firstOptionValue) return true; } } else if (input.type == 'hidden' || input.type == 'text') { if ((defaultValue && input.value != defaultValue) || (!defaultValue && input.value != '')) { return true; } } else if (input.type == 'checkbox' || input.type == 'radio') { for (var i = 0, n = inputs.length; i < n; i++) { var input = inputs[i]; if (defaultValue) { if (input.checked && input.value != defaultValue) return true; if (!input.checked && input.value == defaultValue) return true; } else if (input.checked) return true; } } } return false; }, reset: function() { if (!this.tabNames) this.initTabNames(); var tabNames = this.tabNames; for (var i = 0, n = tabNames.length; i < n; i++) { var tabName = tabNames[i]; this.resetTab(tabName); } }, resetTabClick: function(el) { var li = $q.up(el, '.ext_tab'); if (!li) return null; var tabName = this.getTabName(li.id); if ($el.hasClassName(li, 'ch')) this.resetTab(tabName); else this.activateTab(el); }, resetTab : function(tabName) { this.initTab(tabName); var defaultValues = this.defaultValues || {}; var controlsHash = this.tabs[tabName]; for (var name in controlsHash) { var inputs = controlsHash[name]; var defaultValue = defaultValues[name.replace('[]', '')]; var input = inputs[0]; if (input.tagName == 'SELECT') { if (defaultValue) { input.value = defaultValue; } else if (input.options && input.options.length > 0) { var firstOptionValue = input.options[0].value; input.value = firstOptionValue; } } else if (input.type == 'hidden' || input.type == 'text') { input.value = defaultValue ? defaultValue : ''; } else if (input.type == 'checkbox' || input.type == 'radio') { for (var i = 0, n = inputs.length; i < n; i++) { var input = inputs[i]; if (defaultValue) input.checked = input.value == defaultValue; else input.checked = false; } } } var li = $('t_' + tabName); if (li) $el.removeClassName(li, 'ch'); if (tabName == "languages") this.update_laguages_other_checkbox(); if (tabName == "height") this.updateMetricsVisibility($('height_metric')); if (tabName == "weight") this.updateMetricsVisibility($('weight_metric')); }, laguages_other_checkbox: function() { var select = $('s_languages_other'); var firstOptionValue = select.options[0].value; if (!$('es_other').checked) { select.value = firstOptionValue; $('es_other').checked = false; } $('es_other').checked = false; this.updateModified('languages'); return true; }, laguages_other_select: function() { this.update_laguages_other_checkbox (); this.updateModified('languages'); return false; }, update_laguages_other_checkbox: function() { var select = $('s_languages_other'); var firstOptionValue = select.options[0].value; $('es_other').checked = select.value != firstOptionValue; return false; }, switchMetrics : function(el) { var containerName = el.className.substr(7); var metricField = $(containerName + '_metric'); var currentMetric = metricField.value; var newMetric = this.metrics[currentMetric]; metricField.value = newMetric; this.updateMetricsVisibility(metricField); }, updateMetricsVisibility : function(metricField) { var newMetric = metricField.value; var hiddenMetrics = 'es_' + newMetric; var showedMetrics = 'es_' + this.metrics[newMetric]; $el.removeClassName($(hiddenMetrics), 'hidden'); $el.addClassName($(showedMetrics), 'hidden'); var selectors = $q.select($(showedMetrics), 'SELECT'); for (var i = 0; i < selectors.length; i++) { var el = selectors[i]; var s = el.name.split('_'); $(s[0] + '_' + this.metrics[s[1]] + '_' + s[2]).selectedIndex = el.selectedIndex; } } }; EncountersByCriteria = new $class(dPage, EncountersByCriteria); var EncountersTopRated = { name: 'EncountersTopRated', persons: null, init: function() { $e.on({ '* .encThumbImgA': this.imgClick, '.larr': this.leftArrowClick, '.rarr': this.rightArrowClick }, this); }, initPersonArr: function () { this.persons = {}; var arr = $q.select($('top_result'), '.person'); for (var i=0, n=arr.length; i < n; i++) { var div = arr[i]; div.encIndex = i; this.persons[i] = { div: div }; } }, initImgArr: function (personIndex) { var p = this.persons[personIndex]; p.imgContainer = $q.down(p.div, '.band'); p.loaderPlace = $q.down(p.div, '.for_loader'); p.arrowsHolder = $q.down(p.div, '.holder_arrows'); p.arrowsHolderW = parseInt(p.arrowsHolder.style.width); var imgArr = $q.select(p.div, '.encThumbImg'); for (var i=0, n = imgArr.length; i < n; i++) { var img = imgArr[i]; img.imgIndex = i; img.encIndex = personIndex; img.parentNode.imgIndex = i; img.parentNode.encIndex= personIndex; img.imgW = parseInt(img.getAttribute('width')); img.thumbUploaded = (parseInt(img.offsetLeft) + 20) < p.arrowsHolderW; } p.imgArr = imgArr; p.focused = 0; p.scrollLeft = 0; p.topImg = $q.down(p.div, '.encTopImg'); }, imgClick: function (el) { if (!this.persons) this.initPersonArr(); if (typeof(el.imgIndex)!='undefined' && typeof(el.encIndex)!='undefined') { this.setupFocusedImage(el.encIndex, el.imgIndex); return; } var div = $q.up(el, '.person'); if (!div || typeof(div.encIndex)=='undefined') return; if (typeof(el.imgIndex)=='undefined') this.initImgArr(div.encIndex); this.setupFocusedImage(el.encIndex, el.imgIndex); }, leftArrowClick: function (el) { if (!this.persons) this.initPersonArr(); var div = $q.up(el, '.person'); if (!div || typeof(div.encIndex)=='undefined') return; var p = this.persons[div.encIndex]; if (typeof(p.imgArr)=='undefined') this.initImgArr(div.encIndex); if (p.focused == 0) return; this.setupFocusedImage(div.encIndex, p.focused - 1); }, rightArrowClick: function (el) { if (!this.persons) this.initPersonArr(); var div = $q.up(el, '.person'); if (!div || typeof(div.encIndex)=='undefined') return; var p = this.persons[div.encIndex]; if (typeof(p.imgArr) == 'undefined') this.initImgArr(div.encIndex); if (p.focused >= p.imgArr.length - 1) return; this.setupFocusedImage(div.encIndex, p.focused + 1); }, uploadThumbnails: function (personIndex, numFrom0) { var p = this.persons[personIndex]; var imgArr = p.imgArr; for (var i=0; i <= numFrom0; i++) { var img = imgArr[i]; if (!img.thumbUploaded ) { img.src = img.parentNode.rel; img.thumbUploaded = true; } } }, setupFocusedImage: function (personIndex, newFoc) { var p = this.persons[personIndex]; if (p.imgArr.length < 2) return; var prevImg = p.imgArr[p.focused]; $el.removeClassName(prevImg.parentNode, 'active'); var img = p.imgArr[newFoc]; $el.addClassName(img.parentNode, 'active'); p.focused = newFoc; var loaderPlace = p.loaderPlace; this.uploadThumbnails (personIndex, newFoc); var src = img.parentNode.rev; p.topImg.src = JSRoot + 'i/no.gif'; if (p.topImgPreloader) p.topImgPreloader.preloadStoped = true; $u.startWaiting(loaderPlace); var topImg = p.topImg; var image = new Image; image.onload = function() { if (!this.preloadStoped) { if(/*@cc_on!@*/false) topImg.style.filter='progid:DXImageTransform.Microsoft.Alpha(Opacity=0)'; else topImg.style.opacity=0; topImg.src = src; new $fx.effect({ wait:false, duration: 200, items:[ new $fx.style({ el:topImg, prop:'opacity', from: 0, to: 100, step:function(ct,d) { var s=this.el.style, op=this.fx(ct,this.from,this.to,d); if(/*@cc_on!@*/false) s.filter='progid:DXImageTransform.Microsoft.Alpha(Opacity='+op+')'; else s.opacity=op/100; } }) ] }); } $u.stopWaiting(loaderPlace); }; image.src = src; p.topImgPreloader = image; var imgOffsetLeft = parseInt(img.offsetLeft); var imgW = img.imgW; var prevScrollLeft = p.scrollLeft; if (imgOffsetLeft < p.scrollLeft) { p.scrollLeft = imgOffsetLeft; } else if (imgOffsetLeft + imgW > p.scrollLeft + p.arrowsHolderW) { p.scrollLeft = imgOffsetLeft + imgW- p.arrowsHolderW; } if (prevScrollLeft != p.scrollLeft) { new $fx.effect({ wait:false, duration:300, items:[ new $fx.style({ el:p.imgContainer, prop:'left', from: -prevScrollLeft, to: -p.scrollLeft }) ] }); } if (newFoc > 0 && newFoc < p.imgArr.length - 1) { $el.addClassName(p.arrowsHolder , 'arrows_active'); $el.removeClassName(p.arrowsHolder , 'larr_not_active'); $el.removeClassName(p.arrowsHolder, 'rarr_not_active'); } else { $el.removeClassName(p.arrowsHolder , 'arrows_active'); if (p.imgArr.length > 1) { if (newFoc == 0) $el.addClassName(p.arrowsHolder , 'larr_not_active'); else $el.removeClassName(p.arrowsHolder , 'larr_not_active'); if (newFoc == p.imgArr.length - 1) $el.addClassName(p.arrowsHolder , 'rarr_not_active'); else $el.removeClassName(p.arrowsHolder, 'rarr_not_active'); } } } }; EncountersTopRated = new $class(dPage, EncountersTopRated); var TIWPopup = { name: 'TIWPopup', dropdownVisible: false, ideaText: '', maxLength: 32, init: function() { }, load: function (el) { var to_full = $('to_full_popup'); if (!to_full) return; $e.on({ '#i_want_more_ideas_popup': this.moreIdeas, '* .dropdownBtnPopup': this.dropdownBtn, '.tiw_popup_list_item': this.itemClick, '.tiw_popup_dropdown_item': this.dropdownItemClick }, this); this.label=dLabel.init($('full_box_popup')); $e.add(to_full, 'blur', this.blur, this); $e.add(to_full, 'focus', this.focus, this); var form = $('tiw_popup_form'); $e.add(form,'submit',this.submit,this); $u.form_submit(form); this.maxLength = parseInt(to_full.maxLength || this.maxLength); $u.textarea_count ('to_full_popup', this.maxLength); }, unload: function (el) { $u.textarea_stop_count ('to_full_popup'); var to_full = $('to_full_popup'); $e.del(to_full, 'blur', this.blur, this); $e.del(to_full, 'focus', this.focus, this); var form = $('tiw_popup_form'); $e.del(form,'submit',this.submit,this); $e.un({ '#i_want_more_ideas_popup': this.moreIdeas, '* .dropdownBtnPopup': this.dropdownBtn, '.tiw_popup_list_item': this.itemClick, '.tiw_popup_dropdown_item': this.dropdownItemClick }, this); this.label = null; }, submit: function (el) { var to_id_field_popup = $("to_id_field_popup"); if (to_id_field_popup.value) { if (this.ideaText != $('to_full_popup').value) to_id_field_popup.value = ''; } return true; }, refreshCounter: function () { $u.textarea_stop_count ('to_full_popup'); $u.textarea_count ('to_full_popup', this.maxLength); }, dropdownItemClick: function (el) { if (el && el.rel) { $('to_full_popup').focus(); $('to_full_popup').value = el.rel; this.refreshCounter(); this.hideDLabel(); $("to_id_field_popup").value = ""; } this.dropdownHide(); }, hideDLabel: function (el) { this.label[0].show(); $('to_full_popup').blur(); }, itemClick: function (el) { if (!el || !el.title) return; $('to_full_popup').value = el.title; this.ideaText = el.title; this.refreshCounter(); $("to_id_field_popup").value = el.rel; this.hideDLabel(); }, dropdownBtn: function () { this.dropdownShow(); }, dropdownHide: function (e) { if (e) { var el = e.srcElement || e.target; var btn = $q.up(el, '.dropdownBtnPopup'); if (btn) return; } this.dropdownVisible = false; $el.removeClassName($('full_box_popup'), 'show_dropdown_tiw'); $e.un('__all__',this.dropdownHide,this); }, dropdownShow: function () { this.dropdownVisible = true; $el.addClassName($('full_box_popup'), 'show_dropdown_tiw'); $e.on('__all__',this.dropdownHide,this); }, blur: function () { $el.removeClassName($('full_box_popup'), 'focus'); }, focus: function () { $el.addClassName($('full_box_popup'), 'focus'); }, moreIdeas: function (el) { if (!el || !el.rel || this.waiting) return; this.waiting = true; $u.startWaiting('i_want_more_ideas_popup'); new $r(el.rel,{ method:'post', params:{ws:1}, ready:this.loaded, error: this.error },this); }, error: function () { $u.stopWaiting('i_want_more_ideas_popup'); this.waiting = false; }, loaded: function (res) { $u.stopWaiting('i_want_more_ideas_popup'); this.waiting = false; if (res.html) { $('i_want_ideas_popup').innerHTML = res.html; } if (res.url) $('i_want_more_ideas_popup').rel = res.url; } }; TIWPopup = new $class(dPage, TIWPopup); var MeetMakerPromoLink=new $class(dPage,{ name:'MeetMakerPromoLink', startTS:0, init:function() { if ($('mm_ban_4') || $('mm_ban_1')) this.startTS=setTimeout(function () { $r.script(JSRoot + 'js/meet-maker-promo.js'); }, 1500); }, destroy: function () { clearTimeout(this.startTS); } }); var dSlider=$class({ el:null, fe:null, p:-1, pm:-1, z0:0, z1:1, z0e:null, z1e: null, z:null, onStart:function(p){}, onUpdate:function(p){}, onUpdateEnd:function(p){}, scope:null, constructor:function(config, scope) { this.z=[]; $config(this,config); this.scope=scope||this; if(!this.el || !this.fe){ return; } this.ww=this.el.offsetWidth-this.fe.offsetWidth+1; if(this.p!=-1){ var ex=this.v2px(this.p); this.fe.style.left=ex+'px'; this.pm=this.p; } $e.add(this.z0e,'click',this.zoom_prev,this); $e.add(this.z1e,'click',this.zoom_next,this); $e.add(this.el,'mousedown',this.start,this); }, v2px:function(v) { return this.ww*(v-this.z0)/(this.z1-this.z0); }, fit:function(ex) { var ww=this.ww; ex=ex<0?0:(ex>ww?ww:ex); var p=parseInt((this.z0+(this.z1-this.z0)*ex/ww)*1000)/1000; return p; }, start:function(el) { this.onStart.call(this.scope,this.pm); $e.add(document,'mousemove',this.drag,this); $e.add(document,'mouseup',this.stop,this); var wtl=$el.cumulativeOffset(this.el); this.wx=wtl.left; this.ww=this.el.offsetWidth-this.fe.offsetWidth+1; this.drag(el); }, drag:function(el) { var e=$e.e, ww=this.ww, ex= (e.pageX || (e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft))) - this.wx; ex=ex<0?0:(ex>ww?ww:ex); var p=parseInt((this.z0+(this.z1-this.z0)*ex/ww)*1000)/1000; if(p==this.pm) return; this.fe.style.left=ex+'px'; this.onUpdate.call(this.scope,this.pm=p); }, stop:function() { $e.del(document,'mouseup',this.stop,this); $e.del(document,'mousemove',this.drag,this); this.onUpdateEnd.call(this.scope,this.pm); this.interactive=false; }, zoom_next:function() { var z=this.z, p=this.pm; for(var i=0, n=z.length; i<n; i++) if(z[i]>p){ p=z[i]; break; } this.zoom(p); }, zoom_prev:function() { var z=this.z, p=this.pm; for(var i=z.length-1; i>=0; i--) if(z[i]<p){ p=z[i]; break; } this.zoom(p); }, zoom:function(p) { if(p==this.pm) return; var ex=this.ww*(p-this.z0)/(this.z1-this.z0); this.fe.style.left=ex+'px'; this.onUpdate.call(this.scope,this.pm=p); this.onUpdateEnd.call(this.scope,this.pm); } }); $u.thread=function(fn,scope,timeout,args) { var _timer; var run=function() { _.interactive=false; fn.apply(scope,args); }; var _={ interactive:false, run:run, start:function() { _.interactive=true; args=arguments; clearTimeout(_timer); _timer=setTimeout(run, timeout); }, stop:function() { _.interactive=false; clearTimeout(_timer); } }; return _; }; $u.equal=function(a,b) { if(a===b) return true; var t=typeof(a); if(t!=typeof(b)) return false; switch(t){ case 'string': case 'number': case 'boolean': return false; case 'object': if(a instanceof Array){ if(a.length!=b.length) return false; return a.join(',')==b.join(','); }else{ var i, x=[], y=[]; for(i in a) x[x.length]=i+'='+a[i]; for(i in b) y[y.length]=i+'='+b[i]; if(x.length!=y.length) return false; x.sort(), y.sort(); return x.join('&')==y.join('&'); } } }; var PeopleList=$class(dPage,{ name:'', url:'', params:{}, timeout:0, list:null, wrap:null, send_th:null, _state:'', ST_NONE:'', ST_LOADING:'', ST_SUCCESS:'', constructor:function(config) { $config(this,config); $super(this,arguments); }, init:function() { this.send_th=$u.thread(this.send, this, this.timeout); this.params.ws=1; this._transport=new $r(this.url,{ auto:false, params:this.params, ready:this.readyEx, error:this.error },this); this._req_params=$config({},this.params); }, state:function(state) { if(this.wrap){ $el.removeClassName(this.wrap,this._state); $el.addClassName(this.wrap,state); } this._state=state; }, update:function(params) { $config(this.params,params); if($u.equal(this.params, this._req_params)){ this.send_th.stop(); }else{ this.state(this.ST_LOADING); this.send_th.start(); } }, send:function() { this._transport.url = this.url; this._req_params=$config({},this.params); this._transport.request(); }, readyEx:function(res) { if(res.errno) return this.error(); this.state(this.ST_SUCCESS); this.ready && this.ready(res); }, error:function() { this.state(this.ST_NONE); } }); var SearchList=$class(PeopleList, { timeout:500, ST_LOADING:'is-loading', ST_SUCCESS:'', init:function() { $super(this,arguments); this.list=this.wrap=$('cl_content'); this._sav={ html:this.list.innerHTML }; this.loading_ovl=$('cl_loading_ovl'); }, ready:function(res) { this.list.innerHTML=res.html; window.Statistics && res && res.vars && $config(Statistics.data,res.vars.Statistics); } }); if(_ua=='ie6'){ $mixin(SearchList,{ state:function(state) { if(state==this.ST_LOADING) this.loading_ovl.style.height=this.wrap.offsetHeight+'px'; return $super(this,arguments); } }); } var dSliderEx=$class(dSlider,{ panTo:function(to) { this._pan_fx=new $fx.effect({ wait:false, duration:200, items:[ new $fx.style({ el:this.fe, prop:'left', from:this.v2px(this.pm), to:this.v2px(to) }) ], onEnd:function() { this._pan_fx=null; }, scope:this }); } }); var SlideLocation=new $class(dPage,{ name:'SlideLocation', url:'/ws/search-ws.phtml', params:{}, area_id:'', areas:[], tooltips:[], z:0, init:function() { var scale=$('scale'); if(!scale) return; this.z=this._upd_z=this.area2zoom(this.area_id); this.ds=new dSliderEx({ el:scale, fe:$('slide_me'), p:this.z, z0:0, z1:this.areas.length-1, onUpdate:this.update, onUpdateEnd:this.update_end }, this); this.params.area_id=this.area_id; this.list=new SearchList({ url:this.url, params:this.params }); this.tooltip=$('slider_tooltip'); }, area2zoom:function(area_id) { var areas=this.areas; for(var i=0, n=areas.length; i<n; i++){ if(areas[i]==area_id) return i; } return 0; }, digitize:function(z) { return (z%1<0.5 ? Math.floor(z) : Math.ceil(z)); }, update:function(z) { var dz=this._upd_z=this.digitize(z), z0=+this.tooltips[Math.floor(z)].v||0, z1=+this.tooltips[Math.ceil(z)].v; this.setupTooltip(dz, Math.round((z1-z0)*(z%1)+z0)); }, setupTooltip:function(dz, v) { var t=this.tooltips[dz]; if(typeof(t)=='object'){ t=$u.tpl(t.t,{"v":v||t.v}); } this.tooltip.innerHTML=t; }, update_end:function(z) { z=this.z=this.digitize(z); this.setupTooltip(z); this.ds.panTo(z); this.area_id=this.areas[z]; this.list.update({area_id:this.area_id}); }, update_area:function(area_id) { this.update_end(this.area2zoom(area_id)); } });