﻿// JScript File
function addToFriends(FriendId,SuccessText,ClientID) 
{
    //Close //s done by me (AJH 15/06/07) in order for it to work with a label rather than an image
	oXmlHttp = zXmlHttp.createRequest();
	oXmlHttp.open('get', '/Site/Controls/HiddenPages/AddToFriends.aspx?FriendId='+encodeURIComponent(FriendId), true);
	oXmlHttp.onreadystatechange = function () {
		if (oXmlHttp.readyState == 4)
		{
		    var btn = document.getElementById(ClientID)
			//var btndir = btn.src.substring(0, btn.src.lastIndexOf('/')+1);
			
			if (oXmlHttp.status == 200)
			{
			    //btn.src = '';
			    btn.innerHTML = SuccessText;
			    btn.parentNode.removeAttribute('onclick');
			    //btn.parentNode.removeAttribute('onclickoff')
			    btn.parentNode.style.cursor = 'default';
			    btn.style.color = '#EEEEEE';
			    //btn.parentNode.setAttribute('style', 'cursor: default;');	
			}
			else
			{
				//btn.src = btndir+'add-to-friends.gif';
				//btn.parentNode.setAttribute('onclick', btn.parentNode.getAttribute('onclickoff'));
				//btn.parentNode.removeAttribute('onclickoff')
				//btn.parentNode.style.cursor = 'pointer';
				//btn.parentNode.setAttribute('style', 'cursor: pointer;');
			}
		}
	}
	var btn = document.getElementById('addtofriends')
//	var btndir = btn.src.substring(0, btn.src.lastIndexOf('/')+1);
//	btn.src = btndir+'sending-data.gif';
	//btn.parentNode.setAttribute('onclickoff', btn.parentNode.getAttribute('onclick'));
	//btn.parentNode.setAttribute('onclick', 'return false');
	//btn.parentNode.style.cursor = 'wait';
	//btn.parentNode.setAttribute('style', 'cursor: wait;');
	oXmlHttp.send(null);
}