Cufon.replace('.cufon1',{textShadow:'2px 2px rgba(0, 0, 0, 0.4)'});Cufon.replace('.cufon2, .cufon4',{textShadow:'1px 1px rgba(0, 0, 0, 0.4)'});Cufon.replace('.cufon3, #signup_ad');$(function(){$('.profile_attribute.description .content').expander({slicePoint:400,widow:50,expandPrefix:'',expandText:'read more',userCollapseText:'read less'});$('#profile .status input').live('focus',function(){var $this=$(this);if($this.val()=='What\'s cookin? Share your thoughts.')
$this.val('');});$('#profile .status input').live('blur',function(){var $this=$(this);if($this.val()=='')
$this.val('What\'s cookin? Share your thoughts.');});});function edit_value(current,phpa_id,label,pv_id,update_display_name){option_box_prompt({head:label,text:'',o1:'Save',o2:'Cancel',prefill:current},function(text){$.post('/ajax_profile/profile_value_edit',{text:text,profile_id:window.profile_id,phpa_id:phpa_id,pv_id:pv_id,update_display_name:update_display_name},function(){update_profile_item(phpa_id);});},null);}
function edit_url(message){message=message?message+'<br />':'';option_box_prompt({head:'Edit Profile URL',text:'<span style="color: #990000;">'+message+'</span>'+window.site_url+'user/',o1:'Save',o2:'Cancel',prefill:window.profile_url},function(new_url){$.post('/ajax_profile/profile_url',{new_url:new_url,profile_id:window.profile_id},function(data){if(data==-1){edit_url('Your URL must be at least 3 characters.');}else if(data==-2){edit_url('Your URL must be less than 65 characters.');}else if(data==-3){edit_url('That URL is already being used.');}else if(data==1){window.location.href="/profile/view/"+window.profile_user_id+'?editmode=1';}else{edit_url('There was an error changing your URL.');}});},null);}
function edit_value_double(current,phpa_id,label,text1,text2,pv_id){var split=current.split('|||');var current1=(split[0])?split[0]:'';var current2=(split[1])?split[1]:'';option_box_double({head:label,text1:text1,text2:text2,o1:'Save',o2:'Cancel',prefill1:current1,prefill2:current2},function(text1,text2){$.post('/ajax_profile/profile_value_edit',{text1:text1,text2:text2,profile_id:window.profile_id,phpa_id:phpa_id,pv_id:pv_id},function(){update_profile_item(phpa_id);});},null);}
function edit_value_textarea(current,phpa_id,label,pv_id){option_box_textarea({head:label,text:'',o1:'Save',o2:'Cancel',prefill:current},function(text){$.post('/ajax_profile/profile_value_edit',{text:text,profile_id:window.profile_id,phpa_id:phpa_id,pv_id:pv_id},function(){update_profile_item(phpa_id);});},null);}
function delete_value(pv_id,phpa_id){option_box({head:'Delete Item',text:'Are you sure you want to delete this item?',o1:'Delete',o2:'Cancel'},function(){$.post('/ajax_profile/profile_value_delete',{pv_id:pv_id},function(){update_profile_item(phpa_id);});},null,null);}
function friend_request(phpa_id){option_box({head:'Send Friend Request',text:'Do you want to send a friend request to '+window.profile_display_name+'?',o1:'Request',o2:'Cancel'},function(){$.post('/ajax_profile/friend_request',{user_id:window.profile_user_id},function(){update_profile_item(phpa_id);});},null,null);}
function choose_featured(text,phpa_id,hidden){hidden=(hidden==1)?'&hidden=1':'';$('<a href="/ajax_profile/choose_featured?value='+text+hidden+'" class="iframe"></a>').fancybox({frameWidth:450,frameHeight:220,hideOnContentClick:false,callbackOnClose:function(){var items;if(window.choose_featured_type=='choose'){if(window.choose_featured_items&&window.choose_featured_items.length>0)
items=window.choose_featured_items.join('|');else
items='';$.post('/ajax_profile/profile_value_edit',{text:items,profile_id:window.profile_id,phpa_id:phpa_id},function(){show_attribute(phpa_id);});}else if(window.choose_featured_type=='random'){items='';$.post('/ajax_profile/profile_value_edit',{text:items,profile_id:window.profile_id,phpa_id:phpa_id},function(){show_attribute(phpa_id);});}else if(window.choose_featured_type=='none'){items='';$.post('/ajax_profile/profile_value_edit',{text:items,profile_id:window.profile_id,phpa_id:phpa_id},function(){hide_attribute(phpa_id);});}}}).click();}
function upload_image(callback){$('<a href="/ajax_profile/upload_image" class="iframe"></a>').fancybox({frameWidth:450,frameHeight:340,hideOnContentClick:false,callbackOnClose:function(){if(typeof callback=='function')
callback(window.uploaded_image);}}).click();}
function add_profile_image(phpa_id){upload_image(function(uploaded_image){if(uploaded_image&&uploaded_image.length>0){$.post('/ajax_profile/add_profile_image',{phpa_id:phpa_id,uploaded_image:uploaded_image},function(){update_profile_item(phpa_id,additional_photos_events);});}});}
function delete_profile_image(pi_id,phpa_id){option_box({head:'Delete Image',text:'Are you sure you want to delete this image?',o1:'Delete',o2:'Cancel'},function(){$.post('/ajax_profile/delete_profile_image',{pi_id:pi_id},function(){update_profile_item(phpa_id);});},null,null);}
function show_attribute(phpa_id){$.post('/ajax_profile/show_attribute',{phpa_id:phpa_id},function(){update_profile_item(phpa_id,featured_recipes_events);});}
function hide_attribute(phpa_id){$.post('/ajax_profile/hide_attribute',{phpa_id:phpa_id},function(){update_profile_item(phpa_id,featured_recipes_events);});}
function submit_wall_post(btn,phpa_id){var text=$(btn).parents('.postbox').find("textarea").val();if(text.length<2){option_box({head:'Error',text:'Your post is too short.',o1:'Ok'},function(){$(btn).parents('.postbox').find("textarea").select();},null,true);}else{$(btn).parents('.postbox').find("textarea").val('');$.post('/ajax_profile/submit_wall_post',{text:text,profile_id:window.profile_id},function(){update_profile_item(phpa_id);});}}
function delete_wall_post(id){option_box({head:'Delete Comment',text:'Are you sure you want to delete your wall comment?',o1:'Delete',o2:'Cancel'},function(){$.post('/ajax_profile/delete_wall_post',{id:id},function(){$('#comment_'+id).remove();});},null,null);}
function viewmore_recipes(link){$(link).siblings('.more').show();$(link).hide();}
function viewmore_friends(link){$(link).siblings('.more').show();$(link).hide();}
function viewmore_wall(link){$(link).siblings('.more').show();$(link).hide();}
function remove_friend(phpa_id){option_box({head:'Remove Friend',text:'Are you sure you want to remove this friend?',o1:'Remove',o2:'Cancel'},function(){$.post('/ajax_friends/remove_friend',{friend_id:window.profile_user_id},function(){update_profile_item(phpa_id);});},null,null);}
function follow_user(phpa_id){option_box({head:'Follow User',text:'Do you want to follow '+window.profile_display_name+'?',o1:'Follow',o2:'Cancel'},function(){$.post('/ajax_profile/follow_user',{followee:window.profile_user_id},function(){update_profile_item(phpa_id);});},null,null);}
function unfollow_user(phpa_id){option_box({head:'Follow User',text:'Do you want to stop following '+window.profile_display_name+'?',o1:'Unfollow',o2:'Cancel'},function(){$.post('/ajax_profile/unfollow_user',{followee:window.profile_user_id},function(){update_profile_item(phpa_id);});},null,null);}
function update_status(current,phpa_id){option_box_prompt({head:'Update Status',text:'',o1:'Publish',o2:'Cancel',prefill:current},function(status){$.post('/ajax_profile/update_status',{status:status,profile_user_id:window.profile_user_id},function(){update_profile_item(phpa_id);});},null);}
function update_profile_item(phpa_id,callback){$.post('/ajax_profile/profile_item',{phpa_id:phpa_id,profile_id:window.profile_id,editmode:window.editmode},function(data){$('#profile_item_'+phpa_id).replaceWith(data);if(typeof callback=='function')
callback();Cufon.replace('#profile_item_'+phpa_id+' .cufon1',{textShadow:'2px 2px rgba(0, 0, 0, 0.4)'});Cufon.replace('#profile_item_'+phpa_id+' .cufon2, #profile_item_'+phpa_id+' .cufon4',{textShadow:'1px 1px rgba(0, 0, 0, 0.4)'});Cufon.replace('#profile_item_'+phpa_id+' .cufon3');});}
$(function(){$('#profile .wall .postbox textarea').focus(function(){$(this).css({height:'75px'});});featured_recipes_events();additional_photos_events();});function featured_recipes_events(){$('#profile .featured_recipes .recipe_item').mouseover(function(){var content=$(this).find('.recipe_content').html();var $parent=$(this).parents('.featured_recipes');$parent.find('.recipe_content_show').html(content);$parent.find('.recipe_item img').removeClass('active');$(this).find('img').addClass('active');});$('#profile .featured_recipes .recipe_item:first').mouseover();}
function additional_photos_events(){$("#profile .additional_photos a[rel='additional_photos']").fancybox();}
function viewmore_friends_recipes(link,args){var $link=$(link);$link.html('Loading...').attr('onclick','');$.post('/ajax_profile/get_more_friends_recipes',{args:args},function(data){var $temp_container=$('<div/>').html(data);var $existing_container=$('.profile_attribute.friends_recipes');$existing_container.find('a.viewmore').remove();$temp_container.find('.header, .note').remove();$existing_container.append($temp_container.find('.friends_recipes').html());if($temp_container.find('.friends_recipes').find('div.content').length<10)
$link.remove();$temp_container.remove();});};(function($){$.fn.expander=function(options){var opts=$.extend({},$.fn.expander.defaults,options);var delayedCollapse;return this.each(function(){var $this=$(this);var o=$.meta?$.extend({},opts,$this.data()):opts;var cleanedTag,startTags,endTags;var allText=$this.html();var startText=allText.slice(0,o.slicePoint).replace(/\w+$/,'');startTags=startText.match(/<\w[^>]*>/g);if(startTags){startText=allText.slice(0,o.slicePoint+startTags.join('').length).replace(/\w+$/,'');}
if(startText.lastIndexOf('<')>startText.lastIndexOf('>')){startText=startText.slice(0,startText.lastIndexOf('<'));}
var endText=allText.slice(startText.length);if(!$('span.details',this).length){if(endText.replace(/\s+$/,'').split(' ').length<o.widow){return;}
if(endText.indexOf('</')>-1){endTags=endText.match(/<(\/)?[^>]*>/g);for(var i=0;i<endTags.length;i++){if(endTags[i].indexOf('</')>-1){var startTag,startTagExists=false;for(var j=0;j<i;j++){startTag=endTags[j].slice(0,endTags[j].indexOf(' ')).replace(/(\w)$/,'$1>');if(startTag==rSlash(endTags[i])){startTagExists=true;}}
if(!startTagExists){startText=startText+endTags[i];var matched=false;for(var s=startTags.length-1;s>=0;s--){if(startTags[s].slice(0,startTags[s].indexOf(' ')).replace(/(\w)$/,'$1>')==rSlash(endTags[i])&&matched==false){cleanedTag=cleanedTag?startTags[s]+cleanedTag:startTags[s];matched=true;}};}}}
endText=cleanedTag&&cleanedTag+endText||endText;}
$this.html([startText,'<span class="read-more">',o.expandPrefix,'<a href="#">',o.expandText,'</a>','</span>','<span class="details">',endText,'</span>'].join(''));}
var $thisDetails=$('span.details',this),$readMore=$('span.read-more',this);$thisDetails.hide();$readMore.find('a').click(function(){$readMore.hide();if(o.expandEffect==='show'&&!o.expandSpeed){o.beforeExpand($this);$thisDetails.show();o.afterExpand($this);delayCollapse(o,$thisDetails);}else{o.beforeExpand($this);$thisDetails[o.expandEffect](o.expandSpeed,function(){$thisDetails.css({zoom:''});o.afterExpand($this);delayCollapse(o,$thisDetails);});}
return false;});if(o.userCollapse){$this.find('span.details').append('<span class="re-collapse">'+o.userCollapsePrefix+'<a href="#">'+o.userCollapseText+'</a></span>');$this.find('span.re-collapse a').click(function(){clearTimeout(delayedCollapse);var $detailsCollapsed=$(this).parents('span.details');reCollapse($detailsCollapsed);o.onCollapse($this,true);return false;});}});function reCollapse(el){el.hide().prev('span.read-more').show();}
function delayCollapse(option,$collapseEl){if(option.collapseTimer){delayedCollapse=setTimeout(function(){reCollapse($collapseEl);option.onCollapse($collapseEl.parent(),false);},option.collapseTimer);}}
function rSlash(rString){return rString.replace(/\//,'');}};$.fn.expander.defaults={slicePoint:100,widow:4,expandText:'read more',expandPrefix:'&hellip; ',collapseTimer:0,expandEffect:'fadeIn',expandSpeed:'',userCollapse:true,userCollapseText:'[collapse expanded text]',userCollapsePrefix:' ',beforeExpand:function($thisEl){},afterExpand:function($thisEl){},onCollapse:function($thisEl,byUser){}};})(jQuery);
