// JavaScript Document

function addtofriends(fid,path)
{	
	try
	{	  								
		pars = 'fid=' + fid
					 + '&sq=afriend';

		//make a call to get data
	  	var addFriend_myAjax = new Ajax.Request(
			path, 
			{
				method: 'get', 
				parameters: pars, 			
				onComplete: function(retVal) {
					showFriendButton(fid,path,"on");
					return true;
				}
			}
		);		
	}
	catch (err)
	{
	   alert("addtoFriends:"+err+"\n"+err.number+" - "+err.description);
	}
}



function removefromfriends(fid,path){
	new Ajax.Request(path, {parameters: '&fid=' + fid + '&sq=rfriend' });

	showFriendButton(fid,path,"off");
}

	

	

function showFriendButton(fid,path,status) 

{
	if(status=="on"){
		t=fid+"friend";
		document.getElementById(t).innerHTML = "<a href=\"javascript://\" onclick=\"removefromfriends("+fid+",'"+path+"');\"><img src=\"/images/remove_from__friends.png\" border=0></a>";
	}
	else if(status=="off"){
		t=fid+"friend";

	    document.getElementById(t).innerHTML = "<a href=\"javascript://\" onclick=\"addtofriends("+fid+",'"+path+"');\"><img src=\"/images/add_to_friends.png\" border=0></a>";
	}
}

