(function(){CNB.clickableSkin={load:function(clickables,content,container){this.elements=$$(clickables);this.container=$(container);this.content=$(content);if(!$chk(this.elements)||!$chk(this.container)||!$chk(this.content))return false;this.container.setStyle('position','relative');this.setClickableArea();window.addEvent('resize',this.setClickableArea.bind(this))},setClickableArea:function(){var containerSize=this.container.getScrollSize();var contentSize=this.content.getSize();var gutterSize=containerSize.x-contentSize.x;var width=(gutterSize>0)?Math.floor(gutterSize/2):0;var height=containerSize.y;if(width>0&&height>0){this.elements.each(function(el,i){el.setStyles({'position':'absolute','z-index':'1','top':'0','left':0,'width':width,'height':height});if(i==1){el.setStyles({'left':'auto','right':'0'})}})}}};CNB.Overlay.loadEmail=function(options){var handleFormSubmit=function(e,form){e.stop();overlay.loader.add();var request=new Request.JSON({url:form.getProperty('action'),data:form.toJSON(),onSuccess:function(data){if(data.status=='success'){overlay.notify('Your message has been sent.')}else{overlay.notify('Sorry we can\'t send your message at this time.')}},onComplete:overlay.loader.remove.bind(overlay.loader),onFailure:function(xhr){overlay.notify('Sorry we can\'t send your message at this time.')}}).post()};var overlay=new CNB.Overlay.Async(options);overlay.addOneEvent('contentReady',function(content){var validate=new CNB.Validator(content.getElement('form'),{onValidateSuccess:handleFormSubmit})});overlay.open()};CNB.RegOverlay=new Class({initialize:function(){this.isUser=(Cookie.read('purs_3')!=null)?true:false;this.hasViewed=(Cookie.read('reg-overlay')!=null)?true:false},load:function(){if(this.isUser||this.hasViewed){return false}var path=location.pathname;var host=location.hostname;if(host.contains('jobfunctions')||path.contains('/members/')){return false}if(!CNB.hasCookiesEnabled()){return false}this.overlay=new CNB.Overlay({id:'reg-pop-overlay',containerClass:'contain-overlay-10',content:this.buildContent(),onClose:function(){DW.redir({'ctype':'reg-ol;act','cval':'close'})},onOpen:function(){DW.redir({ctype:'reg-ol;act',cval:'load'});Cookie.write('reg-overlay','1',{duration:30,domain:CNB.getCookieHost(),path:'/'})}}).open()},buildContent:function(){var html='<h2 class="h s-4 fancy space-1_5">Buy DISH Network today for only $24.99/Mo*</h2>'+'<div class="hed hed-1"><h4 class="h s-6 c-3 heavy"><div style="background-color:#fff;padding-right:10px;display:inline;font-size:1em;">And you get all these FREE*</div></h4></div>'+'<div class="space-1"><img src="http://www.theamericandishtv.com/images/pop-up.png" /><div style="font:Verdana,sans-serif;color:#C42828; font-weight:bold; font-size:1em;">For Instant Booking Call 1-888-209-8226 (Promo: FB1010) </div></div><div class="lvl-btn clear space-1"><a href="http://www.theamericandishtv.com/order1.php" class="btn-1" style="color:#FFFFFF;text-decoration:none;" target="_blank">Order Now</a><div class="other-options right fancy c-2"> <a href="http://www.theamericandishtv.com/dish-america-packages.html" style="text-decoration:none;" target="_blank" class="links">Package Details</a> | <a class="close links">No thanks</a></div></div>';var contents=new Element('div',{'class':'content','html':html});var submitLevel=new Element('div',{'class':'lvl-btn clear space-1'}).inject(contents,'bottom');/*var join=new Element('a',{'class':'btn-1','text':'Order Now','events':{'click':function(){DW.redir({ctype:'reg-ol;act',cval:'signmeup'});this.overlay.remove();CNB.Reg.join({regSrc:'reg-over'})}.bind(this)}}).inject(submitLevel,'bottom');var span=new Element('span',{'class':'other-options right fancy c-2','text':' | '}).inject(submitLevel,'bottom');var login=new Element('a',{'html':'Package Details','events':{'click':function(){DW.redir({ctype:'reg-ol;act',cval:'currentmember'});this.overlay.remove();if(typeof CNB.Reg.logIn!='undefined'){CNB.Reg.logIn({regSource:'reg-over'})}else{CNB.Reg.login({regSrc:'reg-over'})}}.bind(this)}}).inject(span,'top');var noThanks=new Element('a',{'text':'No thanks','class':'close','events':{'click':function(){this.overlay.removeEvents('close');DW.redir({ctype:'reg-ol;act',cval:'nothanks'})}.bind(this)}}).inject(span,'bottom');*/return contents}});CNB.SearchSection=new Class({Implements:Options,options:{defaultSection:''},initialize:function(container,options){this.setOptions(options);this.container=$(container);this.form=this.container.getElement('form');this.overlay=this.container.getElement('.overlay-search');this.sectionOptions=this.overlay.getElements('a')},load:function(){this.sectionOptions.each(function(el){el.addEvent('click',this.handleClick.bindWithEvent(this,el))}.bind(this));var pop=new CNB.Pop(this.form,this.overlay,{offset:{x:-5,y:5}}).load();if($chk(this.options.defaultSection)){this.setOnState(this.overlay.getElement('a[section='+this.options.defaultSection+']'));this.setSection(this.options.defaultSection)}this.form.addEvent('submit',this.handleSubmitEvent.bind(this))},handleClick:function(e,el){e.stop();var section=el.getProperty('section');this.setSection(section);this.setOnState(el)},setOnState:function(selected){this.sectionOptions.each(function(el){el.removeClass('on')});selected.addClass('on')},setSection:function(section){var input=this.form.getElement('input');switch(section){}this.form.setProperty('action',action);if(input.hasClass('placeholder')){input.set('value',title)}input.setProperty('placeholder',title)},handleSubmitEvent:function(e){e.stop();var input=this.form.getElement('input');input.set('value',input.get('value').toLowerCase());this.form.submit()}});CNB.Fixation=new Class({Implements:Options,options:{windowInset:20,container:null,zindex:1},initialize:function(element,options){this.setOptions(options);this.element=$(element);this.container=(this.options.container!=null)?$(this.options.container):this.element.getOffsetParent();this.position={original:this.element.getStyle('top')};if(this.element.getSize().y+this.options.windowInset>this.container.getSize().y){return false}this.winSize=window.getSize();this.element.setStyles({'position':'absolute','left':0,'z-index':this.options.zindex});this.setPosition();window.addEvents({'scroll':this.setPosition.bind(this),'resize':function(){this.winSize=window.getSize();this.setPosition()}.bind(this)})},getPositionValues:function(){this.elementSize=this.element.getSize();this.containerCoords=this.container.getCoordinates();this.scroll=window.getScroll();this.scroll.max=this.containerCoords.bottom-this.elementSize.y;if(this.elementSize.y+this.options.windowInset>this.winSize.y){this.position.min=1000000}else{this.position.min=this.containerCoords.top-this.options.windowInset;this.position.max=this.containerCoords.height-this.elementSize.y;this.position.windowTop=this.scroll.y-this.containerCoords.top+this.options.windowInset}},setPosition:function(){var position;this.getPositionValues();if(this.scroll.y<this.position.min){position=this.position.original}else if(this.scroll.y>this.scroll.max){position=this.position.max}else{position=this.position.windowTop}this.element.setStyle('top',position)}});CNB.SubscribePromo=new Class({initialize:function(loggedInForm,loggedOutForm){this.loggedOutForm=$(loggedOutForm);this.loggedInForm=$(loggedInForm);this.loader=new CNB.Loading(this.loggedInForm);this.loggedOutForm.addEvent('submit',this.loggedOutSubmit.bind(this));this.validate=new CNB.Validator(this.loggedInForm,{onValidateSuccess:CNB.Reg.checkLoggedIn.bindWithEvent(CNB.Reg,this.loggedInSubmit.bind(this))})},loggedOutSubmit:function(e){e.stop();CNB.Reg.join({'data':this.loggedOutForm.toJSON()})},loggedInSubmit:function(){this.loader.add();var request=new Request.JSON({url:this.loggedInForm.getProperty('action'),data:$merge(this.loggedInForm.toJSON(),{'appId':'218','updateUser':true}),onSuccess:this.subscribeResponse.bind(this),onComplete:this.loader.remove.bind(this.loader),onFailure:function(xhr){this.subscribeResponse({'status':'failure'})}}).post()},subscribeResponse:function(response){switch(response.status){case'success':msg='Thank you for subscribing.';break;default:msg='Sorry, we encountered a problem, and can\'t process your request at this time.'}this.loggedInForm.empty().set('html','<p class="heavy c-6">'+msg+'</p>')}});window.addEvent('domready',function(){var regOverlay=new CNB.RegOverlay().load();var clickableAreas=$$('.skinClick');if(clickableAreas.length>0){CNB.clickableSkin.load(clickableAreas,'content','mantle_skin')}var noteAnchors=$$('.noteAnchors');if(noteAnchors.length>0){var noteOverlays=$$('.noteOverlays');var tips=new CNB.Pop(noteAnchors,noteOverlays,{offset:{x:5,y:0},position:{x:'left',y:'bottom'}}).load()}}.bind(this))})();
