function printInvitePage()
{
	cleanup();
	changeTab('inviteTab');
	document.getElementById("leftColumn").style.visibility = "hidden";
	document.getElementById("leftTwoHead").style.visibility = "hidden";
	document.getElementById("rightColumn").style.visibility = "hidden";
	document.getElementById("rightTwoHead").style.visibility = "hidden";
	document.getElementById("rightThreeHead").style.visibility = "hidden";

	document.getElementById("user").innerHTML = "<br/><img class='icon' src='"+imageUrl+"icon_invite.gif'/> "+
		"<span style='font-size: 20px; font-weight: bold;'>Invite Friends</span><br/>";
		 
	if ( isOwner )
	{		
		document.getElementById("user").innerHTML += "<br/>Loading ... Please wait ..."
		gadgets.io.makeRequest(requestUrl+"prepfriends.php", processInviteFriends,
			{'METHOD' : gadgets.io.MethodType.POST,'POST_DATA':"invite=1&site="+site+"&uids="+all_friends_uids, 'CONTENT_TYPE':gadgets.io.ContentType.DOM});
	}
	else
	{
		if ( hasApp )
			document.getElementById("user").innerHTML += "Please click <a href='"+appUrl+"'>here</a> to invite your own friends.";
		else
			document.getElementById("user").innerHTML += "Please click <a href='"+installUrl+"'>here</a> to install the app.";
	}
}

function processInviteFriends(response)
{
	var xml = response.data;
		
	if ( xml && xml.getElementsByTagName("head")[0].firstChild != null ) 
	{
		var uids = xml.getElementsByTagName("uid");
		var str = "<br/><img class='icon' src='"+imageUrl+"icon_invite.gif'/> "+
			"<span style='font-size: 20px; font-weight: bold;'>Invite Friends</span><br/><table width='100%'>"+
			"<tr><td colspan='5'>Click on a friend to invite<br/><br/></td></tr>"+
			"<tr>";
		var uid = 0;
		var num = uids.length; 
		if ( num > 35 )
			num = 35;
		for ( var i = 0; i < uids.length; i ++ )
		{
			id = uids[i].firstChild.data;
			str += "<td onClick='selectFriend("+id+")' width='20%' height='20%' class='click'><b>"+uid_name[id]+"</b><br/>";
			str += "<img src='"+uid_thumb[id]+"'/></td>";
						
			if ( ((i+1) % 5) == 0 )
			{
				str += "</tr><tr>"; 
			}
		}	
		document.getElementById("user").innerHTML = str + "</tr></table>";
	}
	else
	{
		document.getElementById("user").innerHTML = "<br/>Invite Friends<br/>All your friends have Restaurants installed. Yay.";
	}
}

function selectFriend(uid)
{
	var str = "<br/><img class='icon' src='"+imageUrl+"icon_invite.gif'/> "+
		"<span style='font-size: 20px; font-weight: bold;'> Invite Friends</span></br/><br/>"+
		"<b>Step 1 :</b> Copy the following text to send to your friend (of course you can modify it)<br/><br/>"+ 
		"<TEXTAREA id='area' rows='10' cols='90'>"+
		"Hey "+uid_name[uid]+", <a href='"+installUrl+"'>install this app</a> to check out restaurants near you, or for the next trip. They have tons of reviews and recommendations. "+
		"Click <a href='"+installUrl+"'>here</a> to see where I have eaten at recently, what kind of food I like, and where I wanna try, etc etc etc..."+
		"<br/><br/>P.S. If the link has problem, can copy and paste this http://www.myspace.com/reviewrestaurant in the address bar."+
		"</TEXTAREA><br/><br/>"+
		"<b>Step 2 :</b> Click on the picture below to load the message page.<br/><br/>"+
		"<a target='_blank' href='http://comment.myspace.com/index.cfm?fuseaction=user.viewProfile_commentForm&friendID="+uid+"'><img src='"+uid_thumb[uid]+"'/></a><br/><br/>"+
		"<b>Step 3 :</b> On the message page, paste the message in the box and click the send button.<br/><br/>"+
		"<b>Step 4 :</b> <span style='font-size: 16px;'> Click <a href='javascript:();' onClick='printInvitePage()'>here</a> to invite more friends.</span>";
	document.getElementById("user").innerHTML = str;	
}