qElements={element:function(a){this.qElementsElement=true;this.inAnimation=false;this.timeAction=null;this.timeDelay=null;if(typeof a.nodeType!="undefined"&&a.nodeType===1){this.elem=a}else{this.elem=document.createElement(a)}}};qElements.element.prototype={appendTo:function(a){if(typeof a=="undefined"){a=document.body}if(typeof a.qElementsElement!="undefined"){a=a.elem}a.appendChild(this.elem)},html:function(a){this.attrs({innerHTML:a})},swap:function(c,d){var a={};for(var b in c){a[b]=this.elem.style[b];this.elem.style[b]=c[b]}d(this);for(var b in c){this.elem.style[b]=a[b]}},attrs:function(b,c){for(var a in b){if(typeof b[a]=="object"){this.attrs(b[a],a);break}if(typeof c=="undefined"){this.elem[a]=b[a]}else{this.elem[c][a]=b[a]}}},css:function(a){if(typeof a.opacity!="undefined"){a.filter=(this.elem.style.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(a.opacity)+""=="NaN"?"":"alpha(opacity="+(a.opacity*100)+")")}this.attrs({style:a})},cur:function(b){if(this.elem[b]!=null&&this.elem.style[b]==null){return this.elem[b]}var a=parseFloat(this.elem.style[b]);if(a){return a}switch(b){case"width":a="clientWidth";break;case"height":a="clientHeight";break;case"left":a="offsetLeft";break;case"top":a="offsetTop";break;default:a=false}if(a){return this.elem[a]}return 0},outer:function(d){if(d!="width"&&d!="height"){return 0}var c=0;if(!browserInfo.msie){var b=d=="width"?["Left","Right"]:["Top","Bottom"];for(var a=0;a<b.length;a++){c+=parseFloat(this.elem.style["padding"+b[a]])||0;c+=parseFloat(this.elem.style["border"+b[a]+"Width"])||0}}return Math.max(0,Math.round(c))},hide:function(){this.css({display:"none"})},show:function(){this.css({display:"block"})},fadeIn:function(a,b){this.animate({to:{opacity:1}},a||0.2,b)},fadeOut:function(a,b){this.animate({to:{opacity:0}},a||0.2,b)},jump:function(b,d,e){var a=this,c={width:this.cur("width"),height:this.cur("height"),left:this.cur("left"),top:this.cur("top")};b=extendObject({width:30,height:30},b);d=(d||0.2)/2;this.animate({to:{width:(c.width*(1+b.width/100)),height:(c.height*(1+b.height/100)),left:(c.left-(c.width*b.width/200)),top:(c.top-(c.height*b.height/200))}},d,function(){a.animate({to:c},d,e)})},animate:function(r,e,m){var p=this,f=this.inAnimation;if(f){if(typeof r!="undefined"){if(typeof r.redefine=="undefined"){this.timeDelay=setTimeout(function(){p.animate(r,e,m)},10);return}this.stop();if(typeof r.redefine.to!="undefined"){for(var b in r.to){f.opts.to[b]=r.to[b];f.work[b]=null}}if(typeof r.redefine.speed!="undefined"){f.spds=e}if(typeof r.redefine.callback!="undefined"){f.clbk=m}}}else{f={opts:r,spds:e,clbk:m,work:{}}}if(f.spds<0.01||typeof f.spds=="undefined"){f.spds=0}var j=true,k=getPageScroll();if(typeof f.opts!="undefined"){if(typeof f.opts.from=="undefined"){f.opts=extendObject({from:{}},f.opts)}if(f.opts.to.left===null){f.opts.to.left=k.x+Math.ceil((document.body.clientWidth-(f.opts.to.width||this.cur("width"))-this.outer("width"))/2)}if(f.opts.to.top===null){f.opts.to.top=k.y+Math.ceil((document.body.clientHeight-(f.opts.to.height||this.cur("height"))-this.outer("height"))/2.5)}for(var b in f.opts.to){var l=(typeof f.opts.from[b]!="undefined")?f.opts.from[b]:this.cur(b);var h=(typeof f.opts.to[b]!="undefined")?f.opts.to[b]:l;var a=b=="opacity"?"":"px";f.work[b]=f.work[b]||{};f.work[b].cur=f.work[b].cur||l;f.work[b].nev=f.work[b].nev||h;f.work[b].dlt=f.work[b].nev-f.work[b].cur;f.work[b].unt=f.work[b].unt||a;f.work[b].stp=f.work[b].stp||f.work[b].dlt/((f.spds||0.04)*25)}}var g={};for(var b in f.work){var i=f.work[b].cur,d=f.work[b].nev,q=f.work[b].stp;if(!f.work[b].dlt){continue}if(Math.abs(d-i)>Math.abs(q)){f.work[b].cur=i=new Number(i)+new Number(q);j=false}else{f.work[b].cur=i=d}g[b]=i+f.work[b].unt}this.css(g);if(j){this.stop();if(typeof f.clbk=="function"){f.clbk()}return}this.inAnimation=f;this.timeAction=setTimeout(function(){p.animate()},40)},stop:function(){if(this.inAnimation){clearTimeout(this.timeAction);this.inAnimation=false}}};var qPictures={elems:{globalBox:new qElements.element("div"),overLay:new qElements.element("div"),loadingBox:new qElements.element("div"),imageBox:new qElements.element("div"),imageCont:new qElements.element("img"),infoBox:new qElements.element("div"),hrefNext:new qElements.element("a"),hrefPrev:new qElements.element("a"),hrefFull:new qElements.element("a"),captionBox:new qElements.element("div"),currentNum:new qElements.element("div")},isReady:false,active:false,iconsPath:"images/images_icons/",padding:10,overlay:0.7,scrollable:true,resizable:true,minWidth:280,minHeight:210,init:function(h,c){this.elems.globalBox.attrs({id:"qPictures"});this.elems.overLay.attrs({id:"qPictures_overlay",onclick:function(){qPictures.die()}});this.elems.loadingBox.attrs({id:"qPictures_loadingbox",onclick:function(){qPictures.die()}});this.elems.loadingBox.css({background:"url("+qPictures.iconsPath+"loading.gif) no-repeat center 40%"});this.elems.imageBox.attrs({id:"qPictures_imagebox"});this.elems.imageBox.css({padding:this.padding+"px"});this.elems.imageCont.css({width:"100%",height:"100%"});this.elems.infoBox.attrs({id:"qPictures_infobox"});this.elems.hrefNext.attrs({className:"next",onclick:function(){return qPictures.showImage(qPictures.images.next())},onmouseover:function(){qPictures.elems.hrefNext.css({background:"url("+qPictures.iconsPath+"next.gif) no-repeat right 45%"})},onmouseout:function(){qPictures.elems.hrefNext.css({background:"transparent url("+qPictures.iconsPath+"transparent.gif) no-repeat"})}});this.elems.hrefPrev.attrs({className:"prev",onclick:function(){return qPictures.showImage(qPictures.images.prev())},onmouseover:function(){qPictures.elems.hrefPrev.css({background:"url("+qPictures.iconsPath+"prev.gif) no-repeat left 45%"})},onmouseout:function(){qPictures.elems.hrefPrev.css({background:"transparent url("+qPictures.iconsPath+"transparent.gif) no-repeat"})}});this.elems.hrefFull.attrs({className:"full",target:"_blank"});this.elems.hrefFull.html("постоянная ссылка");this.elems.captionBox.attrs({id:"qPictures_captionbox"});this.elems.currentNum.attrs({id:"qPictures_currentnum"});var g=new qElements.element("div");g.attrs({id:"qPictures_navcontainer"});if(!browserInfo.msie){g.css({marginTop:"-"+this.padding+"px",marginLeft:"-"+this.padding+"px"})}var f=new qElements.element("div");f.attrs({id:"qPictures_footcontainer"});var e=new qElements.element("div");e.css({clear:"both"});this.elems.hrefPrev.appendTo(g.elem);this.elems.hrefNext.appendTo(g.elem);this.elems.overLay.appendTo(this.elems.globalBox.elem);this.elems.loadingBox.appendTo(this.elems.globalBox.elem);this.elems.imageBox.appendTo(this.elems.globalBox.elem);this.elems.infoBox.appendTo(this.elems.globalBox.elem);g.appendTo(this.elems.imageBox.elem);this.elems.imageCont.appendTo(this.elems.imageBox.elem);f.appendTo(this.elems.infoBox.elem);this.elems.captionBox.appendTo(f.elem);this.elems.currentNum.appendTo(f.elem);this.elems.hrefFull.appendTo(f.elem);e.appendTo(f.elem);if(browserInfo.msie){document.body.onload=function(){document.body.appendChild(qPictures.elems.globalBox.elem)}}else{document.body.appendChild(this.elems.globalBox.elem)}window.onresize=window.onscroll=function(){if(qPictures.active){qPictures.center(0.1)}};if(document.addEventListener){document.addEventListener(browserInfo.opera?"keypress":"keydown",qPictures.keyAction,false)}if(document.attachEvent){document.attachEvent("onkeydown",qPictures.keyAction)}this.relify(GetE(h),c);var b=[this.iconsPath+"loading.gif",this.iconsPath+"next.gif",this.iconsPath+"prev.gif"];for(var d in b){var a=new Image();a.onload=function(){a=null};a.src=b[d]}},relify:function(e,u){var hrefs=e.getElementsByTagName("a");for(var i=0;i<hrefs.length;i++){if(this.images.add(hrefs[i])){hrefs[i].onclick=function(){return qPictures.showImage(this)}}}var r=getXmlHttp();if(typeof u==="undefined"||!r){this.isReady=true;return}r.open("GET",u,false);r.send(null);if(r.status==200||r.status==304){var images=eval("("+r.responseText+")");if(images.length){this.images.clear();this.images.add(images)}}this.isReady=true},keyAction:function(a){if(!qPictures.active){return}a.preventDefault=a.preventDefault||function(){this.returnValue=false};if(!a.shiftKey&&!a.altKey&&!a.metaKey){if(a.ctrlKey){if(a.keyCode==37){a.preventDefault();qPictures.showImage(qPictures.images.prev())}else{if(a.keyCode==39){a.preventDefault();qPictures.showImage(qPictures.images.next())}}}else{if(a.keyCode==27){a.preventDefault();qPictures.die()}}}},targetSize:function(){var a=this.active.width,c=this.active.height,b=Math.max(Math.ceil(document.body.clientWidth*0.9-this.padding*2),this.minWidth),d=Math.max(Math.ceil(document.body.clientHeight*0.8-this.padding*2),this.minHeight);if(a>b||c>d){var e=a/c;a=b;c=Math.ceil(a/e);if(c>d){c=d;a=Math.ceil(c*e)}}return{width:a,height:c}},center:function(a){var b={to:{left:null,top:null},redefine:{to:true}};if(this.resizable){b.to=extendObject(this.targetSize(),b.to)}this.hide("infoBox");this.elems.imageBox.animate(b,a,function(){qPictures.showCaption()})},hide:function(b){if(typeof b=="undefined"){b=["globalBox","overLay","hrefPrev","hrefNext","infoBox"]}if(typeof b!="string"){for(var c=0;c<b.length;c++){this.hide(b[c])}return true}this.elems[b].stop();this.elems[b].hide()},show:function(b){if(typeof b=="undefined"){b=["loadingBox","overLay","globalBox"]}if(typeof b!="string"){for(var c=0;c<b.length;c++){this.show(b[c])}return true}this.elems[b].show()},toppers:function(a){fixToppers(a);if(!this.scrollable){document.body.style.overflow=a?"hidden":"auto"}},startTimeout:null,currentStep:false,justStarted:false,start:function(){if(!this.active){this.active=true;this.toppers(1);this.elems.imageBox.animate({to:{width:1,height:1,left:null,top:null}});this.show();this.elems.overLay.animate({to:{opacity:this.overlay}},0.3)}if(!this.isReady){this.startTimeout=setTimeout("qPictures.showImage(null, {step: 1})",100);return false}return true},die:function(){if(!this.active){return true}this.active=false;clearTimeout(this.startTimeout);this.hide(["loadingBox","infoBox"]);this.elems.imageCont.fadeOut(0.1,null);this.elems.imageBox.jump({},null,function(){qPictures.elems.imageBox.animate({to:{width:1,height:1,left:null,top:null},redefine:{to:true,speed:true,callback:true}},0.2,function(){qPictures.hide("imageBox");qPictures.elems.overLay.fadeOut(0.1,function(){qPictures.hide();qPictures.toppers();var a=getPageScroll();window.scrollTo(a.x+1,a.y);window.scrollTo(a.x,a.y)})})})},showCaption:function(){if(this.currentStep<5){return}var a={width:qPictures.elems.imageBox.cur("width")+qPictures.elems.imageBox.outer("width"),left:qPictures.elems.imageBox.cur("left"),top:qPictures.elems.imageBox.cur("height")+qPictures.elems.imageBox.outer("height")+qPictures.elems.imageBox.cur("top")};this.elems.infoBox.animate({to:a,redefine:{to:true,callback:true}},null,function(){qPictures.elems.infoBox.show();qPictures.elems.infoBox.css({height:"auto"});qPictures.elems.infoBox.animate({to:{height:qPictures.elems.infoBox.cur("height")},from:{height:1}},0.2)})},showImage:function(b,c){c=c||{step:0};b=this.images.get(b);if(!b||(c.step>1&&!this.active)){return true}if(c.step>1&&this.images.active().src!=b.src){c.step=1}switch(this.currentStep=c.step){case 0:if(!this.images.active(b)){return true}this.justStarted=!this.active;if(!this.active){this.showImage(null,{step:1});break}setTimeout(function(){qPictures.hide(["hrefPrev","hrefNext","infoBox"]);qPictures.show("loadingBox")},50);this.elems.imageCont.fadeOut(0.2,function(){qPictures.showImage(null,{step:1})});break;case 1:if(!this.start()){break}var e=new Image();e.onload=function(){qPictures.showImage(null,{step:2,width:this.width,height:this.height});e.onload=null;e=null};e.src=b.src;break;case 2:this.elems.imageCont.attrs({src:b.src});c=extendObject({width:null,height:null},c);this.active={width:c.width,height:c.height};if(this.resizable){var i=this.targetSize();c.width=i.width;c.height=i.height}var g=c.width,h=c.height,f=this.elems.imageBox.cur("width")-g,d=this.elems.imageBox.cur("height")-h;this.elems.imageBox.css({overflow:"hidden"});this.show("imageBox");var a=this.justStarted?3:4;if(f===0&&d===0){setTimeout("qPictures.showImage(null, {step: "+a+"})",200)}else{this.elems.imageBox.animate({to:{width:g,height:h,left:null,top:null},redefine:{to:true,speed:true,callback:true}},0.3,function(){qPictures.showImage(null,{step:a})})}break;case 3:this.elems.imageBox.jump({},null,function(){qPictures.showImage(null,{step:4})});break;case 4:this.hide("loadingBox");this.elems.imageBox.css({overflow:""});this.elems.imageCont.fadeIn(0.2,function(){qPictures.showImage(null,{step:5})});break;case 5:if(this.elems.imageBox.inAnimation!==false){setTimeout(function(){qPictures.showImage(null,{step:5})},10);return}this[b.title?"show":"hide"]("captionBox");this.elems.captionBox.html(b.title);this.elems.currentNum.html(this.images.size()>1?(b.index+1)+"&nbsp;из&nbsp;"+this.images.size():"&nbsp;");this.neighbours();this.showCaption();this[b.full?"show":"hide"]("hrefFull");this.elems.hrefFull.attrs({href:b.full});break;default:return this.showImage(b)}return false},neighbours:function(){if(this.images.single()||this.images.empty()){return}var d=this.images.active();if(!d){return}var a,c=this.images.prev(d),b=this.images.next(d);if(c){this.elems.hrefPrev.attrs({href:c.link});this.elems.hrefPrev.css({background:"transparent url("+this.iconsPath+"transparent.gif) no-repeat"});this.show("hrefPrev");a=new Image();a.src=c.src}if(b){this.elems.hrefNext.attrs({href:b.link});this.elems.hrefNext.css({background:"transparent url("+this.iconsPath+"transparent.gif) no-repeat"});this.show("hrefNext");a=new Image();a.src=b.src}},images:{list:[],image:false,prev:function(a){if(typeof a=="undefined"){a=this.active();if(!a){return a}}if(this.first(a)){return false}return this.get(a.index-1)},next:function(a){if(typeof a=="undefined"){a=this.active();if(!a){return a}}if(this.last(a)){return false}return this.get(a.index+1)},first:function(a){if(typeof a=="undefined"){return this.get(0)}return a.index===0},last:function(a){if(typeof a=="undefined"){return this.get(this.size()-1)}return a.index===this.size()-1},empty:function(){return this.size()===0},single:function(){return this.size()===1},size:function(){return this.list.length},clear:function(){this.list=[];this.image=false},active:function(a){if(typeof a=="undefined"){return this.image}a=this.get(a);if(!a){return a}this.image=a;return true},add:function(c){if(c[0]){for(var a=0;a<c.length;a++){this.add(c[a])}return true}var b=this.create(c);if(!b){return b}b.index=this.size();this.list.push(b);return true},create:function(b){var a={src:"",link:"",full:"",title:"",description:"Undescribed",index:-1,image:true};if(b.image){a.src=b.src||a.src;a.link=b.link||a.link;a.full=b.full||a.full;a.title=b.title||a.title;a.description=b.description||a.description;a.index=b.index||a.index}else{if(b.tagName){if(b.tagName=="A"&&b.href){a.link=b.href;a.title=b.title||a.title;b=b.getElementsByTagName("img")[0]}if(b.tagName=="IMG"&&b.src){a.src=b.src.replace("small","big");a.full=b.src.replace("small","full");a.title=b.alt||a.title}else{a=false}}else{a=false}}if(a){a.src=a.src.replace("big","full")}return a},get:function(d,e){if(typeof d=="undefined"||d===null){return this.active()}else{if(typeof d=="number"){d=this.list[d]||false}else{d=this.create(d);if(!d){return false}var b=false;for(var a=0;a<this.size();a++){var g=this.list[a];if(g.src===d.src&&g.description===d.description){b=g;break}}d=b}}return d}}};var userAgent=navigator.userAgent.toLowerCase();browserInfo={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};function extendObject(){var f=arguments[0]||{},d=1,e=arguments.length,a=false,c;if(f.constructor==Boolean){a=f;f=arguments[1]||{};d=2}if(typeof f!="object"&&typeof f!="function"){f={}}for(;d<e;d++){if((c=arguments[d])!=null){for(var b in c){var g=f[b],h=c[b];if(f===h){continue}if(a&&h&&typeof h=="object"&&!h.nodeType){f[b]=extendObject(a,g||(h.length!=null?[]:{}),h)}else{if(typeof h!="undefined"){f[b]=h}}}}}return f}function getPageScroll(){var a,b;if(self.pageYOffset){b=self.pageYOffset;a=self.pageXOffset}else{if(document.documentElement&&document.documentElement.scrollTop){b=document.documentElement.scrollTop;a=document.documentElement.scrollLeft}else{if(document.body){b=document.body.scrollTop;a=document.body.scrollLeft}}}return{x:a,y:b}}function fixToppers(d){if(!browserInfo.msie||browserInfo.version>=7){return}var f=document.body,a,g=["embed","object","select"];for(var c=0;c<g.length;c++){a=f.getElementsByTagName(g[c]);for(var b=0;b<a.length;b++){a[b].style.visibility=d?"hidden":"visible"}}};
