function fetchUserInfo() {    
        var dataRequest = opensocial.newDataRequest();
        var personRequest = dataRequest.newFetchPersonRequest(opensocial.DataRequest.PersonId.OWNER);
        dataRequest.add(personRequest);
        dataRequest.send(postFetchUserInfo);
}

function postFetchUserInfo(dataResponse) {
        
    var ownerData = dataResponse.get(opensocial.DataRequest.PersonId.OWNER).getData();
    var ownerId = ownerData.getField(opensocial.Person.Field.ID);

    var params = {};
    params[opensocial.ContentRequestParameters.METHOD] = opensocial.ContentRequestParameters.MethodType.GET;
    //params[opensocial.ContentRequestParameters.CONTENT_TYPE] = opensocial.ContentRequestParameters.ContentType.HTML;
    params[opensocial.ContentRequestParameters.AUTHENTICATION] =  opensocial.ContentRequestParameters.AuthenticationType.SIGNED;
    opensocial.Container.get().makeRequest("http://myspace.appizer.com/friendgrid/postback.php?act=friends", divLoad, params);

}

function divLoad(data){ 
	//alert(data);
	temp = data.split('|');
	//alert(temp[0]);
	gadgets.window.adjustHeight(temp[0]);
	document.getElementById('gridview').innerHTML = temp[1]; 
}

function showfriend(id, pos, extra) {
  
  imgdiv = document.getElementById('showfriendimg');
  friendimage = document.getElementById(id);
  if (pos == "right") {
    imgdiv.style.left = '322px'; imgdiv.style.top = '0px';
  } else {
    imgdiv.style.top = '0px'; imgdiv.style.left = '0px';  
}
  imgdiv.style.display = "block";
    
  imgdiv.innerHTML = "<img src='"+friendimage.src+"'><br><b>"+friendimage.alt+"</b>"+extra;

}

function hidefriend(id) { 
  imgdiv = document.getElementById('showfriendimg');
  friendimage = document.getElementById(id);
  imgdiv.style.display = "none";
  imgdiv.innerHTML = "";
}

function init() {
    fetchUserInfo();
}

init();
