//Hardcoded//
	function socialsInit(Id)
	{
		postId = Id;
		//var postId = postId;
		//alert (postId);
		var SITE_ID = google_apikey;
	    var viewer, ownerFriends, activities, email, owner;
		//alert(postId);
		
		if (document.getElementById('vv_Sign_Google_button_'+postId) == undefined) {
			if (document.getElementById('vv_Sign_Facebook_button_'+postId) != undefined) {
				if(typeof(FB) != "undefined") {
					if(typeof(FB.Connect) != "undefined") {
						FB.Connect.ifUserConnected(
							function() {
								document.getElementById('vv_Sign_AOL_button_'+postId).className = '';
								var user_id = FB.Connect.get_loggedInUser();
								FB.Facebook.apiClient.fql_query("SELECT name, pic_square_with_logo, current_location FROM user WHERE uid="+user_id,
											function(rows) {		
												   var string = 'Hello, '+rows[0].name+'!<br><a href="http://www.facebook.com/profile.php?id='+
															user_id+'"><img src="'+rows[0].pic_square_with_logo+'"></a><br><br>'+
															'<a href="javascript:void(0)" onclick="signOutFacebook()">Sign out</a><br><br>'+
															'Name: '+rows[0].name+
															'<br>Country: '+rows[0]['current_location'].country+
															'<br>City: '+rows[0]['current_location'].city;
													document.getElementById('vv_Sign_AOL_button_'+postId).innerHTML = '';									
													document.getElementById('vv_Sign_Facebook_button_'+postId).innerHTML = string;
															addField('displayName',rows[0].name);
															addField('id',user_id);
															addField('profileUrl','http://www.facebook.com/profile.php?id='+user_id);
															addField('thumbnailUrl',rows[0].pic_square_with_logo);
															document.getElementById('_country_'+postId).value = rows[0]['current_location'].country;
															document.getElementById('_city_'+postId).value = rows[0]['current_location'].city;
															//document.getElementById('sign_button').innerHTML = '';
												 });
							}, 
							function ()	{
								// Create the Facebook sign in link
								if (document.getElementById('vv_Sign_Facebook_button_'+postId) != undefined) {
									document.getElementById('vv_Sign_Facebook_button_'+postId).innerHTML = "<a href=\"javascript:void(0)\" onclick=\"FB.Connect.requireSession(); return false;\" class=\"fbconnect_login_button FBConnectButton FBConnectButton_Small\"><span id=\"RES_ID_fb_login_text\"  class=\"FBConnectButton_Text\">Connect with Facebook</span></a>";
								}
								 //create AOL link     onclick="do_aol_auth_request();"
								if (document.getElementById('vv_Sign_AOL_button_'+postId) != undefined) {
									document.getElementById('vv_Sign_AOL_button_'+postId).innerHTML = '<a onclick="do_aol_auth_request(); window.location.href = \'#AUTHDONE\'; window.open(\'http://api.screenname.aol.com/auth/login?f=json&devId=ed1nLwllSzvWsuIa&tokenType=longterm\',\'Sign with aol\',\'height=330, width=530\');" class="vv_aol_signin_link" href="javascript:void(0)" rel="external nofollow">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>';
									document.getElementById('vv_Sign_AOL_button_'+postId).className = 'aol_changed';
								}
							}
						);
					} else {
						// Create the Facebook sign in link
						if (document.getElementById('vv_Sign_Facebook_button_'+postId) != undefined) {
							document.getElementById('vv_Sign_Facebook_button_'+postId).innerHTML = "<a href=\"javascript:void(0)\" onclick=\"FB.Connect.requireSession(); return false;\" class=\"fbconnect_login_button FBConnectButton FBConnectButton_Small\"><span id=\"RES_ID_fb_login_text\"  class=\"FBConnectButton_Text\">Connect with Facebook</span></a>";
						}
						 //create AOL link     onclick="do_aol_auth_request();"
						if (document.getElementById('vv_Sign_AOL_button_'+postId) != undefined) {
							document.getElementById('vv_Sign_AOL_button_'+postId).innerHTML = '<a onclick="do_aol_auth_request(); window.location.href = \'#AUTHDONE\'; window.open(\'http://api.screenname.aol.com/auth/login?f=json&devId=ed1nLwllSzvWsuIa&tokenType=longterm\',\'Sign with aol\',\'height=330, width=530\');" class="vv_aol_signin_link" href="javascript:void(0)" rel="external nofollow">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>';
							document.getElementById('vv_Sign_AOL_button_'+postId).className = 'aol_changed';
						}
					}
			
				} else {
					// Create the Facebook sign in link
					if (document.getElementById('vv_Sign_Facebook_button_'+postId) != undefined) {
						document.getElementById('vv_Sign_Facebook_button_'+postId).innerHTML = "<a href=\"javascript:void(0)\" onclick=\"FB.Connect.requireSession(); return false;\" class=\"fbconnect_login_button FBConnectButton FBConnectButton_Small\"><span id=\"RES_ID_fb_login_text\"  class=\"FBConnectButton_Text\">Connect with Facebook</span></a>";
					}
					 //create AOL link     onclick="do_aol_auth_request();"
					if (document.getElementById('vv_Sign_AOL_button_'+postId) != undefined) {
						document.getElementById('vv_Sign_AOL_button_'+postId).innerHTML = '<a onclick="do_aol_auth_request(); window.location.href = \'#AUTHDONE\'; window.open(\'http://api.screenname.aol.com/auth/login?f=json&devId=ed1nLwllSzvWsuIa&tokenType=longterm\',\'Sign with aol\',\'height=330, width=530\');" class="vv_aol_signin_link" href="javascript:void(0)" rel="external nofollow">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>';
						document.getElementById('vv_Sign_AOL_button_'+postId).className = 'aol_changed';
					}
				}
			} else {
				if (document.getElementById('vv_Sign_AOL_button_'+postId) != undefined) {
					document.getElementById('vv_Sign_AOL_button_'+postId).innerHTML = '<a onclick="do_aol_auth_request(); window.location.href = \'#AUTHDONE\'; window.open(\'http://api.screenname.aol.com/auth/login?f=json&devId=ed1nLwllSzvWsuIa&tokenType=longterm\',\'Sign with aol\',\'height=330, width=530\');" class="vv_aol_signin_link" href="javascript:void(0)" rel="external nofollow">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>';
					document.getElementById('vv_Sign_AOL_button_'+postId).className = 'aol_changed';
				}
			}
		} else {
			google.friendconnect.container.setParentUrl('/api/' );
			google.friendconnect.container.loadOpenSocialApi({ 
	            site: SITE_ID,
	            onload: function() { /*initAllData();*/ init(); }});
		}
	}
	
    function setupData(data) {
      viewer = data.get('viewer').getData();
	  if (document.getElementById('vv_Sign_Google_button_'+postId) != undefined) {
	      if (viewer) {
			var loc2;
			if (google.loader.ClientLocation) {
				var loc = google.loader.ClientLocation.address;
				loc2 = loc.city + " (" + loc.region + "), " + loc.country;
			}
	        document.getElementById('vv_Sign_Google_button_'+postId).innerHTML = 
	        '<img align="left" src="' + viewer.getField("thumbnailUrl")  + '">' +
	        '<b>Hi, ' +  viewer.getField("displayName") + '!</b><br>' +
	        '<a href="javascript:void(0)" onclick="google.friendconnect.requestSettings(); return false;">Settings</a><br>' +
	        //'<a href="#" onclick="google.friendconnect.requestInvite(\'Come and pick a color!\'); return false;">Invite</a><br>' +
	        '<a href="javascript:void(0)" onclick="google.friendconnect.requestSignOut(); return false;">Sign out</a><br>' +
//		'<p>E-mail: ' + viewer.getField("displayEmails") + '<br>' +
//		'Name: ' + viewer.getField("name") + '<br>' +
			/*'Prifile Url: ' + viewer.getField("profileUrl") + '<br>' +
			'Addresses: ' + viewer.getField("addresses") + '<br>' +
			'Current Location: ' + viewer.getField("currentLocation") + '<br>' +
			'Nickname: ' + viewer.getField("nickname") + '<br>' +
			'URLs: ' + viewer.getField("urls")[0].getField("address") + '<br>' +*/
			'Location:' +loc2 + ' <br>' +
//		'<input type="hidden" name="social" value="y">' +
			'<input type="hidden" name="name" value="' + viewer.getField("displayName") + '">' +
			'<input type="hidden" name="thumbnail" value="' + viewer.getField("thumbnailUrl") + '">' +
			'<input type="hidden" name="location" value="' + loc2 + '">' +
			//'<input type="hidden" name="social" value="' +  + '">' +
			//'<input type="hidden" name="social" value="' +  + '">' +
			'</p>';
	      } else {
	        //google.friendconnect.renderSignInButton({ 'id': 'vv_Sign_Google_button','text':'Add your info','style':'standard' });
			document.getElementById('vv_Sign_Google_button_'+postId).innerHTML = "<a href='javascript:void(0)' onclick='google.friendconnect.requestSignIn()'>Add your data</a>";
	      }
	    }
	};
