function todo(){this.action=[];this.execute=function(){for(var i in this.action){try{todo.action[i]();}catch(er){alert('todo >> "'+er.message+'" in "'+er.fileName+'" on "'+er.lineNumber+'"');}}};var onLoadAction=function(o){return function(){o.execute();}}(this);if(typeof document.attachEvent!='undefined')window.attachEvent('onload',onLoadAction);else window.addEventListener('load',onLoadAction,false);}; todo.prototype.get=function(id){return document.getElementById(id);}; todo.prototype.create=function(tag,attrs,text,style){var e=document.createElement(tag);if(attrs)for(var i in attrs)switch(i){case 'class': e.className=attrs[i];break;case 'id': e.id=attrs[i];break;default: e.setAttribute(i,attrs[i]);break;};if(text)e.appendChild(document.createTextNode(text));if(style)for(var i in style)e.style[i]=style[i];return e;}; todo.prototype.onload=function(func){this.action[this.action.length]=func;}; todo.prototype.loop=function(e,func,i,step){step=step?Math.abs(step):1;for(var i=i?i:0;i=start){res=v+step;ready=res>=finish;}else{res=v-step;ready=res<=finish};return {'res':ready?finish:res,'ready':ready};}; todo.prototype.slide=function(e,x,y,breakOff,callback,delay,step){ var stopIt=function(e){if(e && e.timer){window.clearInterval(e.timer);e.timer=null;if(e.callback)e.callback.call(e._);}}; if(e._slide && e._slide.timer){if(breakOff)stopIt(e._slide);else return;}; if(e.style.position=='absolute'){ if(!e.style.left)e.style.left=e.offsetLeft+'px'; if(!e.style.top)e.style.top=e.offsetTop+'px'; }else{if(!e.style.left)e.style.left='0';if(!e.style.top)e.style.top='0';}; e._slide={'_':e, 'delay':delay?delay:50, 'step':step?step:4, 'start':{'x':parseInt(e.style.left),'y':parseInt(e.style.top)}, 'finish':{'x':x,'y':y}, 'callback':callback, 'run':function(){if(!this.timer)this.timer=window.setInterval(function(o){return function(){o._slide.slide();}}(this._),this.delay);}, 'slide':function(){ var res_x=todo.motion(this._.style.left,this.start.x,this.finish.x,this.step), res_y=todo.motion(this._.style.top,this.start.y,this.finish.y,this.step); this._.style.left=res_x.res+'px'; this._.style.top=res_y.res+'px'; if(res_x.ready && res_y.ready)stopIt(this); } }; e._slide.run(); }; todo.prototype.resize=function(e,w,h,breakOff,callback,delay,step){ var stopIt=function(e){if(e && e.timer){window.clearInterval(e.timer);e.timer=null;if(e.callback)e.callback.call(e._);}}; if(e._resize!=undefined&&e._resize.timer){if(breakOff)stopIt(e._resize);else return;}; if(w&&!e.style.width)e.style.width=e.offsetWidth+'px'; if(h&&!e.style.height)e.style.height=e.offsetHeight+'px'; e._resize={'_':e, 'isImg':e.tagName.toLowerCase()=='img', 'delay':delay?delay:50, 'step':step?step:4, 'start':{'w':parseInt(e.style.width),'h':parseInt(e.style.height)}, 'finish':{'w':w,'h':h}, 'callback':callback, 'run':function(){if(!this.timer)this.timer=window.setInterval(function(o){return function(){o._resize.resize();}}(this._),this.delay);}, 'resize':function(){ var ready=true; if(this.finish.w){ var res_w=todo.motion(this._.style.width,this.start.w,this.finish.w,this.step); if(this.isImg)this._.width=res_w.res; this._.style.width=res_w.res+'px'; if(!res_w.ready)ready=false; }; if(this.finish.h){ var res_h=todo.motion(this._.style.height,this.start.h,this.finish.h,this.step); if(this.isImg)this._.height=res_h.res; this._.style.height=res_h.res+'px'; if(!res_h.ready)ready=false; }; if(ready)stopIt(this); } }; e._resize.run(); }; todo.prototype.opacity=function(e,opacity,delay,breakOff,callback){ var stopIt=function(e){if(e && e.timer){window.clearInterval(e.timer);e.timer=null;if(e.callback)e.callback.call(e._);}}; if(e._opacity && e._opacity.timer){if(breakOff)stopIt(e._opacity);else return;}; e._opacity={'_':e, 'delay':delay, 'step':0.07, 'finish':opacity, 'callback':callback, 'run':function(){ if(!this.timer)this.timer=window.setInterval( function(o,stopIt){return function(){ var v=o.get()+o.step*o.sign; if((o.sign>0 && v>=o.finish) || (o.sign<0 && v<=o.finish) || v>1 || v<0){o.set(o.finish);stopIt(o);}else o.set(v); }}(this,stopIt),this.delay); }, 'set':function(v){ var p=this.prop(); if(p=='filter'){if(v==1)v='';else v='alpha(opacity='+v*100+')';} this._.style[p]=v; }, 'get':function(){ var p=this.prop(); if(p=='filter'){ var tmp=this._.style.filter.match(/opacity=([0-9]{1,3})/); if(tmp&&tmp[1])return parseInt(tmp[1])/100; return 1; }; return this._.style[p]==''?1:parseFloat(this._.style[p]); }, 'prop':function(){ if(typeof document.body.style.opacity=='string')return 'opacity'; else if(typeof document.body.style.MozOpacity=='string')return 'MozOpacity'; else if(typeof document.body.style.KhtmlOpacity=='string')return 'KhtmlOpacity'; else if(document.body.filters&&navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5)return 'filter'; return 'opacity'; } }; if(!delay){e._opacity.set(opacity);return;}; e._opacity.sign=e._opacity.get()>opacity?-1:1; e._opacity.run(); }; todo.prototype.dragZIndex=199; todo.prototype.drag=function(e){ e._drag={'_':e,'x':null,'y':null,'draged':false,'onClick':e.onclick, 'startDrag':function(event){ event=event||window.event; this.x=event.clientX-parseInt(this._.style.left); this.y=event.clientY-parseInt(this._.style.top); this.eventIndexMouseMove=todo.setEvent('mousemove',document,function(e){return function(event){return e.drag(event);}}(this)); this.eventIndexMouseUp=todo.setEvent('mouseup',document,function(e){return function(event){return e.stopDrag(event);}}(this)); this.draged=false; if(this._.style.zIndexw?Math.ceil((size.w-w)/2):17, 'top':size.h>h?Math.ceil((size.h-h-46)/2):17} }, pos=getCenterPos(width,height), e=todo.create('div',{'class':'todo_popup'},null,{'position':'absolute','left':pos.left+'px','top':pos.top+'px','width':width+'px','height':height+'px','zIndex':todo.popupZIndex}); e._popup={'_':e,'isClose':true, 'close':function(){ todo.opacity(this._,0.5,50,false,function(w){return function(){w._=w._.parentNode.removeChild(w._);}}(this)); this.isClose=true; }, 'open':function(){ if(!this.isClose)return; this._.style.zIndex=todo.popupZIndex; this.isClose=false; todo.opacity(this._,1); this._=document.body.appendChild(this._); if(this.content)this.content=this.content.parentNode.removeChild(this.content); else this.content=todo.create('div',null,null,{'paddingTop':'23px','paddingBottom':'23px'}); this._.innerHTML='
'; this._.appendChild(this.content); this._.appendChild(todo.create('div',{'class':'todo_button_close'})).onclick=function(){this.parentNode._popup.close();}; }, 'getSize':function(){return {'width':parseInt(this._.style.width),'height':parseInt(this._.style.height)}}, 'getCenterPos':getCenterPos, 'resize':function(w,h,callback){todo.resize(this._,w,h+46,false,callback);}, 'position':function(left,top){todo.slide(this._,left,top);} }; e._popup.open(); return e; }; todo.prototype.gallery=function(name){ var a=document.getElementsByTagName('a'),res,g; if(!this._galleries)this._galleries={}; for(var i=0;i1000){g.setImage();window.clearInterval(g.img._timer)}else g.img._counter++;}}(this),200); break; } }, 'next':function(){if(this.current0)this.set(this.a[this.current-1]);}, 'setTitle':function(){if(this.a[this.current].title){this.e.appendChild(todo.create('div',{'class':'todo_gallery_title'},this.a[this.current].title),{});}}, 'setNav':function(){ if(this.a.length==1)return; var e=this.e.appendChild(todo.create('div',{'class':'todo_gallery_nav'},(this.current+1)+' из '+this.a.length)); if(this.current>0){ var left=e.appendChild(todo.create('div',{'class':'todo_gallery_button_left','title':'Назад'})); left._gallery=this; left.onclick=function(){this._gallery.prev();}; }; if(this.current