if(!window.ustream){window.ustream={}}if(!ustream.labels){ustream.labels={}}(function(l){l["js.v3.email_contact_importer.you_also_can"]="You can also";l["js.v3.email_contact_importer.upload_link"]="upload a contact list";l["js.v3.email_contact_importer.your_email"]="Your email";l["www.signup_find_friends_page.find_people_email_supported"]="To see the supported email sevice providers, <a href=\"#supported_services_link#\" class=\"supportedServices\">click here<\/a>";l["js.v3.email_contact_importer.your_email_password"]="Email password";l["js.v3.email_contact_importer.ustream_will_not_store_password"]="Ustream will not store your password";l["js.v3.email_contact_importer.find_people_action"]="Find People";l["js.v3.email_contact_importer.or"]="or";l["js.v3.email_contact_importer.cancel_action"]="Cancel";l["js.v3.email_friend_finder.join_their_crowds"]="Join their Crowds to see what they're up to!";l["js.v3.email_friend_finder.select_all"]="Select All";l["js.v3.email_friend_finder.join_crowds_action"]="Join Crowds";l["js.v3.email_friend_finder.skip_action"]="Skip";l["js.v3.email_contact_importer.import_link"]="import your email contacts";l["js.v3.email_contact_importer.upload_action"]="Upload";l["js.v3.email_contact_importer.empty_info"]="We couldn't get any contacts from your contact list.";l["js.v3.email_contact_importer.you_can_try_add"]="You can also try";l["js.v3.email_contact_importer.another_email_address"]="another email address";l["js.v3.email_contact_importer.or_connect_with_your"]="or connect with your";l["js.v3.email_contact_importer.social_networks"]="social networks";l["js.v3.email_contact_importer.finish"]="Finish";l["js.v3.email_contact_importer.support_info"]="Contact import is currently supported at the following email service providers:";l["js.v3.email_contact_importer.close"]="Close";l["js.v3.email_friend_finder.verify_info"]="Once you have verified your email, you will be able to get alerts, when they go live.";l["js.v3.email_friend_finder.people_not_on"]="#number# people from your contacts are not on Ustream.";l["js.v3.email_friend_finder.invite_them"]="Invite them!";l["js.v3.email_friend_finder.email_select_all"]="Select All";l["js.v3.email_friend_finder.send_invites_action"]="Send Invites";l["js.v3.email_friend_finder.you_can_try_add"]="You can also try";l["js.v3.email_friend_finder.another_email_address"]="adding another email address";l["js.v3.email_friend_finder.or_connect_with_your"]="or connect with your";l["js.v3.email_friend_finder.social_networks"]="social networks";l["js.v3.email_friend_finder.finish_action"]="Finish";l["js.common_for_all.unknown_error"]="Error!";l["js.v3.email_contact_importer.find_people_email"]="Find People You Email";l["js.v3.email_contact_importer.upload_email_list"]="Upload an Email Contact List";l["js.v3.email_contact_importer.display_email_list"]="You have #number# contacts to add";l["js.v3.email_contact_importer.success_title"]="Success! You've added #number# people";l["js.v3.email_contact_importer.empty_title"]="No contacts found";l["js.v3.email_contact_importer.support_title"]="Supported Email services";l["js.v3.email_friend_finder.checking"]="Checking your contacts...";l["js.v3.email_friend_finder.join_success"]="Success! You've joined #number# new Crowds!";l["js.v3.email_friend_finder.invite_title"]="Invite your friends to Ustream";l["js.v3.email_friend_finder.invite_success"]="Invites were sent to #number# of your Friends";l["js.v3.aim.error"]="Error!";l["js.v3.find_friends.succ_joined_crowds_plural"]="Success! You have joined new Crowds!";l["js.v3.find_friends.succ_joined_crowds_singular"]="Success! You have joined new Crowds!";l["js.v3.find_friends.nosucc_havent_joined_facebook"]="We did not find any of your Facebook friends on Ustream.";l["js.v3.find_friends.nosucc_havent_joined_twitter"]="We did not find any of your Twitter friends on Ustream.";l["js.v3.find_friends.nosucc_havent_joined_myspace"]="We did not find any of your MySpace friends on Ustream.";l["js.v3.find_friends.nosucc_havent_joined_aim"]="We did not find any of your AIM friends on Ustream.";l["js.v3.find_friends.nosucc_havent_joined"]="We did not find any of your friends on Ustream.";l["js.v3.find_friends.other_networks"]="Be sure to check the other Social Networks for more friends or use our search to find exactly what you are looking for.";l["js.v3.find_friends.finish_action"]="Finish";l["js.v3.find_friends.select_all"]="Select All";l["js.v3.find_friends.label_username"]="Username";l["js.v3.find_friends.join_crowds"]="Join Crowds";l["js.v3.find_friends.skip"]="Skip";l["js.v3.find_friends.empty_list"]="We did not find any of your friends on Ustream.";l["js.v3.crowd_customization_form.click_to_connect"]="Click to connect your #service# account with Ustream";l["js.v3.crowd_customization_form.connect_with"]="Connect with #service#";l["js.v3.crowd_customization_form.error_in_connect"]="An error occured during connect with #service#";l["js.v3.crowd_customization_form_facebook.hey_user"]="Hey <a href='#profileUrl#' target='_blank'>#profileName#<\/a>!";l["js.v3.crowd_customization_form_facebook.number_of_your_friends"]="#dataLength# of your facebook friends are on Ustream.";l["js.v3.crowd_customization_form_twitter.hey_user"]="Hey <a href='#profileUrl#' target='_blank'>#profileName#<\/a>!";l["js.v3.crowd_customization_form_twitter.number_of_your_friends"]="#dataLength# people you Follow on Twitter are already on Ustream.";l["js.v3.crowd_customization_form_myspace.hey_user"]="Hey <a href='#profileUrl#' target='_blank'>#profileName#<\/a>!";l["js.v3.crowd_customization_form_myspace.number_of_your_friends"]="#dataLength# of your MySpace Friends are already on Ustream.";l["js.v3.crowd_customization_form_aim.hey_user"]="Hey <strong>#profileName#<\/strong>!";l["js.v3.crowd_customization_form_aim.number_of_your_friends"]="#dataLength# of your AIM Buddies are already on Ustream.";l["js.v3.find_friends.dialog_title"]="Find Friends on Social Networks";})(ustream.labels);
ustream.templates.emailImportCredentials='<form method="POST" action="" data-template="emailImportCredentials"><p><%= _t_("js.v3.email_contact_importer.you_also_can") %> <a href="#" id="UploadEmailAction"><%= _t_("js.v3.email_contact_importer.upload_link") %></a>.<br /></p><label for="findEmailLogin"><%= _t_("js.v3.email_contact_importer.your_email") %></label><br /><small><%= _t_("www.signup_find_friends_page.find_people_email_supported") %></small><br /><input type="text" name="email" id="findEmailLogin" /><br /><label for="findEmailPass"><%= _t_("js.v3.email_contact_importer.your_email_password") %></label><br /><small><%= _t_("js.v3.email_contact_importer.ustream_will_not_store_password") %></small><br /><input type="password" name="password" id="findEmailPass" /><br /><button id="findEmailSubmit"><%= _t_("js.v3.email_contact_importer.find_people_action") %></button> <%= _t_("js.v3.email_contact_importer.or") %> <a href="" class="cancel"><%= _t_("js.v3.email_contact_importer.cancel_action") %></a></form>';
ustream.templates.emailFriendList='<form action="" method="post" data-template="emailFriendList"><p><%= _t_("js.v3.email_friend_finder.join_their_crowds") %></p><div class="itemManageListControl"><label for="emailSelectAll"><input type="checkbox" name="" id="emailSelectAll" /> <% _t_("js.v3.email_friend_finder.select_all") %></label></div><ul class="itemManageList imgList"><% forEach( data, function( user, counter ){ %><li><% if(user.inCrowd){ %><input type="checkbox" checked="checked" disabled="disabled" /><% } else { %><input type="checkbox" name="mailaddress[]" value="<%=user.userId %>" rel="<%=user.userId %>" /><% }%><img src="<%=user.userPicture %>" alt="<%=user.userName %>" /><span><strong><%=user.userName %></strong><br /><%=user.userEmail %></span></li><% }); %></ul><button id="addEmailSubmit"><%= _t_("js.v3.email_friend_finder.join_crowds_action") %></button> <button id="skipEmailSubmit"><%= _t_("js.v3.email_friend_finder.skip_action") %></button></form>';
ustream.templates.emailImportUpload='<form method="POST" action="" enctype="multipart/form-data" data-template="emailImportUpload"><p><%= _t_("js.v3.email_contact_importer.you_also_can") %> <a href="#" id="ImportEmailAction"><%= _t_("js.v3.email_contact_importer.import_link") %></a><br /></p><label for="uploadEmailLogin"><%= _t_("js.v3.email_contact_importer.your_email") %></label><br /><input type="file" name="contactFile" /><br /><button><%= _t_("js.v3.email_contact_importer.upload_action") %></button> <%= _t_("js.v3.email_contact_importer.or") %> <a href="" class="cancel"><%= _t_("js.v3.email_contact_importer.cancel_action") %></a></form>';
ustream.templates.emailImportEmpty='<input type="hidden" data-template="emailImportEmpty" /><p><%= _t_("js.v3.email_contact_importer.empty_info") %></p><p><%= _t_("js.v3.email_contact_importer.you_can_try_add") %> <a href="#" id="ImportEmailAction"><%= _t_("js.v3.email_contact_importer.another_email_address") %></a><br/><%= _t_("js.v3.email_contact_importer.or_connect_with_your") %> <a href="#" id="SocialFindFriendsAction"><%= _t_("js.v3.email_contact_importer.social_networks") %></a></p><button id="addEmailSubmit"><%= _t_("js.v3.email_contact_importer.finish") %></button>';
ustream.templates.emailImportSupport='<input type="hidden" data-template="emailImportSupport" /><p><%= _t_("js.v3.email_contact_importer.support_info") %></p><br class="clear" /><ul style="float:left; width: 110px; margin-left: 10px; list-style-type:square; padding-left:10px;"><li>hotmail.com</li><li>yahoo.com</li><li>gmail.com</li><li>aol.com</li><li>msn.com</li><li>live.com</li><li>fastmail.fm</li><li>web.de</li><li>mail.com</li><li>mail.ru</li><li>rediff.com</li><li>indiatimes.com</li><li>lycos.com</li><li>paracalls.com</li></ul><ul style="float:left; width: 110px; margin-left: 10px; list-style-type:square; padding-left:10px;"><li>libero.it</li><li>rambler.ru</li><li>mac.com</li><li>mynet.com</li><li>interia.pl</li><li>yandex.ru</li><li>qq.com</li><li>sina.com</li><li>126.com</li><li>daum.net</li><li>163.com</li><li>plaxo.com</li><li>me.com</li><li>plaxo.com</li></ul><br class="clear" /><br /><button id="addEmailSubmit"><%= _t_("js.v3.email_contact_importer.close") %></button>';
ustream.templates.inviteFriendList='<form action="" method="post" data-template="inviteFriendList"><% if (joined_count > 0){ %><p><%= _t_("js.v3.email_friend_finder.verify_info") %></p><% } %><p><strong><%= _t_("js.v3.email_friend_finder.people_not_on", {number: invite_count}) %><br /><%= _t_("js.v3.email_friend_finder.invite_them") %></strong></p><div class="itemManageListControl"><label for="emailSelectAll"><input type="checkbox" name="" id="emailSelectAll" /> <%= _t_("js.v3.email_friend_finder.email_select_all") %></label></div><ul class="itemManageList inviteList"><% forEach( mails, function( mail, counter ){ %><li><span class="name"><input type="checkbox" name="mailaddress[]" value="<%=mail.email %>" rel="<%=mail.name %>" /> <%=mail.name %></span><span class="email"><%=mail.email %></span></li><% }); %></ul><button id="addEmailSubmit"><%= _t_("js.v3.email_friend_finder.send_invites_action") %></button> <button id="skipEmailSubmit"><%= _t_("js.v3.email_friend_finder.skip_action") %></button></form>';
ustream.templates.inviteFriendsSuccess='<input type="hidden" data-template="inviteFriendsSuccess" /><p><%= _t_("js.v3.email_friend_finder.you_can_try_add") %> <a href="#" id="ImportEmailAction"><%= _t_("js.v3.email_friend_finder.another_email_address") %></a><br/><%= _t_("js.v3.email_friend_finder.or_connect_with_your") %> <a href="#" id="SocialFindFriendsAction"><%= _t_("js.v3.email_friend_finder.social_networks") %></a></p><button id="addEmailSubmit"><%= _t_("js.v3.email_friend_finder.finish_action") %></button>';
(function(){eval(ustream.namespace);ustream.classes.EmailContactImporter=$.klass({options:{form:{},modal:{},coverLayer:false,onDialogClose:false,credentialsTemplate:ustream.templates.emailImportCredentials,uploadTemplate:ustream.templates.emailImportUpload,listTemplate:ustream.templates.emailImportList,successTemplate:ustream.templates.emailImportSuccess,emptyTemplate:ustream.templates.emailImportEmpty,supportTemplate:ustream.templates.emailImportSupport,onSocialFindAction:function(){}},initialize:function(options){this.options=merge(this.options,options||{});
this.options.emailImportUrl=ustream.vars.emailImportUrl;this.options.emailUploadUrl=ustream.vars.emailUploadUrl;
this.options.form=typeof(this.options.form)=="object"?this.options.form:$(this.options.form);this.options.modal=$('<div id="ImportEmailDialog"></div>');
this.options.modal.dialog({modal:true,width:360,height:250,autoOpen:false,close:bind(this.onModalClose,this)});
this.selectedList=[]},show:function(){this.options.modal.dialog("open");this.switchToImport()},getCoverLayer:function(){if(!this.coverLayer){this.coverLayer=new ustream.classes.CoverLayer(this.options.modal)
}else{this.coverLayer.relocate(this.options.modal)}return this.coverLayer},close:function(e){if(e){e.preventDefault()
}e.stopPropagation();this.options.modal.dialog("close");if(this.options.onDialogClose){this.options.onDialogClose.call(this,this.selectedList)
}},onModalClose:function(){if(this.coverLayer){this.coverLayer.destroy();this.coverLayer=false}},importSubmitHandler:function(){this.getCoverLayer().show();
this.options.modal.find("form").ajaxSubmit({url:this.options.emailImportUrl,dataType:"json",success:bind(this.importResponseHandler,this,false)})
},importResponseHandler:function(response){this.getCoverLayer().hide();if(response.success){this.emailList=response.data;
if(this.emailList.length>0){this.switchToList()}else{this.switchToEmpty()}}else{if(response.error&&response.error.message){ustream.events.dispatch(ustream.events.ERRORNOTIFICATION,{message:response.error.message});
this.options.modal.find("input").removeClass("valid").addClass("error")}else{ustream.events.dispatch(ustream.events.ERRORNOTIFICATION,{message:_t_("js.common_for_all.unknown_error")})
}}},addContacts:function(e){e.preventDefault();e.stopPropagation();var selected=this.options.modal.find(".itemManageList li input:checked");
var currentCount=0;selected.forEach(function(elem){var elem=$(elem);this.selectedList.push({name:elem.attr("rel"),email:elem.attr("value")});
currentCount++},this);this.switchToSuccess(currentCount)},finish:function(e){e.preventDefault();e.stopPropagation();
this.close()},uploadSubmit:function(e){e.preventDefault();e.stopPropagation();this.getCoverLayer().show();
this.options.modal.find("form").ajaxSubmit({url:this.options.emailUploadUrl,dataType:"json",success:bind(this.importResponseHandler,this,false)})
},switchToImport:function(e){if(e){e.preventDefault()}e.stopPropagation();if(typeof(this.options.credentialsTemplate)=="string"){this.options.credentialsTemplate=new ustream.classes.SimpleTpl(this.options.credentialsTemplate)
}this.options.modal.children().remove().end().html(this.options.credentialsTemplate.run()).dialog("option","height",242).dialog("option","position","center").dialog("option","title",_t_("js.v3.email_contact_importer.find_people_email")).find("a.supportedServices").click(eBind(this.switchToSupport,this)).end().find("a#UploadEmailAction").click(eBind(this.switchToUpload,this)).end().find("input").eq(0).focus().end().end().find("a.cancel").click(eBind(this.close,this)).end();
this.validator=new ustream.classes.Validator({form:this.options.modal.find("form"),rules:{email:{required:true,email:true},password:{required:true}},submitHandler:bind(this.importSubmitHandler,this)})
},switchToUpload:function(){if(typeof(this.options.uploadTemplate)=="string"){this.options.uploadTemplate=new ustream.classes.SimpleTpl(this.options.uploadTemplate)
}this.options.modal.children().remove().end().html(this.options.uploadTemplate.run()).dialog("option","height",152).dialog("option","position","center").dialog("option","title",_t_("js.v3.email_contact_importer.upload_email_list")).find("a#ImportEmailAction").click(eBind(this.switchToImport,this)).end().find("button").click(eBind(this.uploadSubmit,this)).end().find("a.cancel").click(eBind(this.switchToImport,this))
},switchToList:function(){if(typeof(this.options.listTemplate)=="string"){this.options.listTemplate=new ustream.classes.SimpleTpl(this.options.listTemplate)
}this.options.modal.children().remove().end().html(this.options.listTemplate.run({data:this.emailList})).dialog("option","height",304).dialog("option","position","center").dialog("option","title",_t_("js.v3.email_contact_importer.display_email_list",{number:this.emailList.length})).find(".itemManageList li").click(eBind(function(e){if(e.target.tagName.toLowerCase()!="input"){e.preventDefault();
e.stopPropagation();var chk=$(e.target).closest("li").find("input").prop("checked");$(e.target).closest("li").find("input").not("[disabled]").if_(chk).prop("checked",false).else_().prop("checked",true)
}this.toggleSubmitButton()},this)).end().find(".itemManageListControl input").change(eBind(function(e){e.preventDefault();
e.stopPropagation();var chk=$(e.target).prop("checked");this.options.modal.find(".itemManageList li input").not("[disabled]").if_(!chk).prop("checked",false).else_().prop("checked",true);
this.toggleSubmitButton()},this)).end().find("#addEmailSubmit").click(eBind(this.addContacts,this)).end().find("a.cancel").click(eBind(this.switchToImport,this));
this.toggleSubmitButton()},toggleSubmitButton:function(){var checkedItems=this.options.modal.find(".itemManageList input:checked").not(":disabled");
if(checkedItems.length){$("#addEmailSubmit").removeClass("disabled").prop("disabled",false)}else{$("#addEmailSubmit").addClass("disabled").prop("disabled",true)
}},switchToSuccess:function(currentCount){if(typeof(this.options.successTemplate)=="string"){this.options.successTemplate=new ustream.classes.SimpleTpl(this.options.successTemplate)
}this.options.modal.children().remove().end().html(this.options.successTemplate.run()).dialog("option","height",140).dialog("option","position","center").dialog("option","title",_t_("js.v3.email_contact_importer.success_title",currentCount)).find("a#ImportEmailAction").click(eBind(this.switchToImport,this)).end().find("a#SocialFindFriendsAction").click(eBind(this.switchToSocial,this)).end().find("#addEmailSubmit").click(eBind(this.finish,this))
},switchToEmpty:function(){if(typeof(this.options.emptyTemplate)=="string"){this.options.emptyTemplate=new ustream.classes.SimpleTpl(this.options.emptyTemplate)
}this.options.modal.children().remove().end().html(this.options.emptyTemplate.run()).dialog("option","height",140).dialog("option","position","center").dialog("option","title",_t_("js.v3.email_contact_importer.empty_title")).find("a#ImportEmailAction").click(eBind(this.switchToImport,this)).end().find("a#SocialFindFriendsAction").click(eBind(this.switchToSocial,this)).end().find("#addEmailSubmit").click(eBind(this.finish,this))
},switchToSupport:function(closeOnButton){closeOnButton=typeof(closeOnButton)=="boolean"?closeOnButton:false;
if(typeof(this.options.supportTemplate)=="string"){this.options.supportTemplate=new ustream.classes.SimpleTpl(this.options.supportTemplate)
}this.options.modal.children().remove().end().html(this.options.supportTemplate.run()).dialog("option","height",368).dialog("option","position","center").dialog("option","title",_t_("js.v3.email_contact_importer.support_title"));
if(closeOnButton){this.options.modal.find("#addEmailSubmit").click(eBind(this.close,this))}else{this.options.modal.find("#addEmailSubmit").click(eBind(this.switchToImport,this))
}},switchToSocial:function(){this.options.modal.dialog("close");if(typeof(this.options.onSocialFindAction)=="function"){this.options.onSocialFindAction.call(this)
}}})})();
(function(){eval(ustream.namespace);ustream.classes.EmailFriendFinder=ustream.classes.EmailContactImporter.extend({initialize:function(options){this.parent(options);
this.options.inviteTemplate=ustream.templates.inviteFriendList;this.options.successTemplate=ustream.templates.inviteFriendsSuccess;
this.options.listTemplate=ustream.templates.emailFriendList;this.options.emptyTemplate=ustream.templates.emailImportEmpty;
this.options.joinCrowdsUrl=ustream.vars.joinCrowdsUrl;this.options.emailImportUrl=ustream.vars.emailFriendsUrl;
this.options.emailInvitesUrl=ustream.vars.emailInvitesUrl},close:function(e){if(e){e.preventDefault()
}e.stopPropagation();this.options.modal.dialog("close")},onModalClose:function(){this.options.modal.html("");
this.invitees=[];this.emailList=[];if(this.coverLayer){this.coverLayer.destroy();this.coverLayer=false
}},show:function(username,password){this.options.modal.dialog("option","height",100).dialog("option","title",_t_("js.v3.email_friend_finder.checking")).dialog("open");
this.getCoverLayer().show();$.ajax({url:this.options.emailImportUrl,type:"POST",data:{email:username,password:password},dataType:"json",success:bind(this.importResponseHandler,this,true)})
},showSupported:function(){this.switchToSupport(true);this.options.modal.dialog("open")},importResponseHandler:function(closeOnError,response){this.getCoverLayer().hide();
closeOnError=closeOnError||false;if(response.success){this.invitees=response.usersNonUstream;this.emailList=response.usersUstream;
if(this.invitees.length==0&&this.emailList==0){this.switchToEmpty()}else{if(this.emailList==0){this.switchToInvite()
}else{this.switchToList()}}}else{ustream.events.dispatch(ustream.events.ERRORNOTIFICATION,{message:response.error.message});
if(closeOnError){this.options.modal.dialog("close")}}},switchToList:function(){this.options.modal.find(".itemManageList").addClass("picList");
this.parent();this.options.modal.dialog("option","height",404).dialog("option","position","center").find("#addEmailSubmit").unbind("click").click(eBind(this.joinCrowds,this)).end().find("#skipEmailSubmit").unbind("click").click(eBind(this.switchToInvite,this,0))
},switchToInvite:function(joinedCount,e){if(e){e.preventDefault()}e.stopPropagation();if(typeof(this.options.inviteTemplate)=="string"){this.options.inviteTemplate=new ustream.classes.SimpleTpl(this.options.inviteTemplate)
}this.options.modal.children().remove().end();if(joinedCount>0){this.options.modal.html(this.options.inviteTemplate.run({joined_count:joinedCount,invite_count:this.invitees.length,mails:this.invitees})).dialog("option","title",_t_("js.v3.email_friend_finder.join_success",{number:joinedCount})).dialog("option","height",364)
}else{this.options.modal.html(this.options.inviteTemplate.run({joined_count:joinedCount,invite_count:this.invitees.length,mails:this.invitees})).dialog("option","title",_t_("js.v3.email_friend_finder.invite_title")).dialog("option","height",323)
}this.options.modal.dialog("option","position","center").find("a#ImportEmailAction").click(eBind(this.switchToImport,this)).end().find(".itemManageList li").click(eBind(function(e){if(e.target.tagName.toLowerCase()!="input"){e.preventDefault();
e.stopPropagation();var chk=$(e.target).closest("li").find("input").prop("checked");$(e.target).closest("li").find("input").not("[disabled]").if_(chk).prop("checked",false).else_().prop("checked",true)
}this.toggleSubmitButton()},this)).end().find(".itemManageListControl input").change(eBind(function(e){e.preventDefault();
e.stopPropagation();var chk=$(e.target).prop("checked");this.options.modal.find(".itemManageList li input").not("[disabled]").if_(!chk).prop("checked",false).else_().prop("checked",true);
this.toggleSubmitButton()},this)).end().find("#addEmailSubmit").click(eBind(this.sendInvites,this)).end().find("#skipEmailSubmit").click(eBind(function(){this.options.modal.dialog("close")
},this));this.toggleSubmitButton()},switchToSuccess:function(invitedCount){if(invitedCount==0){this.options.modal.dialog("close");
return}if(typeof(this.options.successTemplate)=="string"){this.options.successTemplate=new ustream.classes.SimpleTpl(this.options.successTemplate)
}this.options.modal.children().remove().end().html(this.options.successTemplate.run()).dialog("option","height",140).dialog("option","position","center").dialog("option","title",_t_("js.v3.email_friend_finder.invite_success",{number:invitedCount})).find("#ImportEmailAction").click(eBind(this.switchToImport,this)).end().find("#SocialFindFriendsAction").click(eBind(this.switchToSocial,this)).end().find("#addEmailSubmit").click(eBind(this.finish,this))
},switchToSocial:function(){this.options.modal.dialog("close");if(typeof(this.options.onSocialFindAction)=="function"){this.options.onSocialFindAction.call(this)
}},joinCrowds:function(e){e.stop();this.getCoverLayer().show();var crowds=this.collectFromItemList();
$.ajax({url:this.options.joinCrowdsUrl,type:"POST",data:{crowdUserIds:crowds},dataType:"json",success:bind(this.joinCrowdsResponseHandler,this,crowds.length)})
},joinCrowdsResponseHandler:function(joinedCount,response){this.getCoverLayer().hide();if(response.success){if(this.invitees.length==0){this.options.modal.dialog("close")
}else{this.switchToInvite(joinedCount)}}else{if(response.error&&response.error.message){ustream.events.dispatch(ustream.events.ERRORNOTIFICATION,{message:response.error.message})
}else{ustream.events.dispatch(ustream.events.ERRORNOTIFICATION,{message:_t_("js.common_for_all.unknown_error")})
}}},sendInvites:function(e){e.preventDefault();e.stopPropagation();this.getCoverLayer().show();var invites=this.collectFromItemList();
$.ajax({url:this.options.emailInvitesUrl,type:"POST",data:{emails:invites},dataType:"json",success:bind(this.sendInvitesResponse,this,invites.length)})
},sendInvitesResponse:function(inviteLength,response){this.getCoverLayer().hide();if(response.success){this.switchToSuccess(inviteLength)
}else{ustream.events.dispatch(ustream.events.ERRORNOTIFICATION,{message:response.error.message})}},collectFromItemList:function(){var ret=[];
this.options.modal.find(".itemManageList li input:checked").forEach(function(item){ret.push(item.value)
},this);return ret}})})();
(function(){eval(ustream.namespace);ustream.classes.ErrorHandler=$.klass({options:{form:"",attribute:"name",attributeWrapper:"%KEY%",success:null},initialize:function(options){this.options=merge(this.options,options||{});
this.options.fieldSelector=["input[",this.options.attribute,"=",this.options.attributeWrapper,"],","select[",this.options.attribute,"=",this.options.attributeWrapper,"],","textarea[",this.options.attribute,"=",this.options.attributeWrapper,"]"].join("");
this.options.fieldRel="[rel="+this.options.attribute+"="+this.options.attributeWrapper;if(this.options.success){this.options.form.submit(eBind(this.autoSubmitHandler,this))
}},autoSubmitHandler:function(e){if(!this.valid){e.preventDefault();e.stopPropagation();var opts={url:this.options.form.attr("action"),data:this.options.form.serialize(),dataType:"json",type:"POST",success:bind(this.onResponse,this),error:function(response){$.console.log("ERROR",response)
}};this.options.form.ajaxSubmit(opts)}},onResponse:function(resp){if(!resp.success){this.valid=false;
this.validate(resp)}else{this.valid=true;this.options.success()}},validate:function(responseObject){$(this.options.form).find("input.error,select.error,textarea.error").removeClass("error").end().find("span.error").hide();
if(!responseObject.success){$(this.options.form).find(".tip").fadeOut("fast");if(responseObject.error.formFields){forEach(responseObject.error.formFields,this.display,this)
}}return responseObject.success},display:function(obj,key){var input=$(this.options.form).find(this.options.fieldSelector.split("%KEY%").join(key)),fieldRel=this.options.fieldRel.split("%KEY%").join(key);
input.addClass("error");if(input.siblings(fieldRel).length>0){input.siblings(fieldRel).html(obj.text).show()
}else{$('<span class="error" rel="'+this.options.attribute+"="+this.options.attributeWrapper.split("%KEY%").join(key)+'">'+obj.text+"</span>").css({top:input.position().top}).appendTo(input.parent())
}},clear:function(){$(this.options.form).find(".tip").css("display","inherit").end().find("span.error").remove().end().find(".error").removeClass("error")
}})})();
ustream.templates.signupChannelList='<input type="hidden" data-template="signupChannelList" /><% for( var i = 0; i < channelLength; i++ ) { %><li class="wrap"><a href="<%= channel[i].url %>" class="iwrp"><img src="<%= channel[i].image %>" alt="<%= channel[i].channelTitle %>" width="90" height="90" /></a><h3><a href="<%= channel[i].url %>"><%= channel[i].channelTitle %></a></h3><div class="joincrowdwrp"><input type="hidden" class="followUserBinary" value="{userId: <%= channel[i].channelId %>,isFollow: <%= channel[i].isFollowed %>,buttonType: \'normal\',userBasedMode: false,crowdSize: \'<%= channel[i].crowdSize %>\',emailAlerts: false,displayCrowdSize: true}" /></div></li><% } %>';
(function(){eval(ustream.namespace);ustream.classes.Myspace=$.klass({_exclusive:true,onSuccess:nullFunc,openerId:null,initialize:function(){captureEvent(ustream.events.MYSPACECONNECT,eBind(this.onConnectRequest,this));
captureEvent(ustream.events.MYSPACECONNECTED,eBind(this.onConnected,this));captureEvent(ustream.events.MYSPACEDISCONNECT,eBind(this.onDisconnectRequest,this));
captureEvent(ustream.events.MYSPACELOGOUT,eBind(this.onLogoutRequest,this))},onConnectRequest:function(e){this.onSuccess=nullFunc;
if(typeof(e)!="undefined"){if(e.eventData.openerId){this.openerId=e.eventData.openerId}if(typeof(e.eventData.onSuccess)=="function"){this.onSuccess=e.eventData.onSuccess
}}var url=ustream.vars.networkConnections.myspace.urls.connect+"&rnd=xRNDx",win=window.open(stringUtils.urlSubst(url,{opener:this.openerId,rnd:stringUtils.rndTimestamp()}),"MyspaceWindow","width=592, height=596, menubar=no, toolbar=no");
try{win.focus()}catch(e){}},onConnected:function(e){ustream.vars.networkConnections.myspace.connected=true;
if(typeof(e)!="undefined"&&typeof(e.eventData.networkConnections)=="object"){$.extend(true,ustream.vars.networkConnections,e.eventData.networkConnections||{})
}this.onSuccess.call(window,e)},onLogoutRequest:function(e){$.post(ustream.vars.networkConnections.myspace.urls.logout+"?rnd="+stringUtils.rndTimestamp(),null,bind(this.onLogoutHandler,this,e),"json")
},onLogoutHandler:function(e,response){if(response.success){$.extend(true,ustream.vars.networkConnections,response.networkConnections||{});
ustream.events.dispatch(ustream.events.MYSPACELOGGEDOUT,{networkConnections:response.networkConnections});
if(typeof(e)!="undefined"&&typeof(e.eventData.onLogout)=="function"){e.eventData.onLogout()}}else{ustream.events.dispatch(ustream.events.ERRORNOTIFICATION,{message:response.error.message})
}},onDisconnectRequest:function(e){$.post(ustream.vars.networkConnections.myspace.urls.disconnect+"?rnd="+stringUtils.rndTimestamp(),null,bind(this.onDisconnectHandler,this,e),"json")
},onDisconnectHandler:function(e,response){if(response.success){$.extend(true,ustream.vars.networkConnections.myspace,response.networkConnections.myspace);
ustream.events.dispatch(ustream.events.MYSPACEDISCONNECTED);if(typeof(e)!="undefined"&&typeof(e.eventData.onDisconnect)=="function"){e.eventData.onDisconnect()
}}else{ustream.events.dispatch(ustream.events.ERRORNOTIFICATION,{message:response.error.message})}}})
})();
(function(){eval(ustream.namespace);ustream.classes.Twitter=$.klass({_exclusive:true,onSuccess:nullFunc,openerId:null,connectWindow:null,windowTimerName:"checkTwitterWindowClose",initialize:function(){captureEvent(ustream.events.TWITTERCONNECT,eBind(this.onConnectRequest,this));
captureEvent(ustream.events.TWITTERCONNECTED,eBind(this.onConnected,this));captureEvent(ustream.events.TWITTERDISCONNECT,eBind(this.onDisconnectRequest,this));
captureEvent(ustream.events.TWITTERLOGOUT,eBind(this.onLogoutRequest,this))},checkWindowClose:function(){if(!this.connectWindow||this.connectWindow.closed){ustream.timer.remove(this.windowTimerName);
dispatchEvent(ustream.events.TWITTERCANCELLED)}},onConnectRequest:function(e){this.onSuccess=nullFunc;
if(typeof(e)!=="undefined"){if(e.eventData.openerId){this.openerId=e.eventData.openerId}if(typeof(e.eventData.onSuccess)==="function"){this.onSuccess=e.eventData.onSuccess
}}var url=ustream.vars.networkConnections.twitter.urls.connect+"&rnd=xRNDx";this.connectWindow=window.open(stringUtils.urlSubst(url,{opener:this.openerId,rnd:stringUtils.rndTimestamp()}),"TwitterWindow","width=780, height=400, menubar=no, toolbar=no");
ustream.timer.add(1000,bind(this.checkWindowClose,this),this.windowTimerName);try{this.connectWindow.focus()
}catch(err){}},onConnected:function(e){ustream.vars.networkConnections.twitter.connected=true;if(typeof(e)!=="undefined"&&typeof(e.eventData.networkConnections)==="object"){$.extend(true,ustream.vars.networkConnections,e.eventData.networkConnections||{})
}else{if(typeof(e)!=="undefined"&&typeof(e.eventData.exposedVariables)==="object"){$.extend(true,ustream.vars,e.eventData.exposedVariables||{})
}}this.onSuccess.call(window,e.eventData.exposedVariables)},onDisconnectRequest:function(e){$.post(ustream.vars.networkConnections.twitter.urls.disconnect,null,bind(this.onDisconnectHandler,this,e),"json")
},onDisconnectHandler:function(e,response){if(response.success){$.extend(true,ustream.vars.networkConnections.twitter,response.networkConnections.twitter);
dispatchEvent(ustream.events.TWITTERDISCONNECTED);if(typeof(e)!=="undefined"&&typeof(e.eventData.onDisconnect)==="function"){e.eventData.onDisconnect()
}}else{dispatchEvent(ustream.events.ERRORNOTIFICATION,{message:response.error.message})}},onLogoutRequest:function(e){var url=ustream.vars.networkConnections.twitter.urls.logout+"?rnd="+(new Date()).getTime();
$.post(url,null,bind(this.onLogoutHandler,this,e),"json")},onLogoutHandler:function(e,response){if(response.success){$.extend(true,ustream.vars.networkConnections,response.networkConnections||{});
dispatchEvent(ustream.events.TWITTERLOGGEDOUT,{networkConnections:response.networkConnections});if(typeof(e)!=="undefined"&&typeof(e.eventData.onLogout)==="function"){e.eventData.onLogout()
}}}})}());
(function(){eval(ustream.namespace);ustream.classes.Aim=$.klass({_exclusive:true,onSuccess:nullFunc,openerId:null,initialize:function(){this.connPrefs=ustream.vars.networkConnections.aim;
captureEvent(ustream.events.AIMCONNECT,eBind(this.onConnectRequest,this));captureEvent(ustream.events.AIMCONNECTED,eBind(this.onConnected,this));
captureEvent(ustream.events.AIMDISCONNECT,eBind(this.onDisconnectRequest,this));captureEvent(ustream.events.AIMLOGOUT,eBind(this.onLogoutRequest,this))
},onConnectRequest:function(e){this.onSuccess=nullFunc;if(typeof(e)!="undefined"){if(e.eventData.openerId){this.openerId=e.eventData.openerId
}if(typeof(e.eventData.onSuccess)=="function"){this.onSuccess=e.eventData.onSuccess}}var url=this.connPrefs.urls.connect+"&rnd=xRNDx",win=window.open(stringUtils.urlSubst(url,{opener:this.openerId,rnd:stringUtils.rndTimestamp()}),"AimWindow","width=550, height=248, menubar=no, toolbar=no");
try{win.focus()}catch(e){}},onConnected:function(e){this.connPrefs.connected=true;var nc=ustream.vars.networkConnections;
if(typeof(e)!="undefined"&&typeof(e.eventData.networkConnections)=="object"){$.extend(true,ustream.vars.networkConnections,e.eventData.networkConnections||{})
}this.onSuccess.call(window,e)},onLogoutRequest:function(e){$.post(this.connPrefs.urls.logout,null,bind(this.onLogoutHandler,this,e),"json")
},onLogoutHandler:function(e,response){if(!response.success){return this.showError(response)}$.extend(true,ustream.vars.networkConnections,response.networkConnections||{});
dispatchEvent(ustream.events.AIMLOGGEDOUT,{networkConnections:response.networkConnections});if(typeof(e)!="undefined"&&typeof(e.eventData.onLogout)=="function"){e.eventData.onLogout()
}},onDisconnectRequest:function(e){$.post(this.connPrefs.urls.disconnect,null,bind(this.onDisconnectHandler,this,e),"json")
},onDisconnectHandler:function(e,response){if(!response.success){return this.showError(response)}$.extend(true,ustream.vars.networkConnections.aim,response.networkConnections.aim||{});
dispatchEvent(ustream.events.AIMDISCONNECTED);if(typeof(e)!="undefined"&&typeof(e.eventData.onDisconnect)=="function"){e.eventData.onDisconnect()
}},showError:function(response){var msg=_t_("js.v3.aim.error");if(response&&response.error&&response.error.message){msg=response.error.message
}dispatchEvent(ustream.events.ERRORNOTIFICATION,{message:msg})}})})();
ustream.templates.findFriends='<div><input type="hidden" data-template="findFriends" /><div class="tabbedTitleBox followLister" id="<%= typeof(id) == "string" ? id : "" %>"><ul class="title"><% if( typeof(active) == "undefined") { %><% var active = 0; %><% } %><% forEach(titles, function(s, i){ %><li class="tab tab<%= i %> <%= i == active ? "active" : "" %>"><b></b><%= s %></li><% }); %></ul><div class="content"><% forEach(titles, function(s, i){ %><div class="tabPageContent tpCont<%= i %> pGroup pGroup<%= i %>"></div><% }); %></div></div></div>';
ustream.templates.findFriendsSuccess='<input type="hidden" data-template="findFriendsSuccess" /><% var formClassName = "cf" + provider.charAt(0).toUpperCase() + provider.slice(1); %><div class="connectorForm <%= formClassName %>"><p><% if (numberOfCrowds * 1 > 1) { %><%= _t_("js.v3.find_friends.succ_joined_crowds_plural", {n: numberOfCrowds}) %><% } else if (numberOfCrowds * 1 > 0) { %><%= _t_("js.v3.find_friends.succ_joined_crowds_singular", {n: numberOfCrowds}) %><% } else { %><% switch (provider) { case "facebook": %><%= _t_("js.v3.find_friends.nosucc_havent_joined_facebook", "We did not find any of your Facebook friends on Ustream.") %><% break; case "twitter": %><%= _t_("js.v3.find_friends.nosucc_havent_joined_twitter", "We did not find any of your Twitter friends on Ustream.") %><% break; case "myspace": %><%= _t_("js.v3.find_friends.nosucc_havent_joined_myspace", "We did not find any of your MySpace friends on Ustream.") %><% break; case "aim": %><%= _t_("js.v3.find_friends.nosucc_havent_joined_aim", "We did not find any of your AIM friends on Ustream.") %><% break; default: %><%= _t_("js.v3.find_friends.nosucc_havent_joined", "We did not find any of your friends on Ustream.") %><% break; %><% } %><% } %></p><p><%= _t_("js.v3.find_friends.other_networks")%></p></div><div class="endBtns"><a href="#" class="button closeSelf"><%= _t_("js.v3.find_friends.finish_action")%></a>&nbsp;</div>';
ustream.templates.findFriendLister='<div class="connectorForm cfLister" data-template="findFriendLister"><div class="intro"><%= message %></div><% if (records.length) { %><div class="cfListMain"><div class="cfListSelectAll"><% var hasMore=false, i = records.length, record; %><% while(i-- && !hasMore){ %><% record = records[i]; %><% if (!record.inCrowd) { %><input type="checkbox" /><label><%= _t_("js.v3.find_friends.select_all") %></label><% hasMore = true; %><% } %><% } %></div><ul><% forEach(records, function(record){ %><li><div class="colChkBox"><% if (!record.inCrowd) { %><input type="checkbox" value="<%= record.userId %>" /><% } %></div><div class="colPic"><img width="40" height="40" alt="" src="<%= record.userPicture %>" /></div><div class="colDesc"><div class="realName"><%= record.userSocialName %></div><div class="userName"><%= _t_("js.v3.find_friends.label_username") %>: <%= record.userName %></div><% if(record.userSocialNickName) { %><div class="miscText"><%= record.userSocialNickName %></div><% } %></div><div class="clb"></div></li><% }); %></ul></div><div class="endBtns"><a href="#" class="button btnSend disabled"><%= _t_("js.v3.find_friends.join_crowds") %></a>&nbsp;<a href="#" class="button btnSkip"><%= _t_("js.v3.find_friends.skip") %></a></div><% } else { %><p class="emptyList"><%= _t_("js.v3.find_friends.empty_list") %></p><% } %></div>';
(function(){eval(ustream.namespace);ustream.classes.FindFriendLister=$.klass({options:{message:"",connPrefs:null,postUrl:"/ajax/crowd/join.json",onSent:function(){},onSkip:function(){},onEmpty:function(){}},html:ustream.templates.findFriendLister,initialize:function(target,options){this.target=$(target);
this.options=merge(this.options,options||{});this.cover=this.options.cover?this.options.cover:new ustream.classes.CoverLayer(this.target);
this.cover.show({height:130});if(this._debug){this.onListResponse(this._testResp);return}var ffUrl=this.options.connPrefs.urls.findFriends;
$.getJSON(ffUrl,null,bind(this.onListResponse,this))},onListResponse:function(resp){this.buildHtml(resp)
},buildHtml:function(resp){this.cover.hide();this.options.connPrefs.numberOfFriends=resp.data.length;
if(!resp.data.length){this.options.onEmpty();return}this.html=new ustream.classes.SimpleTpl(this.html);
this.htmlIntro=new ustream.classes.SimpleTpl(this.options.message);var params={message:this.htmlIntro.run(merge(this.options.connPrefs,resp)),url:this.options.url,records:resp.data};
this.target.html(this.html.run(params)).parents(".ui-dialog-content").dialog("option","position","center").end().find(".cfListSelectAll input").click(eBind(this.selecteDeselectAll,this)).end().find(".cfListMain ul li input").change(eBind(this.manageSendBtnState,this)).end().find(".btnSend").click(eBind(this.onSendClick,this)).end().find(".btnSkip").click(eBind(this.onSkipClick,this)).end();
this.forceSelectAll()},forceSelectAll:function(){this.target.find(".cfListMain input[type=checkbox]").prop("checked",true);
this.manageSendBtnState()},selecteDeselectAll:function(){var checked=this.target.find(".cfListSelectAll input").is(":checked");
this.target.find(".cfListMain ul input").prop("checked",checked);this.manageSendBtnState()},manageSendBtnState:function(){var checkedNum=this.target.find(".cfListMain ul input:checked");
this.target.find(".btnSend").removeClass("disabled").addClassIf("disabled",!checkedNum.length)},onSendClick:function(e){e.preventDefault();
e.stopPropagation();if($(e.target).hasClass("disabled")){return}var users=[];this.target.find(".cfListMain ul input:checked").each(function(){users.push($(this).val()*1)
});this.cover.relocate(this.target);this.cover.show();if(!users.length){this.onSkipClick()}this.options.connPrefs.numberOfCrowds=users.length;
if(this._debug){setTimeout(bind(function(){this.onSent(this._postTestResp)},this),1000);return}$.post(this.options.postUrl,{crowdUserIds:users},bind(this.onSent,this),"JSON")
},onSent:function(resp){this.cover.hide();if(this.options.onSent){this.options.onSent()}},onSkipClick:function(e){if(e){e.preventDefault();
e.stopPropagation()}if(this.options.onSkip){this.options.onSkip()}}})})();
(function(){eval(ustream.namespace);ustream.classes.CrowdConnectorForm=$.klass({connPrefs:{},initialize:function(target,options){this.target=$(target);
this.target.click(eBind(this.onContainerClick,this));$.extend(true,this,this.options||{});this.connPrefs=ustream.vars.networkConnections[this.name]
},addCover:function(options){this.cover=new ustream.classes.CoverLayer(this.target);if(options&&options.show){this.cover.show()
}},onContainerClick:function(e){var el=$(e.target);if(el.hasClass("closeSelf")){this.closeSelf();e.preventDefault();
e.stopPropagation();return}},closeSelf:function(){this.target.closest(".ui-dialog").find("a:first").click()
},activate:function(){},buildHtml:function(){},unCover:function(){if(this.cover){this.cover.hide()}},onSuccessfulSimpleDisconnect:function(){this.unCover();
this.connPrefs.connected=false;this.activate()}})})();
(function(){eval(ustream.namespace);ustream.classes.CrowdConnectorFormFacebook=ustream.classes.CrowdConnectorForm.extend({name:"facebook",html:'<div class="connectorForm cfFacebook">'+_t_("js.v3.crowd_customization_form.click_to_connect",{service:"Facebook"})+'<br /><br /><a href="#" value="tpCont" class="button connect facebook"><span></span>'+_t_("js.v3.crowd_customization_form.connect_with",{service:"Facebook"})+"</a></div>",errorHtml:'<div class="connectorForm cfFacebook">'+_t_("js.v3.crowd_customization_form.error_in_connect",{service:"Facebook"})+"</div>",initialize:function(target,options){this.parent(target,options);
captureEvent(ustream.events.FACEBOOKCONNECTFAILURE,bind(this.unCover,this));captureEvent(ustream.events.FACEBOOKCONNECTED,bind(this.onSuccessfulConn,this));
this.openerId="findFriends"},activate:function(){this.addCover({show:true});if(!ustream.vars.networkConnections.facebook.connected){this.html=$(this.html);
this.target.html(this.html);this.addCover();this.html.find("a.button").click(eBind(function(e){e.preventDefault();
e.stopPropagation();this.addCover({show:true});dispatchEvent(ustream.events.FACEBOOKCONNECT,{openerId:this.openerId})
},this))}else{this.unCover();this.createStep2()}},onSuccessfulConn:function(e){this.unCover();var data=e.eventData;
this.connPrefs=data.exposedVariables.networkConnections.facebook;if(e.eventData.opener==this.openerId){this.createStep2()
}},createStep2:function(){this.fl=new ustream.classes.FindFriendLister(this.target,{message:'<%= _t_("js.v3.crowd_customization_form_facebook.hey_user", {profileName: profileName, profileUrl: profileUrl}) %><br /><%= _t_("js.v3.crowd_customization_form_facebook.number_of_your_friends", {dataLength: data.length}) %>',connPrefs:this.connPrefs,cover:this.cover,onSkip:bind(this.closeSelf,this),onEmpty:bind(this.createStep3,this),onSent:bind(this.createStep3,this)})
},createStep3:function(){var html=new ustream.classes.SimpleTpl(ustream.templates.findFriendsSuccess);
if(!this.connPrefs.numberOfCrowds){this.connPrefs.numberOfCrowds=0}html=html.run(merge(this.connPrefs,{provider:"facebook"}));
this.target.html(html)}})})();
(function(){eval(ustream.namespace);ustream.classes.CrowdConnectorFormTwitter=ustream.classes.CrowdConnectorForm.extend({name:"twitter",html:'<div class="connectorForm cfTwitter">'+_t_("js.v3.crowd_customization_form.click_to_connect",{service:"Twitter"})+'<br /><br /><a href="#" value="tpCont" class="button connect twitter"><span></span>'+_t_("js.v3.crowd_customization_form.connect_with",{service:"Twitter"})+"</a></div>",initialize:function(target,options){this.parent(target,options)
},activate:function(){if(!this.connPrefs.connected){this.html=$(this.html);this.target.html(this.html);
this.addCover();this.html.find("a.button").click(eBind(function(e){e.preventDefault();e.stopPropagation();
dispatchEvent(ustream.events.TWITTERCONNECT,{openerId:"findFriends",onSuccess:bind(this.onSuccessfulConn,this)})
},this))}else{this.createStep2()}},onSuccessfulConn:function(e){if(typeof(e.eventData)!=="undefined"){this.connPrefs=merge(this.connPrefs,e.eventData.networkConnections.twitter)
}this.connPrefs.connected=true;this.createStep2()},createStep2:function(){this.fl=new ustream.classes.FindFriendLister(this.target,{message:'<%= _t_("js.v3.crowd_customization_form_twitter.hey_user", {profileName: profileName, profileUrl: profileUrl}) %><br /><%= _t_("js.v3.crowd_customization_form_twitter.number_of_your_friends", {dataLength: data.length}) %>',connPrefs:this.connPrefs,cover:this.cover,onSkip:bind(this.closeSelf,this),onEmpty:bind(this.createStep3,this),onSent:bind(this.createStep3,this)})
},createStep3:function(){var html=new ustream.classes.SimpleTpl(ustream.templates.findFriendsSuccess);
if(!this.connPrefs.numberOfCrowds){this.connPrefs.numberOfCrowds=0}html=html.run(merge(this.connPrefs,{provider:"twitter"}));
this.target.html(html)}})})();
(function(){eval(ustream.namespace);ustream.classes.CrowdConnectorFormMyspace=ustream.classes.CrowdConnectorForm.extend({name:"myspace",html:'<div class="connectorForm cfMyspace">'+_t_("js.v3.crowd_customization_form.click_to_connect",{service:"MySpace"})+'<br /><br /><a href="#" value="tpCont" class="button connect myspace"><span></span>'+_t_("js.v3.crowd_customization_form.connect_with",{service:"MySpace"})+"</a></div>",initialize:function(target,options){this.parent(target,options)
},activate:function(){if(!this.connPrefs.connected){this.html=$(this.html);this.target.html(this.html);
this.addCover();this.html.find("a.button").click(eBind(function(e){e.preventDefault();e.stopPropagation();
dispatchEvent(ustream.events.MYSPACECONNECT,{openerId:"findFriends",onSuccess:bind(this.onSuccessfulConn,this)})
},this))}else{this.createStep2()}},onSuccessfulConn:function(e){if(typeof(e.eventData)!="undefined"){this.connPrefs=merge(this.connPrefs||{},e.eventData.networkConnections.myspace)
}this.connPrefs.connected=true;this.createStep2()},createStep2:function(){this.fl=new ustream.classes.FindFriendLister(this.target,{message:'<%= _t_("js.v3.crowd_customization_form_myspace.hey_user", {profileName: profileName, profileUrl: profileUrl}) %><br /><%= _t_("js.v3.crowd_customization_form_myspace.number_of_your_friends", {dataLength: data.length}) %>',connPrefs:this.connPrefs,cover:this.cover,onSkip:bind(this.closeSelf,this),onEmpty:bind(this.createStep3,this),onSent:bind(this.createStep3,this)})
},createStep3:function(){var html=new ustream.classes.SimpleTpl(ustream.templates.findFriendsSuccess);
if(!this.connPrefs.numberOfCrowds){this.connPrefs.numberOfCrowds=0}html=html.run(merge(this.connPrefs,{provider:"myspace"}));
this.target.html(html)}})})();
(function(){eval(ustream.namespace);ustream.classes.CrowdConnectorFormAim=ustream.classes.CrowdConnectorForm.extend({name:"aim",html:'<div class="connectorForm cfAim">'+_t_("js.v3.crowd_customization_form.click_to_connect",{service:"AIM"})+'<br /><br /><a href="#" value="tpCont" class="button connect aim"><span></span>'+_t_("js.v3.crowd_customization_form.connect_with",{service:"AIM"})+"</a></div>",initialize:function(target,options){this.parent(target,options)
},activate:function(){if(!this.connPrefs.connected){this.html=$(this.html);this.target.html(this.html);
this.addCover();this.html.find("a.button").click(eBind(function(e){e.preventDefault();e.stopPropagation();
dispatchEvent(ustream.events.AIMCONNECT,{openerId:"findFriends",onSuccess:bind(this.onSuccessfulConn,this)})
},this))}else{this.createStep2()}},onSuccessfulConn:function(e){if(typeof(e.eventData)!="undefined"){this.connPrefs=merge(this.connPrefs||{},e.eventData.networkConnections.aim)
}this.connPrefs.connected=true;this.createStep2()},createStep2:function(){this.fl=new ustream.classes.FindFriendLister(this.target,{message:'<%= _t_("js.v3.crowd_customization_form_aim.hey_user", {profileName: profileName}) %><br /><%= _t_("js.v3.crowd_customization_form_aim.number_of_your_friends", {dataLength: data.length}) %>',connPrefs:this.connPrefs,cover:this.cover,onSkip:bind(this.closeSelf,this),onEmpty:bind(this.createStep3,this),onSent:bind(this.createStep3,this)})
},createStep3:function(){var html=new ustream.classes.SimpleTpl(ustream.templates.findFriendsSuccess);
if(!this.connPrefs.numberOfCrowds){this.connPrefs.numberOfCrowds=0}html=html.run(merge(this.connPrefs,{provider:"aim"}));
this.target.html(html)}})})();
(function(){eval(ustream.namespace);ustream.classes.FindFriends=$.klass({_exclusive:true,tabNames:["facebook","twitter","myspace","aim"],tabTitles:["Facebook","Twitter","MySpace","AIM"],initialize:function(){var nc=ustream.vars.networkConnections,html=new ustream.classes.SimpleTpl(ustream.templates.findFriends);
this.html=$(html.run({titles:this.tabTitles}));this.html.dialog({modal:true,title:_t_("js.v3.find_friends.dialog_title"),id:"FindFriendsDialog",autoOpen:false,width:450,minHeight:200});
this.lastActiveTabName=this.tabNames[0];this.tabNamesObj={};for(var i=0;i<this.tabNames.length;i++){this.tabNamesObj[this.tabNames[i]]=i
}this.attachOpenerToButton();this.createTabs();this.addTabBox()},attachOpenerToButton:function(){$("#FindFriendsBox a.link, #FindFriendsBoxLink, #FindFriendsBox a.openFindFriends").click(eBind(function(e){e.preventDefault();
e.stopPropagation();var tab=$(e.target).attr("data-tab");if(tab){this.open(tab)}else{this.open()}},this))
},addTabBox:function(){this.tabBox=new ustream.classes.TabbedTitleBox(this.html,{onActiveTabSet:bind(function(n){this.lastActiveTabName=this.tabNames[n];
this.tabs[this.lastActiveTabName].activate()},this),lazyActivate:true})},createTabs:function(){var locate=bind(function(i){return this.html.find(".tpCont"+i).get(0)
},this);this.tabs={facebook:new ustream.classes.CrowdConnectorFormFacebook(locate(0)),twitter:new ustream.classes.CrowdConnectorFormTwitter(locate(1)),myspace:new ustream.classes.CrowdConnectorFormMyspace(locate(2)),aim:new ustream.classes.CrowdConnectorFormAim(locate(3))}
},open:function(tabType){if(typeof tabType=="undefined"){tabType=this.lastActiveTabName}this.html.dialog("open");
var idx=this.tabNamesObj[tabType];this.tabBox.setActiveTab(idx)}})})();
(function(){eval(ustream.namespace);ustream.classes.App=ustream.classes.CommonPage.extend({channelListTpl:ustream.templates.signupChannelList,initialize:function(){var myspace,twitter,aim;
this.parent();myspace=new ustream.classes.Myspace();twitter=new ustream.classes.Twitter();aim=new ustream.classes.Aim()
},pSignupLoginSignup:function(){this.form=$("#EnterForm");this.countValidate=0;this.validator=new ustream.classes.Validator2({form:this.form,rules:{"signup[firstname]":{required:true},"signup[lastname]":{required:true},"signup[username]":{required:true,minlength:4,maxlength:20,freeusername:true},"signup[password]":{required:true,userpassword:true},"signup[passwordVerify]":{required:true,equalTo:"#Signup_Password"},"signup[email]":{required:true,email:true,uniquemail:true},"signup[countryId]":{required:true},"signup[stateId]":{required:true},"signup[zipCode]":{required:true},"signup[gender]":{required:true},"signup[birthYear]":{required:true},"signup[birthMonth]":{required:true},"signup[birthDay]":{required:true},"signup[agree]":{required:true},adcopy_response:{required:true}},groups:{birthDate:"signup[birthYear] signup[birthMonth] signup[birthDay]"},messages:{},submitHandler:$.proxy(this.signUpFormSubmitHandler,this),invalidHandler:$.proxy(this.signUpFormInvalidHandler,this)});
$("#Country").change($.proxy(this.updateState,this));$("#Signup_Terms, #Signup_Privacy").click(function(){window.open($(this).attr("href"),"terms","width=519,height=300,status=1,resizable=1,scrollbars=1")
})},updateState:function(){if($("#Country").val()===ustream.vars.countryUs){$("#StateUS").get(0).selectedIndex=0
}else{$("#StateUS").get(0).selectedIndex=1}},reloadCaptcha:function(){if(typeof window.ACPuzzle!=="undefined"&&$("#adcopy-outer").length>0){window.ACPuzzle.reload()
}},signUpFormInvalidHandler:function(){this.countValidate+=1},signUpFormSubmitHandler:function(e){this.form.find("input.submit").prop("disabled",true).parent().append('<span class="loading"><img src="'+ustream.vars.staticUrl+'images/ajax-loader-small.gif" alt="" /></span>');
this.form.ajaxSubmit({success:$.proxy(this.signUpFormSubmitResponseHandler,this),error:$.proxy(this.signUpFormErrorResponseHandler,this)})
},signUpFormSubmitResponseHandler:function(response){this.form.find("input.submit").prop("disabled",false).parent().find("span.loading").remove();
if(response.success&&response.redirectUrl){window.location.href=response.redirectUrl}else{if(response.error&&response.error.message){ustream.events.dispatch(ustream.events.ERRORNOTIFICATION,{message:response.error.message});
this.reloadCaptcha()}else{ustream.events.dispatch(ustream.events.ERRORNOTIFICATION,{message:_t_("js.common_for_all.unknown_error")});
this.reloadCaptcha()}if(response.error&&response.error.formFields){var errors={};$.forEach(response.error.formFields,function(value,name){if(name==="signup[birthday]"){name="signup[birthDay]"
}if(name){errors[name]=value.text}},this);this.validator.showErrors(errors);this.reloadCaptcha()}}},signUpFormErrorResponseHandler:function(){ustream.events.dispatch(ustream.events.ERRORNOTIFICATION,{message:_t_("js.common_for_all.unknown_error")});
this.reloadCaptcha()},pSignupRecommendations:function(){this.channelListTpl=new ustream.classes.SimpleTpl(this.channelListTpl);
$("#Content ul.menu a").click($.proxy(function(e){e.preventDefault();e.stopPropagation();var el=$(e.target);
el=el.is("a")?el:el.closest("a");el.parent().parent().find("li").removeClass("active").eq(el.parent().index()).addClass("active");
this.recommendCoverLayer=new ustream.classes.CoverLayer($("#channelList"),{show:true});$.ajax({url:el.attr("href"),success:$.proxy(this.loadChannels,this)})
},this))},loadChannels:function(resp){var followUser;$("#channelList").html(this.channelListTpl.run({channel:resp.data,channelLength:resp.data.length}));
dispatchEvent("manageFollowButtons");this.recommendCoverLayer.hide()},pSignupFindFriends:function(){var emailFriendFinder=false;
this.findFriendsDialog=new ustream.classes.FindFriends();$("#FindBySocial a.button").click($.proxy(function(e){e.preventDefault();
e.stopPropagation();var el=$(e.target);if(el.hasClass("facebook")){this.findFriendsDialog.open()}else{if(el.hasClass("myspace")){this.findFriendsDialog.open("myspace")
}else{if(el.hasClass("twitter")){this.findFriendsDialog.open("twitter")}else{if(el.hasClass("aim")){this.findFriendsDialog.open("aim")
}}}}},this));$("#FindByEmail button").click($.proxy(function(e){var user,pass;e.preventDefault();e.stopPropagation();
if(!emailFriendFinder){emailFriendFinder=new ustream.classes.EmailFriendFinder({onSocialFindAction:$.proxy(function(){this.findFriendsDialog.open()
},this)})}user=$("#EmailFriendUsername").val();pass=$("#EmailFriendPassword").val();if(user.length>0&&pass.length>0){emailFriendFinder.show(user,pass)
}},this));$("#FindByEmail .supportedServices").click($.proxy(function(e){e.preventDefault();e.stopPropagation();
if(!emailFriendFinder){emailFriendFinder=new ustream.classes.EmailFriendFinder({onSocialFindAction:$.proxy(function(){this.findFriendsDialog.open()
},this)})}emailFriendFinder.showSupported()},this));$("#FindByEmailForm").submit($.proxy(function(e){var user,pass;
e.preventDefault();e.stopPropagation();user=$("#EmailFriendUsername").val();pass=$("#EmailFriendPassword").val();
if(user.length>0&&pass.length>0){emailFriendFinder.show(user,pass)}},this))}})}());