if (typeof(aol_apikey) != 'undefined') {
		/* * AOL CONNECTION FUNCTIONS */
		// Constructor -- pass a REST request URL to the constructor
	function JSONscriptRequest(fullUrl) {
	    // REST request path
	    this.fullUrl = fullUrl; 
	    // Keep IE from caching requests
	    this.noCacheIE = '&noCacheIE=' + (new Date()).getTime();
	    // Get the DOM location to put the script tag
	    this.headLoc = document.getElementsByTagName("head").item(0);
	    // Generate a unique script tag id
	    this.scriptId = 'JscriptId' + JSONscriptRequest.scriptCounter++;
	}
	
	// Static script ID counter
	JSONscriptRequest.scriptCounter = 1;
	
	// buildScriptTag method
	JSONscriptRequest.prototype.buildScriptTag = function () {
	    // Create the script tag
	    this.scriptObj = document.createElement("script");
	    // Add script object attributes
	    this.scriptObj.setAttribute("type", "text/javascript");
	    this.scriptObj.setAttribute("charset", "utf-8");
	    this.scriptObj.setAttribute("src", this.fullUrl + this.noCacheIE);
	    this.scriptObj.setAttribute("id", this.scriptId);
	}
	 
	// removeScriptTag method
	JSONscriptRequest.prototype.removeScriptTag = function () {
	    // Destroy the script tag
	    this.headLoc.removeChild(this.scriptObj);  
	}
	
	// addScriptTag method
	JSONscriptRequest.prototype.addScriptTag = function () {
	    // Create the script tag
	    this.headLoc.appendChild(this.scriptObj);
	}
	var mqm;
	var token = "";
	var devId = aol_apikey;
	var succURL = "#AUTHDONE";
	var loginDone = false;
	
	/** On startup - just calls routine to wait for user to finish login */
	function do_aol_auth_request() {
	    watchAuthRequest();
	}
	
	/* This routine checks for OpenAuth response to login or consent -
	   it sets a timer until it gets a response.
	  URL Frags returned by OpenAuth 
	   1. AUTHCANCEL - user canceled login flow (user clicked on cancel button)
	   2. AUTHDONE - user successfully authenticated
	   3. INVALIDCALLBACK - invalid jsonp callback ('c' param) value
	   4. CONSENTINVALIDTOKEN - consent url called with invalid token
	   5. CONSENTDONE - consent process done (user clicked on Allow Always or this time)
	   6. CONSENTCANCEL - user denied permission
	*/
	function watchAuthRequest() {
	  var oLoc = location.href;
	  if (!loginDone && oLoc.indexOf("#AUTHDONE") > -1) {
	    // After login is complete, need to do Ajax call to then get the login token
	    doGetToken();		// puts token in global above	
	  } else if (oLoc.indexOf("#CONSENTDONE") > -1) {
	    // try again to get Presence (BL)
	    doGetPresence();
	  } else if (oLoc.indexOf("#CONSENTCANCEL") > -1 || oLoc.indexOf("#AUTHCANCEL") > -1) {
	    // just check out I guess
	    //alert("they cancelled on us!");
	  } else if (oLoc.indexOf("#CONSENTINVALIDTOKEN") > -1) {
	    // endSession();
	    //alert("Please log in again!");
	  } else {
	    // try again in half a second
	    clearTimeout(oTimeout);
	    var oTimeout = setTimeout(watchAuthRequest, 500);
	  }
	}
	
	/** This makes a request of OpenAuth to give us the token for the user that has
	 *  just signed on.  We use a script tag to make this request in order to
	 *  get around the AJAX domain restriction.
	 */
	function doGetToken() {
	  /** Create and make script tag request (JSONScriptRequest)
	   *  If call succeeds then callback parses JSON response into a JSON object
	   */
	  req = "http://api.screenname.aol.com/auth/getToken?c=parseGetToken&f=json&devId=" + devId + "&referer=" + succURL;
	  aObj = new JSONscriptRequest(req);
	  aObj.buildScriptTag();
	  aObj.addScriptTag();	// makes request which does callback to parseGetToken()
	}
	
	/** Parse response, if we got a token then continue on to get Presence */
	function parseGetToken(jsonObj) {
	  if (jsonObj.response.statusCode != 200) {
	    //alert("Failed getToken, with status=" + jsonObj.response.statusCode);
	  } else {
	    token = jsonObj.response.data.token.a;
	    timeout = jsonObj.response.data.token.expiresIn;
	    aObj.removeScriptTag();
	    if (token != null && token != '') {
	      loginDone = true;
	      doGetPresence();
	    }
	  }
	}
	
	/** Again use script tag method to get userInfo */
	function doGetPresence() {
	  req = "http://api.screenname.aol.com/auth/getInfo?c=parseGetInfo&f=json&devId=" + devId + "&a=" + token;
	  aObj = new JSONscriptRequest(req);
	  aObj.buildScriptTag();
	  aObj.addScriptTag();	// makes request which does callback to parseGetInfo()
	}
	
	/** Parse response with userdata */
	function parseGetInfo(jsonObj) {
	  if (jsonObj.response.statusCode != 200) {
	    //alert("Failed getInfo, with status=" + jsonObj.response.statusCode);
	  } else {
	    userdata = jsonObj.response.data.userData;
	
	    loginId = userdata.loginId;
		imgUrl = "http://api.oscar.aol.com/expressions/get?type=buddyIcon&f=native&t=" + loginId;
		email = loginId + "@aol.com";
		//alert('<img src="' + imgUrl + '" border="0" />');
		//document.getElementById('vv_Sign_AOL_button').innerHTML = loginId + '<img src="' + imgUrl + '" border="0" />';
		if (loginId != '')	{
		//document.getElementById("vv_Sign_AOL_button").innerHTML
			var string = '<b style="font-weight:normal;font-size:14px;color:red;">AOL openAuth Connected</b>';
			document.getElementById('vv_Sign_Google_button_'+postId).innerHTML = '';	
			document.getElementById('vv_Sign_Facebook_button_'+postId).innerHTML = '';									
			document.getElementById('vv_Sign_AOL_button_'+postId).innerHTML = string;
			addField('displayName',loginId);
			addField('thumbnailUrl',imgUrl);
			//addField('email',email);
			document.getElementById('vv_Sign_AOL_button_'+postId).className = '';
		}
	  }
	}
	/* * AOL CONNECTION FUNCTIONS */
}

