/**
 * onArcade 2.3.0
 * Copyright © 2006-2010 Hans Mäesalu & Eveterm OÜ, All Rights Reserved
 **
 * ONARCADE IS NOT FREE SOFTWARE!
 * http://www.onarcade.com
 **/
var profile={user_id:0,location:"",location_button:null,location_bubble:null,friends_pages:0,friends:null,comments_page:1,comments:null,comments_form:null,comments_submit:null,draw_friends:function(a,b,c){profile.friends.empty();var d;for(i in a){d=$.createElement("div").addClass("friend");$.createElement("a").attr("href",a[i].url).html('<img src="'+a[i].avatar+'" alt="" />'+a[i].name).appendTo(d);profile.friends.append(d);i==4&&$.createElement("div").addClass("separator").appendTo(profile.friends)}$.createElement("div").addClass("clear").appendTo(profile.friends);
if(b>1){a=$.createElement("div").addClass("pagination");c>1&&$.createElement("a").attr("href","").html("&lsaquo;").data("page",c-1).click(profile.friends_click).appendTo(a);for(i=1;i<=b;i++){d=$.createElement("a").attr("href","").text(i).data("page",i).click(profile.friends_click).appendTo(a);i==c&&d.addClass("current")}c<b&&$.createElement("a").attr("href","").html("&rsaquo;").data("page",c+1).click(profile.friends_click).appendTo(a);profile.friends.append(a)}},friends_click:function(){profile.load_friends($(this).data("page"));
return false},load_friends:function(a){loader.replace(profile.friends);$.getJSON(siteurl+"profile.php?a=friends&u="+profile.user_id+"&p="+a+"&ajax="+profile.friends_pages,function(b){if(b.error)alert(b.message);else{if(b.pages!=undefined)profile.friends_pages=b.pages;profile.draw_friends(b.friends,profile.friends_pages,a)}})},friend_request:function(a){loader.insert(a);$.getJSON(siteurl+"usercp.php?a=friend_request&f="+profile.user_id+"&ajax=1",function(b){error.insert(b.message,a.parent(),{error:b.error});
a.parent().slideUp(250)})},submit_comment:function(){loader.insert(profile.comments_submit);$.post(siteurl+"profile.php?a=submit_comment&u="+profile.user_id+"&ajax=1",profile.comments_form.serializeArray(),function(a){error.insert(a.message,profile.comments_form,{error:a.error});if(a.error)loader.remove(profile.comments_submit);else{profile.comments_form.slideUp();a=$.createElement("div").addClass("comment").html('<a href="'+a.user_url+'"><img src="'+a.avatar+'" class="user_avatar" alt="" /></a><p><span class="user"><a href="'+
a.user_url+'">'+a.username+'</a></span> <span class="date">('+a.date+")</span></p><p>"+a.comment+"</p>");var b=profile.comments.children("div:first-child");b.size()>0?b.before(a):profile.comments.append(a)}},"json")},delete_comment:function(a){if(confirm_delete()){var b=a.closest(".comment");loader.insert(a);$.getJSON(siteurl+"profile.php?a=delete_comment&c="+field_number(b.attr("id"))+"&ajax=1",function(c){c.error?alert(c.message):b.slideUp()})}},load_comments:function(a){loader.replace(profile.comments);
profile.comments.load(siteurl+"profile.php?a=comments&u="+profile.user_id+"&p="+a+"&ajax=1")},open_map:function(){if(profile.location_bubble==null){profile.location_bubble=$.createElement("div").addClass("bubble").width("400px");$.createElement("div").addClass("bubble_up").css("left","70px").appendTo(profile.location_bubble);$(document.body).append(profile.location_bubble);profile.location_bubble.append('<img src="http://maps.google.com/maps/api/staticmap?center='+encodeURI(profile.location)+'&size=400x350&sensor=false&amp;maptype=hybrid" alt="" />');
profile.location_bubble.click(function(b){b.stopPropagation()})}else profile.location_bubble.fadeIn("fast");var a=profile.location_button.offset();profile.location_bubble.css({top:a.top+30,left:a.left-70});$(document).click(profile.close_map)},close_map:function(){profile.location_bubble.fadeOut("fast");$(document).unbind("click",profile.close_map)},init_map:function(){var a=$("#user_location");profile.location=a.children("span").text();if(profile.location.length>0)profile.location_button=a.children("img").css("display",
"inline").click(function(){profile.open_map();return false})},init:function(a){profile.user_id=a;profile.friends=$("#friends");profile.friends.size()>0&&$("#all_friends").click(function(){profile.load_friends(1);return false});$("#friend_request").click(function(){profile.friend_request($(this));return false});profile.comments=$("#comments");profile.comments_form=$("#comment_form");if(profile.comments_form.size()>0){profile.comments_submit=profile.comments_form.find("input:submit");profile.comments_form.submit(function(){profile.submit_comment();
return false})}$("#comments .delete a").live("click",function(b){b.preventDefault();profile.delete_comment($(this))});$("#comments .next").live("click",function(b){b.preventDefault();profile.comments_page++;profile.load_comments(profile.comments_page)});$("#comments .previous").live("click",function(b){b.preventDefault();profile.comments_page--;profile.load_comments(profile.comments_page)});profile.init_map()}};
