var BestOffers={};BestOffers.OfferBar={initialize:function(){this._container=$("offer-bar");this._initCarousel();this._observe()},_initCarousel:function(){new xing.controls.Carousel(this._container)},_observe:function(){this._container.delegate("li","click",function(b){var a=this.down("a");if(a){new Lightbox({url:a.href,dialog:"lightbox"});b.stop()}})}};BestOffers.SubscriptionInfo=Class.create({initialize:function(b){var c=$("js-newsletter-info"),a=$("js-newsletter-hide");if(c&&a){a.hide().up(".toolbox-container").toggleClassName("toolbox-greyed").select("img.display-status").invoke("toggle");c.show();new Ajax.Request(b.ajaxUrl,{method:"GET",onSuccess:function(){c.remove();a.show().down("form").update(b.alreadySubscribed)},on404:function(){c.remove();a.show()},on500:function(){c.remove();a.show()}});this._available=true}},isAvailable:function(){return !!this._available}});BestOffers.OfferCountdown=Class.create({initialize:function(){this._dom=$$("span.offer-countdown");if(this._dom.length){setInterval(this._setCountdown.bind(this),990)}},_setCountdown:function(){this._dom.each(this._calculateDate.bind(this))},_calculateDate:function(c){var d={},e=new Date();var a=c.readAttribute("rel").split("-");a=new Date(a[0],--a[1],a[2]);var b=24*60*60*1000;if((a.getTime()+b)>e.getTime()){var f=a-e;d.h=parseInt(f/1000/60/60,false);d.h+=24;d.m=60-e.getMinutes()-1;d.s=60-e.getSeconds();return this._render(c,d)}else{return this._countdownOver(c)}},_render:function(a,b){a.setStyle({display:"inline"});$w("h m s").each(function(c){a.down("span.offer-countdown-"+c+"-js").update(b[c])})},_countdownOver:function(a){this._dom=this._dom.without(a);this._render(a,{h:0,m:0,s:0})}});BestOffers.OfferView=Class.create({initialize:function(a){this._offerId=a.offerId;this._offerTitle=a.offerTitle;this._offerUrl=a.offerUrl;this._formSubmitter();this._replaceHeader();this._addLinks();this._view()},_formSubmitter:function(){var b=this;var a=$("offer-visit-form-js");a&&a.observe("submit",function(c){c.stop();$(this).request({onCreate:b._visit.bind(b)})})},_addLinks:function(){new xeToolkit.Controls.Toolbox($$("#bo-lb-tools div.toolbox-container").first(),{effect:"blind"})},_replaceHeader:function(){$("lightbox-header").replace('<span id="lightbox-header" class="header">'+this._offerTitle+"</span>")},_view:function(){PremiumProdview(this._offerId,this._offerId)},_visit:function(){var b="offer_external_"+this._offerId;var a=Prototype.Browser.IE?window.open(this._offerUrl,b,"width="+screen.availWidth-50+",height="+screen.availHeight-50+",left=0,top=0,location=yes,menubar=yes,toolbar=yes,status=yes,resizable=yes,scrollbars=yes"):window.open(this._offerUrl,b);a.focus();PremiumClickout(this._offerId,this._offerId)}});document.observe("dom:loaded",function(a){new BestOffers.OfferCountdown();var b=$("login-link");b&&b.down("a").observe("click",function(c){c.stop();b.hide();Effect.BlindDown("bo_login",{duration:0.3})})});