function init() {
  // Create a request to grab the current viewer.
  // We use a params array to ask for all the available fields for the user
  // aboutMe and urls are friend connect specific fields and thus are not defined in the spec
  // They are described in the friend connect documentation
  // The list of friend connect specific field may grow: check the latest documentation.
  var params = {};
  params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] =
  [opensocial.Person.Field.PROFILE_URL, 'aboutMe', 'urls'];
  var req = opensocial.newDataRequest();
  req.add(req.newFetchPersonRequest('VIEWER', params), 'viewer_data');
  // Sent the request
  req.send(onData);
}

function signOutFacebook() {
	FB.Connect.logout();
	document.getElementById('vv_Sign_Facebook_button_'+postId).innerHTML = '';
}

function onData(data) {
  //Hard Coded//
  // If the view_data had an error, then user is not signed in
  if (data.get('viewer_data').hadError()) {
	  //alert ('facebook');
	if(typeof(FB) != "undefined") {
		if(typeof(FB.Connect) != "undefined") {
			FB.Connect.ifUserConnected(
				function(){
					if (document.getElementById('vv_Sign_Facebook_button_'+postId) != undefined)
					{
						document.getElementById('vv_Sign_AOL_button_'+postId).className = '';
						var user_id = FB.Connect.get_loggedInUser();
						FB.Facebook.apiClient.fql_query("SELECT name, pic_square_with_logo, current_location FROM user WHERE uid="+user_id,
									function(rows) {		
										   var string = 'Hello, '+rows[0].name+'!<br><a href="http://www.facebook.com/profile.php?id='+
													user_id+'"><img src="'+rows[0].pic_square_with_logo+'"></a><br><br>'+
													'<a href="javascript:void(0)" onclick="signOutFacebook()">Sign out</a><br><br>'+
													'Name: '+rows[0].name+
													(rows[0]['current_location']!=null ? '<br>Country: '+ rows[0]['current_location'].country : '')+
													(rows[0]['current_location']!=null ? '<br>City: '+rows[0]['current_location'].city : '');
											document.getElementById('vv_Sign_Google_button_'+postId).innerHTML = '';	
											document.getElementById('vv_Sign_AOL_button_'+postId).innerHTML = '';									
											document.getElementById('vv_Sign_Facebook_button_'+postId).innerHTML = string;
													addField('displayName',rows[0].name);
													addField('id',user_id);
													addField('profileUrl','http://www.facebook.com/profile.php?id='+user_id);
													addField('thumbnailUrl',rows[0].pic_square_with_logo);
													document.getElementById('_country_'+postId).value = (rows[0]['current_location']!=null ? rows[0]['current_location'].country : '');
													document.getElementById('_city_'+postId).value = (rows[0]['current_location']!=null ? rows[0]['current_location'].city : '');
													//document.getElementById('sign_button').innerHTML = '';
													//vv_check_email();
										 });
					}
				}, function () {
					// Create the Google sign in link
					if (document.getElementById('vv_Sign_Google_button_'+postId) != undefined) {
						google.friendconnect.renderSignInButton({'id':'vv_Sign_Google_button_'+postId,'style':'long'});
					}
					//document.getElementById("vv_Sign_Google_button").innerHTML = "<a href='#' onclick='google.friendconnect.requestSignIn()'>Add your data</a><br><br>";
					// Create the Facebook sign in link
					if (document.getElementById('vv_Sign_Facebook_button_'+postId) != undefined) {
						document.getElementById('vv_Sign_Facebook_button_'+postId).innerHTML = "<a href=\"javascript:void(0)\" onclick=\"FB.Connect.requireSession(); return false;\" class=\"fbconnect_login_button FBConnectButton FBConnectButton_Small\"><span id=\"RES_ID_fb_login_text\" class=\"FBConnectButton_Text\">Connect with Facebook</span></a>";
					}
					 //create AOL link     onclick="do_aol_auth_request();"
					if (document.getElementById('vv_Sign_AOL_button_'+postId) != undefined) {
						document.getElementById('vv_Sign_AOL_button_'+postId).innerHTML = '<a onclick="do_aol_auth_request(); window.location.href = \'#AUTHDONE\'; window.open(\'http://api.screenname.aol.com/auth/login?f=json&devId=ed1nLwllSzvWsuIa&tokenType=longterm\',\'Sign with aol\',\'height=330, width=530\');" class="vv_aol_signin_link" href="javascript:void(0)" rel="external nofollow">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>';							
						document.getElementById('vv_Sign_AOL_button_'+postId).className = 'aol_changed';
					}
				}
			);
		}
	}
	else {
		// Create the Google sign in link
		if (document.getElementById('vv_Sign_Google_button_'+postId) != undefined) {
			google.friendconnect.renderSignInButton({'id':'vv_Sign_Google_button_'+postId,'style':'long'});
		}
		//document.getElementById("vv_Sign_Google_button").innerHTML = "<a href='#' onclick='google.friendconnect.requestSignIn()'>Add your data</a><br><br>";
		// Create the Facebook sign in link
		if (document.getElementById('vv_Sign_Facebook_button_'+postId) != undefined) {
			document.getElementById('vv_Sign_Facebook_button_'+postId).innerHTML = "<a href=\"javascript:void(0)\" onclick=\"FB.Connect.requireSession(); return false;\" class=\"fbconnect_login_button FBConnectButton FBConnectButton_Small\"><span id=\"RES_ID_fb_login_text\" class=\"FBConnectButton_Text\">Connect with Facebook</span></a>";
		}
		 //create AOL link     onclick="do_aol_auth_request();"
		if (document.getElementById('vv_Sign_AOL_button_'+postId) != undefined) {
			//document.getElementById("vv_Sign_AOL_button").style.background = 'url("images/aol.gif") no-repeat';
			//document.getElementById("vv_Sign_AOL_button").style.backgroundRepeat = 'no-repeat';
			document.getElementById('vv_Sign_AOL_button_'+postId).innerHTML = '<a onclick="do_aol_auth_request(); window.location.href = \'#AUTHDONE\'; window.open(\'http://api.screenname.aol.com/auth/login?f=json&devId=ed1nLwllSzvWsuIa&tokenType=longterm\',\'Sign with aol\',\'height=330, width=530\');" class="vv_aol_signin_link" href="javascript:void(0)" rel="external nofollow">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>';
			document.getElementById('vv_Sign_AOL_button_'+postId).className = 'aol_changed';
		}
	}
  } else {
		if (document.getElementById('vv_Sign_Google_button_'+postId) != undefined) {
			if(document.getElementById('vv_Sign_Facebook_button_'+postId) != undefined)	{
				document.getElementById('vv_Sign_Facebook_button_'+postId).innerHTML = '';
			}
			if(document.getElementById('vv_Sign_AOL_button_'+postId) != undefined) {
				document.getElementById('vv_Sign_AOL_button_'+postId).className = '';
				document.getElementById('vv_Sign_AOL_button_'+postId).innerHTML = '';
			}
			var content = document.getElementById('vv_Sign_Google_button_'+postId);
		    // If the view_data is not empty, we can display the current user
		    // Create html to display the user's name, and a sign-out link.
		    var viewer = data.get('viewer_data').getData();
		   
		    var html = 'Hello, ' + viewer.getDisplayName();
		    
		    html += '<br><a href="javascript:void(0)" onclick="google.friendconnect.requestSignOut();">Sign with another social network?</a>';
			html += '<br><a href="javascript:void(0)" onclick="google.friendconnect.requestSettings(); return false;">Change your profile settings?</a><br>';
		    html += '<br><a href="' +  viewer.getField(opensocial.Person.Field.PROFILE_URL) + '">';
		    
		    html += '<img src="' + viewer.getField(opensocial.Person.Field.THUMBNAIL_URL) + '"/></a>';    
		    /*if (viewer.getField('aboutMe')) {
		      html += '<br><a href="#" onclick="google.friendconnect.requestSettings()">About you</a>:  ';
		      html += viewer.getField('aboutMe') + '<br/>';
		    } else {
		      html += '<br><a href="#" onclick="google.friendconnect.requestSettings()">';
		      html += 'Add something about you!</a><br/>';
		    }*/
		    //html += '<br>Urls about you from your profile:' + urlsAsList(viewer.getField('urls'));
		    
		    html += '<br />Your info:' + personFields(viewer);
		    
			addField('displayName', viewer.getDisplayName());
		    content.innerHTML = html;
		}
  }
}

