function ProfilePage(){
this.superclass();
this.iMessager=null;
this.init=function(){
Page.prototype.init.apply(this);
this.iMessager=new Messager();
this.iMessager.init(["friendsBlock","profileActions"]);
var _1=$("notificationsBlock");
if(_1){
var i,j,_4,_5;
var _4=$("notificationsBlock").getElementsByTagName("a");
for(j=0;j<_4.length;j++){
_5=_4[j].id.match(/^friendRequest(\d*)$/);
if(_5){
_4[j].href="javascript: gPage.startShowFriendRequest("+_5[1]+");";
}
}
}
};
this.startShowFriendRequest=function(_6){
gPage.iDialog=new ConfirmFriendRequestDialog(this,this.confirmCallback,_6);
this.iRequestMode=gConst.kGetUserInfoRequest;
this.submitRequest({userId:_6},"getUserInfo.php");
};
this.confirmCallback=function(_7){
this.iRequestMode=gConst.kSubmit;
var _8=gPage.iDialog.getPostObject();
_8.confirmed=_7;
this.submitRequest(_8,"respondToFriendRequest.php");
};
this.submitRequest=function(_9,_a){
var _b=JSON.stringify(_9);
this.iSetRequest=HTTP.newRequest();
this.iSetRequest.open("POST","data/"+_a,true);
this.iSetRequest.setRequestHeader("Content-type","text/plain");
this.iSetRequest.setRequestHeader("Content-length",_b.length);
this.iSetRequest.setRequestHeader("Connection","close");
this.iSetRequest.onreadystatechange=function(){
gPage.handleAddFriendResponse();
};
this.iSetRequest.send(_b);
this.iSetTimer=window.setTimeout("gPage.setRequestTimedOut();",10000);
};
this.handleAddFriendResponse=function(){
if(this.iSetRequest.readyState==4){
window.clearTimeout(this.iSetTimer);
this.iSetTimer=null;
if(this.iSetRequest.status==200){
var _c=JSON.parse(this.iSetRequest.responseText);
if(_c.ok){
if(this.iRequestMode==gConst.kGetUserInfoRequest){
gPage.iDialog.init(_c);
gPage.iDialog.display();
}else{
if(this.iRequestMode==gConst.kSubmit){
this.finishAddFriend(_c);
}
}
}else{
this.userFeedback("add friend response failed");
}
}else{
this.userFeedback("server error");
this.iSetTimer=null;
}
}
};
this.finishAddFriend=function(_d){
var _e=$("friendReq"+_d.friendReqId);
var _f=_e.parentNode;
_f.removeChild(_e);
var arr=_f.getElementsByTagName("div");
var _11=0;
for(var i=0;i<arr.length;i++){
if(arr[i].className=="notification"){
_11++;
}
}
if(_11==0){
var div=document.createElement("div");
div.className="notification";
div.appendChild(document.createTextNode("no new notifications"));
div.style.fontWeight="bold";
_f.appendChild(div);
}
var _14=_d.confirmed?"Friend request confirmed. You are now friends with "+_d.userName:"Friend request ignored.";
this.userFeedback(_14);
};
this.setRequestTimedOut=function(){
this.iSetTimer=null;
this.userFeedback("request timed out");
};
this.userFeedback=function(_15){
gPage.iDialog=new TimedAlert("respond to friend request",_15);
gPage.iDialog.display();
};
}
ProfilePage.prototype=new Page();
ProfilePage.prototype.superclass=Page;
ProfilePage.prototype.constructor=ProfilePage;
gPage=new ProfilePage();

