var he_wall={action_ids:[],wall_object:'',wall_object_id:0,action_page:false,actions_per_page:10,allow_post:false,show_video_player:false,disable_music_upload:false,list_id:-2,block_request:false,construct:function(wall_id)
{var self=this;this.wall_id=wall_id;this.$wall_container=$('wall_'+ this.wall_id);this.$actions=[];this.like_btn_locked=false;this.del_comment_btn_locked=false;this.show_more_btn_locked=false;this.$hide_action_tpl=$('hide_action_tpl');this.$remove_action_tpl=$('remove_action_tpl');this.$comment_tpl=$('comment_tpl');this.$show_more_btn=$('show_more_btn');this.$action_input=this.$wall_container.getElement('.post_action_input');this.$action_btn=this.$wall_container.getElement('.post_action_btn');this.action_ids.each(function(action_id,index)
{var $action_node=$('wall_action_'+ action_id);self.$actions[action_id]=$action_node;self.prepare_action(action_id);self.last_action_id=action_id;if(index==0)
{self.first_action_id=action_id;}});if(this.action_page)
{return false;}
this.$show_more_btn.addEvent('click',function()
{self.show_more();this.blur();});if(SocialEngine.Viewer.user_exists&&this.allow_post)
{this.prepare_post_action();}},prepare_action:function(action_id)
{if(SocialEngine.Viewer.user_exists)
{this.prepare_delete_comment(action_id);this.prepare_action_like(action_id);this.prepare_action_comment(action_id);this.prepare_action_hide(action_id);this.prepare_action_remove(action_id);}},prepare_post_action:function()
{var self=this;var start_height=this.$action_input.getStyle('height').toInt();var active_height=0;var $action_input_div=this.$action_input.getParent('.input_div');var $upload_photo_form=this.$wall_container.getElement('.upload_photo_form');var $post_link_btn=this.$wall_container.getElement('.post_link_btn');var $post_video_btn=this.$wall_container.getElement('.post_video_btn');var $video_providers=this.$wall_container.getElement('.video_provider');this.prepare_action_tabs();this.$action_input.addEvent('focus',function()
{$action_input_div.addClass('active');this.value=(this.value==SELanguage.Translate(690706010))?'':this.value;if(active_height==0)
{active_height=this.getStyle('height').toInt();}
if(this.value=='')
{this.setStyle('height',active_height);}}).addEvent('blur',function()
{if(this.value!=''){return false;}
$action_input_div.removeClass('active');this.setStyle('height',start_height);this.value=(this.value=='')?SELanguage.Translate(690706010):this.value;}).addEvent('scroll',function()
{var inc_height=(Browser.Engine.trident)?16:7;var height=this.getStyle('height').toInt();if(height>180){return false;}
this.setStyle('height',height+ inc_height);});this.$action_btn.addEvent('click',function()
{self.post_action();});$post_link_btn.addEvent('click',function()
{self.post_link(this);});$post_video_btn.addEvent('click',function()
{self.post_video(this);});$video_providers.addEvent('change',function()
{var $parent_cont=this.getParent('.video_provider_div');$parent_cont.removeClass('youtube_video').removeClass('vimeo_video');if(this.value=='vimeo')
{$parent_cont.addClass('vimeo_video');}
else if(this.value=='youtube')
{$parent_cont.addClass('youtube_video');}});this.prepare_action_privacy();},prepare_action_tabs:function()
{var self=this;var $tab_icons=this.$wall_container.getElements('.wall_tab_icon');var $upload_photo_btn=this.$wall_container.getElement('.upload_photo_btn');var $add_link_btn=this.$wall_container.getElement('.add_link_btn');var $add_music_btn=this.$wall_container.getElement('.add_music_btn');var $add_video_btn=this.$wall_container.getElement('.add_video_btn');var $default_tab=this.$wall_container.getElement('.default_tab');var $upload_photo_tab=this.$wall_container.getElement('.upload_photo_tab');var $add_link_tab=this.$wall_container.getElement('.add_link_tab');var $add_music_tab=this.$wall_container.getElement('.add_music_tab');var $add_video_tab=this.$wall_container.getElement('.add_video_tab');var $close_tab_btn=this.$wall_container.getElements('.tab_contents .close_tab');$tab_icons.addEvent('mouseover',function()
{var $tooltip=this.getElement('.wall_tooltip_cont');$tooltip.removeClass('display_none');}).addEvent('mouseout',function()
{var $tooltip=this.getElement('.wall_tooltip_cont');$tooltip.addClass('display_none');});$upload_photo_btn.addEvent('click',function()
{var $tooltip=this.getElement('.wall_tooltip_cont');$tooltip.addClass('display_none');$default_tab.addClass('display_none');$upload_photo_tab.getElement('.btn_div').grab(self.$action_privacy_block);$upload_photo_tab.removeClass('display_none');self.$action_input.fireEvent('focus');});$add_link_btn.addEvent('click',function()
{var $tooltip=this.getElement('.wall_tooltip_cont');$tooltip.addClass('display_none');$default_tab.addClass('display_none');$add_link_tab.getElement('.btn_div').grab(self.$action_privacy_block);$add_link_tab.removeClass('display_none');self.$action_input.fireEvent('focus');});$add_video_btn.addEvent('click',function()
{var $tooltip=this.getElement('.wall_tooltip_cont');$tooltip.addClass('display_none');$default_tab.addClass('display_none');$add_video_tab.getElement('.btn_div').grab(self.$action_privacy_block);$add_video_tab.removeClass('display_none');self.$action_input.fireEvent('focus');});$close_tab_btn.addEvent('click',function()
{this.getParent('.tab_content').addClass('display_none');$default_tab.getElement('.btn_div').grab(self.$action_privacy_block);$default_tab.removeClass('display_none');this.blur();});if(this.disable_music_upload){return;}
$add_music_btn.addEvent('click',function()
{var $tooltip=this.getElement('.wall_tooltip_cont');$tooltip.addClass('display_none');$default_tab.addClass('display_none');$add_music_tab.getElement('.btn_div').grab(self.$action_privacy_block);$add_music_tab.removeClass('display_none');self.$action_input.fireEvent('focus');});},prepare_action_like:function(action_id)
{var self=this;var $action_node=this.$actions[action_id];var $like_action=$action_node.getElement('.like_btn');$like_action.addEvent('click',function()
{if(self.like_btn_locked){return false;}
self.like_action(action_id,this);this.blur();});},prepare_action_comment:function(action_id)
{var self=this;var $action_node=this.$actions[action_id];var $comment_action=$action_node.getElement('.comment_btn');var $comment_add_box=$action_node.getElement('.comment_add');var $comment_input=$comment_add_box.getElement('.comment_text_input');var $add_comment_btn=$comment_add_box.getElement('.add_comment_btn');$comment_action.addEvent('click',function()
{$comment_add_box.addClass('active');$comment_add_box.removeClass('display_none');$comment_input.fireEvent('focus');self.toggle_comment_box($action_node);this.blur();$comment_input.focus();});$comment_input.addEvent('focus',function()
{$comment_add_box.addClass('active');this.value=(this.value==SELanguage.Translate(690706010))?'':this.value;}).addEvent('blur',function()
{if(this.value.trim()!=''){return false;}
$comment_add_box.removeClass('active');this.value=(this.value.trim()=='')?SELanguage.Translate(690706010):this.value;});$add_comment_btn.addEvent('click',function()
{self.add_comment(action_id,this,$comment_input);});},prepare_delete_comment:function(action_id)
{var self=this;var $action_node=this.$actions[action_id];var $delete_comments=$action_node.getElements('.delete_comment');$delete_comments.addEvent('click',function()
{self.delete_comment(action_id,this);});},prepare_action_hide:function(action_id)
{var self=this;var $action_node=this.$actions[action_id];var $hide_action_btn=$action_node.getElement('.hide_action');if($hide_action_btn==null){return false;}
$action_node.addEvent('mouseover',function()
{$hide_action_btn.setStyle('opacity',1);}).addEvent('mouseout',function()
{$hide_action_btn.setStyle('opacity',0);});$hide_action_btn.addEvent('click',function()
{var $hide_action=self.$hide_action_tpl.clone().removeProperty('id');$hide_action.getElement('.cancel_btn').addEvent('click',function()
{$hide_action.dispose();$action_node.setStyle('display','block');});$hide_action.getElement('.hide_btn').addEvent('click',function()
{self.hide_action(action_id,$hide_action);});$action_node.setStyle('display','none');$hide_action.inject($action_node,'before');});},prepare_action_remove:function(action_id)
{var self=this;var $action_node=this.$actions[action_id];var $remove_action_btn=$action_node.getElement('.remove_action');if($remove_action_btn==null){return false;}
$action_node.addEvent('mouseover',function()
{$remove_action_btn.setStyle('opacity',1);}).addEvent('mouseout',function()
{$remove_action_btn.setStyle('opacity',0);});$remove_action_btn.addEvent('click',function()
{var $remove_action=self.$remove_action_tpl.clone().removeProperty('id');$remove_action.getElement('.cancel_btn').addEvent('click',function()
{$remove_action.dispose();$action_node.setStyle('display','block');});$remove_action.getElement('.remove_btn').addEvent('click',function()
{self.remove_action(action_id,$remove_action);});$action_node.setStyle('display','none');$remove_action.inject($action_node,'before');});},prepare_action_privacy:function()
{var self=this;this.action_privacy_level=63;this.$action_privacy_block=this.$wall_container.getElement('.privacy_block');this.$action_privacy_btn=this.$wall_container.getElement('.action_privacy_btn');this.$action_privacy_levels_cont=this.$wall_container.getElement('.wall_action_privacy');this.$action_privacy_levels=this.$action_privacy_levels_cont.getElements('.privacy_option');this.$action_active_privacy=this.$action_privacy_levels_cont.getElement('.active');if(this.$action_active_privacy!=null){this.action_privacy_level=this.$action_active_privacy.getProperty('id').substr('8');}
this.$action_privacy_btn.addEvent('click',function()
{self.hide_privacy_block=false;self.$action_privacy_levels_cont.removeClass('display_none');this.blur();});this.$action_privacy_levels.addEvent('click',function()
{self.action_privacy_level=this.getProperty('id').substr('8');self.$action_active_privacy.removeClass('active');this.addClass('active');self.$action_active_privacy=this;self.$action_privacy_levels_cont.addClass('display_none');});self.hide_privacy_block=false;this.$action_privacy_levels_cont.addEvent('mouseout',function()
{if(!self.$action_privacy_levels_cont.hasClass('display_none')){self.hide_privacy_block=true;}}).addEvent('mouseover',function()
{self.hide_privacy_block=false;});$$('body').addEvent('click',function()
{if(!self.hide_privacy_block){self.hide_privacy_block=true;}else{self.$action_privacy_levels_cont.addClass('display_none');self.hide_privacy_block=false;}});},hide_action:function(action_id,$hide_node)
{var self=this;var $action_node=this.$actions[action_id];$hide_node.addClass('hide_loading');$hide_node.getElements('.button').setProperty('disabled','disabled').addClass('disabled');new Request.JSON({method:'post',url:'he_wall_ajax_request.php?wall_object='+ self.wall_object+'&wall_object_id='+ self.wall_object_id,data:{'task':'hide_action','action_id':action_id,'list_id':self.list_id,'no_cache':Math.random()},onSuccess:function(result)
{$hide_node.dispose();if(result.result){$action_node.dispose();}else{$action_node.setStyle('display','block');alert(result.message);}}}).send();},remove_action:function(action_id,$remove_node)
{var self=this;var $action_node=this.$actions[action_id];$remove_node.addClass('hide_loading');$remove_node.getElements('.button').setProperty('disabled','disabled').addClass('disabled');new Request.JSON({method:'post',url:'he_wall_ajax_request.php?wall_object='+ self.wall_object+'&wall_object_id='+ self.wall_object_id,data:{'task':'remove_action','action_id':action_id,'list_id':self.list_id,'no_cache':Math.random()},onSuccess:function(result){$remove_node.dispose();if(result.result){$action_node.dispose();}else{$action_node.setStyle('display','block');alert(result.message);}}}).send();},like_action:function(action_id,$like_btn)
{var self=this;var $action_node=this.$actions[action_id];var $like_box=$action_node.getElement('.like_box');var $like_value=$action_node.getElement('.like_content');var $like_loading=$like_btn.getParent('.wall_action_options');this.like_btn_locked=true;$like_loading.addClass('hide_loading');new Request.JSON({method:'post',url:'he_wall_ajax_request.php?wall_object='+ self.wall_object+'&wall_object_id='+ self.wall_object_id,data:{'task':'like_action','action_id':action_id,'list_id':self.list_id,'no_cache':Math.random()},onSuccess:function(result)
{if(result.result){var visible=(result.value!='');var lang_id=(result.like==1)?690706009:690706008;$like_btn.set('text',SELanguage.Translate(lang_id));$like_value.set('html',result.value);if(visible){$like_box.removeClass('display_none');}
else{$like_box.addClass('display_none');}
self.toggle_comment_box($action_node);}else{alert(result.message);}
self.like_btn_locked=false;$like_loading.removeClass('hide_loading');}}).send();},add_comment:function(action_id,$btn_node,$input)
{var self=this;if($input.value.length>1000)
{alert(SELanguage.Translate(690706058));$input.fireEvent('focus');return false;}
$btn_node.setProperty('disabled','disabled').addClass('disabled');$input.addClass('loading');$input.disabled=true;new Request.JSON({method:'post',url:'he_wall_ajax_request.php?wall_object='+ self.wall_object+'&wall_object_id='+ self.wall_object_id,data:{'task':'add_comment','action_id':action_id,'text':$input.value,'list_id':self.list_id,'no_cache':Math.random()},onSuccess:function(data)
{$btn_node.removeProperty('disabled').removeClass('disabled');$input.removeClass('loading');$input.disabled=false;$input.fireEvent('blur');if(data.result==1&&data.comment_info)
{self.new_comment(action_id,data.comment_info);$input.value='';$input.fireEvent('focus').fireEvent('blur');}
else
{alert(data.message);$input.fireEvent('focus');}}}).send();},new_comment:function(action_id,comment_info)
{if(comment_info.id==undefined){return false;}
var self=this;var $action_node=this.$actions[action_id];var $feed_comments=$action_node.getElement('.feed_comments');var $comment=this.$comment_tpl.clone();$comment.setProperty('id','comment_'+ comment_info.id);$comment.getElement('.comment_actual_text').set('html',comment_info.text);$comment.getElement('.date_time').set('text',comment_info.posted_date);$comment.getElement('.delete_comment').addEvent('click',function()
{self.delete_comment(action_id,this);});$feed_comments.grab($comment,'bottom');},delete_comment:function(action_id,$delete_btn)
{var c_result=confirm(SELanguage.Translate(690706011));if(!c_result){return false;}
if(this.del_comment_btn_locked){return false;}
var self=this;var $action_node=this.$actions[action_id];var $feed_comments=$action_node.getElement('.feed_comments');var $del_comment_loading=$delete_btn.getParent('.wall_delete_comment');var $comment=$delete_btn.getParent('.comment');var comment_id=$comment.getProperty('id').substr(8);this.del_comment_btn_locked=true;$del_comment_loading.addClass('hide_loading');new Request.JSON({method:'post',url:'he_wall_ajax_request.php?wall_object='+ self.wall_object+'&wall_object_id='+ self.wall_object_id,data:{'task':'delete_comment','comment_id':comment_id,'list_id':self.list_id,'no_cache':Math.random()},onSuccess:function(result)
{if(result.result==1){$comment.dispose();if($feed_comments.getElements('.comment').length==0)
{self.toggle_comment_box($action_node);}}else{alert(result.message);}
self.del_comment_btn_locked=false;$del_comment_loading.removeClass('hide_loading');}}).send();},toggle_comment_box:function($action_node)
{var $comment_box=$action_node.getElement('.comment_box');var visible=($comment_box.getElements('.display_none').length!=2||$comment_box.getElements('.comment').length!=0);if(visible){$comment_box.removeClass('display_none');}
else{$comment_box.addClass('display_none');}},display_actions_by_list:function(list_id)
{this.list_id=list_id;var self=this;if(this.block_request)return;this.block_request=true;var $show_more_block=this.$show_more_btn.getParent('.wall_show_more');var $wall_actions=this.$wall_container.getElement('.wall_actions');$wall_actions.innerHTML=$$('.he_wall_actions_loader')[0].innerHTML;new Request.JSON({method:'post',url:'he_wall_ajax_request.php?wall_object='+ self.wall_object+'&wall_object_id='+ self.wall_object_id,data:{'task':'show_more','list_id':list_id,'no_cache':Math.random()},onSuccess:function(result)
{$wall_actions.getElement(".he_wall_actions_loader_img").setStyle('display','none');if(result.action_ids.length!=0)
{var $container=new Element('div');$container.innerHTML=result.html;$wall_actions.grab($container,'bottom');result.action_ids.each(function(action_id,index)
{self.action_ids.push(action_id);var $action_node=$('wall_action_'+ action_id);self.$actions[action_id]=$action_node;self.prepare_action(action_id);self.last_action_id=action_id;});if(self.actions_per_page==result.action_ids.length)
{self.show_more_btn_locked=false;self.$show_more_btn.removeClass('display_none');$show_more_block.getElement('.no_more_info').addClass('display_none');}
else
{self.$show_more_btn.addClass('display_none');$show_more_block.getElement('.no_more_info').removeClass('display_none');}}
else
{self.$show_more_btn.addClass('display_none');$show_more_block.getElement('.no_more_info').removeClass('display_none');}
$$('.active_action_type').removeClass('active_action_type');$$('.he_wall_active_list').removeClass('he_wall_active_list');$$('.active_action_type_lists').removeClass('active_action_type_lists');$$('.active_action_type_global').removeClass('active_action_type_global');switch(list_id)
{case-2:{$('he_wall_action_type_network').addClass('active_action_type');$('he_wall_action_type_network').addClass('active_action_type_global');}
break;case-1:{$('he_wall_action_type_friends').addClass('active_action_type');$('he_wall_action_type_friends').addClass('active_action_type_global');}
break;default:{$('he_wall_action_type_'+list_id).addClass('he_wall_active_list');$('show_list_actions').set('text',SELanguage.Translate(690706144)+' - '+ $('he_wall_action_type_'+ list_id).getElement('div a').get('text'));$('show_list_actions').addClass('active_action_type_lists');$('show_list_actions').removeClass('active_action_type_lists_open');}}
$$('.he_wall_lists').setStyle('display','none');self.block_request=false;}}).send();},show_hidden_lists:function()
{$$('.active_action_type_lists').removeClass('active_action_type_lists');if(!$$('.he_wall_lists'))
{return;}
if($$('.he_wall_lists').getStyle('display')=='none')
{$$('.he_wall_lists').setStyle('display','block');$('show_list_actions').addClass('active_action_type_lists');$('show_list_actions').addClass('active_action_type_lists_open');}
else
{$$('.he_wall_lists').setStyle('display','none');$('show_list_actions').removeClass('active_action_type_lists');$('show_list_actions').removeClass('active_action_type_lists_open');}},show_more:function()
{if(this.show_more_btn_locked){return false;}
this.show_more_btn_locked=true;var self=this;var $show_more_block=this.$show_more_btn.getParent('.wall_show_more');var $wall_actions=this.$wall_container.getElement('.wall_actions');var $show_more_loader=$show_more_block.getElement('.show_more_loader');$show_more_loader.removeClass('display_none');new Request.JSON({method:'post',url:'he_wall_ajax_request.php?wall_object='+ self.wall_object+'&wall_object_id='+ self.wall_object_id,data:{'task':'show_more','last_action_id':self.last_action_id,'list_id':self.list_id,'no_cache':Math.random()},onSuccess:function(result)
{if(result.action_ids.length!=0)
{var $container=new Element('div');$container.innerHTML=result.html;$wall_actions.grab($container,'bottom');result.action_ids.each(function(action_id,index)
{self.action_ids.push(action_id);var $action_node=$('wall_action_'+ action_id);self.$actions[action_id]=$action_node;self.prepare_action(action_id);self.last_action_id=action_id;});if(self.actions_per_page==result.action_ids.length)
{self.show_more_btn_locked=false;}
else
{self.$show_more_btn.addClass('display_none');$show_more_block.getElement('.no_more_info').removeClass('display_none');}}
else
{self.$show_more_btn.addClass('display_none');$show_more_block.getElement('.no_more_info').removeClass('display_none');}
$show_more_loader.addClass('display_none');}}).send();},post_action:function()
{if(this.$action_input.value==SELanguage.Translate(690706010)||this.$action_input.value.trim()=='')
{this.$action_input.fireEvent('focus');return false;}
else if(this.$action_input.value.length>1000)
{alert(SELanguage.Translate(690706058));this.$action_input.fireEvent('focus');return false;}
var self=this;var $wall_tabs=this.$wall_container.getElement('.wall_post_tabs');this.$action_btn.setProperty('disabled','disabled').addClass('disabled');this.$action_input.addClass('loading');this.$action_input.disabled=true;$wall_tabs.addClass('hide_loading');new Request.JSON({method:'post',url:'he_wall_ajax_request.php?wall_object='+ self.wall_object+'&wall_object_id='+ self.wall_object_id,data:{'task':'post_action','text':self.$action_input.value,'first_action_id':self.first_action_id,'action_privacy_level':self.action_privacy_level,'list_id':self.list_id,'no_cache':Math.random()},onSuccess:function(result)
{if(result.result==0){alert(result.message);}
else if(result.action_ids.length!=0){self.grab_new_actions(result);}
if(result.status&&result.status_date){self.he_wall_update_status(result.status,result.status_date);}
self.$action_btn.removeProperty('disabled').removeClass('disabled');self.$action_input.removeClass('loading').value='';self.$action_input.disabled=false;self.$action_input.fireEvent('blur');$wall_tabs.removeClass('hide_loading');}}).send();},grab_new_actions:function(result)
{var self=this;var $wall_actions=this.$wall_container.getElement('.wall_actions');var $container=new Element('div');$container.innerHTML=result.html;$wall_actions.grab($container,'top');if(!Browser.Engine.gecko)
{var $music_players=$container.getElements('div.wall_music_player script');$music_players.each(function($player_js,index)
{var player_js=$player_js.get('html');eval(player_js);});}
result.action_ids.each(function(action_id,index)
{self.action_ids.push(action_id);var $action_node=$('wall_action_'+ action_id);self.$actions[action_id]=$action_node;self.prepare_action(action_id);if(index==0)
{self.first_action_id=action_id;}});},post_photo:function($node)
{var self=this;var $upload_photo_tab=this.$wall_container.getElement('.upload_photo_tab');var $tab_title=$upload_photo_tab.getElement('.tab_title');var $wall_photo=$upload_photo_tab.getElement('.wall_photo');var $wall_photo_text=$upload_photo_tab.getElement('.share_photo_text');var $wall_photo_privacy=$upload_photo_tab.getElement('.share_photo_privacy');if($wall_photo.value.trim()==''&&this.$action_input.value.trim()=='')
{return false;}
else if(this.$action_input.value.length>1000)
{alert(SELanguage.Translate(690706058));this.$action_input.fireEvent('focus');return false;}
return AIM.submit($node,{'onStart':function()
{self.$action_btn.setProperty('disabled','disabled').addClass('disabled');self.$action_input.addClass('loading');self.$action_input.disabled=true;$tab_title.addClass('hide_loading');$wall_photo_text.value=self.$action_input.value;$wall_photo_privacy.value=self.action_privacy_level;},'onComplete':function(response)
{eval('var response = '+ response);$tab_title.removeClass('hide_loading');if(response.result==1)
{self.load_new_actions($wall_photo,$wall_photo_text);if(self.wall_object=='group')
{window.setTimeout(function(){SocialEngine.GroupFiles.getFiles();},400);}}
else
{alert(response.message);$wall_photo.value='';$wall_photo_text.value='';self.$action_btn.removeProperty('disabled').removeClass('disabled');self.$action_input.removeClass('loading').value='';self.$action_input.disabled=false;self.$action_input.fireEvent('blur');}}});},post_music:function($node)
{var self=this;var $add_music_tab=this.$wall_container.getElement('.add_music_tab');var $tab_title=$add_music_tab.getElement('.tab_title');var $wall_music=$add_music_tab.getElement('.wall_music');var $wall_music_text=$add_music_tab.getElement('.share_music_text');var $wall_music_privacy=$add_music_tab.getElement('.share_music_privacy');if($wall_music.value.trim()==''&&this.$action_input.value.trim()=='')
{return false;}
else if(this.$action_input.value.length>1000)
{alert(SELanguage.Translate(690706058));this.$action_input.fireEvent('focus');return false;}
return AIM.submit($node,{'onStart':function()
{self.$action_btn.setProperty('disabled','disabled').addClass('disabled');self.$action_input.addClass('loading');self.$action_input.disabled=true;$tab_title.addClass('hide_loading');$wall_music_text.value=self.$action_input.value;$wall_music_privacy.value=self.action_privacy_level;},'onComplete':function(response)
{eval('var response = '+ response);$tab_title.removeClass('hide_loading');if(response.result==1)
{self.load_new_actions($wall_music,$wall_music_text,'music');}
else
{if(response.message)
{alert(response.message);}
$wall_music.value='';$wall_music_text.value='';self.$action_btn.removeProperty('disabled').removeClass('disabled');self.$action_input.removeClass('loading').value='';self.$action_input.disabled=false;self.$action_input.fireEvent('blur');}}});},load_new_actions:function($wall_photo,$wall_photo_text,action_type)
{var self=this;new Request.JSON({method:'post',url:'he_wall_ajax_request.php?wall_object='+ self.wall_object+'&wall_object_id='+ self.wall_object_id,data:{'task':'new_actions','first_action_id':self.first_action_id,'list_id':self.list_id,'no_cache':Math.random()},onSuccess:function(result)
{if(result.action_ids.length!=0)
{self.grab_new_actions(result);}
$wall_photo.value='';$wall_photo_text.value='';self.$action_btn.removeProperty('disabled').removeClass('disabled');self.$action_input.removeClass('loading').value='';self.$action_input.disabled=false;self.$action_input.fireEvent('blur');self.$wall_container.getElement('.upload_photo_tab .close_tab').fireEvent('click');self.$wall_container.getElement('.add_music_tab .close_tab').fireEvent('click');}}).send();},post_link:function($post_link_btn)
{var self=this;var $link_input=this.$wall_container.getElement('.share_link_input');var link=$link_input.value.trim();var $tab_title=this.$wall_container.getElement('.add_link_tab .tab_title');if(link.length==0)
{$link_input.focus();return false;}
else if(this.$action_input.value.length>1000)
{alert(SELanguage.Translate(690706058));this.$action_input.fireEvent('focus');return false;}
$post_link_btn.setProperty('disabled','disabled').addClass('disabled');this.$action_input.addClass('loading');this.$action_input.disabled=true;$tab_title.addClass('hide_loading');new Request.JSON({method:'post',url:'he_wall_ajax_request.php?wall_object='+ self.wall_object+'&wall_object_id='+ self.wall_object_id,data:{'task':'post_link','text':this.$action_input.value,'list_id':self.list_id,'action_privacy_level':self.action_privacy_level,'link':link,'first_action_id':this.first_action_id,'no_cache':Math.random()},onSuccess:function(result)
{if(result.result==0){alert(result.message);}
else if(result.action_ids.length!=0)
{self.grab_new_actions(result);}
$tab_title.removeClass('hide_loading');$post_link_btn.removeProperty('disabled').removeClass('disabled');$link_input.value='';self.$action_input.removeClass('loading').value='';self.$action_input.disabled=false;self.$action_input.fireEvent('blur');self.$wall_container.getElement('.add_link_tab .close_tab').fireEvent('click');}}).send();},post_video:function($post_video_btn)
{var self=this;var $video_provider=this.$wall_container.getElement('.video_provider');var $video_url=this.$wall_container.getElement('.video_url');var video_provider=$video_provider.value.trim();var video_url=$video_url.value.trim();if(video_provider.length==0)
{alert(SELanguage.Translate(690706072));$video_provider.focus();return false;}
if(video_url.length==0)
{alert(SELanguage.Translate(690706073));$video_url.focus();return false;}
var $tab_title=this.$wall_container.getElement('.add_video_tab .tab_title');$post_video_btn.setProperty('disabled','disabled').addClass('disabled');this.$action_input.addClass('loading');this.$action_input.disabled=true;$tab_title.addClass('hide_loading');new Request.JSON({method:'post',url:'he_wall_ajax_request.php?wall_object='+ self.wall_object+'&wall_object_id='+ self.wall_object_id,data:{'task':'post_video','text':this.$action_input.value,'action_privacy_level':self.action_privacy_level,'video_provider':video_provider,'video_url':video_url,'list_id':self.list_id,'first_action_id':this.first_action_id,'no_cache':Math.random()},onSuccess:function(result)
{if(result.action_ids!=null&&result.action_ids.length!=0)
{self.grab_new_actions(result);}
else if(result.result==0)
{alert(result.message);}
$tab_title.removeClass('hide_loading');$post_video_btn.removeProperty('disabled').removeClass('disabled');$video_provider.value='';$video_provider.fireEvent('change');$video_url.value='';self.$action_input.removeClass('loading').value='';self.$action_input.disabled=false;self.$action_input.fireEvent('blur');self.$wall_container.getElement('.add_video_tab .close_tab').fireEvent('click');}}).send();},he_wall_update_status:function(status,status_date)
{if(!status||!status_date){return false;}
var $current_status=$('ajax_currentstatus_value');var $current_status_date=$('ajax_currentstatus_date');var $wall_status=$('he_wall_user_status');var $wall_status_date=$('he_wall_user_status_date');if($current_status){$current_status.set('html',status);}
if($current_status_date){$current_status_date.set('html',status_date);}
if($wall_status){var $wall_status_cont=$wall_status.getParent('.he_wall_profile_status_table');$wall_status.set('html',status);}
if($wall_status_date){$wall_status_date.set('html',status_date);}
if($wall_status_cont){$wall_status_cont.setStyle('display','');}
SocialEngine.Viewer.user_status=status;}};var wall_comment={count:0,lock_page_button:false,construct:function(total,count,action_id)
{var self=this;this.count=count;this.total=total;if(this.total<=this.count)
{$('comment_paging').dispose();}
this.action_id=action_id;this.$page_button=$$('.page_button');if(SocialEngine.Viewer.user_exists)
{$$('.comment_add').removeClass('display_none');}
this.$page_button.addEvent('focus',function()
{this.blur();});this.$page_button.addEvent('click',function(e)
{e.stop();if(self.total<=self.count)
{$('comment_paging').dispose();return false;}
if(self.lock_page_button)
{return false;}
this.addClass('hide_loading');var commentRequest=new Request.JSON({method:'get',url:'he_wall_ajax_request.php',onRequest:function()
{self.lock_page_button=true;},onSuccess:function(result)
{self.$page_button.removeClass('hide_loading');self.count+=result.count;self.lock_page_button=false;var newDiv=new Element('div',{'html':result.html});var $delete_buttons=newDiv.getElements('.delete_comment');$delete_buttons.addEvent('click',function()
{he_wall.delete_comment(result.action_id,this);});$('comments_container').grab(newDiv,'top');$('total_current').innerHTML=self.count;if(self.total<=self.count)
{window.setTimeout(function()
{$('comment_paging').dispose();return false;},1000);}}}).send('action_id='+action_id+'&task=paging&count='+self.count);});}};var he_wall_following={list_id:0,list_name:'',start:0,limit:0,total_followers:0,displayed_followers:0,just_deleted:false,block_loader:false,new_list_created:false,construct:function()
{var self=this;this.$delete_list_btn=$("he_delete_following_list");this.$add_followers_btn=$("he_add_followers");this.$list_name_to_display=$("list_name_to_display");this.$change_list_name_btn=$("he_follower_list_name");this.$text_field_list_name=$("he_list_name_value");this.$change_list_name_box=$("he_follower_list_name_box");this.$show_more_btn=$('he_show_more_btn');this.$new_list_btn=$('following_new_list');if(this.$delete_list_btn)
{this.$delete_list_btn.addEvent('click',function(){self.confirm_delete();});}
if(this.$new_list_btn)
{this.$new_list_btn.addEvent('click',function(){self.new_list();});}
if(this.$text_field_list_name)
{this.$text_field_list_name.addEvent('blur',function(){self.list_name=self.$text_field_list_name.value;self.save_list_name();});}
if(this.$add_followers_btn)
{this.$add_followers_btn.addEvent('click',function(){self.add_followers();});}
if(this.$change_list_name_btn)
{this.$change_list_name_btn.addEvent('click',function(){self.change_list_name();});}
if(this.$show_more_btn)
{this.$show_more_btn.addEvent('click',function(){self.show_more();});}
if(this.total_followers<=this.displayed_followers)
{this.$show_more_btn.getParent().setStyle('display','none');}
var $new_list_input=$('he_following_list_title_input');if($new_list_input)
{$new_list_input.addEvent('keydown',function(event){if(event.key=='enter'){this.blur();}});}
if(this.$text_field_list_name)
{this.$text_field_list_name.addEvent('keydown',function(event){if(event.key=='enter'){this.blur();}});}
if(this.list_id)this.change_list(this.list_id);},confirm_delete:function()
{TB_show(SELanguage.Translate(690706156),'#TB_inline?height=150&width=300&inlineId=confirmdelete','','../images/trans.gif');},change_list_name:function()
{this.$change_list_name_box.setStyle('display','none');this.$text_field_list_name.setStyle('display','block');this.$text_field_list_name.focus();},new_list_create:function()
{var self=this;window.setTimeout(function(){if($('he_following_list_title_input').value.trim()=="")
{return false;}
self.$text_field_list_name.value='';self.list_id=0;self.total_followers=0;self.start=0;self.$change_list_name_btn.setStyle('display','block');self.$delete_list_btn.setStyle('display','none');self.$add_followers_btn.setStyle('display','none');$('he_following_list_title_input').disabled=true;self.hide_show_more();$$('.following_list_container')[0].innerHTML=$$('.no_followers_tmp')[0].innerHTML;self.list_name=$('he_following_list_title_input').value;self.new_list_created=true;self.save_list_name();},300);},save_list_name:function()
{var self=this;if(this.block_loader)return;this.block_loader=true;if(this.new_list_created)
{this.show_loader($('he_following_list_title_input').getParent());$('he_following_list_title_input').disabled=false;}
else
{this.show_loader($('he_wall_following_loader'));}
new Request.JSON({method:'get',url:'he_wall_ajax_request.php',data:{'task':'save_list','list_name':self.list_name,'list_id':self.list_id},onSuccess:function(result)
{self.list_id=result.list_id;he_wall.list_id=result.list_id;if(result.is_error)
{$$('.error_div')[0].innerHTML=result.error_message;}
else
{$$('.following_other_lists')[0].innerHTML+=result.new_list_title;self.$text_field_list_name.value=result.list_name;self.$list_name_to_display.innerHTML=result.list_name;self.list_name=result.list_name;self.$text_field_list_name.setStyle('display','none');self.$change_list_name_box.setStyle('display','block');self.$list_name_to_display.setStyle('display','block');self.$change_list_name_btn.setStyle('display','block');self.$delete_list_btn.setStyle('display','block');self.$add_followers_btn.setStyle('display','block');$('following_list_title_'+self.list_id).innerHTML=self.list_name;$$('.following_title a').removeClass('active_he_list');$('following_list_title_'+self.list_id).addClass('active_he_list');if(result.is_new_list)
{$$('.following_list_container').getElement('.no_result_message').setStyle('display','block');}
$('he_following_list_title_input').getParent().getParent().setStyle('display','none');$('following_new_list').getParent().getParent().setStyle('display','block');self.new_list_created=false;}
self.block_loader=false;self.hide_loader();}}).send();},delete_list:function()
{var self=this;if(this.block_loader)return;this.block_loader=true;this.show_loader($('he_wall_following_loader'));new Request.JSON({method:'get',url:'he_wall_ajax_request.php',data:{'task':'delete_list','list_id':self.list_id},onSuccess:function(result)
{$('following_list_title_'+self.list_id).dispose();self.block_loader=false;self.hide_loader();self.change_list(0);}}).send();},show_loader:function($node)
{var loader=new Element('img',{'src':'./images/icons/he_wall_following_loader2.gif','border':0,'class':'he_wall_following_loaders'});$node.appendChild(loader);},hide_loader:function()
{$$('.he_wall_following_loaders').dispose();},add_followers:function()
{he_contacts.init('user_followers_new.php?contacts_choosed=0&list_id='+this.list_id+'&',0,0,'user_followers_new.php?list_id='+this.list_id+'&',0,SELanguage.Translate(690706155),0);he_contacts.open_form();},added_followers:function()
{this.change_list(this.list_id);setTimeout("TB_remove()","1000");$$('.no_result_message').setStyle('display','none');},delete_user_from_list:function(follower_id)
{var self=this;if(this.block_loader)return;this.block_loader=true;this.show_loader($('he_wall_following_loader'));new Request.JSON({method:'get',url:'he_wall_ajax_request.php',data:{'task':'delete_user_from_list','list_id':self.list_id,'follower_id':follower_id},onSuccess:function(result)
{$('following_user_'+follower_id).dispose();self.displayed_followers--;self.total_followers--;self.start--;self.block_loader=false;self.hide_loader();if(self.displayed_followers<=0)
{self.just_deleted=true;self.show_more();}}}).send();},he_wall_follow_manage:function(user_id,follower_id,task)
{var self=this;if(this.block_loader)return;this.block_loader=true;this.show_loader($('he_wall_following_loader'));new Request.JSON({method:'get',url:'he_wall_ajax_request.php',data:{'user_id':user_id,'follower_id':follower_id,'task':task},onSuccess:function(result)
{$('following_user_'+follower_id).dispose();self.displayed_followers--;self.total_followers--;self.start--;self.block_loader=false;self.hide_loader();if(self.displayed_followers<=0)
{self.just_deleted=true;self.show_more();}}}).send();},hide_show_more:function()
{this.$show_more_btn.getParent().setStyle('display','none');},display_show_more:function()
{this.$show_more_btn.getParent().setStyle('display','block');},change_list:function(list_id)
{var self=this;self.start=0;if(this.block_loader)return;this.block_loader=true;this.show_loader($('following_list_title_'+list_id));new Request.JSON({method:'get',url:'he_wall_ajax_request.php',data:{'task':'get_list','list_id':list_id,'limit':self.limit,'start':self.start},onSuccess:function(result)
{self.start=self.start+ self.limit;self.total_followers=result.total_followers;self.list_id=result.list_id;self.list_name=result.list_name;self.$list_name_to_display.innerHTML=result.list_name;self.$text_field_list_name.value=result.list_name;self.displayed_followers=result.follower_count;he_wall.list_id=result.list_id;if(self.displayed_followers>=self.total_followers)
{self.hide_show_more();}
else
{self.display_show_more();}
$$('.following_title a').removeClass('active_he_list');$('following_list_title_'+list_id).addClass('active_he_list');$$('.error_div').setStyle('display','none');if(list_id!=0)
{self.$text_field_list_name.setStyle('display','none');self.$change_list_name_box.setStyle('display','block');self.$list_name_to_display.setStyle('display','block');self.$change_list_name_btn.setStyle('display','block');self.$delete_list_btn.setStyle('display','block');self.$add_followers_btn.setStyle('display','block');}
else
{self.$change_list_name_btn.setStyle('display','none');self.$delete_list_btn.setStyle('display','none');self.$add_followers_btn.setStyle('display','none');}
$$('.following_list_container')[0].innerHTML=result.html;self.block_loader=false;self.hide_loader();}}).send();},new_list:function()
{$('following_new_list').getParent().getParent().setStyle('display','none');$('he_following_list_title_input').getParent().getParent().setStyle('display','block');$('he_following_list_title_input').focus();},cancel_new_list:function()
{$('following_new_list').getParent().getParent().setStyle('display','block');$('he_following_list_title_input').getParent().getParent().setStyle('display','none');$('he_following_list_title_input').disabled=false;$('he_following_list_title_input').value='';},show_more:function()
{var self=this;if(this.block_loader)return;this.block_loader=true;this.$show_more_btn.getParent().addClass('hide_loading');if(!this.follow_arr){this.follow_arr={};}
new Request.JSON({method:'get',url:'he_wall_ajax_request.php',data:{'task':'get_list','list_id':self.list_id,'limit':self.limit,'start':self.start},onSuccess:function(result)
{self.start=self.start+ self.limit;self.displayed_followers+=result.follower_count;if(self.displayed_followers>=self.total_followers)
{self.hide_show_more();}
else
{self.display_show_more();}
if(result.follower_count!=0||self.just_deleted)
{var $new_items=new Element('div');$new_items.set('html',result.html);$$('.following_list_container')[0].grab($new_items);}
self.just_deleted=false;self.block_loader=false;self.$show_more_btn.getParent().removeClass('hide_loading');}}).send();},more_follow_list:function(user_id,list_type,$node)
{var self=this;var $node=$($node);if(!this.follow_list){this.follow_list={on_page:10,followers:2,followings:2,disabled:false};this.follow_arr={};}
if(!this.$follow_list_item_tpl){this.$follow_list_item_tpl=$('follow_user_tpl');}
if(!this.$follow_list||!this.$follow_list.followers||!this.$follow_list.followings){this.$follow_list={followers:$('user_follower_list'),followings:$('user_following_list')};}
if(this.follow_list.disabled){return false;}
$node.getParent('.he_show_more_btn_cont').addClass('hide_loading');new Request.JSON({method:'post',url:'he_wall_ajax_request.php',data:{task:'follow_list',user_id:user_id,type:list_type,step:this.follow_list[list_type]},onSuccess:function(result)
{var count=0;if(result&&result.result){var $follow_cont=new Element('div');var user_id=SocialEngine.Viewer.user_info.user_id;for(var follow_id in result.follow_list){var follow_info=result.follow_list[follow_id];self.follow_arr[follow_id]=follow_info;var $follow_node=self.$follow_list_item_tpl.clone();var $follow_photo=new Element('img',{'src':follow_info.user_photo,'alt':follow_info.user_photo_alt,'class':'photo','style':'display: block; margin-left: auto; margin-right: auto;','width':'60','height':'60','border':'0'});$follow_node.setProperty('id','following_user_'+ follow_id);$follow_node.getElement('.he_profile_link').setProperty('href',follow_info.user_url);$follow_node.getElement('.he_profile_link').grab($follow_photo);$follow_node.getElement('.he_profile_username').setProperty('href',follow_info.user_url).set('text',follow_info.user_displayname);if(follow_info.user_status!=""){$follow_node.getElement('.he_wall_status_text').set('html',follow_info.user_status);}else{$follow_node.getElement('.he_profile_username').getParent('td').setProperty('height',78);$follow_node.getElement('.he_wall_status_sm').getParent().dispose();}
if(SocialEngine.Viewer.user_exists){$follow_node.getElement('.he_wall_following_options').setProperty('he_following_status_'+ follow_id).removeClass('display_none');var $follow_icon=new Element('img',{'src':follow_info.user_task?'./images/icons/he_wall_remove_from_list_over.png':'./images/icons/he_wall_add_following_over.png','alt':follow_info.user_task?SELanguage.Translate(690706146):SELanguage.Translate(690706146),'class':'icon','border':'0'});$follow_node.getElement('.he_wall_following_options').setProperty('id','he_following_status_'+ follow_id);$follow_node.getElement('.he_wall_following_options .he_wall_following_option').setProperty('id','follow_'+ follow_id).grab($follow_icon);$follow_node.getElement('.he_wall_following_options .he_wall_following_option').addEvent('click',function(){var follow_id=$(this).getProperty('id').substr(7);var follow_status=self.follow_arr[follow_id].user_task?'unfollow':'follow';he_wall_follow_manage2(user_id,follow_id,follow_status);});}
$follow_node.addEvent('mouseover',function(){$(this).addClass('hovered');}).addEvent('mouseout',function(){$(this).removeClass('hovered');});$follow_cont.grab($follow_node);count++;}
self.$follow_list[list_type].grab($follow_cont,'bottom');}
self.follow_list.disabled=false;$node.getParent('.he_show_more_btn_cont').removeClass('hide_loading');if(count<self.follow_list.on_page){$node.dispose();}
self.follow_list[list_type]++;}}).send();}};function he_wall_follow_manage(user_id,follower_id,task)
{if($('he_following_status'))
$('he_following_status').innerHTML="<a><img src='./images/icons/loading2.gif' class='icon' width='20px' height='20px' />"+SELanguage.Translate(690706154)+"</a>";new Request.JSON({method:'get',url:'he_wall_ajax_request.php',onSuccess:function(result)
{if($('he_following_status'))$('he_following_status').innerHTML=result.html;}}).send('user_id='+user_id+'&follower_id='+follower_id+'&task='+task);}
function he_wall_follow_manage2(user_id,follower_id,task)
{if($('he_following_status_'+follower_id))
$('he_following_status_'+follower_id).innerHTML="<img src='./images/icons/loading2.gif' class='icon' width='20px' height='20px' />";new Request.JSON({method:'get',url:'he_wall_ajax_request.php',onSuccess:function(result)
{if($('he_following_status_'+follower_id))$('he_following_status_'+follower_id).innerHTML=result.html;}}).send('user_id='+user_id+'&follower_id='+follower_id+'&task='+task+'&without_label=1');}
function he_wall_show_more($node)
{$node.blur();$node=$$($node);$node.addClass('display_none');$node.getPrevious().addClass('display_none');$node.getNext().removeClass('display_none');$node.getNext('.hide_more_text').removeClass('display_none');}
function he_wall_hide_more($node)
{$node.blur();$node=$$($node);$node.addClass('display_none');$node.getPrevious().addClass('display_none');$node.getPrevious('.show_more_text').removeClass('display_none');$node.getPrevious('.show_more_text').getPrevious().removeClass('display_none');}
function he_wall_show_player($node)
{$node.blur();$node=$($node);if(!he_wall.show_video_player)
{var video_url=$node.getParent().getElement('.video_title').href;window.location.href=video_url;return false;}
$node.addClass('display_none');$node.getNext().removeClass('display_none');}
