
var REMOVE_BOX_ONLY=1;var REMOVE_ENTIRE_APP=2;var REMOVE_LINK_ONLY=3;function removeActionLink(obj,application_name,app_id){var dialog=new contextual_dialog();dialog.set_context(obj);buttons='<div class="dialog_buttons">'+'<input class="inputsubmit" type="button" value="Remove Link" />'+'<input class="inputsubmit" type="button" value="Remove Application" />'+'<input class="inputsubmit" type="button" value="Cancel" />'+'</div>';var prompt='You can remove this link or remove this application from your account.';add_css_class_name(obj,'box_remove_selected');dialog.show_prompt('Do you want to remove this link from '+application_name+'?',prompt+buttons);dialog_options=dialog.obj.getElementsByTagName('input');dialog_options[0].onclick=function(){remove_app(REMOVE_LINK_ONLY,app_id,'pra');dialog.hide();}
dialog_options[1].onclick=function(){remove_app(REMOVE_ENTIRE_APP,app_id,'pra');dialog.hide();}
dialog_options[2].onclick=function(){dialog.hide();remove_css_class_name(obj,'box_remove_selected');}
return false;}
function remove_app(remove_type,app_id,ref){var error_message;if(remove_type==REMOVE_BOX_ONLY){error_message='Sorry, removing this profile box failed.';remove_app_box_from_page(app_id);remove_app_icon_from_page_profile(app_id);}else if(remove_type==REMOVE_LINK_ONLY){error_message='Sorry, removing this profile link failed.';remove_app_link_from_page_profile(app_id);}else{error_message='Sorry, removing this application failed.';remove_app_box_from_page(app_id);remove_app_icon_from_page_profile(app_id);remove_app_link_from_side_nav(app_id);remove_app_link_from_page_profile(app_id);}
ajax_remove_application(app_id,PROFILE_FBID,remove_type,ref,error_message);}
function ajax_remove_application(app_id,profile_fbid,remove_type,ref,error_message){if(!error_message){error_message='Sorry, removing this application failed';}
var ajax=new Ajax(function(obj,text){eval(text);if(!success){Util.error(error_message+'for app %d.',app_id);aiert(error_message);}});ajax.onFail=function(){Util.error(error_message+'for app %d.',app_id);aiert(error_message);}
var post={'profile_fbid':profile_fbid,'app_id':app_id,'remove_type':remove_type,'ref':ref};ajax.post('/ajax/profile_boxes.php',post,true);}
function remove_app_box_from_page(app_id){if(ge('box_app_'+app_id)){$('box_app_'+app_id).style.display='none';}}
function remove_app_link_from_side_nav(app_id){app_id=String(app_id);if(ge(app_id)){$(''+app_id).style.display='none';}}
function remove_app_icon_from_page_profile(app_id){var app_icon_id='icon_app'+app_id;if(ge(app_icon_id)){$(app_icon_id).style.display='none';}}
function remove_app_link_from_page_profile(app_id){if(ge('action_app_'+app_id)){$('action_app_'+app_id).style.display='none';}}
function removeBox(obj,application_name,app_id){var dialog=new contextual_dialog();dialog.set_context(obj);buttons='<div class="dialog_buttons">'+'<input class="inputsubmit" type="button" value="Remove Application" />'+'<input class="inputsubmit" type="button" value="Remove Box" />'+'<input class="inputsubmit" type="button" value="Cancel" />'+'</div>';var remove_prompt='You can remove this application box from your profile or '+'remove this application from your account entirely.';dialog.show_prompt('Do you want to remove '+application_name+'?',dialog.content_to_markup(remove_prompt)+buttons);add_css_class_name(obj,'box_remove_selected');dialog_options=dialog.obj.getElementsByTagName('input');dialog_options[0].onclick=function(){remove_app(REMOVE_ENTIRE_APP,app_id,'prb');dialog.hide();}
dialog_options[1].onclick=function(){remove_app(REMOVE_BOX_ONLY,app_id,'prb');dialog.hide();}
dialog_options[2].onclick=function(){dialog.hide();remove_css_class_name(obj,'box_remove_selected');}
return false;}
function flexToggle(el){if(el.className=='flex_open'){el.className='flex_shut';profileFlexAjax(el.id,1);}else{el.className='flex_open';profileFlexAjax(el.id,0);}}
var all_boxes_open=true;function allBoxesFlexToggle(){all_boxes_open=!all_boxes_open;var text_el=ge('profile_view_button_text');var userprofile=ge('userprofile');if(all_boxes_open){text_el.innerHTML='Minimize Profile';remove_css_class_name(userprofile,'collapsed_mode');}else{text_el.innerHTML='Expand Profile';add_css_class_name(userprofile,'collapsed_mode');}
return false;}
function boxFlexSet(el,open){if(open==true&&has_css_class_name(el,'flex_shut')){remove_css_class_name(el,'flex_shut');add_css_class_name(el,'flex_open');}else if(open==false&&has_css_class_name(el,'flex_open')){remove_css_class_name(el,'flex_open');add_css_class_name(el,'flex_shut');}}
function boxFlexToggle(el){var userprofile=ge('userprofile');if(has_css_class_name(userprofile,'collapsed_mode')){remove_css_class_name(userprofile,'collapsed_mode');remove_css_class_name(el,'flex_shut');add_css_class_name(el,'flex_open');animate_scroll_to_id(el.id,5);profileBoxFlexAjax(el.id,0);return;}
if(has_css_class_name(el,'flex_open')){remove_css_class_name(el,'flex_open');add_css_class_name(el,'flex_shut');profileBoxFlexAjax(el.id,1);}else{remove_css_class_name(el,'flex_shut');add_css_class_name(el,'flex_open');profileBoxFlexAjax(el.id,0);}
el.blur();return false;}
function profileFlexAjax(elId,val){var ajax=new Ajax();ajax.onDone=function(){};ajax.onFail=function(){};ajax.post('/ajax/profile_flex_ajax.php',elId+'='+val);}
function profileBoxFlexAjax(elId,val){var ajax=new Ajax();ajax.onDone=function(){};ajax.onFail=function(){}
ajax.post('/ajax/profile_box_flex_ajax.php',{'app_id':elId,'value':val});}
var mf_uninstalled_apps={};function minifeed_hide(clicked_element,story_id,who,app_id,installed,hash,story_type){var minifeed_dialog_handle=new contextual_dialog();minifeed_dialog_handle.set_context(clicked_element);var title='Are you sure you want to hide this Mini-Feed story?';var message='Hiding will remove the story from '+who+' Mini-Feed and '+'prevent anyone from seeing it.';var hide_story=function(){minifeed_hide_click(story_id);generic_dialog.get_dialog(this).fade_out(100);};var hide_inaccurate_app_story=function(){minifeed_hide_click(story_id,true,story_type,app_id,hash);generic_dialog.get_dialog(this).fade_out(100);};var hide_story_and_remove_app=function(){minifeed_hide_click(story_id,true,story_type,app_id,hash);remove_app(REMOVE_ENTIRE_APP,app_id,'mf');mf_uninstalled_apps[app_id]=true;generic_dialog.get_dialog(this).fade_out(100);};var cancel=function(){generic_dialog.get_dialog(this).fade_out(100);};var inaccurate_installed_app=function(){var uninstall_title='Inaccurate application story';var uninstall_message='You told us the story published by this application was inaccurate.  '+'Thanks for the feedback.  In addition to hiding the story, would you '+'also like to remove this application from your account entirely?';minifeed_dialog_handle.show_choice(uninstall_title,uninstall_message,'Just Hide Story',hide_inaccurate_app_story,'Remove Application',hide_story_and_remove_app,'','Cancel',cancel);var dialog_popup=minifeed_dialog_handle.obj.firstChild;dialog_popup.className='remove_app_dialog_popup '+dialog_popup.className;};if(app_id){message+=' If you are removing this because it is inaccurate, click on "I didn\'t do this".';var inaccurate_function;if(installed&&!mf_uninstalled_apps[app_id]){inaccurate_function=inaccurate_installed_app;}else{inaccurate_function=hide_inaccurate_app_story;}
minifeed_dialog_handle.show_choice(title,message,'Hide Story',hide_story,'I didn\'t do this',inaccurate_function,'','Cancel',cancel);}else{minifeed_dialog_handle.show_choice(title,message,'Hide Story',hide_story,'Cancel',cancel);}
return false;}
function minifeed_hide_click(hide_id,inaccurate,story_type,app_id,hash){ajax=new Ajax();ajax.onDone=function(){};ajax.onFail=function(){aiert("Sorry, hiding this story failed");};story=ge('story_'+hide_id);if(story.previousSibling.className=='date_divider'&&story.nextSibling.className.indexOf('story')==-1){remove_node(story.previousSibling);}else if(story.previousSibling.className=='date_divider'){story.nextSibling.className+=' no_border';}
remove_node(story);minifeed_decrement_story_count();var post={'hide_ministory_key':hide_id,'profile_fbid':PROFILE_FBID};if(inaccurate){post['inaccurate']=1;post['app_id']=app_id;post['story_type']=story_type;post['hash']=hash;}
ajax.post('/ajax/minifeed.php',post,true);}
function minifeed_decrement_story_count(){var text;var mf_story_count_string_array=new Array();var count_el=ge('mf_story_count_string');if(!count_el)return;var count=parseInt(count_el.innerHTML.split(' ')[0]);count=count-1;if(count==1){text='story';}else{text='stories';}
count_el.innerHTML=(count)+' '+text;}
function show_profile_layout_dialog(){var dialog=new pop_dialog();dialog.show_message('',''
);}
function show_public_profile_dialog(url){var dialog=new pop_dialog();dialog.show_message('Public Listing',''
+url
+'');}
function is_left_click(e){if(e.which==null){if(e.button<2)return true;}else{if(e.which<2)return true;}
return false;}
function isMouseLeaveOrEnter(e,handler){if(e.type!='mouseout'&&e.type!='mouseover')return false;var reltg=e.relatedTarget?e.relatedTarget:e.type=='mouseout'?e.toElement:e.fromElement;while(reltg&&reltg!=handler)
reltg=reltg.parentNode;return(reltg!=handler);}
function profile_icon_hover(icon_link){var tooltip=icon_link.previousSibling;tooltip.style.display='block';tooltip.style.zindex=1;if(has_css_class_name(tooltip,'loaded_tooltip')){visible_tooltip=tooltip;return;}
var offsetWidth=tooltip.childNodes[0].offsetWidth;tooltip.style.width=offsetWidth+'px';tooltip.style.left=-((offsetWidth-22)/2)+'px';tooltip.style.top=-24+'px';add_css_class_name(tooltip,'loaded_tooltip');visible_tooltip=tooltip;}
function clear_tooltip(icon_link){var tooltip=icon_link.previousSibling;tooltip.style.display='none';}
function profile_app_switcher_select(scroll_element_id,app_id){boxFlexSet($('box_head_'+app_id).parentNode,1);make_header_blue(app_id);animate_scroll_to_id(scroll_element_id,app_id);return false;}
var ANI_SCROLL_STEP_AMOUNT=250;var ANI_SCROLL_SLOWING_WINDOW=750;var ANI_SCROLL_STOP_WINDOW=13;var ANI_MAX_SLOWDOWN_AMOUNT=120;var ANI_CALLBACK_PAUSE_TIME=200;function animate_scroll_to_id(scroll_element_id,app_id){var element=(typeof app_id!='undefined')?ge('box_app_'+app_id):ge(scroll_element_id);var target_height=elementY(element);var target_bottom=target_height+element.offsetHeight;if(target_height>getPageScrollHeight()&&target_bottom<getPageScrollHeight()+getViewportHeight()){setTimeout("fade_header("+app_id+")",ANI_CALLBACK_PAUSE_TIME+400);}else{animate_scroll_to_id_helper(scroll_element_id,20,app_id,getPageScrollHeight(),'fade_header');}}
function animate_scroll_to_id_helper(scroll_element_id,scroll_speed,app_id,scroll_height,scroll_complete_callback){var element=ge(scroll_element_id);var target_height=elementY(element);var page_scroll_height=getPageScrollHeight();var scroll_dir=1;if(target_height<page_scroll_height){scroll_dir=-1;}
var scroll_amount=0;if(scroll_height!=page_scroll_height){if(scroll_complete_callback){setTimeout(scroll_complete_callback+"("+app_id+")",ANI_CALLBACK_PAUSE_TIME);}
return;}
if(!(page_scroll_height>target_height-ANI_SCROLL_SLOWING_WINDOW&&page_scroll_height<target_height+ANI_SCROLL_SLOWING_WINDOW)){scroll_amount=ANI_SCROLL_STEP_AMOUNT;}else if(!(page_scroll_height>target_height-ANI_SCROLL_STOP_WINDOW&&page_scroll_height<target_height+ANI_SCROLL_STOP_WINDOW)){scroll_amount=parseInt(Math.abs(page_scroll_height-target_height)/ANI_SCROLL_SLOWING_WINDOW*ANI_MAX_SLOWDOWN_AMOUNT);}
if(scroll_amount!=0){var expected_page_scroll_height=getPageScrollHeight()+scroll_dir*scroll_amount;window.scrollBy(0,scroll_dir*scroll_amount);setTimeout("animate_scroll_to_id_helper('"+
scroll_element_id+"',"+
scroll_speed+","+
app_id+","+
expected_page_scroll_height+",'"+
scroll_complete_callback+"')",scroll_speed);}else{window.scrollTo(0,target_height-ANI_SCROLL_STOP_WINDOW);if(scroll_complete_callback){setTimeout(scroll_complete_callback+"("+app_id+")",ANI_CALLBACK_PAUSE_TIME);}}}
function fade_header(id){var box_header=ge('box_head_'+id);remove_css_class_name(box_header,'box_head_highlight');var box=ge('box_head_'+id);if(!box){return;}
remove_css_class_name(box.parentNode,'box_outline');var old_border=ge('scroll_highlight_border');old_border.parentNode.removeChild(old_border);if(id==2719290516){$('wall_text').focus();}}
function make_header_blue(id){var newBorder=document.createElement('div');newBorder.id='scroll_highlight_border';newBorder.className="box_highlight_outline";var box=$('box_head_'+id).parentNode;newBorder.style.top=elementY(ge('box_head_'+id))-10+'px';newBorder.style.left=elementX(ge('box_head_'+id))-10+'px';newBorder.style.width=box.offsetWidth+15+'px';newBorder.style.height=box.offsetHeight+5+'px';document.body.appendChild(newBorder);var box_header=ge('box_head_'+id);}