// General utility function to list fields from the spec that are supported by the container
function personFields(viewer) {
  var field;
  var html = ' ';
  var supported = [];
  var env = opensocial.getEnvironment();
  var fields = []; 
  for (field in opensocial.Person.Field) {	  
    fields.push(field);
    if (env.supportsField(opensocial.Environment.ObjectType.PERSON, opensocial.Person.Field[field])) {
    	//alert('personFields');
      //alert(field);
	  //if (!(viewer.getField(opensocial.Person.Field[field]) == "undefined" )) {
		//html += '<br>' + opensocial.Person.Field[field] + ': ' + viewer.getField(opensocial.Person.Field[field]); 
		
    	addField(opensocial.Person.Field[field], viewer.getField(opensocial.Person.Field[field]));
    	//alert('location');
    	//html += opensocial.Person.Field[field] +':'+ viewer.getField(opensocial.Person.Field[field]);
		
		//}
	  //alert(opensocial.Person.Field[field].getField());
	  //alert( viewer.getField(opensocial.Person.Field[field]));
    }
  }
	html += get_location();
   
  return html;//supported.join('<br/>opensocial.Person.Field.');
}

// This sample shows all the fields available to this date and how to get them
function urlsAsList(urls) {
  var list = ['<ul>'];
  for (var i = 0; i < urls.length; i++) {
    var url = urls[i];
    list.push('<li><a href="');
    list.push(url.getField('address'));
    list.push('">');    
    list.push(url.getField('linkText') ? url.getField('linkText') : 'No linkText Specified');
    list.push('</a>');
    if (url.getField('type').length > 0) {
      list.push(' Type: ');
      list.push(url.getField('type'));
    }
    list.push('</li>');
  }
  list.push('</ul>');
  return list.join('');
}


