if (typeof M=='undefined') M={w:window,d:document,extend:function(a,b){for(var o in b)a[o]=b[o];return a;},get:function(a,b){return(b||M.d).getElementById(a);},tags:function(a,b){return(b||M.d).getElementsByTagName(a);},getRange:function(a){	var v={id:a.middle('#',' '),clss:a.middle('.',' ')},o,q,i;	v.tag=(v.id?a.middle('#'+v.id+' ','.'):a).split('.')[0];	o=M.get(v.id);	if(v.tag){		o=M.tags(v.tag,o);		if(a.middle('.',' ')){q=[];for(i=0;i<o.length;i++)if(o[i].className==v.clss)q.push(o[i]);o=q;}	}	return o;},/* M.create(tagName a, [,attributes b] [,style c] [,document]) */create:function(a,b,c,d){var o=(d||M.d).createElement(a);M.extend(o,b);M.extend(o.style,c);return o;}};var Jb={init:function(){var n,o;for(n in Jb){o=Jb[n];if(o.init)o.init();}},get:function(a,b){return M.get(a,b);},tags:function(a,b){return M.tags(a,b);},set:function(a,b){for(var o in b) { a[o]=b[o];} return a;},create:function(a,b,c,d){return M.create(a,b,c,d);},append:function(q,a,b,c){var o=a.tagName?a:this.create(a,b,c,q.ownerDocument);q.appendChild(o);return o;},replace:function(a,b){a.parentNode.replaceChild(b,a);},time:function(){return new Date().getTime();},fn:function(a){return(0.5-Math.cos(a*Math.PI)/2);},opacity:function(a,b){ 	if (!a.currentStyle || !a.currentStyle.hasLayout) a.style.zoom = 1;	if (browser.isIE) {		a.style.filter = (b == 100) ? '' : "alpha(style=0,opacity=" + Math.min(b,99) + ")";		var filter = a.parentNode ? a.filters.alpha || a.filters['DXImageTransform.Microsoft.Alpha'] : false;		if (filter) {			filter.opacity = Math.round(Math.min(b,99));			filter.enabled = b < 100;		} else if (b < 100) {			//"alpha(style=0,opacity=" + Math.min(b,99) + ")";			a.style.filter = a.style.filter + ' alpha(opacity=' + Math.round(Math.min(b,99)) + ')';		} else				if (a.style.filter=="")a.style.removeAttribute('filter');		}	a.style.opacity = b/100;	// Jb.set(a.style,{'filter':'progid:DXImageTransform.Microsoft.Alpha(opacity='+b+')',opacity:b/100});	return a;},expand:function(a){a.style.display='block';},collapse:function(a){a.style.display='none';}};Jb.effect={max:400,	fade:function(a,from,to,next){		var g=Jb,o=this,dif=to-from;		a.begin=g.time();		a.step=function(){			var t=g.time()-a.begin;			if(t>o.max){g.opacity(a,to);o.stop(a,next);}			else{g.opacity(a,from+g.fn(t/o.max)*dif);}		};		g.opacity(a,from);g.expand(a);a.timer=setInterval(a.step,10);	},	stop:function(a,next){clearInterval(a.timer);a.timer=null;if(next)next();}};Jb.gallery={	shade:80,	init:function(){		var _rel="Fotod";		var g=Jb,o=this,q=g.get('sisu'),db=M.d.body,i,v;if(!q)return;		o.img=[]; 		o.curtain=g.append(db,'div',{id:'curtain',onclick:o.close},{width:db.scrollWidth+'px',height:db.scrollHeight+'px'});		cont = M.create('div', {id:'imgpreview'});		o.hires=g.append(cont,'img',{id:'imgbox',onclick:o.next,alt:'Vajuta j\u00E4rgmisele.'});		o.descbox=g.append(cont,'div',{id:'descbox'});		o.container = g.append(db, cont);		q=o.tags=g.tags('a',q); j=0;		for(i=0;i<q.length;i++){			if (q[i].getAttribute('rel')!=_rel) continue; 			if ((io=g.tags('img',q[i])).length==0) continue;			v=o.img[j++]=new Image(); g.set(v, {_url: q[i].href, desc: io[0].getAttribute('longdesc')}); g.set(q[i],{index:j-1,onclick:o.launch});		}	},	launch:function(){		M.get('imgKlamber').style.position='';		var g=Jb,o=g.gallery; //,oc=o.curtain;		o.container =M.get('imgpreview');		o.current=this.index;		Jb.effect.fade(o.curtain,0,o.shade,o.show);				return false;	},	show:function(){		o=Jb.gallery;		if (o.img[o.current].src && o.img[o.current].src!='') {				oh=o.hires,ic=o.img[o.current];				// oh.onload = o.showImage;				oh.src=ic.src;  				o.showImage(null,null,false);		}		else		ajaxCaller.get(o.img[o.current]._url + '&jsonpic=1', {}, function (dt, hdr, scope) {			try {				_d = eval('('+dt+')'); 				im=scope.img[scope.current].src=_d.data[0].imgsrc; _d = null;								o=scope,oh=o.hires,ic=o.img[o.current];				oh.onload = o.showImage;				oh.src=ic.src;  			} catch (er) {				location.href=scope.img[scope.current]._url;				// alert('error');			}		}, false, o);	},	showImage: function (_a,_b,_c) {					var g=Jb,o=g.gallery,oh=o.hires, top,left,w=M.w,dd=M.d.documentElement;								_db = o.descbox;_cont=o.container;					_ch=w.innerHeight||dd.clientHeight; xtr = 0;					if (ic.desc!='') {_ps=_ch-90; // pix						g.set(_db.style, {height:'75px'}); xtr = 20;					}					else {_ps=_ch*0.9;g.set(_db.style, {height:'0px'});}					_db.innerHTML = ic.desc;					if (ic.height>_ps) {_s=ic.height/ic.width;_nh=_ps;_nw=_nh/_s;						// alert("k\u00F5rgus: "+ic.height+"->"+_nh+"laius: "+ic.width+"->"+_nw);						ic.height = _nh;						ic.width = _nw;						// g.set(ic.style,{width:_nw+'px',height:_nh+'px'});						g.set(_cont.style,{width:_nw+'px',height:_nh+'px'});						g.set(oh.style,{height: _ps+'px'});					} else { _nw = ic.width;					 g.set(_cont.style,{width:_nw+'px',height:_ps+'px'}); 					g.set(oh.style,{height: ic.height+'px'});					 }					top=parseInt((w.pageYOffset||dd.scrollTop)+((_ch)-ic.height)/2)-xtr+'px';					left=parseInt((w.pageXOffset||dd.scrollLeft)+((w.innerWidth||dd.clientWidth)-ic.width)/2)+'px';					g.set(_cont.style,{top:top,left:left});					Jb.effect.fade(o.container,0,100);					if (_c===true) this.onload = null;				}, // end onload	next:function(){		var g=Jb,o=g.gallery;		o.current++;		if(o.current<o.img.length)g.effect.fade(o.container,100,0,o.show);		else o.close();	},	close:function(){		var g=Jb,o=g.gallery;		g.collapse(o.container);		g.effect.fade(o.curtain,o.shade,0,o.end);	},	end:function(){var g=Jb;g.collapse(g.gallery.curtain);M.get('imgKlamber').style.position='relative'}}; // eof Jb.gallery//onContent(Jb.init, Jb);addEvent(M.w, "load", Jb.init);