function onAdd(apps, rid, vType)
{
    if (typeof XMLHttpRequestObject == 'undefined'){XMLHttpRequestObject = new Array;}  
    if(XMLHttpRequestObject[rid] != null){ return;}

    var voteObject = GetXMLHttpRequest();
    if (voteObject){
       XMLHttpRequestObject[rid] = new Object();
        XMLHttpRequestObject[rid].voteObject = voteObject;

        voteObject.onreadystatechange = new Function ("alertAddResponse('" + apps + "','" + rid + "','" + vType + "')");
		var URL = 'http://www.fathost.com/apps/add-mylist.php';
        var url = URL + "?" + "apps=" + apps + "&rid=" + rid + "&vType=" + vType;

        voteObject.open("GET", url, true);
        voteObject.setRequestHeader( "Content-Type" , "application/x-www-form-urlencoded; charset=UTF-8" );
        voteObject.send("");
    }
}

function alertAddResponse(apps, rid, vType)
{
   if (XMLHttpRequestObject[rid].voteObject &&
        XMLHttpRequestObject[rid].voteObject.readyState == 4) 
    {
        if (XMLHttpRequestObject[rid].voteObject.status == 200) 
        {
            var result = XMLHttpRequestObject[rid].voteObject.responseText;
            if (result == "busy" || result == "no-change" || result == "session_expired" || result == "missing_fields")
            {
//              alert("The server is busy. Try again.");
                XMLHttpRequestObject[rid] = null;
            }
            else
            {
				var disable = true;
				
			 	var vTagId = "vLink" + rid;
             	disableAnchor(apps, vTagId, vType);
				
            }
        } 
    }
}

function disableAnchor(apps, vTagId, vType)
{
	var voteObj = document.getElementById(vTagId);
	if(voteObj != null)
	{
		var href = voteObj.getAttribute("href");
		//First we store previous value in a new attribute
		if(href && href != "" && href != null){
			voteObj.setAttribute('href_bak', href);
		}
		voteObj.removeAttribute('href');
		voteObj.removeAttribute('class');
		voteObj.style.textDecoration  = "none";
	}
		
	if(voteObj.hasChildNodes()){
		voteObj.removeChild(voteObj.firstChild);
	}
	if(apps == 'lists'){
		if(vType == 'add'){
			voteObj.setAttribute((document.all ? "className" : "class"), "usrAdded");
			voteObj.style.color= '#3A89C9';
			var newtext = document.createTextNode("like it");
			voteObj.appendChild(newtext);		
		}
	}
} 



//remove 'my bookmark' entry
function deleteFav(memFavId)
{
    var favObject = GetXMLHttpRequest();
    if (favObject) {
		var URL = 'http://www.fathost.com/apps/delete-mylist.php';
        var url = URL + "?" + "memFavId=" + memFavId;		
//		hitsObject.open("POST", url, true);
		favObject.open("GET", url, false); //If TRUE, the execution of the JavaScript function will continue while the response of the server has not yet arrived. in this case the hits count may not be updated (due to slow server response) and the user may already been redirected to the new url
        favObject.setRequestHeader( "Content-Type" , "application/x-www-form-urlencoded; charset=UTF-8" );
        favObject.send("");
	}
	document.getElementById(rid).style.display = "none";
return;
}

