Street=function(){this.jPtr=$("#banner_street");1<this.jPtr.find(".banner").size()&&this.init()};
Street.prototype={SEGMENTS_AMOUNT:5,AUTOROTATE_INTERVAL:15,init:function(){this.initDom();this.initDimensions();this.initSwf()},initDom:function(){this.jWrap=this.jPtr.find(".wrap")},initDimensions:function(){this.iWidth=parseInt(this.jWrap.css("width"));this.iHeight=parseInt(this.jWrap.css("height"));this.iSegmentHeight=parseInt(this.iHeight/this.SEGMENTS_AMOUNT)},initSwf:function(){this.initBanners();this.initZIndexes();this.unlock()},initBanners:function(){var a=this;this.aBanners=[];this.jPtr.find(".banner").each(function(b){var c=
$(this),b=a.bannerFactory(c,b);a.aBanners.push(b);b.jPtr.hasClass("first")&&a.setCurrentBanner(b)})},done:function(){this.attachEvents();this.jPtr.addClass("done");this.autorotate()},attachEvents:function(){var a=this;this.jPtr.find(".rotate .icon").click(function(){a.isLocked()||(a.autorotateStop(),a.rotate())})},initZIndexes:function(){var a=this;this.eachBanner(function(){this.updateZIndex(a.aBanners.length-this.id)})},rotate:function(){this.getNextBanner().isLoaded()&&(this.lock(),this.getCurrentBanner().stop(),
this.setCurrentBanner(this.getNextBanner()),this.getCurrentBanner().rotate())},autorotate:function(){var a=this;this.intAutorotate=setInterval(function(){a.rotate()},1E3*this.AUTOROTATE_INTERVAL)},autorotateStop:function(){if(!this.bAutorotateStopped)clearInterval(this.intAutorotate),this.bAutorotateStopped=!0},rotateComplete:function(){this.push();this.getCurrentBanner().play();this.unlock()},push:function(){var a=this;this.eachBanner(function(){this.updateZIndex(a.increment(this.getZIndex()))})},
increment:function(a){return a>=this.aBanners.length?1:a+1},getCurrentBanner:function(){return this.oCurrentBanner},setCurrentBanner:function(a){this.oCurrentBanner=a},getFirstBanner:function(){return this.getBanner(0)},getBanner:function(a){return this.aBanners[a]},getNextBanner:function(){return this.getBanner(this.increment(this.getCurrentBanner().id+1)-1)},getNumberOfBanners:function(){return this.aBanners.length},lock:function(){this.bLocked=!0},unlock:function(){this.bLocked=!1},isLocked:function(){return this.bLocked},
bannerFactory:function(a,b){return Tehnosila.isFlash()&&a.hasClass("flash")?new FlashBanner(a,b,this):new Banner(a,b,this)},eachBanner:function(a){this.aBanners.each(a)}};$(document).ready(function(){new Street});Banner=function(a,b,c){this.jPtr=a;this.id=b;this.oStreet=c;this.init()};
Banner.prototype={init:function(){this.bLoaded=!1;this.initDom();this.initLoadEvent();this.initSegments()},initDom:function(){this.jContent=this.jPtr.find(".content")},initLoadEvent:function(){var a=this,b=new Image;b.onload=function(){a.onLoad()};b.src=this.jContent.attr("src")},initSegments:function(){this.aSegments=[];this.aSegments.push(new BannerSegment(this.jContent,0,this));for(var a=1,b=this.oStreet.SEGMENTS_AMOUNT;a<b;a++){var c=this.jContent.clone().appendTo(this.jPtr);this.aSegments.push(new BannerSegment(c,
a,this))}this.aSegments[0].jPtr.addClass("first_segment")},rotate:function(){this.prepareToRotate();this.doRotate()},prepareToRotate:function(){this.eachSegment(function(){this.totalClip()});this.rewind();this.setZIndex(this.oStreet.getNumberOfBanners()+1)},doRotate:function(){var a=this;jTweener.addPercent({everyFrame:function(b){a.eachSegment(function(){this.everyFrame(b)})},onComplete:function(){a.oStreet.rotateComplete()},transition:"easeOutSine",time:BannerSegment.ANI_DURATION})},onLoad:function(){this.bLoaded=
!0;if(this.isIamFirstBanner()){var a=this;setTimeout(function(){a.oStreet.done();a.play()},$.browser.opera?1E3:10)}},isLoaded:function(){return this.bLoaded},isIamFirstBanner:function(){return 0===this.id},play:function(){},stop:function(){},rewind:function(){},getZIndex:function(){return this.iZIndex},updateZIndex:function(a){this.iZIndex=a;this.setZIndex(a)},setZIndex:function(a){this.jPtr.css("z-index",a)},getFirstSegment:function(){return this.aSegments[0]},eachSegment:function(a){this.aSegments.each(a)}};
FlashBanner=function(){this.constructor.baseConstructor.apply(this,arguments)};FlashBanner.sHtml='<div class="{class}"><div class="content"><div id="replace_with_swf"></div></div></div>';
FlashBanner.inheritFrom(Banner,{init:function(){this.replaceWithSwf();FlashBanner.superClass.init.call(this)},replaceWithSwf:function(){this.sSwfUrl=this.jPtr.find("input[name = swf_url]").val();var a=this.jPtr.attr("href"),b=$(FlashBanner.sHtml.supplant({"class":this.jPtr.attr("class")}));this.jPtr.replaceWith(b);swfobject.createSWF({data:this.sSwfUrl,width:this.oStreet.iWidth,height:this.oStreet.iHeight},{wmode:"opaque",play:!1,flashvars:this.getFlashVars({url:a,is_first_banner:this.isIamFirstBanner()?
"true":""})},"replace_with_swf").removeAttribute("id");this.jPtr=b},initLoadEvent:function(){var a=this;$.ajax({url:this.sSwfUrl,complete:function(){a.onLoad()}})},play:function(){this.getFirstSegment().unclip();this.getFirstSegment().play()},stop:function(){this.getFirstSegment().stop()},rewind:function(){this.getFirstSegment().rewind()},getFlashVars:function(a){var b=[],c;for(c in a)a.hasOwnProperty(c)&&""!==a[c]&&b.push(c+"="+a[c]);return b.join("&")}});
BannerSegment=function(a,b,c){this.jPtr=a;this.id=b;this.oBanner=c;this.init()};BannerSegment.CLIP_PATTERN="rect({top}{units}, {right}{units}, {bottom}{units}, {left}{units})";BannerSegment.ANI_DURATION=0.4;
BannerSegment.prototype={init:function(){this.initDom();this.initClipping()},initDom:function(){this.eSwf=this.jPtr.find("object")[0]},initClipping:function(){this.oBaseClipping={top:this.id*this.oBanner.oStreet.iSegmentHeight,right:this.oBanner.oStreet.iWidth,bottom:(this.id+1)*this.oBanner.oStreet.iSegmentHeight,left:0,units:"px"}},everyFrame:function(a){this.clip(parseInt(this.oBaseClipping.top+(this.oBaseClipping.bottom-this.oBaseClipping.top)*a))},clip:function(a){var b=$.extend({},this.oBaseClipping);
b.bottom=a;this.jPtr.css("clip",this.getClip(b))},totalClip:function(){this.clip(this.oBaseClipping.top)},unclip:function(){this.jPtr.css("clip",this.getClip({top:"auto",right:"auto",bottom:"auto",left:"auto",units:""}))},play:function(){this.eSwf.Play()},stop:function(){this.eSwf.StopPlay()},rewind:function(){this.eSwf.Rewind()},getClip:function(a){return BannerSegment.CLIP_PATTERN.supplant(a)}};
(function(){function a(a){function c(){if(0<e.getTime()){e.setTime(e.getTime()-1*l);var a=new Date(e.getTime());a.setSeconds(0);a.setMinutes(0);var a=a.getTime()/(l*q*i),b=e.getMinutes(),c=e.getSeconds();f.html(a+g+p(b)+g+p(c))}else clearInterval(n),d()}function d(){(function(c){k.css({width:a[0].offsetWidth,height:a[0].offsetHeight,opacity:0});jTweener.addTween(k,{opacity:1,time:h,transition:"easeInCubic",onComplete:c})})(function(){a.addClass("timer_banner_collapse").css({padding:0,width:a[0].offsetWidth});
jTweener.addTween(a,{width:0,time:h,transition:"easeInOutExpo"})})}function r(a){var b=(new Date).getSeconds();n=setInterval(function(){var c=(new Date).getSeconds();c!==b&&(b=c,a())},200)}function p(a){a=a.toString();return 1===a.length?"0"+a:a}var l=1E3,q=60,i=60,g=":",h=0.7,k=a.find(".curtain"),f=a.find(".timer .wrap"),e,n;(function(){var a=$.trim(f.html()).split(g);e=new Date(Date.UTC(1970,0,1,a[0],a[1],a[2]))})();(function(){setTimeout(function(){r(c)},500)})()}$(document).ready(function(){$(".banner_among_products:has(.timer)").each(function(){a($(this))})})})();
(function(){$(document).ready(function(){function a(){h.find("li").each(function(a){a=promoTab($(this),k.eq(a),a,q);f.push(a);a.isCurrent()&&(e=a)});e||(e=f[0],e.select())}function b(){l(function(){this.initAppearance()})}function c(){l(function(){this.isChangePosition()&&this.prepareToChangingPosition()});jTweener.addPercent({time:i.ani_duration,tween:function(a){l(function(){this.isChangePosition()&&this.changingPositionEveryFrame(a)})}})}function d(){return e.getId()}function r(){return n.getId()}
function p(a){return i[a]}function l(a){f.each(a)}var q,i={ani_duration:0.25,tab_height:2.7,open_tab_height:10,tab_bottom_offset:30,zindex_offset:1},g=$("#promo"),h=g.find("ul.tabs").eq(0),k=g.find("ul.photos li"),f=[],e,n,m,o=!1,j,s;(function(){q={selectTab:function(a){a.id!==d()&&(n=e,e=a,n.deselect(),e.select(),c())},getTabColor:function(){return j||null},setTabColor:function(a){j=a},getCurrentTabColor:function(){return s||null},setCurrentTabColor:function(a){s=a},getCurrentTabId:d,getPrevTabId:r,
getConstant:p,getHeight:function(){return m},lock:function(){o=!0},unlock:function(){o=!1},isLocked:function(){return o}}})();g.size()&&(a(),m=(f.length-1)*i.tab_height+i.open_tab_height,h.css("height",m+"em"),b(),g.addClass("done"))})})();
promoTab=function(a,b,c,d){var r,p;function l(){jTweener.addTween(a,{time:h(),transition:"linear",backgroundColor:d.getCurrentTabColor(),onComplete:function(){d.unlock()}})}function q(){var a=d.getCurrentTabId(),b=d.getPrevTabId();return!(!c.between(a,b,!0)&&!(c===a&&c>b||c===b&&c>a))}function i(){var a=c<=d.getCurrentTabId()?c*d.getConstant("tab_height"):(c-1)*d.getConstant("tab_height")+d.getConstant("open_tab_height");return d.getHeight()-a+d.getConstant("tab_bottom_offset")}function g(){return j}
function h(){return d.getConstant("ani_duration")}function k(a){return a+"em"}var f,e=a.find("h2 a"),n=e.find(".dummy"),m=b.find("img.photo"),o=m.add(b.find(".ribbon")),j=a.hasClass("current");(function(){f={initAppearance:function(){var b=a.css("background-color");a.css({height:k(i()),backgroundColor:b,zIndex:c+d.getConstant("zindex_offset")});j?d.setCurrentTabColor(b):d.getTabColor()||d.setTabColor(b);var b=m.attr("width"),e=m.attr("height"),f=Math.round(b/2),g=Math.round(e/2);m.css({top:k(d.getHeight()/
2),marginLeft:-f,marginTop:-g});n.css({width:b,height:e,marginLeft:-f,marginBottom:-g,paddingBottom:k(d.getHeight()/2),clip:"rect(0 {right}px {bottom}px 0)".supplant({right:b,bottom:e})});o.css("opacity",j?1:0)},select:function(){j=!0;a.addClass("current");e.addClass("alt");jTweener.addTween(o,{time:h(),opacity:1});l()},deselect:function(){j=!1;a.removeClass("current");e.removeClass("alt");jTweener.addTween(o,{time:h(),opacity:0});jTweener.addTween(a,{time:h(),transition:"linear",backgroundColor:d.getTabColor()})},
prepareToChangingPosition:function(){r=parseFloat(a.css("height"));p=i()},changingPositionEveryFrame:function(b){var c=r;a.css("height",k(Math.round(100*(c+(p-c)*b))/100))},getId:function(){return c},isChangePosition:q,isCurrent:g}})();e.click(function(a){if(!j)return d.isLocked()||(d.lock(),d.selectTab(f)),a.preventDefault(),!1});return f};

