var OK = false;
var remove_func;
var set_focus = '';
if (!JsHttpRequest) var JsHttpRequest = new Object();

if(!hs){var hs={lang:{cssDirection:"ltr",loadingText:"Загрузка...",loadingTitle:"Нажмите для отмены",focusTitle:"Click to bring to front",fullExpandTitle:"Показать в оригиналеьном размере (f)",creditsText:"",creditsTitle:"",previousText:"К предыдущему",nextText:"К следующему",moveText:"Переместить",closeText:"Закрыть",closeTitle:"Закрыть (esc)",resizeTitle:"Изменить размер",playText:"Запустить слайдшоу",playTitle:"Запустить слайдшоу (пробел)",pauseText:"Пауза",pauseTitle:"Приостановить слайдшоу (пробел)",previousTitle:"К предыдущему (стрелка влево)",nextTitle:"К следующему (стрелка вправо)",moveTitle:"Переместить",fullExpandText:"1:1",number:"Изображение %1 из %2",restoreTitle:"Кликните для закрытия изображения. Нажмите и перетаскивайте изображение. Используйте стрелки Вашей клавиатуры для переключения между изображениями."},graphicsDir:"highslide/graphics/",expandCursor:"zoomin.cur",restoreCursor:"zoomout.cur",expandDuration:250,restoreDuration:250,marginLeft:15,marginRight:15,marginTop:15,marginBottom:15,zIndexCounter:1001,loadingOpacity:0.75,allowMultipleInstances:true,numberOfImagesToPreload:5,outlineWhileAnimating:2,outlineStartOffset:3,padToMinWidth:false,fullExpandPosition:"bottom right",fullExpandOpacity:1,showCredits:false,creditsHref:"#",creditsTarget:"_self",enableKeyListener:true,openerTagNames:["a"],transitions:[],transitionDuration:250,dimmingOpacity:0,dimmingDuration:50,anchor:"auto",align:"auto",targetX:null,targetY:null,dragByHeading:true,minWidth:200,minHeight:200,allowSizeReduction:true,outlineType:"drop-shadow",skin:{controls:'<div class="highslide-controls"><ul><li class="highslide-previous"><a href="#" title="{hs.lang.previousTitle}"><span>{hs.lang.previousText}</span></a></li><li class="highslide-play"><a href="#" title="{hs.lang.playTitle}"><span>{hs.lang.playText}</span></a></li><li class="highslide-pause"><a href="#" title="{hs.lang.pauseTitle}"><span>{hs.lang.pauseText}</span></a></li><li class="highslide-next"><a href="#" title="{hs.lang.nextTitle}"><span>{hs.lang.nextText}</span></a></li><li class="highslide-move"><a href="#" title="{hs.lang.moveTitle}"><span>{hs.lang.moveText}</span></a></li><li class="highslide-full-expand"><a href="#" title="{hs.lang.fullExpandTitle}"><span>{hs.lang.fullExpandText}</span></a></li><li class="highslide-close"><a href="#" title="{hs.lang.closeTitle}" ><span>{hs.lang.closeText}</span></a></li></ul></div>'},preloadTheseImages:[],continuePreloading:true,expanders:[],overrides:["allowSizeReduction","useBox","anchor","align","targetX","targetY","outlineType","outlineWhileAnimating","captionId","captionText","captionEval","captionOverlay","headingId","headingText","headingEval","headingOverlay","creditsPosition","dragByHeading","autoplay","numberPosition","transitions","dimmingOpacity","width","height","wrapperClassName","minWidth","minHeight","maxWidth","maxHeight","pageOrigin","slideshowGroup","easing","easingClose","fadeInOut","src"],overlays:[],idCounter:0,oPos:{x:["leftpanel","left","center","right","rightpanel"],y:["above","top","middle","bottom","below"]},mouse:{},headingOverlay:{},captionOverlay:{},timers:[],slideshows:[],pendingOutlines:{},clones:{},onReady:[],uaVersion:/Trident\/4\.0/.test(navigator.userAgent)?8:parseFloat((navigator.userAgent.toLowerCase().match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1]),ie:(document.all&&!window.opera),safari:/Safari/.test(navigator.userAgent),geckoMac:/Macintosh.+rv:1\.[0-8].+Gecko/.test(navigator.userAgent),$:function(a){if(a){return document.getElementById(a)}},push:function(a,b){a[a.length]=b},createElement:function(a,f,e,d,c){var b=document.createElement(a);if(f){hs.extend(b,f)}if(c){hs.setStyles(b,{padding:0,border:"none",margin:0})}if(e){hs.setStyles(b,e)}if(d){d.appendChild(b)}return b},extend:function(b,c){for(var a in c){b[a]=c[a]}return b},setStyles:function(b,c){for(var a in c){if(hs.ie&&a=="opacity"){if(c[a]>0.99){b.style.removeAttribute("filter")}else{b.style.filter="alpha(opacity="+(c[a]*100)+")"}}else{b.style[a]=c[a]}}},animate:function(f,a,d){var c,g,j;if(typeof d!="object"||d===null){var i=arguments;d={duration:i[2],easing:i[3],complete:i[4]}}if(typeof d.duration!="number"){d.duration=250}d.easing=Math[d.easing]||Math.easeInQuad;d.curAnim=hs.extend({},a);for(var b in a){var h=new hs.fx(f,d,b);c=parseFloat(hs.css(f,b))||0;g=parseFloat(a[b]);j=b!="opacity"?"px":"";h.custom(c,g,j)}},css:function(a,c){if(a.style[c]){return a.style[c]}else{if(document.defaultView){return document.defaultView.getComputedStyle(a,null).getPropertyValue(c)}else{if(c=="opacity"){c="filter"}var b=a.currentStyle[c.replace(/\-(\w)/g,function(e,d){return d.toUpperCase()})];if(c=="filter"){b=b.replace(/alpha\(opacity=([0-9]+)\)/,function(e,d){return d/100})}return b===""?1:b}}},getPageSize:function(){var f=document,b=window,e=f.compatMode&&f.compatMode!="BackCompat"?f.documentElement:f.body;var c=hs.ie?e.clientWidth:(f.documentElement.clientWidth||self.innerWidth),a=hs.ie?e.clientHeight:self.innerHeight;hs.page={width:c,height:a,scrollLeft:hs.ie?e.scrollLeft:pageXOffset,scrollTop:hs.ie?e.scrollTop:pageYOffset};return hs.page},getPosition:function(a){var b={x:a.offsetLeft,y:a.offsetTop};while(a.offsetParent){a=a.offsetParent;b.x+=a.offsetLeft;b.y+=a.offsetTop;if(a!=document.body&&a!=document.documentElement){b.x-=a.scrollLeft;b.y-=a.scrollTop}}return b},expand:function(b,g,d,c){if(!b){b=hs.createElement("a",null,{display:"none"},hs.container)}if(typeof b.getParams=="function"){return g}try{new hs.Expander(b,g,d);return false}catch(f){return true}},getElementByClass:function(e,c,d){var b=e.getElementsByTagName(c);for(var a=0;a<b.length;a++){if((new RegExp(d)).test(b[a].className)){return b[a]}}return null},replaceLang:function(c){c=c.replace(/\s/g," ");var b=/{hs\.lang\.([^}]+)\}/g,d=c.match(b),e;if(d){for(var a=0;a<d.length;a++){e=d[a].replace(b,"$1");if(typeof hs.lang[e]!="undefined"){c=c.replace(d[a],hs.lang[e])}}}return c},focusTopmost:function(){var c=0,b=-1,a=hs.expanders,e,f;for(var d=0;d<a.length;d++){e=a[d];if(e){f=e.wrapper.style.zIndex;if(f&&f>c){c=f;b=d}}}if(b==-1){hs.focusKey=-1}else{a[b].focus()}},getParam:function(b,d){b.getParams=b.onclick;var c=b.getParams?b.getParams():null;b.getParams=null;return(c&&typeof c[d]!="undefined")?c[d]:(typeof hs[d]!="undefined"?hs[d]:null)},getSrc:function(b){var c=hs.getParam(b,"src");if(c){return c}return b.href},getNode:function(e){var c=hs.$(e),d=hs.clones[e],b={};if(!c&&!d){return null}if(!d){d=c.cloneNode(true);d.id="";hs.clones[e]=d;return c}else{return d.cloneNode(true)}},discardElement:function(a){if(a){hs.garbageBin.appendChild(a)}hs.garbageBin.innerHTML=""},dim:function(a){if(!hs.dimmer){hs.dimmer=hs.createElement("div",{className:"highslide-dimming highslide-viewport-size",owner:"",onclick:function(){hs.close()}},{visibility:"visible",opacity:0},hs.container,true)}hs.dimmer.style.display="";hs.dimmer.owner+="|"+a.key;if(hs.geckoMac&&hs.dimmingGeckoFix){hs.setStyles(hs.dimmer,{background:"url("+hs.graphicsDir+"geckodimmer.png)",opacity:1})}else{hs.animate(hs.dimmer,{opacity:a.dimmingOpacity},hs.dimmingDuration)}},undim:function(a){if(!hs.dimmer){return}if(typeof a!="undefined"){hs.dimmer.owner=hs.dimmer.owner.replace("|"+a,"")}if((typeof a!="undefined"&&hs.dimmer.owner!="")||(hs.upcoming&&hs.getParam(hs.upcoming,"dimmingOpacity"))){return}if(hs.geckoMac&&hs.dimmingGeckoFix){hs.dimmer.style.display="none"}else{hs.animate(hs.dimmer,{opacity:0},hs.dimmingDuration,null,function(){hs.dimmer.style.display="none"})}},transit:function(a,d){var b=d||hs.getExpander();d=b;if(hs.upcoming){return false}else{hs.last=b}hs.removeEventListener(document,window.opera?"keypress":"keydown",hs.keyHandler);try{hs.upcoming=a;a.onclick()}catch(c){hs.last=hs.upcoming=null}try{if(!a||d.transitions[1]!="crossfade"){d.close()}}catch(c){}return false},previousOrNext:function(a,c){var b=hs.getExpander(a);if(b){return hs.transit(b.getAdjacentAnchor(c),b)}else{return false}},previous:function(a){return hs.previousOrNext(a,-1)},next:function(a){return hs.previousOrNext(a,1)},keyHandler:function(a){if(!a){a=window.event}if(!a.target){a.target=a.srcElement}if(typeof a.target.form!="undefined"){return true}var b=hs.getExpander();var c=null;switch(a.keyCode){case 70:if(b){b.doFullExpand()}return true;case 32:c=2;break;case 34:case 39:case 40:c=1;break;case 8:case 33:case 37:case 38:c=-1;break;case 27:case 13:c=0}if(c!==null){hs.removeEventListener(document,window.opera?"keypress":"keydown",hs.keyHandler);if(!hs.enableKeyListener){return true}if(a.preventDefault){a.preventDefault()}else{a.returnValue=false}if(b){if(c==0){b.close()}else{if(c==2){if(b.slideshow){b.slideshow.hitSpace()}}else{if(b.slideshow){b.slideshow.pause()}hs.previousOrNext(b.key,c)}}return false}}return true},registerOverlay:function(a){hs.push(hs.overlays,hs.extend(a,{hsId:"hsId"+hs.idCounter++}))},addSlideshow:function(b){var d=b.slideshowGroup;if(typeof d=="object"){for(var c=0;c<d.length;c++){var e={};for(var a in b){e[a]=b[a]}e.slideshowGroup=d[c];hs.push(hs.slideshows,e)}}else{hs.push(hs.slideshows,b)}},getWrapperKey:function(c,b){var e,d=/^highslide-wrapper-([0-9]+)$/;e=c;while(e.parentNode){if(e.hsKey!==undefined){return e.hsKey}if(e.id&&d.test(e.id)){return e.id.replace(d,"$1")}e=e.parentNode}if(!b){e=c;while(e.parentNode){if(e.tagName&&hs.isHsAnchor(e)){for(var a=0;a<hs.expanders.length;a++){var f=hs.expanders[a];if(f&&f.a==e){return a}}}e=e.parentNode}}return null},getExpander:function(b,a){if(typeof b=="undefined"){return hs.expanders[hs.focusKey]||null}if(typeof b=="number"){return hs.expanders[b]||null}if(typeof b=="string"){b=hs.$(b)}return hs.expanders[hs.getWrapperKey(b,a)]||null},isHsAnchor:function(b){return(b.onclick&&b.onclick.toString().replace(/\s/g," ").match(/hs.(htmlE|e)xpand/))},reOrder:function(){for(var a=0;a<hs.expanders.length;a++){if(hs.expanders[a]&&hs.expanders[a].isExpanded){hs.focusTopmost()}}},mouseClickHandler:function(d){if(!d){d=window.event}if(d.button>1){return true}if(!d.target){d.target=d.srcElement}var b=d.target;while(b.parentNode&&!(/highslide-(image|move|html|resize)/.test(b.className))){b=b.parentNode}var f=hs.getExpander(b);if(f&&(f.isClosing||!f.isExpanded)){return true}if(f&&d.type=="mousedown"){if(d.target.form){return true}var a=b.className.match(/highslide-(image|move|resize)/);if(a){hs.dragArgs={exp:f,type:a[1],left:f.x.pos,width:f.x.size,top:f.y.pos,height:f.y.size,clickX:d.clientX,clickY:d.clientY};hs.addEventListener(document,"mousemove",hs.dragHandler);if(d.preventDefault){d.preventDefault()}if(/highslide-(image|html)-blur/.test(f.content.className)){f.focus();hs.hasFocused=true}return false}}else{if(d.type=="mouseup"){hs.removeEventListener(document,"mousemove",hs.dragHandler);if(hs.dragArgs){if(hs.styleRestoreCursor&&hs.dragArgs.type=="image"){hs.dragArgs.exp.content.style.cursor=hs.styleRestoreCursor}var c=hs.dragArgs.hasDragged;if(!c&&!hs.hasFocused&&!/(move|resize)/.test(hs.dragArgs.type)){f.close()}else{if(c||(!c&&hs.hasHtmlExpanders)){hs.dragArgs.exp.doShowHide("hidden")}}hs.hasFocused=false;hs.dragArgs=null}else{if(/highslide-image-blur/.test(b.className)){b.style.cursor=hs.styleRestoreCursor}}}}return false},dragHandler:function(c){if(!hs.dragArgs){return true}if(!c){c=window.event}var b=hs.dragArgs,d=b.exp;b.dX=c.clientX-b.clickX;b.dY=c.clientY-b.clickY;var f=Math.sqrt(Math.pow(b.dX,2)+Math.pow(b.dY,2));if(!b.hasDragged){b.hasDragged=(b.type!="image"&&f>0)||(f>(hs.dragSensitivity||5))}if(b.hasDragged&&c.clientX>5&&c.clientY>5){if(b.type=="resize"){d.resize(b)}else{d.moveTo(b.left+b.dX,b.top+b.dY);if(b.type=="image"){d.content.style.cursor="move"}}}return false},wrapperMouseHandler:function(c){try{if(!c){c=window.event}var b=/mouseover/i.test(c.type);if(!c.target){c.target=c.srcElement}if(hs.ie){c.relatedTarget=b?c.fromElement:c.toElement}var d=hs.getExpander(c.target);if(!d.isExpanded){return}if(!d||!c.relatedTarget||hs.getExpander(c.relatedTarget,true)==d||hs.dragArgs){return}for(var a=0;a<d.overlays.length;a++){(function(){var e=hs.$("hsId"+d.overlays[a]);if(e&&e.hideOnMouseOut){if(b){hs.setStyles(e,{visibility:"visible",display:""})}hs.animate(e,{opacity:b?e.opacity:0},e.dur)}})()}}catch(c){}},addEventListener:function(a,c,b){if(a==document&&c=="ready"){hs.push(hs.onReady,b)}try{a.addEventListener(c,b,false)}catch(d){try{a.detachEvent("on"+c,b);a.attachEvent("on"+c,b)}catch(d){a["on"+c]=b}}},removeEventListener:function(a,c,b){try{a.removeEventListener(c,b,false)}catch(d){try{a.detachEvent("on"+c,b)}catch(d){a["on"+c]=null}}},preloadFullImage:function(b){if(hs.continuePreloading&&hs.preloadTheseImages[b]&&hs.preloadTheseImages[b]!="undefined"){var a=document.createElement("img");a.onload=function(){a=null;hs.preloadFullImage(b+1)};a.src=hs.preloadTheseImages[b]}},preloadImages:function(c){if(c&&typeof c!="object"){hs.numberOfImagesToPreload=c}var a=hs.getAnchors();for(var b=0;b<a.images.length&&b<hs.numberOfImagesToPreload;b++){hs.push(hs.preloadTheseImages,hs.getSrc(a.images[b]))}if(hs.outlineType){new hs.Outline(hs.outlineType,function(){hs.preloadFullImage(0)})}else{hs.preloadFullImage(0)}if(hs.restoreCursor){var d=hs.createElement("img",{src:hs.graphicsDir+hs.restoreCursor})}},init:function(){if(!hs.container){hs.getPageSize();hs.ieLt7=hs.ie&&hs.uaVersion<7;for(var a in hs.langDefaults){if(typeof hs[a]!="undefined"){hs.lang[a]=hs[a]}else{if(typeof hs.lang[a]=="undefined"&&typeof hs.langDefaults[a]!="undefined"){hs.lang[a]=hs.langDefaults[a]}}}hs.container=hs.createElement("div",{className:"highslide-container"},{position:"absolute",left:0,top:0,width:"100%",zIndex:hs.zIndexCounter,direction:"ltr"},document.body,true);hs.loading=hs.createElement("a",{className:"highslide-loading",title:hs.lang.loadingTitle,innerHTML:hs.lang.loadingText,href:"javascript:;"},{position:"absolute",top:"-9999px",opacity:hs.loadingOpacity,zIndex:1},hs.container);hs.garbageBin=hs.createElement("div",null,{display:"none"},hs.container);hs.viewport=hs.createElement("div",{className:"highslide-viewport highslide-viewport-size"},{visibility:(hs.safari&&hs.uaVersion<525)?"visible":"hidden"},hs.container,1);Math.linearTween=function(f,e,h,g){return h*f/g+e};Math.easeInQuad=function(f,e,h,g){return h*(f/=g)*f+e};Math.easeOutQuad=function(f,e,h,g){return -h*(f/=g)*(f-2)+e};hs.hideSelects=hs.ieLt7;hs.hideIframes=((window.opera&&hs.uaVersion<9)||navigator.vendor=="KDE"||(hs.ie&&hs.uaVersion<5.5))}},ready:function(){if(hs.isReady){return}hs.isReady=true;for(var a=0;a<hs.onReady.length;a++){hs.onReady[a]()}},updateAnchors:function(){var a,c,k=[],h=[],b={},l;for(var e=0;e<hs.openerTagNames.length;e++){c=document.getElementsByTagName(hs.openerTagNames[e]);for(var d=0;d<c.length;d++){a=c[d];l=hs.isHsAnchor(a);if(l){hs.push(k,a);if(l[0]=="hs.expand"){hs.push(h,a)}var f=hs.getParam(a,"slideshowGroup")||"none";if(!b[f]){b[f]=[]}hs.push(b[f],a)}}}hs.anchors={all:k,groups:b,images:h};return hs.anchors},getAnchors:function(){return hs.anchors||hs.updateAnchors()},close:function(a){var b=hs.getExpander(a);if(b){b.close()}return false}};hs.fx=function(b,a,c){this.options=a;this.elem=b;this.prop=c;if(!a.orig){a.orig={}}};hs.fx.prototype={update:function(){(hs.fx.step[this.prop]||hs.fx.step._default)(this);if(this.options.step){this.options.step.call(this.elem,this.now,this)}},custom:function(e,d,c){this.startTime=(new Date()).getTime();this.start=e;this.end=d;this.unit=c;this.now=this.start;this.pos=this.state=0;var a=this;function b(f){return a.step(f)}b.elem=this.elem;if(b()&&hs.timers.push(b)==1){hs.timerId=setInterval(function(){var g=hs.timers;for(var f=0;f<g.length;f++){if(!g[f]()){g.splice(f--,1)}}if(!g.length){clearInterval(hs.timerId)}},13)}},step:function(d){var c=(new Date()).getTime();if(d||c>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var a=true;for(var b in this.options.curAnim){if(this.options.curAnim[b]!==true){a=false}}if(a){if(this.options.complete){this.options.complete.call(this.elem)}}return false}else{var e=c-this.startTime;this.state=e/this.options.duration;this.pos=this.options.easing(e,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};hs.extend(hs.fx,{step:{opacity:function(a){hs.setStyles(a.elem,{opacity:a.now})},_default:function(a){try{if(a.elem.style&&a.elem.style[a.prop]!=null){a.elem.style[a.prop]=a.now+a.unit}else{a.elem[a.prop]=a.now}}catch(b){}}}});hs.Outline=function(g,e){this.onLoad=e;this.outlineType=g;var a=hs.uaVersion,f;this.hasAlphaImageLoader=hs.ie&&a>=5.5&&a<7;if(!g){if(e){e()}return}hs.init();this.table=hs.createElement("table",{cellSpacing:0},{visibility:"hidden",position:"absolute",borderCollapse:"collapse",width:0},hs.container,true);var b=hs.createElement("tbody",null,null,this.table,1);this.td=[];for(var c=0;c<=8;c++){if(c%3==0){f=hs.createElement("tr",null,{height:"auto"},b,true)}this.td[c]=hs.createElement("td",null,null,f,true);var d=c!=4?{lineHeight:0,fontSize:0}:{position:"relative"};hs.setStyles(this.td[c],d)}this.td[4].className=g+" highslide-outline";this.preloadGraphic()};hs.Outline.prototype={preloadGraphic:function(){var b=hs.graphicsDir+(hs.outlinesDir||"outlines/")+this.outlineType+".png";var a=hs.safari&&hs.uaVersion<525?hs.container:null;this.graphic=hs.createElement("img",null,{position:"absolute",top:"-9999px"},a,true);var c=this;this.graphic.onload=function(){c.onGraphicLoad()};this.graphic.src=b},onGraphicLoad:function(){var d=this.offset=this.graphic.width/4,f=[[0,0],[0,-4],[-2,0],[0,-8],0,[-2,-8],[0,-2],[0,-6],[-2,-2]],c={height:(2*d)+"px",width:(2*d)+"px"};for(var b=0;b<=8;b++){if(f[b]){if(this.hasAlphaImageLoader){var a=(b==1||b==7)?"100%":this.graphic.width+"px";var e=hs.createElement("div",null,{width:"100%",height:"100%",position:"relative",overflow:"hidden"},this.td[b],true);hs.createElement("div",null,{filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale, src='"+this.graphic.src+"')",position:"absolute",width:a,height:this.graphic.height+"px",left:(f[b][0]*d)+"px",top:(f[b][1]*d)+"px"},e,true)}else{hs.setStyles(this.td[b],{background:"url("+this.graphic.src+") "+(f[b][0]*d)+"px "+(f[b][1]*d)+"px"})}if(window.opera&&(b==3||b==5)){hs.createElement("div",null,c,this.td[b],true)}hs.setStyles(this.td[b],c)}}this.graphic=null;if(hs.pendingOutlines[this.outlineType]){hs.pendingOutlines[this.outlineType].destroy()}hs.pendingOutlines[this.outlineType]=this;if(this.onLoad){this.onLoad()}},setPosition:function(g,e,c,b,f){var d=this.exp,a=d.wrapper.style,e=e||0,g=g||{x:d.x.pos+e,y:d.y.pos+e,w:d.x.get("wsize")-2*e,h:d.y.get("wsize")-2*e};if(c){this.table.style.visibility=(g.h>=4*this.offset)?"visible":"hidden"}hs.setStyles(this.table,{left:(g.x-this.offset)+"px",top:(g.y-this.offset)+"px",width:(g.w+2*this.offset)+"px"});g.w-=2*this.offset;g.h-=2*this.offset;hs.setStyles(this.td[4],{width:g.w>=0?g.w+"px":0,height:g.h>=0?g.h+"px":0});if(this.hasAlphaImageLoader){this.td[3].style.height=this.td[5].style.height=this.td[4].style.height}},destroy:function(a){if(a){this.table.style.visibility="hidden"}else{hs.discardElement(this.table)}}};hs.Dimension=function(b,a){this.exp=b;this.dim=a;this.ucwh=a=="x"?"Width":"Height";this.wh=this.ucwh.toLowerCase();this.uclt=a=="x"?"Left":"Top";this.lt=this.uclt.toLowerCase();this.ucrb=a=="x"?"Right":"Bottom";this.rb=this.ucrb.toLowerCase();this.p1=this.p2=0};hs.Dimension.prototype={get:function(a){switch(a){case"loadingPos":return this.tpos+this.tb+(this.t-hs.loading["offset"+this.ucwh])/2;case"loadingPosXfade":return this.pos+this.cb+this.p1+(this.size-hs.loading["offset"+this.ucwh])/2;case"wsize":return this.size+2*this.cb+this.p1+this.p2;case"fitsize":return this.clientSize-this.marginMin-this.marginMax;case"maxsize":return this.get("fitsize")-2*this.cb-this.p1-this.p2;case"opos":return this.pos-(this.exp.outline?this.exp.outline.offset:0);case"osize":return this.get("wsize")+(this.exp.outline?2*this.exp.outline.offset:0);case"imgPad":return this.imgSize?Math.round((this.size-this.imgSize)/2):0}},calcBorders:function(){this.cb=(this.exp.content["offset"+this.ucwh]-this.t)/2;this.marginMax=hs["margin"+this.ucrb]},calcThumb:function(){this.t=this.exp.el[this.wh]?parseInt(this.exp.el[this.wh]):this.exp.el["offset"+this.ucwh];this.tpos=this.exp.tpos[this.dim];this.tb=(this.exp.el["offset"+this.ucwh]-this.t)/2;if(this.tpos==0||this.tpos==-1){this.tpos=(hs.page[this.wh]/2)+hs.page["scroll"+this.uclt]}},calcExpanded:function(){var a=this.exp;this.justify="auto";if(a.align=="center"){this.justify="center"}else{if(new RegExp(this.lt).test(a.anchor)){this.justify=null}else{if(new RegExp(this.rb).test(a.anchor)){this.justify="max"}}}this.pos=this.tpos-this.cb+this.tb;if(this.maxHeight&&this.dim=="x"){a.maxWidth=Math.min(a.maxWidth||this.full,a.maxHeight*this.full/a.y.full)}this.size=Math.min(this.full,a["max"+this.ucwh]||this.full);this.minSize=a.allowSizeReduction?Math.min(a["min"+this.ucwh],this.full):this.full;if(a.isImage&&a.useBox){this.size=a[this.wh];this.imgSize=this.full}if(this.dim=="x"&&hs.padToMinWidth){this.minSize=a.minWidth}this.target=a["target"+this.dim.toUpperCase()];this.marginMin=hs["margin"+this.uclt];this.scroll=hs.page["scroll"+this.uclt];this.clientSize=hs.page[this.wh]},setSize:function(a){var b=this.exp;if(b.isImage&&(b.useBox||hs.padToMinWidth)){this.imgSize=a;this.size=Math.max(this.size,this.imgSize);b.content.style[this.lt]=this.get("imgPad")+"px"}else{this.size=a}b.content.style[this.wh]=a+"px";b.wrapper.style[this.wh]=this.get("wsize")+"px";if(b.outline){b.outline.setPosition()}if(this.dim=="x"&&b.overlayBox){b.sizeOverlayBox(true)}if(this.dim=="x"&&b.slideshow&&b.isImage){if(a==this.full){b.slideshow.disable("full-expand")}else{b.slideshow.enable("full-expand")}}},setPos:function(a){this.pos=a;this.exp.wrapper.style[this.lt]=a+"px";if(this.exp.outline){this.exp.outline.setPosition()}}};hs.Expander=function(k,f,b,l){if(document.readyState&&hs.ie&&!hs.isReady){hs.addEventListener(document,"ready",function(){new hs.Expander(k,f,b,l)});return}this.a=k;this.custom=b;this.contentType=l||"image";this.isImage=!this.isHtml;hs.continuePreloading=false;this.overlays=[];this.last=hs.last;hs.last=null;hs.init();var m=this.key=hs.expanders.length;for(var g=0;g<hs.overrides.length;g++){var c=hs.overrides[g];this[c]=f&&typeof f[c]!="undefined"?f[c]:hs[c]}if(!this.src){this.src=k.href}var d=(f&&f.thumbnailId)?hs.$(f.thumbnailId):k;d=this.thumb=d.getElementsByTagName("img")[0]||d;this.thumbsUserSetId=d.id||k.id;for(var g=0;g<hs.expanders.length;g++){if(hs.expanders[g]&&hs.expanders[g].a==k&&!(this.last&&this.transitions[1]=="crossfade")){hs.expanders[g].focus();return false}}if(!hs.allowSimultaneousLoading){for(var g=0;g<hs.expanders.length;g++){if(hs.expanders[g]&&hs.expanders[g].thumb!=d&&!hs.expanders[g].onLoadStarted){hs.expanders[g].cancelLoading()}}}hs.expanders[m]=this;if(!hs.allowMultipleInstances&&!hs.upcoming){if(hs.expanders[m-1]){hs.expanders[m-1].close()}if(typeof hs.focusKey!="undefined"&&hs.expanders[hs.focusKey]){hs.expanders[hs.focusKey].close()}}this.el=d;this.tpos=this.pageOrigin||hs.getPosition(d);hs.getPageSize();var j=this.x=new hs.Dimension(this,"x");j.calcThumb();var h=this.y=new hs.Dimension(this,"y");h.calcThumb();this.wrapper=hs.createElement("div",{id:"highslide-wrapper-"+this.key,className:"highslide-wrapper "+this.wrapperClassName},{visibility:"hidden",position:"absolute",zIndex:hs.zIndexCounter+=2},null,true);this.wrapper.onmouseover=this.wrapper.onmouseout=hs.wrapperMouseHandler;if(this.contentType=="image"&&this.outlineWhileAnimating==2){this.outlineWhileAnimating=0}if(!this.outlineType||(this.last&&this.isImage&&this.transitions[1]=="crossfade")){this[this.contentType+"Create"]()}else{if(hs.pendingOutlines[this.outlineType]){this.connectOutline();this[this.contentType+"Create"]()}else{this.showLoading();var e=this;new hs.Outline(this.outlineType,function(){e.connectOutline();e[e.contentType+"Create"]()})}}return true};hs.Expander.prototype={error:function(a){if(hs.debug){alert("Line "+a.lineNumber+": "+a.message)}else{window.location.href=this.src}},connectOutline:function(){var a=this.outline=hs.pendingOutlines[this.outlineType];a.exp=this;a.table.style.zIndex=this.wrapper.style.zIndex-1;hs.pendingOutlines[this.outlineType]=null},showLoading:function(){if(this.onLoadStarted||this.loading){return}this.loading=hs.loading;var c=this;this.loading.onclick=function(){c.cancelLoading()};var c=this,a=this.x.get("loadingPos")+"px",b=this.y.get("loadingPos")+"px";if(!d&&this.last&&this.transitions[1]=="crossfade"){var d=this.last}if(d){a=d.x.get("loadingPosXfade")+"px";b=d.y.get("loadingPosXfade")+"px";this.loading.style.zIndex=hs.zIndexCounter++}setTimeout(function(){if(c.loading){hs.setStyles(c.loading,{left:a,top:b,zIndex:hs.zIndexCounter++})}},100)},imageCreate:function(){var b=this;var a=document.createElement("img");this.content=a;a.onload=function(){if(hs.expanders[b.key]){b.contentLoaded()}};if(hs.blockRightClick){a.oncontextmenu=function(){return false}}a.className="highslide-image";hs.setStyles(a,{visibility:"hidden",display:"block",position:"absolute",maxWidth:"9999px",zIndex:3});a.title=hs.lang.restoreTitle;if(hs.safari&&hs.uaVersion<525){hs.container.appendChild(a)}if(hs.ie&&hs.flushImgSize){a.src=null}a.src=this.src;this.showLoading()},contentLoaded:function(){try{if(!this.content){return}this.content.onload=null;if(this.onLoadStarted){return}else{this.onLoadStarted=true}var j=this.x,g=this.y;if(this.loading){hs.setStyles(this.loading,{top:"-9999px"});this.loading=null}j.full=this.content.width;g.full=this.content.height;hs.setStyles(this.content,{width:j.t+"px",height:g.t+"px"});this.wrapper.appendChild(this.content);hs.container.appendChild(this.wrapper);j.calcBorders();g.calcBorders();hs.setStyles(this.wrapper,{left:(j.tpos+j.tb-j.cb)+"px",top:(g.tpos+j.tb-g.cb)+"px"});this.initSlideshow();this.getOverlays();var f=j.full/g.full;j.calcExpanded();this.justify(j);g.calcExpanded();this.justify(g);if(this.overlayBox){this.sizeOverlayBox(0,1)}if(this.allowSizeReduction){this.correctRatio(f);var k=this.slideshow;if(k&&this.last&&k.controls&&k.fixedControls){var h=k.overlayOptions.position||"",a;for(var c in hs.oPos){for(var b=0;b<5;b++){a=this[c];if(h.match(hs.oPos[c][b])){a.pos=this.last[c].pos+(this.last[c].p1-a.p1)+(this.last[c].size-a.size)*[0,0,0.5,1,1][b];if(k.fixedControls=="fit"){if(a.pos+a.size+a.p1+a.p2>a.scroll+a.clientSize-a.marginMax){a.pos=a.scroll+a.clientSize-a.size-a.marginMin-a.marginMax-a.p1-a.p2}if(a.pos<a.scroll+a.marginMin){a.pos=a.scroll+a.marginMin}}}}}}if(this.isImage&&this.x.full>(this.x.imgSize||this.x.size)){this.createFullExpand();if(this.overlays.length==1){this.sizeOverlayBox()}}}this.show()}catch(d){this.error(d)}},justify:function(f,b){var g,h=f.target,e=f==this.x?"x":"y";if(h&&h.match(/ /)){g=h.split(" ");h=g[0]}if(h&&hs.$(h)){f.pos=hs.getPosition(hs.$(h))[e];if(g&&g[1]&&g[1].match(/^[-]?[0-9]+px$/)){f.pos+=parseInt(g[1])}if(f.size<f.minSize){f.size=f.minSize}}else{if(f.justify=="auto"||f.justify=="center"){var d=false;var a=f.exp.allowSizeReduction;if(f.justify=="center"){f.pos=Math.round(f.scroll+(f.clientSize+f.marginMin-f.marginMax-f.get("wsize"))/2)}else{f.pos=Math.round(f.pos-((f.get("wsize")-f.t)/2))}if(f.pos<f.scroll+f.marginMin){f.pos=f.scroll+f.marginMin;d=true}if(!b&&f.size<f.minSize){f.size=f.minSize;a=false}if(f.pos+f.get("wsize")>f.scroll+f.clientSize-f.marginMax){if(!b&&d&&a){f.size=Math.min(f.size,f.get(e=="y"?"fitsize":"maxsize"))}else{if(f.get("wsize")<f.get("fitsize")){f.pos=f.scroll+f.clientSize-f.marginMax-f.get("wsize")}else{f.pos=f.scroll+f.marginMin;if(!b&&a){f.size=f.get(e=="y"?"fitsize":"maxsize")}}}}if(!b&&f.size<f.minSize){f.size=f.minSize;a=false}}else{if(f.justify=="max"){f.pos=Math.floor(f.pos-f.size+f.t)}}}if(f.pos<f.marginMin){var c=f.pos;f.pos=f.marginMin;if(a&&!b){f.size=f.size-(f.pos-c)}}},correctRatio:function(c){var a=this.x,g=this.y,e=false,d=Math.min(a.full,a.size),b=Math.min(g.full,g.size),f=(this.useBox||hs.padToMinWidth);if(d/b>c){d=b*c;if(d<a.minSize){d=a.minSize;b=d/c}e=true}else{if(d/b<c){b=d/c;e=true}}if(hs.padToMinWidth&&a.full<a.minSize){a.imgSize=a.full;g.size=g.imgSize=g.full}else{if(this.useBox){a.imgSize=d;g.imgSize=b}else{a.size=d;g.size=b}}e=this.fitOverlayBox(this.useBox?null:c,e);if(f&&g.size<g.imgSize){g.imgSize=g.size;a.imgSize=g.size*c}if(e||f){a.pos=a.tpos-a.cb+a.tb;a.minSize=a.size;this.justify(a,true);g.pos=g.tpos-g.cb+g.tb;g.minSize=g.size;this.justify(g,true);if(this.overlayBox){this.sizeOverlayBox()}}},fitOverlayBox:function(b,c){var a=this.x,d=this.y;if(this.overlayBox){while(d.size>this.minHeight&&a.size>this.minWidth&&d.get("wsize")>d.get("fitsize")){d.size-=10;if(b){a.size=d.size*b}this.sizeOverlayBox(0,1);c=true}}return c},show:function(){var a=this.x,b=this.y;this.doShowHide("hidden");if(this.slideshow&&this.slideshow.thumbstrip){this.slideshow.thumbstrip.selectThumb()}this.changeSize(1,{wrapper:{width:a.get("wsize"),height:b.get("wsize"),left:a.pos,top:b.pos},content:{left:a.p1+a.get("imgPad"),top:b.p1+b.get("imgPad"),width:a.imgSize||a.size,height:b.imgSize||b.size}},hs.expandDuration)},changeSize:function(d,i,b){var k=this.transitions,e=d?(this.last?this.last.a:null):hs.upcoming,j=(k[1]&&e&&hs.getParam(e,"transitions")[1]==k[1])?k[1]:k[0];if(this[j]&&j!="expand"){this[j](d,i);return}if(this.outline&&!this.outlineWhileAnimating){if(d){this.outline.setPosition()}else{this.outline.destroy()}}if(!d){this.destroyOverlays()}var c=this,h=c.x,g=c.y,f=this.easing;if(!d){f=this.easingClose||f}var a=d?function(){if(c.outline){c.outline.table.style.visibility="visible"}setTimeout(function(){c.afterExpand()},50)}:function(){c.afterClose()};if(d){hs.setStyles(this.wrapper,{width:h.t+"px",height:g.t+"px"})}if(this.fadeInOut){hs.setStyles(this.wrapper,{opacity:d?0:1});hs.extend(i.wrapper,{opacity:d})}hs.animate(this.wrapper,i.wrapper,{duration:b,easing:f,step:function(n,l){if(c.outline&&c.outlineWhileAnimating&&l.prop=="top"){var m=d?l.pos:1-l.pos;var o={w:h.t+(h.get("wsize")-h.t)*m,h:g.t+(g.get("wsize")-g.t)*m,x:h.tpos+(h.pos-h.tpos)*m,y:g.tpos+(g.pos-g.tpos)*m};c.outline.setPosition(o,0,1)}}});hs.animate(this.content,i.content,b,f,a);if(d){this.wrapper.style.visibility="visible";this.content.style.visibility="visible";this.a.className+=" highslide-active-anchor"}},fade:function(f,h){this.outlineWhileAnimating=false;var c=this,j=f?hs.expandDuration:0;if(f){hs.animate(this.wrapper,h.wrapper,0);hs.setStyles(this.wrapper,{opacity:0,visibility:"visible"});hs.animate(this.content,h.content,0);this.content.style.visibility="visible";hs.animate(this.wrapper,{opacity:1},j,null,function(){c.afterExpand()})}if(this.outline){this.outline.table.style.zIndex=this.wrapper.style.zIndex;var b=f||-1,d=this.outline.offset,a=f?3:d,g=f?d:3;for(var e=a;b*e<=b*g;e+=b,j+=25){(function(){var i=f?g-e:a-e;setTimeout(function(){c.outline.setPosition(0,i,1)},j)})()}}if(f){}else{setTimeout(function(){if(c.outline){c.outline.destroy(c.preserveContent)}c.destroyOverlays();hs.animate(c.wrapper,{opacity:0},hs.restoreDuration,null,function(){c.afterClose()})},j)}},crossfade:function(g,m,o){if(!g){return}var f=this,p=this.last,l=this.x,k=this.y,d=p.x,b=p.y,a=this.wrapper,i=this.content,c=this.overlayBox;hs.removeEventListener(document,"mousemove",hs.dragHandler);hs.setStyles(i,{width:(l.imgSize||l.size)+"px",height:(k.imgSize||k.size)+"px"});if(c){c.style.overflow="visible"}this.outline=p.outline;if(this.outline){this.outline.exp=f}p.outline=null;var h=hs.createElement("div",{className:"highslide-"+this.contentType},{position:"absolute",zIndex:4,overflow:"hidden",display:"none"});var j={oldImg:p,newImg:this};for(var e in j){this[e]=j[e].content.cloneNode(1);hs.setStyles(this[e],{position:"absolute",border:0,visibility:"visible"});h.appendChild(this[e])}a.appendChild(h);if(c){c.className="";a.appendChild(c)}h.style.display="";p.content.style.display="none";if(hs.safari&&hs.uaVersion<525){this.wrapper.style.visibility="visible"}hs.animate(a,{width:l.size},{duration:hs.transitionDuration,step:function(u,r){var x=r.pos,q=1-x;var w,s={},t=["pos","size","p1","p2"];for(var v in t){w=t[v];s["x"+w]=Math.round(q*d[w]+x*l[w]);s["y"+w]=Math.round(q*b[w]+x*k[w]);s.ximgSize=Math.round(q*(d.imgSize||d.size)+x*(l.imgSize||l.size));s.ximgPad=Math.round(q*d.get("imgPad")+x*l.get("imgPad"));s.yimgSize=Math.round(q*(b.imgSize||b.size)+x*(k.imgSize||k.size));s.yimgPad=Math.round(q*b.get("imgPad")+x*k.get("imgPad"))}if(f.outline){f.outline.setPosition({x:s.xpos,y:s.ypos,w:s.xsize+s.xp1+s.xp2+2*l.cb,h:s.ysize+s.yp1+s.yp2+2*k.cb})}p.wrapper.style.clip="rect("+(s.ypos-b.pos)+"px, "+(s.xsize+s.xp1+s.xp2+s.xpos+2*d.cb-d.pos)+"px, "+(s.ysize+s.yp1+s.yp2+s.ypos+2*b.cb-b.pos)+"px, "+(s.xpos-d.pos)+"px)";hs.setStyles(i,{top:(s.yp1+k.get("imgPad"))+"px",left:(s.xp1+l.get("imgPad"))+"px",marginTop:(k.pos-s.ypos)+"px",marginLeft:(l.pos-s.xpos)+"px"});hs.setStyles(a,{top:s.ypos+"px",left:s.xpos+"px",width:(s.xp1+s.xp2+s.xsize+2*l.cb)+"px",height:(s.yp1+s.yp2+s.ysize+2*k.cb)+"px"});hs.setStyles(h,{width:(s.ximgSize||s.xsize)+"px",height:(s.yimgSize||s.ysize)+"px",left:(s.xp1+s.ximgPad)+"px",top:(s.yp1+s.yimgPad)+"px",visibility:"visible"});hs.setStyles(f.oldImg,{top:(b.pos-s.ypos+b.p1-s.yp1+b.get("imgPad")-s.yimgPad)+"px",left:(d.pos-s.xpos+d.p1-s.xp1+d.get("imgPad")-s.ximgPad)+"px"});hs.setStyles(f.newImg,{opacity:x,top:(k.pos-s.ypos+k.p1-s.yp1+k.get("imgPad")-s.yimgPad)+"px",left:(l.pos-s.xpos+l.p1-s.xp1+l.get("imgPad")-s.ximgPad)+"px"});if(c){hs.setStyles(c,{width:s.xsize+"px",height:s.ysize+"px",left:(s.xp1+l.cb)+"px",top:(s.yp1+k.cb)+"px"})}},complete:function(){a.style.visibility=i.style.visibility="visible";i.style.display="block";hs.discardElement(h);f.afterExpand();p.afterClose();f.last=null}})},reuseOverlay:function(d,c){if(!this.last){return false}for(var b=0;b<this.last.overlays.length;b++){var a=hs.$("hsId"+this.last.overlays[b]);if(a&&a.hsId==d.hsId){this.genOverlayBox();a.reuse=this.key;hs.push(this.overlays,this.last.overlays[b]);return true}}return false},afterExpand:function(){this.isExpanded=true;this.focus();if(this.dimmingOpacity){hs.dim(this)}if(hs.upcoming&&hs.upcoming==this.a){hs.upcoming=null}this.prepareNextOutline();var c=hs.page,b=hs.mouse.x+c.scrollLeft,a=hs.mouse.y+c.scrollTop;this.mouseIsOver=this.x.pos<b&&b<this.x.pos+this.x.get("wsize")&&this.y.pos<a&&a<this.y.pos+this.y.get("wsize");if(this.overlayBox){this.showOverlays()}},prepareNextOutline:function(){var a=this.key;var b=this.outlineType;new hs.Outline(b,function(){try{hs.expanders[a].preloadNext()}catch(c){}})},preloadNext:function(){var b=this.getAdjacentAnchor(1);if(b&&b.onclick.toString().match(/hs\.expand/)){var a=hs.createElement("img",{src:hs.getSrc(b)})}},getAdjacentAnchor:function(c){var b=this.getAnchorIndex(),a=hs.anchors.groups[this.slideshowGroup||"none"];if(a&&!a[b+c]&&this.slideshow&&this.slideshow.repeat){if(c==1){return a[0]}else{if(c==-1){return a[a.length-1]}}}return(a&&a[b+c])||null},getAnchorIndex:function(){var a=hs.getAnchors().groups[this.slideshowGroup||"none"];if(a){for(var b=0;b<a.length;b++){if(a[b]==this.a){return b}}}return null},getNumber:function(){if(this[this.numberPosition]){var a=hs.anchors.groups[this.slideshowGroup||"none"];if(a){var b=hs.lang.number.replace("%1",this.getAnchorIndex()+1).replace("%2",a.length);this[this.numberPosition].innerHTML='<div class="highslide-number">'+b+"</div>"+this[this.numberPosition].innerHTML}}},initSlideshow:function(){if(!this.last){for(var c=0;c<hs.slideshows.length;c++){var b=hs.slideshows[c],d=b.slideshowGroup;if(typeof d=="undefined"||d===null||d===this.slideshowGroup){this.slideshow=new hs.Slideshow(this.key,b)}}}else{this.slideshow=this.last.slideshow}var b=this.slideshow;if(!b){return}var a=b.expKey=this.key;b.checkFirstAndLast();b.disable("full-expand");if(b.controls){this.createOverlay(hs.extend(b.overlayOptions||{},{overlayId:b.controls,hsId:"controls",zIndex:5}))}if(b.thumbstrip){b.thumbstrip.add(this)}if(!this.last&&this.autoplay){b.play(true)}if(b.autoplay){b.autoplay=setTimeout(function(){hs.next(a)},(b.interval||500))}},cancelLoading:function(){hs.discardElement(this.wrapper);hs.expanders[this.key]=null;if(hs.upcoming==this.a){hs.upcoming=null}hs.undim(this.key);if(this.loading){hs.loading.style.left="-9999px"}},writeCredits:function(){if(this.credits){return}this.credits=hs.createElement("a",{href:hs.creditsHref,target:hs.creditsTarget,className:"highslide-credits",innerHTML:hs.lang.creditsText,title:hs.lang.creditsTitle});this.createOverlay({overlayId:this.credits,position:this.creditsPosition||"top left",hsId:"credits"})},getInline:function(types,addOverlay){for(var i=0;i<types.length;i++){var type=types[i],s=null;if(!this[type+"Id"]&&this.thumbsUserSetId){this[type+"Id"]=type+"-for-"+this.thumbsUserSetId}if(this[type+"Id"]){this[type]=hs.getNode(this[type+"Id"])}if(!this[type]&&!this[type+"Text"]&&this[type+"Eval"]){try{s=eval(this[type+"Eval"])}catch(e){}}if(!this[type]&&this[type+"Text"]){s=this[type+"Text"]}if(!this[type]&&!s){this[type]=hs.getNode(this.a["_"+type+"Id"]);if(!this[type]){var next=this.a.nextSibling;while(next&&!hs.isHsAnchor(next)){if((new RegExp("highslide-"+type)).test(next.className||null)){if(!next.id){this.a["_"+type+"Id"]=next.id="hsId"+hs.idCounter++}this[type]=hs.getNode(next.id);break}next=next.nextSibling}}}if(!this[type]&&!s&&this.numberPosition==type){s="\n"}if(!this[type]&&s){this[type]=hs.createElement("div",{className:"highslide-"+type,innerHTML:s})}if(addOverlay&&this[type]){var o={position:(type=="heading")?"above":"below"};for(var x in this[type+"Overlay"]){o[x]=this[type+"Overlay"][x]}o.overlayId=this[type];this.createOverlay(o)}}},doShowHide:function(a){if(hs.hideSelects){this.showHideElements("SELECT",a)}if(hs.hideIframes){this.showHideElements("IFRAME",a)}if(hs.geckoMac){this.showHideElements("*",a)}},showHideElements:function(c,b){var e=document.getElementsByTagName(c);var a=c=="*"?"overflow":"visibility";for(var f=0;f<e.length;f++){if(a=="visibility"||(document.defaultView.getComputedStyle(e[f],"").getPropertyValue("overflow")=="auto"||e[f].getAttribute("hidden-by")!=null)){var h=e[f].getAttribute("hidden-by");if(b=="visible"&&h){h=h.replace("["+this.key+"]","");e[f].setAttribute("hidden-by",h);if(!h){e[f].style[a]=e[f].origProp}}else{if(b=="hidden"){var k=hs.getPosition(e[f]);k.w=e[f].offsetWidth;k.h=e[f].offsetHeight;if(!this.dimmingOpacity){var j=(k.x+k.w<this.x.get("opos")||k.x>this.x.get("opos")+this.x.get("osize"));var g=(k.y+k.h<this.y.get("opos")||k.y>this.y.get("opos")+this.y.get("osize"))}var d=hs.getWrapperKey(e[f]);if(!j&&!g&&d!=this.key){if(!h){e[f].setAttribute("hidden-by","["+this.key+"]");e[f].origProp=e[f].style[a];e[f].style[a]="hidden"}else{if(h.indexOf("["+this.key+"]")==-1){e[f].setAttribute("hidden-by",h+"["+this.key+"]")}}}else{if((h=="["+this.key+"]"||hs.focusKey==d)&&d!=this.key){e[f].setAttribute("hidden-by","");e[f].style[a]=e[f].origProp||""}else{if(h&&h.indexOf("["+this.key+"]")>-1){e[f].setAttribute("hidden-by",h.replace("["+this.key+"]",""))}}}}}}}},focus:function(){this.wrapper.style.zIndex=hs.zIndexCounter+=2;for(var a=0;a<hs.expanders.length;a++){if(hs.expanders[a]&&a==hs.focusKey){var b=hs.expanders[a];b.content.className+=" highslide-"+b.contentType+"-blur";b.content.style.cursor=hs.ie?"hand":"pointer";b.content.title=hs.lang.focusTitle}}if(this.outline){this.outline.table.style.zIndex=this.wrapper.style.zIndex-1}this.content.className="highslide-"+this.contentType;this.content.title=hs.lang.restoreTitle;if(hs.restoreCursor){hs.styleRestoreCursor=window.opera?"pointer":"url("+hs.graphicsDir+hs.restoreCursor+"), pointer";if(hs.ie&&hs.uaVersion<6){hs.styleRestoreCursor="hand"}this.content.style.cursor=hs.styleRestoreCursor}hs.focusKey=this.key;hs.addEventListener(document,window.opera?"keypress":"keydown",hs.keyHandler)},moveTo:function(a,b){this.x.setPos(a);this.y.setPos(b)},resize:function(d){var a,b,c=d.width/d.height;a=Math.max(d.width+d.dX,Math.min(this.minWidth,this.x.full));if(this.isImage&&Math.abs(a-this.x.full)<12){a=this.x.full}b=a/c;if(b<Math.min(this.minHeight,this.y.full)){b=Math.min(this.minHeight,this.y.full);if(this.isImage){a=b*c}}this.resizeTo(a,b)},resizeTo:function(a,b){this.y.setSize(b);this.x.setSize(a);this.wrapper.style.height=this.y.get("wsize")+"px"},close:function(){if(this.isClosing||!this.isExpanded){return}if(this.transitions[1]=="crossfade"&&hs.upcoming){hs.getExpander(hs.upcoming).cancelLoading();hs.upcoming=null}this.isClosing=true;if(this.slideshow&&!hs.upcoming){this.slideshow.pause()}hs.removeEventListener(document,window.opera?"keypress":"keydown",hs.keyHandler);try{this.content.style.cursor="default";this.changeSize(0,{wrapper:{width:this.x.t,height:this.y.t,left:this.x.tpos-this.x.cb+this.x.tb,top:this.y.tpos-this.y.cb+this.y.tb},content:{left:0,top:0,width:this.x.t,height:this.y.t}},hs.restoreDuration)}catch(a){this.afterClose()}},createOverlay:function(e){var d=e.overlayId,a=(e.relativeTo=="viewport"&&!/panel$/.test(e.position));if(typeof d=="string"){d=hs.getNode(d)}if(e.html){d=hs.createElement("div",{innerHTML:e.html})}if(!d||typeof d=="string"){return}d.style.display="block";e.hsId=e.hsId||e.overlayId;if(this.transitions[1]=="crossfade"&&this.reuseOverlay(e,d)){return}this.genOverlayBox();var c=e.width&&/^[0-9]+(px|%)$/.test(e.width)?e.width:"auto";if(/^(left|right)panel$/.test(e.position)&&!/^[0-9]+px$/.test(e.width)){c="200px"}var b=hs.createElement("div",{id:"hsId"+hs.idCounter++,hsId:e.hsId},{position:"absolute",visibility:"hidden",width:c,direction:hs.lang.cssDirection||"",opacity:0},a?hs.viewport:this.overlayBox,true);if(a){b.hsKey=this.key}b.appendChild(d);hs.extend(b,{opacity:1,offsetX:0,offsetY:0,dur:(e.fade===0||e.fade===false||(e.fade==2&&hs.ie))?0:250});hs.extend(b,e);if(this.gotOverlays){this.positionOverlay(b);if(!b.hideOnMouseOut||this.mouseIsOver){hs.animate(b,{opacity:b.opacity},b.dur)}}hs.push(this.overlays,hs.idCounter-1)},positionOverlay:function(e){var f=e.position||"middle center",c=(e.relativeTo=="viewport"),b=e.offsetX,a=e.offsetY;if(c){hs.viewport.style.display="block";e.hsKey=this.key;if(e.offsetWidth>e.parentNode.offsetWidth){e.style.width="100%"}}else{if(e.parentNode!=this.overlayBox){this.overlayBox.appendChild(e)}}if(/left$/.test(f)){e.style.left=b+"px"}if(/center$/.test(f)){hs.setStyles(e,{left:"50%",marginLeft:(b-Math.round(e.offsetWidth/2))+"px"})}if(/right$/.test(f)){e.style.right=-b+"px"}if(/^leftpanel$/.test(f)){hs.setStyles(e,{right:"100%",marginRight:this.x.cb+"px",top:-this.y.cb+"px",bottom:-this.y.cb+"px",overflow:"auto"});this.x.p1=e.offsetWidth}else{if(/^rightpanel$/.test(f)){hs.setStyles(e,{left:"100%",marginLeft:this.x.cb+"px",top:-this.y.cb+"px",bottom:-this.y.cb+"px",overflow:"auto"});this.x.p2=e.offsetWidth}}var d=e.parentNode.offsetHeight;e.style.height="auto";if(c&&e.offsetHeight>d){e.style.height=hs.ieLt7?d+"px":"100%"}if(/^top/.test(f)){e.style.top=a+"px"}if(/^middle/.test(f)){hs.setStyles(e,{top:"50%",marginTop:(a-Math.round(e.offsetHeight/2))+"px"})}if(/^bottom/.test(f)){e.style.bottom=-a+"px"}if(/^above$/.test(f)){hs.setStyles(e,{left:(-this.x.p1-this.x.cb)+"px",right:(-this.x.p2-this.x.cb)+"px",bottom:"100%",marginBottom:this.y.cb+"px",width:"auto"});this.y.p1=e.offsetHeight}else{if(/^below$/.test(f)){hs.setStyles(e,{position:"relative",left:(-this.x.p1-this.x.cb)+"px",right:(-this.x.p2-this.x.cb)+"px",top:"100%",marginTop:this.y.cb+"px",width:"auto"});this.y.p2=e.offsetHeight;e.style.position="absolute"}}},getOverlays:function(){this.getInline(["heading","caption"],true);this.getNumber();if(this.heading&&this.dragByHeading){this.heading.className+=" highslide-move"}if(hs.showCredits){this.writeCredits()}for(var a=0;a<hs.overlays.length;a++){var d=hs.overlays[a],e=d.thumbnailId,b=d.slideshowGroup;if((!e&&!b)||(e&&e==this.thumbsUserSetId)||(b&&b===this.slideshowGroup)){this.createOverlay(d)}}var c=[];for(var a=0;a<this.overlays.length;a++){var d=hs.$("hsId"+this.overlays[a]);if(/panel$/.test(d.position)){this.positionOverlay(d)}else{hs.push(c,d)}}for(var a=0;a<c.length;a++){this.positionOverlay(c[a])}this.gotOverlays=true},genOverlayBox:function(){if(!this.overlayBox){this.overlayBox=hs.createElement("div",{className:this.wrapperClassName},{position:"absolute",width:(this.x.size||(this.useBox?this.width:null)||this.x.full)+"px",height:(this.y.size||this.y.full)+"px",visibility:"hidden",overflow:"hidden",zIndex:hs.ie?4:"auto"},hs.container,true)}},sizeOverlayBox:function(f,d){var c=this.overlayBox,a=this.x,h=this.y;hs.setStyles(c,{width:a.size+"px",height:h.size+"px"});if(f||d){for(var e=0;e<this.overlays.length;e++){var g=hs.$("hsId"+this.overlays[e]);var b=(hs.ieLt7||document.compatMode=="BackCompat");if(g&&/^(above|below)$/.test(g.position)){if(b){g.style.width=(c.offsetWidth+2*a.cb+a.p1+a.p2)+"px"}h[g.position=="above"?"p1":"p2"]=g.offsetHeight}if(g&&b&&/^(left|right)panel$/.test(g.position)){g.style.height=(c.offsetHeight+2*h.cb)+"px"}}}if(f){hs.setStyles(this.content,{top:h.p1+"px"});hs.setStyles(c,{top:(h.p1+h.cb)+"px"})}},showOverlays:function(){var a=this.overlayBox;a.className="";hs.setStyles(a,{top:(this.y.p1+this.y.cb)+"px",left:(this.x.p1+this.x.cb)+"px",overflow:"visible"});if(hs.safari){a.style.visibility="visible"}this.wrapper.appendChild(a);for(var c=0;c<this.overlays.length;c++){var d=hs.$("hsId"+this.overlays[c]);d.style.zIndex=d.zIndex||4;if(!d.hideOnMouseOut||this.mouseIsOver){d.style.visibility="visible";hs.setStyles(d,{visibility:"visible",display:""});hs.animate(d,{opacity:d.opacity},d.dur)}}},destroyOverlays:function(){if(!this.overlays.length){return}if(this.slideshow){var d=this.slideshow.controls;if(d&&hs.getExpander(d)==this){d.parentNode.removeChild(d)}}for(var a=0;a<this.overlays.length;a++){var b=hs.$("hsId"+this.overlays[a]);if(b&&b.parentNode==hs.viewport&&hs.getExpander(b)==this){hs.discardElement(b)}}hs.discardElement(this.overlayBox)},createFullExpand:function(){if(this.slideshow&&this.slideshow.controls){this.slideshow.enable("full-expand");return}this.fullExpandLabel=hs.createElement("a",{href:"javascript:hs.expanders["+this.key+"].doFullExpand();",title:hs.lang.fullExpandTitle,className:"highslide-full-expand"});this.createOverlay({overlayId:this.fullExpandLabel,position:hs.fullExpandPosition,hideOnMouseOut:true,opacity:hs.fullExpandOpacity})},doFullExpand:function(){try{if(this.fullExpandLabel){hs.discardElement(this.fullExpandLabel)}this.focus();var b=this.x.size;this.resizeTo(this.x.full,this.y.full);var a=this.x.pos-(this.x.size-b)/2;if(a<hs.marginLeft){a=hs.marginLeft}this.moveTo(a,this.y.pos);this.doShowHide("hidden")}catch(c){this.error(c)}},afterClose:function(){this.a.className=this.a.className.replace("highslide-active-anchor","");this.doShowHide("visible");if(this.outline&&this.outlineWhileAnimating){this.outline.destroy()}hs.discardElement(this.wrapper);this.destroyOverlays();if(!hs.viewport.childNodes.length){hs.viewport.style.display="none"}if(this.dimmingOpacity){hs.undim(this.key)}hs.expanders[this.key]=null;hs.reOrder()}};hs.Slideshow=function(c,b){if(hs.dynamicallyUpdateAnchors!==false){hs.updateAnchors()}this.expKey=c;for(var a in b){this[a]=b[a]}if(this.useControls){this.getControls()}if(this.thumbstrip){this.thumbstrip=hs.Thumbstrip(this)}};hs.Slideshow.prototype={getControls:function(){this.controls=hs.createElement("div",{innerHTML:hs.replaceLang(hs.skin.controls)},null,hs.container);var b=["play","pause","previous","next","move","full-expand","close"];this.btn={};var c=this;for(var a=0;a<b.length;a++){this.btn[b[a]]=hs.getElementByClass(this.controls,"li","highslide-"+b[a]);this.enable(b[a])}this.btn.pause.style.display="none"},checkFirstAndLast:function(){if(this.repeat||!this.controls){return}var c=hs.expanders[this.expKey],b=c.getAnchorIndex(),a=/disabled$/;if(b==0){this.disable("previous")}else{if(a.test(this.btn.previous.getElementsByTagName("a")[0].className)){this.enable("previous")}}if(b+1==hs.anchors.groups[c.slideshowGroup||"none"].length){this.disable("next");this.disable("play")}else{if(a.test(this.btn.next.getElementsByTagName("a")[0].className)){this.enable("next");this.enable("play")}}},enable:function(d){if(!this.btn){return}var c=this,b=this.btn[d].getElementsByTagName("a")[0],e=/disabled$/;b.onclick=function(){c[d]();return false};if(e.test(b.className)){b.className=b.className.replace(e,"")}},disable:function(c){if(!this.btn){return}var b=this.btn[c].getElementsByTagName("a")[0];b.onclick=function(){return false};if(!/disabled$/.test(b.className)){b.className+=" disabled"}},hitSpace:function(){if(this.autoplay){this.pause()}else{this.play()}},play:function(a){if(this.btn){this.btn.play.style.display="none";this.btn.pause.style.display=""}this.autoplay=true;if(!a){hs.next(this.expKey)}},pause:function(){if(this.btn){this.btn.pause.style.display="none";this.btn.play.style.display=""}clearTimeout(this.autoplay);this.autoplay=null},previous:function(){this.pause();hs.previous(this.btn.previous)},next:function(){this.pause();hs.next(this.btn.next)},move:function(){},"full-expand":function(){hs.getExpander().doFullExpand()},close:function(){hs.close(this.btn.close)}};hs.Thumbstrip=function(k){function p(i){hs.extend(f||{},{overlayId:r,hsId:"thumbstrip",className:"highslide-thumbstrip-"+m+"-overlay "+(f.className||"")});if(hs.ieLt7){f.fade=0}i.createOverlay(f);hs.setStyles(r.parentNode,{overflow:"hidden"})}function c(i){d(undefined,Math.round(i*r[h?"offsetWidth":"offsetHeight"]*0.7))}function d(L,M){if(L===undefined){for(var K=0;K<j.length;K++){if(j[K]==hs.expanders[k.expKey].a){L=K;break}}}if(L===undefined){return}var G=r.getElementsByTagName("a"),z=G[L],w=z.parentNode,y=h?"Left":"Top",N=h?"Right":"Bottom",I=h?"Width":"Height",B="offset"+y,H="offset"+I,x=n.parentNode.parentNode[H],F=x-s[H],v=parseInt(s.style[h?"left":"top"])||0,C=v,D=20;if(M!==undefined){C=v-M;if(F>0){F=0}if(C>0){C=0}if(C<F){C=F}}else{for(var K=0;K<G.length;K++){G[K].className=""}z.className="highslide-active-anchor";var J=L>0?G[L-1].parentNode[B]:w[B],A=w[B]+w[H]+(G[L+1]?G[L+1].parentNode[H]:0);if(A>x-v){C=x-A}else{if(J<-v){C=-J}}}var E=w[B]+(w[H]-g[H])/2+C;hs.animate(s,h?{left:C}:{top:C},null,"easeOutQuad");hs.animate(g,h?{left:E}:{top:E},null,"easeOutQuad");l.style.display=C<0?"block":"none";t.style.display=(C>F)?"block":"none"}var j=hs.anchors.groups[hs.expanders[k.expKey].slideshowGroup||"none"],f=k.thumbstrip,m=f.mode||"horizontal",u=(m=="float"),o=u?["div","ul","li","span"]:["table","tbody","tr","td"],h=(m=="horizontal"),r=hs.createElement("div",{className:"highslide-thumbstrip highslide-thumbstrip-"+m,innerHTML:'<div class="highslide-thumbstrip-inner"><'+o[0]+"><"+o[1]+"></"+o[1]+"></"+o[0]+'></div><div class="highslide-scroll-up"><div></div></div><div class="highslide-scroll-down"><div></div></div><div class="highslide-marker"><div></div></div>'},{display:"none"},hs.container),e=r.childNodes,n=e[0],l=e[1],t=e[2],g=e[3],s=n.firstChild,a=r.getElementsByTagName(o[1])[0],b;for(var q=0;q<j.length;q++){if(q==0||!h){b=hs.createElement(o[2],null,null,a)}(function(){var v=j[q],i=hs.createElement(o[3],null,null,b),w=q;hs.createElement("a",{href:v.href,onclick:function(){hs.getExpander(this).focus();return hs.transit(v)},innerHTML:hs.stripItemFormatter?hs.stripItemFormatter(v):v.innerHTML},null,i)})()}if(!u){l.onclick=function(){c(-1)};t.onclick=function(){c(1)};hs.addEventListener(a,document.onmousewheel!==undefined?"mousewheel":"DOMMouseScroll",function(i){var v=0;i=i||window.event;if(i.wheelDelta){v=i.wheelDelta/120;if(hs.opera){v=-v}}else{if(i.detail){v=-i.detail/3}}if(v){c(-v*0.2)}if(i.preventDefault){i.preventDefault()}i.returnValue=false})}return{add:p,selectThumb:d}};hs.langDefaults=hs.lang;var HsExpander=hs.Expander;if(hs.ie&&window==window.top){(function(){try{document.documentElement.doScroll("left")}catch(a){setTimeout(arguments.callee,50);return}hs.ready()})()}hs.addEventListener(document,"DOMContentLoaded",hs.ready);hs.addEventListener(window,"load",hs.ready);hs.addEventListener(document,"ready",function(){if(hs.expandCursor||hs.dimmingOpacity){var c=hs.createElement("style",{type:"text/css"},null,document.getElementsByTagName("HEAD")[0]);function b(e,f){if(!hs.ie){c.appendChild(document.createTextNode(e+" {"+f+"}"))}else{var d=document.styleSheets[document.styleSheets.length-1];if(typeof(d.addRule)=="object"){d.addRule(e,f)}}}function a(d){return"expression( ( ( ignoreMe = document.documentElement."+d+" ? document.documentElement."+d+" : document.body."+d+" ) ) + 'px' );"}if(hs.expandCursor){b(".highslide img","cursor: url("+hs.graphicsDir+hs.expandCursor+"), pointer !important;")}b(".highslide-viewport-size",hs.ie&&(hs.uaVersion<7||document.compatMode=="BackCompat")?"position: absolute; left:"+a("scrollLeft")+"top:"+a("scrollTop")+"width:"+a("clientWidth")+"height:"+a("clientHeight"):"position: fixed; width: 100%; height: 100%; left: 0; top: 0")}});hs.addEventListener(window,"resize",function(){hs.getPageSize();if(hs.viewport){for(var a=0;a<hs.viewport.childNodes.length;a++){var b=hs.viewport.childNodes[a],c=hs.getExpander(b);c.positionOverlay(b);if(b.hsId=="thumbstrip"){c.slideshow.thumbstrip.selectThumb()}}}});hs.addEventListener(document,"mousemove",function(a){hs.mouse={x:a.clientX,y:a.clientY}});hs.addEventListener(document,"mousedown",hs.mouseClickHandler);hs.addEventListener(document,"mouseup",hs.mouseClickHandler);hs.addEventListener(document,"ready",hs.getAnchors);hs.addEventListener(window,"load",hs.preloadImages)};


/* GALLERY SETTINGS */
  hs.graphicsDir = '/js/highslide/graphics/';
  hs.align = 'center';
  hs.transitions = ['expand', 'crossfade'];
  hs.wrapperClassName = 'dark borderless floating-caption';
  hs.outlineType = 'rounded-white';
  hs.fadeInOut = true;
  //hs.numberPosition = 'caption';
  hs.dimmingOpacity = 0.75;

// controlbar
  if (hs.addSlideshow) hs.addSlideshow({
	//slideshowGroup: 'group1',
  	interval: 2500,
  	repeat: false,
  	useControls: true,
  	fixedControls: 'hit',
  	overlayOptions: {
  		opacity: .6,
  		position: 'bottom center',
  		hideOnMouseOut: true
  	}
  });

/* ONE IMAGE SETTINGS */
  //hs_one.graphicsDir = '/js/highslide/graphics/';
  //hs_one.outlineType = 'rounded-white';
  //hs_one.transitions = ['expand', 'crossfade'];
  //hs_one.fadeInOut = true;


function $(id){ return document.getElementById(id); }


function _key(event)	{

if (event) {	 var k = event.keyCode;
	 if(k==0) { k=event.charCode; return false; }
	 if(k==13 && $('loading-box').style.display == 'block')  {		    $('loading-box').style.display = 'none';
		    if (OK==true) remove_func();
		    if (set_focus != '' && set_focus != undefined) {
		    	set_focus.focus();
				if (set_focus!=null && set_focus.className == 'inp_text') set_focus.className = 'inp_text_err';
		    	}
		    return false;
		    }
	 if(k==27) {
		    if ($('loading-box').style.display == 'block') $('loading-box').style.display = 'none';
		    if (set_focus != '' && set_focus != undefined) {		    	set_focus.focus();
				if (set_focus!=null && set_focus.className == 'inp_text') set_focus.className = 'inp_text_err';
		    	}
		   return false;
		   }
}

}


function show_message(text){
	if (text==undefined) text = 'Обработка данных';
	var top = (document.body.scrollTop>0) ? document.body.scrollTop : document.documentElement.scrollTop;
	$('loading-box').style.width = '270px';
	$('loading-box').style.textAlign = 'center';
	$('loading-box').style.display = 'block';
    	$('loading-actions').style.display = 'none';
    	$('loading-actions-confirm').style.display = 'none';
	if (self.screen) $('loading-box').style.top = (parseInt(top,10)+(screen.height/2)-200)+'px';
	else $('loading-box').style.top = (parseInt(top,10)+(document.body.clientHeight/2)-90)+'px';
	$('loading-box').style.left = ((document.body.clientWidth/2)-100)+'px';

	var new_height = $('loading-box').offsetHeight;
	var top = (document.body.scrollTop>0) ? document.body.scrollTop : document.documentElement.scrollTop;
	//var scr_height=0; if (self.screen) scr_height = screen.height
	//else if (self.java) { var jkit = java.awt.Toolkit.getDefaultToolkit(); var scrsize = jkit.getScreenSize(); scr_height = scrsize.height;	}
	//var body_height = (scr_height>0 && document.body.clientHeight>scr_height) ? scr_height-150 : document.body.clientHeight;
	body_height = document.body.clientHeight;
	var new_top = (parseInt(top,10)+(body_height/2)-(new_height/2)-30);
	$('loading-box').style.top = new_top+'px';
	var new_width = $('loading-box').offsetWidth;
   	$('loading-box').style.left = ((document.body.clientWidth/2)-(new_width/2))+'px';

	$('loading-img').style.display = '';
	$('loading-text').innerHTML = text+', пожалуйста подождите...';

}

function close_message(status, text, focus){

    OK = false;
	$('loading-box').style.display = 'block';
	$('loading-box').style.textAlign = 'left';
	$('loading-box').style.left = '0px';
	if (navigator.appName == 'Opera') {
	$('loading-box').style.width = '270px';
	$('loading-box').style.height = '80px';
	}
	else {
	$('loading-box').style.width = 'auto';
	$('loading-box').style.height = 'auto';
	}

   	$('loading-actions').style.display = 'none';
   	$('loading-actions-confirm').style.display = 'none';

	if (status==undefined) {
		$('loading-box').style.display = 'none';
		return false;
		}
	else if (status=='info') {
		$('loading-img').style.display = 'none';
		if (text==undefined) text = 'Информация';
		$('loading-text').innerHTML = '<br /><img class="image" src="/_admincp/_design/img/icons/warning.png" />&nbsp;'+text+'';
	    $('loading-actions').style.display = '';
	} else if (status=='confirm') {
		OK = true;
		$('loading-img').style.display = 'none';
		if (text==undefined) text = 'Информация';
		$('loading-text').innerHTML = '<br />&nbsp;'+text+'';     //<img class="image" src="/_admincp/_design/img/icons/warning.png" />
	    $('loading-actions').style.display = 'none';
	    $('loading-actions-confirm').style.display = '';
	}
	else if (status=='error') {
		$('loading-img').style.display = 'none';
		if (text==undefined) text = 'Произошла ошибка';
		$('loading-text').innerHTML = '<br /><img class="image" src="/_admincp/_design/img/icons/error.png" />&nbsp;'+text+'';
	    $('loading-actions').style.display = '';
	}

	var new_height = $('loading-box').offsetHeight;
	var top = (document.body.scrollTop>0) ? document.body.scrollTop : document.documentElement.scrollTop;
	//var half_screen_height = (screen.height>0) ? (screen.height/2)-parseInt(screen.height/8) : (document.body.clientHeight/2);
	var half_screen_height = document.body.clientHeight/2; 
	$('loading-box').style.top = (parseInt(top,10)+(half_screen_height)-(new_height/2)-30)+'px';

	var new_width = $('loading-box').offsetWidth;
   	$('loading-box').style.left = ((document.body.clientWidth/2)-(new_width/2))+'px';

	if (focus!=undefined && $(focus)!=null) {		set_focus = $(focus);
        	if (set_focus!=null && set_focus.className == 'inp_text') { set_focus.className = 'inp_text_err'; }
		}
	else set_focus = '';
	$('loading-box').focus();

}


// ****************************************** //
// ********* <<<<<<   ФИЛЬТР		   ****** //
// ****************************************** //
function execute_filter(){	var brend = $('brend');
	var catalog1 = $('catalog1');
	var catalog2 = $('catalog2');
	if (brend.value == 0) close_message('info', 'Необходимо выбрать производителя', 'brend');
	else if (catalog1.value == 0) close_message('info', 'Необходимо выбрать категорию товара', 'catalog1');
	else if (brend.value == 'all' && catalog1.value == 'all') close_message('info', 'Необходимо выбрать подкатегорию товара', 'catalog2');
	else document.filter.submit();
}

// ФИЛЬТР - выборка по трем полям
function load_filter(active){

	var brend = $('brend');
	var catalog1 = $('catalog1');
	var catalog2 = $('catalog2');
    var change_select;

	switch(active){
		case 1: catalog1.disabled=true;
				catalog2.disabled=true;
				catalog1.value = 0;
				catalog2.value = 0;
				change_select = catalog1;
				break;
		case 2: catalog2.disabled=true;
				catalog2.value = 0;
				change_select = catalog2;
				break;
		case 3: document.filter.submit(); return true;
	}

   if (active == 1 && brend.value == 0) return true;
   else if (active == 2 && catalog1.value == 0) return true;

	show_message();

	var value1 = brend.value;
	var value2 = catalog1.value;
	var value3 = catalog2.value;

  var req = new JsHttpRequest();
  req.open(null, '/js/_ajax/fetch.php', true);
  var data = { 'brend': value1, 'catalog1': value2, 'catalog2' : value3, 'active_field': active};
  req.send(data);

  req.onreadystatechange = function() {

//	$('debug').innerHTML = req.responseText;

  	if (req.readyState == 4) {

		if (req.responseJS.errors!=''){			if (active == 2) { document.filter.submit(); return true; }
			else { close_message('error', req.responseJS.errors); return true; }		} else {
	 		var massiv = new Array();
		    var keys = new Array();
	 		values = req.responseJS.values;
	 		keys = req.responseJS.keys;

 			///alert(value1+' ::: '+value2+' ::: '+value3); //+' === '+values);

			if (values.length>0) {
				change_select.length = 1;

				if (values.length>1 && (active==1 || (active==2 && (value1!='all' || value2!='all')))) {		 	    	 var option = document.createElement('option');
		     	 	 //option.id = 'all';
	             	 option.value = 'all';
		         	 option.innerHTML = (active==1) ? 'Все категории': 'Все подкатегории';
				 	 change_select.appendChild(option);					}

		        for (i = 0; i<values.length; i++) {
		 	    	 var option = document.createElement('option');
		     	 	 //option.id = 'value_'+i;
	             	 option.value = keys[i];
		         	 option.innerHTML = values[i];
				 	 change_select.appendChild(option);
		       	}
			}

			switch(active){
				case 1: catalog1.disabled=false; break;
				case 2: catalog2.disabled=false; break;
			}

			close_message();
		}

  	}
  }
}

// ****************************************** //
// *********  ФИЛЬТР	>>>>>>>		   ****** //
// ****************************************** //



// ****************************************** //
// **** <<<<<< КОРЗИНА ПОЛЬЗОВАТЕЛЯ    ****** //
// ****************************************** //

function check_basket(){var result = true;
	if ($('empty_shopping_cart')!=null) result = ($('empty_shopping_cart').style.display == '') ? false : true;
	if (result == false) close_message('info', 'Ваша корзина пуста');
return result;}

// добавить позицию в корзину
function add_product(sid, catalog_id, id, price, action) {

  var req = new JsHttpRequest();
	req.open(null, '/js/_ajax/basket/add.php', true);
	var data = { 'sid': sid, 'catalog_id': catalog_id, 'id': id, 'price' : price };
        req.send(data);

	if (action!='купить') show_message('Добавление товара в корзину');

    	req.onreadystatechange = function() {
		if (req.readyState == 4) {
//		alert(req.responseText);

			var quantity = req.responseJS.quantity;
			var total_price = req.responseJS.total_price;

			if (quantity>0) {
				if ($('empty_shopping_cart') != null) $('empty_shopping_cart').style.display = 'none';
				if ($('shopping_cart') != null) $('shopping_cart').style.display = '';
				if ($('quantity') != null) $('quantity').innerHTML = quantity;
				if ($('total_price') != null) $('total_price').innerHTML = total_price;
				if ($('ending') != null) $('ending').innerHTML = req.responseJS.end;
				if ($('basket_'+id) != null) $('basket_'+id).src = '/img/buttons/p10.gif';
			}

			if (action == 'купить') window.location.href='/shopping_cart/';
			else close_message('confirm','Товар добавлен в корзину<br>&nbsp;Приятных, Вам, покупок');

		}

   }
}

// удаление позиции из корзины
function remove_product(sid, id, catalog_id){
  var req = new JsHttpRequest();
	req.open(null, '/js/_ajax/basket/remove.php', true);
	var data = { 'sid': sid, 'id': id, 'catalog_id': catalog_id };
    req.send(data);

    show_message('Удаление товара');

    req.onreadystatechange = function() {
	if (req.readyState == 4) {

        var parent = $('tr_'+id).parentNode.id;
		removeElement(parent,'tr_'+id);
        if ($(parent)) {
        	var parent_table = $(parent).parentNode.id;
        	var trs = $(parent).getElementsByTagName('tr').length;        	if (trs-2 == 0 && parent_table) $(parent_table).style.display = 'none';
        	}

			var quantity = req.responseJS.quantity;
			var total_price = req.responseJS.total_price;

			if (quantity>0) {					var ids = req.responseJS.ids;
					if (ids && $('recount_ids')!=null) $('recount_ids').value = ids;
					//if ($('delivery_type')!=null) var delivery = $('delivery_type').value;
					if ($('t_price')!=null) $('t_price').innerHTML = total_price+' руб.';
					//$('price_delivery').innerHTML = total_price+' руб.';
					$('empty_shopping_cart').style.display = 'none';
					$('shopping_cart').style.display = '';
					if ($('quantity')!=null) $('quantity').innerHTML = quantity;
					if ($('total_price')!=null) $('total_price').innerHTML = total_price;
					if ($('ending')!=null) $('ending').innerHTML = req.responseJS.end;
					//if ($('delivery_type')!=null) choose_delivery_type(delivery);
			}
			else {
					$('empty_shopping_cart').style.display = '';
					$('shopping_cart').style.display = 'none';
					$('whole_basket').innerHTML = '<br>Ваша корзина пуста';
					if ($('order_form')!=null) $('order_form').style.display = 'none';
				}

            close_message();
		}

   }
}
// сообщение об удалении
function remove_message(sid, p_id, c_id, name){
	remove_func = new Function("remove_product('"+sid+"', '"+p_id+"', '"+c_id+"');");
	close_message('confirm','Вы действительно хотите удалить "'+name+'" из корзины?');
}

// пересчитать сумму в корзине
function recount(sid){
  var req = new JsHttpRequest();

  var products = new Array();
  if ($('recount_ids')!=null) products = $('recount_ids').value.split(',');

  if (products.length>0) {  var j = 0, k = 0;
  var values = new Array();
  var products_id = new Array();
  var new_prices = new Array();

  for (i = 0; i<products.length; i++) if ($('quantity_'+products[i])!=null) {
	values[j] = $('quantity_'+products[i]).value;
	products_id[j] = products[i];
	j++;
	}

	req.open(null, '/js/_ajax/basket/recount.php', true);
	var data = { 'sid': sid, 'products_id': products_id, 'values': values };
        req.send(data);

  	show_message('Перерасчет количества товаров и суммы заказа');

	req.onreadystatechange = function(){		//$('debug').innerHTML = req.responseText;
		if (req.readyState == 4) {

				var quantity = req.responseJS.quantity;
				var total_price = req.responseJS.total_price;
				var total_prices = req.responseJS.new_prices;
				var product_prices = req.responseJS.product_prices;
				//if ($('delivery_type')!=null) var delivery = $('delivery_type').value;

				if (quantity>0) {
					if ($('t_price')!=null) $('t_price').innerHTML = total_price+' руб.';
					//$('price_delivery').innerHTML = total_price+' руб.';
					$('empty_shopping_cart').style.display = 'none';
					$('shopping_cart').style.display = '';
					if ($('quantity')!=null) $('quantity').innerHTML = quantity;
					if ($('total_price')!=null) $('total_price').innerHTML = total_price;
					if ($('ending')!=null) $('ending').innerHTML = req.responseJS.end;
					//if (delivery>0) choose_delivery_type(delivery);
					if (products.length>0)
						for (i = 0; i<products.length; i++) if ($('price_'+products[i])!=null && total_prices[k]) {
						if (total_prices[k]>0) $('price_'+products[i]).innerHTML = product_prices[k];
						if ($('summa_'+products[i])!=null) $('summa_'+products[i]).innerHTML = total_prices[k];
						k++;
						}

				}

				close_message();

		}
	 }
   }
}

// проверка на введенное количество
function CheckQuantities(){

	var ids = new Array();
    if ($('recount_ids')!=null) ids = $('recount_ids').value.split(',');

 if (ids.length > 0) {
 	for (var i = 0; i < ids.length; i++) if ($('quantity_'+ids[i])!=null) {

 	    inp = $('quantity_'+ids[i]);
        var value = inp.value;

 		if ((isNaN(parseInt(value, 10)) ) || (parseInt(value,10)<=0)) {
 			close_message('info','Кол-во товара должно быть больше нуля!', 'quantity_'+ids[i]);
 			inp.value = 1;
			return 0;
 			}
	 }
	return 1;
  }
}

// ****************************************** //
// ****** КОРЗИНА ПОЛЬЗОВАТЕЛЯ >>>>>   ****** //
// ****************************************** //



function removeElement(parent_name,child_name) {
  if ($(parent_name) && $(child_name)) {
  var d = $(parent_name);
  var olddiv = $(child_name);
  d.removeChild(olddiv);
  }
}

function choose_delivery_type(name){
   $('form_st_1.1').style.display = 'none';
   $('form_st_1.2').style.display = 'none';
   $('form_st_2.1').style.display = 'none';
   $('form_st_2.2').style.display = 'none';
   $('form_st_3.1').style.display = 'none';
   $('form_st_3.2').style.display = 'none';

   var total_price = $('total_price').innerHTML;
   total_price = total_price - 0;
   if (name == '2.2') total_price = Math.ceil((total_price + 500)*1.087);
   if (name == '3.1') total_price = total_price + 1500;
   if (name == '3.2') total_price = total_price + 4000;

   $('price_delivery').innerHTML = total_price+' руб.';
   $('help').style.display = 'none';
   $('order_title').style.display = '';
   $('form_st_'+name).style.display = '';
   $('delivery_type').value = name;
   $('price_value_'+name).value = total_price;
}






function load_menu(cat_id, type, brend){  	var req = new JsHttpRequest();

	show_message('Построение меню');

	req.open(null, '/js/_ajax/load_menu.php', true);

	var data = { 'cat_id': cat_id, 'type': type, 'brend': brend };
	req.send(data);

	req.onreadystatechange = function() {
		if (req.readyState == 4) {

		if (req.responseText) close_message('error', req.responseText);

		var html = req.responseJS.html;
		var menu = req.responseJS.menu;
		var h1 = req.responseJS.h1;
		var nav_line = req.responseJS.nav_line;
		var meta_title = req.responseJS.meta_title;
		var new_id = req.responseJS.new_id;
		var sort_link = req.responseJS.sort_link;

		if (h1 && $('cat_h1')!=null) {				$('cat_h1').innerHTML = h1;
				//if ($('zakaz')!=null) $('zakaz').style.display = 'none';
				}
				else if ($('zakaz')!=null) $('zakaz').style.display = '';

		$('menu_catalog').innerHTML = (menu) ? menu : '';
		if (html && $('content')!=null) $('content').innerHTML = (html) ? html : '';
		if (nav_line && $('navigation_line')!=null) $('navigation_line').innerHTML = nav_line;
		if ($('sorting')!=null) $('sorting').style.display = (new_id==11) ? 'none' : '';

		if ($('menu_class')!=null && sort_link) {							$('menu_class').className = ($('menu_class').className == 'zag') ? 'zag2' : 'zag';
							$('menu_class').innerHTML = sort_link;
			}

		close_message();

		////// ЗАГОЛОВОК СТРАНИЦЫ
		document.title = meta_title;

		}


	}

}


function load_catalog(cat_id, page){
  	var req = new JsHttpRequest();
  	//var id = (($('catalog_id')!=null)) ? $('catalog_id').innerHTML : 0;
  	var brend = (($('brend_id')!=null)) ? $('brend_id').innerHTML : 0;
	var num_on_page = $('num_on_page').value;
	var sort_by = $('sort_by').value;
	if (page == undefined) page = 1;

	//if (id>0){
	show_message('Загрузка данных');

	req.open(null, '/js/_ajax/load_catalog.php', true);

	var data = {'sort_by': sort_by, 'nums': num_on_page, 'cat_id': cat_id, 'page': page, 'brend': brend };
	req.send(data);

	req.onreadystatechange = function() {
		if (req.readyState == 4) {

		if (req.responseText) close_message('error', req.responseText);

		var html = req.responseJS.html;
		if (html) $('content').innerHTML = (html) ? html : '';
		else close_message('info', 'Данные, не могут быть получены, выберите сначала раздел каталога');

		//deleteCookie("num_on_page", "/")
		//addCookie("num_on_page", num_on_page, 28, "/");
		if (html) close_message();
		}


	//}
    }

}

////////////////////////////////////
// <<<<<ДИНАМ. ИЗМЕН. СОДЕРЖИМОГО //
////////////////////////////////////

function change_content(id, path, parent_name){
	var content = $(parent_name);

	if (content!=null) {

		show_message('Загрузка данных');

	  	var req = new JsHttpRequest();
		req.open(null, '/js/_ajax/change_content.php', true);
		var data = { 'id': id, 'path': path, 'module': parent_name };
    	req.send(data);

		req.onreadystatechange = function() {
//			$('debug').innerHTML = req.responseText;

			if (req.readyState == 4) {

			//**** СОДЕРЖИМОЕ ****//
			var html = req.responseJS.html;
			content.innerHTML = (html) ? html : '';

			//**** ЗАГОЛОВОК СТРАНИЦЫ ****//
			document.title = req.responseJS.MetaTitle;

			//**** НАВИГАЦИОННАЯ ЛИНИЯ ****//
			//var navigationLine = req.responseJS.navigationLine;
			//if (navigationLine && $('navigation')!=null) $('navigation').innerHTML = navigationLine;
			//**** МЕНЮ САЙТА ****//
			//var menu = req.responseJS.menu;
			//if (menu && $('menu')!=null) $('menu').innerHTML = menu;
			close_message();
			}


		}
	} else if (path) location.href = ''+path+'';
}
////////////////////////////////////
// ДИНАМ. ИЗМЕН. СОДЕРЖИМОГО>>>>> //
////////////////////////////////////




// ЗАГРУЗКА НАЧАЛЬНЫХ ПАРАМЕТРОВ
function load_params(id, url){
	cat_id = id;
	func_back[0] = new Function("getData('"+id+"', '"+url+"');");
	current_page = 0;
}



function getData(id, link){
if ($('goback')!=null) {
if ($('goback').style.cursor == '') {
    	$('goback').src = 'js/images/btn_left_on.png';
    	$('goback').style.cursor = 'pointer';
	}
	current_page++;
    func_back[current_page] = new Function("load_body('"+id+"', '"+link+"');");
}

	if (getCookie('ajax') == 'true') { load_body(id, link); return false; }
	else return true;

}

function load_body(id, path){
  	var req = new JsHttpRequest();
  	var div_body = $('main_body');

	show_message('Загрузка данных');

	req.open(null, '/js/_ajax/load_body.php', true);
	var data = { 'id': id, 'path': path };
    req.send(data);

	req.onreadystatechange = function() {
		if (req.readyState == 4) {

		//$('debug').innerHTML = req.responseText;

		var html = req.responseJS.html;
		var category = req.responseJS.category;
		var MetaTitle = req.responseJS.MetaTitle;
		var navigationLine = req.responseJS.navigationLine;
		var menu = req.responseJS.menu;
		div_body.innerHTML = (html) ? html : '';
		if (category == 'true') {
		////// ВЫДЕЛЕНИЕ ТЕКУЩЕЙ ДИРЕКТОРИИ
		if ($('cat_'+id) != null) $('cat_'+id).className = 'hov';
		if (!before_id && $('cat_'+cat_id) != null && id!=cat_id) $('cat_'+cat_id).className = '';
		if ($('cat_'+before_id) != null && id!=before_id) $('cat_'+before_id).className = '';
		} else {
			//alert('модули');
		}
		////// ЗАГОЛОВОК СТРАНИЦЫ
		document.title = MetaTitle;
		////// НАВИГАЦИОННАЯ ЛИНИЯ
		if (navigationLine && $('navigation')!=null) $('navigation').innerHTML = navigationLine;
		///// МЕНЮ САЙТА
		if (menu && $('menu')!=null) $('menu').innerHTML = menu;

		before_id = id;
		close_message();
		}


	}


}


function menu(id){
if ($('img_'+id)!=null && $('menu_'+id)!=null){
	var img = $('img_'+id);
	var menu = $('menu_'+id);

	img.src = (/p7.gif/.test(img.src)) ? 'img/p6.gif' : 'img/p7.gif';
	menu.className = (menu.className == 'open') ? 'close' : 'open';

   // get_menu();}

}


function get_menu(){
	var p_ids = new Array(); var j = 0;

	thisCheckBoxes = $('menu_catalog').getElementsByTagName('div');
			for (i = 1; i < thisCheckBoxes.length; i++)
				if (thisCheckBoxes[i].className == 'open') {
	 				  j++;
                      p_ids[j] = thisCheckBoxes[i].id.substring(5);
				}
        if (p_ids.length>0) {
              for (i = 1; i < p_ids.length; i++)  alert(p_ids[i]);
        }

}


function check_all(e,Name,cookie_name,action,group){
		thisCheckBoxes = e.parentNode.parentNode.parentNode.getElementsByTagName('input');
		var add_values = ''; var del_values = '';
		for (i = 1; i < thisCheckBoxes.length; i++)
			if (thisCheckBoxes[i].name == Name){
				thisCheckBoxes[i].checked = e.checked;
				if (thisCheckBoxes[i].checked==true) add_values += thisCheckBoxes[i].value+',';
				else del_values += thisCheckBoxes[i].value+',';
			}

	if (action == 'save' && cookie_name!=undefined) {		if (group!=undefined) resetCookie(cookie_name,group);		if (add_values) saveCookieValues(cookie_name, add_values.substring(0,add_values.length-1), 1);
		if (del_values) delCookieValues(cookie_name, del_values.substring(0,del_values.length-1), 1);	}
}


function check_one(e,cookie_name,action,group){
	//if ($(e.id.replace('chb','str'))) {e.checked = !e.checked;}
	if (action == 'save' && cookie_name!=undefined){		if (group!=undefined) resetCookie(cookie_name,group);		if (e.checked == true) saveCookieValues(cookie_name, e.value, 1);
		else delCookieValues(cookie_name, e.value, 1);
	}
}



function compare_checked(){	var p_ids = new Array();
	var result = false;

    var compare = getCookie('compare');
    if (compare != null && compare != '') var p_ids = compare.split(',');

    if (p_ids.length>1) result = true;
    else if (p_ids.length==1) close_message('info', 'Для того чтобы сравнить, необходимо выбрать не менее двух товаров!');
    else close_message('info', 'Отметьте позиции, которые Вы хотите сравнить!');

return result;
}



////////////////////////////
// <<<<< РАБОТА С COOKIE  //
////////////////////////////
function addCookie(szName,szValue,dtDaysExpires,cPath)
{
   var dtExpires = new Date();
   var dtExpiryDate = "";

   dtExpires.setTime(dtExpires.getTime() + dtDaysExpires * 24 * 60 * 60 * 1000);
   dtExpiryDate = dtExpires.toGMTString();
   document.cookie = szName + "=" + szValue + "; path=" +cPath+ "; expires=" + dtExpiryDate;
}

function getCookie(name) {
        var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1) return null
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
        if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

function deleteCookie(name, path, domain) {		if (path==undefined) path = '/';
        if (getCookie(name)) {
                document.cookie = name + "=" +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                "; expires=Thu, 01-Jan-70 00:00:01 GMT"
	}
}

function saveCookieValues(cookie_name, new_values, period, path){
        if (!new_values) return false;
        if (period==undefined) period = 1;
        if (path==undefined) path = '/';

        var checked_values = {};
  		var cookie_value = getCookie(cookie_name);
        if (cookie_value == null || cookie_value == '') addCookie(cookie_name, new_values, period, path);
        else {
            var values = (cookie_value+','+new_values).split(',');
            var save_values = '';
         	if (values.length > 0) for (var i=0; i<values.length; i++) if (values[i]>0 && !checked_values['id'+values[i]]) {
					save_values += values[i]+',';
					checked_values['id'+values[i]] = 1;
         			}
         if (save_values) {
         	save_values = save_values.substring(0,save_values.length-1);
         	addCookie(cookie_name, save_values, period, path);
         	}
		}
}

function delCookieValues(cookie_name, del_values, period, path){
        if (!del_values) return false;
        if (period==undefined) period = 1;
        if (path==undefined) path = '/';

        var checked_values = {};
  		var cookie_value = getCookie(cookie_name);

        if (cookie_value != null && cookie_value != '') {        	del_values = del_values.split(',');
        	if (del_values.length>0) for (var i=0; i<del_values.length; i++) checked_values['id'+del_values[i]] = 1;

            var values = cookie_value.split(',');
            var save_values = '';
         	if (values.length > 0) for (var i=0; i<values.length; i++) if (values[i]>0 && !checked_values['id'+values[i]]) {
					save_values += values[i]+',';
					checked_values['id'+values[i]] = 1;
         			}
     	if (save_values) save_values = save_values.substring(0,save_values.length-1);
       	addCookie(cookie_name, save_values, period, path);
		}
}

function resetCookie(cookie_name,group,period, path){	if (group==undefined) return false;
    if (period==undefined) period = 1;
    if (path==undefined) path = '/';

	var value = getCookie(cookie_name+'_group');
	//alert(value + ' == ' + group);
	if (value!=null && value!=group) {		addCookie(cookie_name,'',period,path);
	}
	addCookie(cookie_name+'_group',group,period,path);


}
////////////////////////////
// РАБОТА С COOKIE >>>>>> //
////////////////////////////



// УДАЛЕНИЕ ФАЙЛА
function delete_photo(name, dir){
	remove_func = new Function("remove_photo('"+name+"', '"+dir+"');");
	close_message('confirm','Вы действительно хотите удалить файл?');
}

function remove_photo(name, dir) {
	var req = new JsHttpRequest();
	req.open(null, '/js/_ajax/remove_photo.php', true);

	var data = { 'name': name, 'dir': dir};
        req.send(data);

		show_message('Удаление файла');

    req.onreadystatechange = function() {
		if (req.readyState == 4) {

		var status = req.responseJS.status;
		if (status == true) {
			//$('avatar_image_yes').style.display = 'none';
			$('avatar_image').innerHTML = 'Аватaр удален';
			close_message('info','Файл успешно удален');
			return true;
		} else {
			close_message('error','Невозможно удалить файл, <a href="/box/error_message/__user__edit__/" rel="gb_page_center[600, 320]" title="Форма отправки сообщений">Написать администратору</a>');
			return false;
		}


			close_message();
		}
    }
}





// ***************************************** //
// *****  <<<<<< Работа с формами   ******** //
// ***************************************** //
var errs = new Array();
var ie=document.all
var ns6=document.getElementById&&!document.all

function imgFormClick (el,val) {
	if ((ie||ns6) && $(el)) {
	rad_value = $(el).value;

	if (val > 0) new_value = val;
	else if (val == 'x') new_value = rad_value;
	else new_value = rad_value == 1? '2': '1';

	new_text_value = '';

	var path=$(el+'_img').src;
	var regexp =/_.\./g;
	path = path.replace(regexp,'_'+new_value+'.');
	$(el+'_img').src=path;
	$(el+'_img').alt = new_text_value;
	$(el).value = new_value;
	}
}

function FormCheckInt (el,id,showerr,elfocus,errmsg) {
	if ((ie||ns6) && el && $('f'+id)) {
	value = el.value;
	if (!(/^(\d{1,3})$/.test(value))) {
		el.className = 'inp_text_err';
		errs[id] = 1;
		if (showerr == 1) {
			$('f'+id).innerHTML = errmsg;
		}
		if (elfocus == 1) {
			el.focus();
		}
	}
	else if ((errs[id] == 1 && errmsg.toLowerCase() == $('f'+id).innerHTML.toLowerCase()) || !errs[id]) {

		$('f'+id).innerHTML = '';
		el.className = 'inp_text_hover';
		errs[id] = 0;
		if (elfocus == 1) {
			el.focus();
		}
	}
	}
}

function change_class(e){
 if (e!=null && e.value!='') e.className = 'inp_text';
}

function FormCheckEmail(id, user_id){
    var e = $(id);
	if (e!=null) {
		if (e.value=='') close_message('error', 'Необходимо ввести email адрес', e.id);
		else if (/^[\w\-\.]{2,32}\@[\w\-\.]+\.[a-zA-Z0-9]{2,5}$/i.test(e.value)==false) close_message('error', 'Некорректно введен email адрес', e.id);
		else if (FormCheckLogin(e, 'Email', user_id, 'Необходимо ввести email адрес', 'Введенный email адрес уже существует')) return true;
    } else close_message('error', 'Неверно указан елемент');

return false;
}


function FormCheckLogin(e, name, user_id, errtext1, errtext2) {

	var value = e.value;
	if (value=='') { close_message('error', errtext1, e.id); return false; }
	else {
	if (name=='Name' && $('Email').type == 'text'){
			 if (/^[\w-\.]{2,64}$/i.test(value)==false) { close_message('error', 'Некорректно введено имя пользователя', e.id); return false;}
			 else if (/admin|root|support/i.test(value)==true) { close_message('error', 'В имени пользователя найдены запрещенные слова, попробуйте другой логин', e.id); return false;}
			 }

	  var req = new JsHttpRequest();
		req.open(null, '/js/_ajax/check_regname.php', true);
		var data = { 'Name': name, 'Value': value, 'UserID': user_id };
	    	req.send(data);

	    	req.onreadystatechange = function() {
				if (req.readyState == 4) if (req.responseJS.status>0) close_message('error', errtext2, e.id);
	    	}

	 	}

}



function FormCheckName (el,id,showerr,elfocus,errmsg) {
	if ((ie||ns6) && el && $('f'+id)) {
	value = el.value;
	if (/[\||\'|\<|\>|\"|\!|\$|\@|\&\~\*\+]/.test(value)) {
		el.className = 'inp_text_err';
		errs[id] = 1;
		if (showerr == 1) {
			$('f'+id).innerHTML = errmsg;
		}
		if (elfocus == 1) {
			el.focus();
		}
	}
	else if ((errs[id] == 1 && errmsg.toLowerCase() == $('f'+id).innerHTML.toLowerCase()) || !errs[id]) {

		$('f'+id).innerHTML = '';
		el.className = 'inp_text_hover';
		errs[id] = 0;
		if (elfocus == 1) {
			el.focus();
		}
	}
	}
}

function FormCheckEmpty (el,id,len,showerr,elfocus,errmsg) {
	if ((ie||ns6) && el && $('f'+id)) {
	value = el.value;
	if (el.value.replace(/ /gi,"").length < len) {
		el.className = 'inp_text_err';
		errs[id] = 1;
		if (showerr == 1) {
			$('f'+id).innerHTML = errmsg;
		}
		if (elfocus == 1) {
			el.focus();
		}
	}
	else if ((errs[id] == 1 && errmsg.toLowerCase() == $('f'+id).innerHTML.toLowerCase()) || !errs[id]) {
		$('f'+id).innerHTML = '';
		el.className = 'inp_text_hover';
		errs[id] = 0;
		if (elfocus == 1) {
			el.focus();
		}
	}
	}
}


function CheckForm ( type, el, id, showerr, elfocus, errmsg )
{
	if (type==undefined||type==null) type = 'empty';
    alert(type[0]);
	if ((ie||ns6)&&el)
	{
		var value=el.value.trim();
		var regexp=null;

		switch (type)
		{
			case 'int':
			 regexp = /^(\d{1,3})$/;
			 break;
		}
	}
}

function check_form_errors(form_id){var t = eval('checkFields_'+form_id);
var mas = (t) ? t : null;
if (!mas) return false;

for (var i in mas)
	if ($('fields'+i)){		var fname = ($('fname'+i)) ? ' "'+$('fname'+i).innerHTML+'"' : '';
		var value = $('fields'+i).value; 
			if ((value == '' || value == 0) && mas[i] == 1) {				if ($('fields'+i).type == 'text') close_message('error', 'Необходимо заполнить поле'+fname, 'fields'+i);
				else close_message('error', 'Необходимо выбрать значение в поле'+fname, 'fields'+i);
				return false;
			} else if (/e-?mail|ема[и|й]л|электро(нная\ )?почта/i.test(fname) && /^[\w\-\.]+\@[\w\-\.]+\.[a-z]{2,5}$/i.test(value)==false && ((value.length>0 && mas[i] == 0) || mas[i] == 1)) {
				close_message('error', 'Некорректно введен email адрес', 'fields'+i);
				return false;
			} else if (/телефон|мобильный|сотовый|phone|mobile/i.test(fname) && /^[\d\-\(\)\ \.\,\+]{4,}$/i.test(value)==false && ((value.length>0 && mas[i] == 0) || mas[i] == 1)) {
				close_message('error', 'Некорректно введен '+fname, 'fields'+i);
				return false;
			}
	}

return true;}

function send_form_data(form_id){
if (check_form_errors(form_id) == false) return false;
else {
	var fdata = $('form_data'+form_id);
	var fields_value = new Array(fdata.length);
	for (var i=0; i<fdata.length; i++) fields_value[fdata.elements[i].name] = fdata.elements[i];

  		var req = new JsHttpRequest();
		req.open(null, '/js/_ajax/messages/send_form_data.php', true);
		var data = { 'form_id': form_id, 'data': fields_value, 'back_link' : eval('back_link'+form_id) };
        req.send(data);

		show_message('Отправление данных');

    	req.onreadystatechange = function() {
		//$('debug').innerHTML = req.responseText;

		  if (req.readyState == 4) {

		  var message = req.responseJS.result;
		  var errors = req.responseJS.errors;
          var focus = req.responseJS.focus;

            if (errors != '') close_message('error', errors, focus);
            else {
		        if (message) {
		        	close_message('info', message);
		        	$('form_data'+form_id).reset();
		        	reImg('iCodeForm'+form_id);
					//for (var i=0; i<fdata.length; i++) fdata.elements[i].value = '';
		        }
				else close_message();
            }

		   }
		}

}
}


function reImg(id){
	if ($(id)==null) return false;
	var ndate = new Date().getTime();
	$(id).src = "inc/Modules/antibot.php?" + ndate;
}


// ***************************************** //
// ******* Работа с формами >>>>>>> ******** //
// ***************************************** //

function print_page(){
	if (typeof(window.print) != undefined) {
	    window.print();
	}
}



/* ЗАГРУЗИТЬ КАРТИНКУ */
function Preload(imgObj,imgSrc) {
        if (document.images) {
                eval(imgObj+' = new Image()')
                eval(imgObj+'.src = "'+imgSrc+'"')
        }
}