function get_location(){
	var html = '';
	if (google.loader.ClientLocation) {
		var loc = google.loader.ClientLocation.address;
		document.getElementById('_country_'+postId).value = loc.country;
		html += '<br> Country:' + loc.country;
		if(loc.city != loc.region) {
			document.getElementById('_city_'+postId).value = loc.city +', '+ loc.region;
			html += '<br> City:' + loc.city + ', ' + loc.region;
		} else {
			document.getElementById('_city_'+postId).value = loc.city;
			html += '<br> City:' + loc.city;
		}
	}
	return html;
}


function addField(field,_value) {
	switch(field) {
		case 'displayName':			
			document.getElementById('_displayName_'+postId).value = _value;
			break;
		case 'id':			
			document.getElementById('_id_'+postId).value = _value;	
			break;
		case 'profileUrl':			
			document.getElementById('_profileUrl_'+postId).value = _value;		
			break;
		case 'name':			
			document.getElementById('_name_'+postId).value = _value;
			break;
		case 'nickname':			
			document.getElementById('_nickname_'+postId).value = _value;		
			break;
		case 'thumbnailUrl':			
			document.getElementById('_thumbnailUrl_'+postId).value = _value;			
			break;
		case 'email':			
			document.getElementById('_email_'+postId).value = _value;			
			break;
		default: 
			break;
	}
}