           var ids = new Array();
            var idsAdded = new Array();
            function inviteFriends(num)
            {
                var i = 0;
                
                ownerAddedFriends.each(function(person) {
                    
                    var tempId = person.getField(opensocial.Person.Field.ID);
                    idsAdded[i] = tempId;
                    i++;
                    
                });

                
                i = 0;

                ownerFriends.each(function(person) {
                    
                    var tempId = person.getField(opensocial.Person.Field.ID);
                    var alreadyAdded = 0;

                    for (var j = 0; j < idsAdded.length; j++)
                    {
                        if (idsAdded[j] == tempId)
                        {
                            alreadyAdded = 1;
                            break; 
                        }
                    }

                    if ((alreadyAdded == 0) && (i < num))
                    {
                        ids[i] = tempId;
                        i++;
                    }
                });

                popupInvite();
            }

             
            function popupInvite()
            {
                var id = ids.pop();

                if (!id)
                {
                
                gh('NukEM Games - Text friends play endless games ... Have Fun','<center><font size="3"><b>NukEM Games</b><bR><bR><a href="http://nukemgames.com" target="_blank">Play Tons of games and add them to your myspace.<br>Text Your friends right from online for free. <br>Add a TEXT ME box to your myspace so people can start texting you.<br><Br><img src="http://i145.photobucket.com/albums/r239/kipdlid/cornerani.gif">');
                }

                message = opensocial.newMessage("Hey [recipient], [sender] would like you to install the [app] app!  [app] is a fun game you should try and install... INSTALL NOW");
                opensocial.requestShareApp(id, message, ptcallback);

}

function bulletincall(someVal1){
	            if (someVal1 == MyOpenSpace.PostTo.Result.ERROR) 
{
inviteFriends(12);
	            }
	            else if (someVal1 == MyOpenSpace.PostTo.Result.CANCELLED) 
                {  
                gh(gamename,bulletincont,bulletincall);
	            }
	            else if (someVal1 == MyOpenSpace.PostTo.Result.SUCCESS) 
                {
inviteFriends(12);
	            }
	            else
                {
               inviteFriends(12);

            }
}

function myFunction(){
var count = GetCookie('count');
var i = parseInt(count);
var lefti = 5 - i;
if (lefti <=0){lefti = '0';}
if (i >= 5) {
pressbulletin();
}else{   
document.getElementById('Message').innerHTML = 'You have invited '+i+' people successfully. You have to invite '+lefti+' more people to finish inviting and play';
}
}

