/* pngfix */
function is_ie6(){return ((window.XMLHttpRequest == undefined) && (ActiveXObject != undefined));} if (is_ie6()) { var DD_belatedPNG={ns:"DD_belatedPNG",imgSize:{},delay:10,nodesFixed:0,createVmlNameSpace:function(){document.namespaces&&!document.namespaces[this.ns]&&document.namespaces.add(this.ns,"urn:schemas-microsoft-com:vml")},createVmlStyleSheet:function(){var a;a=document.createElement("style");a.setAttribute("media","screen");document.documentElement.firstChild.insertBefore(a,document.documentElement.firstChild.firstChild);if(a.styleSheet){a=a.styleSheet;a.addRule(this.ns+"\\:*","{behavior:url(#default#VML)}"); a.addRule(this.ns+"\\:shape","position:absolute;");a.addRule("img."+this.ns+"_sizeFinder","behavior:none; border:none; position:absolute; z-index:-1; top:-10000px; visibility:hidden;");this.screenStyleSheet=a;a=document.createElement("style");a.setAttribute("media","print");document.documentElement.firstChild.insertBefore(a,document.documentElement.firstChild.firstChild);a=a.styleSheet;a.addRule(this.ns+"\\:*","{display: none !important;}");a.addRule("img."+this.ns+"_sizeFinder","{display: none !important;}")}}, readPropertyChange:function(){var a,c,b;a=event.srcElement;if(a.vmlInitiated){if(event.propertyName.search("background")!=-1||event.propertyName.search("border")!=-1)DD_belatedPNG.applyVML(a);if(event.propertyName=="style.display"){c=a.currentStyle.display=="none"?"none":"block";for(b in a.vml)if(a.vml.hasOwnProperty(b))a.vml[b].shape.style.display=c}event.propertyName.search("filter")!=-1&&DD_belatedPNG.vmlOpacity(a)}},vmlOpacity:function(a){if(a.currentStyle.filter.search("lpha")!=-1){var c=a.currentStyle.filter; c=parseInt(c.substring(c.lastIndexOf("=")+1,c.lastIndexOf(")")),10)/100;a.vml.color.shape.style.filter=a.currentStyle.filter;a.vml.image.fill.opacity=c}},handlePseudoHover:function(a){setTimeout(function(){DD_belatedPNG.applyVML(a)},1)},fix:function(a){if(this.screenStyleSheet){var c;a=a.split(",");for(c=0;c<a.length;c++)this.screenStyleSheet.addRule(a[c],"behavior:expression(DD_belatedPNG.fixPng(this))")}},applyVML:function(a){a.runtimeStyle.cssText="";this.vmlFill(a);this.vmlOffsets(a);this.vmlOpacity(a); a.isImg&&this.copyImageBorders(a)},attachHandlers:function(a){var c,b,e,d,f;c=this;b={resize:"vmlOffsets",move:"vmlOffsets"};if(a.nodeName=="A"){e={mouseleave:"handlePseudoHover",mouseenter:"handlePseudoHover",focus:"handlePseudoHover",blur:"handlePseudoHover"};for(d in e)if(e.hasOwnProperty(d))b[d]=e[d]}for(f in b)if(b.hasOwnProperty(f)){e=function(){c[b[f]](a)};a.attachEvent("on"+f,e)}a.attachEvent("onpropertychange",this.readPropertyChange)},giveLayout:function(a){a.style.zoom=1;if(a.currentStyle.position== "static")a.style.position="relative"},copyImageBorders:function(a){var c,b;c={borderStyle:true,borderWidth:true,borderColor:true};for(b in c)if(c.hasOwnProperty(b))a.vml.color.shape.style[b]=a.currentStyle[b]},vmlFill:function(a){if(a.currentStyle){var c,b,e,d;c=a.currentStyle;for(b in a.vml)if(a.vml.hasOwnProperty(b))a.vml[b].shape.style.zIndex=c.zIndex;a.runtimeStyle.backgroundColor="";a.runtimeStyle.backgroundImage="";b=true;if(c.backgroundImage!="none"||a.isImg){if(a.isImg)a.vmlBg=a.src;else{a.vmlBg= c.backgroundImage;a.vmlBg=a.vmlBg.substr(5,a.vmlBg.lastIndexOf('")')-5)}e=this;if(!e.imgSize[a.vmlBg]){b=document.createElement("img");e.imgSize[a.vmlBg]=b;b.className=e.ns+"_sizeFinder";b.runtimeStyle.cssText="behavior:none; position:absolute; left:-10000px; top:-10000px; border:none; margin:0; padding:0;";d=function(){this.width=this.offsetWidth;this.height=this.offsetHeight;e.vmlOffsets(a)};b.attachEvent("onload",d);b.src=a.vmlBg;b.removeAttribute("width");b.removeAttribute("height");document.body.insertBefore(b, document.body.firstChild)}a.vml.image.fill.src=a.vmlBg;b=false}a.vml.image.fill.on=!b;a.vml.image.fill.color="none";a.vml.color.shape.style.backgroundColor=c.backgroundColor;a.runtimeStyle.backgroundImage="none";a.runtimeStyle.backgroundColor="transparent"}},vmlOffsets:function(a){var c,b,e,d,f,h;c=a.currentStyle;b={W:a.clientWidth+1,H:a.clientHeight+1,w:this.imgSize[a.vmlBg].width,h:this.imgSize[a.vmlBg].height,L:a.offsetLeft,T:a.offsetTop,bLW:a.clientLeft,bTW:a.clientTop};e=b.L+b.bLW==1?1:0;d=function(g, l,m,i,j,k){g.coordsize=i+","+j;g.coordorigin=k+","+k;g.path="m0,0l"+i+",0l"+i+","+j+"l0,"+j+" xe";g.style.width=i+"px";g.style.height=j+"px";g.style.left=l+"px";g.style.top=m+"px"};d(a.vml.color.shape,b.L+(a.isImg?0:b.bLW),b.T+(a.isImg?0:b.bTW),b.W-1,b.H-1,0);d(a.vml.image.shape,b.L+b.bLW,b.T+b.bTW,b.W,b.H,1);d={X:0,Y:0};if(a.isImg){d.X=parseInt(c.paddingLeft,10)+1;d.Y=parseInt(c.paddingTop,10)+1}else for(f in d)d.hasOwnProperty(f)&&this.figurePercentage(d,b,f,c["backgroundPosition"+f]);a.vml.image.fill.position= d.X/b.W+","+d.Y/b.H;f=c.backgroundRepeat;h={T:1,R:b.W+e,B:b.H,L:1+e};c={X:{b1:"L",b2:"R",d:"W"},Y:{b1:"T",b2:"B",d:"H"}};if(f!="repeat"||a.isImg){d={T:d.Y,R:d.X+b.w,B:d.Y+b.h,L:d.X};if(f.search("repeat-")!=-1){f=f.split("repeat-")[1].toUpperCase();d[c[f].b1]=1;d[c[f].b2]=b[c[f].d]}if(d.B>b.H)d.B=b.H;a.vml.image.shape.style.clip="rect("+d.T+"px "+(d.R+e)+"px "+d.B+"px "+(d.L+e)+"px)"}else a.vml.image.shape.style.clip="rect("+h.T+"px "+h.R+"px "+h.B+"px "+h.L+"px)"},figurePercentage:function(a,c,b, e){var d,f;f=true;d=b=="X";switch(e){case "left":case "top":a[b]=0;break;case "center":a[b]=0.5;break;case "right":case "bottom":a[b]=1;break;default:if(e.search("%")!=-1)a[b]=parseInt(e,10)/100;else f=false}a[b]=Math.ceil(f?c[d?"W":"H"]*a[b]-c[d?"w":"h"]*a[b]:parseInt(e,10));a[b]%2===0&&a[b]++;return a[b]},fixPng:function(a){a.style.behavior="none";var c,b,e,d,f;if(!(a.nodeName=="BODY"||a.nodeName=="TD"||a.nodeName=="TR")){a.isImg=false;if(a.nodeName=="IMG")if(a.src.toLowerCase().search(/\.png$/)!= -1){a.isImg=true;a.style.visibility="hidden"}else return;else if(a.currentStyle.backgroundImage.toLowerCase().search(".png")==-1)return;c=DD_belatedPNG;a.vml={color:{},image:{}};b={shape:{},fill:{}};for(d in a.vml)if(a.vml.hasOwnProperty(d)){for(f in b)if(b.hasOwnProperty(f)){e=c.ns+":"+f;a.vml[d][f]=document.createElement(e)}a.vml[d].shape.stroked=false;a.vml[d].shape.appendChild(a.vml[d].fill);a.parentNode.insertBefore(a.vml[d].shape,a)}a.vml.image.shape.fillcolor="none";a.vml.image.fill.type="tile"; a.vml.color.fill.on=false;c.attachHandlers(a);c.giveLayout(a);c.giveLayout(a.offsetParent);a.vmlInitiated=true;c.applyVML(a)}}};try{document.execCommand("BackgroundImageCache",false,true)}catch(r){}DD_belatedPNG.createVmlNameSpace();DD_belatedPNG.createVmlStyleSheet(); }
/* jcarousellite */
(function($){$.fn.jCarouselLite=function(o){o=$.extend({btnPrev:null,btnNext:null,btnGo:null,mouseWheel:false,auto:null,speed:200,easing:null,vertical:false,circular:true,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null},o||{});return this.each(function(){var b=false,animCss=o.vertical?"top":"left",sizeCss=o.vertical?"height":"width";var c=$(this),ul=$("ul",c),tLi=$("li",ul),tl=tLi.size(),v=o.visible;if(o.circular){ul.prepend(tLi.slice(tl-v-1+1).clone()).append(tLi.slice(0,v).clone());o.start+=v}var f=$("li",ul),itemLength=f.size(),curr=o.start;c.css("visibility","visible");f.css({overflow:"hidden",float:o.vertical?"none":"left"});ul.css({margin:"0",padding:"0",position:"relative","list-style-type":"none","z-index":"1"});c.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"});var g=o.vertical?height(f):width(f);var h=g*itemLength;var j=g*v;f.css({width:f.width(),height:f.height()});ul.css(sizeCss,h+"px").css(animCss,-(curr*g));c.css(sizeCss,j+"px");if(o.btnPrev)$(o.btnPrev).click(function(){return go(curr-o.scroll)});if(o.btnNext)$(o.btnNext).click(function(){return go(curr+o.scroll)});if(o.btnGo)$.each(o.btnGo,function(i,a){$(a).click(function(){return go(o.circular?o.visible+i:i)})});if(o.mouseWheel&&c.mousewheel)c.mousewheel(function(e,d){return d>0?go(curr-o.scroll):go(curr+o.scroll)});if(o.auto)setInterval(function(){go(curr+o.scroll)},o.auto+o.speed);function vis(){return f.slice(curr).slice(0,v)};function go(a){if(!b){if(o.beforeStart)o.beforeStart.call(this,vis());if(o.circular){if(a<=o.start-v-1){ul.css(animCss,-((itemLength-(v*2))*g)+"px");curr=a==o.start-v-1?itemLength-(v*2)-1:itemLength-(v*2)-o.scroll}else if(a>=itemLength-v+1){ul.css(animCss,-((v)*g)+"px");curr=a==itemLength-v+1?v+1:v+o.scroll}else curr=a}else{if(a<0||a>itemLength-v)return;else curr=a}b=true;ul.animate(animCss=="left"?{left:-(curr*g)}:{top:-(curr*g)},o.speed,o.easing,function(){if(o.afterEnd)o.aftsherEnd.call(this,vis());b=false});if(!o.circular){$(o.btnPrev+","+o.btnNext).removeClass("disabled");$((curr-o.scroll<0&&o.btnPrev)||(curr+o.scroll>itemLength-v&&o.btnNext)||[]).addClass("disabled")}}return false}})};function css(a,b){return parseInt($.css(a[0],b))||0};function width(a){return a[0].offsetWidth+css(a,'marginLeft')+css(a,'marginRight')};function height(a){return a[0].offsetHeight+css(a,'marginTop')+css(a,'marginBottom')}})(jQuery);
/* jlitebox */
(function(b){b.fn.lightBox=function(a){function o(){b("body").append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><b class="tl"></b><b class="tr"></b><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+a.imageLoading+'"></a></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="'+ a.imageBtnClose+'"></a></div></div></div><b class="bl"></b><b class="br"></b></div></div>');var c=j();b("#jquery-overlay").css({backgroundColor:a.overlayBgColor,opacity:a.overlayOpacity,width:c[0],height:c[1]}).fadeIn();var d=k();b("#jquery-lightbox").css({top:d[1]+c[3]/10,left:d[0]}).show();b("#jquery-overlay,#jquery-lightbox").click(function(){i()});b("#lightbox-loading-link,#lightbox-secNav-btnClose").click(function(){i();return false});b(window).resize(function(){var e=j();b("#jquery-overlay").css({width:e[0], height:e[1]});var f=k();b("#jquery-lightbox").css({top:f[1]+e[3]/10,left:f[0]})}); $.fn.rsz = function(){var e=j();b("#jquery-overlay").css({width:e[0], height:e[1]});var f=k();b("#jquery-lightbox").css({top:f[1]+e[3]/10,left:f[0]})}  }function g(){b("#lightbox-loading").show();a.fixedNavigation?b("#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber").hide():b("#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber").hide();var c=new Image;c.onload=function(){b("#lightbox-image").attr("src",a.imageArray[a.activeImage][0]); p(c.width,c.height);c.onload=function(){}};c.src=a.imageArray[a.activeImage][0]}function p(c,d){var e=b("#lightbox-container-image-box").width(),f=b("#lightbox-container-image-box").height(),l=c+a.containerBorderSize*2,m=d+a.containerBorderSize*2;e=e-l;f=f-m;b("#lightbox-container-image-box").animate({width:l,height:m},a.containerResizeSpeed,function(){q()});if(e==0&&f==0)b.browser.msie?n(250):n(100);b("#lightbox-container-image-data-box").css({width:c});b("#lightbox-nav-btnPrev,#lightbox-nav-btnNext").css({height:d+ a.containerBorderSize*2})}function q(){b("#lightbox-loading").hide().rsz();b("#lightbox-image").fadeIn(function(){b("#lightbox-container-image-data-box").slideDown("fast");b("#lightbox-image-details-caption").hide();a.imageArray[a.activeImage][1]&&b("#lightbox-image-details-caption").html(a.imageArray[a.activeImage][1]).show();a.imageArray.length>1&&b("#lightbox-image-details-currentNumber").html(a.txtImage+" "+(a.activeImage+1)+" "+a.txtOf+" "+a.imageArray.length).show();r()});if(a.imageArray.length-1> a.activeImage){objNext=new Image;objNext.src=a.imageArray[a.activeImage+1][0]}if(a.activeImage>0){objPrev=new Image;objPrev.src=a.imageArray[a.activeImage-1][0]}}function r(){b("#lightbox-nav").show();b("#lightbox-nav-btnPrev,#lightbox-nav-btnNext").css({background:"transparent url("+a.imageBlank+") no-repeat"});if(a.activeImage!=0)a.fixedNavigation?b("#lightbox-nav-btnPrev").css({background:"url("+a.imageBtnPrev+") left 15% no-repeat"}).unbind().bind("click",function(){a.activeImage-=1;g();return false}): b("#lightbox-nav-btnPrev").unbind().hover(function(){b(this).css({background:"url("+a.imageBtnPrev+") left 15% no-repeat"})},function(){b(this).css({background:"transparent url("+a.imageBlank+") no-repeat"})}).show().bind("click",function(){a.activeImage-=1;g();return false});if(a.activeImage!=a.imageArray.length-1)a.fixedNavigation?b("#lightbox-nav-btnNext").css({background:"url("+a.imageBtnNext+") right 15% no-repeat"}).unbind().bind("click",function(){a.activeImage+=1;g();return false}):b("#lightbox-nav-btnNext").unbind().hover(function(){b(this).css({background:"url("+ a.imageBtnNext+") right 15% no-repeat"})},function(){b(this).css({background:"transparent url("+a.imageBlank+") no-repeat"})}).show().bind("click",function(){a.activeImage+=1;g();return false});s()}function s(){b(document).keydown(function(c){if(c==null){keycode=event.keyCode;escapeKey=27}else{keycode=c.keyCode;escapeKey=c.DOM_VK_ESCAPE}key=String.fromCharCode(keycode).toLowerCase();if(key==a.keyToClose||key=="x"||keycode==escapeKey)i();if(key==a.keyToPrev||keycode==37)if(a.activeImage!=0){a.activeImage-= 1;g();b(document).unbind()}if(key==a.keyToNext||keycode==39)if(a.activeImage!=a.imageArray.length-1){a.activeImage+=1;g();b(document).unbind()}})}function i(){b("#jquery-lightbox").remove();b("#jquery-overlay").fadeOut(function(){b("#jquery-overlay").remove()});b("embed, object, select").css({visibility:"visible"})}function j(){var c,d;if(window.innerHeight&&window.scrollMaxY){c=window.innerWidth+window.scrollMaxX;d=window.innerHeight+window.scrollMaxY}else if(document.body.scrollHeight>document.body.offsetHeight){c= document.body.scrollWidth;d=document.body.scrollHeight}else{c=document.body.offsetWidth;d=document.body.offsetHeight}var e,f;if(self.innerHeight){e=document.documentElement.clientWidth?document.documentElement.clientWidth:self.innerWidth;f=self.innerHeight}else if(document.documentElement&&document.documentElement.clientHeight){e=document.documentElement.clientWidth;f=document.documentElement.clientHeight}else if(document.body){e=document.body.clientWidth;f=document.body.clientHeight}pageHeight=d< f?f:d;pageWidth=c<e?c:e;return arrayPageSize=[pageWidth,pageHeight,e,f]}function k(){var c,d;if(self.pageYOffset){d=self.pageYOffset;c=self.pageXOffset}else if(document.documentElement&&document.documentElement.scrollTop){d=document.documentElement.scrollTop;c=document.documentElement.scrollLeft}else if(document.body){d=document.body.scrollTop;c=document.body.scrollLeft}return arrayPageScroll=[c,d]}function n(c){var d=new Date;do var e=new Date;while(e-d<c)}a=jQuery.extend({overlayBgColor:"#000", overlayOpacity:0.8,fixedNavigation:false,imageLoading:"i/lightbox-loading.gif",imageBtnPrev:"lightbox-btn-prev.gif",imageBtnNext:"i/lightbox-next.gif",imageBtnClose:"i/lightbox-close.png",imageBlank:"i/images/lightbox-blank.gif",containerBorderSize:0,containerResizeSpeed:400,txtImage:"\u0424\u043e\u0442\u043e",txtOf:"\u0438\u0437",keyToClose:"c",keyToPrev:"p",keyToNext:"n",imageArray:[],activeImage:0},a);var h=this;return this.unbind("click").click(function(){b("embed, object, select").css({visibility:"hidden"}); o();a.imageArray.length=0;a.activeImage=0;if(h.length==1)a.imageArray.push([this.getAttribute("href"),this.getAttribute("title")]);else for(var c=0;c<h.length;c++)a.imageArray.push([h[c].getAttribute("href"),h[c].getAttribute("title")]);for(;a.imageArray[a.activeImage][0]!=this.getAttribute("href");)a.activeImage++;g();return false})}})(jQuery);



$(document).ready(function(){
	/*  IE6: hover, png */
	if($.browser.msie && $.browser.version <= '6.0') {
		DD_belatedPNG.fix('#header div.menu li i, div.twitter .link, #mainpage div.works .brd, div.news-list, div.about, div.about *, div.sideimage img, #header .contacts i, #footer .city div, #prevImg, #nextImg, #mainpageWorks div.works-small img, #footerClients img');
		
		$('#footerClients li:gt(2)').hide();
	}
	
	
	/* mainpage: works */
	$('#mainpageWorks div.works-big').jCarouselLite({
		btnPrev: '#prevImg',
		btnNext: '#nextImg',
		visible: 1,
		scroll: 1
	});
	$('#mainpageWorks div.works-small div').jCarouselLite({
		btnPrev: '#prevImg',
		btnNext: '#nextImg',
		visible: 1,
		scroll: 1,
		speed: 0
	});
	
	/* mainpage: about text */
	$('#mainpageAboutText').css('height', 'auto').hide();
	$('#expandMainpageAboutText').click(function(){
		var spanArr = $(this).find('.arr');
		
		$('#mainpageAboutText').slideToggle(500, function(){
			if (spanArr.text() == '↓') spanArr.text('↑');
			else spanArr.text('↓');
		});
		
		return false;
	});
	
	/* Footer */
	var oFtClients = $('#footerClients');
	var oFtClientsLogos = $('div.logos', oFtClients);
	var oFtClientsLogosUl = $('div.logos ul', oFtClients);
	var iFtClientsLogosH = oFtClientsLogos.height();
	
	$('a.expand', oFtClients).click(function(){		
		var boxH = oFtClientsLogos.height();
		var innerH = oFtClientsLogosUl.height();
		
		var newHeight = boxH > iFtClientsLogosH ? iFtClientsLogosH : parseInt(innerH);

		oFtClientsLogos.animate({
			height: newHeight
		});
		
		return false;
	});
	
	$('li', oFtClientsLogosUl).hover(function(){		
		$(this).children('.gray').hide();
	}, function(){
		$(this).children('.gray').show();
	});
	
	
	$('#footerContacts .cities li').click(function(){
		$(this).addClass('active').siblings().removeClass('active');
		$('#footerContacts div.city').hide().eq($('#footerContacts .cities li').index($(this))).show();
	});
	
	
	$('#photos .img a').lightBox();

});

