
Citysearch.Offer={offerActionsDivId:'couponActions',init:function(){var couponList=$('couponList');if($chk(couponList)){Citysearch.ModalWindow.setTitle(Citysearch.Text.Main.couponTitle+' ('+couponList.getElements('li').length+')');var selectAllLabel=new Element('label',{'text':'select all'});var selectAllCheckBox=new Element('input',{'type':'checkbox'});selectAllCheckBox.addEvent('click',function(e){couponList.getElements('li input[type=checkbox]').each(function(checkbox){checkbox.set('checked',e.target.get('checked'));});});var selectAllContainer=new Element('span',{'id':'selectAllOffers'});selectAllContainer.adopt(selectAllLabel,selectAllCheckBox);var offerSelectionButton=couponList.getElement('button');selectAllContainer.inject(offerSelectionButton,'after');}
var selectCouponForm=$('selectCouponForm');if($chk(selectCouponForm)){selectCouponForm.addEvent('submit',function(e){e.preventDefault();var printOfferCheckboxes=$$('.printOfferCheckbox');if($chk(printOfferCheckboxes)){var offerChecked=false;printOfferCheckboxes.each(function(printOfferCheckbox){if(printOfferCheckbox.get('checked')){offerChecked=true;}});if(offerChecked){Citysearch.AjaxInit.postViaAjax(this,this.get('action'),Citysearch.ModalWindow.bodyObj);}
else{alert('Please select an offer to print.');}}});}
var printOfferLinks=$$('.printOfferLink');if($chk(printOfferLinks)){printOfferLinks.each(function(printOfferLink){printOfferLink.addEvent('click',function(e){e.preventDefault();var ajaxLink=Citysearch.AjaxInit.hijaxHref(this.href);Citysearch.AjaxInit.getViaAjax(ajaxLink,Citysearch.ModalWindow.bodyObj);});});}
if(!$(this.offerActionsDivId)){return;}
var offerActionsDiv=$(this.offerActionsDivId);var printLink=new Element('a',{'text':'Print Coupons','name':'listing_profile/coupon/print_coupons','href':'#','events':{'click':function(e){var stop=new Event(e).preventDefault();window.print();}}});var printIcon=new Element('span',{'class':'actionSprite printIcon'});printLink.grab(printIcon,'top');offerActionsDiv.grab(printLink);if(Citysearch.TempConfig.printNow){var printLater=function(){window.print();};printLater.delay(Citysearch.ModalWindow.animationDuration+100);}
Citysearch.ModalWindow.setTitle(Citysearch.Text.Main.couponPrintTitle);}};window.addEvent('domready',function(){Citysearch.Offer.init();});
