/*    HTTP Host:  static.ak.fbcdn.net                                          */
/*    Generated:  February 10th 2010 4:43:57 AM PST                            */
/*      Machine:  10.16.140.106                                                */
/*       Source:  Backing Store                                                */
/*     Location:  js/connect_widget/connect_widget_wizard.js h:afw4xxs3        */
/*       Locale:  nu_ll                                                        */
/*         Path:  js/connect_widget/connect_widget_wizard.js                   */

if (window.CavalryLogger) { CavalryLogger.start_js(["js\/connect_widget\/connect_widget_wizard.js"]); }

function ConnectWidgetWizardController(_L0,_L1,_L2){this.wizard=$(_L0);this.markup_filterlist=_L1;this.widget_filterlist=_L2;this.selected_wizard=null;this.selected_wizard_id=null;this.app_id='';this.app_data={};this.connectscript='';}ConnectWidgetWizardController.prototype.getWizard=function(){return this.wizard;};ConnectWidgetWizardController.prototype.go=function(){this.appselector=$('selected_app');this.appselector.listen('change',function(e){var key=this.appselector.options[this.appselector.selectedIndex].value;var _L2=window.location;var _L3=_L2.protocol+'//'+_L2.host+_L2.pathname+'?connect_wizard&wizard='+this.selected_wizard_id+'&app_id='+key;window.location=_L3;}.bind(this));this.refresh();return this;};ConnectWidgetWizardController.prototype.refresh=function(){var _L0=this.markup_filterlist.getSelectedItem();_L0=_L0?_L0.data:this.widget_filterlist.getSelectedItem().data;if(_L0!=this.selected_wizard_id){this.selected_wizard_id=_L0;switch(this.selected_wizard_id){case 'share':this.selected_wizard=new ConnectShareWizard(this);break;case 'comments':this.selected_wizard=new ConnectCommentsWizard(this);break;case 'fan':this.selected_wizard=new ConnectFanWizard(this);break;case 'livestream':this.selected_wizard=new ConnectLiveStreamWidgetWizard(this);break;case 'stream_publish':this.selected_wizard=new ConnectStreamPublishWizard(this);break;case 'social_markup':this.selected_wizard=new ConnectSocialMarkupWizard(this);break;}if(this.selected_wizard)this.selected_wizard.showWizard();}};ConnectWidgetWizardController.prototype.setConnectScript=function(_L0){this.connectscript=_L0;return this;};ConnectWidgetWizardController.prototype.getConnectScript=function(){return this.connectscript;};ConnectWidgetWizardController.prototype.setCurrentApp=function(app){this.app_id=app;return this;};ConnectWidgetWizardController.prototype.setAppData=function(_L0){this.app_data=_L0;return this;};ConnectWidgetWizardController.prototype.getAppData=function(){return this.app_data;};ConnectWidgetWizardController.prototype.getAppId=function(){return this.app_id;};function ConnectWidgetWizard(_L0){this.controller=_L0;var _L1=this.getDeferredWidgetScript();if(_L1)eval_global(_L1);}ConnectWidgetWizard.prototype.showSelector=function(_L0,_L1){_L0.listen('change',function(e){var key=_L0.options[_L0.selectedIndex].value;_L1(key);}.bind(this));return _L0;};ConnectWidgetWizard.prototype.getConnectScript=function(){return this.controller.getConnectScript();};ConnectWidgetWizard.prototype.getConnectInit=function(){var _L0=this.getAppData();var _L1=this.getAppId();if(!_L0[_L1])return '';return '<script type="text/javascript">'+'FB.init("'+_L0[_L1].apikey+'");'+'</script>';};ConnectWidgetWizard.prototype.getConnectEnd=function(){return '';};ConnectWidgetWizard.prototype.getPreviewDom=function(){if(!this.preview)this.preview=this.find('div.preview');return this.preview;};ConnectWidgetWizard.prototype.getTextareaDom=function(){return null;};ConnectWidgetWizard.prototype.refresh=function(){var textareaDom=this.getTextareaDom();if(textareaDom)textareaDom.value=this.getConnectScript()+this.getConnectInit()+this.getWidgetScript()+this.getDeferredWidgetScript()+this.getConnectEnd()+this.getWidgetMarkup();if(this.rendered_preview)DOM.remove(this.rendered_preview);var previewDom=this.getPreviewDom();if(previewDom){var widgetScript=this.getWidgetScript();if(widgetScript){var widget_div=previewDom;eval(widgetScript);}else{var widgetMarkup=this.getWidgetMarkup();if(widgetMarkup){this.rendered_preview=HTML(this.getWidgetMarkup());DOM.setContent(previewDom,this.rendered_preview);FB.ensureInit(function(){FB.XFBML.Host.parseDomElement(previewDom);}.bind(this));}}}};ConnectWidgetWizard.prototype.getWidgetScript=function(){return '';};ConnectWidgetWizard.prototype.getDeferredWidgetScript=function(){return '';};ConnectWidgetWizard.prototype.getWidgetMarkup=function(){return '';};ConnectWidgetWizard.prototype.find=function(_L0){return DOM.find(this.wizard,_L0);};ConnectWidgetWizard.prototype.getConnectScript=function(){return this.controller.getConnectScript();};ConnectWidgetWizard.prototype.initStringProperty=function(_L0,_L1){var _L2=_L0+'_input';this[_L0]='';this[_L2]=$(_L1);Event.listen(this[_L2],'change',function(e){this.setStringProperty(_L0,this[_L2].value);}.bind(this));};ConnectWidgetWizard.prototype.setStringProperty=function(_L0,txt){if(this[_L0]!=txt){this[_L0]=txt;this.refresh();}};ConnectWidgetWizard.prototype.getAppId=function(){return this.controller.getAppId();};ConnectWidgetWizard.prototype.getPageId=function(){return this.controller.getPageId();};ConnectWidgetWizard.prototype.getAppData=function(){return this.controller.getAppData();};function ConnectPicWidgetWizard(_L0){this.parent.construct(this,_L0);}ConnectPicWidgetWizard.extend('ConnectWidgetWizard');ConnectPicWidgetWizard.prototype.setPicSize=function(_L0){this.pic_size=_L0;this.refresh();};ConnectPicWidgetWizard.prototype.getPicSize=function(){return this.pic_size;};function ConnectWidgetWizardPage(_L0){this.parent.construct(this,_L0);}ConnectWidgetWizardPage.extend('ConnectWidgetWizard');ConnectWidgetWizardPage.prototype.showWizard=function(){this.refresh();};function ConnectLoginButtonWizard(_L0){this.parent.construct(this,_L0);this.wizard=$('login_button');this.sizeselector=$('select_button_size');this.button_size=this.sizeselector.options[this.sizeselector.selectedIndex].value;this.showSelector(this.sizeselector,this.setButtonSize.bind(this));this.custom_text=$('custom_text');Event.listen(this.custom_text,'click',function(e){this.custom_button.checked=true;this.updateButtonText();}.bind(this));Event.listen(this.custom_text,'keyup',function(e){this.updateButtonText();}.bind(this));this.button_text_radio=document.getElementsByName('button_text');for(var i=0;i<this.button_text_radio.length;i++){var _L2=this.button_text_radio[i];if(_L2.checked){this.button_text=_L2.value;}else if(_L2.value=='Custom')this.custom_button=_L2;Event.listen(_L2,'click',function(e){this.updateButtonText();}.bind(this));}}ConnectLoginButtonWizard.extend('ConnectWidgetWizard');ConnectLoginButtonWizard.prototype.getTextareaDom=function(){if(!this.textarea)this.textarea=$('login_button_code');return this.textarea;};ConnectLoginButtonWizard.prototype.getConnectScript=function(){return '';};ConnectLoginButtonWizard.prototype.getConnectInit=function(){return '';};ConnectLoginButtonWizard.prototype.getWidgetMarkup=function(){return '<fb:login-button v="2" size="'+this.getButtonSize()+'">'+this.getButtonText()+'</fb:login-button>';};ConnectLoginButtonWizard.prototype.updateButtonText=function(_L0){if(!_L0){for(var i=0;i<this.button_text_radio.length;i++){_L0=this.button_text_radio[i];if(_L0.checked)break;}if(_L0.value=='Custom'){this.button_text=this.custom_text.value;}else this.button_text=_L0.value;this.refresh();}};ConnectLoginButtonWizard.prototype.getButtonText=function(){return this.getButtonSize()=='icon'?'':this.button_text;};ConnectLoginButtonWizard.prototype.setButtonSize=function(_L0){this.button_size=_L0;this.refresh();};ConnectLoginButtonWizard.prototype.getButtonSize=function(){return this.button_size;};function ConnectProfilePicWizard(_L0){this.parent.construct(this,_L0);this.wizard=$('profile_pic');this.sizeselector=$('select_profile_pic_size');this.pic_size=this.sizeselector.options[this.sizeselector.selectedIndex].value;this.showSelector(this.sizeselector,this.setPicSize.bind(this));this.uid='';this.uid_input=$('profile_pic_uid');Event.listen(this.uid_input,'change',function(e){this.setUid(this.uid_input.value);}.bind(this));}ConnectProfilePicWizard.extend('ConnectPicWidgetWizard');ConnectProfilePicWizard.prototype.getTextareaDom=function(){if(!this.textarea)this.textarea=$('profile_pic_code');return this.textarea;};ConnectProfilePicWizard.prototype.getConnectScript=function(){return '';};ConnectProfilePicWizard.prototype.getConnectInit=function(){return '';};ConnectProfilePicWizard.prototype.getWidgetMarkup=function(){return '<fb:profile-pic uid="'+this.getUid()+'" size="'+this.getPicSize()+'" facebook-logo="true'+'"></fb:profile-pic>';};ConnectProfilePicWizard.prototype.setUid=function(uid){if(this.uid!=uid){this.uid=uid;this.refresh();}};ConnectProfilePicWizard.prototype.getUid=function(){if(!this.uid)return 'loggedinuser';return this.uid;};function ConnectNameWizard(_L0){this.parent.construct(this,_L0);this.wizard=$('user_name');this.use_you_checkbox=$('use_you');this.use_you=this.use_you_checkbox.checked;Event.listen(this.use_you_checkbox,'change',function(e){this.updateUseYou();}.bind(this));this.name_link_checkbox=$('name_link');this.name_link=this.name_link_checkbox.checked;Event.listen(this.name_link_checkbox,'change',function(e){this.updateNameLink();}.bind(this));this.uid_input=$('name_uid');this.uid=this.uid_input.value;Event.listen(this.uid_input,'change',function(e){this.setUid(this.uid_input.value);}.bind(this));}ConnectNameWizard.extend('ConnectWidgetWizard');ConnectNameWizard.prototype.getTextareaDom=function(){if(!this.textarea)this.textarea=$('user_name_code');return this.textarea;};ConnectNameWizard.prototype.getConnectScript=function(){return '';};ConnectNameWizard.prototype.getConnectInit=function(){return '';};ConnectNameWizard.prototype.getWidgetMarkup=function(){return '<fb:name uid="'+this.getUid()+'" useyou="'+this.getUseYou()+'" linked="'+this.getNameLink()+'"></fb:name>';};ConnectNameWizard.prototype.updateNameLink=function(){if(this.name_link!=this.name_link_checkbox.checked){this.name_link=this.name_link_checkbox.checked;this.refresh();}};ConnectNameWizard.prototype.getNameLink=function(){return this.name_link;};ConnectNameWizard.prototype.updateUseYou=function(){if(this.use_you!=this.use_you_checkbox.checked){this.use_you=this.use_you_checkbox.checked;this.refresh();}};ConnectNameWizard.prototype.getUseYou=function(){return this.use_you;};ConnectNameWizard.prototype.setUid=function(uid){if(this.uid!=uid){this.uid=uid;this.refresh();}};ConnectNameWizard.prototype.getUid=function(){if(!this.uid)return 'loggedinuser';return this.uid;};function ConnectFriendsWizard(_L0){this.parent.construct(this,_L0);this.wizard=$('friends');this.sizeselector=$('select_friends_size');this.pic_size=this.sizeselector.options[this.sizeselector.selectedIndex].value;this.showSelector(this.sizeselector,this.setPicSize.bind(this));this.nfselector=$('select_num_friends');this.num_friends=this.nfselector.options[this.nfselector.selectedIndex].value;this.showSelector(this.nfselector,this.setNumFriends.bind(this));}ConnectFriendsWizard.extend('ConnectPicWidgetWizard');ConnectFriendsWizard.prototype.getTextareaDom=function(){if(!this.textarea)this.textarea=$('friends_code');return this.textarea;};ConnectFriendsWizard.prototype.getConnectScript=function(){return '';};ConnectFriendsWizard.prototype.getConnectInit=function(){var _L0='<div id="profile_pics"></div>\r\n'+'<script type="text/javascript">\r\n'+'var widget_div = document.getElementById("profile_pics");\r\n';return _L0;};ConnectFriendsWizard.prototype.getConnectEnd=function(){return '</script>';};ConnectFriendsWizard.prototype.getWidgetScript=function(){var nf=this.getNumFriends();var sz=this.getPicSize();var _L2='FB.ensureInit(function () {\r\n'+'  FB.Facebook.get_sessionState().waitUntilReady(function() {\r\n'+'  FB.Facebook.apiClient.friends_get(null, function(result) {\r\n'+'    var markup = "";\r\n'+'    var num_friends = result ? Math.min('+nf+', result.length) : 0;\r\n'+'    if (num_friends > 0) {\r\n'+'      for (var i=0; i<num_friends; i++) {\r\n'+'        markup += \r\n'+'          \'<fb:profile-pic size="'+sz+'" uid="\'+result[i]+\'"'+' facebook-logo="true"></fb:profile-pic>\';\r\n'+'      }\r\n'+'    }\r\n'+'    widget_div.innerHTML = markup;\r\n'+'    FB.XFBML.Host.parseDomElement(widget_div);\r\n'+'  });\r\n'+'  });\r\n'+'});\r\n';return _L2;};ConnectFriendsWizard.prototype.setNumFriends=function(_L0){this.num_friends=_L0;this.refresh();};ConnectFriendsWizard.prototype.getNumFriends=function(){return this.num_friends;};function ConnectSocialMarkupWizard(_L0){this.parent.construct(this,_L0);this.wizard=DOM.find(this.controller.getWizard(),'div.connect_social_markup_wizard');this.script_text=$('body_script_tag');this.login_button_wizard=new ConnectLoginButtonWizard(_L0);this.profile_pic_wizard=new ConnectProfilePicWizard(_L0);this.name_wizard=new ConnectNameWizard(_L0);this.friends_wizard=new ConnectFriendsWizard(_L0);this.script_text.value=this.parent.getConnectScript()+this.parent.getConnectInit();}ConnectSocialMarkupWizard.extend('ConnectWidgetWizardPage');ConnectSocialMarkupWizard.prototype.refresh=function(){this.login_button_wizard.refresh();this.profile_pic_wizard.refresh();this.name_wizard.refresh();this.friends_wizard.refresh();this.parent.refresh();};ConnectSocialMarkupWizard.prototype.getPreviewDom=function(){return null;};function ConnectStreamPublishWizard(_L0){this.parent.construct(this,_L0);this.wizard=DOM.find(this.controller.getWizard(),'div.connect_streampublish_wizard');this.script_text=$('stream_script_tag');this.script_text.value=this.parent.getConnectScript()+this.parent.getConnectInit();this.initStringProperty('title_text','title_text');this.initStringProperty('image_href','image_link');this.initStringProperty('body_text','body_text');this.initStringProperty('image_src','image_src');this.initStringProperty('al_text','action_link_text');this.initStringProperty('al_href','action_link_url');}ConnectStreamPublishWizard.extend('ConnectWidgetWizardPage');ConnectStreamPublishWizard.prototype.getTextareaDom=function(){if(!this.textarea)this.textarea=$('stream_publish_code');return this.textarea;};ConnectStreamPublishWizard.prototype.getConnectScript=function(){return '';};ConnectStreamPublishWizard.prototype.getConnectInit=function(){var _L0='<script type="text/javascript">\r\n';return _L0;};ConnectStreamPublishWizard.prototype.getConnectEnd=function(){return '</script>\r\n';};ConnectStreamPublishWizard.prototype.getWidgetMarkup=function(){var _L0='<input type="button" onclick="callPublish(\'\','+this.getAttachment()+','+this.getActionLink()+');'+'return false;" value="Preview Dialog" />';return _L0;};ConnectStreamPublishWizard.prototype.getDeferredWidgetScript=function(){var _L0='function callPublish(msg, attachment, action_link) {\r\n'+'  FB.ensureInit(function () {\r\n'+'    FB.Connect.streamPublish(\'\', attachment, action_link);\r\n'+'  });\r\n'+'}';return _L0;};ConnectStreamPublishWizard.prototype.getAttachment=function(){if(!this.title_text||!this.image_href)return 'null';var _L0='{\'name\':\''+this.title_text+'\',\'href\':\''+this.image_href+'\'';if(this.body_text)_L0+=',\'description\':\''+this.body_text+'\'';if(this.image_src)_L0+=',\'media\':[{\'type\':\'image\',\'src\':\''+this.image_src+'\',\'href\':\''+this.image_href+'\'}]';_L0+='}';return _L0;};ConnectStreamPublishWizard.prototype.getActionLink=function(){if(!this.al_text||!this.al_href)return 'null';var _L0='[{\'text\':\''+this.al_text+'\',\'href\':\''+this.al_href+'\'}]';return _L0;};function ConnectCommentsWizard(_L0){this.parent.construct(this,_L0);this.wizard=DOM.find(this.controller.getWizard(),'div.connect_comments_wizard');this.comments_box_wizard=new ConnectCommentsBoxWizard(_L0);}ConnectCommentsWizard.extend('ConnectWidgetWizardPage');ConnectCommentsWizard.prototype.refresh=function(){this.comments_box_wizard.refresh();this.parent.refresh();};function ConnectCommentsBoxWizard(_L0){this.parent.construct(this,_L0);this.wizard=$('comments_box');}ConnectCommentsBoxWizard.extend('ConnectWidgetWizard');ConnectCommentsBoxWizard.prototype.getTextareaDom=function(){if(!this.textarea)this.textarea=$('comments_box_code');return this.textarea;};ConnectCommentsBoxWizard.prototype.getWidgetMarkup=function(){return '<fb:comments> </fb:comments>';};function ConnectFanWizard(_L0){this.parent.construct(this,_L0);this.wizard=DOM.find(this.controller.getWizard(),'div.connect_fan_wizard');this.fan_box_wizard=new ConnectFanBoxWizard(_L0);}ConnectFanWizard.extend('ConnectWidgetWizardPage');ConnectFanWizard.prototype.refresh=function(){this.fan_box_wizard.refresh();this.parent.refresh();};function ConnectFanBoxWizard(_L0){this.parent.construct(this,_L0);this.wizard=$('fan_box');this.show_stream_checkbox=$('stream');this.show_stream=this.show_stream_checkbox.checked;Event.listen(this.show_stream_checkbox,'change',function(e){this.updateShowStream();}.bind(this));this.show_fans_checkbox=$('fans');this.show_fans=this.show_fans_checkbox.checked;Event.listen(this.show_fans_checkbox,'change',function(e){this.updateShowFans();}.bind(this));}ConnectFanBoxWizard.extend('ConnectWidgetWizard');ConnectFanBoxWizard.prototype.getTextareaDom=function(){if(!this.textarea)this.textarea=$('fan_box_code');return this.textarea;};ConnectFanBoxWizard.prototype.updateShowStream=function(){if(this.show_stream!=this.show_stream_checkbox.checked){this.show_stream=this.show_stream_checkbox.checked;this.refresh();}};ConnectFanBoxWizard.prototype.getShowStream=function(){return this.show_stream?1:0;};ConnectFanBoxWizard.prototype.updateShowFans=function(){if(this.show_fans!=this.show_stream_checkbox.checked){this.show_fans=this.show_fans_checkbox.checked;this.refresh();}};ConnectFanBoxWizard.prototype.getShowFans=function(){return this.show_fans?10:0;};ConnectFanBoxWizard.prototype.getWidgetMarkup=function(){var _L0=this.getAppId();var _L1=this.getAppData();return '<fb:fan profile_id="'+_L0+'" stream="'+this.getShowStream()+'" connections="'+this.getShowFans()+'" width="300">'+'</fb:fan>'+'<div style="font-size:8px; padding-left:10px">'+'<a href="'+_L1[_L0].connect_url+'">'+_L1[_L0].application_name+'</a> on Facebook'+'</div>';};function ConnectLiveStreamWidgetWizard(_L0){this.parent.construct(this,_L0);this.wizard=DOM.find(this.controller.getWizard(),'div.connect_livestream_wizard');}ConnectLiveStreamWidgetWizard.extend('ConnectWidgetWizardPage');ConnectLiveStreamWidgetWizard.prototype.getTextareaDom=function(){if(!this.textarea)this.textarea=$('livestream_code');return this.textarea;};ConnectLiveStreamWidgetWizard.prototype.getWidgetMarkup=function(){var _L0=this.getAppId();return '<fb:live-stream event_app_id="'+_L0+'" xid="YOUR_EVENT_XID" width="300" height="500">'+'</fb:live-stream>';};function ConnectShareWizard(_L0){this.parent.construct(this,_L0);this.wizard=DOM.find(this.controller.getWizard(),'div.connect_share_wizard');this.share_button_wizard=new ConnectShareButtonWizard(_L0);this.script_text=$('share_script_tag');this.script_text.value=this.parent.getConnectScript()+this.parent.getConnectInit();}ConnectShareWizard.extend('ConnectWidgetWizardPage');ConnectShareWizard.prototype.refresh=function(){this.share_button_wizard.refresh();this.parent.refresh();};function ConnectShareButtonWizard(_L0){this.parent.construct(this,_L0);this.wizard=$('share_button');this.typeselector=$('select_share_type');this.share_type=this.typeselector.options[this.typeselector.selectedIndex].value;this.showSelector(this.typeselector,this.setShareType.bind(this));this.share_link='';this.share_link_input=$('share_link');Event.listen(this.share_link_input,'change',function(e){this.setShareLink(this.share_link_input.value);}.bind(this));}ConnectShareButtonWizard.extend('ConnectWidgetWizard');ConnectShareButtonWizard.prototype.getTextareaDom=function(){if(!this.textarea)this.textarea=$('share_button_code');return this.textarea;};ConnectShareButtonWizard.prototype.getConnectScript=function(){return '';};ConnectShareButtonWizard.prototype.getConnectInit=function(){return '';};ConnectShareButtonWizard.prototype.getWidgetMarkup=function(){return '<fb:share-button class="url'+'" href="'+this.getShareLink()+'" type="'+this.getShareType()+'"></fb:share-button>';};ConnectShareButtonWizard.prototype.setShareLink=function(_L0){if(this.share_link!=_L0){this.share_link=_L0;this.refresh();}};ConnectShareButtonWizard.prototype.getShareLink=function(){if(!this.share_link){var _L0=this.getAppData();var _L1=this.getAppId();if(!_L0[_L1]||!_L0[_L1].connect_url)return 'http://www.facebook.com';return _L0[_L1].connect_url;}return this.share_link;};ConnectShareButtonWizard.prototype.setShareType=function(_L0){this.share_type=_L0;this.refresh();};ConnectShareButtonWizard.prototype.getShareType=function(){return this.share_type;};

if (window.Bootloader) { Bootloader.done(["js\/connect_widget\/connect_widget_wizard.js"]); }