function onLinkedInAuth() {
  IN.API.Profile("me")
  	.fields(["id", "firstName", "lastName", "pictureUrl", "headline" , "location", "siteStandardProfileRequest", "industry" ,"publicProfileUrl"])
    .result( function(me) {
      var id = me.values[0].id;
      var firstName = me.values[0].firstName;
      var lastName = me.values[0].lastName;
      var pictureUrl = me.values[0].pictureUrl;
      var headline = me.values[0].headline;
      var locationName = me.values[0].location.name;
      var locationCountry = me.values[0].location.country.code;
      var publicProfileUrl = escape(me.values[0].publicProfileUrl);
      var standardProfileUrl = escape(me.values[0].siteStandardProfileRequest.url);
      var industry = me.values[0].industry;
      //alert(JSON.stringify(me));
      //alert("pp url: "+publicProfileUrl);
      //alert(id+"\n"+ me.values[0].firstName + "\n" + me.values[0].lastName + "\n" +publicProfileUrl);	     	
			$.ajax({
				type: "POST",
				data: "cmd=doLogin&id="+id+"&firstName="+firstName+"&lastName="+lastName+"&pictureUrl="+pictureUrl+"&headline="+headline+"&locationName="+locationName+"&locationCountry="+locationCountry+"&publicProfileUrl="+publicProfileUrl+"&standardProfileUrl="+standardProfileUrl+"&industry="+industry+"",
				url: "ajax_login_handler.php",
				success: function(msg){
					if(msg == "errorurl"){
						alert("An error has occured.");
					}else{
						//alert(msg);
						$("#inlogMenu").html("<span class=\"msg\"><a href=\""+currentPage+"?loggoff=1\">Log off</a></span> | <span class=\"msg\">"+msg+"</span>");
						window.location.reload();
					}		
				}
			});       
    });
}


