/*    HTTP Host:  static.ak.fbcdn.net                                          */
/*    Generated:  February 9th 2010 7:49:09 PM PST                             */
/*      Machine:  10.16.139.106                                                */
/*       Source:  Backing Store                                                */
/*     Location:  js/7xkl4ov7o944g0wo.pkg.js h:7yqjpkv9                        */
/*       Locale:  nu_ll                                                        */
/*         Path:  js/7xkl4ov7o944g0wo.pkg.js                                   */

if (window.CavalryLogger) { CavalryLogger.start_js(["js\/7xkl4ov7o944g0wo.pkg.js"]); }

function show_error_section(_L0,_L1,_L2){if(_L0==undefined)return false;if(_L0.length){error_html='';for(var i=0;i<_L0.length;i++)error_html=error_html+'<li>'+_L0[i]+'</li>';DOM.setContent(_L1,HTML(error_html));if(_L2.length)for(var i=0;i<_L2.length;i++)CSS.addClass(_L2[i],'error_border');show(_L1);return true;}else return false;}function show_fallback_error_section(_L0,_L1){if(_L0==undefined)return false;var _L2=false;for(var _L3 in _L0)if(_L0[_L3]&&_L0[_L3] instanceof Array)_L2=show_error_section(_L0[_L3],_L1,[])||_L2;return _L2;}function prefill_ad_creation_v3(){var _L0=ge('adgroup_src');if(_L0){adgroup_id=get_form_select_value(_L0);if(adgroup_id!='default'){var _L1=$('act').value;goURI(muffinize('/muffins/create/?adgroup_id='+adgroup_id+'&act='+_L1));}}}
function admanager_tracking_log_step(_L0){var _L1='type=waterfall'+'&params[]='+_L0+'&act='+window.admanager_tracking_account_id+'&';new AsyncSignal(muffinize('/muffins/ajax/tracking_log.php?'+_L1)).send();}function admanager_tracking_usage_log(_L0,_L1){var _L2='type=usage'+'&params[]='+escapeURI(_L0)+'&params[]='+escapeURI(_L1?_L1:'')+'&act='+window.admanager_tracking_account_id+'&';new AsyncSignal(muffinize('/muffins/ajax/tracking_log.php?'+_L2)).send();}
function AdCreate_PageController(){this.step_controllers=[];this.hidden_step_ids=[];this.shown_step_ids=[];this.isStepByStep=false;this.isEditAd=false;this.submit_disabled=false;this.currency='USD';this.timezone_id=1;if(AdCreate_PageController.direct_sales)$('creative_type').listen('change',this._onCreativeTypeChange.bind(this));AdCreate_PageController.instance=this;}copy_properties(AdCreate_PageController,{instance:null,direct_sales:false,getInstance:function(){return AdCreate_PageController.instance||(AdCreate_PageController.instance=new AdCreate_PageController());}});copy_properties(AdCreate_PageController.prototype,{initLog:function(_L0){var _L1=_L1(_L0);for(var i=0;i<_L1.length;i++){var id=_L1[i];var _L4=this.getStepController(id);if(_L4)_L4.initLog(_L0[id]);}},addStepController:function(_L0){this.step_controllers.push(_L0);if(AdCreate_PageController.direct_sales)this._setControllerVisibility(_L0);},getStepController:function(id){for(var i=0;i<this.step_controllers.length;i++){var _L2=this.step_controllers[i];if(_L2.id==id||(_L2.stepType&&_L2.stepType==id))return _L2;}},getStepIDs:function(){var _L0=[];for(var i=1;i<this.step_controllers.length;i++){var _L2=this.step_controllers[i].id;if(this.step_controllers[i].stepType)_L2=this.step_controllers[i].stepType;_L0.push(_L2);}return _L0;},initSubmitButton:function(_L0){this.isStepByStep=_L0;var _L1=$('ads_create_submit');if(this.isStepByStep){this.hidden_step_ids=this.getStepIDs();var _L2=this.hidden_step_ids[0];this.shown_step_ids.push(_L2);$('ads_create_submit').value=_tx("Continue");}else{this.shown_step_ids=this.getStepIDs();if(this.isEditAd){$('ads_create_submit').value=_tx("Save");}else $('ads_create_submit').value=_tx("Create");}_L1.listen('click',this.submit.bind(this));},setEditAd:function(_L0){this.isEditAd=_L0;return this;},advanceStep:function(){var _L0=this.hidden_step_ids.shift();switch(this.hidden_step_ids.length){case 1:var _L1='CREATE_TARGETING';break;case 0:var _L1='CREATE_SETTINGS';$('ads_create_submit').value=_tx("Create");break;}this.shown_step_ids.push(_L0);admanager_tracking_log_step(_L1);animation($(_L0)).from('height',0).to('height','auto').duration(400).blind().show().go();},_onCreativeTypeChange:function(){var _L0=get_form_select_value($('creative_type'));for(var i=0;i<this.step_controllers.length;i++){var _L2=this.step_controllers[i];this._setControllerVisibility(_L2);}},_setControllerVisibility:function(_L0){var _L1=get_form_select_value($('creative_type'));if(_L0.step_type&&_L0.step_type=='creative')if(_L0.id==_L1){show($(_L0.id));}else hide($(_L0.id));},_resetErrors:function(){var _L0=$('create_ad_form');var _L1=['input','select','textarea'];for(var i=0;i<_L1.length;i++){var _L3=_L1[i];var _L4=DOM.scry(_L0,_L3+'.error_border');_L4.removeClass('error_border');}var _L5=DOM.scry(_L0,'ul.error_box');for(var i=0;i<_L5.length;i++)DOM.empty(_L5[i]);var _L6=DOM.scry(_L0,'h2.step_header_error');_L6.removeClass('step_header_error');},_createAd:function(){var _L0={};for(var i=0;i<this.shown_step_ids.length;i++){var _L2=this.step_controllers[i];_L0[_L2.id]=_L2.onSubmit();}create_hidden_inputs({'ui_logging':_L0},$('create_ad_form'));document.create_ad_form.submit();},submit:function(){if(this.submit_disabled)return false;var _L0=$('ads_create_validate_progress');_L0.removeClass('hidden');this._resetErrors();var _L1=serialize_form($('create_ad_form'));var _L2=function(_L4){var _L5=_L4.getPayload();if(_L5.success&&this.hidden_step_ids.length==0){_L0.addClass('hidden');if(_L5.show_dialog){var _L6=this._createAd.bind(this);var _L7=function(){goURI(muffinize('/muffins/manage/'));};new Dialog().setTitle(_tx("Paused Ad")).setBody(_tx("This ad is paused.  If you edit it, it will become active after it has been reviewed.")).setButtons(Dialog.OK_AND_CANCEL).setHandler(_L6).setCancelHandler(_L7).show();}else this._createAd();return false;}this.submit_disabled=false;var _L8=null;for(var i=0;i<this.step_controllers.length;i++){var _La=this.step_controllers[i];var _Lb=_La.id;if(_La.stepType)_Lb=_La.stepType;if(_L5[_Lb])var _Lc=_La.display_errors(_L5[_Lb]);_L8=_L8||_Lc;}if(_L8){DOMScroll.scrollTo(_L8);}else if(this.hidden_step_ids.length>0){this.advanceStep();}else{show_error_section([_tx("There was an error with the information you submitted.")],$('ad_creative_adspace_generic_errors'),[]);DOMScroll.scrollTo('ad_creative_adspace');}_L0.addClass('hidden');return false;}.bind(this);var _L3=function(){this.submit_disabled=false;_L0.addClass('hidden');};this.submit_disabled=true;new AsyncRequest().setURI(muffinize('/muffins/ajax/create_form_validate.php')).setData(_L1).setReadOnly(true).setHandler(_L2).setErrorHandler(_L3).send();return false;}});
var UIAdsUtil={addHiddenClass:function(){for(var i=0;i<arguments.length;i++)if(arguments[i])CSS.addClass(arguments[i],'hidden');},removeHiddenClass:function(){for(var i=0;i<arguments.length;i++)if(arguments[i])CSS.removeClass(arguments[i],'hidden');},showError:function(_L0,_L1,_L2){if(!_L1||!_L1.length||_L1.length<=0)return false;var _L3='<ul>';for(var i=0;i<_L1.length;i++)_L3+='<li>'+_L1[i]+'</li>';_L3+='</ul>';DOM.setContent(_L0,HTML(_L3));UIAdsUtil.removeHiddenClass(_L0);if(_L2&&_L2.length>0)for(var i=0;i<_L2.length;i++)CSS.addClass(_L2[i],'UIAdCreative_ErrorBorder');return true;},hideError:function(_L0,_L1){DOM.setContent(_L0,'');UIAdsUtil.addHiddenClass(_L0);if(_L1&&_L1.length>0)for(var i=0;i<_L1.length;i++)CSS.removeClass(_L1[i],'UIAdCreative_ErrorBorder');},getTextCapitalizationInfo:function(_L0,_L1){var _L2={'white_space':/\s+/,'uc_first':/^[A-Z]/,'lc_first':/^(?:[a-df-hj-z]|[ei][^A-Z])/,'is_domain':/^(?:\w+\.)?\w+\.\w{2,3}[\.!?]?$/,'uc_all':/^[A-Z]{2,}[\.!;,?]?$/,'ends_sentence':/[\.!?]$/};var _L3=_L0.split(_L2['white_space']);var _L4={'innerWordUCF':0,'firstWordLCF':0,'wholeWordUC':0};var _L5=true;for(var i=0;i<_L3.length;i++){var _L7=_L3[i];if(_L7.match(_L2['is_domain'])){}else if(_L5&&_L7.match(_L2['lc_first'])){_L4['firstWordLCF']++;}else if(!_L5&&_L1&&_L7.match(_L2['uc_first'])){_L4['innerWordUCF']++;}else if(_L7.match(_L2['uc_all']))_L4['wholeWordUC']++;_L5=_L7.match(_L2['ends_sentence']);}var _L8=0;for(var _L9 in _L4)_L8+=_L4[_L9];_L4['wordCount']=_L3.length;_L4['badCount']=_L8;_L4['score']=parseInt(_L4['badCount']/_L4['wordCount']*100)/100;return _L4;}};
function UIAdCreative(id,_L1,_L2,_L3,_L4,_L5){this.id=id;this.topDiv=$(this.id);this.destinationComponent=_L1;this.titleComponent=_L2;this.bodyComponent=_L3;this.imageComponent=_L4;this.capitalizationCheckData=_L5;if(this.destinationComponent){this.destinationConstants=this.destinationComponent.constants;this.destinationComponent.setDestinationLinkTypeChangeCallback(this.onDestinationLinkTypeChange.bind(this),true);this.destinationComponent.setFbidChangeCallback(this.onFbidChange.bind(this),true);this.destinationComponent.setWebsiteUrlChangeCallback(this.onWebsiteUrlChange.bind(this),true);this.destinationComponent.setWebsiteTypeChangeCallback(this.onWebsiteTypeChange.bind(this),true);}if(this.titleComponent)this.titleComponent.setTitleChangeCallback(this.onTitleChange.bind(this),true);if(this.bodyComponent)this.bodyComponent.setBodyChangeCallback(this.onBodyChange.bind(this),true);if(this.imageComponent)this.imageComponent.setImageChangeCallback(this.onImageChange.bind(this),true);this.warningDiv=this.topDiv.find('div.UIAdCreation_WarningDiv');this.warningMessage=this.topDiv.find('span.UIAdCreative_CapWarningMessage');this.refreshPreview();}copy_properties(UIAdCreative.prototype,{refreshPreview:function(){var _L0=function(_L2){DOM.setContent(this.topDiv.find('div.UIAdCreative_Preview'),HTML(_L2.getPayload()));}.bind(this);var _L1={body:this.body,title:this.title,imageURI:this.imageUrl};if(this.destinationConstants.external==this.destinationLinkType){if(this.websiteUrl&&this.websiteType)_L1.linkURI=this.websiteType+this.websiteUrl;}else if(this.selectedFbid){_L1.objId=this.selectedFbid;if(this.frameType&&this.frameType>0)_L1.frameType=this.frameType;}new AsyncRequest().setURI(muffinize('/muffins/ajax/creative_preview.php')).setData(_L1).setHandler(_L0).setStatusElement('preview_loading').setReadOnly(true).send();},_updateAdPreviewText:function(_L0,_L1,_L2){_L0=_L0.replace(/</g,'&lt;');_L0=_L0.replace(/>/g,'&gt;');if(_L2)_L0=html_wordwrap(_L0,15,htmlize);if(_L1)_L1.setContent(HTML(_L0));},onTitleChange:function(_L0,_L1){this.title=_L0;this.checkCapitalization();if(!_L1){var _L2=this.topDiv.find('div.UIAdCreative_Preview a.UIEMUASFrame_title');this._updateAdPreviewText(this.title,_L2,true);}},onBodyChange:function(_L0,_L1){this.body=_L0;this.checkCapitalization();if(!_L1){var _L2=DOM.find(this.topDiv,'div.UIAdCreative_Preview .UIEMUASFrame_body');this._updateAdPreviewText(this.body,_L2,false);}},onDestinationLinkTypeChange:function(_L0,_L1,_L2){this.destinationLinkType=_L0;this.frameType=_L1;this.updateFixedTitle();if(!_L2){this.refreshPreview();this.updateHelpSection();}},onFbidChange:function(_L0,_L1,_L2,_L3){this.destinationLinkType=this.destinationConstants.internal;this.selectedFbid=_L0;this.selectedFbidText=_L1;this.frameType=_L2;this.updateFixedTitle();if(!_L3){this.refreshPreview();this.updateHelpSection();}},onWebsiteUrlChange:function(_L0,_L1){this.websiteUrl=_L0;if(!_L1)this.refreshPreview();},onWebsiteTypeChange:function(_L0,_L1){this.websiteType=_L0;if(!_L1)this.refreshPreview();},onImageChange:function(_L0,_L1){this.imageUrl=_L0;if(!_L1)this.refreshPreview();},updateFixedTitle:function(){if(this.destinationLinkType==this.destinationConstants.internal&&this.frameType!=0){this.titleComponent.showFixedTitle(this.selectedFbidText);}else this.titleComponent.hideFixedTitle();},displayErrors:function(_L0){var _L1=this.titleComponent.displayErrors(_L0);_L1=this.bodyComponent.displayErrors(_L0)||_L1;_L1=this.destinationComponent.displayErrors(_L0)||_L1;return _L1;},updateHelpSection:function(){if(this.parentController&&this.parentController.updateHelp)this.parentController.updateHelp(this.frameType,this.parentController);},checkCapitalization:function(){if(!this.capitalizationCheckData||!this.capitalizationCheckData['enabled'])return;var _L0=false;var _L1=false;if(this.title){var _L2=UIAdsUtil.getTextCapitalizationInfo(this.title,false);_L0=(_L2['wordCount']>=this.capitalizationCheckData['title_word_count_minimum']&&_L2['score']>=this.capitalizationCheckData['title_score_minimum']);}if(this.body){var _L3=UIAdsUtil.getTextCapitalizationInfo(this.body,true);_L1=(_L3['wordCount']>=this.capitalizationCheckData['body_word_count_minimum']&&_L3['score']>=this.capitalizationCheckData['body_score_minimum']);}if(_L0||_L1){var _L4='';if(_L0&&_L1){_L4=_tx("There is a chance that your ad's title and body may not meet our capitalization guidelines and could cause your ad to be rejected. Your ad may not include excessive or incorrect capitalization. Acronyms, however, may be capitalized. If you believe your ad uses standard and proper capitalization, please disregard this message.");}else if(_L0){_L4=_tx("There is a chance that your ad's title may not meet our capitalization guidelines and could cause your ad to be rejected. Your ad may not include excessive or incorrect capitalization. Acronyms, however, may be capitalized. If you believe your ad uses standard and proper capitalization, please disregard this message.");}else _L4=_tx("There is a chance that your ad's body may not meet our capitalization guidelines and could cause your ad to be rejected. Your ad may not include excessive or incorrect capitalization. Acronyms, however, may be capitalized. If you believe your ad uses standard and proper capitalization, please disregard this message.");DOM.setText(this.warningMessage,_L4);UIAdsUtil.removeHiddenClass(this.warningDiv);}else UIAdsUtil.addHiddenClass(this.warningDiv);}});
function UIAdCreativeBody(id){this.topDiv=$(id);this.bodyDiv=this.topDiv.find('textarea.UIAdCreativeBody_BodyText');this.errorDiv=this.topDiv.find('div.UIAdCreativeBody_Error');this.bodyValue='';if(this.bodyDiv){this.bodyDiv.listen('keyup',this.onBodyChange.bind(this));this.bodyDiv.listen('blur',this.onBodyChange.bind(this));}}copy_properties(UIAdCreativeBody.prototype,{setBodyChangeCallback:function(_L0,_L1){this.bodyChangeCallback=_L0;if(_L1)this.onBodyChange(null,true);},onBodyChange:function(e,_L1){UIAdsUtil.hideError(this.errorDiv,[this.bodyDiv]);if(this.bodyValue!=this.bodyDiv.value){this.bodyValue=this.bodyDiv.value;if(this.bodyChangeCallback)this.bodyChangeCallback(this.bodyValue,_L1);}},displayErrors:function(_L0){var _L1=false;if(_L0.body)_L1=UIAdsUtil.showError(this.errorDiv,_L0.body,[this.bodyDiv]);return _L1;}});
function UIAdCreativeDestination(id,_L1,_L2){this.id=id;this.frameMapping=_L1;this.constants=_L2;this.topDiv=$(this.id);this.destinationUrlDiv=this.topDiv.find('div.UIAdCreativeDestination_ExternalDiv');this.destinationLinkTypeDiv=this.topDiv.find('input[name='+'"UIAdCreativeDestination_LinkType"]');this.frameTypeInput=this.topDiv.find('input[name='+'"UIAdCreativeDestination_FrameType"]');this.websiteUrlDiv=this.topDiv.find('input.UIAdCreativeDestination_WebsiteURL');this.websiteTypeDiv=this.topDiv.find('select.UIAdCreativeDestination_WebsiteType');this.errorDiv=this.topDiv.find('div.UIAdCreativeDestination_LinkErrors');this.contentSelectorDiv=DOM.scry(this.topDiv,'div.UIAdCreativeDestination_InternalDiv');if(this.contentSelectorDiv&&this.contentSelectorDiv.length==1){this.contentSelectorDiv=this.contentSelectorDiv[0];this.fbIdSelector=this.topDiv.find('select.UIAdSocialSources_Selector');var _L3=this.topDiv.find('a[name="UIAdCreativeDestination_ShowInternal"]');if(_L3)_L3.listen('click',this.showContentSelector.bind(this));var _L4=this.topDiv.find('a[name="UIAdCreativeDestination_ShowExternal"]');if(_L4)_L4.listen('click',this.hideContentSelector.bind(this));}if(this.destinationLinkTypeDiv&&this.constants.internal==this.destinationLinkTypeDiv.value)this.showContentSelector();if(this.fbIdSelector)this.fbIdSelector.listen('change',this.onFbidChange.bind(this));if(this.websiteUrlDiv)this.websiteUrlDiv.listen('change',this.onWebsiteUrlChange.bind(this));if(this.websiteTypeDiv)this.websiteTypeDiv.listen('change',this.onWebsiteTypeChange.bind(this));}copy_properties(UIAdCreativeDestination.prototype,{setDestinationLinkTypeChangeCallback:function(_L0,_L1){this.destinationLinkTypeChangeCallback=_L0;if(_L1)this.onDestinationLinkTypeChange(null,true);},setFbidChangeCallback:function(_L0,_L1){this.fbidChangeCallback=_L0;if(_L1&&this.destinationLinkTypeDiv.value==this.constants.internal)this.onFbidChange(null,true);},setWebsiteUrlChangeCallback:function(_L0,_L1){this.websiteUrlChangeCallback=_L0;if(_L1&&(this.destinationLinkTypeDiv.value==this.constants.external))this.onWebsiteUrlChange(null,true);},setWebsiteTypeChangeCallback:function(_L0,_L1){this.websiteTypeChangeCallback=_L0;if(_L1&&(this.destinationLinkTypeDiv.value==this.constants.external))this.onWebsiteTypeChange(null,true);},onDestinationLinkTypeChange:function(e,_L1){if(this.destinationLinkTypeDiv.value==this.constants.internal){this.onFbidChange();}else if(this.destinationLinkTypeChangeCallback)this.destinationLinkTypeChangeCallback(this.destinationLinkTypeDiv.value,this.frameTypeInput.value,_L1);},onFbidChange:function(e,_L1){if(this.fbidChangeCallback&&this.fbIdSelector){var _L2=this.fbIdSelector.options[this.fbIdSelector.selectedIndex].text;this.frameTypeInput.value=this.frameMapping[this.fbIdSelector.value];this.fbidChangeCallback(this.fbIdSelector.value,_L2,this.frameMapping[this.fbIdSelector.value],_L1);}},onWebsiteUrlChange:function(e,_L1){UIAdsUtil.hideError(this.errorDiv,[this.websiteUrlDiv,this.websiteTypeDiv]);if(this.websiteUrlChangeCallback){this.websiteUrlDiv.value=this.websiteUrlDiv.value.replace(/^(http|https)\:\/\//,'');this.websiteUrlChangeCallback(this.websiteUrlDiv.value,_L1);}},onWebsiteTypeChange:function(e,_L1){if(this.websiteTypeChangeCallback)this.websiteTypeChangeCallback(this.websiteTypeDiv.value,_L1);},showContentSelector:function(){if(this.destinationUrlDiv)UIAdsUtil.addHiddenClass(this.destinationUrlDiv);if(this.contentSelectorDiv)UIAdsUtil.removeHiddenClass(this.contentSelectorDiv);if(this.destinationLinkTypeDiv)this.destinationLinkTypeDiv.value=this.constants.internal;this.onDestinationLinkTypeChange();return false;},hideContentSelector:function(){if(this.contentSelectorDiv)UIAdsUtil.addHiddenClass(this.contentSelectorDiv);if(this.destinationUrlDiv)UIAdsUtil.removeHiddenClass(this.destinationUrlDiv);if(this.destinationLinkTypeDiv)this.destinationLinkTypeDiv.value=this.constants.external;this.frameTypeInput.value=this.constants.frame_type_default;this.onDestinationLinkTypeChange();return false;},displayErrors:function(_L0){var _L1=false;if(_L0.link)_L1=UIAdsUtil.showError(this.errorDiv,_L0.link,[this.websiteUrlDiv,this.websiteTypeDiv]);return _L1;}});
function UIAdCreativeImage(id){this.id=id;this.topDiv=$(this.id);this.progressElem=this.topDiv.find('div.UIAdCreativeImage_UploadProgress');this.removeElem=this.topDiv.find('a.AdsCreativeRemoveImageLink');this.errorDiv=this.topDiv.find('div.UIAdCreativeImage_InvalidMsg');this.imageUrlElem=this.topDiv.find('input[name="UIAdCreativeImage_ImageUrl"]');this.imagePathElem=this.topDiv.find('input[name="UIAdCreativeImage_ImagePath"]');this.imageVolElem=this.topDiv.find('input[name="UIAdCreativeImage_ImageVolume"]');this.imageWElem=this.topDiv.find('input[name="UIAdCreativeImage_ImageWidth"]');this.imageHElem=this.topDiv.find('input[name="UIAdCreativeImage_ImageHeight"]');this.isPermanentElem=this.topDiv.find('input[name="UIAdCreativeImage_IsPermanent"]');this.removeElem.listen('click',this.removeImage.bind(this));}copy_properties(UIAdCreativeImage.prototype,{setImageChangeCallback:function(_L0,_L1){this.imageChangeCallback=_L0;if(_L1)this.onImageChange(null,true);},onImageChange:function(e,_L1){if(this.imageChangeCallback)this.imageChangeCallback(this.imageUrlElem.value,_L1);},onFileUpload:function(_L0){UIAdsUtil.addHiddenClass(this.errorDiv);UIAdsUtil.removeHiddenClass(this.progressElem);if(_L0){UIAdsUtil.addHiddenClass(_L0);if(_L0.form)_L0.form.submit();}},removeImage:function(){this.imageUrlElem.value='';this.imagePathElem.value='';this.imageVolElem.value='';this.imageWElem.value='';this.imageHElem.value='';this.isPermanentElem.value=0;UIAdsUtil.addHiddenClass(this.removeElem);this.onImageChange();},saveUploadedImage:function(_L0,src,vol,w,h){UIAdsUtil.addHiddenClass(this.progressElem);UIAdsUtil.removeHiddenClass(this.removeElem);this.imagePathElem.value=_L0;this.imageUrlElem.value=src;this.imageVolElem.value=vol;this.imageWElem.value=w;this.imageHElem.value=h;this.isPermanentElem.value=0;this.onImageChange();},saveUploadError:function(_L0){UIAdsUtil.addHiddenClass(this.progressElem);UIAdsUtil.removeHiddenClass(this.errorDiv);}});
function UIAdCreativeTitle(id){this.id=id;this.topDiv=$(this.id);this.titleDiv=this.topDiv.find('input.UIAdCreativeTitle_TitleText');this.fixedTitleDiv=this.topDiv.find('input.UIAdCreativeTitle_FixedTitleText');this.titleWarningSpan=this.topDiv.find('span.AdsCreateSectionSubtext');this.errorDiv=this.topDiv.find('div.UIAdCreativeTitle_Error');this.titleValue='';if(this.titleDiv){this.titleDiv.listen('keyup',this.onTitleChange.bind(this));this.titleDiv.listen('blur',this.onTitleChange.bind(this));}}copy_properties(UIAdCreativeTitle.prototype,{setTitleChangeCallback:function(_L0,_L1){this.titleChangeCallback=_L0;if(_L1)this.onTitleChange(null,true);},onTitleChange:function(e,_L1){UIAdsUtil.hideError(this.errorDiv,[this.titleDiv]);if(this.titleValue!=this.titleDiv.value){this.titleValue=this.titleDiv.value;if(this.titleChangeCallback)this.titleChangeCallback(this.titleDiv.value,_L1);}},showFixedTitle:function(_L0){UIAdsUtil.hideError(this.errorDiv,[this.titleDiv]);UIAdsUtil.addHiddenClass(this.titleDiv,this.titleWarningSpan);UIAdsUtil.removeHiddenClass(this.fixedTitleDiv);this.fixedTitleDiv.setAttribute('disabled',true);this.fixedTitleDiv.value=_L0;this.titlevalue=_L0;},hideFixedTitle:function(){UIAdsUtil.addHiddenClass(this.fixedTitleDiv);UIAdsUtil.removeHiddenClass(this.titleDiv,this.titleWarningSpan);},displayErrors:function(_L0){var _L1=false;if(_L0.title)_L1=UIAdsUtil.showError(this.errorDiv,_L0.title,[this.titleDiv]);return _L1;}});
function AdCreateSection(){this.ui_logs={};}copy_properties(AdCreateSection.prototype,{initLogs:function(_L0){var _L1=_L1(_L0);for(var i=0;i<_L1.length;i++)this.ui_logs[_L1[i]]=JSON.decode(_L0[_L1[i]]);},addLog:function(_L0,_L1){if(!this.ui_logs[_L0]){this.ui_logs[_L0]=[_L1];}else this.ui_logs[_L0].push(_L1);},onSubmit:function(){var k=keys(this.ui_logs);var _L1={};for(var i=0;i<k.length;i++){var key=k[i];_L1[key]=JSON.encode(this.ui_logs[key]);}return _L1;}});
var intlNumUtils={normalizeNumberString:function(num,_L1,_L2){return Number(num.split(_L1).join('').split(_L2).join('.'));},roundUp:function(num){if(num<100)return Math.ceil(num);if(num<1000)return Math.ceil(num/10)*10;if(num<10000)return Math.ceil(num/100)*100;return Math.ceil(num/1000)*1000;},getIntegerString:function(num,_L1){var str=String(num);var _L3=/(\d+)(\d{3})/;while(_L3.test(str))str=str.replace(_L3,'$1'+_L1+'$2');return str;}};
function UIAdDelivery(id,_L1){this.parent.construct(this);this.id=id;this.stepType='ad_delivery';this.elem=$(id);this.campaigns={};this.currencyInfo={};this.directSales=false;this.dailyBudgetChanged=false;this.CPCBidChanged=false;this.CPMBidChanged=false;this.editingCreative=_L1;this.stepType='ad_delivery';this.timezoneInfo={};this.timezoneNameMap={};this.CPMIntervalMin=null;this.CPMIntervalMax=null;this.CPCIntervalMin=null;this.CPCIntervalMax=null;this.audienceNumber=null;this.decimalSymbol=null;this.commaSymbol=null;this._CPM_placements=[this.PLACEMENTS.RIGHT];if(this.directSales){this._CPM_placements.push(this.PLACEMENTS.NEWS_FEED);this._CPM_placements.push(this.PLACEMENTS.OWL);}this._id('cpc_bid_value').listen('change',function(){this.CPCBidChanged=true;}.bind(this));this._id('cpm_bid_value').listen('change',function(){this.CPMBidChanged=true;}.bind(this));if(this._ge('daily_budget'))this._id('daily_budget').listen('change',function(){this.dailyBudgetChanged=true;}.bind(this));this.updateInventoryAndBidEstimates();AdCreate_PageController.getInstance().addStepController(this);}UIAdDelivery.extend('AdCreateSection');copy_properties(UIAdDelivery.prototype,{IMPRESSIONS_MINIMUM:1,IMPRESSIONS_EXTRA:2,ESTIMATED_CTR:.0046,PLACEMENTS:{RIGHT:'right_side',OWL:'owl',BANNERS:'banners',NEWS_FEED:'news_feed'},_id:function(_L0,_L1){var id=this.id+'_'+_L0;return this.elem.find('#'+id);},_idCPX:function(_L0,_L1){return this._id((_L0?'cpm':'cpc')+'_'+_L1);},_ge:function(_L0){var id=this.id+'_'+_L0;return ge(id);},_class:function(_L0){return 'UIAdDelivery_'+_L0;},setTimezoneInfo:function(_L0,_L1){this.timezoneInfo=_L0;this.timezoneNameMap=_L1;return this;},initCountryListeners:function(){this._id('country_code').listen('change',this._onCountryChange.bind(this));return this;},_onCountryChange:function(){var _L0=get_form_select_value(this._id('country_code'));var _L1=this.timezoneInfo[_L0];var _L2=this._ge('country_code');var _L3=this._ge('timezone_id');for(var i=_L3.options.length-1;i>=0;i--)DOM.remove(_L3.options[i]);for(var i=0;i<_L1.length;i++)_L3.options[i]=new Option(_L1[i].label,_L1[i].value);this.setTimezoneID(_L1[0].value);},initTimezoneListeners:function(){this._id('timezone_id').listen('change',this._onTimezoneChange.bind(this));return this;},_onTimezoneChange:function(){var _L0=get_form_select_value(this._id('timezone_id'));this.setTimezoneID(_L0);},setTimezoneID:function(_L0){AdCreate_PageController.getInstance().timezone_id=_L0;var _L1=this.timezoneNameMap[_L0];var _L2='span.'+this._class('AccountTimezoneDisplayName');var _L3=DOM.scry($(this.id),_L2);for(var i=0;i<_L3.length;i++)DOM.setContent(_L3[i],HTML(_L1));return this;},setCurrencyInfo:function(_L0){this.currencyInfo=_L0;return this;},initCurrencyListeners:function(){var id=this.id+'_currency_code';var _L1=ge(id);if(_L1)_L1.listen('change',this._onCurrencyChange.bind(this));return this;},_onCurrencyChange:function(){var _L0=get_form_select_value(this._id('currency_code'));this.setCurrency(_L0);},setCurrency:function(_L0){var _L1=AdCreate_PageController.getInstance().currency;var _L2=_L0!=_L1;AdCreate_PageController.getInstance().currency=_L0;var _L3=this.currencyInfo[_L0];var _L4=DOM.scry($(this.stepType),'span.'+this._class('UpdatableCurrencyCode'));for(var i=0;i<_L4.length;i++)DOM.setContent(_L4[i],HTML(_L0));var _L6=_L3.symbol;var _L7=DOM.scry($(this.stepType),'span.'+this._class('UpdatableCurrencySymbol'));for(var i=0;i<_L7.length;i++)DOM.setContent(_L7[i],HTML(_L6));var _L8=this._ge('min_daily_budget');if(_L8)DOM.setContent(_L8,_L3.min_daily_budget);DOM.setContent(this._id('cpm_min_bid'),_L3.min_cpm_bid_right_side);DOM.setContent(this._id('cpc_min_bid'),_L3.min_cpc_bid);if(!this.dailyBudgetChanged&&this._ge('daily_budget'))this._id('daily_budget').value=_L3.default_daily_budget==0?'':_L3.default_daily_budget;if(_L2)this.updateInventoryAndBidEstimates();return this;},initCampaignOptionHandler:function(){var _L0=DOM.scry($(this.id),'input[name="new_or_existing"]');for(var i=0;i<_L0.length;i++){_L0[i].listen('click',this._onCampaignOptionChange.bind(this,_L0[i].value));if(_L0[i].checked)this._onCampaignOptionChange(_L0[i].value);}return this;},initBidToInventoryEstimator:function(){var _L0=['cpm_bid_value','cpc_bid_value','daily_budget'];for(var ii=0;ii<_L0.length;ii++){var id=_L0[ii];var _L3=this._ge(id);if(_L3)this._id(id).listen('change',this.calculateBidToInventoryEstimate.bind(this));}return this;},calculateBidToInventoryEstimate:function(){if(this.directSales||this.editingCreative)return;this._id('cpc_inventory_estimate').addClass('hidden');this._id('cpm_inventory_estimate').addClass('hidden');var _L0=this._ge('cpm_radio');var _L1=this._ge('cpc_radio');if(!_L1)return;var _L2=!_L1.checked;if(_L2&&(!_L0||!_L0.checked))return;if(!this.decimalSymbol||!this.commaSymbol)return;var _L3=intlNumUtils.normalizeNumberString(this._id('daily_budget').value,this.commaSymbol,this.decimalSymbol);var _L4=intlNumUtils.normalizeNumberString(this._idCPX(_L2,'bid_value').value,this.commaSymbol,this.decimalSymbol);if(!_L3||!_L4)return;var _L5=this._ge('existing_cmpn');if(_L5&&_L5.checked)return;var _L6=_L2?this.CPMIntervalMin:this.CPCIntervalMin;var _L7=_L2?this.CPMIntervalMax:this.CPCIntervalMax;if(!_L6||!_L7||_L4<_L6)return;_L4=Math.min(_L4,_L7);var _L8=(_L4-_L6);var _L9=(_L7-_L6);var _La=(_L8/_L9);var _Lb=this.IMPRESSIONS_MINIMUM+(_La*this.IMPRESSIONS_EXTRA);var _Lc=0;var _Ld=0;if(_L2){_Lc=this.audienceNumber*_Lb;_Ld=_L3/_L4*1000;}else{_Lc=_Lb*this.audienceNumber*this.ESTIMATED_CTR;_Ld=_L3/_L4;}var _Le=this.estimateAndFormat(_Ld,_Lc);var _Lf='<strong>'+_Le+'</strong>';_Lf=_L2?_tx("Estimate: {num} impressions per day",{'num':_Lf}):_tx("Estimate: {num} clicks per day",{'num':_Lf});DOM.setContent(this._idCPX(_L2,'inventory_estimate'),HTML(_Lf));this._idCPX(_L2,'inventory_estimate').removeClass('hidden');},estimateAndFormat:function(_L0,_L1){var _L2=Math.min(_L0,_L1);var _L3=intlNumUtils.roundUp(_L2);return intlNumUtils.getIntegerString(_L3,this.commaSymbol);},_onCampaignOptionChange:function(_L0){UIAdsUtil.addHiddenClass(this._id('new_info'),this._id('existing_info'));UIAdsUtil.removeHiddenClass(this._id(_L0));this.calculateBidToInventoryEstimate();},initDurationHandler:function(){if(!this.editingCreative){var _L0=DOM.scry($(this.id),'input[name="duration"]');for(var i=0;i<_L0.length;i++)_L0[i].listen('click',this._onDurationChange.bind(this,_L0[i].value));$(this.id+'_duration_continuous').checked=true;}var _L2=ge(this.id+'_duration_continuous');if(_L2)_L2.checked=true;return this;},initCampaignListeners:function(_L0){this.campaigns=_L0;var _L1=this._ge('campaign_id');if(!_L1)return;this._id('campaign_id').listen('change',this._onCampaignChange.bind(this));return this;},_onCampaignChange:function(){var _L0=this._ge('campaign_id');if(!_L0)return;var _L1=get_form_select_value(this._id('campaign_id'));var _L2=this.campaigns[_L1].budget;var _L3=this.campaigns[_L1].schedule;DOM.setText(this._id('campaign_budget'),_L2);DOM.setText(this._id('campaign_schedule'),_L3);},_onDurationChange:function(_L0){var _L1=(_L0=='continuous')?'addClass':'removeClass';this._id('CampaignTimespan')[_L1]('hidden');},initPricingTypeHandler:function(){var _L0=DOM.scry($(this.id),'input[name="bid_type"]');for(var i=0;i<_L0.length;i++)_L0[i].listen('click',this._onPricingTypeChange.bind(this,_L0[i].value));return this;},setCPCBidChanged:function(_L0){this.CPCBidChanged=_L0;return this;},setCPMBidChanged:function(_L0){this.CPMBidChanged=_L0;return this;},_onFCPMChange:function(){if(this._id('corp_fixed_cpm').checked)this._setPricingToCPM();},_setPricingToCPM:function(){DOM.find($(this.id),'div.'+this._class('CPCInfo')).addClass('hidden');DOM.find($(this.id),'div.'+this._class('CPMInfo')).removeClass('hidden');this._id('cpm_radio').checked=true;return this;},_onPricingTypeChange:function(_L0){var _L1=DOM.find($(this.id),'div.'+this._class('CPCInfo'));var _L2=DOM.find($(this.id),'div.'+this._class('CPMInfo'));UIAdsUtil.addHiddenClass(_L1,_L2);this.calculateBidToInventoryEstimate();switch(_L0){case 'cpm':UIAdsUtil.removeHiddenClass(_L2);break;case 'cpc':UIAdsUtil.removeHiddenClass(_L1);default:if(this._ge('corp_fixed_cpm'))this._id('corp_fixed_cpm').checked=false;break;}},updateInventoryAndBidEstimates:function(){var _L0=get_targeting_array(true);copy_properties(_L0,{bid_estimate:1,currency:AdCreate_PageController.getInstance().currency});var _L1=$(this.id).scry('img.'+this._class('BidEstimateProgress'));_L1.removeClass('hidden');show($('inventory_waiting'));for(var i=0;i<this._CPM_placements.length;i++){var pl=this._CPM_placements[i];var id='cpm_bid_estimate_'+pl;hide(this._id(id));}hide(this._id('cpc_bid_estimate'));hide(this._ge('audience_size_phrase'));CSS.setStyle($('reach_sentence'),'visibility','hidden');var _L5=function(r){var _L8=r.getPayload();if(!_L8.BidEstimate)return;hide($('inventory_waiting'));DOM.setContent($('audience_size'),HTML(_L8.UserCountString));var _L9=_L8.sentence_info;var _La=[];if(_L9.length>0){_La.push('<ul class="ads_estimate_lines">');for(var i=0;i<_L9.length;i++){var _Lb=_L9[i];_La.push('<li><span class="targeting_term_line">'+_Lb+'</span></li>');}_La.push('</ul>');}DOM.setContent($('reach_sentence'),HTML(_La.join("\n")));show($('reach_sentence'));CSS.setStyle($('reach_sentence'),'visibility','visible');show(ge('audience_size_phrase'));for(var i=0;i<this._CPM_placements.length;i++){var pl=this._CPM_placements[i];var id='cpm_bid_estimate_'+pl;var min=_L8.BidEstimate[pl].cpm_min;var max=_L8.BidEstimate[pl].cpm_max;DOM.setText(this._id(id),this._getBidSuggestionString(min,max));if(pl==this.getSelectedPlacement())show(this._id(id));}var min=_L8.BidEstimate.right_side.cpc_min;var max=_L8.BidEstimate.right_side.cpc_max;var _Le='cpc_bid_estimate';DOM.setText(this._id(_Le),this._getBidSuggestionString(min,max));show(this._id(_Le));var _Lf=this._id('cpc_bid_value');if(_Lf.value==''||!this.CPCBidChanged)_Lf.value=_L8.BidEstimate.right_side.cpc_mid;var _L10=this._id('cpm_bid_value');if(_L10.value==''||!this.CPMBidChanged){var _L11=_L8.BidEstimate[this.getSelectedPlacement()];if(_L11&&_L11.cpm_mid)_L10.value=_L11.cpm_mid;}this.CPCIntervalMin=_L8.cpc_interval_min;this.CPCIntervalMax=_L8.cpc_interval_max;this.CPMIntervalMin=_L8.cpm_interval_min;this.CPMIntervalMax=_L8.cpm_interval_max;this.audienceNumber=_L8.UserCountInt;this.commaSymbol=_L8.intl_number_data.C;this.decimalSymbol=_L8.intl_number_data.D;this.calculateBidToInventoryEstimate();_L1.addClass('hidden');}.bind(this);var _L6=function(r){hide(ge('inventory_waiting'));CSS.setStyle($('reach_sentence'),'visibility','hidden');hide(ge("audience_size_phrase"));for(var i=0;i<this._CPM_placements.length;i++){var pl=this._CPM_placements[i];var id='cpm_bid_estimate_'+pl;DOM.setText(this._id(id),this._getBidSuggestionString(0,0));if(pl==this.getSelectedPlacement())show(this._id(id));}show(this._id('cpc_bid_estimate'));DOM.setText(this._id('cpc_bid_estimate'),this._getBidSuggestionString(0,0));_L1.addClass('hidden');}.bind(this);new AsyncRequest().setURI('/ajax/inventory_estimator.php').setData(_L0).setReadOnly(true).setHandler(_L5).setErrorHandler(_L6).send();},_getBidSuggestionString:function(low,_L1){var _L2='';if((low==0)||(_L1==0)){_L2=_tx("No Data");}else _L2=_tx("{low} - {high}",{'low':low,'high':_L1})+' '+AdCreate_PageController.getInstance().currency;return _L2;},getSelectedPlacement:function(){var _L0='';if(!this.directSales||this._id(this.PLACEMENTS.RIGHT).checked){_L0=this.PLACEMENTS.RIGHT;}else if(this._id(this.PLACEMENTS.OWL).checked){_L0=this.PLACEMENTS.OWL;}else if(this._id(this.PLACEMENTS.BANNERS).checked){_L0=this.PLACEMENTS.BANNERS;}else _L0=this.PLACEMENTS.RIGHT;return _L0;},initDirectSalesHandlers:function(){this.directSales=true;var _L0=DOM.scry($(this.id),'input.'+this._class('ImpControlType'));for(var i=0;i<_L0.length;i++){var id=_L0[i].id;_L0[i].listen('click',this._onImpCtrlChange.bind(this,id));if(_L0[i].checked)this._impCtrlAdjustVisibilities(id);}var _L3=DOM.scry($(this.id),'input.'+this._class('PlacementType'));for(var i=0;i<_L3.length;i++){var _L4=_L3[i].value;_L3[i].listen('click',this._onPlacementChange.bind(this,_L4));if(_L3[i].checked)this._placementAdjustVisibilities(_L4);}this._id('corp_fixed_cpm').listen('click',this._onFCPMChange.bind(this));if(this._ge('lifetime_budget')&&this._ge('daily_budget')){this._id('lifetime_budget').listen('blur',function(){this._id('daily_budget').value='';}.bind(this));this._id('daily_budget').listen('blur',function(){this._id('lifetime_budget').value='';}.bind(this));}return this;},_onPlacementChange:function(_L0){this._id('no_show_percentage').value=0;if(_L0==this.PLACEMENTS.OWL||_L0==this.PLACEMENTS.RIGHT)this._id('no_show_percentage').value=1;this._placementAdjustVisibilities(_L0);},_placementAdjustVisibilities:function(_L0){var _L1=['banner_options','imp_ctrl_options','freq_cap_value_select','reach_block_value_select'];for(var i=0;i<_L1.length;i++){var id=_L1[i];this._id(id).addClass('hidden');}if(_L0==this.PLACEMENTS.OWL||_L0==this.PLACEMENTS.RIGHT){this._id('imp_ctrl_options').removeClass('hidden');if(this._id('freq_cap').checked)this._id('freq_cap_value_select').removeClass('hidden');if(this._id('reach_block').checked)this._id('reach_block_value_select').removeClass('hidden');}else if(_L0=='banners'){this._id('banner_options').removeClass('hidden');this._id('freq_cap_value_select').removeClass('hidden');}var _L4=this.getSelectedPlacement();var _L5=[this.PLACEMENTS.RIGHT,this.PLACEMENTS.NEWS_FEED,this.PLACEMENTS.OWL];for(var i=0;i<_L5.length;i++){var id='cpm_bid_estimate_'+_L5[i];if(_L4==_L5[i]){show(this._id(id));if(this._minCPMInfo)this._id('cpm_min_bid').value=this._minCPMInfo[_L5[i]];}else hide(this._id(id));}},setMinCPMinfo:function(_L0){this._minCPMInfo=_L0;return this;},_onImpCtrlChange:function(_L0){if(_L0==this._id('reach_block').id||_L0==this._id('road_block').id){this._id('corp_fixed_cpm').checked=true;this._setPricingToCPM();}this._impCtrlAdjustVisibilities(_L0);},_impCtrlAdjustVisibilities:function(_L0){var _L1=['freq_cap_value_select','reach_block_value_select'];for(var i=0;i<_L1.length;i++){var id=_L1[i];this._id(id).addClass('hidden');}if(_L0==this._id('freq_cap').id){this._id('freq_cap_value_select').removeClass('hidden');}else if(_L0==this._id('reach_block').id)this._id('reach_block_value_select').removeClass('hidden');},_transformKeyToClassname:function(key){var _L1=key.split('_');for(var ii=0;ii<_L1.length;ii++){var _L3=_L1[ii].charAt(0).toUpperCase()+_L1[ii].substring(1);_L1[ii]=_L3;}return _L1.join('');},display_errors:function(_L0){var _L1=false;var _L2=['bid','campaign','placement','holdout_offset','holdout_percent','priority','imp_control'];for(var i=0;i<_L2.length;i++){var _L4=_L2[i];var _L5=_L0[_L4];var _L6=this._class('ErrorBox_'+this._transformKeyToClassname(_L4)+'Errors');var _L7=DOM.scry($(this.id),'.'+_L6);if(!_L7[0])continue;_L7=_L7[0];_L1=show_error_section(_L5,_L7,[])||_L1;}var _L8=$(this.stepType+'_generic_errors');var _L9=_L0.generic;_L1=show_error_section(_L9,_L8,[])||_L1;if(!_L1)_L1=show_fallback_error_section(_L0,_L8);var _La=DOM.find($(this.stepType),'h2.step_header');if(_L1){CSS.addClass(_La,'step_header_error');return this.stepType;}else return null;}});
function AdCreate_Adspace(id,_L1){this.parent.construct(this);this.id=id;this.step_type='creative';this.creativeController=_L1;this.creativeController.parentController=this;this.creativeController.updateHelpSection();AdCreate_PageController.getInstance().addStepController(this);}AdCreate_Adspace.extend('AdCreateSection');copy_properties(AdCreate_Adspace.prototype,{FRAME_TYPE_NONE:0,FRAME_TYPE_FAN:5001,FRAME_TYPE_RSVP:5002,updateHelp:function(_L0,_L1){if(!_L1)return;var _L2={};_L2[_L1.FRAME_TYPE_NONE]='standard_unit_help';_L2[_L1.FRAME_TYPE_FAN]='fan_unit_help';_L2[_L1.FRAME_TYPE_RSVP]='rsvp_unit_help';var _L3=$(_L1.id);for(var _L4 in _L2){if(_L4==_L0)continue;var _L5=DOM.scry(_L3,'.step_help .'+_L2[_L4]);for(var i=0;i<_L5.length;i++)CSS.addClass(_L5[i],'hidden');}if(_L2[_L0]){var _L7=DOM.scry(_L3,'.step_help .'+_L2[_L0]+'.hidden');for(var i=0;i<_L7.length;i++)CSS.removeClass(_L7[i],'hidden');}return true;},display_errors:function(_L0){var _L1=$(this.id+'_generic_errors');var _L2=show_error_section(_L0.generic,_L1,[]);_L2=this.creativeController.displayErrors(_L0);if(!_L2)_L2=show_fallback_error_section(_L0,_L1);var _L3=DOM.find($(this.id),'h2.step_header');if(_L2){CSS.addClass(_L3,'step_header_error');return this.id;}else return null;}});
function AdCreate_Targeting(id){this.parent.construct(this);this.id=id;this.expanded_keywords={};this.suggested_keywords=[];this.added_keywords=[];this.warningDiv=DOM.scry(ge('targeting_editor'),'div.UIAdCreation_WarningDiv');this.warningMessage=DOM.scry(ge('targeting_editor'),'span.UIAdConnections_WarningMessage');this._update_inventory_estimate_soon();AdCreate_PageController.getInstance().addStepController(this);}AdCreate_Targeting.extend('AdCreateSection');copy_properties(AdCreate_Targeting.prototype,{initTargetingInputs:function(){var _L0=get_all_form_inputs(ge('targeting_editor'));for(var i=0;i<_L0.length;++i){var inp=_L0[i];if(inp.type=='checkbox'||inp.type=='radio'){Event.listen(inp,'click',this._update_inventory_estimate_soon.bind(this));}else Event.listen(inp,'change',this._update_inventory_estimate_soon.bind(this));}$('college_years_min').listen('change',this._update_graduation_years.bind(this));$('college_years_max').listen('change',this._update_graduation_years.bind(this));var _L3=ge('radius');if(_L3)Event.listen(_L3,'change',function(){if(!$('include_radius').checked)$('include_radius').checked=true;}.bind(this));var _L4=ge('friends_of_connections');if(_L4){_L4.tokenizer.ontokenadded=chain(_L4.tokenizer.ontokenadded,this._check_connections_constraint.bind(this));_L4.tokenizer.ontokenremoved=chain(_L4.tokenizer.ontokenremoved,this._check_connections_constraint.bind(this));}var _L5=ge('connections');if(_L5){_L5.tokenizer.ontokenadded=chain(_L5.tokenizer.ontokenadded,this._check_connections_constraint.bind(this));_L5.tokenizer.ontokenremoved=chain(_L5.tokenizer.ontokenremoved,this._check_connections_constraint.bind(this));}var _L6=ge('excluded_connections');if(_L6){_L6.tokenizer.ontokenadded=chain(_L6.tokenizer.ontokenadded,this._check_connections_constraint.bind(this));_L6.tokenizer.ontokenremoved=chain(_L6.tokenizer.ontokenremoved,this._check_connections_constraint.bind(this));}var _L7=DOM.scry(ge('targeting_editor'),'div.tokenizer');for(var i=0;i<_L7.length;i++){var tok=_L7[i];tok.tokenizer.ontokenadded=chain(tok.tokenizer.ontokenadded,this._update_inventory_estimate_soon.bind(this));tok.tokenizer.ontokenremoved=chain(tok.tokenizer.ontokenremoved,this._update_inventory_estimate_soon.bind(this));}DOM.scry(ge('countries'),'.inline_placeholder').setStyle('display','none');if(ge('keyword_expansion')){var _L9=$('keywords');_L9.tokenizer.ontokenadded=chain(_L9.tokenizer.ontokenadded,this._update_keyword_expansion.bind(this));_L9.tokenizer.ontokenremoved=chain(_L9.tokenizer.ontokenremoved,this._update_keyword_expansion.bind(this));var _La=DOM.find($('keyword_expansion'),'a');_La.listen('click',this._insert_keywords.bind(this));hide(_La);var _Lb=$('keywords').tokenizer.get_token_values();if(_Lb.length>0)this._update_keyword_expansion();}},_check_connections_constraint:function(){var _L0=DOM.scry(ge('connections'),'input.fb_token_hidden_input');if(_L0.length==0){UIAdsUtil.addHiddenClass(this.warningDiv[0]);return;}var _L1=null;var _L2=DOM.scry(ge('friends_of_connections'),'input.fb_token_hidden_input');if(this._hasOverlap(_L0,_L2)){_L1=_tx("You have chosen to target your ad to users already connected to and users whose friends already connected to the same Page, Application, Group or Event.  Choosing both filters excludes everyone. If you wish to target all of your connections and their friends, we recommend creating two ads. One ad will target your Connections and the other will target Friends of connections.");}else{var _L3=DOM.scry(ge('excluded_connections'),'input.fb_token_hidden_input');if(this._hasOverlap(_L0,_L3))_L1=_tx("You have chosen to target your ad to users already connected to and users not connected to the same Page, Application, Group or Event. Choosing both filters excludes everyone. If you wish to target both groups, we recommend creating two ads. One ad will target your connections and the other will target users not connected to your Page, Application, Group or Event.");}if(_L1){DOM.setText(this.warningMessage[0],_L1);UIAdsUtil.removeHiddenClass(this.warningDiv[0]);}else UIAdsUtil.addHiddenClass(this.warningDiv[0]);},_hasOverlap:function(_L0,_L1){if(_L0.length>0&&_L1.length>0)for(var i=0;i<_L0.length;++i)for(var j=0;j<_L1.length;++j)if(_L0[i].value==_L1[j].value)return true;return false;},initLogs:function(_L0){if(_L0.kw_suggester){kw_log=JSON.decode(_L0.kw_suggester);this.suggested_keywords=kw_log[1];this.added_keywords=kw_log[2];_L0.kw_suggester='';}this.parent.initLogs(_L0);},_insert_keywords:function(){var _L0=$('keywords');var _L1=$('keyword_expansion');var _L2=DOM.find(_L1,'a');hide(_L2);var _L3=DOM.scry(_L1,'div.checkbox input[type="checkbox"]');for(var i=0;i<_L3.length;i++)if(_L3[i].checked){var obj=this.expanded_keywords[_L3[i].value];new token(obj,_L0.tokenizer);this.added_keywords.push(_L3[i].value);}this._update_inventory_estimate_soon();this._update_keyword_expansion();return false;},_select_expanded_keyword:function(){var _L0=$('keyword_expansion');var _L1=DOM.find(_L0,'a');var _L2=DOM.scry(_L0,'div.checkbox input[type="checkbox"]');var _L3=false;for(var i=0;i<_L2.length;i++)if(_L2[i].checked){_L3=true;break;}if(_L3){show(_L1);}else hide(_L1);},_update_keyword_expansion:function(){var _L0={'keywords':$('keywords').tokenizer.get_token_values()};var _L1=$('keyword_expansion');hide(_L1);if(_L0.keywords.length==0){hide($('keyword_expansion'));return;}var _L2=function(_L4){var _L5=_L4.getPayload();this.expanded_keywords={};if(_L5.length>0){var _L6=DOM.find($('keyword_expansion'),'div.checkbox');DOM.empty(_L6);var _L7=[];for(var i=0;i<_L5.length;i++){this.suggested_keywords.push(_L5[i].i);var _L9='keyword_id_'+_L5[i].i;var _La=$N('label',{htmlFor:_L9});DOM.setContent(_La,_L5[i].t);var _Lb=$N('input',{type:'checkbox',className:'inputcheckbox',value:_L5[i].i,id:_L9});this.expanded_keywords[_L5[i].i]=_L5[i];Event.listen(_Lb,'click',this._select_expanded_keyword.bind(this));_L7.push(_Lb);_L7.push(_La);_L7.push($N('br'));}DOM.setContent(_L6,_L7);show($('keyword_expansion'));}};var _L3=function(){hide($('keyword_expansion'));};new AsyncRequest().setURI(muffinize('/muffins/ajax/keyword_expansion.php')).setData(_L0).setReadOnly(true).setHandler(_L2.bind(this)).setErrorHandler(_L3.bind(this)).send();},_update_inventory_estimate_soon:function(){(function(){var _L0=AdCreate_PageController.getInstance().getStepController('ad_delivery');if(_L0){_L0.updateInventoryAndBidEstimates();}else console.error('failed to find ad_delivery step controller');}).defer();},_update_graduation_years:function(e){var _L1=$('college_years_min');var _L2=$('college_years_max');if(_L1.value>_L2.value||(0==_L1.value&&_L2.value>0))if(e.getTarget()==_L1){_L2.value=_L1.value;}else _L1.value=_L2.value;},display_errors:function(_L0){var _L1=false;var _L2=['location','regions','cities','age','sex','keyword','education','workplace','relationship','interested_in','cluster','app_type','page_type','locale','connections','excluded_connections'];for(var i=0;i<_L2.length;i++){var _L4=_L2[i];var id=_L4+'_errors';if(!ge(id))continue;_L1=show_error_section(_L0[_L4],$(id),[])||_L1;}var _L6=$(this.id+'_generic_errors');_L1=show_error_section(_L0.generic,_L6,[])||_L1;if(!_L1)_L1=show_fallback_error_section(_L0,_L6);var _L7=DOM.find($(this.id),'h2.step_header');if(_L1){CSS.addClass(_L7,'step_header_error');return this.id;}else return null;},onSubmit:function(){var _L0=unique($('keywords').tokenizer.get_token_values());this.suggested_keywords=unique(this.suggested_keywords);this.added_keywords=array_intersect(unique(this.added_keywords),_L0);this.ui_logs.kw_suggester=[_L0,this.suggested_keywords,this.added_keywords];return this.parent.onSubmit();}});
function AdCreateTextInputControl(_L0,_L1){copy_properties(this,{warningarea:ge(_L1)});return this.parent.construct(this,_L0);}AdCreateTextInputControl.extend('TextInputControl');copy_properties(AdCreateTextInputControl.prototype,{getMaxLength:function(){return this.maxLength;},onupdate:function(){this.parent.onupdate();var _L0=this.getRoot();if(_L0){var _L1=_L0.value;var _L2=_L1.length;var _L3=this.getMaxLength();var _L4=_L3-_L2;var _L5=this.getWarningArea();if(_L5)DOM.setContent(_L5,_L4);}},getWarningArea:function(){return this.warningarea;}});
function ad_targeting_connections_source(_L0){this.parent.construct(this,[]);this.params_=JSON.decode(_L0);if(!ad_targeting_connections_source.locales){ad_targeting_connections_source.locales=[];}else for(var i=0,il=ad_targeting_connections_source.locales.length;i<il;i++){this.values=ad_targeting_connections_source.locales[i].v;this.index=ad_targeting_connections_source.locales[i].i;this.ready();return;}new AsyncRequest().setURI(muffinize('/muffins/ajax/typeahead_connections.php')).setReadOnly(true).setData(this.params_).setHandler(function(_L3){this.values=_L3.getPayload();this.build_index();ad_targeting_connections_source.locales.push({v:this.values,i:this.index});this.ready();}.bind(this)).send();}ad_targeting_connections_source.extend('custom_source');
function ad_targeting_locale_source(act){this.parent.construct(this,[]);if(!ad_targeting_locale_source.locales){ad_targeting_locale_source.locales=[];}else for(var i=0,il=ad_targeting_locale_source.locales.length;i<il;i++){this.values=ad_targeting_locale_source.locales[i].v;this.index=ad_targeting_locale_source.locales[i].i;this.ready();return;}new AsyncRequest().setURI(muffinize('/muffins/ajax/typeahead_locales.php')).setReadOnly(true).setData({'act':act}).setHandler(function(_L3){this.values=_L3.getPayload();this.build_index();ad_targeting_locale_source.locales.push({v:this.values,i:this.index});this.ready();}.bind(this)).send();}ad_targeting_locale_source.extend('custom_source');
function keyword_source(_L0){this.parent.construct(this,[]);this.category=_L0;if(!keyword_source.categories){keyword_source.categories=[];}else for(var i=0,il=keyword_source.categories.length;i<il;i++)if(keyword_source.categories[i].c==this.category){this.values=keyword_source.categories[i].v;this.index=keyword_source.categories[i].i;this.ready();return;}new AsyncRequest().setURI('/ajax/typeahead_keywords.php').setData({c:this.category}).setMethod('GET').setReadOnly(true).setHandler(function(_L3){this.values=_L3.getPayload();this.build_index();keyword_source.categories.push({c:this.category,v:this.values,i:this.index});this.ready();}.bind(this)).send();}keyword_source.extend('custom_source');keyword_source.prototype.noinput=false;keyword_source.prototype.text_placeholder=_tx("Type a keyword");
function regions_source(_L0){this.parent.construct(this,[]);this.country=_L0;this.reload();}regions_source.extend('custom_source');regions_source.prototype.noinput=false;regions_source.prototype.text_placeholder=_tx("Type a region");regions_source.prototype.reload=function(){new AsyncRequest().setMethod('GET').setReadOnly(true).setURI('/ajax/typeahead_regions.php').setData({c:this.country,v:1}).setHandler(function(_L0){this.values=_L0.getPayload();this.build_index();this.ready();}.bind(this)).send();};

if (window.Bootloader) { Bootloader.done(["js\/7xkl4ov7o944g0wo.pkg.js"]); }